function navigateSearchResults(formName, actionPage, startRow){
	// Set the startRow variable in the form
	if(startRow){
		document[formName].startRow.value = startRow;
	}	
	
	submitForm(formName, actionPage);
}

function orderColumnSearchResults(formName, actionPage, sortColumn){
	// Set the sortColumn variable in the form (and reset startRow to 1)
	if(sortColumn){
		document[formName].sortColumn.value = sortColumn;
		document[formName].startRow.value = 1;
	}	
	
	submitForm(formName, actionPage);
}

function submitForm(formName, actionPage){
	// Adjust the action page
	if(actionPage){
		document[formName].action = actionPage;
	}
	document[formName].submit();
}

function undoFormSearchCriteria(formName,undoFieldList,newValueList)
{
	//alert('hello');
	var undoFieldSplit = undoFieldList.split(',');
	var newValueSplit = newValueList.split(',');
	for(i=0; i<undoFieldSplit.length; i++)
	{
		targetFormField = eval('document.'+formName+'.'+undoFieldSplit[i]);
		if(newValueSplit[i]=='emptyString')
			targetFormField.value='';
		else
			targetFormField.value=newValueSplit[i];
			//alert(targetFormField.value);
	}
	targetFormField.form.submit();
}

function updateFormSearchCriteria(formName,undoField,removeValue)
{
	targetFormField = eval('document.'+formName+'.'+undoField);
	var oldValueSplit = targetFormField.value.split(',');
	var newValue = '';
	for(c=0; c<oldValueSplit.length; c++)
	{
		if(oldValueSplit[c]!=removeValue)
			newValue = newValue.length > 0? newValue+','+oldValueSplit[c] : oldValueSplit[c];
	}
	newValue = newValue.length > 0? newValue : 0;
	targetFormField.value=newValue;
	targetFormField.form.submit();	
}

$(document).ready(function(){
	/* FUNCTION ONCLICK Create Email Alert Button
	 * substitution >> href="javascript:document.jobSearchResultsToCreateMySearches.submit();"
	 ************************************/	
	$('a.btnEmailIcon').click(function() {
	  $('#jobSearchRsltToCreateMySearches').submit();
	  return false;
	});	
	
	/* FUNCTION ONCLICK Advanced Search Localitons - US - RadioButtons (US & GLOBAL)
	 * substitution >> onClick="document.forms.profileform.iCountry.selectedIndex=-1;toggleLayerOn('USTab');toggleLayerOff('GlobalTab');document.forms.profileform.sUSLocationWhichTab.value = 'US';"
	 * substitution >> onClick="toggleLayerOn('GlobalTab');toggleLayerOff('USTab');document.forms.profileform.sUSLocationWhichTab.value = 'Global';"
	 ************************************/	
	$('label#usLocLabel input#usLoc').click(function() {
	  document.forms.profileform.iCountry.selectedIndex=-1;
	  toggleLayerOn('USTab');
	  toggleLayerOff('GlobalTab');
	  document.forms.profileform.sUSLocationWhichTab.value = 'US';
	});	
	$('label#globalLocLabel input#globalLoc').click(function() {
	  toggleLayerOn('GlobalTab');
	  toggleLayerOff('USTab');
	  document.forms.profileform.sUSLocationWhichTab.value = 'Global';
	});	
	
	/* FUNCTION ONBLUR ONFOCUS & ONKEYUP Advanced Search Localitons - US - Textbox City & State or Zip 
	 * substitution >> onblur="bHasFocusFreetext=false;"  
	 * substitution >> onfocus="bHasFocusFreetext=true; iAjaxElem = 0; objAjaxElem = this;"
	 * substitution >> onkeyup="bHasFocusFreetext=true; iAjaxElem = 0; objAjaxElem = this;")
	 ************************************/		
	$('span#radiusSpan input#sRadiusLocation').keyup(function() {	
		bHasFocusFreetext=true; 
		iAjaxElem = 0; 
		objAjaxElem = this;
	});
	$('span#radiusSpan input#sRadiusLocation').focus(function() {	
		bHasFocusFreetext=true; 
		iAjaxElem = 0; 
		objAjaxElem = this;
	});	
	$('span#radiusSpan input#sRadiusLocation').blur(function() {
		bHasFocusFreetext=false;
	});
    
});