function validate_contactus_form() {
	var pb=document.contactus_form;
	if (pb.personName.value==0) {
		alert("Please enter your name");
		pb.personName.focus();
		return false;
	}
	
	if (!isNaN(pb.personName.value)) {
		alert("Name should be in alphabets only");
		pb.personName.focus();
		return false;
	}
	
	var email_check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if((pb.email.value.length >= 0) && (!email_check.test(pb.email.value))) {
		alert("Please enter a valid Email ID");
		pb.email.focus();
		return false;
	}
	
	if (pb.phone.value!=0) {
		if (pb.phone.value.length < 8) {
			alert("Please enter a valid phone number");
			pb.phone.focus();
			return false;
		}
		if (isNaN(pb.phone.value)) {
			alert("Phone number should be in numeric only");
			pb.phone.focus();
			return false;
		}
	}
	
	if (pb.address.value==0) {
		alert("Please enter your address");
		pb.address.focus();
		return false;
	}
	
	if (pb.city.value==0) {
		alert("Please enter your city");
		pb.city.focus();
		return false;
	}
	
	if (pb.country.value==0) {
		alert("Please select your country");
		pb.country.focus();
		return false;
	}
	
	if (pb.zipcode.value!=0) {
		if (pb.zipcode.value.length < 2) {
			alert("Please enter a valid zipcode number");
			pb.zipcode.focus();
			return false;
		}
		/*
		if (isNaN(pb.zipcode.value)) {
			alert("Zipcode number should be in numeric only");
			pb.zipcode.focus();
			return false;
		}
		*/
	}
	
	if (pb.comments.value==0) {
		alert("Please enter enquiry for details.");
		pb.comments.focus();
		return false;						
	}
	
	if(pb.security_code.value.length < 6){
		alert("Please enter verification code");
		pb.security_code.focus();
		return false;	
	}
}


function validate_feedback_form() {
	var pb=document.feedback_form;
	if (pb.firstName.value==0) {
		alert("Please enter your first name");
		pb.firstName.focus();
		return false;
	}
	
	if (!isNaN(pb.firstName.value)) {
		alert("Name should be in alphabets only");
		pb.firstName.focus();
		return false;
	}
	
	if (pb.lastName.value==0) {
		alert("Please enter your last name");
		pb.lastName.focus();
		return false;
	}
	
	if (!isNaN(pb.lastName.value)) {
		alert("Name should be in alphabets only");
		pb.lastName.focus();
		return false;
	}
	
	
	if (pb.companyName.value==0) {
		alert("Please enter your company name");
		pb.companyName.focus();
		return false;
	}
	
	var email_check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if((pb.email.value.length >= 0) && (!email_check.test(pb.email.value))) {
		alert("Please enter a valid Email ID");
		pb.email.focus();
		return false;
	}
	
	if (pb.comments.value==0) {
		alert("Please enter enquiry for details.");
		pb.comments.focus();
		return false;						
	}
	
	if(pb.security_code.value.length < 6){
		alert("Please enter verification code");
		pb.security_code.focus();
		return false;	
	}
}


function validate_login_form() {
	var pb=document.login_form;
	
	var email_check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if((pb.email.value.length >= 0) && (!email_check.test(pb.email.value))) {	
		alert("Please enter your User Name");
		pb.email.value = "";
		pb.email.focus();
		return false;
	}
	
	if (pb.pwd.value == 0 || pb.pwd.value == "Enter Your Password") {
		alert("Please enter your password");
		pb.pwd.value = "";
		pb.pwd.focus();
		return false;
	}	
}


function validate_forgot_password() {
	var pb=document.forgot_password;
	
	var email_check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if((pb.email.value.length >= 0) && (!email_check.test(pb.email.value))) {	
		alert("Please enter your Email ID");
		pb.email.value = "";
		pb.email.focus();
		return false;
	}
}


function validate_newsletter_form() {
	var pb=document.newsletter_form;
	
	if (pb.name.value == 0) {
		alert("Please enter your name");
		pb.name.focus();
		return false;
	}
	
	var email_check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;	
	if((pb.email.value.length >= 0) && (!email_check.test(pb.email.value))) {
		alert("Please enter a valid Email ID");
		pb.email.focus();
		return false;
	}
}


function validate_register_member_form() {
	var pb=document.register_member_form;
	var email_check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var pwd_check = /^([a-zA-Z0-9])+$/;
	var name_check = /^([a-zA-Z\s])+([\s])*([a-zA-Z\s])*$/;
	
	if (pb.firstName.value==0) {
		alert("Please enter your first name");
		pb.firstName.focus();
		return false;
	}
	if (!name_check.test(pb.firstName.value)) {
		alert("Name should be in alphabets only");
		pb.firstName.focus();
		return false;
	}
	
	if (pb.lastName.value==0) {
		alert("Please enter your last name");
		pb.lastName.focus();
		return false;
	}
	if (!name_check.test(pb.lastName.value)) {
		alert("Name should be in alphabets only");
		pb.lastName.focus();
		return false;
	}
	
	if (pb.companyName.value==0) {
		alert("Please enter your company name");
		pb.companyName.focus();
		return false;
	}
	
	if (pb.phone.value.length > 0) {
		if (isNaN(pb.phone.value)) {
			alert("Phone number should be numeric only");
			pb.phone.focus();
			return false;
		}
	}
	
	if (pb.address.value==0) {
		alert("Please enter your address");
		pb.address.focus();
		return false;
	}
	
	if (pb.city.value==0) {
		alert("Please enter your city");
		pb.city.focus();
		return false;
	}
	if (!name_check.test(pb.city.value)) {
		alert("City name should be in alphabets only");
		pb.city.focus();
		return false;
	}
	
	if (pb.state.value!=0) {		
		if (!name_check.test(pb.state.value)) {
			alert("State name should be in alphabets only");
			pb.state.focus();
			return false;
		}
	}
	
	if (pb.pinCode.value!=0) {
		if (pb.pinCode.value.length < 2) {
			alert("Please enter a valid pin code number");
			pb.pinCode.focus();
			return false;
		}
		/*
		if (isNaN(pb.pinCode.value)) {
			alert("Pin code number should be numeric only");
			pb.pinCode.focus();
			return false;
		}
		*/
	}	
	
	if (pb.country.options[pb.country.selectedIndex].value == "") {
		alert("Please select your country");
		pb.country.focus();
		return false;
	}
	
	if (pb.email.value==0) {
		alert("Please enter your Email ID");
		pb.email.focus();
		return false;
	}
	
	if(!email_check.test(pb.email.value)) {
		alert("Please enter a valid Email ID");
		pb.email.focus();
		return false;
	}
	
	if (pb.pwd.value == 0) {
		alert("Please enter your password");
		pb.pwd.focus();
		return false;
	}
	if (pb.pwd.value.length < 5) {
		alert("Password must be atleast 5 characters long (a-z, A-Z, 0-9 only");
		pb.pwd.focus();
		return false;
	}
	if((pb.pwd.value.length > 0) && (!pwd_check.test(pb.pwd.value))) {
		alert("Password must be atleast 5 characters long (a-z, A-Z, 0-9 only)");
		pb.pwd.focus();
		return false;
	}
	
	if (pb.cpwd.value == 0) {
		alert("Please confirm your password");
		pb.cpwd.focus();
		return false;
	}
	
	if (pb.pwd.value != pb.cpwd.value) {
		alert("Confirm Password does not match");
		pb.cpwd.focus();
		return false;
	}
	
	if(pb.security_code.value.length < 6){
		alert("Please enter verification code");
		pb.security_code.focus();
		return false;	
	}
	
	/*	
	if (pb.terms.value != "Y") {
		alert("Please select terms of use");
		pb.terms.focus();
		return false;
	}
	*/
}


function validate_change_password_form() {
	var pb=document.change_password_form;
	
	if (pb.opwd.value==0) {
		alert("Please enter your old password");
		pb.opwd.focus();
		return false;
	}
	
	if (pb.npwd.value == 0) {
		alert("Please enter your new password");
		pb.npwd.focus();
		return false;
	}
	
	if (pb.npwd.value.length < 6) {
		alert("Please enter a valid password [Minimum 6 characters]");
		pb.npwd.focus();
		return false;
	}
	
	if (pb.cpwd.value == 0) {
		alert("Please confirm your new password");
		pb.cpwd.focus();
		return false;
	}
	
	if (pb.npwd.value != pb.cpwd.value) {
		alert("Confirm Password does not match");
		pb.cpwd.focus();
		return false;
	}	
}


function validate_add_new_product_form() {
	var pb=document.add_new_product_form;
	
	if (pb.mainCategory.options[pb.mainCategory.selectedIndex].value == "") {
		alert("Please select your category");
		pb.mainCategory.focus();
		return false;
	}
	
	var pkb=0;
	var len=pb.industryType.length;
	
	if (!len) {
		if (!pb.industryType.checked) {
			alert("Please check atleaset one Sub Categories");
			pb.industryType.focus();
			return false;
		}
	}
	else {
		for (var i=0; i < len; i++) {
			if (pb.industryType[i].checked) {
				pkb=1;
				break;
			}
		}
		if (pkb == 0) {
			alert("Please check atleaset one Sub Categories");
			pb.industryType[0].focus();
			return false;
		}
	}
	
	if(pb.productName.value == 0){
		alert("Please enter product name");
		pb.productName.focus();
		return false;	
	}
	
	if(pb.make.value == 0){
		alert("Please enter product make details");
		pb.make.focus();
		return false;	
	}
	
	
	if(pb.yom.value != 0) {
		if(pb.yom.value.length != 4){
			alert("Please enter product year of manufacture eg : 1999, 2010 etc");
			pb.yom.focus();
			return false;	
		}
		if (isNaN(pb.yom.value)) {	
			alert("Please enter only numeric values");
			pb.yom.focus();
			return false;	
		}
	}
	
	if(pb.manufacturer.value == 0){
		alert("Please enter product manufacturer name");
		pb.manufacturer.focus();
		return false;	
	}
	
	if(pb.productLocation .value == 0){
		alert("Please enter product location");
		pb.productLocation.focus();
		return false;	
	}
	
	/*
	if(pb.dealerPrice.value == 0){
		alert("Please enter product price");
		pb.dealerPrice.focus();
		return false;	
	}
	if (isNaN(pb.dealerPrice.value)) {	
		alert("Please enter only numeric values");
		pb.dealerPrice.focus();
		return false;	
	}
	*/
	
	if(pb.dealerPrice.value == 0){
		if(!pb.csp.checked){
			alert("Please enter product price or check the Contact Seller for Price option");
			pb.dealerPrice.focus();
			return false;	
		}
	}
	
	if(pb.completeDescription.value == 0){
		alert("Please enter product description");
		pb.completeDescription.focus();
		return false;	
	}
	
	if (pb.image1.value != 0) {
		if ((pb.image1.value.lastIndexOf('.jpg')==-1) && (pb.image1.value.lastIndexOf('.gif')==-1) && (pb.image1.value.lastIndexOf('.jpeg')==-1) && (pb.image1.value.lastIndexOf('.png')==-1)) {
			alert('You May Only Upload .jpg, .jpeg, .png, .gif Files');
			pb.image1.focus();
			return false;
		}
	}
	if (pb.image2.value != 0) {
		if ((pb.image2.value.lastIndexOf('.jpg')==-1) && (pb.image2.value.lastIndexOf('.gif')==-1) && (pb.image2.value.lastIndexOf('.jpeg')==-1) && (pb.image2.value.lastIndexOf('.png')==-1)) {
			alert('You May Only Upload .jpg, .jpeg, .png, .gif Files');
			pb.image2.focus();
			return false;
		}
	}
	if (pb.image3.value != 0) {
		if ((pb.image3.value.lastIndexOf('.jpg')==-1) && (pb.image3.value.lastIndexOf('.gif')==-1) && (pb.image3.value.lastIndexOf('.jpeg')==-1) && (pb.image3.value.lastIndexOf('.png')==-1)) {
			alert('You May Only Upload .jpg, .jpeg, .png, .gif Files');
			pb.image3.focus();
			return false;
		}
	}
	if (pb.image4.value != 0) {
		if ((pb.image4.value.lastIndexOf('.jpg')==-1) && (pb.image4.value.lastIndexOf('.gif')==-1) && (pb.image4.value.lastIndexOf('.jpeg')==-1) && (pb.image4.value.lastIndexOf('.png')==-1)) {
			alert('You May Only Upload .jpg, .jpeg, .png, .gif Files');
			pb.image4.focus();
			return false;
		}
	}
	
	if (pb.productMannual.value != 0) {
		if ((pb.productMannual.value.lastIndexOf('.pdf')==-1) && (pb.productMannual.value.lastIndexOf('.doc')==-1) && (pb.productMannual.value.lastIndexOf('.rtf')==-1) && (pb.productMannual.value.lastIndexOf('.txt')==-1)) {
			alert('You May Only Upload .pdf, .doc, .rtf, .txt Files');
			pb.image1.focus();
			return false;
		}
	}
}


function validate_edit_expired_product_form() {
	var pb=document.edit_expired_product_form;
	
	if(pb.clientComment.value == 0){
		alert("Please enter your comment");
		pb.clientComment.focus();
		return false;	
	}
}


function validate_add_new_wanted_machine_form() {
	var pb=document.add_new_wanted_machine_form;
	
	if(pb.visitorName.value == 0){
		alert("Please enter your name");
		pb.visitorName.focus();
		return false;	
	}
	if (!isNaN(pb.visitorName.value)) {
		alert("Name should be in alphabets only");
		pb.visitorName.focus();
		return false;
	}
	
	var email_check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if((pb.email.value.length >= 0) && (!email_check.test(pb.email.value))) {
		alert("Please enter a valid Email ID");
		pb.email.focus();
		return false;
	}
	
	if (pb.address.value==0) {
		alert("Please enter your address");
		pb.address.focus();
		return false;
	}
	
	if (pb.mainCategory.options[pb.mainCategory.selectedIndex].value == "") {
		alert("Please select your category");
		pb.mainCategory.focus();
		return false;
	}
	
	var pkb=0;
	var len=pb.industryType.length;
	
	if (!len) {
		if (!pb.industryType.checked) {
			alert("Please check atleaset one Sub Categories");
			pb.industryType.focus();
			return false;
		}
	}
	else {
		for (var i=0; i < len; i++) {
			if (pb.industryType[i].checked) {
				pkb=1;
				break;
			}
		}
		if (pkb == 0) {
			alert("Please check atleaset one Sub Categories");
			pb.industryType[0].focus();
			return false;
		}
	}
	
	if(pb.productName.value == 0){
		alert("Please enter product name");
		pb.productName.focus();
		return false;	
	}
	
	if(pb.dealerPrice.value != 0){		
		if (isNaN(pb.dealerPrice.value)) {	
			alert("Please enter only numeric values");
			pb.dealerPrice.focus();
			return false;	
		}
	}	
	
	if(pb.completeDescription.value == 0){
		alert("Please enter product description");
		pb.completeDescription.focus();
		return false;	
	}
	
	if (pb.image1.value != 0) {
		if ((pb.image1.value.lastIndexOf('.jpg')==-1) && (pb.image1.value.lastIndexOf('.gif')==-1) && (pb.image1.value.lastIndexOf('.jpeg')==-1) && (pb.image1.value.lastIndexOf('.png')==-1)) {
			alert('You May Only Upload .jpg, .jpeg, .png, .gif Files');
			pb.image1.focus();
			return false;
		}
	}	
}


function submit_form2(dropVal,slno) {	
	document.formn.recordID.value=slno;
	document.formn.featuredProduct.value=dropVal;
	document.formn.submit();	
}


function submit_form3(dropVal,slno) {	
	document.formn.recordID.value=slno;
	document.formn.newProduct.value=dropVal;
	document.formn.submit();	
}


function validate_refer_friend_form() {
	var pb=document.refer_friend_form;
	
	var name_check = /^([a-zA-Z\s])+([\s])*([a-zA-Z\s])*$/;	
	if((pb.your_name.value.length >= 0) && (!name_check.test(pb.your_name.value))) {
		alert("Please enter your name, should be in alphabets only");
		pb.your_name.focus();
		return false;
	}
	
	var email_check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if((pb.your_email.value.length >= 0) && (!email_check.test(pb.your_email.value))) {
		alert("Please enter a valid email id");
		pb.your_email.focus();
		return false;
	}
	
	if((pb.friend_name.value.length >= 0) && (!name_check.test(pb.friend_name.value))) {
		alert("Please enter your friend's name, should be in alphabets only");
		pb.friend_name.focus();
		return false;
	}
	
	if((pb.friend_email.value.length >= 0) && (!email_check.test(pb.friend_email.value))) {
		alert("Please enter a valid email id of your friend");
		pb.friend_email.focus();
		return false;
	}
}


function validate_post_banner_form() {
	var pb=document.post_banner_form;
	if (pb.firstName.value==0) {
		alert("Please enter your first name");
		pb.firstName.focus();
		return false;
	}
	
	if (!isNaN(pb.firstName.value)) {
		alert("Name should be in alphabets only");
		pb.firstName.focus();
		return false;
	}
	
	if (pb.lastName.value==0) {
		alert("Please enter your last name");
		pb.lastName.focus();
		return false;
	}
	
	if (!isNaN(pb.lastName.value)) {
		alert("Name should be in alphabets only");
		pb.lastName.focus();
		return false;
	}	
	
	if (pb.address.value==0) {
		alert("Please enter your address");
		pb.address.focus();
		return false;
	}
	
	if (pb.city.value==0) {
		alert("Please enter your city");
		pb.city.focus();
		return false;
	}
	
	if (pb.country.value==0) {
		alert("Please select your country");
		pb.country.focus();
		return false;
	}
	
	var email_check = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if((pb.email.value.length >= 0) && (!email_check.test(pb.email.value))) {
		alert("Please enter a valid Email ID");
		pb.email.focus();
		return false;
	}
	
	if (pb.bannerImage.value == 0) {
		alert("Please upload banner image");
		pb.bannerImage.focus();
		return false;
	}
	if (pb.bannerImage.value != 0) {
		if ((pb.bannerImage.value.lastIndexOf('.jpg')==-1) && (pb.bannerImage.value.lastIndexOf('.gif')==-1) && (pb.bannerImage.value.lastIndexOf('.jpeg')==-1) && (pb.bannerImage.value.lastIndexOf('.png')==-1)) {
			alert('You May Only Upload .jpg, .jpeg, .png, .gif Files');
			pb.bannerImage.focus();
			return false;
		}
	}
		
}


function validate_keyword_search() {
	var pb=document.keyword_search;
	if (pb.keyword.value==0 || pb.keyword.value=="Search") {
		alert("Please enter search keyword");
		pb.keyword.focus();
		return false;
	}
}


function validate_payment_form() {
	var pb=document.payment_form;
	
	var pkb=0;
	
	var len=document.getElementsByName('paymentMethod').length;
	var obj=document.getElementsByName('paymentMethod');
	
	for (var i=0; i < len; i++) {
		if (obj[i].checked) {
			pkb=1;
			break;
		}
	}
	if (pkb == 0) {
		alert('Please select atleast one payment method.');
		return false;
	}
	
	if (!pb.terms.checked) {
		alert("Please accept terms & conditions");
		pb.terms.focus();
		return false;
	}
}


function validate_set_status_form () {
	var pb=document.set_status_form;
	
	var pkb=0;
	
	var len=document.getElementsByName('enquiry_id[]').length;
	var obj=document.getElementsByName('enquiry_id[]');
	
	for (var i=0; i < len; i++) {
		if (obj[i].checked) {
			pkb=1;
			break;
		}
	}
	if (pkb == 0) {
		alert('Please select atleast one enquiry.');
		return false;
	}
	
	if (pb.enquiry_status.options[pb.enquiry_status.selectedIndex].value == "") {
		alert("Please select enquiry status");
		pb.enquiry_status.focus();
		return false;
	}
}


function chk_unchk_all(){
	var pb=document.set_status_form;
	var count = pb.elements.length;
	var i=0;
	var ids="";
	
	if(pb.chk_unchk_chbx.checked == 0){
		for (i=0; i < count; i++){
			if(pb.elements[i].type=="checkbox"){
				pb.elements[i].checked = 0;
				pb.chk_unchk_chbx.checked=0;
			}
		}
	}
	
	if(pb.chk_unchk_chbx.checked == 1 ){
		for (i=0; i < count; i++){
			if(pb.elements[i].type=="checkbox"){
				pb.elements[i].checked = 1;
				pb.chk_unchk_chbx.checked=1;
				if (pb.elements[i].value) {
					ids+=pb.elements[i].value+"^";
				}
			}
		}
	}
	
	if (ids == "") {
		document.getElementById('prem_1').style.display="block";
		document.getElementById('prem_2').style.display="none";
	}
	else {
		document.getElementById('prem_1').style.display="none";
		document.getElementById('prem_2').style.display="block";
		document.getElementById('fancy_box').href='reply_enquiry.php?ids='+ids;
	}
}


function chk_unchk_single(form_name) {
	dml=eval('document.'+form_name);
	len=dml.elements.length;
	var i=0;
	var ids="";
	for (i=0; i<len; i++) {
		if (dml.elements[i].type == "checkbox") {
			if (dml.elements[i].checked==true) {
				if (dml.elements[i].value) {
					ids+=dml.elements[i].value+"^";
				}
			}			
		}
	}
	
	if (ids == "") {
		document.getElementById('prem_1').style.display="block";
		document.getElementById('prem_2').style.display="none";
	}
	else {
		document.getElementById('prem_1').style.display="none";
		document.getElementById('prem_2').style.display="block";
		document.getElementById('fancy_box').href='reply_enquiry.php?ids='+ids;
	}
}


function validate_chk_box() {
	var pkb="";
	
	var len=document.getElementsByName('enquiry_id[]').length;
	var obj=document.getElementsByName('enquiry_id[]');
	
	for (var i=0; i < len; i++) {
		if (obj[i].checked) {
			pkb=1;
			break;
		}
	}
	if (pkb == 0) {
		alert('Please select atleast one enquiry.');
		document.getElementById('prem_1').style.display="block";
		document.getElementById('prem_2').style.display="none";
		return false;
	}	
}


function submit_form(slno, expiryDate, plan) {	
	document.formn.recordID.value=slno;
	document.formn.expiryDate.value=document.getElementById(expiryDate).value;
	document.formn.planType.value=document.getElementById(plan).value;
	document.formn.submit();	
}


function submit_form4(slno, expiryDate, form_action) {	
	document.formn.recordID.value=slno;
	document.formn.expiryDate.value=document.getElementById(expiryDate).value;
	document.formn.submit();	
}


function display_field(cnt) {
	document.getElementById("display_keyword_option").style.display='none';
	document.getElementById("display_categories_option").style.display='none';
	
	if (cnt == 5 || cnt == 6 || cnt == 7 || cnt == 8) {
		document.getElementById("display_keyword_option").style.display='block';
	}
	if (cnt == 30 || cnt == 31 || cnt == 32 || cnt == 33) {
		document.getElementById("display_categories_option").style.display='block';
	}
}
