	var preloadFlag = false;
 

	function popup(url,name){
		window.open(url,name,"width=700,height=600,scrollbars=yes,status=yes,toolbar=yes,directories=no,menubar=yes,location=yes,resizable");
	}
	
	
	/*
	* function to check if the username
	* and password is entered by the user
	*
	*/
	function validateLogin(){
	
		if (document.agentLogin.loginEmail.value == "")
		{			
			alert("Please enter your email address");
			document.agentLogin.loginEmail.focus();
			return false;
		} else if (document.agentLogin.loginPwd.value == "") {
			alert("Please enter your password");
			document.agentLogin.loginPwd.focus();
			return false;
		} else {
			return true;
		}
	}
	// functions included from userprofiletable.jsp
	function getAgents(){ 
		document.agentListing.submit();
	}
	function addAgent(){
		//document.agentListing.actionValue.value="AddAgent";
		//alert("The Action is :: "+document.agentListing.actionValue.value);
		document.agentListing.action = "/GECAREERS/jsp/us/searchJobs/jobAgent/agentAction.jsp";
		document.agentListing.submit();
		//document.AddAgent.submit();
	}
	/*
	function profile(element){
		document.chgProfile.Action.value = element;
		document.chgProfile.submit();
	}
	*/
	
	function profile(prm){		
		f = document.getElementById('agentList');
		n = document.createElement('input');
		n.setAttribute('name', 'chgprofile');
		n.setAttribute('value', prm);
		n.setAttribute('type', 'hidden');
		f.appendChild(n);
		document.getElementById('agentList').submit();		
	}
	
	/* function to validate and add a new user
	*
	*
	*/

	function validateNewUser()
	{		
		if (document.userRegistration.loginEmail.value == ""){
		
			alert("Please enter your email address");
			document.userRegistration.loginEmail.focus();
			return false;
		} else if (document.userRegistration.loginEmail.value.indexOf ('@',0) == -1 ||
		
    		document.userRegistration.loginEmail.value.indexOf ('.',0) == -1){
     		alert("The email address field requires a \"@\" and a \".\" be used.\nPlease re-enter your email address.")
     		document.userRegistration.loginEmail.select();
     		document.userRegistration.loginEmail.focus();
      		return false;
      	} else if (document.userRegistration.loginPwd.value == "") {
  
  	alert("Please enter your password");
			document.userRegistration.loginPwd.focus();
			return false;
		} else if (document.userRegistration.loginPwdConfirm.value == "") {
		
			alert("Please re-enter your password");
			document.userRegistration.loginPwdConfirm.focus();
			return false;
		} else if (document.userRegistration.loginPwdConfirm.value != document.userRegistration.loginPwd.value) {
		
			alert("Your password does not match the password you re-entered.  \nPlease try again.");
			document.userRegistration.loginPwd.focus();
			return false;
		} else if(!LengthGreaterThan6(document.userRegistration)){

			alert("Password must be at least six characters in length.");
			document.userRegistration.loginPwd.focus();
			return false;
		} else if(!checkCharsAllowed(document.userRegistration)){

			alert("Password can only contain letters and numbers.");
			document.userRegistration.loginPwd.focus();
			return false;
		} else {

			return true;
		}

	}
	/* functions added from PWInclude.js
	*
	*
	*
	*/	
	
//---------------------------------------------------------------------------------------

	function LengthGreaterThan6(form)
	{
		if (form.loginPwd.value.length < 6)
			return false
		return true
	}

//---------------------------------------------------------------------------------------

	function checkCharsAllowed(form) {
		var validPW;
		validPW = true;
		for(var i=0;i<form.loginPwd.value.length;++i) 
		{
	  		var ch = form.loginPwd.value.charAt(i);
	  		if(!isAlpha(ch) && !isNumber(ch)) 
			{
	   			validPW = false;
			}
	  	}
		return validPW;
	}

	function validateJobCode(form)
	{		
		var validPW;
		validPW = true;
		for(var i=0;i<form.JobCode.value.length;++i) 
		{
	  		var ch = form.JobCode.value.charAt(i);
	  		if(!isNumber(ch)) 
			{
	   			validPW = false;
				alert("Use Only Numeric values for JobCode");
				form.JobCode.focus();
				form.JobCode.select();
				break;
			}
	  	}
		
			if( !validPW)
			{
				return 	false;
			}
			
			if (!validateSQL(form))
			{
				form.Keyword.focus();
				form.Keyword.select();
				return false;
			}
			else
			{
				return true;
			}
//			return validPW;
		 
	}
//---------------------------------------------------------------------------------------

	function isAlpha(ch) {
	  if(ch >= "a" && ch <= "z") return true
	  if(ch >= "A" && ch <= "Z") return true
	  return false
	}
	
	function isNumber(ch) {
	  if(ch >= "0" && ch <= "9") return true
	  return false
	}

	 function validateSQL(form)
	  {
		
		var validPW;
		validPW = true;
		for(var i=0;i<form.Keyword.value.length;++i) 
		{
	  		var ch = form.Keyword.value.charAt(i);
	  		if(ch == "'") 
			{
	   			validPW = false;
				alert(" Single Quotes ' Not Allowed in Keyword ");
				form.Keyword.focus();
				form.Keyword.select();
				break;
			}
	  	}
		return validPW;
	  }
	
	/* function to change 
	 *  user`s profile
	 */
	
	function changeProfile(){
		if (document.chgUserProfile.action.value == "Password") {
			if (document.chgUserProfile.loginPwd.value == "") {
				alert("Please enter your new password");
				document.chgUserProfile.loginPwd.focus();
				return false;
			} else if (document.chgUserProfile.loginPwdConfirm.value == "") {
				alert("Please re-enter your new password");
				document.chgUserProfile.loginPwdConfirm.focus();
				return false;
			} else if (document.chgUserProfile.loginPwdConfirm.value != document.chgUserProfile.loginPwd.value) {
				alert("Your new password does not match the password you re-entered.  \nPlease try again.");
				document.chgUserProfile.loginPwd.focus();
				return false;
			} else if(!LengthGreaterThan6(document.chgUserProfile)){
				alert("Password must be at least six characters in length.");
				document.chgUserProfile.loginPwd.focus();
				return false;
			} else if(!checkCharsAllowed(document.chgUserProfile)){
				alert("Password can only contain letters and numbers.");
				document.chgUserProfile.loginPwd.focus();
				return false;
			} else {
				return true;
			}
		} else {
			if (document.chgUserProfile.loginEmail.value == ""){
				alert("Please enter your new email address");
				document.chgUserProfile.loginEmail.focus();
				return false;
			} else if (document.chgUserProfile.loginEmail.value.indexOf ('@',0) == -1 ||
       			document.chgUserProfile.loginEmail.value.indexOf ('.',0) == -1){
     			alert("The email address field requires a \"@\" and a \".\" be used.\nPlease re-enter your email address.")
     			document.chgUserProfile.loginEmail.select();
     			document.chgUserProfile.loginEmail.focus();
      			return false;
			} else if (document.chgUserProfile.loginEmailConfirm.value == "") {
				alert("Please re-enter your new email address");
				document.chgUserProfile.loginEmailConfirm.focus();
				return false;
			} else if (document.chgUserProfile.loginEmailConfirm.value != document.chgUserProfile.loginEmail.value) {
				alert("Your new email address does not match the email you re-entered.  \nPlease try again.");
				document.chgUserProfile.loginEmail.focus();
				return false;
			} else {
				return true;
			}
		}
	}
	
	/* Functions used for adding and updating and deleting agents
	 *
	 */	
	function validateAgentListing(){
			var mydoc = document.agentList;
			if (mydoc.Action.value != "Add") {
				if (!radio(mydoc))
				{
					alert("\nPlease select an agent before requesting this action.");
					return false;
				} //end if
			} //end if
			return true;
			
		}//end function validateAgentListing()
		
		 function radio(entry) {
			var typeFieldChecked = false;
			if (entry.selAgent.length){
				for (var i=0;i<entry.selAgent.length;i++) {
					if (entry.selAgent[i].checked) {
						typeFieldChecked = true;
						entry.selAgent[0].focus();
						break;
					} //endif
				} //end for
			} else {
				if (entry.selAgent.checked) {
					typeFieldChecked = true;
					entry.selAgent.focus();
				} // end if
			}
			return typeFieldChecked;
		} //end function radio()
			
		function navigate(type){
			//if (type == "Add" || type == "Modify"){
				//alert(type);
			var bVal = "false";
			/*
			alert(" document.agentList.function.value :: "+ eval("document.agentList.function_.value"));
			alert(" document.agentList.business.value :: "+ document.agentList.business.value);
			alert(" document.agentList.country.value :: "+ document.agentList.country.value);
			//alert(" document.agentList.state.value :: "+ document.agentList.state.value);
			*/
				if(type =="Add")
				{
					//alert("in the add function..");
					document.agentList.actionValue.value="AddAgent";
				}
				else if(type=="Modify")
				{
					//alert("in the modify function..");  
					if(validateAgentListing())
					{
						bVal = "false";
					}
					else
					{
						bVal = "true";
					}
					document.agentList.actionValue.value="ModifyAgent";
				}
				else if (type == "Delete")
				{  
					//alert("in the delete function..");
					if(validateAgentListing())
					{						
						if(confirm("Are you sure you want to delete this agent?"))
						{
							document.agentList.actionValue.value="DeleteAgent";
							document.agentList.action = "/GECAREERS/jsp/us/searchJobs/jobAgent/agentaddedit.jsp";
							//document.agentList.submit();
							return true;
						}
					}
					else
					{
						return false;
					}
				}
				//alert("The Value is ::"+document.agentList.actionValue.value);
				//document.agentList.action = "agentAction.jsp";
				//if(validateAgentListing())
				if(bVal == "false")
				{
					//document.forms[0].submit(); this line was change for the line below
					//document.agentList.submit();
					return true;
				}
				else
				{
					return false;
				}
			/*
			} else if (type == "Delete"){
				document.agentList.action = "AgentAddEdit.asp";
			}
			else{
				document.agentList.action = "";
			}
			document.agentList.Action.value = type;
			if (validateAgentListing()){
				if (type == "Delete") 
				{
					if(confirm("Are you sure you want to delete this agent?")){
						document.agentList.submit();
					}
				} 
				else 
				{
					document.agentList.submit();
				}
			}// end if
			*/
		}// end function navigate()

	/* code to validate 
	* adding and editing the 
	* job agent.
	*/

		function validateAgentAction(){
		alert ('enrto');
		var frequencyindex = document.agentAddEdit.Frequency.selectedIndex;
		var countryindex = document.agentAddEdit.Country.selectedIndex;
		var stateindex = document.agentAddEdit.State.selectedIndex;
		var functionindex = document.agentAddEdit.Function.selectedIndex;
		var businessindex = document.agentAddEdit.Business.selectedIndex;
		
		var cntCriteria;
		cntCriteria = 0;
	
		if (document.agentAddEdit.agentName.value == "" || document.agentAddEdit.agentName.value.length == 0 || document.agentAddEdit.agentName.value == null ){
			alert ("Please enter a name for this agent.");
			document.agentAddEdit.agentName.select();
         	document.agentAddEdit.agentName.focus();
			return false;
		}
		
	/*	if (!fieldCheck(document.agentAddEdit.agentName)) {
			alert("Special characters are not allowed in the Agent Name field.  Please re-enter using letters and numbers only.");
			return false;
		}
		
		if (!fieldCheck(document.agentAddEdit.Keyword)) {
			alert("Special characters are not allowed in the Keyword Search field.  Please re-enter using letters and numbers only.");
			return false;
		}
	*/	
		if (stateindex > 0){
			if (countryindex == 1924 || document.agentAddEdit.Country[countryindex].value == "1924") {
			}else {
			alert ("The state selection criteria is only valid for the United States.");
			document.agentAddEdit.Country.focus();
			return false;
			}
		}
				
		if (countryindex > 0 || stateindex > 0){
			cntCriteria = cntCriteria + 1;
		}
		
		if (functionindex > 0){
			cntCriteria = cntCriteria + 1;
		}
		
		if (businessindex > 0){
			cntCriteria = cntCriteria + 1;
		}
		
		if (cntCriteria < 2){
			alert("Please select a value (other then the current defaults) from at least two of the 'numbered' data fields.");
			document.agentAddEdit.Country.focus();
			return false;
		}
		return true;
	}
	
	function fieldCheck(field){
		var i = 0;
		var fieldLen = field.value.length;
		var ch;
		while (i < fieldLen){
			ch = field.value.charAt(i);
			if (isSpecial(ch)){
				field.focus();
				return false;
			}
		i = i +1;
		}
		return true;
	}
	
	function isSpecial(ch){
		var special = new Array("!","\"","#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_","`","{","|","}","~");
		var i = 0;
		while (i < special.length){
			if(ch == special[i]){
				return true;
			}
		i++;
		}
 		return false;
	}
	
	function init(){
		//alert("in the init function");
       if (navigator.appName == "Netscape") {
			layerStyleRef="layer.";
			layerRef="document.layers";
			styleSwitch="";
       }else{
			layerStyleRef="layer.style.";
			layerRef="document.all";
			styleSwitch=".style";
	}
	
}

function showLayer(layerName){
	eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
}

function hideLayer(layerName){
	eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}



/*	function to validate 
*	password for the pw reminder page
*/
function validateEmailId(){
		if (document.PwdReminder.loginEmail.value == ""){
			alert("Please enter your email address");
			document.PwdReminder.loginEmail.focus();
			return false;
		} else if (document.PwdReminder.loginEmail.value.indexOf ('@',0) == -1 || 
       			document.PwdReminder.loginEmail.value.indexOf ('.',0) == -1){
     			alert("The email address field requires a \"@\" and a \".\" be used.\nPlease re-enter your email address.")
     			document.PwdReminder.loginEmail.select();
     			document.PwdReminder.loginEmail.focus();
      			return false;
		} else {
			return true;
		}
	}