//*******************************************************************************
//'* Purpose  : Commonly used Javascript Functions in Alghanim Career Site.
//'* Date     : 03-OCt-2006
//'* Author   : SV
//'* 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();
	}				
}
// 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("txtEmail").value;
		if (temp == "" || temp == "(Enter Email address)" || isWhitespace(temp) == true) {
				alert("Please enter word(s) to search.");
				document.getElementById("txtEmail").value = "";
				document.getElementById("txtEmail").focus();
		}else{
			window.location="SiteSearch.aspx?txtSearch="+temp;
		}
	}
	function clearTxtSearch(e, txt)
	{
		if (e.value == txt){
			e.value = "";
		}

	}
			
	function defaultTxtSearch(e, txt)
	{	
		if (e.value.length == 0)
			{
				e.value = txt;
			}
	}
	
	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)
	{
		e.value = "";
	}
	
	function defaultLogin(e)
	{	
		if (e.value.length == 0)
		{
			e.value = "username (email)";
		}
	}


	function WriteFlash()
	{
		document.write('<OBJECT codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"	height="184" width="180" 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/en-US/PIC.swf">\n');
			document.write('<PARAM NAME="Src" VALUE="images/en-US/PIC.swf">\n');
			document.write('<PARAM NAME="WMode" VALUE="Window">\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/en-US/PIC.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="180" height="184"> </embed>\n');
		document.write('</OBJECT>\n');
	}
//End