function doSearchLog(iRandom, sResumeId, iCnt, sParam, sSource)
{
	var callbackLog = {};
	var sUrl = dPath + "/search/resume-search-log.php?rnd="+iRandom+"&cnt="+iCnt+"&ri="+sResumeId + "&ssrc=" + sSource + "&" + sParam;
	
	//Optional to assign timeout in ms.
	callbackLog.timeout = 8000; 
	//Do request
	var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callbackLog, null);  
}


/* Start Keyword Input Control */
function boldKeywordHint()
{
	oCtrl = getEl('key');
	oCtrl.style.fontWeight = 'bold';
}

function unBoldKeywordHint()
{
	oCtrl = getEl('key');
	oCtrl.style.fontWeight = 'normal';
}

function onFocusKeywordInput(oCtrl)
{
	if(oCtrl.value != 'Keywords') return;
	oCtrl.value = "";
	unBoldKeywordHint();
}

function onBlurKeywordInput(oCtrl)
{
	if(oCtrl.value != '') return;
	oCtrl.value = "Keywords";
	boldKeywordHint();
}

function boldCityHint()
{
	oCtrl = getEl('loc');
	oCtrl.style.fontWeight = 'bold';
}

function unBoldCityHint()
{
	oCtrl = getEl('loc');
	oCtrl.style.fontWeight = 'normal';
}

function onFocusCityInput(oCtrl)
{
	if(oCtrl.value != 'You can enter multiple cities') return;
	oCtrl.value = "";
	unBoldCityHint();
}

function onBlurCityInput(oCtrl)
{
	if(oCtrl.value != '') return;
	oCtrl.value = "You can enter multiple cities";
	boldCityHint();
}
/* End Keyword Input Control */

/* Start Advance Search*/
function doAdvanceSearch(sUrl)
{	
	oCtrl = getEl('key');		
	if(oCtrl.value == "Keywords") oCtrl.value = "";

	oCtrl = getEl('loc');		
	if(oCtrl.value == "You can enter multiple cities") oCtrl.value = "";

	//Advance search possible param
	var sParam = "";
	sParam = sParam + asGetText('key');
	sParam = sParam + asGetAllList('country');
	sParam = sParam + asGetText('loc');	
	sParam = sParam + asGetCBList('pos-lvl', 1);
	sParam = sParam + asGetCBList('emp', 1);
	sParam = sParam + asGetText('qua', true);
	sParam = sParam + asGetText('nal', true);
	sParam = sParam + asGetText('yoe-min', true);
	sParam = sParam + asGetText('yoe-max' , true);
	sParam = sParam + asGetText('last-update', true);
		
	if(sParam != "") 
	{
		sParam = sParam.substring(1, sParam.length);		
		sUrl = sUrl + '?' + sParam;
	}
	
	document.location.href = sUrl;	
}

function getEl(sId) 
{ 
	return document.getElementById(sId); 
}

function asGetText(sKey, bSelectList)
{
	if(typeof(bSelectList) == 'undefined') bSelectList = false;
	oCtrl = getEl(sKey);
	if(oCtrl != null) 
	{
		sVal = trim(oCtrl.value);
		if(bSelectList && sVal== '-1') return '';
		if(sVal != "") return '&' + sKey + '=' + asUrlEncode(sVal);
	}
	return '';
}

function asGetCBList(sKey, bArray)
{
	sCtrl = sKey;
	if(typeof(bArray) !='undefined' && bArray == 1) sCtrl = sCtrl + '[]';
	oCtrl = document.getElementsByName(sCtrl);
	var sParam = '';
    for (i = 0; i < oCtrl.length; i++) {
		if(oCtrl[i].checked && oCtrl[i].disabled == false && oCtrl[i].value != "" && oCtrl[i].value != "-1")
		{
			sParam = sParam + oCtrl[i].value + ',';
		}	
    }
	if(sParam != '')
	{
		sParam = sParam.substring(0, sParam.length-1);	
		sParam = '&' + sKey + '=' + asUrlEncode(sParam);
	}
	return sParam;
}

function asGetAllList(sKey)
{
	sCtrl = sKey;
	oCtrl = getEl(sCtrl);
	
	if(typeof(oCtrl.options)=='undefined') return '';

	var sParam = '';
	for(var i = 0; i < oCtrl.options.length; i++)
	{
		if(oCtrl.options[i].value == '-1') continue;
		sParam = sParam + oCtrl.options[i].value + ',';
	}	

	if(sParam != '')
	{
		sParam = sParam.substring(0, sParam.length-1);	
		sParam = '&' + sKey + '=' + asUrlEncode(sParam);
	}
	return sParam;
}

function asGetHidden(sKey)
{
	oCtrl = document.getElementsByName(sKey);
	var sParam = '';
    for (i = 0; i < oCtrl.length; i++) {		
		sParam = sParam + oCtrl[i].value;			
    }	
	if(sParam != '')
	{		
		sParam = '&' + sKey + '=' + sParam;
	}
	return sParam;
}

function asUrlEncode(str)
{
	var ret = str;     
	ret = ret.toString();    
	ret = encodeURIComponent(ret);    
	ret = ret.replace(/%20/g, '+');     
	return ret;
	//return escape(str).replace(/\+/g,'%2B').replace(/%20/g, '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40');
}
/* End Advance Search*/

/* Change Country*/
function addCountry()
{
	oCountryOpt = getEl('country-opt');
	var i;
	for (i = 0; i < oCountryOpt.length; i++) 
	{
		if (oCountryOpt.options[i].selected) 
		{
			sCountry = oCountryOpt.options[i].text;
			iCountryCode = oCountryOpt.options[i].value;

			oCountry = getEl('country');
			addListBox(oCountry, iCountryCode, sCountry);
		}
	}
}

function removeCountry()
{
	oCountry = getEl('country');
	var i;
	for (i = oCountry.length - 1; i>=0; i--) 
	{
		if (oCountry.options[i].selected) 
		{
			iCountryCode = oCountry.options[i].value;	
			if(iCountryCode >=0) removeListBox(oCountry, iCountryCode);	
		}
	}
}
/* End Change Country*/

/* Dynamic List Box Control*/
function addListBox(oCtrl, sValue, sText)
{
	if(typeof(oCtrl) != 'object') return;
	
	//Check in List
	bInList = false;
	for(var i = oCtrl.options.length - 1; i >=0; i--)
	{
		if(oCtrl.options[i].value == sValue)
		{
			bInList = true;
			break;
		}	
	}	

	//Add list if not in list
	if(bInList == false)
	{
		if(typeof(oCtrl.options)!='undefined')
		{
			oCtrl.options.add(new Option(sText,sValue,true,false));
		}
	}
}

function removeListBox(oCtrl, sValue)
{
	if(typeof(oCtrl) != 'object') return;
	
	//Check in List
	bMove = false;
	for(var i = 0 ; i < oCtrl.options.length; i++)
	{
		if(oCtrl.options[i].value == sValue)
		{
			bMove = true;			
		}

		if(bMove)
		{
			oCtrl.options[i] = null;
			if(typeof(oCtrl.options[i + 1]) != 'undefined' ) 
			{
				oCtrl.options.add(new Option(oCtrl.options[i + 1].text,oCtrl.options[i + 1].value,true,false));				
			}			
		}
	}	

}

function resetListBox(oCtrl)
{
	if(typeof(oCtrl) != 'object') return;
	
	for(var i = oCtrl.options.length - 1; i >=0;i--)
	{
		oCtrl.options[i] = null;
	}	
}
/* End Dynamic List Box Control*/
