//vans related common functions  start here

function validate_form(type){
	
	// declare error array
	var errors = new Array();
	var element_arr = new Array();
	
	$(".required").each(function(){
		if($("#"+this.id).val()==''){
			errors.push(this.title+' is Required');
			element_arr.push(this.id);
		}
	});
	
	// Zip Code validation
	var zipFilter = /^\d{5}([\-]\d{4})?$/;
	$(".zip").each(function(){
		if($("#"+this.id).val()!='' && !(zipFilter.test($("#"+this.id).val()))){
			errors.push('Please Enter valid '+this.title);
			element_arr.push(this.id);
		}
	});

	// Email Validation 
	var emailFilter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	$(".email").each(function(){
		if($("#"+this.id).val()!='' && !(emailFilter.test($("#"+this.id).val()))){
			errors.push('Please Enter valid '+this.title);
			element_arr.push(this.id);
		}
	});
	
	// phone validation 	
	var phoneFilter = /\d{3}\-\d{3}\-\d{4}/;
	$(".phone").each(function(){
		if($("#"+this.id).val()!='' && !(phoneFilter.test($("#"+this.id).val()))){
			errors.push('Please Enter valid '+this.title+ " Format : xxx-xxx-xxxx");
			element_arr.push(this.id);
		}
	});		

	//Cell phone validation 	
	var cellphoneFilter = /\d{10}/;
	$(".cellphone").each(function(){
		if($("#"+this.id).val()!='' && !(cellphoneFilter.test($("#"+this.id).val()))){
			errors.push('Please Enter valid '+this.title+ " , 10 Digits allowed");
			element_arr.push(this.id);
		}
	});	
			
	// Numeric validation
	var numericFilter = /^[-]?\d*\.?\d*$/;
	$(".numeric").each(function(){
		if($("#"+this.id).val()!='' && !(numericFilter.test($("#"+this.id).val()))){
			errors.push('Please Enter valid '+this.title);
			element_arr.push(this.id);
		}
	});		
	
	$(".file_upload").each(function(){
		 var imagePath = $("#"+this.id).val();
		 var pathLength = imagePath.length;
		 var lastDot = imagePath.lastIndexOf(".");
		 var fileType = imagePath.substring(lastDot,pathLength);
		 
		 if((fileType == ".gif") || (fileType == ".jpg") || (fileType == ".png") || (fileType == ".GIF") || (fileType == ".JPG") || (fileType == ".PNG")) {
		  	return true;
		 } else {
		  alert("Supported image type .JPG, .PNG, and .GIF image formats. Your file-type is " + fileType);
		  return false;
		 }		
	});


	
	if(type=='print'){	
		if(errors.length>0){
			$("#errorDiv").html(errors.join('<br/>'));
			$("#"+element_arr[0]).focus();
			$("#"+element_arr[0]).val('');
			return false;
		}
	}else if(type=='alert'){
		if(errors.length>0){
			alert(errors[0]);
			$("#"+element_arr[0]).focus();
			$("#"+element_arr[0]).val('');		
			return false;
		}	
	}	
}

function CheckAlpha(id_val){
        var filter=/^[a-zA-Z]+$/;
        var test_bool = filter.test(id_val); 
        if (test_bool==false){
            return false;            
        }
   }


//vans related common functions  end here

function CreateBookmarkLink(SITEURL) {

		title = "MobilityExpressvans.com";   url = SITEURL; 
		
		if (window.sidebar) { // Mozilla Firefox Bookmark 

			window.sidebar.addPanel(title,url,""); 
			return false;
			
		}else if( window.external ) { // IE Favorite
			
			window.external.AddFavorite(url,title); 
			
		}
		else if(window.opera && window.print) { // Opera Hotlist 
			
			return true; 
		
		}
		
		
}


function ValidateQuickForm(currentform){    
	with(currentform){
	if((Trim(name.value) == "Please enter your name") || (Trim(name.value) == "Name") || (Trim(name.value) == '')){		  
	    
			name.style.color = "#FF0000";
			name.value = "Please enter your name";//	display message in the name textbox.
			return false;
		}
		 if(!isNaN(name.value)){
		 	alert("Enter Valid Name");
		 	return false;
		 }
		if((Trim(phone.value) == "Please enter phone number") || (Trim(phone.value) == "Phone") || (Trim(phone.value) == ''))
		{
			phone.style.color = "#FF0000";
			phone.value = "Please enter phone number";
			return false;
		} 
		if(isNaN(phone.value)){
			alert("Enter Valid Phone Number");
			return false;
		}
		if((Trim(email.value) == "Please enter valid email id") || (Trim(email.value) == "E-mail") || (Trim(email.value) == ''))
		{
			email.style.color = "#FF0000";
			email.value = "Please enter valid email id";
			return false;
		}
		else{
			var emails=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

			 var membermailid = Trim(email.value);		
		 	result1=membermailid.search(emails);
			 if(result1==-1)
			 {
				email.style.color = "#FF0000";
				email.value = "Please enter valid email id";
				return false;
			 }
		}		
	}
	return true;

}



function FavoriteCalling(){
	
	if (window.sidebar) { // Mozilla Firefox Bookmark
	window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
	window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
	return true; }

}
function checkvalidemail(formname,fieldname,message)
{ 
	 var emails=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	var membermailid = eval("document."+formname+"."+fieldname+".value");
			
	result1=membermailid.search(emails);
	if(result1==-1)
	{
		alert(message);
		eval("document."+formname+"."+fieldname+".focus()");
		eval("document."+formname+"."+fieldname+".value"+"=''");
		return false;
	}
	return true;
}

function Mycheckvalidemail(id,message)
{ 
	 var emails=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	var membermailid = document.getElementById(id).value;
			
	result1=membermailid.search(emails);
	if(result1==-1)
	{
		alert(message);
		document.getElementById(id).focus();
		document.getElementById(id).value='';
		return false;
	}
	return true;
}

function CheckingNull(formname,fieldname,message)

{
	var fieldval = eval("document."+formname+"."+fieldname+".value");
	
	fieldval= fieldval.replace(/^\s+|\s+$/g, "");
	
	if( fieldval == '')
	 {
	  	alert(message);
	  	
	  	eval("document."+formname+"."+fieldname+".value"+"=''");
	  	eval("document."+formname+"."+fieldname+".focus()");
	 	return false;
	 }
	 return true;
}

function MyCheckingNull(id,message)
{
	var fieldval = document.getElementById(id).value;
	fieldval= fieldval.replace(/^\s+|\s+$/g, "");
	
	if( fieldval == '')
	 {
	  	alert(message);
	  	document.getElementById(id).value='';
	  	document.getElementById(id).focus();
	 	return false;
	 }
	 return true;
}
function Trim(Value)
{
		return Value.replace(/^\s+|\s+$/g, "");
}
function chksearchpara() {

	if(document.searchbyproductname.productname.value == '') {
		alert("Please Enter The Name of Product");
		document.searchbyproductname.productname.focus;
		return false;
	}
	else {
		document.searchbyproductname.productname.value = Trim(document.searchbyproductname.productname.value);
		
	}
}
function Check_search() 
{
	var productname;
	//var ueresultnull;
	
	productname = CheckingNull("searchbyproductname","productname","Enter Valid Product Name");
	if(productname == false)
	{
		return false;
	}
//	else
//	{
//		ueresult = checkvalidemail("frmdiscountpage","txt_newsletter","Enter Valid Email Address");
//		if(ueresult == false)
//		{
//			return false;
//		}	
//	}
}
function openpopup(url,popup_name,height,width,other_properties)
{	
	var left		= parseInt((screen.width-350)/2);
	var top			= parseInt((screen.height-300)/2)	
	var win_options = 'height='+height+',width='+width+',resizable=no,' 
	+ 'scrollbars=no,left=' + left + ',top=' + top;
	window.open(url,popup_name,win_options); 
}

function Check_email_the_lowest_price() 
{
	var uname;
	
	uname = CheckingNull("frm_email_the_lowest_price","uname","Enter Your Name.");
	if(uname == false)
	{
		return false;
	}
	
	var ueresult;
	var ueresultnull;
	var feresultnull;
	var feresult;
	
	ueresultnull = CheckingNull("frm_email_the_lowest_price","uemail","Enter Valid Your Email");
	if(ueresultnull == false)
	{
		return false;
	}
	
	ueresult = checkvalidemail("frm_email_the_lowest_price","uemail","Enter Valid Your Email");
	if(ueresult == false)
	{
		return false;
	}
}
function frmordervalidate()
{
	if (document.frmordertracking.orderid.value=="")
	{
		document.frmordertracking.orderid.focus();
		alert("Enter Valid Sales Receipt No or Order No !");
		return false;
	}
	if (document.frmordertracking.zipcode.value=="")
	{
		document.frmordertracking.zipcode.focus();
		alert("Enter Valid Billing Zip Code !");
		return false;
	}
	
	return true;
}
function Check_Customer_Servey() 
{
	var ueresult;
	var rdemail;
	var ueresultnull;
	
	if(document.frm_servey.rd_email_confirm[0].checked)
	{
		ueresultnull = CheckingNull("frm_servey","email_address","Enter Valid Email Address");
		if(ueresultnull == false)
		{
			return false;
		}
		else
		{
			ueresult = checkvalidemail("frm_servey","email_address","Enter Valid Email Address");
			if(ueresult == false)
			{
				return false;
			}	
		}
	}	
}

function Check_Left_Discount() 
{
	var ueresult;
	var ueresultnull;
	
	ueresultnull = CheckingNull("frmdiscount","txt_newsletter","Enter Valid Email Address");
	if(ueresultnull == false)
	{
		return false;
	}
	else
	{
		ueresult = checkvalidemail("frmdiscount","txt_newsletter","Enter Valid Email Address");
		if(ueresult == false)
		{
			return false;
		}	
	}
}	

function Check_Discount_Club() 
{
	var ueresult;
	var ueresultnull;
	
	ueresultnull = CheckingNull("frmdiscountpage","txt_newsletter","Enter Valid Email Address");
	if(ueresultnull == false)
	{
		return false;
	}
	else
	{
		ueresult = checkvalidemail("frmdiscountpage","txt_newsletter","Enter Valid Email Address");
		if(ueresult == false)
		{
			return false;
		}	
	}
}


//added by ashini
//this function is use for pricematch
function pricematch_validate(){
	var name;
	var phone;
	var email;
	var mobility;
	var model;
	var cprice;
	var dprice;
	var cname;
	var url;
	 
	name=CheckingNull("frm_pricematch","brand","Enter Valid Name");
	if(name == false){
		return false;
	}

	
	phone=CheckingNull("frm_pricematch","serial","Enter Valid Phone Number");
	if(phone == false){
		return false;
	}
	if (isNaN(document.frm_pricematch.serial.value))
			{
				alert("Enter Valid Phone Number");
				document.frm_pricematch.serial.value = '';
				document.frm_pricematch.serial.focus();
				return false;
			}
	email=CheckingNull("frm_pricematch","serial2","Enter Valid Email Address");
	if(email == false){
		return false;
	}
	email = checkvalidemail("frm_pricematch","serial2","Enter Valid Email Address");
			if(email == false)
			{
				return false;
			}
	
	if (document.frm_pricematch.serial2.value != document.frm_pricematch.serial2.value)	
				{
					alert("Email & Confirm Email should be same.");
					document.frm_contactus.txt_cemail.value = '';
					document.frm_contactus.txt_cemail.focus();
					return false;
				}
	mobility=CheckingNull("frm_pricematch","serial3","Enter Valid Mobility Product");
	if(mobility == false){
		return false;
	}
	model=CheckingNull("frm_pricematch","serial4","Enter Valid Model");
	if(model == false){
		return false;
	}
	cprice=CheckingNull("frm_pricematch","serial5","Enter Valid Competetior's Price");
	if(cprice == false){
		return false;
	}
	dprice=CheckingNull("frm_pricematch","serial7","Enter Valid Scooterdirect.com Price");
	if(dprice == false){
		return false;
	}
	cname=CheckingNull("frm_pricematch","serial8","Enter Valid Competitor Business Name");
	if(cname == false){
		return false;
	}
	url=CheckingNull("frm_pricematch","serial9","Enter Valid Exact URL of product on Competitor's site");
	if(url == false){
		return false;
	}
}






// Added By Yogesh
// This Function is used for contact us form
function Check_Contact_Us() 
{
	
	var firstname;	  
	var lastname;	     
	var phone;
	var email;
	var message;
	
	firstname = MyCheckingNull("txt_fname","Enter Valid First Name");	      
    if(firstname == false)
	{
		return false;
	}

    
	lastname = MyCheckingNull("txt_lname","Enter Valid Last Name");
	
    
    	if(lastname == false)
	{
		return false;
	}

	
	/*var optobj =document.getElementById("rd_contact");

	if (optobj[0].checked)
	{
		phone = MyCheckingNull("txt_ph_no","Enter Valid Phone Number");
		if(phone == false)
		{
			return false;
		}
		else
		{
			if (isNaN(document.getElementById("txt_ph_no").value))
			{
				alert("Enter Valid Phone Number");
				document.getElementById("txt_ph_no").value = '';
				document.getElementById("txt_ph_no").focus();
				return false;
			}
		}
	}*/

//	if (optobj[1].checked)
//	{
		email = MyCheckingNull("txt_email","Enter Valid Email Address");

		if(email == false)
		{
			return false;
		}
		else
		{
			email = checkvalidemail("frm_contactus","txt_email","Enter Valid Email Address");
			if(email == false)
			{
				return false;
			}
		}
		cemail = checkvalidemail("frm_contactus","txt_cemail","Enter Valid Confirm Email Address");
		if(cemail == false)
		{
			return false;
		}
		else
		{
			if (document.getElementById("txt_email").value != document.getElementById("txt_cemail").value)	
			{
				alert("Email & Confirm Email should be same.");
				document.getElementById("txt_cemail").value = '';
				document.getElementById("txt_cemail").focus();
				return false;
			}
		}
		//}
	//}

	if (document.getElementById("txt_zip").value != "")
	{
		if (isNaN(document.frm_contactus.txt_zip.value))
		{
			alert("Enter Valid Zip Code");
			document.getElementById("txt_zip").value = '';
			document.getElementById("txt_zip").focus();
			return false;
		}
	}
	
	message = MyCheckingNull("txt_message","Enter Message");
	if(message == false)
	{
		return false;
	}
}


// This Function is used for the update customer information
function Check_Cust_Update() 
{
	var bill_firstname;
	var bill_lastname;
	var bill_address1;
	var bill_address2;
	var bill_city;
	var bill_state;
	var bill_zip;
	var bill_email;
	var bill_veri_email;
	var bill_homecode;
	var bill_homephone;
	var ship_firstname;
	var ship_lastname;
	var ship_address1;
	var ship_address2;
	var ship_city;
	var ship_state;
	var ship_zip;
	var ship_homecode;
	var ship_homephone;

	bill_firstname = CheckingNull("frmshopcart","billingfirstname","Enter Billing First Name");
	if(bill_firstname == false)
	{
		return false;
	}

	bill_lastname = CheckingNull("frmshopcart","billinglastname","Enter Billing Last Name");
	if(bill_lastname == false)
	{
		return false;
	}

	bill_address1 = CheckingNull("frmshopcart","billingaddress1","Enter Billing Address");
	if(bill_address1 == false)
	{
		return false;
	}
/*
	bill_address2 = CheckingNull("frmshopcart","billingaddress2","Enter Billing Address");
	if(bill_address2 == false)
	{
		return false;
	}
*/
	bill_city = CheckingNull("frmshopcart","billingcity","Enter Billing City");
	if(bill_city == false)
	{
		return false;
	}

	bill_state = CheckingNull("frmshopcart","billingstate","Select Billing State");
	if(bill_state == false)
	{
		return false;
	}

	bill_zip = CheckingNull("frmshopcart","billingzip","Enter Billing Zip code");
	if(bill_zip == false)
	{
		return false;
	}

	if (document.frmshopcart.billingzip.value != "")
	{
		if (isNaN(document.frmshopcart.billingzip.value))
		{
			alert("Enter Valid Zip Code");
			document.frmshopcart.billingzip.value = '';
			document.frmshopcart.billingzip.focus();
			return false;
		}
	}
	
	bill_email = checkvalidemail("frmshopcart","billingemail","Enter Billing Email Address");
	if(bill_email == false)
	{
		return false;
	}
	bill_email = checkvalidemail("frmshopcart","billingemail","Enter Valid Email Address");
	if(bill_email == false)
	{
		return false;
	}

	bill_veri_email = checkvalidemail("frmshopcart","billingveriemail","Enter Billing Verify Email Address");
	if(bill_veri_email == false)
	{
		return false;
	}
	else
	{
		if (document.frmshopcart.billingemail.value != document.frmshopcart.billingveriemail.value)	
		{
			alert("Billing Email & Billing Verify Email should be same.");
			document.frmshopcart.billingveriemail.value='';
			document.frmshopcart.billingveriemail.focus();
			return false;
		}
	}
	bill_veri_email = checkvalidemail("frmshopcart","billingveriemail","Enter Billing Verify Email Address");
	if(bill_veri_email == false)
	{
		return false;
	}
	

	bill_homecode = CheckingNull("frmshopcart","Billing_Home_Code","Enter Billing Home Phone");
	if(bill_homecode == false)
	{
		return false;
	}
	if (document.frmshopcart.Billing_Home_Code.value != "")
	{
		if (isNaN(document.frmshopcart.Billing_Home_Code.value))
		{
			alert("Enter Valid Billing Home Phone Code");
			document.frmshopcart.Billing_Home_Code.value = '';
			document.frmshopcart.Billing_Home_Code.focus();
			return false;
		}
	}


	bill_homephone = CheckingNull("frmshopcart","Billing_Home_Phone","Enter Billing Home Phone");
	if(bill_homephone == false)
	{
		return false;
	}
	if (document.frmshopcart.Billing_Home_Phone.value != "")
	{
		if (isNaN(document.frmshopcart.Billing_Home_Phone.value))
		{
			alert("Enter Valid Billing Home Phone Number");
			document.frmshopcart.Billing_Home_Phone.value = '';
			document.frmshopcart.Billing_Home_Phone.focus();
			return false;
		}
	}
	
	if (document.frmshopcart.Billing_Work_Code.value != "")
	{
		if (isNaN(document.frmshopcart.Billing_Work_Code.value))
		{
			alert("Enter Valid Billing Work Phone Code");
			document.frmshopcart.Billing_Work_Code.value = '';
			document.frmshopcart.Billing_Work_Code.focus();
			return false;
		}
	}
	
	if (document.frmshopcart.Billing_Work_Phone.value != "")
	{
		if (isNaN(document.frmshopcart.Billing_Work_Phone.value))
		{
			alert("Enter Valid Billing Work Phone Number");
			document.frmshopcart.Billing_Work_Phone.value = '';
			document.frmshopcart.Billing_Work_Phone.focus();
			return false;
		}
	}
	
	if (document.frmshopcart.Billing_Fax_Code.value != "")
	{
		if (isNaN(document.frmshopcart.Billing_Fax_Code.value))
		{
			alert("Enter Valid Billing Fax Code");
			document.frmshopcart.Billing_Fax_Code.value = '';
			document.frmshopcart.Billing_Fax_Code.focus();
			return false;
		}
	}
	
	if (document.frmshopcart.Billing_Fax_Phone.value != "")
	{
		if (isNaN(document.frmshopcart.Billing_Fax_Phone.value))
		{
			alert("Enter Valid Billing Fax Number");
			document.frmshopcart.Billing_Fax_Phone.value = '';
			document.frmshopcart.Billing_Fax_Phone.focus();
			return false;
		}
	}
	
	ship_firstname = CheckingNull("frmshopcart","shippingfirstname","Enter Shipping First Name");
	if(ship_firstname == false)
	{
		return false;
	}

	ship_lastname = CheckingNull("frmshopcart","shippinglastname","Enter Shipping Last Name");
	if(ship_lastname == false)
	{
		return false;
	}

	ship_address1 = CheckingNull("frmshopcart","shippingaddress1","Enter Shipping Address");
	if(ship_address1 == false)
	{
		return false;
	}
/*
	ship_address2 = CheckingNull("frmshopcart","shippingaddress2","Enter Shipping Address");
	if(ship_address2 == false)
	{
		return false;
	}
*/
	ship_city = CheckingNull("frmshopcart","shippingcity","Enter Shipping City");
	if(ship_city == false)
	{
		return false;
	}

	ship_state = CheckingNull("frmshopcart","shippingstate","Select Shipping State");
	if(ship_state == false)
	{
		return false;
	}

	ship_zip = CheckingNull("frmshopcart","shippingzip","Enter Shipping Zip code");
	if(ship_zip == false)
	{
		return false;
	}

	if (document.frmshopcart.shippingzip.value != "")
	{
		if (isNaN(document.frmshopcart.shippingzip.value))
		{
			alert("Enter Valid Zip Code");
			document.frmshopcart.shippingzip.value = '';
			document.frmshopcart.shippingzip.focus();
			return false;
		}
	}
	
	ship_homecode = CheckingNull("frmshopcart","Shipping_Home_Code","Enter Shipping Home Phone");
	if(ship_homecode == false)
	{
		return false;
	}
	if (document.frmshopcart.Shipping_Home_Code.value != "")
	{
		if (isNaN(document.frmshopcart.Shipping_Home_Code.value))
		{
			alert("Enter Valid Shopping Home Phone Code");
			document.frmshopcart.Shipping_Home_Code.value = '';
			document.frmshopcart.Shipping_Home_Code.focus();
			return false;
		}
	}


	ship_homephone = CheckingNull("frmshopcart","Shipping_Home_Phone","Enter Shipping Home Phone");
	if(ship_homephone == false)
	{
		return false;
	}
	if (document.frmshopcart.Shipping_Home_Phone.value != "")
	{
		if (isNaN(document.frmshopcart.Shipping_Home_Phone.value))
		{
			alert("Enter Valid Shopping Home Phone Number");
			document.frmshopcart.Shipping_Home_Phone.value = '';
			document.frmshopcart.Shipping_Home_Phone.focus();
			return false;
		}
	}

	if (document.frmshopcart.Shipping_Work_Code.value != "")
	{
		if (isNaN(document.frmshopcart.Shipping_Work_Code.value))
		{
			alert("Enter Valid Shopping Work Phone Code");
			document.frmshopcart.Shipping_Work_Code.value = '';
			document.frmshopcart.Shipping_Work_Code.focus();
			return false;
		}
	}

	if (document.frmshopcart.Shipping_Work_Phone.value != "")
	{
		if (isNaN(document.frmshopcart.Shipping_Work_Phone.value))
		{
			alert("Enter Valid Shopping Work Phone Number");
			document.frmshopcart.Shipping_Work_Phone.value = '';
			document.frmshopcart.Shipping_Work_Phone.focus();
			return false;
		}
	}

	if (document.frmshopcart.Shipping_Fax_Code.value != "")
	{
		if (isNaN(document.frmshopcart.Shipping_Fax_Code.value))
		{
			alert("Enter Valid Shopping Fax Code");
			document.frmshopcart.Shipping_Fax_Code.value = '';
			document.frmshopcart.Shipping_Fax_Code.focus();
			return false;
		}
	}

	if (document.frmshopcart.Shipping_Fax_Phone.value != "")
	{
		if (isNaN(document.frmshopcart.Shipping_Fax_Phone.value))
		{
			alert("Enter Valid Shopping Fax Number");
			document.frmshopcart.Shipping_Fax_Phone.value = '';
			document.frmshopcart.Shipping_Fax_Phone.focus();
			return false;
		}
	}

	return true;	
}

function addtracking_validate(){
	var orderno;
	var salesno;
	var billinglast;
	var billingzip;
	var phone;
	var trackingno;
	var email;
	var orderdate;

	orderdate = CheckingNull("frmtracking","orderdate","Enter Valid Order Date");
	if(orderdate == false)
	{
		return false;
	}

	if(document.frmtracking.iOrderMasterId.value ==''){
		if(document.frmtracking.Sales_Receipt_No.value == ''){
			orderno=CheckingNull("frmtracking","iOrderMasterId","Enter Valid Order Number / Sales Receipt Number");
			if(orderno == false){
				return false;	
			}
		}
	}	
//	if(document.frmtracking.Sales_Receipt_No.value ==''){
//		if(document.frmtracking.iOrderMasterId.value == ''){
//			salesno=CheckingNull("frmtracking","Sales_Receipt_No","Enter Valid Order Number / Sales Receipt Number");
//			if(salesno == false){
//				return false;	
//			}
//		}
//	}	
	billinglast = CheckingNull("frmtracking","Billing_Last_Name","Enter Valid BillingLastName");
			if(billinglast == false)
			{
				return false;
			}
	billingzip = CheckingNull("frmtracking","Billing_Zip_Code","Enter Valid BillingZipCode");
			if(billingzip == false)
			{
				return false;
			}
			if(isNaN(document.frmtracking.Billing_Zip_Code.value))
			{
				alert("Enter Valid BillingZipCode");
				document.frmtracking.Billing_Zip_Code.value = '';
				document.frmtracking.Billing_Zip_Code.focus();
				return false;
			}
/*
	phone = CheckingNull("frmtracking","Phone_No","Enter Valid Phone No");
			if(phone == false)
			{
				return false;
			}
			if (isNaN(document.frmtracking.Phone_No.value))
			{
				alert("Enter Valid PhoneNo");
				document.frmtracking.Phone_No.value = '';
				document.frmtracking.Phone_No.focus();
				return false;
			}
*/
	trackingno = CheckingNull("frmtracking","tracking_no","Enter Valid tracking no");
			if(trackingno == false)
			{
				return false;
			}
//			if (isNaN(document.frmtracking.tracking_no.value))
//			{
//				alert("Enter Valid tracking no");
//				document.frmtracking.tracking_no.value = '';
//				document.frmtracking.tracking_no.focus();
//				return false;
//			}
	
	email=CheckingNull("frmtracking","Email","Enter Valid Email Address");
	if(email == false){
		return false;
	}
	email = checkvalidemail("frmtracking","Email","Enter Valid Email Address");
	if(email == false)
	{
		return false;
	}
}


// This Function is used for the change password
function Check_ChgPasswd() 
{
	var old_passwd;
	var new_passwd;
	var conf_passwd;

	old_passwd = CheckingNull("frmchgpass","old_passwd","Enter Valid Old Password");
	if(old_passwd == false)
	{
		return false;
	}

	new_passwd = CheckingNull("frmchgpass","new_passwd","Enter Valid New Password");
	if(new_passwd == false)
	{
		return false;
	}

	conf_passwd = CheckingNull("frmchgpass","conf_passwd","Enter Valid Confirm Password");
	if(conf_passwd == false)
	{
		return false;
	}
	else
	{
		if (document.frmchgpass.new_passwd.value != document.frmchgpass.conf_passwd.value)	
		{
			alert("New Password & Confirm Password should be same.");
			document.frmchgpass.conf_passwd.value = '';
			document.frmchgpass.conf_passwd.focus();
			return false;
		}
	}
}
// This is for the click on the same for billing and shipping
function filldata()
{
	document.frmshopcart.shippingfirstname.value=document.frmshopcart.billingfirstname.value;
	document.frmshopcart.ShippingMiddleInitial.value=document.frmshopcart.BillingMiddleInitial.value;
	document.frmshopcart.shippinglastname.value=document.frmshopcart.billinglastname.value;
	document.frmshopcart.shippingcompany.value=document.frmshopcart.billingcompany.value;
	document.frmshopcart.shippingaddress1.value=document.frmshopcart.billingaddress1.value;
	document.frmshopcart.shippingaddress2.value=document.frmshopcart.billingaddress2.value;
	document.frmshopcart.shippingcity.value=document.frmshopcart.billingcity.value;
	document.frmshopcart.shippingstate.value=document.frmshopcart.billingstate.value;
	document.frmshopcart.shippingzip.value=document.frmshopcart.billingzip.value;
	document.frmshopcart.Shipping_Home_Code.value=document.frmshopcart.Billing_Home_Code.value;
	document.frmshopcart.Shipping_Home_Phone.value=document.frmshopcart.Billing_Home_Phone.value;
	document.frmshopcart.Shipping_Work_Code.value=document.frmshopcart.Billing_Work_Code.value;
	document.frmshopcart.Shipping_Work_Phone.value=document.frmshopcart.Billing_Work_Phone.value;
	document.frmshopcart.Shipping_Fax_Code.value=document.frmshopcart.Billing_Fax_Code.value;
	document.frmshopcart.Shipping_Fax_Phone.value=document.frmshopcart.Billing_Fax_Phone.value;
}
// End Added By Yogesh


function Check_User_Login(frm) 
{
	var ueresult;
	var ueresultnull;
	
	ueresultnull = MyCheckingNull("txt_log_email","Enter Valid Email Address");
	
	if(ueresultnull == false)
	{
		return false;
	}
	else
	{
		ueresult = Mycheckvalidemail("txt_log_email","Enter Valid Email Address");
		if(ueresult == false)
		{
			return false;
		}	
	}
	
	var chkpasswordnull;
	chkpasswordnull = MyCheckingNull("txt_log_password","Enter Password");
	
	if(chkpasswordnull == false)
	{
		return false;
	}
	return true;	
}


function Check_Account_Create() 
{
	var ueresult;
	var ueresultnull;
	
	ueresultnull = CheckingNull("frm_login","txt_email","Enter Valid Email Address");
	
	if(ueresultnull == false)
	{
		return false;
	}
	else
	{
		ueresult = checkvalidemail("frm_login","txt_email","Enter Valid Email Address");
		if(ueresult == false)
		{
			return false;
		}	
	}
	
	var chkfname;
	chkfname = CheckingNull("frm_login","txt_fname","Enter First Name");
	
	if(chkfname == false)
	{
		return false;
	}
	
	var chklname;
	chklname = CheckingNull("frm_login","txt_lname","Enter Last Name");
	
	if(chklname == false)
	{
		return false;
	}
	
	var chkpasswordnull;
	chkpasswordnull = CheckingNull("frm_login","txt_password","Enter Password");
	
	if(chkpasswordnull == false)
	{
		return false;
	}
	
	var chkcpasswordnull;
	chkcpasswordnull = CheckingNull("frm_login","txt_cpassword","Enter Confirm Password");
	
	if(chkcpasswordnull == false)
	{
		return false;
	}
	
	/*var chkreminder;
	chkreminder = CheckingNull("frm_login","txt_reminder","Enter Password Reminder");
	
	if(chkreminder == false)
	{
		return false;
	}*/
	
	if(document.frm_login.txt_password.value != document.frm_login.txt_cpassword.value)
	{
		alert("Password & Confirm Password should be same.");
		return false;
	}	
}

function MyCheck_Account_Create() 
{
	var ueresult;
	var ueresultnull;
	
	ueresultnull = MyCheckingNull("txt_email","Enter Valid Email Address");
	
	if(ueresultnull == false)
	{
		return false;
	}
	else
	{
		ueresult = Mycheckvalidemail("txt_email","Enter Valid Email Address");
		if(ueresult == false)
		{
			return false;
		}	
	}
	
	var chkfname;
	chkfname = MyCheckingNull("txt_fname","Enter First Name");
	
	if(chkfname == false)
	{
		return false;
	}
	
	var chklname;
	chklname = MyCheckingNull("txt_lname","Enter Last Name");
	
	if(chklname == false)
	{
		return false;
	}
	
	var chkpasswordnull;
	chkpasswordnull = MyCheckingNull("txt_password","Enter Password");
	
	if(chkpasswordnull == false)
	{
		return false;
	}
	
	var chkcpasswordnull;
	chkcpasswordnull = MyCheckingNull("txt_cpassword","Enter Confirm Password");
	
	if(chkcpasswordnull == false)
	{
		return false;
	}
	
	/*var chkreminder;
	chkreminder = CheckingNull("frm_login","txt_reminder","Enter Password Reminder");
	
	if(chkreminder == false)
	{
		return false;
	}*/
	
	if(document.getElementById("txt_password").value != document.getElementById("txt_cpassword").value)
	{
		alert("Password & Confirm Password should be same.");
		return false;
	}
	return true;	
}


function Check_Service() 
{
	var chkreceiptno;
	chkreceiptno = CheckingNull("frm_service","txt_receipt_no","Enter Valid Sales Receipt NO.");
	
	if(chkreceiptno == false)
	{
		return false;
	}
	
	var chkcustname;
	chkcustname = CheckingNull("frm_service","txt_cust_name","Enter Customer Name");
	
	if(chkcustname == false)
	{
		return false;
	}	
	
	var chkpurdate;
	chkpurdate = CheckingNull("frm_service","txt_pur_date","Enter Date of Purchase");
	
	if(chkpurdate == false)
	{
		return false;
	}
	var chkbmodel;
	chkbmodel = CheckingNull("frm_service","txt_bmodel","Enter Brand and Model of Product");
	
	if(chkbmodel == false)
	{
		return false;
	}
	
	var ueresult;
	var ueresultnull;
	
	ueresultnull = CheckingNull("frm_service","txt_email","Enter Valid Email Address");
	
	if(ueresultnull == false)
	{
		return false;
	}
	else
	{
		ueresult = checkvalidemail("frm_service","txt_email","Enter Valid Email Address");
		if(ueresult == false)
		{
			return false;
		}	
	}
	
	
	
	
	
	var chkreason;
	chkreason = CheckingNull("frm_service","txt_reason","Enter Reason for service Request");
	
	if(chkreason == false)
	{
		return false;
	}

}

function Check_search_Service_center() 
{
	var chkreceiptno;
	chkreceiptno = CheckingNull("frm_search_service","txt_zipcode","Enter Zip Code Number.");
	
	if(chkreceiptno == false)
	{
		return false;
	}
}

function doSubmit() 
{
	var usermail;
	var useremail;

	usermail = CheckingNull("frm_login","txt_log_email","Enter Valid Email Address");
	
	if(usermail == false)
	{
		return false;
	}
	else
	{
		useremail = checkvalidemail("frm_login","txt_log_email","Enter Valid Email Address");
		if(useremail == false)
		{
			return false;
		}	
	}

	document.frm_login.submit();
}

function chkpaymentmethod() 
{
	var selected=false;
	for(i=0;i<3;i++) 
	{
		var val = eval("document.form3.Paymethods["+i+"].checked");
		if(val== true) {
			var selected = true;
			break;
		}
	}
	if(selected) {
		return true;
	} 
	else {
		alert("Please select any one Payment Method.");
		return false;
	}
} 
function uncheckedforAll(frm,index)
{
	with(frm)
	{
		var subchk = document.getElementById("subcount["+index+"]");
		
		if(subchk.value > 0)
		{
			
			var i;
			for(i= 1; i<= parseInt(subchk.value); i++)
			{
				var subcat = document.getElementById("Subcat["+index+"]["+i+"]");
				if(subcat.checked)
				{
					subcat.checked = false;
				}
			}
		}
		
	}
}
function uncheckedforOthers(frm,index)
{
	with(frm)
	{
		var allcat = document.getElementById("Cat["+index+"]");
		if(allcat.checked)
		{
			allcat.checked = false;
		}
 	}
}
function getCatsubCat(frm){
	
	with(frm)
	{
		var totalelements = frm.elements.length;
		//alert(totalelements);
		var i=0;
		for(i=1; i< totalelements; i++)
		{
			if(elements[i].type == "checkbox")
			{
				if(elements[i].checked)
				{
					if(elements[i].adjacentText == "All")
					{
						alert(elements[i].adjacentText);
					}
					else{alert(elements[i].AdjacentText);}
					
					
				}	//	End of if checked.
			}	//	End of checkbox.
			
		}	//	End of for.
		return false;
		var subchk = document.getElementById("count");
	}
}
function uncheckedAll(){
	
	//alert(document.frmscooterselect.allbrandname.checked);return false;
	if(document.frmscooterselect.allbrandname.checked==true)
		{
			
			document.frmscooterselect.allbrandname.checked = false;
			
		}
	
}
function uncheckedOthers(){
	//flag = 0;
	
	var comp="";
	// count the no of elements in a form
	var num_elements = document.frmscooterselect.elements.length;
	//
	if(document.frmscooterselect.allbrandname.checked == true) {
		
		for(i=0;i<num_elements;i++) {
			
			
		if (document.frmscooterselect.elements[i].type == 'checkbox' && document.frmscooterselect.elements[i].name != "allbrandname" )
		{	
			if(document.frmscooterselect.elements[i].checked==true)
			{
				document.frmscooterselect.elements[i].checked=false;
			}
		}
	}
	
	}
}
function selectcategory() {
	flag = 0;
	var comp="";
	// count the no of elements in a form
	var num_elements = document.frmscooterselect.elements.length;
	
	for(i=0;i<num_elements;i++) {

	if (document.frmscooterselect.elements[i].type == 'checkbox')
	{
		if(document.frmscooterselect.elements[i].checked==true)
		{
			if (comp != "")
				comp = comp+"_"+document.frmscooterselect.elements[i].value;
			else
				comp = document.frmscooterselect.elements[i].value;
		}
	}
		
		// check weather any formfield is selected
		if(document.frmscooterselect.elements[i].name == "brandname[]" || document.frmscooterselect.elements[i].name == "category" || document.frmscooterselect.elements[i].name == "pricerange" ||
	       document.frmscooterselect.elements[i].name == "maxweight" || document.frmscooterselect.elements[i].name == "topspeed" || document.frmscooterselect.elements[i].name == "heaviestscooter" || document.frmscooterselect.elements[i].name == "drivingrange" ) {
		
			if(document.frmscooterselect.elements[i].checked) {
				flag = 1;
			}
		}
	}
	document.frmscooterselect.companyid.value = comp;
	if(flag != 1) {
		alert("please select the any one item.");
		return false;
	}
}

// This function is used for validate credit card details
function validate_from()
{
	var d = new Date()
	var yr = d.getFullYear();
	var mn = d.getMonth();
	mn = mn + 1;

	if(!document.frmcreditcard.cardname.value)
	{
		alert("Please Enter Name On Credit Card !");
		document.frmcreditcard.cardname.focus();	
		return false;
 	}

	if(!document.frmcreditcard.cardnumber.value)
	{
		alert("Please Enter Credit Card Number !");
		document.frmcreditcard.cardnumber.focus();	
		return false;
 	}
	if(isNaN(document.frmcreditcard.cardnumber.value))
	{
 		alert("Please Enter Valid Credit Card Number !");
		document.frmcreditcard.cardnumber.focus();	
		return false;
 	}
	else
	{
		if(document.frmcreditcard.cardnumber.value.length<15)
		{
			alert("Please Enter Valid Credit Card Number !");
			document.frmcreditcard.cardnumber.focus();	
			return false;
		}

		if(document.frmcreditcard.cardtype.value=="Amex" && document.frmcreditcard.cardnumber.value.length!=15 )
		{
			alert("Please Enter Valid Credit Card Number for American Express !");
			document.frmcreditcard.cardnumber.focus();	
			return false;
		}
		else if(document.frmcreditcard.cardtype.value!="Amex" && document.frmcreditcard.cardnumber.value.length!=16 )
		{
			alert("Please Enter Valid Credit Card Number !");
			document.frmcreditcard.cardnumber.focus();	
			return false;
		}

		if(document.frmcreditcard.cardtype.value=="Amex" && document.frmcreditcard.cardnumber.value.indexOf("3")!=0)
		{	
			alert("Please Enter Valid Credit Card Number for American Express !");
			document.frmcreditcard.cardnumber.focus();	
			return false;
		}

		if(document.frmcreditcard.cardtype.value=="Visa" && document.frmcreditcard.cardnumber.value.indexOf("4")!=0)
		{
			alert("Please Enter Valid Credit Card Number for Visa !");
			document.frmcreditcard.cardnumber.focus();	
			return false;
		}

		if(document.frmcreditcard.cardtype.value=="Master Card" && document.frmcreditcard.cardnumber.value.indexOf("5")!=0)
		{	
			alert("Please Enter Valid Credit Card Number for Master Card !");
			document.frmcreditcard.cardnumber.focus();	
			return false;
		}

		if(document.frmcreditcard.cardtype.value=="Discover" && document.frmcreditcard.cardnumber.value.indexOf("6")!=0)
		{	
			alert("Please Enter Valid Credit Card Number for Discover !");
			document.frmcreditcard.cardnumber.focus();	
			return false;
		}
	}

	if (document.frmcreditcard.year.value == yr)
	{
		if (document.frmcreditcard.month.value <= mn)
		{
			alert("Please Enter Valid Expiry Date !");
			return false;
		}
	}

	if(!document.frmcreditcard.vcode.value)
	{
		alert("Please Enter V Code Number !");
		document.frmcreditcard.vcode.focus();	
		return false;
	}
	if(isNaN(document.frmcreditcard.vcode.value))
	{
		alert("Please Enter Valid V Code Number !");
		document.frmcreditcard.vcode.focus();	
		return false;
	}
	else
	{
		if(document.frmcreditcard.cardtype.value=="Amex" && document.frmcreditcard.vcode.value.length!=4 )
		{
			alert("Please Enter Valid V Code Number for American Express !");
			document.frmcreditcard.vcode.focus();	
			return false;
		}
		else if (document.frmcreditcard.cardtype.value!="Amex" && document.frmcreditcard.vcode.value.length!=3)
		{
			alert("Please Enter Valid V Code Number !");
			document.frmcreditcard.vcode.focus();
			return false;
		}
	}

	if (document.getElementById("checkreturn"))
	{
		if (!document.getElementById("checkreturn").checked)
		{
			alert("Please Read And Understand The Return Policy!");
			return false;
		}
	}

	document.frmcreditcard.submit();
}

function Conversion_Inches2Foot() {
	
	var inches = trimAll(document.frmrampcalculator.verticleriseininches.value);

	// check weather it is empty
	if((inches.length) <= 0) {
		alert("Please Enter the Inches");
		document.frmrampcalculator.verticleriseininches.value = '';
		document.frmrampcalculator.verticleriseininches.focus();
		return false;
	}
	else {
		// check weather it is not a number
		if(isNaN(inches)) { 
			alert("Inches must be a Number.");
			document.frmrampcalculator.verticleriseininches.value = '';
			document.frmrampcalculator.verticleriseininches.focus();
			return false;	
		} 
		else {
//			alert(inches);
			var foot = eval(inches/3);
			document.frmrampcalculator.verticleriseinfoot.value = foot;
			return false;
		}
	}
}

function ResetText() {
	document.frmrampcalculator.verticleriseininches.value = '';
	document.frmrampcalculator.verticleriseinfoot.value = '';
	document.frmrampcalculator.verticleriseininches.focus;
}

function trimAll(sString) 
{
	while (sString.substring(0,1) == ' ')
	{
	sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
	sString = sString.substring(0,sString.length-1);
	
	}
	return sString;
		
} //End Function

function EditForm(){
	
	if(!document.frm.Billing_vFirstName.value)
	{
		alert("Please Enter Customer First Name For Billing !");
		document.frm.Billing_vFirstName.focus();	
		return false;
 	}
 	if(!document.frm.Billing_vLastName.value)
	{
		alert("Please Enter Customer Last Name For Billing  !");
		document.frm.Billing_vLastName.focus();	
		return false;
 	}
 	if(!document.frm.Billing_vAddress1.value)
	{
		alert("Please Enter Address1 For Billing !");
		document.frm.Billing_vAddress1.focus();	
		return false;
 	}
 	if(!document.frm.Billing_vCity.value)
	{
		alert("Please Enter City For Billing  !");
		document.frm.Billing_vCity.focus();	
		return false;
 	}
 	if(!document.frm.Billing_vState.value)
	{
		alert("Please Enter State For Billing !");
		document.frm.Billing_vState.focus();	
		return false;
 	}
 	if(!document.frm.Billing_vZipCode.value)
	{
		alert("Please Enter Zip Code For Billing !");
		document.frm.Billing_vZipCode.focus();	
		return false;
 	}
 	
 	if(!document.frm.Billing_Home_Phone.value)
	{
		alert("Please Enter Phone No For Billing !");
		document.frm.Billing_Home_Phone.focus();	
		return false;
 	}
 	if(!document.frm.Billing_vEmail.value)
	{
		alert("Please Enter Email For Billing !");
		document.frm.Billing_vEmail.focus();	
		return false;
 	}
 	
 	
 	if(!document.frm.Shipping_vFirstName.value)
	{
		alert("Please Enter Customer First Name For Shipping !");
		document.frm.Shipping_vFirstName.focus();	
		return false;
 	}
 	if(!document.frm.Shipping_vLastName.value)
	{
		alert("Please Enter Customer Last Name For Shipping  !");
		document.frmr.Shipping_vLastName.focus();	
		return false;
 	}
 	if(!document.frm.Shipping_vAddress1.value)
	{
		alert("Please Enter Address1 For Shipping !");
		document.frm.Shipping_vAddress1.focus();	
		return false;
 	}
 	if(!document.frm.Shipping_vCity.value)
	{
		alert("Please Enter City For Shipping  !");
		document.frm.Shipping_vCity.focus();	
		return false;
 	}
 	if(!document.frm.Shipping_vState.value)
	{
		alert("Please Enter State For Shipping !");
		document.frm.Shipping_vState.focus();	
		return false;
 	}
 	if(!document.frm.Shipping_vZipCode.value)
	{
		alert("Please Enter Zip Code For Shipping !");
		document.frm.Shipping_vZipCode.focus();	
		return false;
 	}
 	if(!document.frm.Shipping_Home_Phone.value)
	{
		alert("Please Enter Phone No For Shipping !");
		document.frm.Shipping_Home_Phone.focus();	
		return false;
 	}
 	if(!document.frm.Shipping_vEmail.value)
	{
		alert("Please Enter Email For Shipping !");
		document.frm.Shipping_vEmail.focus();	
		return false;
 	}
 }
 
 function IsValidateServiceCenter(){
	
	var formName 
	formName = document.addservicecenter
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?_" ;
	Lenfirstname = formName.txt_first_name.value.length;
	if (!(validateString(formName.txt_first_name, "Please Enter First Name")))
		return false
		
	if(Lenfirstname > 255)
	{
		alert("First Name should not be more then 255 characters");
		formName.txt_first_name.focus();
		return false;
	}	
	var iChars1 = "0123456789!@#$%^&*()+=-[]\\\';,./{}|\":<>?_" ;
	for (var i = 0; i < formName.txt_first_name.value.length; i++) {
		if (iChars1.indexOf(eval("formName.txt_first_name.value.charAt("+i+")")) != -1) {
			alert("First Name: Only a to z , A to Z and space is allowed.");
			formName.txt_first_name.focus();
		  	formName.txt_first_name.value = '';
		  	return false;
	  	}
	}
	Lenlastname = formName.txt_last_name.value.length;
	if (!(validateString(formName.txt_last_name, "Please Enter Last Name")))
		return false

	if(Lenlastname > 255)
	{
		alert("Last Name should not be more then 255 characters");
		formName.txt_last_name.focus();
		return false;
	}
	
	for (var i = 0; i < formName.txt_last_name.value.length; i++) {
		if (iChars1.indexOf(eval("formName.txt_last_name.value.charAt("+i+")")) != -1) {
			alert("Last Name : Only a to z , A to Z and space is allowed.");
			formName.txt_last_name.focus();
		  	formName.txt_last_name.value = '';
		  	return false;
	  	}
	}
	
	Lencompname = formName.txt_comp_name.value.length;
	if (!(validateString(formName.txt_comp_name, "Please Enter Company Name")))
		return false
		
	if(Lencompname > 255)
	{
		alert("Company Name should not be more then 255 characters");
		formName.txt_comp_name.focus();
		return false;
	}	
	
	if (!(validateString(formName.txt_phone, "Please Enter Phone")))
		return false
	
	var iChars = "";
	Lenphone = formName.txt_phone.value.length;
	
	if(Lenphone > 12)
	{
		alert("Phone number should not be more then 12 digits");
		formName.txt_phone.focus();
		return false;
	}
	result1 = formName.txt_phone.value.search(iChars);
	if (result1 == -1) 
	   	{
			alert("Please enter valid phone number(###-###-####).");
			formName.txt_phone.focus();
	   		return false;
		}
		
	if (!(validateString(formName.txt_add1, "Please Enter Address1")))
		return false	
	if (!(validateString(formName.txt_city, "Please Enter City")))
		return false
	if (!(validateString(formName.txt_state, "Please Select State")))
		return false	
	if (!(validateString(formName.txt_zipcode, "Please Enter ZipCode")))
		return false
		
	Lenzipcode = formName.txt_zipcode.value.length;
	
	if(Lenzipcode < 5)
	{
		alert("Zipcode should not be less then 5 digits");
		formName.txt_zipcode.focus();
		return false;
	}
	if(Lenzipcode > 10)
	{
		alert("Zipcode should not be more then 10 digits");
		formName.txt_zipcode.focus();
		return false;
	}
	
	if (isNaN(formName.txt_zipcode.value))
	{
		alert("Enter Valid ZipCode");
		formName.txt_zipcode.value = '';
		formName.txt_zipcode.focus();
		return false;
	}
	if(document.addservicecenter.txt_email.value != '')
	{
		res = checkvalidemail("addservicecenter","txt_email","Please Enter Valid Email Address")
		if(res==false)
		{
			return false;
		}
	}
	
	if(document.addservicecenter.txt_url.value != '')
	{	
		var urlregex = new RegExp("^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([0-9A-Za-z]+\.)");
		if(!(urlregex.test(formName.txt_url.value)))
		{
			alert("Please Enter valid URL");
			formName.txt_url.value = '';
			formName.txt_url.focus();
			return false;
		}
	}

	if (!(validateString(formName.txt_service, "Please Enter Service")))
		return false
/*
	if (!(validateString(formName.txt_paymentoption, "Please Enter Payment Option")))
		return false
	if (!(validateString(formName.txt_brand, "Please Enter Brand")))
		return false
	if (!(validateString(formName.txt_comment, "Please Enter Comment")))
		return false*/
}

function chklength ()
{		
	
 if(vanSelling.txt_vin.length>17){
 	alert("VIN cannot be exceed to 17 characters.");
 	vanSelling.txt_vin.focus();
 	return false;	
 }
 return true;
 	
}

/**
 * Function Name : ShowMessege
 * Description : Used to show message in the dialog box(alert) or in given element by id.
 * Parameter Description :
 * 		String ObjId = HtmlElementObject Id to display a message, leave blank or pass 'alert' to alert the string.
 *		String MsgString = Message String to be display
 */
function ShowMessege(ObjId, MsgString) {
	
	if( !ObjId || ObjId=='alert' || ObjId=='') {
	// Div Element Id is not defined or making alert
		alert(MsgString);
		
	} else {
	// Div Element Id is defined and message string is displayed in Element 	
		document.getElementById(ObjId).innerHTML = MsgString;
		
	}
}

function isEmpty(obj, errorString, errorObjName, defaultValue ) {
	
	if(obj!='') {
		
		if( trimAll(obj.value)=='' || obj.value == defaultValue ) {
			
			ShowMessege(errorObjName, errorString);
			
			return true;
			
		} else {
			
			if( errorObjName && errorObjName!='alert' && errorObjName!='') {
				document.getElementById(errorObjName).innerHTML = '';	
			}
			
		}
	}
	return false;
}



//var TabbedPanels1 = new Spry.Widget.TabbedPanels("tabber123");
function MM_openBrWindow(theURL,winName,features) { //v2.0
	 window.open(theURL,winName,features);
	 
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; 
  document.MM_sr=new Array; 
  for(i=0;i<(a.length-2);i+=3)
  	if ((x=MM_findObj(a[i]))!=null){
  		document.MM_sr[j++]=x; 
  	if(!x.oSrc) 
  		x.oSrc=x.src; x.src=a[i+2];
  }
}	 
}


function on_focus_text(obj) {
	if(obj.value == 'eg. xxx-xxx-xxxx') {
		obj.value = '';
		obj.style.color = '';
	}
	
}
function on_blur_text(obj) {
	if(obj.value == '') {
		obj.value = 'eg. xxx-xxx-xxxx';
		obj.style.color = '#BFBFBF';
	}
}
function autoaddSeprator(obj,event) {
	if(event.keyCode != 8) {
		if(obj.value.length == 3) {
			obj.value = obj.value + "-";
		}
		if(obj.value.length == 7) {
			obj.value = obj.value + "-";
		}
	}
}
function on_focus_secure_text(obj) {
	if(obj.value == 'eg. xxx-xx-xxxx') {
		obj.value = '';
		obj.style.color = '';
	}
	
}
function on_blur_secure_text(obj) {
	if(obj.value == '') {
		obj.value = 'eg. xxx-xx-xxxx';
		obj.style.color = '#BFBFBF';
	}
}
function autoaddSecureSeprator(obj,event) {
	if(event.keyCode != 8) {
		if(obj.value.length == 3) {
			obj.value = obj.value + "-";
		}
		if(obj.value.length == 6) {
			obj.value = obj.value + "-";
		}
	}
}
