//*******************************************************************************
//'* Purpose  : Commonly used Javascript Functions in Gulf Air Career Site.
//'* Date     : 25-Jan-2006
//'* Author   : Syed Abid
//'* History      Auth        Date	Description
//'  --------     --------    ------- ---------------------------------------------
//'
//'*******************************************************************************
// Start

function ContainOnlyAlphabetsWithSpaces(strValue)
{
		strValue = strValue.toUpperCase();
		for (i=0;i<strValue.length;i++)
		{
			if (strValue.charAt(i)<"A" || strValue.charAt(i) > "Z")
			{
				if (strValue.charAt(i) != ' '){
					return false;
				}	
			}
		}
		return true;
}

function openWindow(url, windowName, featureString) 
{
	if (featureString == "")
	{
		featureString = "width=780,height=580,status=yes,scrollbars=yes,minimize=yes,top=10,left=10,resizable=1,toolbar=1,location=1,menubar=1";
	}

	winname = open (url, windowName, featureString);
	if (!winname) {
		alert("The window could not be opened. Please check if you have a popup blocker installed that may be preventing the window from opening. Try holding down the Ctrl key on your keyboard while clicking on the link.");
	}else 
	{
		winname.focus();
	}				
}

function OpenWindow(Agent,Relogin)
{
	var CompanyId = document.getElementById('txtCompanyID').value;
	if (Relogin)
		eurl = "../Frameset.aspx?CompanyID="+ CompanyId;
	else
	{
		var VacancyId = document.getElementById('txtVacancyID').value
		if (CompanyId == 14)
			eurl = "../PrivacyStatement.aspx?CompanyID="+ CompanyId + "&VacancyID=" + VacancyId;
		else
			{
			eurl = "../Frameset.aspx?CompanyID="+ CompanyId + "&VacancyId=" + VacancyId;
			}
	}	
	if (Agent){
		eurl+="&Agent=1"
	}
	awindow = openCentered(eurl, 795, 520, 'application', 'toolbar=yes,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes')	
}

// Checking white spaces in a field

var whitespace = " \t\n\r";

function isEmpty(s)
{   
	return ((s == null) || (s.length == 0))
}
				
	
function isWhitespace (s)
{   
	var i;
	if (isEmpty(s)) return true;
	for (i = 0; i < s.length; i++)
	{   
		// Check that current character isn't whitespace.
		var c = s.charAt(i);
		if (whitespace.indexOf(c) == -1) return false;
	}
	// All characters are whitespace.
	return true;
}  // End Checking white spaces in a field


function alltrim(strLine)
{	var trimstr = ""
	trimstr = rtrim(ltrim(strLine))
	return trimstr
}

function ltrim(strLine)
{var trimstr = ""
	var blkflg = 0
	var len    = strLine.length
	for (var i=0; i<=len-1; i++)
	{if(strLine.charAt(i) != " " )
		{{
				trimstr= strLine.substring(i,len)
				blkflg = 1
				break }}}
	return trimstr
}	

function rtrim(strLine)
{var trimstr = ""
	var blkflg = 0
	var len    = strLine.length-1
	var i = len
	while (strLine.charAt(i) == " ") {i=i-1 }
	trimstr = strLine.substring(0,i+1)
	return trimstr
}


	//function for Search button / image
	function goSearch(){
	
	var temp = document.getElementById("ucHeaderControl_txtSearch").value;
		if (temp == "" || temp == "(Search text)" || isWhitespace(temp) == true) {
				alert("Please enter word(s) to search.");
				document.getElementById("ucHeaderControl_txtSearch").value = "";
				document.getElementById("ucHeaderControl_txtSearch").focus();
		}else{
			window.location="SiteSearch.aspx?txtSearch="+temp;
		}
	}
	function clearTxtSearch(e)
	{
		if (e.value == "" ){
			e.value = "";
		}

	}
			
	function defaultTxtSearch(e)
	{	
		if (e.value.length == 0)
			{
				e.value = "";
			}
	}
	
	function checkEnter(e)
	{
		var code;
		
		if (!e) e = window.event;
		if (e.keyCode) 
		{
			code = e.keyCode;
		}
		else
		{
			code = e.which;
		}
		
		if (code == 13)
		{
			goSearch();
			return false;
		}
		return true;
	}

	function clearLogin(e)
	{
		if (e.value == "email")
		{
			e.value = "";
		}
	}
	
	function defaultLogin(e)
	{	
		if (e.value.length == 0)
		{
			e.value = "email";
		}
	}


	function clearPassword(e)
	{
		if (e.value == "password")
		{
			e.value = "";
		}
	}
	
	function defaultPassword(e)
	{	
		if (e.value.length == 0)
		{
			e.value = "password";
		}
	}

	function WriteFlash()
	{
		document.write('<OBJECT codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"	height="190" width="850" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">\n');
			document.write('<PARAM NAME="_cx" VALUE="4763">\n');
			document.write('<PARAM NAME="_cy" VALUE="4868">\n');
			document.write('<PARAM NAME="FlashVars" VALUE="">\n');
			document.write('<PARAM NAME="Movie" VALUE="Images/zain.swf">\n');
			document.write('<PARAM NAME="Src" VALUE="Images/zain.swf">\n');
			document.write('<PARAM NAME="WMode" VALUE="transparent">\n');
			document.write('<PARAM NAME="Play" VALUE="-1">\n');
			document.write('<PARAM NAME="Loop" VALUE="-1">\n');
			document.write('<PARAM NAME="Quality" VALUE="High">\n');
			document.write('<PARAM NAME="SAlign" VALUE="">\n');
			document.write('<PARAM NAME="Menu" VALUE="-1">\n');
			document.write('<PARAM NAME="Base" VALUE="">\n');
			document.write('<PARAM NAME="AllowScriptAccess" VALUE="">\n');
			document.write('<PARAM NAME="Scale" VALUE="ShowAll">\n');
			document.write('<PARAM NAME="DeviceFont" VALUE="0">\n');
			document.write('<PARAM NAME="EmbedMovie" VALUE="0">\n');
			document.write('<PARAM NAME="BGColor" VALUE="">\n');
			document.write('<PARAM NAME="SWRemote" VALUE="">\n');
			document.write('<PARAM NAME="MovieData" VALUE="">\n');
			document.write('<PARAM NAME="SeamlessTabbing" VALUE="1">\n');
			document.write('<PARAM NAME="Profile" VALUE="0">\n');
			document.write('<PARAM NAME="ProfileAddress" VALUE="">\n');
			document.write('<PARAM NAME="ProfilePort" VALUE="0">\n');
			document.write('<embed src="Images/zain.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" width="850" height="190"> </embed>\n');
		document.write('</OBJECT>\n');
	}
	
	function whenloading()
	{
		if(document.getElementById("useractive").value=="false")
		{
			document.getElementById("ucHeaderControl_txtPassword").value="password";
		}
	}	
	
	function popHelp()
	{
		window.open ("../keywordhelp.aspx?CompanyId=48", null, "width=650,height=450,scrollbars=yes");
	}	
			
	function ValidateVacancy()				
	{
						
		if (document.getElementById("ddlVacancy").value == "0")
			{							
				alert(Message8007);
				document.getElementById("ddlVacancy").focus();
				return false;
			}
	}

//End