function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function popitupdescDl(url)	// feedback popup
{
	newwindow=window.open(url,'name','height=310,width=400,titebar=no,location=1,status=no,scrollbars=yes,top=150,left=400');
	if (window.focus){
		newwindow.focus()
	}
	return false;
}

function popitupdesc(url)
{
	newwindow=window.open(url,'name','height=510,width=500,titebar=no,location=1,status=no,scrollbars=yes');
	if (window.focus){
		newwindow.focus()
	}
	return false;
}

function checkContact() {
	name = document.getElementById("name").value;
	email = document.getElementById("email").value;
	mobile = document.getElementById("mobile").value;
	address = document.getElementById("address").value;
	captcha = document.getElementById("captcha").value;
	validRegExp = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
  
  	if (name == "") {
  		hideAllErrors();
		document.getElementById("nameError").style.display = "block";
		document.getElementById("name").select();
		document.getElementById("name").focus();
	  	return false;
  	} 
	if (email == "" || document.getElementById("email").value.search(validRegExp) == -1) {
		hideAllErrors();
		document.getElementById("emailError").style.display = "block";
		document.getElementById("email").select();
		document.getElementById("email").focus();
		return false;
  	} 
	if (mobile == "" || document.getElementById("mobile").value.search(/\d{10}/)==-1) {
		hideAllErrors();
		document.getElementById("mobileError").style.display = "block";
		document.getElementById("mobile").select();
		document.getElementById("mobile").focus();
		return false;
  	} 
	if (address == "") {
		hideAllErrors();
		document.getElementById("addressError").style.display = "block";
		document.getElementById("address").select();
		document.getElementById("address").focus();
		return false;
	}
	if (trim(captcha) != document.getElementById('captchaVerify').value) {
		hideAllErrors();
		document.getElementById("captchaError").style.display = "block";
		document.getElementById("captcha").select();
		document.getElementById("captcha").focus();
		return false;
	}
  	return true;
}
 
function hideAllErrors() {
	document.getElementById("nameError").style.display = "none"
	document.getElementById("emailError").style.display = "none"
	document.getElementById("mobileError").style.display = "none"
	document.getElementById("addressError").style.display = "none"
	document.getElementById("captchaError").style.display = "none"
}



function popitupdescPrint(url)	// feedback popup
{
	newwindow=window.open(url,'name','height=450,width=820,titebar=no,location=1,status=no,scrollbars=yes,top=150,left=400');
	if (window.focus){
		newwindow.focus()
	}
	return false;
}


function confirmDelete()
{
    return confirm("Are you sure you wish to Delete this entry?");
}


function sendEnquiry_checkval(){
	if(document.sendEnquiry.tx_name.value == ""){
		alert("Enter your Name");
		document.sendEnquiry.tx_name.focus();
		return false;
	}

	apos=document.sendEnquiry.tx_email.value.indexOf("@")
	dotpos=document.sendEnquiry.tx_email.value.lastIndexOf(".")
	if (document.sendEnquiry.tx_email.value == "" || apos<1 || dotpos-apos<2)
	{
	alert("Enter Valid Email Address")
	document.sendEnquiry.tx_email.focus()
	return false
	}
/*	
	if(document.sendEnquiry.tx_contact_no.value.search(/^([+][\d]{12})/) == -1 || document.sendEnquiry.tx_contact_no.value==""){
		alert("Enter your Contact No. eg(+917121234567)");
		document.sendEnquiry.tx_contact_no.focus();
		return false;
	}
*/
	if(document.sendEnquiry.ta_message.value == ""){
		alert("Enter your Message!");
		document.sendEnquiry.ta_message.focus();
		return false;
	}
	
	if (document.getElementById('captcha').value != document.getElementById('captchaVerify').value) {
		alert("Please enter correct captcha code!");
		document.getElementById("captcha").focus();
		return false;
	}
	
	return true;
}


/*
// IMAGE TYPE VALIDATION START HERE
	function load_image()
	{
		var imgpath = document.getElementById('fupImage').value;
		if(imgpath != "")
		{
			// code to get File Extension..
			var arr1 = new Array;
			arr1 = imgpath.split("\\");
			var len = arr1.length;
			var img1 = arr1[len-1];
			var filext = img1.substring(img1.lastIndexOf(".")+1);
			// Checking Extension
			if(filext == "jpg" || filext == "jpeg" || filext == "gif" || filext == "png")
			document.getElementById('imgUser').src = imgpath;
			else
			{
				alert("File Format Selected Is Invalid");
				document.getElementById('fupImage').value = "";
				return false;
			}
		}
	}
// IMAGE SIZE AND TYPE VALIDATION END HERE


function shipping_checkval() {
	if(document.shipping_address.tx_name.value.search(/^[a-zA-Z]+$/) || document.shipping_address.tx_name.value==""){
		alert("Please enter your name!");
		document.shipping_address.tx_name.focus();
		return false;
	}
	if(document.shipping_address.tx_contact_no.value.search(/^([+][\d]{12})/) == -1 || document.shipping_address.tx_contact_no.value==""){
		alert("Please Enter Valid Contact No. eg(+917121234567)");
		document.shipping_address.tx_contact_no.focus();
		return false;
	}
	if(document.shipping_address.ta_address.value==""){
		alert("Please Enter Shipping Address.");
		document.shipping_address.ta_address.focus();
		return false;
	}
	if(document.shipping_address.tx_pincode.value.search(/^\d{6}$/)== -1 || document.shipping_address.tx_pincode.value==""){
		alert("Please Enter Valid Pin Code.");
		document.shipping_address.tx_pincode.focus();
		return false;
	}
	if(document.shipping_address.dd_country.value==""){
		alert("Please select country.");
		document.shipping_address.dd_country.focus();
		return false;
	}
	if(document.shipping_address.dd_state.value==""){
		alert("Please select State.");
		document.shipping_address.dd_state.focus();
		return false;
	}
	if(document.shipping_address.dd_city.value==""){
		alert("Please select City.");
		document.shipping_address.dd_city.focus();
		return false;
	}
	return true
}



function recover_checkval() {
		apos=document.recover_password.tx_email.value.indexOf("@")
		dotpos=document.recover_password.tx_email.value.lastIndexOf(".")
		if (document.recover_password.tx_email.value == "" || apos<1 || dotpos-apos<2)
		{
		alert("Enter Valid Email Address")
		document.recover_password.tx_email.focus()
		return false
	}
	return true
}


function login_cart_checkval(){
	if(document.login_cart.tx_password.value !== document.login_cart.tx_password1.value){
		alert("Password Incorrect !");
		document.login_cart.tx_password.focus();
		return false;
	}
	return true;
}


function check_search()
{
	if(document.getElementById("search_keyword").value=="" || document.getElementById("search_keyword").value=="Search in stylewale.com" || document.getElementById("search_keyword").value.search(/^.{4,100}$/) == -1){
		alert("Enter more than 3 characters");
		document.getElementById("search_keyword").focus();
		return false;
	}
	return true;
}


function login_checkval1(){
	apos=document.getElementById("tx_login_email_1").value.indexOf("@")
	dotpos=document.getElementById("tx_login_email_1").value.lastIndexOf(".")
	if (document.getElementById("tx_login_email_1").value == "" || apos<1 || dotpos-apos<2)
	{
	alert("Enter Valid Email Address")
	document.getElementById("tx_login_email_1").focus()
	return false
	}
	if(document.getElementById("tx_login_pwd_1").value==""){
		alert("Please enter password!");
		document.getElementById("tx_login_pwd_1").focus();
		return false;
	}
	return true;
}


function login_checkval2(){
	apos=document.getElementById("tx_login_email_2").value.indexOf("@")
	dotpos=document.getElementById("tx_login_email_2").value.lastIndexOf(".")
	if (document.getElementById("tx_login_email_2").value == "" || apos<1 || dotpos-apos<2)
	{
	alert("Enter Valid Email Address")
	document.getElementById("tx_login_email_2").focus()
	return false
	}
	if(document.getElementById("tx_login_pwd_2").value==""){
		alert("Please enter password!");
		document.getElementById("tx_login_pwd_2").focus();
		return false;
	}
	return true;
}


function check_adCart(){
	if(document.addToCart.tx_qty.value < 1){
		alert("Please enter product quantity!");
		document.addToCart.tx_qty.focus();
		return false;
	}
	return true;
}


function user_checkval(){

validRegExp = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;

	if(document.user.tx_first_name.value==""){
		alert("Please enter first name!");
		document.user.tx_first_name.focus();
		return false;
	}
	if(document.user.tx_last_name.value==""){
		alert("Please enter last name!");
		document.user.tx_last_name.focus();
		return false;
	}
	apos=document.user.tx_username.value.indexOf("@")
	dotpos=document.user.tx_username.value.lastIndexOf(".")
	if (document.user.tx_username.value == "" || apos<1 || dotpos-apos<2)
	{
	alert("Enter Valid Email Address")
	document.user.tx_username.focus()
	return false
	}
	if(document.user.tx_password.value==""){
		alert("Please enter password!");
		document.user.tx_password.focus();
		return false;
	}
	if(document.user.tx_password1.value==""){
		alert("Please retype password!");
		document.user.tx_password1.focus();
		return false;
	}
	if(document.user.accept_terms.checked == false ){
		alert("Please Read and Select Terms and Conditions checkbox!");
		return false;
	}
	if(document.user.tx_password.value !== document.user.tx_password1.value){
		alert("Both Password does not match");
		document.user.tx_password.focus();
		return false;
	}
	return true;
}



function update_checkval(){

validRegExp = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	
	if(document.update_user.tx_first_name.value==""){
		alert("Please enter first name!");
		document.update_user.tx_first_name.focus();
		return false;
	}
	if(document.update_user.tx_last_name.value==""){
		alert("Please enter last name!");
		document.update_user.tx_last_name.focus();
		return false;
	}
	if(document.update_user.tx_dob.value==""){
		alert("Please enter the date of birth!");
		document.update_user.tx_dob.focus();
		return false;
	}
	if(document.update_user.dd_occupation.value==""){
		alert("Please select occupation!");
		document.update_user.dd_occupation.focus();
		return false;
	}
	if(document.update_user.tx_mobile.value==""){
		alert("Please enter the mobile no.!");
		document.update_user.tx_mobile.focus();
		return false;
	}

	apos=document.update_user.tx_email.value.indexOf("@")
	dotpos=document.update_user.tx_email.value.lastIndexOf(".")
	if (document.update_user.tx_email.value == "" || apos<1 || dotpos-apos<2)
	{
	alert("Enter Valid Email Address")
	document.update_user.tx_email.focus()
	return false
	}

	if(document.update_user.ta_address.value==""){
		alert("Please enter the address!");
		document.update_user.ta_address.focus();
		return false;
	}
	if(document.update_user.dd_country.value==""){
		alert("Please select the country!");
		document.update_user.dd_country.focus();
		return false;
	}
	if(document.update_user.dd_state.value=="" ){
		alert("Please select the state!");
		document.update_user.dd_state.focus();
		return false;
	}
	if(document.update_user.dd_city.value==""){
		alert("Please enter city name!");
		document.update_user.tx_city.focus();
		return false;
	}
	if(document.update_user.tx_password.value==""){
		alert("Please enter password!");
		document.update_user.tx_password.focus();
		return false;
	}
	if(document.update_user.tx_password1.value==""){
		alert("Please retype password!");
		document.update_user.tx_password1.focus();
		return false;
	}
	if(document.update_user.tx_password.value !== document.update_user.tx_password1.value){
		alert("Both Password does not match");
		document.update_user.tx_password1.focus();
		return false;
	}
	return true;
}


function designer_checkval(){

	if(document.designer.tx_display_name.value==""){
		alert("Please enter Brand Name!");
		document.designer.tx_display_name.focus();
		return false;
	}
	if(document.designer.tx_first_name.value==""){
		alert("Please enter contact person's name!");
		document.designer.tx_first_name.focus();
		return false;
	}
	if(document.designer.ta_address.value==""){
		alert("Please enter the address!");
		document.designer.ta_address.focus();
		return false;
	}
	if(document.designer.dd_country.value==""){
		alert("Please select the country!");
		document.designer.dd_country.focus();
		return false;
	}
	if(document.designer.dd_state.value=="" || document.designer.dd_state.value==0){
		alert("Please select the state!");
		document.designer.dd_state.focus();
		return false;
	}
	if(document.designer.dd_city.value==""){
		alert("Please enter city name!");
		document.designer.dd_city.focus();
		return false;
	}
	if(document.designer.tx_mobile.value==""){
		alert("Please enter the mobile no.!");
		document.designer.tx_mobile.focus();
		return false;
	}
	apos=document.designer.tx_username.value.indexOf("@")
	dotpos=document.designer.tx_username.value.lastIndexOf(".")
	if (document.designer.tx_username.value == "" || apos<1 || dotpos-apos<2)
	{
	alert("Enter Valid Email Address")
	document.designer.tx_username.focus()
	return false
	}
	if(document.designer.tx_password.value==""){
		alert("Please enter password!");
		document.designer.tx_password.focus();
		return false;
	}
	if(document.designer.tx_password1.value==""){
		alert("Please retype password!");
		document.designer.tx_password1.focus();
		return false;
	}
	if(document.designer.accept_terms.checked == false ){
		alert("Please Read and Select Terms and Conditions checkbox!");
		return false;
	}
	if(document.designer.tx_password.value !== document.designer.tx_password1.value){
		alert("Both Password does not match");
		document.designer.tx_password1.focus();
		return false;
	}
	return true;
}


function designer_update_checkval(){

	if(document.designer.tx_display_name.value==""){
		alert("Please enter Brand Name!");
		document.designer.tx_display_name.focus();
		return false;
	}
	if(document.designer.tx_first_name.value==""){
		alert("Please enter contact person's name!");
		document.designer.tx_first_name.focus();
		return false;
	}
	if(document.designer.ta_address.value==""){
		alert("Please enter the address!");
		document.designer.ta_address.focus();
		return false;
	}
	if(document.designer.dd_country.value==""){
		alert("Please select the country!");
		document.designer.dd_country.focus();
		return false;
	}
	if(document.designer.dd_state.value=="" || document.designer.dd_state.value==0){
		alert("Please select the state!");
		document.designer.dd_state.focus();
		return false;
	}
	if(document.designer.dd_city.value==""){
		alert("Please enter city name!");
		document.designer.dd_city.focus();
		return false;
	}
	if(document.designer.tx_mobile.value==""){
		alert("Please enter the mobile no.!");
		document.designer.tx_mobile.focus();
		return false;
	}
	if(document.designer.tx_password.value==""){
		alert("Please enter password!");
		document.designer.tx_password.focus();
		return false;
	}
	if(document.designer.tx_password1.value==""){
		alert("Please Confirm password!");
		document.designer.tx_password1.focus();
		return false;
	}
	if(document.designer.tx_password.value !== document.designer.tx_password1.value){
		alert("Both Password does not match");
		document.designer.tx_password1.focus();
		return false;
	}
	return true;
}
*/
