<!--

function checkForNumber(str, desc) {
	if(isNaN(str)) alert(desc + ' should be a number');
}

function submitLoginFormOnEnterKey(e) {

	var key;

	if (window.event) {
		key = e.keyCode; // for IE, e.keyCode or window.event.keyCode can be used
	} else if (e.which) {
		key = e.which; // netscape
	}


	if (key == 13) {
		this.submitLoginForm();
	} else {
		return;
	}
}

function submitLoginForm() {

	var thisForm = document.forms[0];
	var uname = thisForm.loginId;
	var pass = thisForm.password;
	var message = "";
	var unameError = false;
	var passError = false;

	if (uname.value == "") {
		unameError = true;
		message = "Login id missing";
	} else {
		if ( ! isEmail(uname.value)) {
			unameError = true;
			message = "Login id should be a valid email id.";
		}
	}

	if (pass.value == "") {
		if (message != "") {
			message = message + "\n Password missing";
		} else {
			message = message + "Password missing";
		}

		passError = true;
	}

	if (unameError) {
		thisForm.loginId.focus();
	} else if (passError) {
		thisForm.password.focus();
	}

	if (message != "") {
		alert(message);
	} else {
		thisForm.hiddenAction.value = "DoUserLogin";
		thisForm.submit();
	}
}

function submitForgotPasswordOnEnterKey(e) {

	var key;

	if (window.event) {
		key = e.keyCode; // for IE, e.keyCode or window.event.keyCode can be used
	} else if (e.which) {
		key = e.which; // netscape
	}

	if (key == 13) {
		this.submitForgotPassword();
	} else {
		return;
	}
}



function submitForgotPassword() {


	var loginId = document.forms[0].forgotPasswordLoginId;
	var loginIdStr = trim(loginId.value);

	if (loginIdStr.length == 0) {
		alert('Login id missing. Enter your valid email id. ');
		loginId.focus();
		return;
	}

	if (! isEmail(loginIdStr)) {
		alert('Login id should be a valid email id.');
		loginId.focus();
		return;
	}

	document.forms[0].hiddenAction.value = "GetNewPassword";
	document.forms[0].submit();

}


function submitChangePassword() {

	currPass = document.forms[0].currPass;
	newPass1 = document.forms[0].newPass1;
	newPass2 = document.forms[0].newPass2;
	
	var msg = "";

	if (currPass.value.length == 0) {
		msg += 'Current password missing\n';
	}

	if (newPass1.value.length == 0) {
		msg += 'New password missing\n';
	}

	if (newPass2.value.length == 0) {
		msg += 'Confirm new password missing\n';
	}

	if (newPass1.value != newPass2.value) {
		msg += 'New password and Confirm password are not same';
	}


	if (currPass.value.length == 0) {
		currPass.focus();
	} else if (newPass1.value.length == 0) {
		newPass1.focus();
	} else if (newPass2.value.length == 0) {
		newPass2.focus();
	} else if (newPass1.value != newPass2.value) {
		newPass2.focus();
	}

	if (msg.length != 0) {
		alert("The following fields are missing\n" + msg);
		return;
	}

	document.forms[0].hiddenAction.value = "UpdatePassword";
	document.forms[0].submit();

}

function userLogout() {
	document.forms[0].hiddenAction.value = "DoUserLogout";
	document.forms[0].submit();
}

function updateJSInfo() {
	thisForm = document.forms[0];
	
	var msg = "";

	if (thisForm.userName.value.length == 0) {
		msg += 'user Name.\n';
	}

	//todo for other fields

	if (msg.length != 0){
		alert("ERROR\nThe following fields are missing:\n" + msg);
		return;
	}

	thisForm.hiddenAction.value = "UpdateJSInfo";
	thisForm.submit();
}

function closeWindow () {
	window.close();
	window.opener.focus();
}

function setCount(obj1, obj2, count) {
	var len = obj1.value.length;
	if (len > count) {
		//alert("Resume should be less than 2000 characters.");
		alert("Entered text more than " + count);
		obj1.value = obj1.value.substr(0, count);
	}
	obj2.value = obj1.value.length;
}

/*
function writeResumeCount() {
	var len = document.forms[0].resume.value.length;
	document.write(len + "/2000");
}
*/


function submitJobForm() {
	var thisForm = document.forms[0];

	var msg = '';

	if (trim(thisForm.jobRefId.value).length == 0) {
		msg += "Job Reference Id\n";
	}


	if (trim(thisForm.jobTitle.value).length == 0)  {
		msg += "Job Title\n";
	}

	if (thisForm.jobCategory.selectedIndex == 0) {
		msg += "Job Category\n";
	}

	if (thisForm.education.selectedIndex == 0) {
		msg += "Education\n";
	}

	if (thisForm.experience.selectedIndex == 0) {
		msg += "Experience\n";
	}

	if (thisForm.jobType.selectedIndex == 0) {
		msg += "Job Type\n";
	}

	if (thisForm.jobDuration.selectedIndex == 0) {
		msg += "Job Duration\n";
	}
	
	
	if (trim(thisForm.salaryAmount.value).length == 0) {
		msg += "Salary (Amount)\n";
	}


	if (trim(thisForm.jobDesc.value).length == 0) {
		msg += "Job Description\n";
	} else if (trim(thisForm.jobDesc.value).length > 1000) {
		msg += "Job Description should be less than 1000 chars\n";
	}

	if (trim(thisForm.requirements.value).length == 0) {
		msg += "Minimum Requirement\n";
	} else if (trim(thisForm.requirements.value).length > 1000) {
		msg += "Minimum Requirement should be less than 1000 chars\n";
	}

	if (msg.length != 0) {
		var temp = "Error: The following fields are missing\n---------------------------------------\n";
		alert(temp + msg);

		if (trim(thisForm.jobRefId.value).length == 0) {
			thisForm.jobRefId.focus();
		} else if (trim(thisForm.jobTitle.value).length == 0)  {
			thisForm.jobTitle.focus();
		} else if (thisForm.jobCategory.selectedIndex == 0) {
			thisForm.jobCategory.focus();
		} else if (thisForm.education.selectedIndex == 0) {
			thisForm.education.focus();
		} else if (thisForm.experience.selectedIndex == 0) {
			thisForm.experience.focus();
		} else if (thisForm.jobType.selectedIndex == 0) {
			thisForm.jobType.focus();
		} else if (thisForm.jobDuration.selectedIndex == 0) {
			thisForm.jobDuration.focus();
		} else if (trim(thisForm.salaryAmount.value).length == 0) {
			thisForm.salaryAmount.focus();
		} else if (trim(thisForm.jobDesc.value).length == 0) {
			thisForm.jobDesc.focus();
		} else if (trim(thisForm.jobDesc.value).length > 1000) {
			thisForm.jobDesc.focus();
		} else if (trim(thisForm.requirements.value).length == 0) {
			thisForm.requirements.focus();
		} else if (trim(thisForm.requirements.value).length > 1000) {
			thisForm.requirements.focus();
		}

		return false;
	}



	thisForm.hiddenAction.value = "JobPosted";
	thisForm.submit();
}

function submitUpdateJobForm() {
	var thisForm = document.forms[0];
	thisForm.hiddenAction.value = "UpdateJob";
	thisForm.submit();

}

function trim(str) {
   return str.replace(/^\s*|\s*$/g,"");
}

function isEmail(string) {
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) {
		return true;
	} else {
		return false;
	}
}


function setSelectedValue(theField, selectedValue) {
	var optionsArray = theField.options;
	var count = optionsArray.length;
	for (i = 0; i < count ; i++) {
		if (optionsArray[i].value == selectedValue) {
			theField.selectedIndex = i;
			break;
		}
	}
}


function changeRowColor(tableName, rowIndex, oldColor, e) {
	if (e.checked) {
		var otable = document.getElementById(tableName);
		otable.rows[rowIndex].style.backgroundColor="#f9e8d2"; 
	 } else {
		var otable = document.getElementById(tableName);
		otable.rows[rowIndex].style.backgroundColor = oldColor; 

	 }
}


function submitPaging(searchTypeStr) {
  document.forms[0].pageIdHidden.value = document.forms[0].paging.value;
  //alert (document.forms[0].pageIdHidden.value);
  submitJobSearch(searchTypeStr, false);
}

function submitJobSearchOnEnterKey(e, buttonName) {

	var key;

	if (window.event) {
		key = e.keyCode; // for IE, e.keyCode or window.event.keyCode can be used
	} else if (e.which) {
		key = e.which; // netscape
	}

	if (key == 13) {
		//if (buttonName == 'DoJobRefIdSearch') {
		//	this.submitJobSearch(buttonName, true);
		//} else {
		//	this.submitJobSearch(buttonName, true);
		//}
		this.submitJobSearch(buttonName, true);
	} else {
		return;
	}
}


function submitJobSearch(buttonName, countFromDB) {

	if (buttonName == 'DoJobRefIdSearch') {
	
		var jobRefIdStr = document.forms[0].jobRefId.value;
		//clear keywords
		document.forms[0].keywords.value = "";

		jobRefIdStr = trim(jobRefIdStr);

		if (jobRefIdStr.length == 0) {
			document.forms[0].jobRefId.value = "";
			alert("Job Reference Id missing.");
			document.forms[0].jobRefId.focus();
			return;
		}

		if ((jobRefIdStr.indexOf("'") != -1) || (jobRefIdStr.indexOf("\"") != -1)) 	{
			alert("single quote (') or double quote(\") NOT allowed.");
			return;
		}

		if (jobRefIdStr.length == 0)	{
			alert("Job Reference Id missing.");
			document.forms[0].jobRefId.focus();
			return;
		}

		if (jobRefIdStr.length < 2)	{
			alert("Job Reference Id should be min. 2 chars.");
			document.forms[0].jobRefId.focus();
			return;
		}

	} else {

		document.forms[0].jobRefId.value = "";
	
		var keywords = document.forms[0].keywords.value;
		keywords = trim(keywords);

		if (keywords.length == 0) {
			document.forms[0].keywords.value = "";
			alert("Search Keyword Missing.");
			document.forms[0].keywords.focus();
			return;
		}

		if ((keywords.indexOf("'") != -1) || (keywords.indexOf("\"")  != -1)) 	{
			alert("No single quote (') or double quote(\") not allowed.");
			return;
		}

		if (keywords.length == 0)	{
			alert("Keywords missing.");
			document.forms[0].keywords.focus();
			return;
		}

		if (keywords.length < 3)	{
			alert("Keywords should be min. 3 chars.");
			document.forms[0].keywords.focus();
			return;
		}
	}

	document.forms[0].hiddenAction.value = buttonName;
	if (countFromDB == true) {
		document.forms[0].hiddenGetCount.value = "GetDBCount";
	}
	document.forms[0].submit();
}


function showJobDetailsPopup(jobIdStr) {
  //ijeWindow = window.open("/JobDetailsPopup.php?jobId=" + jobIdStr, "", 'width=750, height=600,resizable=yes,scrollbars=yes');
	ijeWindow = window.open("/JobDetails.php?jobId=" + jobIdStr);
	ijeWindow.focus();
}


function popupSupport() {
  newwindow = window.open("/Support.php", '', 'width=450,height=400,resizable=no,scrollbars=yes');
  newwindow.focus();
}



function userLoginPage(str) {
	if (str == true) {
		window.location = "/JSLogin.php";
		return;
	} else {
		window.location = "/EmpLogin.php";
		return;
	}

}


	function submitEmpSignupForm() {
		var msg = "";

		thisForm = document.forms[0];

		loginIdStr = thisForm.loginId.value;
		contactPersonStr = thisForm.contactPerson.value;
		companyNameStr = thisForm.companyName.value;
		companyTypeStr = thisForm.companyType.value;
		companyPhoneStr = thisForm.companyPhone.value;
		companyCountryStr = thisForm.companyCountry.value;

		companyDescStr = thisForm.companyDesc.value;

		if (loginIdStr.length == 0) {
			msg += "Login Id\n";
		} else if ( ! isEmail(loginIdStr)) {
			msg += "Login id should be a valid email id\n";
		}

		if (contactPersonStr.length == 0) {
			msg += "Your Name\n";
		}
		if (companyNameStr.length == 0) {
			msg += "Company Name\n";
		}
		if (companyTypeStr.length == 0) {
			msg += "Company Type\n";
		}
		if (companyPhoneStr.length == 0) {
			msg += "Company Phone\n";
		}
		if (companyCountryStr.length == 0) {
			msg += "Company Location (Country)\n";
		}

		if (companyDescStr.length == 0) {
			msg += "Company Description\n";
		}

		if (msg.length != 0) {
			alert("The following fields are missing:\n\n" + msg);

			if (loginIdStr.length == 0) {
				thisForm.loginId.focus();
			} else if ( ! isEmail(loginIdStr)) {
				thisForm.loginId.focus();
			} else if (contactPersonStr.length == 0) {
				thisForm.contactPerson.focus();
			} else if (companyNameStr.length == 0) {
				thisForm.companyName.focus();
			} else if (companyTypeStr.length == 0) {
				thisForm.companyType.focus();
			} else if (companyPhoneStr.length == 0) {
				thisForm.companyPhone.focus();
			} else if (companyCountryStr.length == 0) {
				thisForm.companyCountry.focus();
			} else if (companyDescStr.length == 0) {
				thisForm.companyDesc.focus();
			}
			
			
			return false;
		}


		thisForm.hiddenAction.value = "EmpRegister";
		thisForm.submit();
	}



	function submitJSSignupForm() {
		var msg = "";

		thisForm = document.forms[0];

		isDobDateError = false;
		isDobMonthError = false;
		isDobYearError = false;

		loginIdStr = trim(thisForm.loginId.value);
		userNameStr = trim(thisForm.userName.value);

		dobDateStr = trim(thisForm.dobDate.value);
		dobMonthStr = trim(thisForm.dobMonth.value);
		dobYearStr = trim(thisForm.dobYear.value);

		phone1Str = trim(thisForm.phone1.value);
		locationCountryStr = trim(thisForm.locationCountry.value);
		locationStateStr = trim(thisForm.locationState.value);
		locationCityStr = trim(thisForm.locationCity.value);
		educationStr = trim(thisForm.education.value);
		experienceStr = trim(thisForm.experience.value);
		skillsStr = trim(thisForm.skills.value);
		resumeStr = trim(thisForm.resume.value);

		if (loginIdStr.length == 0) {
			msg += "Login Id\n";
		} else if ( ! isEmail(loginIdStr)) {
			msg += "Login id should be a valid email id\n";
		}

		if (userNameStr.length == 0) {
			msg += "Name\n";
		}

		if (dobDateStr.length == 0)	{
			msg += "Date Of Birth (Date)\n";
			isDobDateError = true;
		} else if (isNaN(dobDateStr)) {
			msg += "Date Of Birth (Date) should be number\n";
			isDobDateError = true;
		} else if (( 1 > dobDateStr) || (dobDateStr > 31)) {
			msg += "Date Of Birth (Date) should be between 1 to 31\n";
			isDobDateError = true;
		}

		if (dobMonthStr.length == 0)	{
			msg += "Date Of Birth (Month)\n";
			isDobMonthError = true;
		} else if (isNaN(dobMonthStr)) {
			msg += "Date Of Birth (Month) should be number\n";
			isDobMonthError = true;
		} else if (( 1 > dobMonthStr) || (dobMonthStr > 12)) {
			msg += "Date Of Birth (Month) should be between 1 to 12\n";
			isDobMonthError = true;
		}


		if (dobYearStr.length == 0)	{
			msg += "Date Of Birth (Year)\n";
			isDobYearError = true;
		} else if (isNaN(dobYearStr)) {
			msg += "Date Of Birth (Year) should be number\n";
			isDobYearError = true;
		} else if (( dobYearStr > 1988) || (dobYearStr < 1946)) {
			msg += "Date Of Birth (Year) should be between 1988 to 1946 (18 to 60 years)\n";
			isDobYearError = true;
		}

		if (phone1Str.length == 0) {
			msg += "Phone 1 (Primary)\n";
		}

		if (locationCountryStr.length == 0) {
			msg += "Location (Country)\n";
		}

		if (locationStateStr.length == 0) {
			msg += "Location (State)\n";
		}

		if (locationCityStr.length == 0) {
			msg += "Location (City)\n";
		}

		if (educationStr.length == 0) {
			msg += "Education\n";
		}

		if (experienceStr.length == 0) {
			msg += "Experience\n";
		}

		if (skillsStr.length == 0) {
			msg += "Major Skills\n";
		}

		if (resumeStr.length == 0) {
			msg += "Resume\n";
		}


		if (msg.length != 0) {
			alert("The following fields are missing:\n\n" + msg);

			if (loginIdStr.length == 0) {
				thisForm.loginId.focus();
			} else if ( ! isEmail(loginIdStr)) {
				thisForm.loginId.focus();
			} else if (userNameStr.length == 0) {
				thisForm.userName.focus();
			} else if (isDobDateError) {
				thisForm.dobDate.focus();
			} else if (isDobMonthError) {
				thisForm.dobMonth.focus();
			} else if (isDobYearError) {
				thisForm.dobYear.focus();
			} else if (phone1Str.length == 0) {
				thisForm.phone1.focus();	
			} else if (locationCountryStr.length == 0) {
				thisForm.locationCountry.focus();
			} else if (locationStateStr.length == 0) {
				thisForm.locationState.focus();
			} else  if (locationCityStr.length == 0) {
				thisForm.locationCity.focus();
			} else if (educationStr.length == 0) {
				thisForm.education.focus();
			} else if (experienceStr.length == 0) {
				thisForm.experience.focus();
			} else if (skillsStr.length == 0) {
				thisForm.skills.focus();
			} else if (resumeStr.length == 0) {
				thisForm.resume.focus();
			}

			return false;
		}

		thisForm.hiddenAction.value = "JSRegister";
		thisForm.submit();
	}



function popupSCSBanner() {
    scsBannerWindow = window.open("http://www.SingaporeCarSales.com/SingaporeCarSales300x300.html", 'SingaporeCarSales', 'width=300,height=300,resizable=no,scrollbars=no,top=225,left=25');
}


function popupAIMBanner() {
    aimBannerWindow = window.open("http://www.allindiamarriage.com/AllIndiaMarriage350x350-2.html", 'AllIndiaMarriage', 'width=350,height=350,resizable=no,scrollbars=no,top=225,left=350');
}


function removeLoading() {
	var targelem = document.getElementById('loadContainer');
	targelem.style.display='none';
	targelem.style.visibility='hidden';
}


function popupTermsAndConditions() {
	var popupURL = '/terms.php' ;
    newwindow = window.open(popupURL, 'SingaporeJobSearch', 'width=500,height=400,resizable=yes,scrollbars=yes');
    newwindow.focus();
}


function popupPrivacy() {
	var popupURL = '/privacy.php' ;
    sjsPrivacyWindow = window.open(popupURL, 'SingaporeJobSearchPrivacy', 'width=520,height=400,resizable=yes,scrollbars=yes');
    sjsPrivacyWindow.focus();
}


//->