var xmlHttp
 
var divId;
var helpId;
var regFieldName;

function getFileContent(filename,id)
{
	divId ="helppage";
	helpId=id;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../helpers/getFileContent.php?filename=";
	url=url+filename;

	xmlHttp.onreadystatechange=helpStateChanged;
	xmlHttp.open("GET",url,true);
	
	xmlHttp.send(null);
}
function getFileContentHighlighted(filename,id,keyword)
{
	divId ="helppage";
	helpId=id;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../helpers/getFileContentHighlighted.php?filename=";
	url=url+filename+"&keyword="+keyword;

	xmlHttp.onreadystatechange=helpStateChanged;
	xmlHttp.open("GET",url,true);
	
	xmlHttp.send(null);
}
function getStandardPlans(countryId)
{
	divId ="standardplan1";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../../helpers/getStandardPlansForCountry.php?countryId=";
	url=url+countryId;
	//alert(url);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	
	xmlHttp.send(null);
}

function getRecordCount(recordcnt)
{
	divId ="recordcount";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	//var url="../../helpers/getStandardPlansForCountry.php?countryId=";
	//url=url+countryId;
	//alert(url);
	xmlHttp.onreadystatechange=stateRecordChanged;
	xmlHttp.open("GET",url,true);
	
	xmlHttp.send(null);
}
 
function getSubmodules(moduleid)
{
	divId ="submodule1";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../../helpers/getSubmodule.php?module=";
	url=url+moduleid;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	
	xmlHttp.send(null);
}

function getBannerPanel(groupid)
{
	divId ="sizeandspace1";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../../helpers/getBannerPanel.php?groupid=";
	url=url+groupid;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	
	xmlHttp.send(null);
}

function getMetaSubmodules(moduleid)
{
	divId ="submodule1";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../../helpers/getMetaSubmodule.php?module=";
	url=url+moduleid;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	
	xmlHttp.send(null);
}

function getSections(submoduleid)
{
	divId ="section1";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../../helpers/getSection.php?submodule=";
	url=url+submoduleid;
	//alert(url);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	
	xmlHttp.send(null);
}

function getMetaSections(submoduleid)
{
	divId ="section1";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../../helpers/getMetaSection.php?submodule=";
	url=url+submoduleid;
	//alert(url);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	
	xmlHttp.send(null);
}

function getFiles(sectionid)
{
	divId ="files1";
	var submodulename = document.getElementById("submodule").value;
	var splitval = submodulename.split("|");
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../../helpers/getFiles.php?sectionid=";
	url=url+sectionid+"&modulename="+splitval[0]+"&submodulename="+splitval[1];
	//alert(url);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	
	xmlHttp.send(null);
}

function getMultipleStates()
{
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	
	searchform =document.getElementById('advancesearchform');
	cnt=0;
	tempCntryStr="";
	for(i=0; i<searchform.country.length; i++) 
	{
		if(searchform.country[i].selected) 
		{
			if(cnt==0)
			{
				tempCntryStr = tempCntryStr + searchform.country[i].value;
			}
			else
			{
				tempCntryStr = tempCntryStr + ',' + searchform.country[i].value;
			}
			cnt++;
		}
		
	}
	divId ="state1";
	
	var url="helpers/getAdvanceProvince.php?country=";
	url=url+tempCntryStr;
	//alert(url);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	
	xmlHttp.send(null);
}

function getMultipleCity()
{
	xmlHttp=GetXmlHttpObject()
	
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	
	searchform =document.getElementById('advancesearchform');
	cnt=0;
	tempStateStr="";
	for(i=0; i<searchform.state.length; i++) 
	{
		if(searchform.state[i].selected) 
		{
			if(cnt==0)
			{
				tempStateStr = tempStateStr + searchform.state[i].value;
			}
			else
			{
				tempStateStr = tempStateStr + ',' + searchform.state[i].value;
			}
			cnt++;
		}
		
	}
	//alert(tempStateStr);
	divId ="city1"; 

	 
	var url="helpers/getAdvanceCity.php?state=";
	url=url+tempStateStr;
	//alert(url);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}  

function getSearchCountry(regionId)
{
	divId ="country1";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../helpers/getCountry.php?region=";
	url=url+regionId;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	
	xmlHttp.send(null);
} 

function getState(countryId)
{
	divId ="state1";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../helpers/getProvince.php?country=";
	url=url+countryId;
	//alert(url);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	
	xmlHttp.send(null);
}

function getVariableState(countryId)
{
	divId ="state1";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../helpers/getVariableProvince.php?country=";
	url=url+countryId;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	
	xmlHttp.send(null);
}

function getSBVariableState(countryId)
{
	divId ="state1";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../helpers/getSBVariableProvince.php?country=";
	url=url+countryId;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	
	xmlHttp.send(null);
}
 
function getSearchState(countryId)
{
	divId ="state1";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../helpers/getSearchProvince.php?country=";
	url=url+countryId;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	
	xmlHttp.send(null);
} 

function getHomeState(countryId)
{
	divId ="statehome";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="helpers/getHomeProvince.php?country=";
	url=url+countryId;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	
	xmlHttp.send(null);
} 
 
function getCity(provinceId)
{
	divId ="city1"; 

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../helpers/getCity.php?state=";
	url=url+provinceId;
	//alert(url);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function getAlertState(countryId)
{
	divId ="state1";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../helpers/getAlertProvince.php?country=";
	url=url+countryId;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	
	xmlHttp.send(null);
}
 
function getAlertCity(provinceId)
{
	divId ="city1"; 

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../helpers/getAlertCity.php?state=";
	url=url+provinceId;

	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function getVariableCity(provinceId)
{
	divId ="city1"; 

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../helpers/getVariableCity.php?state=";
	url=url+provinceId;

	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function getSBVariableCity(provinceId)
{
	divId ="city1"; 

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../helpers/getSBVariableCity.php?state=";
	url=url+provinceId;

	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function getSearchCity(provinceId)
{
	divId ="city1"; 

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../helpers/getSearchCity.php?state=";
	url=url+provinceId;

	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
} 

function getSubCategory(catId)
{
	divId ='subcategory1'; 
	if (catId == '')
	{ 
		document.getElementById(divId).innerHTML="";
		return;
	}
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../helpers/getSubCategory.php?catId=";
	url=url+catId;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}


function getAlertSubCategory(catId)
{
	divId ='subcategory1'; 
	if (catId == '')
	{ 
		document.getElementById(divId).innerHTML="";
		return;
	}
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../helpers/getAlertSubCategory.php?catId=";
	url=url+catId;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function getVariableSubCategory(catId)
{
	divId ='subcategory1'; 
	if (catId == '')
	{ 
		document.getElementById(divId).innerHTML="";
		return;
	}
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="../helpers/getVariableSubCategory.php?catId=";
	url=url+catId;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
 
function getAdvanceSubCategory(catId)
{
	divId ='subcategory1'; 
	if (catId == '')
	{ 
		document.getElementById(divId).innerHTML="";
		return;
	}
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	}
	//alert("Hello");
	var url="helpers/getAdvanceSubCategory.php?catId=";
	url=url+catId;
	//alert(url);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
} 
 
function getHomeSubCategory(catId)
{
	divId ='subcategoryhome'; 
	if (catId == '')
	{ 
		document.getElementById(divId).innerHTML="";
		return;
	}
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
	var url="helpers/getHomeSubcategory.php?catId=";
	url=url+catId;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function submitAddMyJobsRequest(selstr, cnt, sessid)
{
	divId="myjobheaderdiv";
	helpId = cnt;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	    alert ("Your browser does not support AJAX!");
	    return;
	}
	var url="../helpers/getMyJobs.php?selstr=";
	url=url + selstr + "&sess_id=" + sessid;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
 
function stateChanged() 
{ 	
	if (xmlHttp.readyState==4)
	{
		if (xmlHttp.status == 200)
		{
			document.getElementById(divId).innerHTML=xmlHttp.responseText;
			if(divId=='statehome')
				$('#state').sSelect({ddMaxHeight: '90px'});
			if(divId=='subcategoryhome')
				$('#subcategory').sSelect({ddMaxHeight: '55px'});
			if(divId=='countryhome')
				$('#country').sSelect({ddMaxHeight: '120px'});
			if(divId=='myjobheaderdiv')
			{
				document.getElementById('addjobdiv'+helpId).style.display = 'none';
				document.getElementById('removejobdiv'+helpId).style.display = 'block';
			}
		}
		else 
		{
			alert("There was a problem while using XMLHTTP:\n" + xmlHttp.statusText);
		}
	}
}

function stateRecordChanged() 
{ 	
	if (xmlHttp.readyState==4)
	{
		if (xmlHttp.status == 200)
		{
			//alert(xmlHttp.responseText);
			document.getElementById(divId).innerHTML='Saved Resumes('+recordcnt+')';
		}
		else 
		{
			alert("There was a problem while using XMLHTTP:\n" + xmlHttp.statusText);
		}
	}
}

 
function helpStateChanged() 
{ 	
	if (xmlHttp.readyState==4)
	{
		if (xmlHttp.status == 200)
		{
			document.getElementById(divId).innerHTML=xmlHttp.responseText;
			for(i=1;i<=26;i++)
			{
				tempstr = 'm'+i;
				if(tempstr==helpId)
				{
					if(navigator.appName=="Microsoft Internet Explorer")
					{
						document.getElementById(helpId).setAttribute('className','selectedmenu');
					}
					else
					{
						document.getElementById(helpId).setAttribute('class','selectedmenu');
					}
				}
				else
				{
					if(navigator.appName=="Microsoft Internet Explorer")
					{
						document.getElementById(tempstr).setAttribute('className','unselectedmenu');
					}
					else
					{
						document.getElementById(tempstr).setAttribute('class','unselectedmenu');
					}
				}
			}
		}
		else 
		{
			alert("There was a problem while using XMLHTTP:\n" + xmlHttp.statusText);
		}
	}
}

function GetXmlHttpObject()
{

var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  
return xmlHttp;
}


function getHomeSearchCountry(regionId)
{
	divId ="countryhome";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	}
	var url="helpers/getHomeCountry.php?region=";
	url=url+regionId;
	//alert( url );
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);

	xmlHttp.send(null);
}


function validateRegisterField(fieldName, fieldValue, fieldSpan)
{
	divId =fieldSpan;
	regFieldName = fieldName;
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	}
	var url="../helpers/pull_lib.php?cmd=";
	url=url + fieldName + "&val=" + fieldValue;
	//alert( url );
	xmlHttp.onreadystatechange=stateValidateRegisterChanged;
	xmlHttp.open("GET",url,true);

	xmlHttp.send(null);
}


function stateValidateRegisterChanged()
{
	if (xmlHttp.readyState==4)
	{
		if (xmlHttp.status == 200)
		{
			if(xmlHttp.responseText != '')
			{
				responseArray = xmlHttp.responseText.split(':');

				document.getElementById(regFieldName + 'reqerr').value =  '';
				document.getElementById(regFieldName + 'invaliderr').value = '';
				document.getElementById(regFieldName + 'availableerr').value = '';
				
				if(responseArray[1] == '1' )
					document.getElementById(regFieldName + 'reqerr').value =  responseArray[0];
				else if(responseArray[1] == '2')
					document.getElementById(regFieldName + 'invaliderr').value =  responseArray[0];
				else if(responseArray[1] == '3' )
					document.getElementById(regFieldName + 'availableerr').value =  responseArray[0];

				document.getElementById(divId).innerHTML = '<img src="../gifs/icon_wrong.gif" />';
			}
			else
			{
				document.getElementById(divId).innerHTML = '<img src="../gifs/right_icon.gif" />';
				document.getElementById(regFieldName + 'reqerr').value =  '';
				document.getElementById(regFieldName + 'invaliderr').value = '';
				document.getElementById(regFieldName + 'availableerr').value = '';
			}

			var errorStr = generateRegErrors();
			
			if( errorStr != '' )
			{
					document.getElementById('regerrortop').style.display = 'block';
					document.getElementById('regerror').style.display = 'block';
					document.getElementById('regerrorbottom').style.display = 'block';
					document.getElementById('regerror').innerHTML = errorStr;
			}
			else
			{
					document.getElementById('regerrortop').style.display = 'none';
					document.getElementById('regerror').style.display = 'none';
					document.getElementById('regerrorbottom').style.display = 'none';
			}
			
		}
		else
		{
			alert("There was a problem while using XMLHTTP:\n" + xmlHttp.statusText);
		}
	}
}

function generateRegErrors()
{
	tempStr = '';
	fieldArray = new Array('username', 'firstname', 'lastname', 'email', 'password', 'securityanswer','securityquestion','code','terms');

	errorArray = new Array();

	for(i=0;i<fieldArray.length;i++)
	{
		reqErrValue = document.getElementById(fieldArray[i] + 'reqerr').value;
		invalidErrValue = document.getElementById(fieldArray[i] + 'invaliderr').value;
		availErrValue = document.getElementById(fieldArray[i] + 'availableerr').value;

		if( reqErrValue != '')
			errorArray.push(reqErrValue);
		if( invalidErrValue != '')
			errorArray.push(invalidErrValue);
		if( availErrValue != '')
			errorArray.push(availErrValue);
	}

	if( errorArray.length > 0 )
		tempStr = errorArray.join("<br>");

	return tempStr;
}


