function openWindow(strUrl, iWidth, iHeight)
{
	var width=iWidth-10;
	var height=iHeight-10;
	var LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
	
	if(iHeight<screen.height)
	{
		window.open(strUrl,'OpenWindow','top='+TopPosition+',left='+LeftPosition+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+'').focus();
	}
	else
	{
		window.open(strUrl,'OpenWindow','top='+TopPosition+',left='+LeftPosition+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+'').focus();
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function addToFavorites() 
{ 
	var urlAddress = window.location.href;
		var pageName = "careerlink.com.vn- Tim Viec Lam va Tuyen Dung"
		if( document.all ) 
        { //MSIE
                window.external.AddFavorite(urlAddress, pageName);
        }
        else if (window.sidebar) 
        { // firefox
              window.sidebar.addPanel(pageName, urlAddress,"");
        } 
        else
        {
               alert("Sorry, your browser doesn't support this");
         }
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function openWindowNoResize(strUrl, iWidth, iHeight)
{
	var width=iWidth-10;
	var height=iHeight-10;
	var LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
	
	if(iHeight<screen.height)
	{
		window.open(strUrl,'OpenWindow','top='+TopPosition+',left='+LeftPosition+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+width+',height='+height+'').focus();
	}
	else
	{
		window.open(strUrl,'OpenWindow','top='+TopPosition+',left='+LeftPosition+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+width+',height='+height+'').focus();
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function openEditor(returnControl, imageFolder, strUrl)
{
	window.open(strUrl + "?control=" + returnControl + "&folder="  + imageFolder,'AQContextHelp','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=680,height=400').focus();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Check All function
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function checkAll(coltrolName, target)
{
	var iIndex = 1;
	for (i = 0; i < document.frmForm.elements.length; i++)
	{	
		e = document.frmForm.elements[i];
		if ((e.name == coltrolName) && (e.disabled == false))
		{
			e.checked = target.checked;
			var trRow = document.getElementById("trRow" + iIndex);
			if(target.checked)
			{
				trRow.bgColor = "#CEDAEF";
			}
			else
			{
				trRow.bgColor = "#FFFFFF";
			}
		}
		if ((e.name == coltrolName))
		{
			iIndex++;
		}
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Check All function
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function changeSalary(target)
{
	alert(target.value);
	//document.getElementById("cbMoneyRateIDFrom").value = target.value;
	//document.getElementById("cbMoneyRateIDTo").value = target.value;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Check All function
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function checkAllEx(coltrolName,trName, target)
{
	var iIndex = 1;
	for (i = 0; i < document.frmForm.elements.length; i++)
	{	
		e = document.frmForm.elements[i];
		if ((e.name == coltrolName) && (e.disabled == false))
		{
			e.checked = target.checked;
			var trRow = document.getElementById(trName + iIndex);
			if(target.checked)
			{
				trRow.bgColor = "#CEDAEF";
			}
			else
			{
				trRow.bgColor = "#FFFFFF";
			}
		}
		if ((e.name == coltrolName))
		{
			iIndex++;
		}
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Check All function
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function swapImage(divName, strUrl)
{
	var strImageText = "<img src=\"" + strUrl + "\">";
	document.getElementById(divName).innerHTML = strImageText;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Check All function
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function buyNow(coltrolName,cbProductOption,strUrl)
{
	var iIndex = 1;
	for (i = 0; i < document.frmForm.elements.length; i++)
	{	
		e = document.frmForm.elements[i];
		if ((e.name == coltrolName) && (e.disabled == false))
		{
			strUrl = strUrl + "&pid[]=" + e.value;
		}
		if ((e.name == cbProductOption) && (e.disabled == false))
		{
			strUrl = strUrl + "&" + cbProductOption + "[]=" + e.value;
		}
	}
	window.location.href=strUrl;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function moveMe(iCurrentID)
{
	document.frmForm.hCurrentID.value = iCurrentID;
	return true;
}
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function changeComboAppend(target, queryKey, queryValue, strUrl)
{
	//
	strUrl = strUrl + "&" + queryKey + "=" + target.value
	window.location.href=strUrl;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function checkSelect(target, iIndex)
{
	var trRow = document.getElementById("trRow" + iIndex);
	if(target.checked)
	{
		trRow.bgColor = "#CEDAEF";
	}
	else
	{
		trRow.bgColor = "#FFFFFF";
	}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function displayObject(objectName,imageName)
{
	var isShow = true;
	if(document.getElementById(objectName).style.display == "")
	{
		isShow = false;
	}
	if(isShow)
	{
		document.getElementById(objectName).style.display = "";
		document.getElementById(imageName).src = "/images/public/minus_button.gif";
	}
	else
	{
		document.getElementById(objectName).style.display = "none";
		document.getElementById(imageName).src = "/images/public/plus_button.gif";
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function checkSelectEx(target, rowName, iIndex)
{
	var trRow = document.getElementById(rowName + iIndex);
	if(target.checked)
	{
		trRow.bgColor = "#CEDAEF";
	}
	else
	{
		trRow.bgColor = "#FFFFFF";
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function changeComboBox(target, queryKey, queryValue, strUrl)
{
	strUrl = strUrl.toLowerCase();
	queryKey = queryKey.toLowerCase();
	queryValue = queryValue.toLowerCase();
	if(strUrl.indexOf("&" + queryKey + "=") > 0)
	{
		
		strUrl = strUrl.replace("&" + queryKey + "=" + queryValue, "&" + queryKey + "=" + target.value);
		
	}
	else
	{
		strUrl = strUrl + "&" + queryKey + "=" + target.value
	}
	window.location.href=strUrl;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function URLEncode(str)
{
	var ms = "%25#23 20?3F<3C>3E{7B}7D[5B]5D|7C^5E~7E`60+2B"
	var msi = 0
	var i,c,rs,ts
	while (msi < ms.length)
	{
		c = ms.charAt(msi)
		rs = ms.substring(++msi, msi +2)
		msi += 2
		i = 0
		while (true)
		{
			i = str.indexOf(c, i)
			if (i == -1) break
			ts = str.substring(0, i)
			str = ts + "%" + rs + str.substring(++i, str.length)
		}
	}
	str = str.replace("+","%2B");
	str = str.replace("&","%26");
	return str
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function actionMe(strAlertMessage, strMustSelectMessage)
	{
		var count = 0;
		var strAlert = "";
		for (i = 0; i < document.frmForm.elements.length; i++)
		{	
			e = document.frmForm.elements[i];
			if (e.name == "ckSelect[]" && e.checked == true)
			{
				count++;
			}
		}
		if (count > 0)
			if(strAlert != "")
			{
				alert(strAlert);
				return false;
			}
			else
			{
				strAlertMessage = strAlertMessage.replace("{Count}",count);
				return confirm(strAlertMessage)
			}
		else
		{
			alert(strMustSelectMessage);
			return false;
		}
	}
	
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function actionMeControl(controlName,strAlertMessage, strMustSelectMessage)
	{
		var count = 0;
		var strAlert = "";
		for (i = 0; i < document.frmForm.elements.length; i++)
		{	
			e = document.frmForm.elements[i];
			if (e.name == controlName && e.checked == true)
			{
				count++;
			}
		}
		if (count > 0)
			if(strAlert != "")
			{
				alert(strAlert);
				return false;
			}
			else
			{
					strAlertMessage = strAlertMessage.replace("{Count}",count);
					return confirm(strAlertMessage);
			}
		else
		{
			alert(strMustSelectMessage);
			return false;
		}
	}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function actionMeControlEx(controlName,strAlertMessage, strMustSelectMessage)
{
	var count = 0;
	var strAlert = "";
	for (i = 0; i < document.frmForm.elements.length; i++)
	{	
		e = document.frmForm.elements[i];
		if (e.name == controlName && e.checked == true)
		{
			count++;
		}
	}
	if (count > 0)
		if(strAlert != "")
		{
			alert(strAlert);
			return false;
		}
		else
		{
			strAlertMessage = strAlertMessage.replace("{Count}",count);
			return confirm(strAlertMessage)
		}
	else
	{
		alert(strMustSelectMessage);
		return false;
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	function actionMeAppend(strAlertMessage, strMustSelectMessage, appendMessage)
	{
		var count = 0;
		var strAlert = "";
		for (i = 0; i < document.frmForm.elements.length; i++)
		{	
			e = document.frmForm.elements[i];
			if (e.name == "ckSelect[]" && e.checked == true)
			{
				count++;
			}
		}
		if (count > 0)
			if(strAlert != "")
			{
				alert(strAlert);
				return false;
			}
			else
			{
				strAlertMessage = strAlertMessage.replace("{Count}",count);
				return confirm(strAlertMessage)
			}
		else
		{
			alert(strAlertMessage);
		}
	}
	/////////////////////////////////////////////////////////////////////////////////////
	//
	/////////////////////////////////////////////////////////////////////////////////////
	function addNew()
	{
		if(document.frmForm.hTable.value == "")
		{
			document.frmForm.hTable.value = document.getElementById("tdTable").innerHTML;
		}
		var strTable = document.getElementById("tdTable").innerHTML;
		strTable = strTable + document.frmForm.hTable.value;
		document.getElementById("tdTable").innerHTML = strTable;
		
	}
	/////////////////////////////////////////////////////////////////////////////////////
	//
	/////////////////////////////////////////////////////////////////////////////////////
	function unDo()
	{
		var strTable = document.getElementById("tdTable").innerHTML;
		var arrTable = strTable.split("<!--BEGIN-->");
		var strNewTable = "";
		if(arrTable.length > 1)
		{
			for(i = 0; i < (arrTable.length -1); i++)
			{
				strNewTable = strNewTable + "<!--BEGIN-->" + arrTable[i];
			}
			document.getElementById("tdTable").innerHTML = strNewTable;
		}
		else
		{
			alert("Can not remove");
		}
	}	
	
	
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function changeCountry(target,ProvinceComboboxName,ProvinceDivID,DistrictComboboxName,DistrictDivID)
		{
			var CountryCode = target.value;
			var iIndex = GetArrayIndex(arrCountryArray,CountryCode);
			var strProvinceControl = "";
			if(iIndex >= 0)
			{
				var strListProvinceCode = arrProvinceListArrayCode[iIndex]
				var strListProvinceName = arrProvinceListArrayName[iIndex]
				var arrProvinceCode = strListProvinceCode.split("|");
				var arrProvinceName = strListProvinceName.split("|");
				if(arrProvinceCode.length > 0)
				{
					strProvinceControl = strProvinceControl + "<select  class=\"TEXTBOX\" id=\"" + ProvinceComboboxName + "\" name=\"" + ProvinceComboboxName + "\" onchange=\"changeProvince(this,'" + DistrictComboboxName + "','" + DistrictDivID + "')\">";
					for(i = 0; i < arrProvinceCode.length;i++)
					{
						strProvinceControl = strProvinceControl + "<option value=\"" + arrProvinceCode[i] + "\">" + arrProvinceName[i] + "</option>";
					}
					strProvinceControl = strProvinceControl + "</select>";
				}
			}
			else
			{
				strProvinceControl = strProvinceControl + "<select  class=\"TEXTBOX\" id=\"" + ProvinceComboboxName + "\" name=\"" + ProvinceComboboxName + "\">";
				strProvinceControl = strProvinceControl + "<option value=\"\">---</option>";
				strProvinceControl = strProvinceControl + "</select>";
				document.getElementById(DistrictDivID).innerHTML = strProvinceControl;
			}
			document.getElementById(ProvinceDivID).innerHTML = strProvinceControl;
		}
		////////////////////////////////////////////////////////////////////////////////////
		//
		////////////////////////////////////////////////////////////////////////////////////
		function changeProvince(target,DistrictComboboxName,DistrictDivID)
		{
			var ProvinceCode = target.value;
			var iIndex = GetArrayIndex(arrProvinceArray,ProvinceCode);
			
			var strDistrictControl = "";
			if(iIndex >= 0)
			{
				var strListDistrictCode = arrDistrictListArrayCode[iIndex]
				var strListDistrictName = arrDistrictListArrayName[iIndex]
				var arrDistrictCode = strListDistrictCode.split("|");
				var arrDistrictName = strListDistrictName.split("|");
				if(arrDistrictCode.length > 0)
				{
					strDistrictControl = strDistrictControl + "<select class=\"TEXTBOX\" id=\"" + DistrictComboboxName + "\" name=\"" + DistrictComboboxName + "\" onchange=\"changeProvince(this,'" + DistrictComboboxName + "','" + DistrictDivID + "')\">";
					for(i = 0; i < arrDistrictCode.length;i++)
					{
						strDistrictControl = strDistrictControl + "<option value=\"" + arrDistrictCode[i] + "\">" + arrDistrictName[i] + "</option>";
					}
					strDistrictControl = strDistrictControl + "</select>";
				}
			}
			else
			{
				strDistrictControl = strDistrictControl + "<select class=\"TEXTBOX\" id=\"" + DistrictComboboxName + "\" name=\"" + DistrictComboboxName + "\">";
				strProvinceControl = strProvinceControl + "<option value=\"\">---</option>";
				strDistrictControl = strDistrictControl + "</select>";
			}
			document.getElementById(DistrictDivID).innerHTML = strDistrictControl;
			
		}
		////////////////////////////////////////////////////////////////////////////////////
		//
		////////////////////////////////////////////////////////////////////////////////////
		function GetArrayIndex(arrArray,value)
		{
			var iReturnValue = -1;
			for(i = 0; i < arrArray.length;i++)
			{
				if(arrArray[i] == value)
				{
					iReturnValue = i;
				}
			}
			return iReturnValue;
		}
		
		////////////////////////////////////////////////////////////////////////////////////
		//
		////////////////////////////////////////////////////////////////////////////////////
		
		function changeCountryEx(target,cbProvinceCodeName,txtProvinceCodeName)
		{
			var cbProvinceCode = document.getElementById(cbProvinceCodeName);
			var txtProvinceCode = document.getElementById(txtProvinceCodeName);
			if(target.value.toUpperCase() == "VN")
			{
				cbProvinceCode.style.display = "";
				txtProvinceCode.style.display = "none";
			}
			else
			{
				cbProvinceCode.style.display = "none";
				txtProvinceCode.style.display = "";
			}
		}
		////////////////////////////////////////////////////////////////////////////////////
		//
		////////////////////////////////////////////////////////////////////////////////////
		
		function changeStateEx(target,cbProvinceCodeName,txtProvinceCodeName)
		{
			var cbProvinceCode = document.getElementById(cbProvinceCodeName);
			var txtProvinceCode = document.getElementById(txtProvinceCodeName);
			if(target.value.toUpperCase() == "OT")
			{
				txtProvinceCode.style.display = "";
			}
			else
			{
				txtProvinceCode.style.display = "none";
			}
		}
		////////////////////////////////////////////////////////////////////////////////////
		//
		////////////////////////////////////////////////////////////////////////////////////
		
		function urlencode(value)
		{
			value = escape(value);
			value = value.replace("+","%2B");
			return value;
		}
		////////////////////////////////////////////////////////////////////////////////////
		//
		////////////////////////////////////////////////////////////////////////////////////
		
		function urlencodeex(value)
		{
			value = URLEncode(value);
			value = value.replace("+","%2B");
			value = value.replace("&","%26");
			return value;
		}
		
		////////////////////////////////////////////////////////////////////////////////////
		//
		////////////////////////////////////////////////////////////////////////////////////
		function changeTab(preFixTabName, prefixContentName, tabCount, tabIndex)
		{
			tabCount = parseInt(tabCount,10);
			for(i = 1; i <=tabCount;i++)
			{
				//alert(document.getElementById(prefixContentName + i.toString()));
				document.getElementById(prefixContentName + i.toString()).style.display = "none";
				document.getElementById(preFixTabName + i.toString()).className = "";
			}
			//Display the tab
			document.getElementById(prefixContentName + tabIndex.toString()).style.display = "";
			document.getElementById(preFixTabName + tabIndex.toString()).className = "select";
		}		