// FURTADOS JS FUNCTIONS

//var PREFIX = '/furtados/';
var PREFIX = '/';
function trim(str){
	var s = str.replace(/^(\s)*/, '');
	s = s.replace(/(\s)*$/, '');
	return s;
}

function isValidEmail(str) {
	emailRe = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/
	if (!emailRe.test(str))	
		return false;	
	else
		return true;				
}

// FUNCTION FOR TOP SEARCH
function checkSearch(){
	var st = trim(document.getElementById("searchText").value);
	if(st == "" || st == "Search"){
		alert("Please enter your search criteria.");	
		document.getElementById("searchText").value = '';
		document.getElementById("searchText").focus();
		return false;
	}
	return true;
}//checkSearch()

// FUNCTION TO RESET THE FORM
function clearForm(form){
 $(':input', form).each(function() {
 var type = this.type;
 var tag = this.tagName.toLowerCase(); 
 if (type == 'text' || type == 'password' || tag == 'textarea')
   this.value = "";
 else if (type == 'checkbox' || type == 'radio')
   this.checked = false;
 else if (tag == 'select')
   this.selectedIndex = 0;
  });
}

// FUNCTION TO CLICK CHECKBOXES : MUSICIAN REGISTRATION
function checkAllReg(form){

 $(':input', form).each(function() {
	var type = this.type;
	if(type == 'checkbox'){
		
		if(document.getElementById("all").checked == false){
			this.checked = false;
		}else{
			this.checked = true;
		}
	}
});
}

// FUNCTION TO CLICK CHECKBOXES : MUSIC TEACHER REGISTRATION
function checkAllRegTeacher(form) {

 $(':input', form).each(function() {
	var type = this.type;
	if(type == 'checkbox'){
		if(document.getElementById("all_instruments").checked == false){
			this.checked = false;
		}else{
			this.checked = true;
		}
	}
});
}

// NEWSLETTER SUBSCRIPTION
function subscribe(){
	var frm=document.newsletter_subscription;
	var email = trim(frm.emailID.value);
	
	if(email== "" || email == "Enter Your Email ID here.."){
		alert("Please enter your email address.");	
		frm.emailID.value = '';
		frm.emailID.focus();
		return false;
	}else if(trim(frm.emailID.value) != ""){
			emailvalid=isValidEmail(email);	
			if(emailvalid!=true){
				alert("Please enter valid email address.");
				frm.emailID.value = "";
				frm.emailID.focus();	
				return false;
			}else{	
				$.post(PREFIX+"newsletter_subscription2db.php", { emailvalue:email},
				function(data){	//alert(data);
					if(data == 50){
						window.location = PREFIX+"index.html";
						return true;
					}else{
						$('#newsletter').html(data);
					}
				});	
				return true;
			}
	}//else
}

// ADD ADDRESS BOOK SUBSCRIPTION
function addressbook(flag, rd){
	
	if(flag == "addressbook"){
		var frm = document.add_addressbook;
	}else if(flag == "shipping"){
		var frm = document.shippingaddress_form;
	}
	
	var address_title = trim(frm.address_title.value);
	var first_name = trim(frm.first_name.value);
	var last_name = trim(frm.last_name.value);
	var address = trim(frm.address.value);
	var state = frm.state.value;
	var city = frm.city.value;
	var pincode = trim(frm.pincode.value);
	var telephone = trim(frm.telephone.value);
		
	if(flag == "addressbook"){
		var hide_action = frm.hide_action.value;
		var hide_id = frm.hide_id.value;
	}
	
	var proceed = frm.proceed.value;
	
	if(address_title == ""){
		alert("Please enter Address Title.");	
		frm.address_title.value = "";
		frm.address_title.focus();
		return false;
	}
	if(first_name == ""){
		alert("Please enter First Name.");	
		frm.first_name.value = "";
		frm.first_name.focus();
		return false;
	}
	if(last_name == ""){
		alert("Please enter Last Name.");	
		frm.last_name.value = "";
		frm.last_name.focus();
		return false;
	}
	if(address == ""){
		alert("Please enter Address.");	
		frm.address.value = "";
		frm.address.focus();
		return false;
	}
	if(state == ""){
		alert("Please select state.");	
		frm.state.focus();
		return false;
	}
	if(city == ""){
		alert("Please select city.");	
		frm.city.focus();
		return false;
	}
	if(pincode == ""){
		alert("Please enter your Pincode number.");	
		frm.pincode.value = "";
		frm.pincode.focus();
		return false;
	}else if(pincode != ""){
			if(isNaN(pincode)){
				alert("Please enter Valid Pincode number.");	
				frm.pincode.value = "";
				frm.pincode.focus();
				return false;
			}
	}
	if(telephone == ""){
		alert("Please enter your Telephone number.");	
		frm.telephone.value = "";
		frm.telephone.focus();
		return false;
	}else if(telephone != ""){
			if(isNaN(telephone)){
				alert("Please enter Valid Telephone number.");	
				frm.telephone.value = "";
				frm.telephone.focus();
				return false;
			}
	}
	
	if(proceed == 0){
		alert("Sorry, Currently we are unable to ship the product to this pincode. Please enter proper pincode.");	
		frm.pincode.focus();
		return false;	
	}


	if(flag == "addressbook"){
		$.post(PREFIX+"addaddressbook2db.php", { address_title:address_title, first_name:first_name, last_name:last_name, address:address, city:city, state:state, pincode:pincode, telephone:telephone,hide_action:hide_action,hide_id:hide_id,proceed:proceed },
			function(data){		//alert(data);
				if(data == 50){
					window.location = PREFIX+"index.php";	
					return true;
				}else{
					$('#addressbook').html(data);
					if(rd != ''){
						window.location = rd;
						return true;
					}
				}
			});
	}
	return true;
}

// ADD ADDRESS BOOK VALIDATION
function add_addressbook(){
	$.post(PREFIX+"add_addressbook_check2db.php", {},
		function(data){			//alert(data);
			if(data == "success"){
				window.location = "addaddressbook.php";
				return true;
			}else{
				$('#add_addressbook_response').html(data);
			}
		});	
	return true;
}

// DELETE ADDRESS BOOK 
function delete_addressbook(){
	var answer = confirm ("Do you want to delete it?")
	if (answer){
			var frm = document.delete_address;
			var del_address = frm.del_address.value;
			
			if(del_address == ""){
				alert("Please select Address to delete.");	
				frm.del_address.focus();
				return false;
			}else{
			
				$.post(PREFIX+"delete_addressbook2db.php", {del_address:del_address},
					function(data){								//alert(data);
						if(data == 50){
							window.location = PREFIX+"index.php";
							return true;
						}else{
							$('#delete_msg').html(data);
						}
					});	
				return true;
			}
	}
}

// MODIFY ADDRESS BOOK 
function modify_addressbook(){
		
	var frm = document.modify_address;
	var edit_address = frm.edit_address.value;
	
	if(edit_address == ""){
		alert("Please select Address to modify.");	
		frm.edit_address.focus();
		return false;
	}else{
		window.location = PREFIX+"addaddressbook.php?action=m&id="+edit_address;
		return true;
	}
}

// ADD FEEDBACK
function add_feedback(){
	var frm = document.feeback_form;
	
	var name = trim(frm.name.value);
	var email = trim(frm.email.value);
	var comment = trim(frm.comment.value);

	if(name == ""){
		alert("Please enter your Name.");	
		frm.name.value = "";
		frm.name.focus();
		return false;
	}
	if(email == ""){
		alert("Please enter your email Address.");	
		frm.email.value = "";
		frm.email.focus();
		return false;
	}
	if(email != ""){
		var emailvalid=isValidEmail(email);	
		if(emailvalid!=true){
			alert("Please enter valid email address.");
			frm.email.value = "";	
			frm.email.focus();	
			return false;
		}
	}
	if(comment == ""){
		alert("Please enter your Comment.");	
		frm.comment.value = "";
		frm.comment.focus();
		return false;
	}
	$.post(PREFIX+"feedback2db.php", { name:name, email:email, comment:comment },
			function(data){			//alert(data);
				if(data == 50){
					window.location = "index.php";
					return true;
				}else{
					$('#feedback_msg').html(data);
				}
			});	
	return true;
}

// FUNCTION FOR : ORDER SUMMARY PAGE (MOVE TO WISHLIST)
function moveToWishlist(field){
	
	var boxesTicked = "";
	for (i = document.getElementsByName('list').length - 1; i >= 0; i--) {
		if (document.getElementsByName('list')[i].checked){
			boxesTicked = boxesTicked + document.getElementsByName('list')[i].value + "\n";
		}
	}
	
	if (boxesTicked == ""){
		alert ("Select some product to move.");
		return false;
	}

	var answer = confirm ("Do you want to delete products from cart?");
	var productid_quantity,result;
	if(answer){
		var arr_productid = new Array();
		var j=0;
		
		for (i = document.getElementsByName('list').length - 1; i >= 0; i--) {
			if (document.getElementsByName('list')[i].checked){
				
				productid_quantity = document.getElementsByName('list')[i].value;
				result = productid_quantity.split("@#$");
			
				$.post(PREFIX+"addwishlist2db.php", { 'productid':result[0], 'quantity': result[1]},
				function(data){			//alert(data);
					
				});
				
			}// IF - CHK
		}//FOR
		alert("Products moved to Wishlist.");
		window.location.reload();
		return true;
	}//IF - ANSWER = YES
	
}//FUNCTION

// VIEW PRODUCT PAGE ( ADD PRODUCT TO WISHLIT )
function addtowishlist(id){	
	
	$.post(PREFIX+"addwishlist2db.php", {'productid': id}, function(data) {		//alert(data);
		var message='';
			
			if(data == 1){
				message = "This product is added to your wishlist.";
			}else if(data == 2){
				message = "Please log in to make your wishlist.";
			}else if(data == 3){
				message = "This product is already in your wishlist.";
			}else if(data == 4){
				message = "Some problem occured.";
			}else if(data == 50){
				window.location = "index.php";
				return true;
			}	
				
			var outmessage = "<div style='background:#FFFF99; position:absolute; width:195px;padding:5px; border:1px #999 solid; z-index:1; font:11px arial; color:#333;'><nobr>"+message+"</nobr><div>";
				
				$('#wishdata_'+id).html(outmessage);
				$('#wishdata_'+id).show();
				setTimeout("clearALL('wishdata_"+id+"')",3000);				
				
	});
	return true;
}

// WISH LIST - MOVE TO SHOPPING CART
function move_to_cart(field){
	
	var boxesTicked = "";
	for (i = document.getElementsByName('list').length - 1; i >= 0; i--) {
		if (document.getElementsByName('list')[i].checked){
			boxesTicked = boxesTicked + document.getElementsByName('list')[i].value + "\n";
		}
	}
	
	if (boxesTicked == ""){
		alert ("Select some product to move to shopping cart.");
		return false;
	}

	var answer = confirm ("Do you want to move these products to shopping cart?");
	var product_values = '', prod_string;
	if(answer){
		
		for (var i = document.getElementsByName('list').length - 1; i >= 0; i--) {
			if (document.getElementsByName('list')[i].checked){
				product_values = product_values + document.getElementsByName('list')[i].value + "~";
			}
		}

		var length = product_values.length - 1;					//alert(product_values);
		prod_string = product_values.substr(0,length);		    //alert(prod_string);	//	alert(length);	
		
		$.post(PREFIX+"addtocart.php", { 'prod_string':prod_string, 'flag':'wishlist'},
			function(data){			//alert(data);
				window.location.reload();
				return true;
		});
		alert("Products moved to shopping cart.");	
		return true;
		
	}//IF - ANSWER = YES	
}

// FUNCTION TO FORMAT AMOUNT (1,222.00)
function addCommas(nStr){
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

// DELETE CART PRODUCTS
function deleteAddcartProducts(field){
	//for validating if any option has been selected or not!!
	
	var boxesTicked = "";
	for (i = document.getElementsByName('list').length - 1; i >= 0; i--) {
		if (document.getElementsByName('list')[i].checked){
			boxesTicked = boxesTicked + document.getElementsByName('list')[i].value + "\n";
		}
	}
	
	if (boxesTicked == ""){
		alert ("Select some product to delete.");
		return false;
	}

	var answer = confirm ("Do you want to delete products from cart?");
	var productid_quantity,result,productid='',quantity='',totalamount=0;
	if(answer){
		var arr_productid = new Array();
		var j=0;
		
		for (i = document.getElementsByName('list').length - 1; i >= 0; i--) {
			
			if (document.getElementsByName('list')[i].checked){
				
				productid_quantity = document.getElementsByName('list')[i].value;
				result = productid_quantity.split("@#$");
				productid += result[0]+",";
				quantity += result[1]+",";
			}
		}
		
		//alert("productid="+productid+"<==>quantity="+quantity);
		
		$.post(PREFIX+"updatecart.php", { 'productid':productid, 'quantity': quantity, 'type':'delete'},
			function(data){			//alert(data);
				window.location.reload();
				return true;
		});
			
		return true;
	}//IF - ANSWER = YES
}//deleteAddcartProducts()

// UPDATE OF CART in shippingcart.php and ordersummary.php
function updatetocart(flag, shtype){

	if(flag == "updatecart"){
		var field = document.updatecart;
	}else if(flag == "ordersummary"){
		var field = document.ordersummary;
	}
	
	var quantity='',price='',productid='',amount,totalamount=0,checkboxvalue='';
	var answer = confirm("Do you want to update cart?")
	if(answer){
		
		var arr_productid = new Array();
		var action = "m";
		
		for (i = 0; i < field.elements.length; i++){
			if(field.elements[i].type ==  "text" && field.elements[i].name ==  "quantity"){
				quantity += Math.round(field.elements[i].value)+",";
			}
			if(field.elements[i].type ==  "hidden"){
				if(field.elements[i].name ==  "productid"){
					productid += field.elements[i].value+",";
				}
			}
		}
		
		//alert(productid); alert(quantity);
		
		$.post(PREFIX+"updatecart.php", {'productid':productid, 'quantity': quantity, 'type':'update'},
			function(data){					//alert(data);
				
				if(flag == "updatecart"){
					window.location = PREFIX+"shoppingcart.php";	
					return true;
				}else if(flag == "ordersummary"){
					window.location = PREFIX+"ordersummary.php";
					return true;
				}
			
			});
		
	}// IF - ANSWER
}

// FUNCTION FOR WISH LIST AND ADD TO CART PAGE 
function checkAll(field){	
	if(field.length == undefined){		// ONLY 1 PRODUCT IN WISHLIST
		field.checked = true ;	
	}else{
		for (i = 0; i < field.length; i++)
			field[i].checked = true ;
	}
}

function uncheckAll(field){
	if(field.length == undefined){		// ONLY 1 PRODUCT IN WISHLIST
		field.checked = false ;
	}else{
		for (i = 0; i < field.length; i++)
			field[i].checked = false ;
	}
}

function deleteWishlistProducts(field){
	
	var boxesTicked = "";
	for (i = document.getElementsByName('list').length - 1; i >= 0; i--) {
		if (document.getElementsByName('list')[i].checked){
			boxesTicked = boxesTicked + document.getElementsByName('list')[i].value + "\n";
		}
	}
	
	if (boxesTicked == ""){
		alert ("Select some product to delete.");
		return false;
	}

	var answer = confirm ("Do you want to delete products from wishlist?");
	var productid_quantity,result;
	if(answer){
		var arr_productid = new Array();
		var j=0;
		
		for (i = document.getElementsByName('list').length - 1; i >= 0; i--) {
			
			if (document.getElementsByName('list')[i].checked){
				
				productid_quantity = document.getElementsByName('list')[i].value;
				result = productid_quantity.split("@#$");
				
				$.post(PREFIX+"whishlist2db.php", { 'id':result[0], 'quantity': result[1], 'action':'d'},
					function(data){			//alert(data);
						
				});
			}
		}//FOR
		alert("Wishlist products are deleted.");
		window.location.reload();
		return true;
				
	}//IF - ANSWER = YES

}

// RECENTLY VIEWED ITEMS
function navigate(flag,count){

	var sitepath = "http://staging.furtadosonline.com/images/";

	if(flag=='next'){
		for(i=1;i<=count;i++){
		//	alert(i);
			if(document.getElementById('div'+i).style.display=='block'){
			//alert('coming'+i);
					var firstblock= i;
					break;
			}
		}
		//alert(firstblock);
		if(firstblock+1 <= count){
			if(firstblock+1 == count){
				document.getElementById('next_image').src=''+sitepath+'rightarrow-dull.gif';	
			}
			document.getElementById('previous_image').src=''+sitepath+'Leftarrow-highlighted.gif';	
			document.getElementById('div'+firstblock).style.display='none';
			var nextblock=firstblock+1;
			document.getElementById('div'+nextblock).style.display='block';
		}
	}else if(flag=='prev'){
		for(i=1;i<=count;i++){
		//	alert(i);
			if(document.getElementById('div'+i).style.display=='block'){		//alert('coming'+i);
					var firstblock= i;
					break;
			}
		}
	//	alert(firstblock);
		var prevblock=firstblock-1;
		if(prevblock >= 1){
			if(prevblock == 1){
				document.getElementById('previous_image').src=''+sitepath+'Leftarrow-dull.gif';	
			}
			document.getElementById('next_image').src=''+sitepath+'rightarrow-highlighted.gif';
			document.getElementById('div'+prevblock).style.display='block';
			var nextblock=prevblock+1;
			document.getElementById('div'+nextblock).style.display='none';
		}
	}
}

// SHOPPING CART - STEP 2 : SHIPPING ADDRESS OPTION
function change_shipping_address(val){
	if(val != ""){
		window.location = PREFIX+"shippingaddress.php?addressid="+val;
		return true;
	}else{
		window.location = PREFIX+"shippingaddress.php";
		return true;
	}
}

// LOGIN CHECK VALIDATION
function login_check(){
	var frm = document.login_form;
	var emailid = trim(frm.emailid.value);
	var password = trim(frm.password.value);
	
	if(emailid== ""){
		alert("Please enter your email address.");	
		frm.emailid.value = '';
		frm.emailid.focus();
		return false;
	}else if(frm.emailid.value != ""){
			emailvalid=isValidEmail(emailid);	
			if(emailvalid!=true){
				alert("Please enter valid email address.");
				frm.emailid.value = "";
				frm.emailid.focus();	
				return false;
			}
	}
	if(password== ""){
		alert("Please enter Password.");	
		frm.password.value = '';
		frm.password.focus();
		return false;
	}
	return true;
	
}

// FUNCTION TO ADD PRODUCT INTO THE SHOPPING CART
function addtocart(productId){

	$.post(PREFIX+"addtocart.php", {'productid': productId}, function(data) {	//alert(data);
		if(data == 1){
			window.location = PREFIX+'shopping-cart.html';					
			return true;
		}
	});
	return true;
}

// VIEW PRODUCT : PRODUCT PHOTOGALLERY EFFECT
function change_image(imageid){	
	for(var i=1;i<=4;i++){
		if(i == imageid){		//alert("main_image_"+i);
			document.getElementById("main_image_"+i).style.display = "block";
		}else{
			document.getElementById("main_image_"+i).style.display = "none";
		}
	}
}

// VIEW PRODUCT : INFORM ME WHEN AVAILABLE
function checkInformMe(){
	var frm = document.formInformMe;		
	var emailid = frm.emailid.value;
	var cno = frm.cno.value;
	var pid = frm.hiddernPid.value;
	
	if(emailid== ""){
		alert("Please enter your email address.");	
		frm.emailid.value = '';
		frm.emailid.focus();
		return false;
	}else if(emailid != ""){
			emailvalid=isValidEmail(emailid);	
			if(emailvalid!=true){
				alert("Please enter valid email address.");
				frm.emailid.value = "";
				frm.emailid.focus();	
				return false;
			}
	}
	
	if(cno== ""){
		alert("Please enter your Phone number.");	
		frm.cno.value = '';
		frm.cno.focus();
		return false;
	}
	$.post(PREFIX+"informme2db.php", {'emailid':emailid, 'cno':cno, 'pid':pid},
			function(data){		//alert(data);
				if(data == 50){
					window.location = "index.php";
					return true;
				}else{
					$('#notavailablediv').html(data);
					setTimeout("hidediv('#notavailablediv')", 5000);
				}
			});	
}

function hidediv(){
	document.getElementById("notavailablediv").style.visibility = 'hidden';
}
// REGISTRATION TYPE VALIDATION
function checkRegistrationType(){	
	var frm = document.formRegistrationType;
	var rType = frm.registrationType.value;
	
	if(rType == ""){
		alert("Please select registration type.");	
		frm.registrationType.focus();
		return false;	
	}else{
		return true;		
	}
}

// REGISTRATION VALIDATION
function validateRegistration(){
	var frm = document.formRegistration;
	
	var emailid = trim(frm.emailAddress.value);
	var password = trim(frm.password.value);
	var reRnterPassword = trim(frm.reRnterPassword.value);
	var title = frm.title.value;
	var firstName = trim(frm.firstName.value);
	var lastName = trim(frm.lastName.value);
	var address1 = trim(frm.address1.value);
	var state = frm.state.value;
	
	var pincode = trim(frm.pincode.value);
	var telNumber = trim(frm.telNumber.value);
	
	var rtype = frm.rType.value;

	if(rtype == 3){
		var qualification = trim(frm.qualification.value);
	}
	
	if(emailid== ""){
		alert("Please enter your email address.");	
		frm.emailAddress.value = '';
		frm.emailAddress.focus();
		return false;
	}else if(emailid != ""){
			emailvalid=isValidEmail(emailid);	
			if(emailvalid!=true){
				alert("Please enter valid email address.");
				frm.emailAddress.value = "";
				frm.emailAddress.focus();	
				return false;
			}
	}
	if(password == ""){
		alert("Please enter Password.");	
		frm.password.value = '';
		frm.password.focus();
		return false;
	}
	if(password.length < 6){
		alert("Password should contain at least 6 characters.");	
		frm.password.value = '';
		frm.password.focus();
		return false;
	}
	if(reRnterPassword == ""){
		alert("Please Reenter Password.");	
		frm.reRnterPassword.value = '';
		frm.reRnterPassword.focus();
		return false;
	}
	if(password != "" && reRnterPassword != ""){
		if(password != reRnterPassword){
			alert("Password & Reenter Password does not match");	
			frm.reRnterPassword.value = '';
			frm.password.focus();
			return false;	
		}
	}
	if(title == ""){
		alert("Please select Title.");	
		frm.title.focus();
		return false;
	}
	if(firstName == ""){
		alert("Please enter First Name.");	
		frm.firstName.value = "";
		frm.firstName.focus();
		return false;
	}
	if(lastName == ""){
		alert("Please enter Last Name.");	
		frm.lastName.value = "";
		frm.lastName.focus();
		return false;
	}
	if(address1 == ""){
		alert("Please enter address.");	
		frm.address1.value = "";
		frm.address1.focus();
		return false;
	}
	if(state == ""){
		alert("Please select State.");	
		frm.state.focus();
		return false;
	}else{
		var city = frm.city.value;	
		var otherCity = trim(frm.otherCity.value);
		//alert(city+"=="+otherCity);
		if(city == 0){
			if(otherCity == ""){
				alert("Please Enter City.");	
				frm.otherCity.focus();
				return false;
			}
		}
		
	}
	if(pincode == ""){
		alert("Please enter Pincode.");	
		frm.pincode.value = "";
		frm.pincode.focus();
		return false;
	}else if(pincode != ""){
		if(isNaN(pincode)){		
			alert("Please enter valid Pincode.");	
			frm.pincode.value = "";
			frm.pincode.focus();
			return false;
		}
	}
	
	if(telNumber == ""){
		alert("Please enter Telephone Number.");	
		frm.telNumber.value = "";
		frm.telNumber.focus();
		return false;
	}
	
	var flag = 0;
	if(rtype == 2){
		for(i=0;i<=11;i++){
			if(document.getElementById("m"+i).checked == true){
				flag = 1;
				break;
			}
		}
		if(flag == 0){
			alert("Please select Instrument.");	
			return false;	
		}
	}
	
	if(rtype == 3){
		
		for(i=0;i<=12;i++){
			if(document.getElementById("mt"+i).checked == true){
				flag = 1;
				break;
			}
		}
		if(flag == 0){
			alert("Please select Instrument.");	
			return false;	
		}
		
		if(qualification == ""){
			alert("Please enter your Qualification.");	
			frm.qualification.value = "";
			frm.qualification.focus();
			return false;
		}
	}

	return true;	
}// validateRegistration()

// SHORT REGISTRATION VALIDATION
function validateRegistration_short(){
	var frm = document.formRegistration;
	
	var emailid = trim(frm.emailAddress.value);
	var password = trim(frm.password.value);
	var reRnterPassword = trim(frm.reRnterPassword.value);
	var title = frm.title.value;
	var firstName = trim(frm.firstName.value);
	var lastName = trim(frm.lastName.value);
	
	if(emailid== ""){
		alert("Please enter your email address.");	
		frm.emailAddress.value = '';
		frm.emailAddress.focus();
		return false;
	}else if(emailid != ""){
			emailvalid=isValidEmail(emailid);	
			if(emailvalid!=true){
				alert("Please enter valid email address.");
				frm.emailAddress.value = "";
				frm.emailAddress.focus();	
				return false;
			}
	}
	if(password == ""){
		alert("Please enter Password.");	
		frm.password.value = '';
		frm.password.focus();
		return false;
	}
	if(password.length < 6){
		alert("Password should contain at least 6 characters.");	
		frm.password.value = '';
		frm.password.focus();
		return false;
	}
	if(reRnterPassword == ""){
		alert("Please Reenter Password.");	
		frm.reRnterPassword.value = '';
		frm.reRnterPassword.focus();
		return false;
	}
	if(password != "" && reRnterPassword != ""){
		if(password != reRnterPassword){
			alert("Password & Reenter Password does not match");	
			frm.reRnterPassword.value = '';
			frm.password.focus();
			return false;	
		}
	}
	if(title == ""){
		alert("Please select Title.");	
		frm.title.focus();
		return false;
	}
	if(firstName == ""){
		alert("Please enter First Name.");	
		frm.firstName.value = "";
		frm.firstName.focus();
		return false;
	}
	if(lastName == ""){
		alert("Please enter Last Name.");	
		frm.lastName.value = "";
		frm.lastName.focus();
		return false;
	}
	return true;	
}// validateRegistration_short()

//  REGISTRATION : SHOW CITY DROP-DOWN
function showCity(stval,dbval,other){
	
	$.post(PREFIX+"showcity.php", {'stval':stval, 'dbval':dbval,'other':other},
		function(data){	
			$('#city_value').html(data);
			$('#city').focus();
	});	
}

// REGISTRATION : CITY DROPDOWN (OTHER CITY) - SHOW OTHER CITY TEXTFIELD
function displayOtherCity(value){
	if(value == 0){
		document.getElementById("othercitydiv").style.display = "block";	
	}else{
		document.getElementById("othercitydiv").style.display = "none";		
	}
}

// CHECK PINCODE
function checkPincode(formname, ctid){
	
	if(formname == 'registration')	{
		var frm = document.formRegistration;
	}else if(formname == 'addressbook')	{
		var frm = document.add_addressbook;
	}
	var pcode = trim(frm.pincode.value);
	if(pcode == ""){
		alert("Please enter Pincode.");	
		frm.pincode.value = "";
		frm.pincode.focus();
		return false;
	}else if(pcode != ""){
		if(isNaN(pcode)){		
			alert("Please enter valid Pincode.");	
			frm.pincode.value = "";
			frm.pincode.focus();
			return false;
		}
	}
	$.post(PREFIX+"checkpincode.php", {'pcode':pcode, 'type':1, 'ctid':ctid},
		function(data){		//alert(data);
			if(data == 1){
				$('#pincodeMsgId').hide("fast");
				//$('#proceed').val(1);
				document.getElementById("proceed").value = 1;
			}else if(data == 2){
				$('#pincodeMsgId').show();
				$('#pincodeMsgId').html("<b style='color:#FF0000'>Sorry, Currently we are unable to ship the product to this pincode.<br><br><a href='javascript:void(0);' class='bl_12' onclick='pincodePopup();'><b>Enter your Pincode here to verify if dispatch is available to that location</b></a></b>");
				//$('#proceed').val(0);
				document.getElementById("proceed").value = 0;
			}else if(data == 3){
				$('#pincodeMsgId').show();
				$('#pincodeMsgId').html("<b style='color:#FF0000'>Sorry, Currently we are unable to ship the product to this pincode.</b>");
				//$('#proceed').val(0);
				document.getElementById("proceed").value = 0;
			}
			else if(data == 4){
				$('#pincodeMsgId').show();
				//$('#pincodeMsgId').html("<b style='color:#FF0000'>Sorry, Pincode & City doesn't match.</b>");
				$('#pincodeMsgId').html("<b style='color:#FF0000'>Sorry, Incorrect Pincode.</b>");
				//$('#proceed').val(0);
				document.getElementById("proceed").value = 0;
			}
	});	
	return true;
}//checkPincode

// CHANGE PASSWORD VALIDATION
function validatePassword(){	

	var frm = document.formChangePassword;

	var flag = frm.hideFlag.value;
	var uid = frm.loginid.value;
	if(flag == 1){
		var oldpassword = trim(frm.oldPassword.value);
		var co = "";
	}else if(flag == 0){
		var oldpassword = "";
		var co = frm.hideCode.value;
	}

	var password = trim(frm.password.value);
	var reRnterPassword = trim(frm.reRnterPassword.value);
	
	if(flag == 1){
		if(oldpassword == ""){
			alert("Please enter Old Password.");	
			frm.oldPassword.value = '';
			frm.oldPassword.focus();
			return false;
		}
	}
	if(password == ""){
		alert("Please enter New Password.");	
		frm.password.value = '';
		frm.password.focus();
		return false;
	}
	if(password.length < 6){
		alert("Password should contain at least 6 characters.");	
		frm.password.value = '';
		frm.password.focus();
		return false;
	}
	if(reRnterPassword == ""){
		alert("Please Reenter Password.");	
		frm.reRnterPassword.value = '';
		frm.reRnterPassword.focus();
		return false;
	}
	if(password != "" && reRnterPassword != ""){
		if(password != reRnterPassword){
			alert("Password & Reenter Password does not match");	
			frm.password.value = '';
			frm.reRnterPassword.value ='';
			frm.password.focus();
			return false;	
		}
	}
	
	$.post(PREFIX+"changepassword2db.php", {old:oldpassword, newpass:password, repass:reRnterPassword, flag:flag, uid:uid, code:co},
			function(data){		//alert(data);
				if(data == 50){
					window.location = "index.php";
					return true;
				}else{
					$('#passwordMsg').html(data);
				}
			});	
	
}// validatePassword()


// POST REVIEW : CHECK USER IS LOGGED IN
function loginCheck(pid){
	$.post(PREFIX+"logincheck.php", {'flag':1, 'pid':pid},
			function(data){		
				if(data == 0){
					$('#writeReviewId').hide();
					$('#loginDiv').show();
					$('#loginDiv').html("<b class='b_12'>You need to be <a href='"+PREFIX+"login.php?redirect=postreview.php?id="+pid+"' class='bl_12'><b>login</b></a> to post review</b>");
				}else if(data == 1){
					window.location = PREFIX+"postreview.php?id="+pid;
					return true;
				}else if(data == 2){
					$('#writeReviewId').hide();
					$('#loginDiv').show();
					$('#loginDiv').html("<b class='b_12'>You have already given review on this product</b>");
				}
			});			
}

// POST REVIEW : FORM VALIDATION
function checkReview(pid){
	var frm = document.formReview;
	
	var title = trim(frm.title.value);

	var overall_rating_value = frm.overall.value;
	var features_rating_value = frm.features.value;
	var quality_rating_value = frm.quality.value;
	var value_rating_value = frm.val.value;

	var experience = trim(frm.experience.value);
	var background = trim(frm.background.value);
	var review = trim(frm.review.value);
	
	if(title == ""){
		alert("Please enter Title.");	
		frm.title.value = "";
		frm.title.focus();
		return false;
	}
	if(overall_rating_value == ""){
		alert("Please click to rate the product - Overall.");	
		return false;
	}
	if(features_rating_value == ""){
		alert("Please click to rate the product - Features.");	
		return false;
	}
	if(quality_rating_value == ""){
		alert("Please click to rate the product - Quality.");	
		return false;
	}
	if(value_rating_value == ""){
		alert("Please click to rate the product - Value.");	
		return false;
	}
	if(experience == ""){
		alert("Please select experience with product.");	
		frm.experience.focus();
		return false;
	}
	if(background == ""){
		alert("Please enter your Background.");	
		frm.background.value = "";
		frm.background.focus();
		return false;
	}
	if(review == ""){
		alert("Please enter review about product.");	
		frm.review.value = "";
		frm.review.focus();
		return false;
	}
	
	$.post(PREFIX+"postreview2db.php", { 'title':title, 'overall':overall_rating_value, 'features':features_rating_value, 'quality':quality_rating_value, 'val':value_rating_value, 'experience':experience, 'background':background, 'review':review,'pid':pid},
			function(data){			//alert(data);
				if(data == 50){
					window.location = "index.php";
					return true;
				}else{
					$('#before').hide();
					$('#review_msg').html(data);
				}
			});	
	return true;
}

// PRODUCT DETAILS  PAGE : CHECK STORE SELECTED
function checkStore(){
	var store = document.getElementById("storeselect_details").value;

	if(store == ""){
		alert("Please select store");	
	}else{	
		document.getElementById("hiddenStoreId").value = store;
		showstore(store);
	}
}

// FOR VALUE TO BE NUMERIC
function chk_num(field_obj){
	var val = field_obj.value;
	if(isNaN(val)) {
		field_obj.value = "";
	}
}

// SERVICE SUPPORT CHECK VALIDATION
function checkServiceSupport(){
	var frm = document.formServiceSupport;
	var billno = trim(frm.billno.value);
	var productinfo = trim(frm.productinfo.value);
	
	if(billno == ""){
		alert("Please enter your Order Number.");	
		frm.billno.value = '';
		frm.billno.focus();
		return false;
	}else {
		return true;
	}
}// checkServiceSupport()

function checkProblem(){
	var frm = document.formServiceSupport_products;
	var problem = trim(frm.problem.value);

	if(problem == ""){
		alert("Please enter your Problem about the product/order.");	
		frm.problem.value = '';
		frm.problem.focus();
		return false;
	}else {
		return true;
	}
}// checkProblem

// LOOKING FOR TEACHER VALIDATION
function checkTeacher(){
	var frm = document.formTeacher;
	var mi = trim(frm.mi.value);
	var level = trim(frm.level.value);
	var city = trim(frm.city.value);
	var location = trim(frm.location.value);
	
	if(mi == ""){
		alert("Please Select Instrument.");	
		frm.mi.focus();
		return false;
	}
	if(level == ""){
		alert("Please Select Level.");	
		frm.level.focus();
		return false;
	}
	if(city == ""){
		alert("Please Select City.");	
		frm.city.focus();
		return false;
	}
	if(location == ""){
		alert("Please enter Locaton.");	
		frm.location.value = '';
		frm.location.focus();
		return false;
	}
	return true;
}// checkServiceSupport()

// CHANGE ACCOUNT TYPE : VALIDATION
function checkAccountType(){	
	
	var frm = document.formAccountType;
	var rtype = frm.rType.value;

	if(rtype == 2){
		var instruments_played = trim(frm.instruments_played.value);
		var favorite_instrument = trim(frm.favorite_instrument.value);
		
		if(instruments_played == ""){
			alert("Please enter Instruments played by you.");	
			frm.instruments_played.value = "";
			frm.instruments_played.focus();
			return false;
		}
		if(favorite_instrument == ""){
			alert("Please enter your favorite instrument.");	
			frm.favorite_instrument.value = "";
			frm.favorite_instrument.focus();
			return false;
		}
	}

	if(rtype == 3){
		var experience = trim(frm.experience.value);
		var qualification = trim(frm.qualification.value);
		
		if(experience == ""){
			alert("Please enter your Experience.");	
			frm.experience.value = "";
			frm.experience.focus();
			return false;
		}
		if(qualification == ""){
			alert("Please enter your Qualification.");	
			frm.qualification.value = "";
			frm.qualification.focus();
			return false;
		}
	}
	
	return true;	
}// checkAccountType()

// FUNCTION TO CHAGE SHIPPING METHOD : WITH TYPE
function changeShippingMethod(shiptype){	//alert(shiptype);
	
	$.post(PREFIX+"setshippingmethod.php", {'shiptype':shiptype},
		function(data){ 	//alert(data);
			if(data == 50){
				window.location = "index.php";
				return true;
			}else{
				window.location = PREFIX+"ordersummary.php";
				return true;				
			}
		});	

	return true;	
}

function storecookie(storeid){
	$.post(PREFIX+"setstorecookie.php", {'storeid':storeid},
			function(data){ 	//alert(data);
				$("#showStoreInfo").show();
				$("#showStoreInfo").html(data);
			});	

	return true;	
}

// PRODUCT DETAILS : FEEDBACK FORM
function checkProductFeedback(){
	var frm = document.form_feedback;		
	var ii = "";
	var pi = "";
	var incd = "";
	var pd = "";
	var wc = "";
	var pname = frm.hidden_feedback_pname.value;;
	var pid = frm.hidden_feedback_pid.value;;

	var flag = 0;
	if(document.getElementById("incorrect_image").checked == true){
		ii = frm.incorrect_image.value;
		flag = 1;
	}
	if(document.getElementById("poor_image").checked == true){
		pi = frm.poor_image.value;
		flag = 1;
	}
	if(document.getElementById("incorrect_description").checked == true){
		incd = frm.incorrect_description.value;
		flag = 1;
	}
	if(document.getElementById("poor_description").checked == true){
		pd = frm.poor_description.value;
		flag = 1;
	}
	if(document.getElementById("wrong_categorization").checked == true){
		wc = frm.wrong_categorization.value;
		flag = 1;
	}
	var feed_text = frm.feedback_text.value;
	if(feed_text != '' && feed_text != 'Comment'){
		flag = 1;	
	}
	
	if(flag == 0){
		alert("Please select at least one field.");	
		return false;	
	}else{
		$.post(PREFIX+"productfeedback2db.php", {'ii':ii,'pi':pi,'incd':incd,'pd':pd,'wc':wc,'feed_text':feed_text,'pname':pname,'pid':pid},
				function(data){		//alert(data);
					if(data == 50){
						window.location = "index.php";
						return true;
					}else{
						$('#feedbackId').html(data);
						setTimeout("hidefeedbackdiv('#feedbackId')", 5000);
					}
				
				});	
	}
}//checkProductFeedback()

function hidefeedbackdiv(){
	document.getElementById("feedbackId").style.display = 'none';
}

function changeMainCategory(value, file){
	$.post(PREFIX+"setmaincategory.php", {'maincatid':value},
			function(data){ 	//alert(data);
				//alert(PREFIX+file+"?type="+value);
				window.location = PREFIX+file;
				return true;			
			});	

	return true;			
}

// FUCNTION TO CALCULATE SHIPPING COST BASED ON PINCODE : SHOPPING CART & ORDER SUMMARY PAGE
function caculateShippingCost(pincode, page, type){		
	if(page == "shoppingcart.php"){	
		var input_pinccode = trim(document.getElementById("input_pinccode").value);
		if(input_pinccode == ""){
			document.getElementById("input_pinccode").focus();
			return false;
		}

		$("#div_show_shipping_cost").fadeOut("slow");
		$.post(PREFIX+"findShippingCost.php", {'pincode':pincode, 'type':type},
				function(data){ 				//alert(data);
					$("#div_show_shipping_cost").show("slow");
					$("#div_show_shipping_cost").fadeIn("slow");
					
					if(data == 0){				
						$("#div_show_shipping_cost").html("<b class='r_12'>We regret we are unable to ship to this pincode</b>");
					}else{						
						
						var res = data.split("||");
						if(res[0] == "DP"){
							
							if(res[2] == undefined){
								var v_str = "";	
							}else{
								var v_str = "<br><b>VPP &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: </b>Rs."+res[3];	
							}
							$("#div_show_shipping_cost").html("<b>Express Shipping : </b>Rs."+res[1]+v_str);	
						}else if(res[0] == "VPP"){
							$("#div_show_shipping_cost").html("<b>VPP : </b>Rs."+res[1]);	
						}else if(res[0] == "Express"){
							$("#div_show_shipping_cost").html("<b>Express Shipping : </b>Rs."+res[1]);	
						}else{
							$("#div_show_shipping_cost").html("<b>Normal Shipping &nbsp; : </b>Rs."+res[1]+"<br><b>Express Shipping : </b>Rs."+res[2]);	
						}
						
					}//ELSE
				});	
		
	}else if(page == "ordersummary.php"){	
		$.post(PREFIX+"findShippingCost.php", {'pincode':pincode, 'type':type},
				function(data){ 											//alert(data);
					$("#total_sc").show("slow");
					if(data == 0){	
						$("#total_sc").html("<b class='r_12'>We regret we are unable to ship to this pincode</b>");
					}else{		
						var res = data.split("||");
						
						$("#total_sc").fadeIn("slow");
						
						if(res[0] == "Normal"){
							$("#normal_sc").html(res[1]);	
						}else if(res[0] == "Express"){
							$("#express_sc").html(res[1]);	
						}else if(res[0] == "VPP"){	
							if(res[1] == '0'){
								$("#free_shipping_text").html('');		
								$("#vpp_sc_free").html('<b>Free Shipping</b>');	
							}else{
								$("#vpp_sc").html(res[1]);		
							}
							
						}else{
							$("#dp_sc").html("Rs.: "+res[1]);	
						}
						
						$("#total_sc").html(res[1]);	
						
					}//ELSE
				});	
	}
	return true;
}

// FUNCTION TO VALIDATE SPECIAL SHIPPING MODE FORM (VIEWPRODUCT.PHP)
function checkSCForm(){
	var frm = document.form_special_product;
	
	var isLogged = trim(frm.isLogged.value);
	var sc_pid = trim(frm.sc_pid.value);
	var sc_pname = trim(frm.sc_pname.value);
	
	if(isLogged == 1){
		var sc_del_address_list = trim(frm.sc_del_address_list.value);	
		var sc_new_address = trim(frm.sc_new_address.value);
	}else if(isLogged == 0){
		var sc_name = trim(frm.sc_name.value);
		var sc_del_address = trim(frm.sc_del_address.value);
		var sc_contact_no = trim(frm.sc_contact_no.value);
		var sc_email = trim(frm.sc_email.value);
	}
	
	var sc_pincode = trim(frm.sc_pincode.value);

	if(isLogged == 0){
		if(sc_name == ""){
			alert("Please enter your Name.");	
			frm.sc_name.value = "";
			frm.sc_name.focus();
			return false;
		}
		if(sc_del_address == ""){
			alert("Please enter your Delivery Address.");	
			frm.sc_del_address.value = "";
			frm.sc_del_address.focus();
			return false;
		}
	}
	if(isLogged == 1){
		if(sc_del_address == "" || sc_del_address_list == ""){
			alert("Please select/enter your Delivery Address.");	
			frm.sc_del_address_list.focus();
			return false;
		}
	}
	if(sc_pincode == ""){
		alert("Please enter your Pincode Number.");	
		frm.sc_pincode.value = "";
		frm.sc_pincode.focus();
		return false;
	}
	if(isLogged == 0){
		if(sc_contact_no == ""){
			alert("Please enter your Contact Number.");	
			frm.sc_contact_no.value = "";
			frm.sc_contact_no.focus();
			return false;
		}
		if(sc_email == ""){
			alert("Please enter your Email Address.");	
			frm.sc_email.value = "";
			frm.sc_email.focus();
			return false;
		}
		if(sc_email != ""){
			var emailvalid=isValidEmail(sc_email);	
			if(emailvalid!=true){
				alert("Please enter valid Email address.");
				frm.sc_email.value = "";	
				frm.sc_email.focus();	
				return false;
			}
		}
	}
	
	if(isLogged == 1){
		$.post(PREFIX+"spcial_shipping2db.php", { 'sc_del_address_list':sc_del_address_list, 'sc_new_address':sc_new_address, 'sc_pincode':sc_pincode, 'isLogged':isLogged, 'sc_pid':sc_pid, 'sc_pname':sc_pname },
			   function(data){			
			if(data == 50){
				window.location = "index.php";
				return true;
			}else{
				alert(data);
				$('#id_special_product').hide();
				$('#id_normal_data').show();
			}
		});	
	}else{
		$.post(PREFIX+"spcial_shipping2db.php", { 'sc_name':sc_name, 'sc_del_address':sc_del_address, 'sc_pincode':sc_pincode, 'sc_contact_no':sc_contact_no, 'sc_email':sc_email,'isLogged':isLogged, 'sc_pid':sc_pid, 'sc_pname':sc_pname },	
			   function(data){			//alert(data);
			if(data == 50){
				window.location = "index.php";
				return true;
			}else{
				alert(data);
				$('#id_special_product').hide();
				$('#id_normal_data').show();
			}
		});	
	}
		
	return true;
}

// BAND CREATE VALIDATION
function validateEvent(){
	var frm = document.formEvent;
	
	var event_headline = trim(frm.event_headline.value);
	var event_date = trim(frm.event_date.value);
	var event_time = trim(frm.event_time.value);
	var event_venue = frm.event_venue.value;
	var event_city = frm.event_city.value;
	var bandname = trim(frm.bandname.value);
	var upfile = document.getElementById('event_image').value;
	
	if(event_headline== ""){
		alert("Please enter Event Headline.");	
		frm.event_headline.value = '';
		frm.event_headline.focus();
		return false;
	}
	if(event_date == ""){
		alert("Please select Event Date.");	
		frm.event_date.value = '';
		frm.event_date.focus();
		return false;
	}
	if(event_time == ""){
		alert("Please enter Event Time.");	
		frm.event_time.value = '';
		frm.event_time.focus();
		return false;
	}
	if(event_venue == ""){
		alert("Please enter Event Venue.");	
		frm.event_venue.value = '';
		frm.event_venue.focus();
		return false;
	}
	if(event_city == ""){
		alert("Please enter Event City.");	
		frm.event_city.value = '';
		frm.event_city.focus();
		return false;
	}
	if(upfile != ''){
		/*var res = validateFileUpload('event_image');
		if(res == false){
		return false;	
		}*/
	}
	if(bandname == ""){
		alert("Please enter Artist.");	
		frm.bandname.value = "";
		frm.bandname.focus();
		return false;
	}
	
	
	return true;	
}// validateEvent()

// BAND CREATE VALIDATION
function validateNews(){
	var frm = document.formNews;
	
	var news_headline = trim(frm.news_headline.value);
	
	if(news_headline== ""){
		alert("Please enter News Headline.");	
		frm.news_headline.value = '';
		frm.news_headline.focus();
		return false;
	}
	
	return true;	
}// validateNews()

function validateFileUpload(id){
	var uploadcontrol = document.getElementById(id).value; 
	//Regular Expression for fileupload control.
	var reg = /^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.jpg|.JPG|.jpeg|.JPEG|.gif|.GIF)$/;

	if(uploadcontrol.length > 0){
		if (reg.test(uploadcontrol)){
			return true;
		}else{	
			alert("Only .jpg, .gif files are allowed!");
			return false;
		}
	}
}// validateFileUpload()

// Virgil Donati contest
function validateContest(){
	var frm = document.formContest;
	
	var full_name = trim(frm.full_name.value);
	var email = trim(frm.email.value);
	var contact = trim(frm.contact.value);

	if(full_name== ""){
		alert("Please enter your Name.");	
		frm.full_name.value = '';
		frm.full_name.focus();
		return false;
	}
	if(email == ""){
			alert("Please enter your Email Address.");	
			frm.email.value = "";
			frm.email.focus();
			return false;
		}
	if(email != ""){
		var emailvalid=isValidEmail(email);	
		if(emailvalid!=true){
			alert("Please enter valid Email address.");
			frm.email.value = "";	
			frm.email.focus();	
			return false;
		}
	}
	if(contact == ""){
		alert("Please enter your Mobile Number");	
		frm.contact.value = '';
		frm.contact.focus();
		return false;
	}
	
	return true;	
}// validateContest()

// ADD TESTIMONIAL
function add_testimonial(){
	var frm = document.testimonial_form;
	
	var name = trim(frm.name.value);
	var email = trim(frm.email.value);
	var comment = trim(frm.comment.value);

	if(name == ""){
		alert("Please enter your Name.");	
		frm.name.value = "";
		frm.name.focus();
		return false;
	}
	if(email == ""){
		alert("Please enter your email Address.");	
		frm.email.value = "";
		frm.email.focus();
		return false;
	}
	if(email != ""){
		var emailvalid=isValidEmail(email);	
		if(emailvalid!=true){
			alert("Please enter valid email address.");
			frm.email.value = "";	
			frm.email.focus();	
			return false;
		}
	}
	if(comment == ""){
		alert("Please enter your Comment.");	
		frm.comment.value = "";
		frm.comment.focus();
		return false;
	}
	$.post(PREFIX+"testimonial2db.php", { name:name, email:email, comment:comment },
			function(data){			//alert(data);
				if(data == 50){
					window.location = "index.php";
					return true;
				}else{
					$('#testimonial_msg').html(data);
				}
			});	
	return true;
}

