

if (!Array.prototype.filter){

	Array.prototype.filter = function(fun /*, thisp*/){

		var len = this.length;

		if (typeof fun != "function") throw new TypeError();



		var res = new Array();

		var thisp = arguments[1];

		for (var i = 0; i < len; i++){

			if (i in this){

				var val = this[i]; // in case fun mutates this

				if (fun.call(thisp, val, i, this)) res.push(val);

			}

		}



		return res;

	};

}



if (!Array.prototype.forEach){

	Array.prototype.forEach = function(fun /*, thisp*/){

		var len = this.length;

		if (typeof fun != "function") throw new TypeError();



		var thisp = arguments[1];

		for (var i = 0; i < len; i++){

			if (i in this) fun.call(thisp, this[i], i, this);

		}

	};

}









var Loader = {

	ContainerForm: false,

	Container:  false,

	ContainerDisplay: false,

	Action: true,

	GetParams: false,

	ContainerID: false,

	CurrentPage: false,

	Id:false,

	SelectedOption: false,

	Do: "process.php?",

	SubmitType: false,

	ObjOption: false,

	

	GetSelectedOption: function(id,name){		 

		var idcountry = document.getElementById(id).value;

		

		var obj = document.getElementById(name);	    

		obj.length = 0;

		Loader.ObjOption = obj;

		

		if (idcountry != ""){

			Params = Loader.Do + "type=forjson" + "&id=" + idcountry + "&name=freight";	

			 new Ajax.Request(Params,{method:'post',onComplete: Loader.GetSelectedOptionResponses});		 

		}

		

	},

	GetSelectedOptionResponses: function(oReq)

	{   

	  var obj = document.getElementById('freightid');	

	  obj.length = 0;

	  var result = oReq.responseText;

	   

	   if (result.indexOf("None") == 0){ 

		 

		obj.options[0] = new Option("No Results","none");	

	   }

	   

	   else{

			

			strdata = result.split("==");

			 

			for(i=0;i < strdata.length ;i++ )

			{	

				data = strdata[i];				  

				data = data.split("--");			

				obj.options[i] = new Option(data[1],data[0]);

				/*

				if(!Loader.SelectedOption){ 

					obj.options[i] = new Option(data[1],data[0]);

					alert(obj);

				}

				else{

					obj.options[i] = new Option(data[1],data[0]);

					//alert(data[1] + ':' + data[0]);

					if (Loader.SelectedOption == data[0]) obj.options[i].selected = 'selected';									

					

				}*/

				

			}					  		   

	  }

	 

	},

	fn_SetParams: function(type){

		//document.write(type);

	    //alert('fn_SetParams');

		 

		if (type != 'car')

			var strName = document.getElementById("name").value;

			

		var Page = location.href;

		var Params = "name=" + strName;

		

		var uid = document.getElementById("user").value;	

		var lang = document.getElementById("language").value;	

		 

		switch(type){

			case "userinfo":  

				Params += "&action=del&type=" + type + "&id=" + Loader.Id + "&uid=" + uid + "&lang=" + lang;	 

				//alert(Params);

				break; 

			case "fuel":

				var nameja = "";

				if (Page.indexOf("edit") > 0){			

					nameja = document.getElementById("nameja").value; 

					var id = document.getElementById("idmake").value; 

					Params += "&action=update&type=" + type + "&id=" + id  + "&uid=" + uid + "&nameja=" + nameja + "&lang=" + lang;			

				}

				else if (Page.indexOf("add") > 0){

					nameja = document.getElementById("nameja").value; 

					Params += "&action=add&type=" + type + "&uid=" + uid + "&nameja=" + nameja + "&lang=" + lang;

				}

				else{ 

					var id = document.getElementById("idmake").value; 

					Params += "&action=del&type=" + type + "&id=" + Loader.Id + "&uid=" + uid + "&lang=" + lang;			

				}

				

				 

				break; 	

			case "make":

				var nameja = "";

				if (Page.indexOf("edit") > 0){			

					nameja = document.getElementById("nameja").value; 

					var id = document.getElementById("idmake").value; 

					Params += "&action=update&type=" + type + "&id=" + id  + "&uid=" + uid + "&nameja=" + nameja + "&lang=" + lang;			

				}

				else if (Page.indexOf("add") > 0){

					nameja = document.getElementById("nameja").value; 

					Params += "&action=add&type=" + type + "&uid=" + uid + "&nameja=" + nameja + "&lang=" + lang;

				}

				else{ 

					var id = document.getElementById("idmake").value; 

					Params += "&action=del&type=" + type + "&id=" + Loader.Id + "&uid=" + uid + "&lang=" + lang;			

				}

				

				 

				break; 

			case "enginemake":

				var nameja = "";

				if (Page.indexOf("edit") > 0){			

					nameja = document.getElementById("nameja").value; 

					var id = document.getElementById("idmake").value; 

					Params += "&action=update&type=" + type + "&id=" + id  + "&uid=" + uid + "&nameja=" + nameja + "&lang=" + lang;			

				}

				else if (Page.indexOf("add") > 0){

					nameja = document.getElementById("nameja").value; 

					Params += "&action=add&type=" + type + "&uid=" + uid + "&nameja=" + nameja + "&lang=" + lang;

				}

				else{ 

					var id = document.getElementById("idmake").value; 

					Params += "&action=del&type=" + type + "&id=" + Loader.Id + "&uid=" + uid + "&lang=" + lang;			

				}

				

				//alert(Params);

				break; 			

			case "model":

				var nameja = "";

				if (Page.indexOf("edit") > 0){			

					nameja = document.getElementById("nameja").value; 

					var id = document.getElementById("idmodel").value; 

					var makeid = document.getElementById("makeid").value;

					Params += "&action=update&type=" + type + "&id=" + id + "&makeid=" + makeid  + "&uid=" + uid + "&nameja=" + nameja ;					Params += "&lang=" + lang;

				}

				else if (Page.indexOf("add") > 0){

					nameja = document.getElementById("nameja").value; 

					var makeid = document.getElementById("makeid").value;

					Params += "&action=add&type=" + type + "&makeid=" + makeid  + "&uid=" + uid + "&nameja=" + nameja + "&lang=" + lang;	

					

				}

				else{ 					

					Params += "&action=del&type=" + type + "&id=" + Loader.Id  + "&uid=" + uid + "&lang=" + lang;				

				}

			

			    break;

			case "enginemodel":

				var nameja = "";

				if (Page.indexOf("edit") > 0){			

					nameja = document.getElementById("nameja").value; 

					var id = document.getElementById("idmodel").value; 

					var makeid = document.getElementById("makeid").value;

					Params += "&action=update&type=" + type + "&id=" + id + "&makeid=" + makeid  + "&uid=" + uid + "&nameja=" + nameja ;					Params += "&lang=" + lang;

				}

				else if (Page.indexOf("add") > 0){

					nameja = document.getElementById("nameja").value; 

					var makeid = document.getElementById("makeid").value;

					Params += "&action=add&type=" + type + "&makeid=" + makeid  + "&uid=" + uid + "&nameja=" + nameja + "&lang=" + lang;	

					

				}

				else{ 					

					Params += "&action=del&type=" + type + "&id=" + Loader.Id  + "&uid=" + uid + "&lang=" + lang;				

				}

			

			    break;	

			case "feature":

				var nameja = "";

				if (Page.indexOf("edit") > 0){			

					nameja = document.getElementById("nameja").value; 

					var id = document.getElementById("idmake").value; 

					Params += "&action=update&type=" + type + "&id=" + id + "&uid=" + uid + "&lang=" + lang + "&nameja=" + nameja;

				}

				else if (Page.indexOf("add") > 0){

					nameja = document.getElementById("nameja").value; 

					Params += "&action=add&type=" + type + "&uid=" + uid + "&lang=" + lang + "&nameja=" + nameja;

				}

				else{ 

					var id = document.getElementById("idmake").value; 

					Params += "&action=del&type=" + type + "&id=" + Loader.Id + "&uid=" + uid + "&lang=" + lang;

				}		

				//alert(Params);

				break; 			

			case "category":

				if (Page.indexOf("edit") > 0){			

					var id = document.getElementById("idmake").value; 

					Params += "&action=update&type=" + type + "&id=" + id;			

				}

				else if (Page.indexOf("add") > 0){

					Params += "&action=add&type=" + type;

				}

				else{ 

					var id = document.getElementById("idmake").value; 

					Params += "&action=del&type=" + type + "&id=" + Loader.Id;				

				}		

				

				break; 	

			case "country":

				if (Page.indexOf("edit") > 0){			

					var id = document.getElementById("idcountry").value; 

					var currency = document.getElementById("currency").value; 

					Params += "&action=update&type=" + type + "&id=" + id + "&currency=" + currency ;			

				}

				else if (Page.indexOf("add") > 0){

					

					var currency = document.getElementById("currency").value; 

					Params += "&action=add&type=" + type + "&currency=" + currency ;

				}

				else{ 

					var id = document.getElementById("idcountry").value; 

					Params += "&action=del&type=" + type + "&id=" + Loader.Id;				

				}		

				

				break; 

			case "city":

				if (Page.indexOf("edit") > 0){			

					var id = document.getElementById("idmodel").value; 

					var makeid = document.getElementById("makeid").value;

					Params += "&action=update&type=" + type + "&id=" + id + "&countryid=" + makeid;				

				}

				else if (Page.indexOf("add") > 0){

					var makeid = document.getElementById("makeid").value;

					Params += "&action=add&type=" + type + "&countryid=" + makeid;	

					

				}

				else{ 					

					Params += "&action=del&type=" + type + "&id=" + Loader.Id;				

				}

			

			    break;	

			case "myinfo":

			 

			  

				if (Page.indexOf("edit") > 0){			

					var id="",fname="",lname="",email="",company="",address="",phone="",fax="",uname="",upass="";

					var admin = document.getElementById("admin").value; 

					

					id = document.getElementById("idmyinfo").value; 

					fname = document.getElementById("fname").value; 

					lname = document.getElementById("lname").value; 

					uname = document.getElementById("uname").value; 				

					upass = document.getElementById("upass").value; 				

					

					if(admin == "false"){						 

						 email = document.getElementById("email").value; 

						 company = document.getElementById("company").value;					

						 address = document.getElementById("address").value; 

						 phone = document.getElementById("phone").value; 

						 fax = document.getElementById("fax").value;						 

					}

					Params += "&action=update&type=" + type + "&id=" + id + "&fname=" + fname + "&lname=" + lname;	

					Params = Params + "&email=" + email + "&company=" + company + "&address=" + address  + "&phone=" + phone  + "&fax=" + fax;

					Params = Params + "&uname=" + uname + "&upass=" + upass + "&admin=" + admin;

				}

				else if (Page.indexOf("add") > 0){

					var makeid = document.getElementById("makeid").value;

					Params += "&action=add&type=" + type + "&countryid=" + makeid;	

					

				}

				else{ 					

					Params += "&action=del&type=" + type + "&id=" + Loader.Id;				

				}

			 

			    break;		

			case "port":

				if (Page.indexOf("edit") > 0){			

					var id = document.getElementById("idport").value; 

					var makeid = document.getElementById("makeid").value;

					Params += "&action=update&type=" + type + "&id=" + id + "&countryid=" + makeid;				

				}

				else if (Page.indexOf("add") > 0){

					var makeid = document.getElementById("makeid").value;

					Params += "&action=add&type=" + type + "&countryid=" + makeid;	

					

				}

				else{ 					

					Params += "&action=del&type=" + type + "&id=" + Loader.Id;				

				}

			

			    break;	

			/*

				if (Page.indexOf("edit") > 0){			

					var portid = document.getElementById("idport").value;

				

					var countryid = document.getElementById("countryid").value;	

					//var cityid = document.getElementById("cityid").value;

					var portrate = document.getElementById("portrate").value;

					//Params += "&action=update&type=" + type + "&portid=" + id + "&cityid=" + cityid + "&portrate=" + portrate + "&id=" + portid;					

					Params += "&action=update&type=" + type + "&portid=" + portid +  "&portrate=" + portrate + "&countryid=" + countryid;					

				}

				else if (Page.indexOf("add") > 0){

					var portid = document.getElementById("idport").value;					

					//var cityid = document.getElementById("cityid").value;

					var portrate = document.getElementById("portrate").value;

					//Params += "&action=add&type=" + type + "&portid=" + portid + "&cityid=" + cityid + "&portrate=" + portrate;	

					Params += "&action=add&type=" + type + "&portid=" + portid + "&portrate=" + portrate;	

					

				}

				else{ 					

					Params += "&action=del&type=" + type + "&id=" + Loader.Id;				

				}

			*/  

			case "freightrate":

				if (Page.indexOf("edit") > 0){			

					var portid = document.getElementById("idport").value;

				

					var countryid = document.getElementById("countryid").value;	

					//var cityid = document.getElementById("cityid").value;

					var portrate = document.getElementById("portrate").value;

					//Params += "&action=update&type=" + type + "&portid=" + id + "&cityid=" + cityid + "&portrate=" + portrate + "&id=" + portid;					

					Params += "&action=update&type=" + type + "&portid=" + portid +  "&portrate=" + portrate + "&countryid=" + countryid;					

				}

				else if (Page.indexOf("add") > 0){

					var portid = document.getElementById("idport").value;					

					//var cityid = document.getElementById("cityid").value;

					var portrate = document.getElementById("portrate").value;

					//Params += "&action=add&type=" + type + "&portid=" + portid + "&cityid=" + cityid + "&portrate=" + portrate;	

					Params += "&action=add&type=" + type + "&portid=" + portid + "&portrate=" + portrate;	

					

				}

				else{ 					

					Params += "&action=del&type=" + type + "&id=" + Loader.Id;				

				}

			

			    break;		

				  

			case "conversion":

				 

				//var rate = document.getElementById("id").value; 

				//alert(rrateate);

				

			 

				if (Page.indexOf("edit") > 0){			

					var id = document.getElementById("idcountry").value; 

					var currency = document.getElementById("currency").value; 

					Params += "&action=update&type=" + type + "&id=" + id + "&currency=" + currency ;			

				}

				else if (Page.indexOf("add") > 0){

					

					var countryid = document.getElementById("countryid").value; 

					

					Params += "&action=add&type=" + type + "&countryid=" + countryid;

					

				}

				else{ 

					var id = document.getElementById("idrate").value; 

					Params += "&action=del&type=" + type + "&id=" + Loader.Id;				

				}

				 

				 

				

				break; 

			

			case "forjson":

				if (Page.indexOf("edit") > 0){			

					var id = document.getElementById("idmodel").value; 

					var makeid = document.getElementById("makeid").value;

					Params += "&action=update&type=" + type + "&id=" + id + "&countryid=" + makeid;				

				}

				else if (Page.indexOf("add") > 0){

					var makeid = document.getElementById("makeid").value;

					Params += "&action=add&type=" + type + "&countryid=" + makeid;	

					

				}

				else{ 					

					Params += "&action=del&type=" + type + "&id=" + Loader.Id;				

				}

			

			    break;		

			case "car":

				

				if (Page.indexOf("edit") > 0){								

					

				}

				else if (Page.indexOf("add") > 0){					

					

				}

				else{ 					

					Params = "&action=del&type=" + type + "&id=" + Loader.Id + "&uid=" + uid;				

				}

			

				

				

			    break;	

				

			case "shippingcompany":

				if (Page.indexOf("edit") > 0){			

					var id = document.getElementById("idshippingcompany").value; 

					var rates = document.getElementById("rate").value; 

					Params += "&action=update&type=" + type + "&id=" + id + "&rate=" + rates ;			

					

				}

				else if (Page.indexOf("add") > 0){					

					var rates = document.getElementById("rate").value; 					

					Params += "&action=add&type=" + type + "&rate=" + rates ;

				}

				else{ 

					var id = document.getElementById("idshippingcompany").value; 

					Params += "&action=del&type=" + type + "&id=" + Loader.Id;				

				}		

				

				break; 	

				

			case "vehiclesize":

				if (Page.indexOf("edit") > 0){			

					var id = document.getElementById("idfreightrate").value; 

					var m3 = document.getElementById("m3").value; 

					Params += "&action=update&type=" + type + "&id=" + id + "&m3=" + m3 ;			

					

				}

				else if (Page.indexOf("add") > 0){					

					var m3 = document.getElementById("m3").value; 					

					Params += "&action=add&type=" + type + "&m3=" + m3 ;

				}

				else{ 

					var id = document.getElementById("idfreightrate").value; 

					Params += "&action=del&type=" + type + "&id=" + Loader.Id;				

				}		

				

				break; 		

			case "customer":

				if (Page.indexOf("edit") > 0){			

					var fname = document.getElementById("fname").value; 

					var lname = document.getElementById("lname").value; 

					var email = document.getElementById("email").value; 

					var company = document.getElementById("company").value;					

					var address = document.getElementById("address").value; 

					var phone = document.getElementById("phone").value;

					var fax = document.getElementById("fax").value; 

					var idcustomer = document.getElementById("idcustomer").value;

					var customerrights = document.getElementById("customerrights").value; 

					var uname  = document.getElementById("uname").value; 

					var upass = document.getElementById("upass").value; 

					Params += "&action=update&type=" + type + "&IDCustomer=" + idcustomer;			

					Params += "&fname=" + fname + "&lname=" + lname + "&email=" + email ;

					Params += "&company=" + company + "&address=" + address  + "&phone=" + phone;

					Params += "&fax=" + fax + "&rights=" + customerrights;

					Params += "&uname=" + uname + "&upass=" + upass;

				}

				else if (Page.indexOf("add") > 0){					

					var m3 = document.getElementById("m3").value; 					

					Params += "&action=add&type=" + type + "&m3=" + m3 ;

				}

				else{ 

					var id = document.getElementById("idfreightrate").value; 

					Params += "&action=del&type=" + type + "&id=" + Loader.Id;				

				}		

				

				break; 			

			

			

		}

		

		Loader.GetParams = Loader.Do + Params;

		 

	},



	

	

	fn_delete: function(id,type){		

		var ConfrimVal =confirm("This process cannot be undone. Are you sure you want to delete it?");

		 

		if (ConfrimVal==true){

			Loader.Id = id;

			Loader.fn_Submit(type);		 

		}

	},

	GetSubmitResponse_: function(obj){

	  var sid = document.getElementById("PHPSESSID").value;		 

	  var type = Loader.SubmitType;

	  var result = obj.responseText;  

	  //alert('response: ' + result);

	   

	  

	   switch(result){

			case "successinsert":

				alert('Data successfully inserted.');

				

				window.location.href = type + '.php?PHPSESSID=' + sid;	

				break;

			case "duplicate":

				alert('Cannot insert duplicate data.');

				break;

			case "successupdate":

				alert('Data successfully updated.');	

				 

				window.location.href = type + '.php?PHPSESSID=' + sid;			

				break;

			case "successdelete":

				alert('Data successfully deleted.');				

				window.location.href = type + '.php?PHPSESSID=' + sid;

				break;	

	   }

	 

	   

	},

	fn_Submit: function(type){	

		

		Loader.SubmitType = type;

		Loader.fn_SetParams(type);    

		 

	  new Ajax.Request(Loader.GetParams,{method:'post',onComplete: Loader.GetSubmitResponse_});

	 

		 

	},

	GetCarmodelResponse: function(obj){

		 var objmodel = document.getElementById("model");

		   

		 var result = obj.responseText;					

		 //alert(result);
		  //unsuccessfuly
		  if(result == 1){	 

			objmodel.length = 0;

			objmodel.options[0] = new Option("none","-1");	

			alert('No results. Kindly select another make.');

		  }

		  else{

			 objmodel.length = 0;

				result = result.split("==");

				for(i=0;i<result.length;i++){

					strdata = result[i];

					strdata = strdata.split("::");

					objmodel.options[i] = new Option(strdata[1],strdata[0]);	

				}

		  } 

	},

	GetEngineModelResponse: function(obj){

		 var objmodel = document.getElementById("enginemodel");

		   

		 var result = obj.responseText;					

		 //alert(result);

		  if(result == 'empty'){			 

			objmodel.length = 0;

			objmodel.options[0] = new Option("none","");	

			alert('No results. Kindly select another engine make.');

		  }

		  else{

			 objmodel.length = 0;

				result = result.split("==");

				for(i=0;i<result.length;i++){

					strdata = result[i];

					strdata = strdata.split("::");

					objmodel.options[i] = new Option(strdata[1],strdata[0]);	

				}

		  } 

	},

	fn_CarModelSubmit: function(){		

		

	     var makeid = document.getElementById("make").value;
	     //alert(makeid);
	     if(makeid == "0")		
	     {
	        var objmodel = document.getElementById("model");
		objmodel.length = 0;
		objmodel.options[0] = new Option("All Model","0");
	     }
	     else
	     {
		 //var lang = 'en';
		 var lang = document.getElementById("language").value;
		 var params = Loader.Do + "type=getmodel&" + "id=" + makeid + "&language=" + lang;	 	    	  

		 new Ajax.Request(params,{method:'post',onComplete: Loader.GetCarmodelResponse});
	     } 

	},

	LoadEngineModel: function(){		

		

	     var makeid = document.getElementById("enginemake").value;

		 var lang = document.getElementById("language").value;

		 var params = Loader.Do + "type=getenginemodel&" + "id=" + makeid + "&lang=" + lang;	 	    

		 alert(params);

		 new Ajax.Request(params,{method:'post',onComplete: Loader.GetEngineModelResponse});

		 

		

	},

	GetFeatureResponse:function(obj){

	

		

	},

	

	FeatureUpdate: function(id,blnChecked){		

	    

		 vehicleid =  document.getElementById("idcar").value;		 

		 params = Loader.Do + "type=vehicledetails&" + "id=" + id + "&name=" + blnChecked + "&idvehicle=" + vehicleid;

		 if (blnChecked)

			params = params + "&action=add"; 

		else

			params = params + "&action=del"; 			

			

		new Ajax.Request(params,{method:'post',onComplete: Loader.GetFeatureResponse});		

	},

	GetRemoveImageResponse: function(obj){

		 

		if (obj.responseText == 'true'){

			alert('Successfully Removed.');

			window.location.href = location.href

		}

		else alert('Please email support@planetcars.jp if you encounter this message and unable to delete the image.');

		 

	},

	RemoveImage: function(imageid,imagename){		

	    

		var ConfrimVal =confirm("This process cannot be undone. Are you sure you want to delete it?");

		

		if (ConfrimVal==true){		 

			var vehicleid =  document.getElementById("idcar").value;			

			var uid = document.getElementById("user").value;

			var lang = document.getElementById("language").value;

			params = Loader.Do + "type=vehicleimages&" + "name=" + imagename + "&id=" + imageid + "&idvehicle=" + vehicleid + "&uid=" + uid + "&lang=" + lang; 

			//var companyid =  document.getElementById("companyid").value;

			//params = Loader.Do + "type=vehicleimages&" + "name=" + imagename + "&id=" + imageid + "&companyid=" + companyid; 

			

			new Ajax.Request(params,{method:'post',onComplete: Loader.GetRemoveImageResponse});	

		}

	},

	GetFeaturedVehicleResponse: function(obj){

		

		if (obj.responseText == 'successinsert')

			alert('Successfully added.');

		else if	 (obj.responseText == 'successdelete')

			alert('Successfully deleted.');

		else if	 (obj.responseText == 'successupdate')

			alert('Successfully updated.');	

			

			

	},

	GetCustomerResponse: function(obj){

		 

		if(obj.responseText == 'successupdate') alert('Successfully Updated.');

		else alert('Unable to update.');

	},

	

	FeaturedVehicle: function(action,idvehicle){		

	    

		if(action)

			params = 'type=featuredvehicle&action=add';

		else

			params = 'type=featuredvehicle&action=del';

		

        params += '&idvehicle='	+ idvehicle;	

		 

		 new Ajax.GetFeaturedVehicle(params,{method:'post',onComplete: Loader.GetFeaturedVehicleResponse});		

	},	

	GetPricing: function(obj){

	

	 	if (obj.responseText != null) {

					//window.location.href = location.href;

					//alert for error handling

					if (obj.responseText == 'successupdate')

					alert('Successfully Updated.');

					

		}

				   

	},

	CIFPricing: function(data,idvehicle){		

	    

		 if (data) data = 1;

		 else data = 0;

		 

		params = Loader.Do + 'type=cifpricing&action=update&data=' + data;		

        params += '&idvehicle='	+ idvehicle;	

		new Ajax.GetFeaturedVehicle(params,{method:'post',onComplete: Loader.GetPricing});		

	 

		

	},

	CustomerActive: function(IsActive,IDCustomer){

		params = Loader.Do + 'type=customer&action=update&IsActive=' + IsActive + '&IDCustomer=' + IDCustomer;

		new Ajax.Request(params,{method:'post',onComplete: Loader.GetCustomerResponse});		

		

	},

	

	ConsigneeActive: function(IsActive,IDCustomer){

		params = Loader.Do + 'type=consignee&action=update&IsActive=' + IsActive + '&idconsignee=' + IDCustomer;

	 

		new Ajax.Request(params,{method:'post',onComplete: Loader.GetCustomerResponse});		

		

	},

	

	fn_SubmitSearch: function(PageDestination){

		var searchvalue = document.getElementById("search").value;

		window.location.href = PageDestination + "?search=" + searchvalue;

	},

	

	AuctionActivate: function(action,auctionid){

		if(action)

			params = Loader.Do + 'type=auction&action=update&auctiondata=1';

		else

			params = Loader.Do + 'type=auction&action=update&auctiondata=0';

		

        params += '&auctionid='	+ auctionid;	

		  

		 new Ajax.Request(params,{method:'post',onComplete: Loader.GetFeaturedVehicleResponse});	

	}	

	,

	

	CommercialVehicleActivate: function(request,modelid){

		if(request) params = Loader.Do + 'type=model&action=update&blncommercial=1';

		else params = Loader.Do + 'type=model&action=update&blncommercial=0';

		

        params += '&id=' + modelid;	

		  

		 new Ajax.Request(params,{method:'post',onComplete: Loader.GetFeaturedVehicleResponse});	

	},

	CommercialPopularActivate: function(request,modelid){

		if(request) params = Loader.Do + 'type=model&action=update&blnpopular=1';

		else params = Loader.Do + 'type=model&action=update&blnpopular=0';

		 	

		params += '&id=' + modelid;	

		  

		 new Ajax.Request(params,{method:'post',onComplete: Loader.GetFeaturedVehicleResponse});	

		 

	},

	CountryActivate: function(request,countryid){

		 

		if(request) params = Loader.Do + 'type=country&action=update&IsActive=1';

		else params = Loader.Do + 'type=country&action=update&IsActive=0';

		

        params += '&id=' + countryid;	

		 

		 new Ajax.Request(params,{method:'post',onComplete: Loader.GetFeaturedVehicleResponse});	

	},

	CountryStock: function(request,countryid){

		 

		if(request) params = Loader.Do + 'type=country&action=update&IsWithStock=1';

		else params = Loader.Do + 'type=country&action=update&IsWithStock=0';

	

        params += '&id=' + countryid;	

		 

		 new Ajax.Request(params,{method:'post',onComplete: Loader.GetFeaturedVehicleResponse});	

	},

	VehicleSizeActivate: function(request,countryid){

		 

		if(request) params = Loader.Do + 'type=country&action=update&IsActive=1';

		else params = Loader.Do + 'type=country&action=update&IsActive=0';

		

        params += '&id=' + countryid;	

		 

		 new Ajax.Request(params,{method:'post',onComplete: Loader.GetFeaturedVehicleResponse});	

	},

	PageGoto: function(link){	     

		window.location.href = link;

	}

	



}



function HideContainer(container,containerHide)

{

	if (containerHide != "")

	{

		selectedvalue = document.getElementById(container).value;

		

		switch(selectedvalue){

			case '2': 

				 document.getElementById(containerHide).style.display = 'none';

			break;

			case '3': 

				 document.getElementById(containerHide).style.display = 'none';

			break;

			case '4': 

				document.getElementById(containerHide).style.display = 'block';

			break;

		}

	}

}



function CheckEntry () {



	  theForm = document.getElementById('form_make');
	/*
	  var required = ["makeid", "modelid", "length", "year", "width", "height","enginemake","enginemodel","horsepower","fuel","usedhours","status","location","price","txtareadesc","seatingcapacity","boatlength","enginetype","numengines"];
	  	  */

	  var required = ["makeid", "modelid", "year", "width", "height","enginemake","enginemodel","horsepower","fuel","usedhours","status","location","price","txtareadesc","seatingcapacity","boatlength","enginetype","numengines","length"];

	   

	  var invalid = false;

	  

	  for (i=0;i < required.length; i++) {  

		var theField = theForm[required[i]];

		

		

		if (theField.value == "") {	 
		  theField.parentNode.className = "emptyfield"; 
		  if (!invalid) theField.focus();

		  invalid = true;

		} else {
		 
		  theField.parentNode.className = "";

		}

	  } 

	  

	  

	  if (invalid) {

		

		return (false);

	  } else {

		

		return (true);

	  }

}

function CheckEntry () { 

	  theForm = document.getElementById('inquiry');
	 

	  var required = ["name", "company", "email", "country", "city", "message"];
 

	  var invalid = false;
 
	  for (i=0;i < required.length; i++) {  

		var theField = theForm[required[i]]; 

		if (theField.value == "") {	 
		  theField.parentNode.className = "emptyfield"; 
		  if (!invalid) theField.focus();

		  invalid = true;

		} else {
		 
		  theField.parentNode.className = "";

		}

	  } 
 

	  if (invalid) {  
		return (false);

	  } else { 
		return (true); 
	  }

}

function ChangeLanguage(lang)
{
	var currentPage = location.href;
	
	if (currentPage.indexOf('php?')  > -1)
	{ 
		currentPage = currentPage.substring(0,currentPage.indexOf('?')); 
	} 
	else if (currentPage.indexOf('.php') == -1)
	{
		 
		currentPage += "index.php";
	}
	var qString = ""; 
	//qString = document.getElementById('qstring').value;
	window.location.href = currentPage + "?language=" + lang;
	if(qString != "")	
	{
		window.location.href = currentPage + "?language=" + lang + "&" + qString;
	}
	else
	{
		window.location.href = currentPage + "?language=" + lang;
	}
	 window.location.href = currentPage + "?language=" + lang;
}

function PopWindow(path) {
	var language = document.getElementById("language").value;
	var url  = "printable.php?path=" + path + "&language=" + language ;
	 
	newwindow=window.open(url,'name','height=600,width=600');
	if (window.focus) {newwindow.focus()}
	return false;
}
