var showNotice,adminMenu,columns,validateForm;(function(a){adminMenu={init:function(){var b=a("#adminmenu");a(".wp-menu-toggle",b).each(function(){var c=a(this),d=c.siblings(".wp-submenu");if(d.length){c.click(function(){adminMenu.toggle(d)})}else{c.hide()}});this.favorites();a(".separator",b).click(function(){if(a("body").hasClass("folded")){adminMenu.fold(1);deleteUserSetting("mfold")}else{adminMenu.fold();setUserSetting("mfold","f")}return false});if(a("body").hasClass("folded")){this.fold()}this.restoreMenuState()},restoreMenuState:function(){a("li.wp-has-submenu","#adminmenu").each(function(c,d){var b=getUserSetting("m"+c);if(a(d).hasClass("wp-has-current-submenu")){return true}if("o"==b){a(d).addClass("wp-menu-open")}else{if("c"==b){a(d).removeClass("wp-menu-open")}}})},toggle:function(b){var c=b.slideToggle(150,function(){b.css("display","")}).parent().toggleClass("wp-menu-open").attr("id");if(c){a("li.wp-has-submenu","#adminmenu").each(function(f,g){if(c==g.id){var d=a(g).hasClass("wp-menu-open")?"o":"c";setUserSetting("m"+f,d)}})}return false},fold:function(b){if(b){a("body").removeClass("folded");a("#adminmenu li.wp-has-submenu").unbind()}else{a("body").addClass("folded");a("#adminmenu li.wp-has-submenu").hoverIntent({over:function(j){var d,c,g,k,i;d=a(this).find(".wp-submenu");c=a(this).offset().top+d.height()+1;g=a("#wpwrap").height();k=60+c-g;i=a(window).height()+a(window).scrollTop()-15;if(i<(c-k)){k=c-i}if(k>1){d.css({marginTop:"-"+k+"px"})}else{if(d.css("marginTop")){d.css({marginTop:""})}}d.addClass("sub-open")},out:function(){a(this).find(".wp-submenu").removeClass("sub-open").css({marginTop:""})},timeout:220,sensitivity:8,interval:100})}},favorites:function(){a("#favorite-inside").width(a("#favorite-actions").width()-4);a("#favorite-toggle, #favorite-inside").bind("mouseenter",function(){a("#favorite-inside").removeClass("slideUp").addClass("slideDown");setTimeout(function(){if(a("#favorite-inside").hasClass("slideDown")){a("#favorite-inside").slideDown(100);a("#favorite-first").addClass("slide-down")}},200)}).bind("mouseleave",function(){a("#favorite-inside").removeClass("slideDown").addClass("slideUp");setTimeout(function(){if(a("#favorite-inside").hasClass("slideUp")){a("#favorite-inside").slideUp(100,function(){a("#favorite-first").removeClass("slide-down")})}},300)})}};a(document).ready(function(){adminMenu.init()});columns={init:function(){a(".hide-column-tog","#adv-settings").click(function(){var b=a(this).val();if(a(this).attr("checked")){a(".column-"+b).show()}else{a(".column-"+b).hide()}columns.save_manage_columns_state()})},save_manage_columns_state:function(){var b=a(".manage-column").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"hidden-columns",hidden:b,screenoptionnonce:a("#screenoptionnonce").val(),page:pagenow})}};a(document).ready(function(){columns.init()});validateForm=function(b){return !a(b).find(".form-required").filter(function(){return a("input:visible",this).val()==""}).addClass("form-invalid").find("input:visible").change(function(){a(this).closest(".form-invalid").removeClass("form-invalid")}).size()}})(jQuery);showNotice={warn:function(){var a=commonL10n.warnDelete||"";if(confirm(a)){return true}return false},note:function(a){alert(a)}};jQuery(document).ready(function(d){var f=false,a,e,c,b;d("div.wrap h2:first").nextAll("div.updated, div.error").addClass("below-h2");d("div.updated, div.error").not(".below-h2").insertAfter(d("div.wrap h2:first"));d("#show-settings-link").click(function(){if(!d("#screen-options-wrap").hasClass("screen-options-open")){d("#contextual-help-link-wrap").css("visibility","hidden")}d("#screen-options-wrap").slideToggle("fast",function(){if(d(this).hasClass("screen-options-open")){d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#contextual-help-link-wrap").css("visibility","");d(this).removeClass("screen-options-open")}else{d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("screen-options-open")}});return false});d("#contextual-help-link").click(function(){if(!d("#contextual-help-wrap").hasClass("contextual-help-open")){d("#screen-options-link-wrap").css("visibility","hidden")}d("#contextual-help-wrap").slideToggle("fast",function(){if(d(this).hasClass("contextual-help-open")){d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#screen-options-link-wrap").css("visibility","");d(this).removeClass("contextual-help-open")}else{d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("contextual-help-open")}});return false});d("tbody").children().children(".check-column").find(":checkbox").click(function(g){if("undefined"==g.shiftKey){return true}if(g.shiftKey){if(!f){return true}a=d(f).closest("form").find(":checkbox");e=a.index(f);c=a.index(this);b=d(this).attr("checked");if(0<e&&0<c&&e!=c){a.slice(e,c).attr("checked",function(){if(d(this).closest("tr").is(":visible")){return b?"checked":""}return""})}}f=this;return true});d("thead, tfoot").find(":checkbox").click(function(i){var j=d(this).attr("checked"),h="undefined"==typeof toggleWithKeyboard?false:toggleWithKeyboard,g=i.shiftKey||h;d(this).closest("table").children("tbody").filter(":visible").children().children(".check-column").find(":checkbox").attr("checked",function(){if(d(this).closest("tr").is(":hidden")){return""}if(g){return d(this).attr("checked")?"":"checked"}else{if(j){return"checked"}}return""});d(this).closest("table").children("thead,  tfoot").filter(":visible").children().children(".check-column").find(":checkbox").attr("checked",function(){if(g){return""}else{if(j){return"checked"}}return""})});d("#default-password-nag-no").click(function(){setUserSetting("default_password_nag","hide");d("div.default-password-nag").hide();return false})});jQuery(document).ready(function(b){var a=b("span.turbo-nag","#user_info");if(!a.length||("undefined"!=typeof(google)&&google.gears)){return}if("undefined"!=typeof GearsFactory){return}else{try{if(("undefined"!=typeof window.ActiveXObject&&ActiveXObject("Gears.Factory"))||("undefined"!=typeof navigator.mimeTypes&&navigator.mimeTypes["application/x-googlegears"])){return}}catch(c){}}a.show()});

// JavaScript Document

// JavaScript Document

/***********************************************User Manager****************************************/
function user_edit(user_id,page,limit)
{
	document.frm_user_mgmt.action="user_add.php?user_id="+user_id+"&page="+page+"&limit="+limit;
	document.frm_user_mgmt.submit();
}
function user_delete(user_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_user_mgmt.action="user_delete.php?user_id="+user_id+"&page="+page+"&limit="+limit;
		document.frm_user_mgmt.submit();	
	}
}

function user_save(page,limit)
{
	//alert(limit);
	//alert("hi");
	if(document.frm_user_add.user_type_id.value==0){
		alert("Select user type");
		document.frm_user_add.user_type_id.focus();
		return false;
	}else if(document.frm_user_add.user_first_name.value==''){
		alert("Please enter First Name");
		document.frm_user_add.user_first_name.focus();
		return false;
	}else if(document.frm_user_add.user_last_name.value==''){
		alert("Please enter Last Name");
		document.frm_user_add.user_last_name.focus();
		return false;
	}else if(document.frm_user_add.user_email_address.value == ""){
		alert("Please enter EmailID");
		document.frm_user_add.user_email_address.focus();
		return false;
	}else if(document.frm_user_add.user_email_address.value.indexOf("@") == -1){
		alert("Please enter valid Email");
		document.frm_user_add.user_email_address.focus();
		return false;
	}else if(document.frm_user_add.user_email_address.value.indexOf(".") == -1){
		alert("Please enter valid Email");
		document.frm_user_add.user_email_address.focus();
		return false;
	}else{
		var password=document.frm_user_add.user_password;
		
		if(password.value==""){
			alert("Please enter your password");
			password.focus();
			return false;
		}else if(password.value.length < 6){
			alert("Your password should contain minimum 6 characters");
			password.focus();
			return false;
		}
		
		var pass_string = password.value;		
		var valid="123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

		for (var i=0; i<pass_string.length; i++) {
        	if (valid.indexOf(pass_string.charAt(i)) < 0) {
            	alert('Your password contains invalid characters');
				password.focus();
            	return false;
        	}
    	}
		
		var alphaCount=0
 		var numCount=0

		var num_valid="123456789";
		
		for (var i=0; i<pass_string.length; i++) {
			if (num_valid.indexOf(pass_string.charAt(i)) < 0) {
			 numCount++;
			}
		}
		if(numCount==pass_string.length){
			alert('Your password contains only characters. Please enter an alphanumeric	value like -alpha1-');
			password.focus();
			return false;
		}
		
		var	alph_valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		
		for (var i=0; i<pass_string.length; i++) {
			if (alph_valid.indexOf(pass_string.charAt(i)) < 0) {
				alphaCount++;
			}
		}
		if(alphaCount==pass_string.length){
			alert('Your password contains only numbers. Please enter an alphanumeric value like -alpha1-');
			password.focus();
			return false;
		}

		document.frm_user_add.action="user_save.php?page="+page+"&limit="+limit;
		document.frm_user_add.submit();
	}
}

/***************************************************News Manager**************************************************/

function news_save(id,img,page,limit){
	if(document.frm_news_add.news_name.value==''){
		alert("Please enter News Name");
		document.frm_news_add.news_name.focus();
		return false;
	}
	
	
		document.frm_news_add.action="news_save.php?news_id="+id+"&img="+img+"&page="+page+"&limit="+limit;
		document.frm_news_add.submit();
	
}

function news_edit(id,page,limit){
	document.frm_news_mgmt.action="news_add.php?page="+page+"&limit="+limit+"&news_id="+id;
	document.frm_news_mgmt.submit();
}

function news_delete(id,page,limit){
	document.frm_news_mgmt.action="news_delete.php?page="+page+"&limit="+limit+"&news_id="+id;
	document.frm_news_mgmt.submit();
}

/******************************************** Page Manager **************************************/

function page_edit(page_id,page,limit)
{
	document.frm_page_mgmt.action="page_add.php?page_id="+page_id+"&page="+page+"&limit="+limit;
	document.frm_page_mgmt.submit();
}

function page_delete(page_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_page_mgmt.action="page_delete.php?page_id="+page_id+"&page="+page+"&limit="+limit;
		document.frm_page_mgmt.submit();	
	}
}

function page_save(page,limit,page_id,image)
{
	//var textarea = tinyMCE.get('page_desc').getContent(); 
	//alert(textarea);
	if(document.frm_page_add.page_name.value==''){
		alert("Please Enter Page Name");
		document.frm_page_add.page_name.focus();
		return false;
		//tinyMCE.getContent()
	}else if(document.frm_page_add.page_link.value==''){
		alert("Please Enter Page Link");
		document.frm_page_add.page_link.focus();
		return false;
	}else{
		document.frm_page_add.action="page_save.php?page="+page+"&limit="+limit;
		document.frm_page_add.submit();
	}
	
}
/*******************************************FAQ Category Manager ***********************************/

function cat_edit(faq_category_id,page,limit)
{
	document.frm_cat_mgmt.action="faq_cat_add.php?faq_category_id="+faq_category_id+"&page="+page+"&limit="+limit;
	document.frm_cat_mgmt.submit();
}

function cat_delete2(faq_category_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_cat_mgmt.action="faq_cat_delete.php?faq_category_id="+faq_category_id+"&page="+page+"&limit="+limit;
		document.frm_cat_mgmt.submit();	
	}
}

var int =/^\d+$/;
function cat_save(id1,page,limit)
{	
	if(document.frm_cat_add.category_name.value==''){
		alert("Please Enter FAQ Category Name")
		document.frm_cat_add.category_name.focus();
		return false;
	}else if(document.frm_cat_add.parent_id.value==""){
		alert("Please Select Parent Category")
		document.frm_cat_add.parent_id.focus();
		return false;
	}else if(document.frm_cat_add.display_order.value==""){
	alert("Please Enter Display Order")
	document.frm_cat_add.display_order.focus();
	return false;
	}else{
		if(!int.test(document.frm_cat_add.display_order.value)){
		alert("Please Enter Only Integer");
		document.frm_cat_add.display_order.focus();
		return false;
		}else{
	document.frm_cat_add.action="faq_cat_save.php?page="+page+"&limit="+limit+"&id="+id1;
	document.frm_cat_add.submit();
	}
	}
}

var int =/^\d+$/;
function cat_save1(page,limit)
{	
	if(document.frm_cat_add.category_name.value==''){
		alert("Please Enter FAQ Category Name")
		document.frm_cat_add.category_name.focus();
		return false;
	}else if(document.frm_cat_add.parent_id.value==""){
		alert("Please Select Parent Category")
		document.frm_cat_add.parent_id.focus();
		return false;
	}else if(document.frm_cat_add.display_order.value==""){
	alert("Please Enter Display Order")
	document.frm_cat_add.display_order.focus();
	return false;
	}else{
		if(!int.test(document.frm_cat_add.display_order.value)){
		alert("Please Enter Only Integer");
		document.frm_cat_add.display_order.focus();
		return false;
		}else{
	document.frm_cat_add.action="faq_cat_save.php?page="+page+"&limit="+limit;
	document.frm_cat_add.submit();
	}
	}
}
/*****************************FAQ Manager******************************/
var int =/^\d+$/;
function faq_save(page,limit)
{
	//var textarea = tinyMCE.get('page_desc').getContent(); 
	//alert(textarea);
	var value;
	var select_del = document.getElementsByTagName('select');
	for (var i=0; i<select_del.length; i++) {
		var input = select_del[ i ];
		if (input.name == 'cat_id') {
			value = input.value;
			//break;
			//alert(value);
		}
		if(value == ''){
			//alert("hi");
			//alert(value);
			alert("Please select atleast 1 category type");
			//document.frm_product_add.delivery_type[].focus();
			return false;
		}
		
	}
	if(document.frm_faq_add.faq_question.value==''){
		alert("Please Enter FAQ Question");
		document.frm_faq_add.faq_question.focus();
		return false;
	}else if(document.frm_faq_add.display_order.value==""){
	alert("Please Enter Display Order")
	document.frm_faq_add.display_order.focus();
	return false;
	}else{
		if(!int.test(document.frm_faq_add.display_order.value)){
		alert("Please Enter Only Integer");
		document.frm_faq_add.display_order.focus();
		return false;
		}else{
		document.frm_faq_add.action="faq_save.php?page="+page+"&limit="+limit;
		document.frm_faq_add.submit();
	}
	}
}

/*********************************Dealer Manager**************************/


function dealer_save(id,img,img1,page,limit){
	if(document.frm_dealer_add.dealer_name.value==''){
		alert("Please enter Dealer Name");
		document.frm_dealer_add.dealer_name.focus();
		return false;
	}else if(document.frm_dealer_add.dealer_address.value==""){
		alert("Please Enter Dealer Address");
		document.frm_dealer_add.dealer_address.focus();
		return false;
	/*}else if(document.frm_dealer_add.dealer_website.value==""){
		alert("Please Enter Website");
		document.frm_dealer_add.dealer_website.focus();
		return false;
	}else if(document.frm_dealer_add.dealer_email.value==""){
		alert("Please Enter Email Address");
		document.frm_dealer_add.dealer_email.focus();
		return false;
	}else if(document.frm_dealer_add.dealer_email.value.indexOf("@") == -1){
		alert("Please enter valid Email");
		document.frm_dealer_add.dealer_email.focus();
		return false;
	}else if(document.frm_dealer_add.dealer_email.value.indexOf(".") == -1){
		alert("Please enter valid Email");
		document.frm_dealer_add.dealer_email.focus();
		return false;
	}else if(document.frm_dealer_add.dealer_telephone.value==""){
		alert("Please Enter Telephone");
		document.frm_dealer_add.dealer_telephone.focus();
		return false;
	}else if(document.frm_dealer_add.display_order.value==""){
		alert("Please Enter Display Order");
		document.frm_dealer_add.display_order.focus();
		return false;*/
	}else{//alert(id);
		if(id == ''){
			if(document.frm_dealer_add.small_map.value == ''){
				alert("Please upload your small image");
				document.frm_dealer_add.small_map.focus();
				return false;
			}
			if(document.frm_dealer_add.big_map.value == ''){
				alert("Please upload your big image");
				document.frm_dealer_add.big_map.focus();
				return false;
			}
		}else{
			if(img == ''){
				if(document.frm_dealer_add.small_map.value == ''){
					alert("Please upload your small image");
					document.frm_dealer_add.small_map.focus();
					return false;
				}
			}
				if(img1 == ''){
				if(document.frm_dealer_add.big_map.value == ''){
					alert("Please upload your small image");
					document.frm_dealer_add.big_map.focus();
					return false;
				}
			}
		}
		
		if(document.frm_dealer_add.small_map.value != ''){
			
			var extensions = new Array("jpg","jpeg","gif","png","bmp","tif");   
  
			var image_file = document.frm_dealer_add.small_map.value;   
			  
			var image_length = document.frm_dealer_add.small_map.value.length;   
			  
			var pos = image_file.lastIndexOf('.') + 1;   
			  
			var ext = image_file.substring(pos, image_length);   
			  
			var final_ext = ext.toLowerCase();   
			  
			var flag = false;
			
			for (i = 0; i < extensions.length; i++)   
			{   
				if(extensions[i] == final_ext)   
				{   
					flag = true;   
				}   
			}   
			  
			if(flag == false){ 
				alert("Please upload category image with one of the following extensions: "+ extensions.join(', ') +".");   		
				document.frm_dealer_add.small_map.focus();
				return false;   
			}
		
		}	
		if(document.frm_dealer_add.big_map.value != ''){
			
			var extensions = new Array("jpg","jpeg","gif","png","bmp","tif");   
  
			var image_file = document.frm_dealer_add.big_map.value;   
			  
			var image_length = document.frm_dealer_add.big_map.value.length;   
			  
			var pos = image_file.lastIndexOf('.') + 1;   
			  
			var ext = image_file.substring(pos, image_length);   
			  
			var final_ext = ext.toLowerCase();   
			  
			var flag = false;
			
			for (i = 0; i < extensions.length; i++)   
			{   
				if(extensions[i] == final_ext)   
				{   
					flag = true;   
				}   
			}   
			  
			if(flag == false){ 
				alert("Please upload category image with one of the following extensions: "+ extensions.join(', ') +".");   		
				document.frm_dealer_add.big_map.focus();
				return false;   
			}
		
		}		
		
	}
		document.frm_dealer_add.action="dealer_save.php?dealer_id="+id+"&img="+img+"&img1="+img1+"&page="+page+"&limit="+limit;
		document.frm_dealer_add.submit();
	
}

function dealer_edit(dealer_id,page,limit){
	document.frm_dealer_mgmt.action="dealer_add.php?page="+page+"&limit="+limit+"&dealer_id="+dealer_id;
	document.frm_dealer_mgmt.submit();
}

function dealer_delete(dealer_id,page,limit){
	document.frm_dealer_mgmt.action="dealer_delete.php?page="+page+"&limit="+limit+"&dealer_id="+dealer_id;
	document.frm_dealer_mgmt.submit();
}

/*************************Front side************************/

function validate(){
mn = document.form
if(mn.name.value.length <1){
alert("Please specify your Name")
mn.name.focus()
return false
}
if(document.form.email.value==""){
   alert("Please enter E-mail address");
   document.form.email.focus();
   document.form.email.select();
   return false;
   }
   
   if(document.form.email.value!=""){
   var validstr,indexofat,indexofdot;
   validstr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-@."
   indexofat=document.form.email.value.indexOf("@");
   indexofdot=document.form.email.value.indexOf(".");
   for(i=0;i<document.form.email.value.length;i++)
    {
      if(validstr.indexOf(document.form.email.value.charAt(i)) == -1)
       {
	   alert("Please enter a valid E-mail.")
       document.form.email.focus();
	   document.form.email.select();
        return false;
		break;
       } 
    }
  if(indexofat<1 || document.form.email.value.length-2 < indexofdot || document.form.email.value.length<7){   
    alert("Please enter a valid E-mail.")
       document.form.email.focus();
	   document.form.email.select();
	return false;   
	}
	}
return true
}

function validate1(){
	mn = document.form
	if(mn.name.value.length <1){
		alert("Please specify your Name")
		mn.name.focus()
		return false
	}
	if(document.form.email.value==""){
	   alert("Please enter E-mail address");
	   document.form.email.focus();
	   document.form.email.select();
	   return false;
	}
	 if(document.form.phone_number.value==""){
	   alert("Please enter Phone Number");
	   document.form.phone_number.focus();
	   document.form.phone_number.select();
	   return false;
	}  
	if(document.form.email.value!=""){
	   var validstr,indexofat,indexofdot;
	   validstr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-@."
	   indexofat=document.form.email.value.indexOf("@");
	   indexofdot=document.form.email.value.indexOf(".");
	   for(i=0;i<document.form.email.value.length;i++)
	   {
		  if(validstr.indexOf(document.form.email.value.charAt(i)) == -1)
		  {
				alert("Please enter a valid E-mail.")
				document.form.email.focus();
				document.form.email.select();
				return false;
				break;
		   } 
		}
		if(indexofat<1 || document.form.email.value.length-2 < indexofdot || document.form.email.value.length<7){   
			alert("Please enter a valid E-mail.")
			document.form.email.focus();
			document.form.email.select();
			return false;   
		}
	}
	return true
}

function check()
{
	if (document.myform.Name.value.length==0)
		{
			alert("Please enter your Name");
			document.myform.Name.focus();
		}
			else if(document.myform.Email.value.length==0 || document.myform.Email.value.indexOf("@")==-1 || document.myform.Email.value.indexOf(".")==-1 || document.myform.Email.value.indexOf(" ")==0)
		{
			alert("You must enter a Valid Email ID")
			document.myform.Email.focus();
		}
	 	else if (document.myform.Subject[document.myform.Subject.selectedIndex].value.length==0)
			{
			alert("Please select a Subject");
			document.myform.Subject.focus();
		}
	else if(document.myform.Message.value==0)
		{
		alert("Message field cannot be left empty");
		document.myform.Message.focus();
		}

	else
		{
		document.myform.submit()
		}
}

/******************************************* Category Manager ***********************************/

function cat_edit(category_id,page,limit)
{
	document.frm_cat_mgmt.action="cat_add.php?category_id="+category_id+"&page="+page+"&limit="+limit;
	document.frm_cat_mgmt.submit();
}

function cat_delete(category_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_cat_mgmt.action="cat_delete.php?category_id="+category_id+"&page="+page+"&limit="+limit;
		document.frm_cat_mgmt.submit();	
	}
}

var float =/^(\+?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+-]?[0-9]+)?))$/;
function cat_save3(id1,img1,page,limit)
{	
	if(document.frm_cat_add.category_name.value==''){
		alert("Please Enter Category Name");
		document.frm_cat_add.category_name.focus();
		return false;
	}else if(document.frm_cat_add.parent_id.value==""){
		alert("Please Select Parent Category");
		document.frm_cat_add.parent_id.focus();
		return false;
	
	}else{//alert(id);
		if(id1 == ''){
			if(document.frm_cat_add.txt_image.value == ''){
				alert("Please upload category image");
				document.frm_cat_add.txt_image.focus();
				return false;
			}
		}else{
			if(img1 == ''){
				if(document.frm_cat_add.txt_image.value == ''){
					alert("Please upload category image");
					document.frm_cat_add.txt_image.focus();
					return false;
				}
			}
		}
		if(document.frm_cat_add.txt_image.value != ''){
			
			var extensions = new Array("jpg","jpeg","gif","png","bmp","tif");   
  
			var image_file = document.frm_cat_add.txt_image.value;   
			  
			var image_length = document.frm_cat_add.txt_image.value.length;   
			  
			var pos = image_file.lastIndexOf('.') + 1;   
			  
			var ext = image_file.substring(pos, image_length);   
			  
			var final_ext = ext.toLowerCase();   
			  
			var flag = false;
			
			for (i = 0; i < extensions.length; i++)   
			{   
				if(extensions[i] == final_ext)   
				{   
					flag = true;   
				}   
			} 
			if(flag == false){ 
				alert("Please upload category image with one of the following extensions: "+ extensions.join(', ') +".");   		
				document.frm_cat_add.txt_image.focus();
				return false;   
			}
		}
	}
	if(document.frm_cat_add.display_order.value==""){
		alert("Please enter Display Order");
		document.frm_cat_add.display_order.focus();
		return false;
	}
	document.frm_cat_add.action="category_save.php?page="+page+"&limit="+limit+"&image="+img1+"&id="+id1;
	document.frm_cat_add.submit();
}

var float =/^(\+?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+-]?[0-9]+)?))$/;
function cat_save4(page,limit)
{
	if(document.frm_cat_add.category_name.value==''){
		alert("Please Enter Category Name");
		document.frm_cat_add.category_name.focus();
		return false;
	}else if(document.frm_cat_add.parent_id.value==''){
		alert("Please Select Parent Category")
		document.frm_cat_add.parent_id.focus();
		return false;
	}else if(document.frm_cat_add.txt_image.value == ''){
		alert("Please upload category image");
		document.frm_cat_add.txt_image.focus();
		return false;
	}else{//alert(id);
		if(document.frm_cat_add.txt_image.value != ''){
			
			var extensions = new Array("jpg","jpeg","gif","png","bmp","tif"); 
			var image_file = document.frm_cat_add.txt_image.value;
			var image_length = document.frm_cat_add.txt_image.value.length;
			var pos = image_file.lastIndexOf('.') + 1;
			var ext = image_file.substring(pos, image_length);
			var final_ext = ext.toLowerCase();
			var flag = false;
			for (i = 0; i < extensions.length; i++)   
			{   
				if(extensions[i] == final_ext)   
				{   
					flag = true;   
				}   
			}
			if(flag == false){ 
				alert("Please upload category image with one of the following extensions: "+ extensions.join(', ') +".");   		
				document.frm_cat_add.txt_image.focus();
				return false;   
			}
		}
		if(document.frm_cat_add.display_order.value==""){
			alert("Please enter Display Order");
			document.frm_cat_add.display_order.focus();
			return false;
		}
		document.frm_cat_add.action="category_save.php?page="+page+"&limit="+limit;
		document.frm_cat_add.submit();
	}
}

/***********************************Brand Manager**********************************/
function brand_edit(brand_id,page,limit)
{
	document.frm_brand_mgmt.action="brand_add.php?brand_id="+brand_id+"&page="+page+"&limit="+limit;
	document.frm_brand_mgmt.submit();
}

function brand_delete(brand_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_brand_mgmt.action="brand_delete.php?brand_id="+brand_id+"&page="+page+"&limit="+limit;
		document.frm_brand_mgmt.submit();	
	}
}

var float =/^(\+?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+-]?[0-9]+)?))$/;
function brand_save(id1,img1,page,limit)
{	
	if(document.frm_brand_add.brand_name.value==''){
		alert("Please Enter Brand Name");
		document.frm_brand_add.brand_name.focus();
		return false;
	}
	if(document.frm_brand_add.display_order.value==""){
		alert("Please enter Display Order");
		document.frm_brand_add.display_order.focus();
		return false;
	}
	document.frm_brand_add.action="brand_save.php?page="+page+"&limit="+limit;
	document.frm_brand_add.submit();
}

/****************************Car Manager***************************************/

function model_save(id1,page,limit)
{	
	if(document.frm_model_add.brand_id.value==0){
		alert("Please select any Brand");
		document.frm_model_add.brand_id.focus();
		return false;
	}else if(document.frm_model_add.model_name.value==''){
		alert("Please Enter Model Name");
		document.frm_model_add.model_name.focus();
		return false;
	}else if(document.frm_model_add.display_order.value==""){
		alert("Please enter Display Order");
		document.frm_model_add.display_order.focus();
		return false;
	}else{
		
	document.frm_model_add.action="model_save.php?page="+page+"&limit="+limit+"&id="+id1;
	document.frm_model_add.submit();
	
	}
}

function model_edit(model_id,page,limit)
{
	document.frm_model_mgmt.action="model_add.php?model_id="+model_id+"&page="+page+"&limit="+limit;
	document.frm_model_mgmt.submit();
}

function model_delete(model_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_model_mgmt.action="model_delete.php?model_id="+model_id+"&page="+page+"&limit="+limit;
		document.frm_model_mgmt.submit();	
	}
}

/****************************car Manager***************************************/

function car_save(id1,page,limit)
{	
	
	document.frm_car_add.action="car_save.php?page="+page+"&limit="+limit;
	document.frm_car_add.submit();
}

function car_edit(car_id,page,limit)
{
	document.frm_car_mgmt.action="car_add.php?car_id="+car_id+"&page="+page+"&limit="+limit;
	document.frm_car_mgmt.submit();
}

function car_delete(car_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_car_mgmt.action="car_delete.php?car_id="+car_id+"&page="+page+"&limit="+limit;
		document.frm_car_mgmt.submit();	
	}
}
/****************************Tier Manager***************************************/

function tire_save(id1,page,limit)
{	
	
	document.frm_tire_add.action="tire_save.php?page="+page+"&limit="+limit;
	document.frm_tire_add.submit();
}

function tire_edit(tire_id,page,limit)
{
	document.frm_tire_mgmt.action="tire_add.php?tire_id="+tire_id+"&page="+page+"&limit="+limit;
	document.frm_tire_mgmt.submit();
}

function tire_delete(tire_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_tire_mgmt.action="tire_delete.php?tire_id="+tire_id+"&page="+page+"&limit="+limit;
		document.frm_tire_mgmt.submit();	
	}
}
/******************************Country Manager*********************************/

function country_save(page,limit)
{	
	if(document.frm_country_add.country_name.value==''){
		alert("Please enter Country Name");
		document.frm_country_add.country_name.focus();
		return false;
	}else if(document.frm_country_add.exchange_rate.value==''){
		alert("Please enter Exchange Rate Vs USD");
		document.frm_country_add.exchange_rate.focus();
		return false;
	}else if(document.frm_country_add.currency_type.value==''){
		alert("Please enter Currency Type");
		document.frm_country_add.currency_type.focus();
		return false;
	}else{
	document.frm_country_add.action="country_save.php?page="+page+"&limit="+limit;
	document.frm_country_add.submit();
	}
}

function country_edit(country_id,page,limit)
{
	document.frm_country_mgmt.action="country_add.php?country_id="+country_id+"&page="+page+"&limit="+limit;
	document.frm_country_mgmt.submit();
}

function country_delete(country_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_country_mgmt.action="country_delete.php?country_id="+country_id+"&page="+page+"&limit="+limit;
		document.frm_country_mgmt.submit();	
	}
}

/************************Product manager**************************************/
function Inint_AJAX() {
   try { return new ActiveXObject("Msxml2.XMLHTTP");  } catch(e) {} //IE
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE
   try { return new XMLHttpRequest(); } catch(e) {} //Native Javascript
   alert("XMLHttpRequest not supported");
   return null;
};

function getPrice(val){
	 //alert(val);
	 var len = document.getElementById("item_id").length; 
	//alert(len);
	var attribute_value = new Array();
	for(i=0; i<len; i++)
	{ 
		if(document.frm_product_add.item_id[i].selected)
		{		
			attribute_value[i]=document.frm_product_add.item_id[i].value;
			//alert(attribute_value[i]);
		}
	}
	 var req = Inint_AJAX();
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
			   		document.getElementById("div_Price").innerHTML=req.responseText; //retuen value
               } 
          }
     };
	 //alert("get_price.php?item_id="+val+"&arr="+attribute_value);
	 req.open("GET", "get_price.php?item_id="+val+"&arr="+attribute_value); //make connection
	 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header
     req.send(null); //send value
};

function GetXmlHttpObject() 
{ 
  	var xmlhttp; 
  	if(window.XMLHttpRequest)
  	{ 
    	xmlhttp = new XMLHttpRequest(); 
  	} 
  	else if (window.ActiveXObject)
  	{ 
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		if (!xmlhttp)
		{ 
			xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
		}
	} 
  	return xmlhttp; 
} 

function getCat(val){
	//alert(val);
	 var req = Inint_AJAX();
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
			   		document.getElementById("divCat").innerHTML=req.responseText; //retuen value
               } 
          }
     };
	 req.open("GET", "get_model.php?brand_id="+val); //make connection
	 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header
     req.send(null); //send value
};


function getUser_Model(val,user){
	
	 var req = Inint_AJAX();
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {				   
			   		document.getElementById("divModel2").innerHTML=req.responseText; //retuen value
               } 
          }
     };
	 req.open("GET", "/get_model_user.php?brand_id="+val+"&user_name="+user); //make connection
	 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header
     req.send(null); //send value
};

function product_edit(product_id,page,limit)
{
	document.frm_product_mgmt.action="product_add.php?product_id="+product_id+"&page="+page+"&limit="+limit;
	document.frm_product_mgmt.submit();
}

function product_delete(product_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_product_mgmt.action="product_delete.php?product_id="+product_id+"&page="+page+"&limit="+limit;
		document.frm_product_mgmt.submit();	
	}
}

function product_save()
{	//alert(color_id);
	
	if(document.frm_product_add.item_name.value == '')
	{
		alert("Please Enter Item Name");
		document.frm_product_add.item_name.focus();
		return false;
	}
	if(document.frm_product_add.item_price.value == '')
	{
		alert("Please Enter Item Price");
		document.frm_product_add.item_price.focus();
		return false;
	}
	if(document.frm_product_add.car_id.value ==0)
	{
		alert("Please Enter Brand Type");
		document.frm_product_add.car_id.focus();
		return false;
	}
	if(document.frm_product_add.model_id.value ==0)
	{
		alert("Please Select Model Name");
		document.frm_product_add.model_id.focus();
		return false;
	}
	
	if(document.frm_product_add.model_year_id.value ==0)
	{
		alert("Please Select Model Year");
		document.frm_product_add.model_year_id.focus();
		return false;
	}
	if(document.frm_product_add.shipping_profile.value ==0)
	{
		alert("Please Select Shipping Profile");
		document.frm_product_add.shipping_profile.focus();
		return false;
	}
	if(document.frm_product_add.manufacturer_id.value ==0)
	{
		alert("Please Select Manufacturer");
		document.frm_product_add.manufacturer_id.focus();
		return false;
	}
	if(document.frm_product_add.product_photo.value != '')
		{
			var extensions = new Array("jpg","jpeg","gif","png","bmp","tif");
			var image_file = document.frm_product_add.product_photo.value; 
			var image_length = document.frm_product_add.product_photo.value.length; 
			var pos = image_file.lastIndexOf('.') + 1;   
			var ext = image_file.substring(pos, image_length); 
			var final_ext = ext.toLowerCase();  
			var flag = false;
			for (i = 0; i < extensions.length; i++)   
			{   
				if(extensions[i] == final_ext)   
				{   
					flag = true;   
				}   
			}  
			if(flag == false){
				alert("Please upload product image with one of the following extensions: "+ extensions.join(', ') +".");
				document.frm_product_add.product_photo.focus();
				return false;   
			}
		}
		
		document.frm_product_add.action="product_save.php";
		document.frm_product_add.submit();
}

/****************************Manufacturer Manager**************************************/

function manufacturer_save(manufacturer_id,page,limit)
{	
	if(document.frm_manufacturer_add.category_id.value==0){
		alert("Select Product Type");
		document.frm_manufacturer_add.category_id.focus();
		return false;
	}else if(document.frm_manufacturer_add.manufacturer_name.value==''){
		alert("Please Enter Manufacturer Name");
		document.frm_manufacturer_add.manufacturer_name.focus();
		return false;
	}else if(document.frm_manufacturer_add.display_order.value==""){
		alert("Please enter Display Order");
		document.frm_manufacturer_add.display_order.focus();
		return false;
	}else{
	document.frm_manufacturer_add.action="manufacturer_save.php?page="+page+"&limit="+limit+"&manufacturer_id="+manufacturer_id;
	document.frm_manufacturer_add.submit();
	}
}

function manufacturer_edit(manufacturer_id,page,limit)
{
	document.frm_manufacturer_mgmt.action="manufacturer_add.php?manufacturer_id="+manufacturer_id+"&page="+page+"&limit="+limit;
	document.frm_manufacturer_mgmt.submit();
}

function manufacturer_delete(manufacturer_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_manufacturer_mgmt.action="manufacturer_delete.php?manufacturer_id="+manufacturer_id+"&page="+page+"&limit="+limit;
		document.frm_manufacturer_mgmt.submit();	
	}
}

/****************Product category manager (Front side)**************************************/

function getProdCat(val){
	 var req = Inint_AJAX();
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
			   		document.getElementById("divCat").innerHTML=req.responseText; //retuen value
               } 
          }
     };
	 req.open("GET", "get_cat.php?cat_id="+val); //make connection
	 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header
     req.send(null); //send value
};

function getBrand(val){
	 var req = Inint_AJAX();
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
			   		document.getElementById("brand").innerHTML=req.responseText; //retuen value
               } 
          }
     };
	 req.open("GET", "get_brand.php?man_id="+val); //make connection
	 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header
     req.send(null); //send value
};
function getCar(val){
	//alert(val);
    /* if(document.frm_pro_category.category_id.value==''){
		alert("Select any Category");
		document.frm_pro_category.category_id.focus();
		return false;
	}else if(document.frm_pro_category.manu_id.value==''){
		alert("Select any Manufacturer");
		document.frm_pro_category.manu_id.focus();
		return false;
	}else if(document.frm_pro_category.model_id.value==''){
		alert("Please Enter Manufacturer Name");
		document.frm_pro_category.manufacturer_name.focus();
		return false;
	}else if(document.frm_pro_category.display_order.value==""){
		alert("Please enter Display Order");
		document.frm_pro_category.display_order.focus();
		return false;
	}else{*/
	 document.getElementById("brand").style.display = "none";
	 var req = Inint_AJAX();
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
			   		document.getElementById("car").innerHTML=req.responseText; //retuen value
               } 
          }
     };
	 req.open("GET", "get_car.php?car_id="+val); //make connection
	 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header
     req.send(null); //send value
	//}
};
function getManu(val){
	//alert(val);
	 //document.getElementById("menu").style.display = "none";
	 var req = Inint_AJAX();
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
			   		document.getElementById("manu").innerHTML=req.responseText; //retuen value
               } 
          }
     };
	 req.open("GET", "get_manufacturer.php?manu_id="+val); //make connection
	 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header
     req.send(null); //send value
};

function getModel(val){

	 var req = Inint_AJAX();
		req.onreadystatechange = function () { 		
          if (req.readyState==4) {
               if (req.status==200) {
				   document.getElementById("divModel_Update").innerHTML=req.responseText; //retuen value			   		
               } 
          }
     };
	 req.open("GET", "/get_model.php?make_id="+val); //make connection
	 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header
     req.send(null); //send value
};

function getModelIndex(val){
	
	 var req = Inint_AJAX();
		req.onreadystatechange = function () { 		
          if (req.readyState==4) {
               if (req.status==200) {
				   document.getElementById("divModel").innerHTML=req.responseText; //retuen value			   		
               } 
          }
     };
	 req.open("GET", "/get_model_index.php?make_id="+val); //make connection
	 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header
     req.send(null); //send value
};

function getModel_Insert(val){
	 var req = Inint_AJAX();
		req.onreadystatechange = function () { 		
          if (req.readyState==4) {
               if (req.status==200) {
				  if(val == "brand")
					{
						document.getElementById("brand_td").style.display='block';
					}			   		
					document.getElementById("divModel").innerHTML=req.responseText; //retuen value					
               } 
          }
     };
	 req.open("GET", "/get_model_insert.php?make_id="+val); //make connection
	 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header
     req.send(null); //send value
};


/******************************City Manager*********************************/

function city_save(id,page,limit)
{	
	if(document.frm_city_add.city_name.value==''){
		alert("Please enter City Name");
		document.frm_city_add.city_name.focus();
		return false;
	}else{
	document.frm_city_add.action="city_save.php?page="+page+"&limit="+limit+"&country_id="+id;
	document.frm_city_add.submit();
	}
}

function city_edit(id,city_id,page,limit)
{
	document.frm_city_mgmt.action="city_add.php?city_id="+city_id+"&page="+page+"&limit="+limit+"&country_id="+id;
	document.frm_city_mgmt.submit();
}

function city_delete(id,city_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_city_mgmt.action="city_delete.php?city_id="+city_id+"&page="+page+"&limit="+limit+"&country_id="+id;
		document.frm_city_mgmt.submit();	
	}
}

/********************Get cities from country for Dealer********************************/
function getHTTPObject() 
{ 
	var xmlhttp; 
	if(window.XMLHttpRequest)
	{ 
		xmlhttp = new XMLHttpRequest(); 
	} 
	else if (window.ActiveXObject)
	{ 
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		if (!xmlhttp)
		{ 
			xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
		}
	} 
	return xmlhttp; 
} 

function get_City(country_id)
{ 	 
	//alert(country_id);
	var len = document.getElementById("country_id").length; 
	//alert(len);
	var attribute_value = new Array();
	for(i=0; i<len; i++)
	{ 
		if(document.frm_dealer_add.country_id[i].selected)
		{		
			attribute_value[i]=document.frm_dealer_add.country_id[i].value;
			//alert(attribute_value[i]);
		}
	}
	var req = getHTTPObject();
	req.onreadystatechange = function () { 
	       if (req.readyState==4) {
	          if (req.status==200) {
	             document.getElementById("div_Country_City").innerHTML=req.responseText; //retuen value
				} 
           }
        };
	 req.open("GET", "getcity.php?country_id="+country_id+"&arr="+attribute_value); //make connection
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header
     req.send(null); //send value	 
}

function callCity(val){
	var req = Inint_AJAX();
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
			   		document.getElementById("divCityCall").innerHTML=req.responseText; //retuen value
               } 
          }
     };
	 req.open("GET", "get_city.php?country_id="+val); //make connection
	 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header
     req.send(null); //send value
};

/******************************Customs Costs Manager*********************************/

function customs_costs_save(page,limit)
{	
	if(document.frm_customs_costs_add.customs_profile_name.value==''){
		alert("Please enter Customs Costing Profile Name");
		document.frm_customs_costs_add.customs_profile_name.focus();
		return false;
	}else{
	document.frm_customs_costs_add.action="customs_costs_save.php?page="+page+"&limit="+limit;
	document.frm_customs_costs_add.submit();
	}
}

function customs_costs_edit(customs_costs_id,page,limit)
{
	document.frm_customs_costs_mgmt.action="customs_costs_add.php?customs_costs_id="+customs_costs_id+"&page="+page+"&limit="+limit;
	document.frm_customs_costs_mgmt.submit();
}

function customs_costs_delete(customs_costs_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{

		document.frm_customs_costs_mgmt.action="customs_costs_delete.php?customs_costs_id="+customs_costs_id+"&page="+page+"&limit="+limit;
		document.frm_customs_costs_mgmt.submit();	
	}
}

/******************************Shipping Costs Manager*********************************/

function shipping_costs_save(page,limit)
{	
	if(document.frm_shipping_costs_add.shipping_profile_name.value==''){
		alert("Please enter Shipping Costing Profile Name");
		document.frm_shipping_costs_add.shipping_profile_name.focus();
		return false;
	}else{
	document.frm_shipping_costs_add.action="shipping_costs_save.php?page="+page+"&limit="+limit;
	document.frm_shipping_costs_add.submit();
	}
}

function shipping_costs_edit(shipping_costs_id,page,limit)
{
	document.frm_shipping_costs_mgmt.action="shipping_costs_add.php?shipping_costs_id="+shipping_costs_id+"&page="+page+"&limit="+limit;
	document.frm_shipping_costs_mgmt.submit();
}

function shipping_costs_delete(shipping_costs_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_shipping_costs_mgmt.action="shipping_costs_delete.php?shipping_costs_id="+shipping_costs_id+"&page="+page+"&limit="+limit;
		document.frm_shipping_costs_mgmt.submit();	
	}
}

/******************************Extra Costs Manager*********************************/

function extra_costs_save(page,limit)
{	
	if(document.frm_extra_costs_add.extra_profile_name.value==''){
		alert("Please enter Extra Costs Profile Name");
		document.frm_extra_costs_add.extra_profile_name.focus();
		return false;
	}else if(document.frm_extra_costs_add.extra_costs_amount.value==''){
		alert("Please enter Extra Costs Amount");
		document.frm_extra_costs_add.extra_costs_amount.focus();
		return false;
	}else{
	document.frm_extra_costs_add.action="extra_costs_save.php?page="+page+"&limit="+limit;
	document.frm_extra_costs_add.submit();
	}
}

function extra_costs_edit(extra_costs_id,page,limit)
{
	document.frm_extra_costs_mgmt.action="extra_costs_add.php?extra_costs_id="+extra_costs_id+"&page="+page+"&limit="+limit;
	document.frm_extra_costs_mgmt.submit();
}

function extra_costs_delete(extra_costs_id,page,limit)
{
	var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_extra_costs_mgmt.action="extra_costs_delete.php?extra_costs_id="+extra_costs_id+"&page="+page+"&limit="+limit;
		document.frm_extra_costs_mgmt.submit();	
	}
}

/******************************Discounts Manager*********************************/

function discounts_save(page,limit)
{	
	if(document.frm_discounts_add.discount_profile_name.value==''){
		alert("Please enter Discount Profile Name");
		document.frm_discounts_add.discount_profile_name.focus();
		return false;
	}else if(document.frm_discounts_add.discount_amount.value==''){
		alert("Please enter Discount Amount");
		document.frm_discounts_add.discount_amount.focus();
		return false;
	}else if(document.frm_discounts_add.product_shipping_discount.value==0){
		alert("Please select discount you want to apply");
		document.frm_discounts_add.product_shipping_discount.focus();
		return false;
	}else if(document.frm_discounts_add.country_discount.value==0){
		alert("Please select Country");
		document.frm_discounts_add.country_discount.focus();
		return false;
	}else if(document.frm_discounts_add.dealer_discount.value==0){
		alert("Please select Dealer");
		document.frm_discounts_add.dealer_discount.focus();
		return false;
	}else{
	document.frm_discounts_add.action="discounts_save.php?page="+page+"&limit="+limit;
	document.frm_discounts_add.submit();
	}
}

function discounts_edit(discount_id,page,limit)
{
	document.frm_discounts_mgmt.action="discounts_add.php?discount_id="+discount_id+"&page="+page+"&limit="+limit;
	document.frm_discounts_mgmt.submit();
}

function discounts_delete(discount_id,page,limit)
{
var ans=confirm("Are you sure want to delete?");
	if(ans==true)
	{
		document.frm_discounts_mgmt.action="discounts_delete.php?discount_id="+discount_id+"&page="+page+"&limit="+limit;
		document.frm_discounts_mgmt.submit();	
	}
}

/*************************Package Price Calculation**************************/

function netPrice(val){
	 //alert(val);
	 var req = Inint_AJAX();
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
			   		document.getElementById("div_Final_Price").innerHTML=req.responseText; //retuen value
               } 
          }
     };
	 //alert("get_price.php?item_id="+val+"&arr="+attribute_value);
	 req.open("GET", "final_price.php?radio_id="+val); //make connection
	 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header
     req.send(null); //send value
};

/********************Product Validation(Front Side)*****************************/

function validate_product()
{
	if(document.frm_pro_category.category_id.value==''){
		alert("Please select Category");
		document.frm_pro_category.category_id.focus();
		return false;
	}else if(document.frm_pro_category.manu_id.value==''){
		alert("Please select Manufacturer");
		document.frm_pro_category.manu_id.focus();
		return false;
	}else if(document.frm_pro_category.model_type.value==''){
		alert("Please select Car Model");
		document.frm_pro_category.model_type.focus();
		return false;
	}else if(document.frm_pro_category.model_year_id.value==''){
		alert("Please select Car Model Year");
		document.frm_pro_category.model_year_id.focus();
		return false;
	}else if(document.frm_pro_category.country_id.value==''){
		alert("Please select Country");
		document.frm_pro_category.country_id.focus();
		return false;
	}else if(document.frm_pro_category.city_id.value==''){
		alert("Please select City");
		document.frm_pro_category.city_id.focus();
		return false;
	}else{
	document.frm_pro_category.action="product_search_result.php";
	document.frm_pro_category.submit();
	}
}

/************************Get Dealer in Product Search(Front Side)*******************/

function getDealer(val,divid){
	 //alert(val);
	 var req = Inint_AJAX();
		req.onreadystatechange = function () { 
          if (req.readyState==4) {
               if (req.status==200) {
			   		document.getElementById("Dealer_From_city"+divid).innerHTML=req.responseText; //retuen value
               } 
          }
     };
	 req.open("GET", "get_dealer.php?city_id="+val); //make connection
	 
	 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1"); // set Header
     req.send(null); //send value
	//}
};

/************************************Quotation Save************************************/

function quote_save()
{
	
	if(document.frm_quote.first_name.value==''){
		alert("Please enter First Name");
		document.frm_quote.first_name.focus();
		return false;
	}else if(document.frm_quote.last_name.value==''){
		alert("Please enter Last Name");
		document.frm_quote.last_name.focus();
		return false;
	}else if(document.frm_quote.email.value==''){
		alert("Please enter Email Address");
		document.frm_quote.email.focus();
		return false;
	}else if(document.frm_quote.email.value.indexOf("@") == -1){
		alert("Please enter valid Email");
		document.frm_quote.email.focus();
		return false;
	}else if(document.frm_quote.email.value.indexOf(".") == -1){
		alert("Please enter valid Email");
		document.frm_quote.email.focus();
		return false;
	}else if(document.frm_quote.address1.value==''){
		alert("Please enter Address");
		document.frm_quote.address1.focus();
		return false;
	}else if(document.frm_quote.address2.value==''){
		alert("Please enter alternative Address");
		document.frm_quote.address2.focus();
		return false;
	}else if(document.frm_quote.city.value==''){
		alert("Please enter City");
		document.frm_quote.city.focus();
		return false;
	}else if(document.frm_quote.country.value==''){
		alert("Please enter Country");
		document.frm_quote.country.focus();
		return false;
	}else if(document.frm_quote.zipcode.value==''){
		alert("Please enter ZipCode");
		document.frm_quote.zipcode.focus();
		return false;
	}else if(document.frm_quote.phone_number.value==''){
		alert("Please enter Phone Number");
		document.frm_quote.phone_number.focus();
		return false;
	}else if(document.frm_quote.mobile_number.value==''){
		alert("Please enter Mobile Number");
		document.frm_quote.mobile_number.focus();
		return false;
	}else{
	document.frm_quote.action="quotation_save.php";
	document.frm_quote.submit();
	}
}


function emailcheck(){
if(document.frm_car_add.email.value==""){
   alert("Please enter E-mail address");
   document.frm_car_add.email.focus();
   document.frm_car_add.email.select();
   return false;
   }
   
   
   if(document.frm_car_add.email.value!=""){
   var validstr,indexofat,indexofdot;
   validstr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-@."
   indexofat=document.frm_car_add.email.value.indexOf("@");
   indexofdot=document.frm_car_add.email.value.indexOf(".");
   for(i=0;i<document.frm_car_add.email.value.length;i++)
    {
      if(validstr.indexOf(document.frm_car_add.email.value.charAt(i)) == -1)
       {
	   alert("Please enter a valid E-mail.")
       document.frm_car_add.email.focus();
	   document.frm_car_add.email.select();
        return false;
		break;
       } 
    }
  if(indexofat<1 || document.frm_car_add.email.value.length-2 < indexofdot || document.frm_car_add.email.value.length<7){   
    alert("Please enter a valid E-mail.")
       document.frm_car_add.email.focus();
	   document.frm_car_add.email.select();
	return false;   
	}
	}



if(document.frm_car_add.brand_id.value=="0"){
   alert("Please choose brand");
   document.frm_car_add.brand_id.focus();
  
   return false;
   }
   if(document.frm_car_add.model_id.value=="0"){
   alert("Please choose model");
   document.frm_car_add.model_id.focus();
  
   return false;
   }
   
   if(document.frm_car_add.width1.value==""){
   alert("Please enter Width(mm)");
   document.frm_car_add.width1.focus();
    document.frm_car_add.width1.select();
   return false;
   }
   
    if(document.frm_car_add.wheel_diameter.value==""){
   alert("Please enter Diameter(inch)");
   document.frm_car_add.wheel_diameter.focus();
    document.frm_car_add.wheel_diameter.select();
   return false;
   }
   
    if(document.frm_car_add.serie.value==""){
   alert("Please enter Serie");
   document.frm_car_add.serie.focus();
    document.frm_car_add.serie.select();
   return false;
   }
   
  
    if(document.frm_car_add.wheel_width.value==""){
   alert("Please enter Width(J)");
   document.frm_car_add.wheel_width.focus();
    document.frm_car_add.wheel_width.select();
   return false;
   }
   
   if(document.frm_car_add.diameter.value==""){
   alert("Please enter Diameter");
   document.frm_car_add.diameter.focus();
    document.frm_car_add.diameter.select();
   return false;
   }
   
   if(document.frm_car_add.pcd.value==""){
   alert("Please enter PCD");
   document.frm_car_add.pcd.focus();
    document.frm_car_add.pcd.select();
   return false;
   }
   
    if(document.frm_car_add.et.value==""){
   alert("Please enter ET");
   document.frm_car_add.et.focus();
    document.frm_car_add.et.select();
   return false;
   }
   
    if(document.frm_car_add.tolerances_width_1.value==""){
   alert("Please enter Width tire");
   document.frm_car_add.tolerances_width_1.focus();
    document.frm_car_add.tolerances_width_1.select();
   return false;
   }
   
    if(document.frm_car_add.tolerances_width_2.value==""){
   alert("Please enter Width tire");
   document.frm_car_add.tolerances_width_2.focus();
    document.frm_car_add.tolerances_width_2.select();
   return false;
   }
   
     if(document.frm_car_add.circumference_1.value==""){
   alert("Please enter Circumference");
   document.frm_car_add.circumference_1.focus();
    document.frm_car_add.circumference_1.select();
   return false;
   }
     if(document.frm_car_add.circumference_2.value==""){
   alert("Please enter Circumference");
   document.frm_car_add.circumference_2.focus();
    document.frm_car_add.circumference_2.select();
   return false;
   }
return true
}



function emailcheck_u(){
if(document.frm_car_add1.email_u.value==""){
   alert("Please enter E-mail address");
   document.frm_car_add1.email_u.focus();
   document.frm_car_add1.email_u.select();
   return false;
   }
   
   if(document.frm_car_add1.email_u.value!=""){
   var validstr,indexofat,indexofdot;
   validstr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-@."
   indexofat=document.frm_car_add1.email_u.value.indexOf("@");
   indexofdot=document.frm_car_add1.email_u.value.indexOf(".");
   for(i=0;i<document.frm_car_add1.email_u.value.length;i++)
    {
      if(validstr.indexOf(document.frm_car_add1.email_u.value.charAt(i)) == -1)
       {
	   alert("Please enter a valid E-mail.")
       document.frm_car_add1.email_u.focus();
	   document.frm_car_add1.email_u.select();
        return false;
		break;
       } 
    }
  if(indexofat<1 || document.frm_car_add1.email_u.value.length-2 < indexofdot || document.frm_car_add1.email_u.value.length<7){   
    alert("Please enter a valid E-mail.")
       document.frm_car_add1.email_u.focus();
	   document.frm_car_add1.email_u.select();
	return false;   
	}
	}
	if(document.frm_car_add1.brand_id_u.value=="0"){
   alert("Please choose the brand");
   document.frm_car_add1.brand_id_u.focus();
   //document.frm_car_add1.brand_id_u.select();
   return false;
   }
	
	if(document.frm_car_add1.model_id_u.value=="0"){
   alert("Please choose the model");
   document.frm_car_add1.model_id_u.focus();
   //document.frm_car_add1.model_id_u.select();
   return false;
   }
    /* if(document.frm_car_add1.et_u.value==""){
   alert("Please enter the ET");
   document.frm_car_add1.et_u.focus();
   document.frm_car_add1.et_u.select();
   return false;
   }
      if(document.frm_car_add1.pcd_u.value==""){
   alert("Please enter the PCD");
   document.frm_car_add1.pcd_u.focus();
   document.frm_car_add1.pcd_u.select();
   return false;
   }
     if(document.frm_car_add1.diameter_u.value==""){
   alert("Please enter the Diameter");
   document.frm_car_add1.diameter_u.focus();
   document.frm_car_add1.diameter_u.select();
   return false;
   }
   
      if(document.frm_car_add1.wheel_width_u.value==""){
   alert("Please enter the Width(J)");
   document.frm_car_add1.wheel_width_u.focus();
   document.frm_car_add1.wheel_width_u.select();
   return false;
   }
   
     if(document.frm_car_add1.serie_u.value==""){
   alert("Please enter the Serie");
   document.frm_car_add1.serie_u.focus();
   document.frm_car_add1.serie_u.select();
   return false;
   }
     if(document.frm_car_add1.wheel_diameter_u.value==""){
   alert("Please enter the Diameter");
   document.frm_car_add1.wheel_diameter_u.focus();
   document.frm_car_add1.wheel_diameter_u.select();
   return false;
   }
   
    if(document.frm_car_add1.width2.value==""){
   alert("Please enter the width(mm)");
   document.frm_car_add1.width2.focus();
   document.frm_car_add1.width2.select();
   return false;
   }*/
 
  
  
  
  
return true
}


