function checkBlogComment(){
	with(document.blogFrm){
		if(userIDVal.value==""){
			alert("You must be logged in to add comment.");
			return false;
		}
		if(strComment.value==""){
			alert("Comment text is blank.");
			strComment.focus();
			return false;
		}
	}
}
function checkClassifiedData(){
	with(document.classifiedForm){
		if(fldTitle.value==""){
			alert("Title is blank.");
			fldTitle.focus();
			return false;
		}
		if(fldTitle.value.length>255){
			alert("Title cannot be more than 255 characters.");
			fldBlogTitle.focus();
			return false;
		}
		if(fldDescription.value==""){
			alert("Description is blank.");
			return false;
		}
		if(fldListID.value==""){
			alert("Please select main category.");
			return false;
		}
		if(fldPriceRange.value!=""){
			if(isNaN(fldPriceRange.value)){
				alert("Please enter valid estimated price.");
				return false;
			}
		}
	}
}
function checkBlogData(){
	with(document.blogForm){
		if(fldBlogTitle.value==""){
			alert("Blog title is blank.");
			fldBlogTitle.focus();
			return false;
		}
		if(fldBlogTitle.value.length>255){
			alert("Title cannot be more than 255 characters.");
			fldBlogTitle.focus();
			return false;
		}
		if(fldBlogText.value==""){
			alert("Blog text is blank.");
			return false;
		}
	}
}

function checkFrontLogin(){
	with(document.frmLogin){
		if(txtLoginName.value==""){
			alert("Please enter username!");
			txtLoginName.focus();
			return false;
		}
		if(txtPassword.value==""){
			alert("Please enter password!");
			txtPassword.focus();
			return false;
		}
	}
}
function checkFrontLogin1(){
	with(document.frmLogin1){
		if(txtLoginName.value==""){
			alert("Please enter username!");
			txtLoginName.focus();
			return false;
		}
		if(txtPassword.value==""){
			alert("Please enter password!");
			txtPassword.focus();
			return false;
		}
	}
}
function checkLogin(id) {//return true;
	if (!bLogin) {
		alert("User Login is required before apply");
		return false;	
	}
	else {
		window.location="application/application.php?jobId="+ id;
		return true;
	}
}


function checkMyPlace(){
	with(document.myplaceForm){
		if(fldTitle.value==""){
			alert("Title is blank.");
			fldTitle.focus();
			return false;
		}
		if(fldListID.value==""){
			alert("Please select category.");
			fldListID.focus();
			return false;
		}
		if(fldShortDescription.value==""){
			alert("Short description is blank.");
			return false;
		}
		if(fldLongDescription.value==""){
			alert("Long description is blank.");
			return false;
		}
	}
}
//Function to enable checkbox
function enableHomePageCheckBox(form) {
	if(form.fldIsActive.checked == true) {
		form.fldShowOnHomePage.disabled = false;
	}
	if(form.fldIsActive.checked == false) {
		form.fldShowOnHomePage.disabled = true;
	}
}

//Function to submit form to activate a record
/*function radioFormSubmit() {
	document.radioForm.submit();
}
*/
//Function to check special symbol and numeric value
function isAlphabet(fld,mesg) {
	var iChars = "~!@#$%^&*()+=-[]\\;,./{}|:<>?0123456789";
	for (var i = 0; i < fld.value.length; i++) {
		if (iChars.indexOf(fld.value.charAt(i)) != -1) {
			alert ("The "+mesg+" has special characters or numeric values. \nThe following characters are not allowed:\n"+iChars);
			fld.select();
			return false;
		}
	}
	return true;
	
}

//Function to check for alphanumeric
function isAlphanumeric(fld,mesg) {
	var iChars = "~!@#$%^&*()+=-[]\\;,./{}|:<>?";
	for (var i = 0; i < fld.value.length; i++) {
		if (iChars.indexOf(fld.value.charAt(i)) != -1) {
			alert ("The "+mesg+" has special characters. \nThe following characters are not allowed:\n"+iChars);
			fld.select();
			return false;
		}
	}
	return true;
	
}
//function to check email
/*
function echeck(str1,msg){
	var str=str1.value
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,4}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
	testresults=true
	else{
	testresults=false
	}
	return (testresults)
}
*/
 function echeck(str,msg) {
	   
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true;					
} 
//function to check search filed
function checkSearchField() {
	var form = document.searchForm;
	if(!isEmpty(form.fldSearch,"Please fill Search Text")) {
				form.fldSearch.focus();
				return false;
	}
	return true;
}

//function to check income
function checkIncome(str,fld) {
	var iChars = "!@#$%^&*()+=-[]\\\';./{}|\":<>?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	  for (var i = 0; i < str.value.length; i++) {
		if (iChars.indexOf(str.value.charAt(i)) != -1) {
			alert ("Your " + fld + " has special characters or alphabets. \nThese are not allowed.\n Please remove them and try again.");
			return false;
		}
	 }
	  return true;
}
// function to check all fields validation for edit profile form
function checkEditMyProfile() {
	var form = document.editProfilefrm;
			if(!isEmpty(form.fldFirstName,"Please fill First Name")) {
				form.fldFirstName.focus();
				return false;
			}
			else if(!isAlphabet(form.fldFirstName,"First Name")) {
				return false;
			}
			else if(form.fldFirstName.value.length > 50) {
				alert("First Name can not have more than 50 characters");
				form.fldFirstName.focus();
				return false;
			}
			/*if(!isEmpty(form.fldLastName,"Please fill Last Name")) {
				form.fldLastName.focus();
				return false;
			}
			else if(!isAlphabet(form.fldLastName,"Last Name")) {
				return false;
			}
			else if(form.fldLastName.value.length > 50) {
				alert("Last Name can not be have than 50 characters");
				form.fldLastName.focus();
				return false;
			}*/
			if(!isEmptyNoMsg(form.fldLastName)) {
				 if(!isAlphabet(form.fldLastName,"Last Name")) {
					return false;
				}
				else if(form.fldLastName.value.length > 50) {
					alert("Last Name can not be have than 50 characters");
					form.fldLastName.focus();
					return false;
				}	
			}
			if(!isEmpty(form.fldUserName,"Please fill User Name")) {
				form.fldUserName.focus();
				return false;
			}
			else if(!isAlphanumeric(form.fldUserName,"User Name")) {
				return false;
			}
			else if(form.fldUserName.value.length > 50) {
				alert("User Name can not have more than 50 characters");
				form.fldUserName.focus();
				return false;
			} 
			if(!isEmpty(form.fldEmail,"Please fill  Email ID")) {
				form.fldEmail.focus();
				return false;
			}
			else if(!echeck(form.fldEmail,"Please fill valid Email ID")){
				//form.fldEmail.value="";
				form.fldEmail.focus();
				return false;
			}
			else if(form.fldEmail.value.length > 100) {
				alert("Email ID can not have more than 100 characters");
				form.fldEmail.focus();
				return false;
			}
			if(!isEmpty(form.fldOccupation,"Please fill Occupation")) {
				form.fldOccupation.focus();
				return false;
			}
			else if(form.fldOccupation.value.length > 100) {
				alert("Occupation can not have more than 100 characters");
				form.fldOccupation.focus();
				return false;
			}
			if(!isEmpty(form.fldCompany,"Please fill Company")) {
				form.fldCompany.focus();
				return false;
			}
			else if(form.fldCompany.value.length > 100) {
				alert("Company can not have more than 100 characters");
				form.fldCompany.focus();
				return false;
			}
			if(!isEmpty(form.fldAge,"Please fill Age")) {
				form.fldAge.focus();
				return false;
			}
			else if(!checkIncome(form.fldAge,"Age")) {
				form.fldAge.focus();
				return false;
			}
			else if(form.fldAge.value.length > 3) {
				alert("Age can not have more than 3 characters");
				form.fldAge.focus();
				return false;
			}
			if(!isEmpty(form.fldIncome,"Please fill Income")) {
				form.fldIncome.focus();
				return false;
			}
			else if(!checkIncome(form.fldIncome,"Income")) {
				form.fldIncome.focus();
				return false;
			}
			else if(form.fldIncome.value.length > 20) {
				alert("Income can not have more than 20 characters");
				form.fldIncome.focus();
				return false;
			}
			
	return true;
}
//function to check add/edit Title Form
function checkTitleForm() {
	var form = document.titleForm;
	if(!isEmpty(form.fldTitleName,"Please enter title name.")) {
		form.fldTitleName.focus();
		return false;
	}
	if(!isEmpty(form.fldLowerLimit,"Please enter lower limit.")) {
		form.fldTitleName.focus();
		return false;
	}
	if(!isEmpty(form.fldUpperLimit,"Please enter upper limit.")) {
		form.fldTitleName.focus();
		return false;
	}
	return true;
}
//function to check add/edit list Form
function checkListForm() {
	var form = document.listForm;
	if(!isEmpty(form.fldTitle,"Please fill Title")) {
		form.fldTitle.focus();
		return false;
	}
	else if(!isAlphabet(form.fldTitle,"Title")) {
		return false;
	}
	else if(form.fldTitle.value.length > 50) {
		alert("Title can not be more than 50 characters");
		form.fldTitle.focus();
		return false;
	}
	return true;
}
//function to check add/Edit Item Form
function checkItemForm() {
	var form = document.itemForm;
	if(!(form.fldListId.value > 0)) {
		alert("Please select List");
		form.fldListId.focus();
		return false;
	}
	if(!isEmpty(form.fldTitle,"Please fill Title")) {
		form.fldTitle.focus();
		return false;
	}
	else if(!isAlphabet(form.fldTitle,"Title")) {
		return false;
	}
	else if(form.fldTitle.value.length > 100) {
		alert("Title can not be more than 100 characters");
		form.fldTitle.focus();
		return false;
	}
	if(!isEmpty(form.fldShortDescription,"Please fill Short Description")) {
		form.fldShortDescription.focus();
		return false;
	}
	else if(form.fldShortDescription.value.length > 255) {
		alert("Short Description can not be more than 100 characters");
		form.fldShortDescription.focus();
		return false;
	}
	if(!isEmpty(form.fldLongDescription,"Please fill Long Description")) {
		form.fldLongDescription.focus();
		return false;
	}
	return true;
}
// Function to check fields of application page
function checkApplicationForm() {
	var form = document.applicationForm;
	if(!isEmpty(form.fldCandidateName,"Please fill  Candidate Name")) {
		form.fldCandidateName.focus();
		return false;
	}
	else if(form.fldCandidateName.value.length > 100) {
		alert("Candidate Name can not have more than 100 characters");
		form.fldCandidateName.focus();
		return false;
	}
	if(form.month.value == "no") {
		alert("Please select Month");
		form.month.focus();
		return false;
	}
	if(form.day.value == "no") {
		alert("Please select Day");
		form.day.focus();
		return false;
	}
	if(form.year.value == "no") {
		alert("Please select Year");
		form.year.focus();
		return false;
	}
	if(!isEmpty(form.fldQualification,"Please fill Qualification")) {
		form.fldQualification.focus();
		return false;
	}
	else if(form.fldQualification.value.length > 100) {
		alert("Qualification Name can not have more than 100 characters");
		form.fldQualification.focus();
		return false;
	}
	if(!isEmpty(form.fldExperience,"Please fill Experience")) {
		form.fldExperience.focus();
		return false;
	}
	else if(form.fldExperience.value.length > 100) {
		alert("Experience Name can not have more than 100 characters");
		form.fldExperience.focus();
		return false;
	}
	if(!isEmpty(form.fldEmploymentHistory,"Please fill Employment History")) {
		form.fldEmploymentHistory.focus();
		return false;
	}
	if(!isEmpty(form.fldResume,"Please fill Resume")) {
		form.fldResume.focus();
		return false;
	}
	return true;
}
// function to check fields of add/edit rumor form
function checkRumorForm() {
	var form = document.rumorForm;
	if(!isEmpty(form.fldTitle,"Please fill Title")) {
		form.fldTitle.focus();
		return false;
	}
	else if(!isAlphabet(form.fldTitle,"Title")) {
		return false;
	}
	else if(form.fldTitle.value.length > 100) {
		alert("Title can not have more than 100 characters");
		form.fldTitle.focus();
		return false;
	}
	if(!isEmpty(form.fldShortDescription,"Please fill Short Description")) {
		form.fldShortDescription.focus();
		return false;
	}
	else if(form.fldShortDescription.value.length > 255) {
		alert("Short Description can not have more than 255 characters");
		form.fldShortDescription.focus();
		return false;
	}
	if(!isEmpty(form.fldLongDescription,"Please fill Long Description")) {
		form.fldLongDescription.focus();
		return false;
	}

	var oTags = document.getElementById('fldTags');
	var bSelected = false;
	var iLength = oTags.options.length;
	for (i = 0; i < iLength; i++) {
		if (oTags.options[i].selected) { 
			var bSelected = 1;
			break;
		}
	}
	if (!bSelected) {
		alert("Please select Tag(s)");
		oTags.focus();
		return false;
	}


	return true;
}
// function to check fields of add/edit link form
function checkLinkForm() {
	var form = document.linkForm;
	if(!isEmpty(form.fldURL,"Please fill URL")) {
		form.fldURL.focus();
		return false;
	}
	else if(form.fldURL.value.length > 255) {
		alert("URL can not have more than 255 characters");
		form.fldURL.focus();
		return false;
	}
	else if(!CheckUrl(form.fldURL,"Invalid URL")) {
		form.fldURL.focus();
		return false;
	}
	if(!isEmpty(form.fldTitle,"Please fill Title")) {
		form.fldTitle.focus();
		return false;
	}
	else if(!isAlphabet(form.fldTitle,"Title")) {
		return false;
	}
	else if(form.fldTitle.value.length > 100) {
		alert("Title can not have more than 100 characters");
		form.fldTitle.focus();
		return false;
	}
	if(!isEmpty(form.fldDescription,"Please fill Description")) {
		form.fldDescription.focus();
		return false;
	}


	var oTags = document.getElementById('fldTags');
	var bSelected = false;
	var iLength = oTags.options.length;
	for (i = 0; i < iLength; i++) {
		if (oTags.options[i].selected) { 
			var bSelected = 1;
			break;
		}
	}
	if (!bSelected) {
		alert("Please select Tag(s)");
		oTags.focus();
		return false;
	}


	/*
	if(!isEmpty(form.fldTags,"Please fill Tags")) {
		form.fldTags.focus();
		return false;
	}
	else if(form.fldTags.value.length > 255) {
		alert("Tags can not have more than 255 characters");
		form.fldTags.focus();
		return false;
	}
	*/

	return true;
}
//function to check comment form fields
function checkCommentForm() {
	var form = document.commentFrom;
	if(!isEmpty(form.fldComment,"Please fill Comment")) {
		form.fldComment.focus();
		return false;
	}
}
//function for chnage password at userSide
function checkChangePasswordForm() {
	var form = document.frmHomeChangePassword;
	if(!isEmpty(form.txtOldPassword,"Please fill Old Password")) {
		form.txtOldPassword.focus();
		return false;
	}
	
	if(!isEmpty(form.txtNewPassword,"Please fill New Password")) {
		form.txtNewPassword.focus();
		return false;
	}
	else if(form.txtNewPassword.value.length < 5 || form.txtNewPassword.value.length > 12) {
		alert("Password can be only between 5 to 12 characters");
		form.txtNewPassword.focus();
		return false;
	}

	if(!isEmpty(form.txtConfirmPassword,"Please fill Confirm Password")) {
		form.txtConfirmPassword.focus();
		return false;
	}
	// check if both password fields are the same
	if (form.txtNewPassword.value != form.txtConfirmPassword.value)
	{
		alert("New Password and Confirm Password are not the same.");
		form.txtConfirmPassword.focus();
		return false;
	}
	return true;
}


//function check forgot password fields at user side
function checkForgotPasswordForm() {
	var form = document.frmHomeforgotPassword;
	if(!isEmpty(form.fldEmail,"Please fill  Email ID")) {
			form.fldEmail.focus();
			return false;
		}
		else if(!echeck(form.fldEmail,"Please fill valid Email ID")){
			//form.fldEmail.value="";
			form.fldEmail.focus();
			return false;
		}
		else if(form.fldEmail.value.length > 100) {
			alert("Email ID can not have more than 100 characters");
			form.fldEmail.focus();
			return false;
	}
}

/******************************************************/
//Admin sided functions

//function to check add/edit user form
function checkUserForm1() {
	var form = document.userForm;
		if(!isEmpty(form.fldFirstName,"Please fill First Name")) {
			form.fldFirstName.focus();
			return false;
		}
		else if(!isAlphabet(form.fldFirstName,"First Name")) {
			return false;
		}
		else if(form.fldFirstName.value.length > 100) {
			alert("First Name can not have more than 100 characters");
			form.fldFirstName.focus();
			return false;
		}
		if(!isEmptyNoMsg(form.fldLastName)) {
			 if(!isAlphabet(form.fldLastName,"Last Name")) {
				return false;
			}
			else if(form.fldLastName.value.length > 100) {
				alert("Last Name can not have more than 100 characters");
				form.fldLastName.focus();
				return false;
			}	
		}
		/*
		if(!isEmpty(form.fldUserName,"Please fill User Name")) {
			form.fldUserName.focus();
			return false;
		}
		else if(!isAlphabet(form.fldUserName,"User Name")) {
			return false;
		}
		else if(form.fldUserName.value.length > 50) {
			alert("User Name can not have more than 50 characters");
			form.fldUserName.focus();
			return false;
		} */
		if(!isEmpty(form.fldEmail,"Please fill  Email ID")) {
			form.fldEmail.focus();
			return false;
		}
		else if(!echeck(form.fldEmail,"Please fill valid Email ID")){
			form.fldEmail.focus();
			return false;
		}
		else if(form.fldEmail.value.length > 100) {
			alert("Email ID can not have more than 100 characters");
			form.fldEmail.focus();
			return false;
		}
		if(!isEmpty(form.fldPassword,"Please fill Password")) {
			form.fldPassword.focus();
			return false;
		}
		else if(form.fldPassword.value.length < 5 || form.fldPassword.value.length > 12) {
			alert("Password can be only between 5 to 12 characters");
			form.fldPassword.focus();
			return false;
		}
		if(!isEmpty(form.fldRePassword,"Please retype password")) {
			form.fldRePassword.focus();
			return false;
		}
		else if(form.fldRePassword.value.length < 5 || form.fldRePassword.value.length > 12) {
			alert("Re-password can be only between 5 to 12 characters");
			form.fldPassword.focus();
			return false;
		}
		if(form.fldRePassword.value!=form.fldPassword.value){
			alert("Both passwords should be the same");
			form.fldRePassword.focus();
			return false;
		}
	return true;
}

function checkGroupForm() {
	var form = document.groupForm;
	var iChars = "!@#$%^&*()+=-_[]\\\';./{}|\":<>?";
	 
	if(!isEmpty(form.fldGroupName,"Please fill Group Name")) {
		form.fldGroupName.focus();
		return false;
	}
	else if(form.fldGroupName.value.length > 50) {
		alert("Group Name can not have more than 100 characters");
		form.fldGroupName.focus();
		return false;
	}
	for (var i = 0; i < form.fldGroupName.value.length; i++) {
		if (iChars.indexOf(form.fldGroupName.value.charAt(i)) != -1) {
			alert ("Group Name has special characters. \nThese are not allowed:\n"+iChars + "\n Please remove them and try again.");
			return false;
		}
	}
	return true;
}

// function to check all fields validation for registerUser form
function checkRegisterPage() {
	var form = document.registerUser;
			if(!isEmpty(form.fldFirstName,"Please fill First Name")) {
				form.fldFirstName.focus();
				return false;
			}
			else if(!isAlphabet(form.fldFirstName,"First Name")) {
				return false;
			}
			else if(form.fldFirstName.value.length > 50) {
				alert("First Name can not have more than 50 characters");
				form.fldFirstName.focus();
				return false;
			}
			/*if(!isEmpty(form.fldLastName,"Please fill Last Name")) {
				form.fldLastName.focus();
				return false;
			}
			else if(!isAlphabet(form.fldLastName,"Last Name")) {
				return false;
			}
			else if(form.fldLastName.value.length > 50) {
				alert("Last Name can not be have than 50 characters");
				form.fldLastName.focus();
				return false;
			}*/
			if(!isEmptyNoMsg(form.fldLastName)) {
				 if(!isAlphabet(form.fldLastName,"Last Name")) {
					return false;
				}
				else if(form.fldLastName.value.length > 50) {
					alert("Last Name can not be have than 50 characters");
					form.fldLastName.focus();
					return false;
				}	
			}
			if(!isEmpty(form.fldUserName,"Please fill User Name")) {
				form.fldUserName.focus();
				return false;
			}
			else if(!isAlphabet(form.fldUserName,"User Name")) {
				return false;
			}
			else if(form.fldUserName.value.length > 50) {
				alert("User Name can not have more than 50 characters");
				form.fldUserName.focus();
				return false;
			} 
			/*if(!isEmpty(form.fldEmail,"Please fill  Email ID")) {
				form.fldEmail.focus();
				return false;
			}
			else if(!echeck(form.fldEmail,"Please fill valid Email ID")){
				//form.fldEmail.value="";
				form.fldEmail.focus();
				return false;
			}
			else if(form.fldEmail.value.length > 100) {
				alert("Email ID can not have more than 100 characters");
				form.fldEmail.focus();
				return false;
			}*/
			if(!isEmpty(form.fldPassword,"Please fill Password")) {
				form.fldPassword.focus();
				return false;
			}
			else if(form.fldPassword.value.length < 5 || form.fldPassword.value.length > 12) {
				alert("Password can be only between 5 to 12 characters");
				form.fldPassword.focus();
				return false;
			}
			if(!isEmpty(form.fldConfirmPassword,"Please fill Confirm Password")) {
				form.fldConfirmPassword.focus();
				return false;
			}
			// check if both password fields are the same
			if (form.fldPassword.value != form.fldConfirmPassword.value)
			{
				alert("New Password and Confirm Password are not the same.");
				form.fldConfirmPassword.focus();
				return false;
			}
			if(!isEmpty(form.fldOccupation,"Please fill Occupation")) {
				form.fldOccupation.focus();
				return false;
			}
			else if(form.fldOccupation.value.length > 100) {
				alert("Occupation can not have more than 100 characters");
				form.fldOccupation.focus();
				return false;
			}
			if(!isEmpty(form.fldCompany,"Please fill Company")) {
				form.fldCompany.focus();
				return false;
			}
			else if(form.fldCompany.value.length > 100) {
				alert("Company can not have more than 100 characters");
				form.fldCompany.focus();
				return false;
			}
			if(!isEmpty(form.fldAge,"Please fill Age")) {
				form.fldAge.focus();
				return false;
			}
			else if(!checkIncome(form.fldAge,"Age")) {
				form.fldAge.focus();
				return false;
			}
			else if(form.fldAge.value.length > 3) {
				alert("Age can not have more than 3 characters");
				form.fldAge.focus();
				return false;
			}
			if(!isEmpty(form.fldIncome,"Please fill Income")) {
				form.fldIncome.focus();
				return false;
			}
			else if(!checkIncome(form.fldIncome,"Income")) {
				form.fldIncome.focus();
				return false;
			}
			else if(form.fldIncome.value.length > 20) {
				alert("Income can not have more than 20 characters");
				form.fldIncome.focus();
				return false;
			}
			if(!isEmpty(form.fldKey,"Please fill Key")) {
				form.fldKey.focus();
				return false;
			}
	return true;
}
function validateEmail(email){
	if (email == ""){return false;}
	badStuff = ";:/,' \"\\";
	for (i=0; i<badStuff.length; i++)
	{
		badCheck = badStuff.charAt(i)
		if (email.indexOf(badCheck,0) != -1){return false;}
	}
	posOfAtSign = email.indexOf("@",1)
	if (posOfAtSign == -1){return false;}
	if (email.indexOf("@",posOfAtSign+1) != -1){return false;}
	posOfPeriod = email.indexOf(".", posOfAtSign)
	if (posOfPeriod == -1){return false;}
	if (posOfPeriod+2 > email.length){return false;}
	return true;
}
/**
 * Validate Global Invitation
 *
 * @param object Form
 * @return boolean
 */
function validateGlobalInvitation(oForm)
{	
	if(!isEmpty(oForm.fldInvitationNo, "Invitation number cannot be empty.")) {
		oForm.fldInvitationNo.focus();
		return false;
	}
	if (isNaN(oForm.fldInvitationNo.value) || oForm.fldInvitationNo.value=='0') {
		alert("Invitation number should be numeric.");
		oForm.fldInvitationNo.focus();
		return false;
	}
	return true;
}

// Function to check fields of job page
function checkJobForm() {
	var form = document.jobForm;
	if(!isEmpty(form.fldCompanyName,"Please fill Company Name")) {
		form.fldCompanyName.focus();
		return false;
	}
	else if(form.fldCompanyName.value.length > 100) {
		alert("Company Name can not have more than 100 characters");
		form.fldCompanyName.focus();
		return false;
	}
	if(!isEmpty(form.fldCompanyHistory,"Please fill Company History")) {
		form.fldCompanyHistory.focus();
		return false;
	}
	if(!isEmpty(form.fldTitle,"Please fill Title")) {
		form.fldTitle.focus();
		return false;
	}
	else if(!isAlphabet(form.fldTitle,"Title")) {
		return false;
	}
	else if(form.fldTitle.value.length > 100) {
		alert("Title can not have more than 100 characters");
		form.fldTitle.focus();
		return false;
	}

	if(!isEmpty(form.fldDescription,"Please fill Description")) {
		form.fldDescription.focus();
		return false;
	}
	if(!isEmpty(form.fldRequirements,"Please fill Requirements")) {
		form.fldRequirements.focus();
		return false;
	}
	if(!isEmpty(form.fldSalary,"Please fill Salary")) {
		form.fldSalary.focus();
		return false;
	}
	else if(form.fldSalary.value.length > 20) {
		alert("Income can not have more than 20 characters");
		form.fldSalary.focus();
		return false;
	}
	if(!isEmpty(form.fldContactPerson,"Please fill Contact Person")) {
		form.fldContactPerson.focus();
		return false;
	}
	else if(form.fldContactPerson.value.length > 100) {
		alert("Contact Person can not have more than 100 characters");
		form.fldContactPerson.focus();
		return false;
	}
	if(!isEmpty(form.fldEmail,"Please fill  Email ID")) {
		form.fldEmail.focus();
		return false;
	}
	else if(!echeck(form.fldEmail,"Please fill valid Email ID")){
		//form.fldEmail.value="";
		form.fldEmail.focus();
		return false;
	}
	else if(form.fldEmail.value.length > 100) {
		alert("Email ID can not have more than 100 characters");
		form.fldEmail.focus();
		return false;
	}
	return true;
}
//function for chnage password 
function checkChangePasswordFormAdmin() {
	var form = document.frmAdminChangePassword;
	if(!isEmpty(form.txtOldPassword,"Please fill Old Password")) {
		form.txtOldPassword.focus();
		return false;
	}
	
	if(!isEmpty(form.txtNewPassword,"Please fill New Password")) {
		form.txtNewPassword.focus();
		return false;
	}
	else if(form.txtNewPassword.value.length < 5 || form.txtNewPassword.value.length > 12) {
		alert("Password can be only between 5 to 12 characters");
		form.txtNewPassword.focus();
		return false;
	}

	if(!isEmpty(form.txtConfirmPassword,"Please fill Confirm Password")) {
		form.txtConfirmPassword.focus();
		return false;
	}
	// check if both password fields are the same
	if (form.txtNewPassword.value != form.txtConfirmPassword.value)
	{
		alert("New Password and Confirm Password are not the same.");
		form.txtConfirmPassword.focus();
		return false;
	}
	return true;
}
//function check forgot password fields at admin side
function checkForgotPasswordFormAdmin() {
	var form = document.frmAdminLogin;
	if(!isEmpty(form.fldEmail,"Please fill  Email ID")) {
			form.fldEmail.focus();
			return false;
		}
		else if(!echeck(form.fldEmail,"Please fill valid Email ID")){
			//form.fldEmail.value="";
			form.fldEmail.focus();
			return false;
		}
		else if(form.fldEmail.value.length > 100) {
			alert("Email ID can not have more than 100 characters");
			form.fldEmail.focus();
			return false;
	}
}
//function check add/edit Answer Form
function checkAnswerForm() {
	var form = document.answerForm;
	if(form.fldAnswerText.value==""){
		alert("Please enter answer text.");
		form.fldAnswerText.focus();
		return false;
	}
	return true;
}

//function check add/edit Question Form
function checkQuestionAnswerForm() {
	var form = document.questionAnswerForm;
	if(form.fldQuestionText.value==""){
		alert("Please enter voice text.");
		form.fldQuestionText.focus();
		return false;
	}
	return true;
}

//function check add/edit Tag Form
function checkTagForm() {
	var form = document.tagForm;
	if(!isEmpty(form.fldTag,"Please fill Tag")) {
		form.fldTag.focus();
		return false;
	}
	else if(!isAlphabet(form.fldTag,"Tag")) {
		return false;
	}
	else if(form.fldTag.value.length > 30) {
		alert("Tag can not have more than 30 characters");
		form.fldAnswerTwo.focus();
		return false;
	}
	if(form.fldTagType.value == "no") {
		alert("Please select Tag type");
		form.fldTagType.focus();
		return false;
	}
	return true;
}
function checkUserFormAdmin(){
	form = document.userForm;
	var year;
	/*
	var emailID=form.fldEmail;
	var username=form.fldUserName;

	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value,'Please Enter your valid Email ID')==false){
		emailID.focus()
		return false
	}
	
	if ((document.getElementById("userName").value==null)||(document.getElementById("userName").value=="")){
		alert("Please Enter username")
		document.getElementById("userName").focus()
		return false
	}
	if(document.getElementById("userName").value.match(/[^a-z0-9A-Z]/) != null) {
		alert("Please Enter valid username")
		document.getElementById("userName").focus()
		return false
	}
*/
	
	var fldZip = form.fldZip;
	if ((fldZip.value==null)||(fldZip.value=="")){
		alert("Please Enter Postal Code")
		fldZip.focus()
		return false
	}

	/**Check DOB***NOV-29-2007**/
	var myDate=new Date()
	myDate.setFullYear(form.fldYear.value,(form.fldMonth.value-1),form.fldDay.value)

	var today = new Date()


	leapfldYear = (form.fldYear.value) % 4;
	
	if(form.fldMonth.value == "") {
		alert("Please select Month");
		form.fldMonth.focus();
		return false;
	}
	if(form.fldDay.value == "") {
		alert("Please select Day");
		form.fldDay.focus();
		return false;
	}
	
	if(form.fldYear.value == "") {
		alert("Please select Year");
		form.fldYear.focus();
		return false;
	}
	if((form.fldDay.value > 30) && (form.fldMonth.value == '04' || form.fldMonth.value == '06' || form.fldMonth.value == '09' || form.fldMonth.value == '11' )) {
		alert("Please select date less than 31");
		form.fldDay.focus();
		return false;
	}
	if(form.fldDay.value > 29 && form.fldMonth.value == 02  && leapfldYear == 0) {
		alert("Please select Day less than 30");
		form.fldDay.focus();
		return false;
	}
	else if(form.fldDay.value > 28 && form.fldMonth.value == 02  && leapfldYear > 0) {
		alert("Please select Day less than 29");
		form.fldDay.focus();
		return false;
	}
	else if (myDate>today) {
		 alert("Please select date less than current date");
		 form.fldDay.focus();
		return false;
	}
	
}
function checkUserForm() {

	form = document.userForm;
	var emailID=form.fldEmail;
	var year;
	var username=form.fldUserName;

	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value,'Please Enter your valid Email ID')==false){
		emailID.focus()
		return false
	}
	
	if ((document.getElementById("userName").value==null)||(document.getElementById("userName").value=="")){
		alert("Please Enter username")
		document.getElementById("userName").focus()
		return false
	}
	if(document.getElementById("userName").value.match(/[^a-z0-9A-Z]/) != null) {
		alert("Please Enter valid username")
		document.getElementById("userName").focus()
		return false
	}

	var fldPassword = form.fldPassword;
	if ((fldPassword.value==null)||(fldPassword.value=="")){
		alert("Please Enter Password")
		fldPassword.focus()
		return false
	}

	var fldRePassword = form.fldRePassword;
	if ((fldRePassword.value==null)||(fldRePassword.value=="")){
		alert("Please Enter Confirm Password")
		fldRePassword.focus()
		return false
	}

	if(fldPassword.value != fldRePassword.value) {
		alert("Passwords do not match")
		fldPassword.focus()
		return false
	}

	var fldZip = form.fldZip;
	if ((fldZip.value==null)||(fldZip.value=="")){
		alert("Please Enter Postal Code")
		fldZip.focus()
		return false
	}

	if(!document.getElementById("txtGender").checked){
		alert("Please select Gender");
		document.getElementById("txtGender").focus();
		return false;
	}
	/**Check DOB***NOV-29-2007**/
	var myDate=new Date()
	myDate.setFullYear(form.fldYear.value,(form.fldMonth.value-1),form.fldDay.value)

	var today = new Date()


	leapfldYear = (form.fldYear.value) % 4;
	
	if(form.fldMonth.value == "") {
		alert("Please select Month");
		form.fldMonth.focus();
		return false;
	}
	if(form.fldDay.value == "") {
		alert("Please select Day");
		form.fldDay.focus();
		return false;
	}
	
	if(form.fldYear.value == "") {
		alert("Please select Year");
		form.fldYear.focus();
		return false;
	}
	if((form.fldDay.value > 30) && (form.fldMonth.value == '04' || form.fldMonth.value == '06' || form.fldMonth.value == '09' || form.fldMonth.value == '11' )) {
		alert("Please select date less than 31");
		form.fldDay.focus();
		return false;
	}
	if(form.fldDay.value > 29 && form.fldMonth.value == 02  && leapfldYear == 0) {
		alert("Please select Day less than 30");
		form.fldDay.focus();
		return false;
	}
	else if(form.fldDay.value > 28 && form.fldMonth.value == 02  && leapfldYear > 0) {
		alert("Please select Day less than 29");
		form.fldDay.focus();
		return false;
	}
	else if (myDate>today) {
		 alert("Please select date less than current date");
		 form.fldDay.focus();
		return false;
	}
	if (document.getElementById("verificationTxt").value==""){
		alert("Please fill Verification code")
		document.getElementById("verificationTxt").focus()
		return false;
	}
	 if(!form.agreechk.checked){
		alert("Please accept the terms of use and privacy policy");
		form.agreechk.focus();
		return false;
	}
	
	/***END DOB****/

}


function checkDOB(str) {
	dobArr = str.split('-');
	year = parseInt(dobArr[0]);
	month = parseInt(dobArr[1]);
	day = parseInt(dobArr[2]);

	currentYear = new Date().getYear();
	currentYear += 2000; 

	if(isNaN(year) || year < 1900 || year > currentYear) {
		return false;
	}
	if(isNaN(month) || month < 1 || month > 12) {
		return false;
	}
	if(isNaN(day) || day < 1 || day > 31) {
		return false;
	}

	leapYear = false;

	if(year%4 == 0) {
		leapYear = true;
	}

	switch (month)
	{
	case 2:
		if(leapYear == true)
			maxDays = 29;
		else
			maxDays = 28;
	break;
	case 4:
	case 6:
	case 9:
	case 11:
		maxDays = 30;
		break;
	}

	if(day > maxDays) {
		return false;
	}
}

/*function echeck(str) {alert(str);

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}*/
//function for company
function checkCompanyForm(){

	if(document.getElementById("cname").value==''){
		mesg='Please Enter Company Name';
		alert(mesg);
       document.getElementById("cname").focus();
	   return false;
	}

	if(document.getElementById("caddress").value==''){
		mesg='Please Enter Company Address';
		alert(mesg);
       document.getElementById("caddress").focus();
	   return false;
	}

	if(document.getElementById("cstreet").value==''){
	   mesg='Please Enter Company Street';
	   alert(mesg);
       document.getElementById("cstreet").focus();
	   return false;
	}

	if(document.getElementById("cCity").value==''){
		mesg='Please Enter Company City';
		alert(mesg);
       document.getElementById("cCity").focus();
	   return false;
	}

  if(document.getElementById("cState").value==''){
		mesg='Please Enter Company State';
		alert(mesg);
       document.getElementById("cState").focus();
	   return false;
	}

  if(validateZIP2(document.getElementById("cZip").value)==false){

	 document.getElementById("cZip").focus();
	 return false;
	}

	if(document.getElementById("cZip").value==''){
		mesg='Please Enter zipcode ';
		alert(mesg);
       document.getElementById("cZip").focus();
	   return false;
	}

 if(document.getElementById("cxcoord").value==''){
		mesg='Please Enter X Co-ordinate ';
		alert(mesg);
       document.getElementById("cxcoord").focus();
	   return false;
	}

if(document.getElementById("ycoord").value==''){
		mesg='Please Enter Y Co-ordinate ';
		alert(mesg);
       document.getElementById("ycoord").focus();
	   return false;
	}
return true;
}

function validateZIP2(field) {
var valid = "0123456789-";
var hyphencount = 0;

if (field.length!=5 && field.length!=10) {
alert("Please enter your 5 digit or 5 digit+4 zip code.");
return false;
}
for (var i=0; i < field.length; i++) {
temp = "" + field.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your zip code.  Please try again.");
return false;
}
if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
return false;
   }
}
return true;
}//End function

//Form check for Deals
function echeckDealForm(){

      if(document.getElementById("ListingTitle").value==''){
	  mesg='Please Fill Listing Title';
	  alert(mesg);
      document.getElementById("ListingTitle").focus();
	  return false;
	  }

	  if(document.getElementById("Description").value==''){
	  mesg='Please Fill Description';
	  alert(mesg);
      document.getElementById("Description").focus();
	  return false;
	  }

	  if(document.getElementById("Company").value==''){
	  mesg='Please Fill Company Name';
	  alert(mesg);
      document.getElementById("Company").focus();
	  return false;
	  }

	  if(document.getElementById("Price").value==''){
	  mesg='Please Fill Price';
	  alert(mesg);
      document.getElementById("Price").focus();
	  return false;
	  }

	  if(isDate(document.getElementById("Date").value)==false)
		{
			document.getElementById("Date").value="";
			document.getElementById("Date").focus();
			return false;
		}

 
	return true;
}//End of function

function numberWithoutDecimal(e,dvalue){
	
	var unicode; //=e.charCode? e.charCode : e.keyCode
			
	if( !e ) {
		if( window.event ) {
			e = window.event;
		}else {}
	}
  
	if(e.keyCode) {
		unicode = e.keyCode;
	} else if(e.which) {
		unicode = e.which;
	} else if(e.charCode) {
		unicode = e.charCode;
	} else {}
	
	if(unicode!=8 && unicode!=13 && unicode!=9){

			if(unicode < 48 || unicode > 57){
	           return false;}
	}
	
 }


 //Date function

var dtCh= "-";
var minYear=1900;
var maxYear=2100;
 
function isInteger(s){
 var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}


function stripCharsInBag(s, bag){
 var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
 
function daysInFebruary (year){
 // February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function DaysArray(n) {
 for (var i = 1; i <= n; i++){
  this[i] = 31
  if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
  if (i==2) {this[i] = 29}
   } 
   return this
}
function isDate(dtStr){

 var daysInMonth = DaysArray(12)
    
 var pos1=dtStr.indexOf(dtCh)
	 
 var pos2=dtStr.indexOf(dtCh,pos1+1)
 
 var strMonth=dtStr.substring(pos1+1,pos1+3)
 var strDay=dtStr.substring(pos2+1)
 var strYear=dtStr.substring(0,pos1)
 
 strYr=strYear
 if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
 if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
 for (var i = 1; i <= 3; i++) {
		  if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
		 }
 month=parseInt(strMonth)
 day=parseInt(strDay)
 year=parseInt(strYr)
	 if (pos1==-1 || pos2==-1){
	  alert("The date format should be : yyyy-mm-dd")
	  return false
	 }
		 if(isNaN(month)){
		  alert("Please enter a valid month")
		  return false
		 }
			 if (strMonth.length<1 || month<1 || month>12){
			  alert("Please enter a valid month")
			  return false
			 }
		 if(isNaN(day)){
		  alert("Please enter a valid day")
		  return false
		 }
		 if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		  alert("Please enter a valid day")
		  return false
		 }
			 if (strYear.length != 4 || year==0 || year<minYear){
			  alert("Please enter a valid 4 digit year")
			  return false
			 }
				 if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
				  alert("Please enter a valid date")
				  return false
				 }
		 return true
		}

// End of function


function validateDicussionNewsletter() {
	form = document.dicussionNewsletterForm;

	var discussionNewsletterEmail = form.discussionNewsletterEmail.value;

	if ((discussionNewsletterEmail==null)||(discussionNewsletterEmail=="")){
		alert("Please Enter your Email ID")
		form.discussionNewsletterEmail.focus()
		return false
	}
	if (echeck(discussionNewsletterEmail)==false){
		alert("Please Enter your valid Email ID")
		form.discussionNewsletterEmail.focus()
		return false
	}

	return true;
}
//Nov-28-2007
//function to check all fields validation for invite friend form
function checkInviteFriend() {
	var form = document.inviteFriendForm;
	if(!isEmpty(form.fldEmail,"Please fill  Email ID")) {
		form.fldEmail.focus();
		return false;
	}
	else if(!echeck(form.fldEmail.value,"Please fill valid Email ID")){
		form.fldEmail.focus();
		return false;
	}
	else if(form.fldEmail.value.length > 100) {
		alert("Email ID can not have more than 100 characters");
		form.fldEmail.focus();
		return false;
	}
	return true;
}
/***NOV-28-2007
Function will check the request text
***/
function chkFriendRequest(){
	form = document.frndRequest;
	if(!isEmpty(form. fldMessage,"Please fill Message")) {
		form. fldMessage.focus();
		return false;
	}
}
/***NOV-29-2007
Function will check the question text
***/
function checkQDataAll(){
	with(document.footerFrm){
		if(fldQuestionText.value==""){
			alert("Question is blank.");
			fldQuestionText.focus();
			return false;
		}
	}
}
//End form check for deals