// JavaScript Document

function changetoggle(id){
	divid = eval('"submenu'+id+'"');
	if(document.getElementById(divid).style.display=='none') {
		for(i=1;i<=1;i++)
		{
			if(i!=id) {
				divhide = eval('"submenu'+i+'"');
				if(document.getElementById(divhide).style.display=='') {	
					new Effect.SlideUp(divhide);
				}
			}
		}
		new Effect.SlideDown(divid);
	}
	else{
		new Effect.SlideUp(divid);
	}
}

function usernamecheck(e, decimal) {
	var key;
	var keychar;

	if (window.event) {
	   key = window.event.keyCode;
	}
	else if (e) {
	   key = e.which;
	}
	else {
	   return true;
	}
	if ((key==32)) {
	   return false;
	}
}

function textCounter(field,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
}

function VerifyMailSend(id) {
	pageurl(id,'resend');
}

function SignUpValidation()
{
		if(document.myform.user_title.value=='')
		{
			alert("Please select Title.");
			document.myform.user_title.focus();
			return false;
		}
		if(document.myform.user_firstname.value=='')
		{
			alert("Please fill first name.");
			document.myform.user_firstname.focus();
			return false;
		}
		if(document.myform.user_lastname.value=='')
		{
			alert("Please fill last name.");
			document.myform.user_lastname.focus();
			return false;
		}
	   
		if(document.myform.user_db_day.value=='')
		{
			alert("Please select day for Date of Birth.");
			document.myform.user_db_day.focus();
			return false;
		}
		if(document.myform.user_db_month.value=='')
		{
			alert("Please select month for Date of Birth.");
			document.myform.user_db_month.focus();
			return false;
		}
		if(document.myform.user_db_year.value=='')
		{
			alert("Please select year for Date of Birth.");
			document.myform.user_db_year.focus();
			return false;
		}
		if(document.myform.user_postcode1.value=='')
		{
			alert("Please fill post code.");
			document.myform.user_postcode1.focus();
			return false;
		}
		if(document.myform.user_postcode2.value=='')
		{
			alert("Please fill post code.");
			document.myform.user_postcode2.focus();
			return false;
		}
		if(!checkPostCode(document.myform.user_postcode1.value+" "+document.myform.user_postcode2.value)) {
			alert("Invalid post code.");
			document.myform.user_postcode2.focus();
			return false;
		}
		if(document.myform.user_email.value=='')
		{
			alert("Please fill your email.");
			document.myform.user_email.focus();
			return false;
		}
	   var email=document.myform.user_email.value;
	   if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
	   {
			alert("The e-mail format is not correct.");
			document.myform.user_email.focus();
			return false;
	   }
		 if(document.myform.checkemail.value=='0')
		{
			alert("Please enter a valid Email.");
			document.myform.user_email.focus();
			return false;
		}
		if(document.myform.user_username.value=='')
		{
			alert("Please fill user name.");
			document.myform.user_username.focus();
			return false;
		}
		
		 if(document.myform.checkuser.value=='0')
		{
			alert("Please enter a valid username.");
			document.myform.user_username.focus();
			return false;
		}
		if(document.myform.user_password.value=='')
		{
			alert("Please fill password.");
			document.myform.user_password.focus();
			return false;
		}
		if(document.myform.user_password2.value=='')
		{
			alert("Please fill confirm password.");
			document.myform.user_password2.focus();
			return false;
		}
	   if(document.myform.user_password.value!=document.myform.user_password2.value)
	   {
		   alert("Password and confirm password not match");
		   document.myform.user_password2.focus();
		   return false;
	   }
	    if(!document.myform.user_terms.checked)
		{
			alert("Please check terms & conditions.");
			return false;
		}
}

function EditUserValidation()
{
		if(document.myform.user_title.value=='')
		{
			alert("Please select Title.");
			document.myform.user_title.focus();
			return false;
		}
		if(document.myform.user_firstname.value=='')
		{
			alert("Please fill first name.");
			document.myform.user_firstname.focus();
			return false;
		}
		if(document.myform.user_lastname.value=='')
		{
			alert("Please fill last name.");
			document.myform.user_lastname.focus();
			return false;
		}
	   
		if(document.myform.user_db_day.value=='')
		{
			alert("Please select day for Date of Birth.");
			document.myform.user_db_day.focus();
			return false;
		}
		if(document.myform.user_db_month.value=='')
		{
			alert("Please select month for Date of Birth.");
			document.myform.user_db_month.focus();
			return false;
		}
		if(document.myform.user_db_year.value=='')
		{
			alert("Please select year for Date of Birth.");
			document.myform.user_db_year.focus();
			return false;
		}
		if(document.myform.user_postcode1.value=='')
		{
			alert("Please fill post code.");
			document.myform.user_postcode1.focus();
			return false;
		}
		if(document.myform.user_postcode2.value=='')
		{
			alert("Please fill post code.");
			document.myform.user_postcode2.focus();
			return false;
		}
		if(!checkPostCode(document.myform.user_postcode1.value+" "+document.myform.user_postcode2.value)) {
			alert("Invalid post code.");
			document.myform.user_postcode2.focus();
			return false;
		}
		if(document.myform.user_email.value=='')
		{
			alert("Please fill your email.");
			document.myform.user_email.focus();
			return false;
		}
	   var email=document.myform.user_email.value;
	   if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
	   {
			alert("The e-mail format is not correct.");
			document.myform.user_email.focus();
			return false;
	   }
	    if(document.myform.checkemail.value=='0')
		{
			alert("Please enter a valid Email.");
			document.myform.user_email.focus();
			return false;
	   }
	   if(!document.myform.user_terms.checked)
	   {
			alert("Please check terms & conditions.");
			return false;
		}
}
	
//*******************************************************************************

function ClubSignUpValidation()
{
		if(document.myform.club_name.value=='')
		{
			alert("Please fill club name.");
			document.myform.club_name.focus();
			return false;
		}
		if((document.myform.club_url_check[0].checked) && (document.myform.club_url.value==''||document.myform.club_url.value=='www'))
		{
			alert("Please fill club website URL.");
			document.myform.club_url.focus();
			return false;
		}
		if(document.myform.club_add1.value=='')
		{
			alert("Please fill address line1.");
			document.myform.club_add1.focus();
			return false;
		}
		if(document.myform.club_postcode1.value=='')
		{
			alert("Please fill post code.");
			document.myform.club_postcode1.focus();
			return false;
		}
		if(document.myform.club_postcode2.value=='')
		{
			alert("Please fill post code.");
			document.myform.club_postcode2.focus();
			return false;
		}
		if(!checkPostCode(document.myform.club_postcode1.value+" "+document.myform.club_postcode2.value)) {
			alert("Invalid post code.");
			document.myform.club_postcode2.focus();
			return false;
		}
		if(document.myform.club_telephone1.value=='')
		{
			alert("Please fill telephone no. 1");
			document.myform.club_telephone1.focus();
			return false;
		}
		if(document.myform.club_gen_email.value=='')
		{
			alert("Please fill general email address.");
			document.myform.club_gen_email.focus();
			return false;
		}
		var email=document.myform.club_gen_email.value;
	   if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
	   {
			alert("The General e-mail address format is not correct.");
			document.myform.club_gen_email.focus();
			return false;
	   }
	  
		if(document.myform.club_con_title.value=='')
		{
			alert("Please fill club contact title.");
			document.myform.club_con_title.focus();
			return false;
		}
		if(document.myform.club_con_name.value=='')
		{
			alert("Please fill club contact first name.");
			document.myform.club_con_name.focus();
			return false;
		}
		if(document.myform.club_con_lname.value=='')
		{
			alert("Please fill club contact last name.");
			document.myform.club_con_lname.focus();
			return false;
		}
		if(document.myform.club_con_telephone.value=='')
		{
			alert("Please fill club contact telephone.");
			document.myform.club_con_telephone.focus();
			return false;
		}
		if(document.myform.club_con_email.value=='')
		{
			alert("Please fill club email address.");
			document.myform.club_con_email.focus();
			return false;
		}
		var email=document.myform.club_con_email.value;
	   if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
	   {
			alert("The Club e-mail address format is not correct.");
			document.myform.club_con_email.focus();
			return false;
	   }
	   
	   	if(document.myform.club_username.value=='')
		{
			alert("Please fill user name.");
			document.myform.club_username.focus();
			return false;
		}
		
		
		if(document.myform.club_password.value=='')
		{
			alert("Please fill password.");
			document.myform.club_password.focus();
			return false;
		}
		if(document.myform.club_password2.value=='')
		{
			alert("Please fill confirm password.");
			document.myform.club_password2.focus();
			return false;
		}
	   if(document.myform.club_password.value!=document.myform.club_password2.value)
	   {
		   alert("Password and confirm password not match");
		   document.myform.club_password2.focus();
		   return false;
	   }
	    if(!document.myform.club_terms.checked)
		{
			alert("Please check terms & conditions.");
			return false;
		}
		 if(document.myform.checkgemail.value=='0')
		{
			alert("Please enter a valid Email.");
			document.myform.club_gen_email.focus();
			return false;
		}
		
		 if(document.myform.checkemail.value=='0')
		{
			alert("Please enter a valid Email.");
			document.myform.club_con_email.focus();
			return false;
		}

		if(document.myform.checkuser.value=='0')
		{
			alert("Please enter a valid username.");
			document.myform.club_username.focus();
			return false;
		}
}

function ClubEditValidation()
{
		if(document.myform.club_name.value=='')
		{
			alert("Please fill club name.");
			document.myform.club_name.focus();
			return false;
		}
		if((document.myform.club_url_check[0].checked) && (document.myform.club_url.value==''||document.myform.club_url.value=='www'))
		{
			alert("Please fill club website URL.");
			document.myform.club_url.focus();
			return false;
		}
		if(document.myform.club_add1.value=='')
		{
			alert("Please fill address line1.");
			document.myform.club_add1.focus();
			return false;
		}
		if(document.myform.club_postcode1.value=='')
		{
			alert("Please fill post code.");
			document.myform.club_postcode1.focus();
			return false;
		}
		if(document.myform.club_postcode2.value=='')
		{
			alert("Please fill post code.");
			document.myform.club_postcode2.focus();
			return false;
		}
		if(!checkPostCode(document.myform.club_postcode1.value+" "+document.myform.club_postcode2.value)) {
			alert("Invalid post code.");
			document.myform.club_postcode2.focus();
			return false;
		}
		if(document.myform.club_telephone1.value=='')
		{
			alert("Please fill telephone no. 1");
			document.myform.club_telephone1.focus();
			return false;
		}
		if(document.myform.club_gen_email.value=='')
		{
			alert("Please fill general email address.");
			document.myform.club_gen_email.focus();
			return false;
		}
		var email=document.myform.club_gen_email.value;
	   if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
	   {
			alert("The General e-mail address format is not correct.");
			document.myform.club_gen_email.focus();
			return false;
	   }
	   
	   if(document.myform.club_con_title.value=='')
		{
			alert("Please fill club contact title.");
			document.myform.club_con_title.focus();
			return false;
		}
		if(document.myform.club_con_name.value=='')
		{
			alert("Please fill club contact first name.");
			document.myform.club_con_name.focus();
			return false;
		}
		if(document.myform.club_con_lname.value=='')
		{
			alert("Please fill club contact last name.");
			document.myform.club_con_lname.focus();
			return false;
		}
		if(document.myform.club_con_telephone.value=='')
		{
			alert("Please fill club contact telephone.");
			document.myform.club_con_telephone.focus();
			return false;
		}
		if(document.myform.club_con_email.value=='')
		{
			alert("Please fill club email address.");
			document.myform.club_con_email.focus();
			return false;
		}
		var email=document.myform.club_con_email.value;
	   if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
	   {
			alert("The Club e-mail address format is not correct.");
			document.myform.club_con_email.focus();
			return false;
	   }
	   
	   if(document.myform.club_optional_link_1_title.value!='' && (document.myform.club_optional_link_1_url.value=="" || document.myform.club_optional_link_1_url.value=="www"))
	   {
			alert("Please fill Optional link 1 URL.");
			document.myform.club_optional_link_1_url.focus();
			return false;
	   }
	   if(document.myform.club_optional_link_2_title.value!='' && (document.myform.club_optional_link_2_url.value=="" || document.myform.club_optional_link_2_url.value=="www"))
	   {
			alert("Please fill Optional link 2 URL.");
			document.myform.club_optional_link_2_url.focus();
			return false;
	   }
	   if(document.myform.club_optional_link_3_title.value!='' && (document.myform.club_optional_link_3_url.value=="" || document.myform.club_optional_link_3_url.value=="www"))
	   {
			alert("Please fill Optional link 3 URL.");
			document.myform.club_optional_link_3_url.focus();
			return false;
	   }
	   if(!document.myform.club_terms.checked)
		{
			alert("Please check terms & conditions.");
			return false;
		}

		if(document.myform.checkgemail.value=='0')
		{
			alert("Please enter a valid Email.");
			document.myform.club_gen_email.focus();
			return false;
	   }
	   if(document.myform.checkemail.value=='0')
		{
			alert("Please enter a valid Email.");
			document.myform.club_con_email.focus();
			return false;
	   }
}

//************************************************************

function SupplierSignUpValidation()
{
		if(document.myform.supplier_company.value=='')
		{
			alert("Please fill company name.");
			document.myform.supplier_company.focus();
			return false;
		}
		if((document.myform.supplier_url_check[0].checked)&&(document.myform.supplier_url.value==''|| document.myform.supplier_url.value=='www'))
		{
			alert("Please fill supplier website URL.");
			document.myform.supplier_url.focus();
			return false;
		}
		if(document.myform.supplier_add1.value=='')
		{
			alert("Please fill address line1.");
			document.myform.supplier_add1.focus();
			return false;
		}
		if(document.myform.supplier_postcode1.value=='')
		{
			alert("Please fill post code.");
			document.myform.supplier_postcode1.focus();
			return false;
		}
		if(document.myform.supplier_postcode2.value=='')
		{
			alert("Please fill post code.");
			document.myform.supplier_postcode2.focus();
			return false;
		}		
		if(!checkPostCode(document.myform.supplier_postcode1.value+" "+document.myform.supplier_postcode2.value)) {
			alert("Invalid post code.");
			document.myform.supplier_postcode2.focus();
			return false;
		}
		if(document.myform.supplier_telephone1.value=='')
		{
			alert("Please fill telephone no. 1");
			document.myform.supplier_telephone1.focus();
			return false;
		}
		if(document.myform.supplier_gen_email.value=='')
		{
			alert("Please fill general email address.");
			document.myform.supplier_gen_email.focus();
			return false;
		}
		var email=document.myform.supplier_gen_email.value;
	   if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
	   {
			alert("The General e-mail address format is not correct.");
			document.myform.supplier_gen_email.focus();
			return false;
	   }
	   
	    if(document.myform.supplier_title.value=='')
	    {
			alert("Please fill title.");
			document.myform.supplier_title.focus();
			return false;
		}
		if(document.myform.supplier_con_name.value=='')
		{
			alert("Please fill supplier contact name.");
			document.myform.supplier_con_name.focus();
			return false;
		}
		if(document.myform.supplier_con_email.value=='')
		{
			alert("Please fill supplier email address.");
			document.myform.supplier_con_email.focus();
			return false;
		}
		var email=document.myform.supplier_con_email.value;
	   if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
	   {
			alert("The Supplier e-mail address format is not correct.");
			document.myform.supplier_con_email.focus();
			return false;
	   }
	    
	   if(document.myform.supplier_con_telephone.value=='')
		{
			alert("Please fill contact tel no. .");
			document.myform.supplier_con_telephone.focus();
			return false;
		}
		if(document.myform.supplier_username.value=='')
		{
			alert("Please fill user name.");
			document.myform.supplier_username.focus();
			return false;
		}

		if(document.myform.supplier_password.value=='')
		{
			alert("Please fill password.");
			document.myform.supplier_password.focus();
			return false;
		}
		if(document.myform.supplier_password2.value=='')
		{
			alert("Please fill confirm password.");
			document.myform.supplier_password2.focus();
			return false;
		}
	   if(document.myform.supplier_password.value!=document.myform.supplier_password2.value)
	   {
		   alert("Password and confirm password not match");
		   document.myform.supplier_password2.focus();
		   return false;
	   }
	    if(!document.myform.supplier_terms.checked)
		{
			alert("Please check terms & conditions.");
			return false;
		}

		if(document.myform.checkgemail.value=='0')
		{
			alert("Please enter a valid Email.");
			document.myform.supplier_gen_email.focus();
			return false;
		}
	   if(document.myform.checkemail.value=='0')
		{
			alert("Please enter a valid Email.");
			document.myform.supplier_con_email.focus();
			return false;
		}
		if(document.myform.checkuser.value=='0')
		{
			alert("Please enter a valid user name.");
			document.myform.supplier_username.focus();
			return false;
		}
}


function SupplierProfileValidation()
{
		if(document.myform.supplier_company.value=='')
		{
			alert("Please fill company name.");
			document.myform.supplier_company.focus();
			return false;
		}
		if((document.myform.supplier_url_check[0].checked) && (document.myform.supplier_url.value==''||document.myform.supplier_url.value=='www'))
		{
			alert("Please fill supplier website URL.");
			document.myform.supplier_url.focus();
			return false;
		}
		if(document.myform.supplier_add1.value=='')
		{
			alert("Please fill address line1.");
			document.myform.supplier_add1.focus();
			return false;
		}
		if(document.myform.supplier_postcode1.value=='')
		{
			alert("Please fill post code.");
			document.myform.supplier_postcode1.focus();
			return false;
		}
		if(document.myform.supplier_postcode2.value=='')
		{
			alert("Please fill post code.");
			document.myform.supplier_postcode2.focus();
			return false;
		}		
		if(!checkPostCode(document.myform.supplier_postcode1.value+" "+document.myform.supplier_postcode2.value)) {
			alert("Invalid post code.");
			document.myform.supplier_postcode2.focus();
			return false;
		}
		if(document.myform.supplier_telephone1.value=='')
		{
			alert("Please fill telephone no. 1");
			document.myform.supplier_telephone1.focus();
			return false;
		}
		if(document.myform.supplier_gen_email.value=='')
		{
			alert("Please fill general email address.");
			document.myform.supplier_gen_email.focus();
			return false;
		}
		var email=document.myform.supplier_gen_email.value;
	   if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
	   {
			alert("The General e-mail address format is not correct.");
			document.myform.supplier_gen_email.focus();
			return false;
	   }

	   if(document.myform.supplier_title.value=='')
		{
			alert("Please fill title.");
			document.myform.supplier_title.focus();
			return false;
		}
		if(document.myform.supplier_con_name.value=='')
		{
			alert("Please fill supplier contact name.");
			document.myform.supplier_con_name.focus();
			return false;
		}
		if(document.myform.supplier_con_email.value=='')
		{
			alert("Please fill supplier email address.");
			document.myform.supplier_con_email.focus();
			return false;
		}
		var email=document.myform.supplier_con_email.value;
	   if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
	   {
			alert("The Supplier e-mail address format is not correct.");
			document.myform.supplier_con_email.focus();
			return false;
	   }

	    if(document.myform.supplier_con_telephone.value=='')
		{
			alert("Please fill contact tel no.");
			document.myform.supplier_con_telephone.focus();
			return false;
		}
		
		var cat = document.getElementById("supplier_category_id");
		var count = 0;
		for(var i=1;i<cat.length;i++) {
			if(document.myform.supplier_category_id[i].selected) {
				count++;
			}
		}
		if(count<1)
		{
			alert("Please choose at least one supplier category.");
			return false;
		}
		if(!document.myform.supplier_terms.checked)
		{
			alert("Please check terms & conditions.");
			return false;
		}

		if(document.myform.checkgemail.value=='0')
		{
			alert("Please enter a valid Email.");
			document.myform.supplier_gen_email.focus();
			return false;
		}

	    if(document.myform.checkemail.value=='0')
		{
			alert("Please enter a valid Email.");
			document.myform.supplier_con_email.focus();
			return false;
		}
}

function ValidationLogin() {
		if(document.loginform.username.value=='')
		{
			alert("Please fill user name.");
			document.loginform.username.focus();
			return false;
		}
			
		if(document.loginform.password.value=='')
		{
			alert("Please fill password.");
			document.loginform.password.focus();
			return false;
		}
}

function ValidationHeaderLogin() {
		if(document.headerloginform.header_username.value=='')
		{
			alert("Please fill user name.");
			document.headerloginform.header_username.focus();
			return false;
		}
			
		if(document.headerloginform.header_password.value=='')
		{
			alert("Please fill password.");
			document.headerloginform.header_password.focus();
			return false;
		}
}
function ForgotPassword() {
	if(document.forgotpasswordform.forgot_email.value=='')
		{
			alert("Please fill email address.");
			document.forgotpasswordform.forgot_email.focus();
			return false;
		}
		var email=document.forgotpasswordform.forgot_email.value;
	   if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
	   {
			alert("The E-mail address format is not correct.");
			document.forgotpasswordform.forgot_email.focus();
			return false;
	   }
}

function ValidationChangePassword() {
				
		if(document.changepasswordform.old_password.value=='')
		{
			alert("Please fill old password.");
			document.changepasswordform.old_password.focus();
			return false;
		}
		if(document.changepasswordform.new_password.value=='')
		{
			alert("Please fill new password.");
			document.changepasswordform.new_password.focus();
			return false;
		}
		if(document.changepasswordform.new_password2.value=='')
		{
			alert("Please fill confirm password.");
			document.changepasswordform.new_password2.focus();
			return false;
		}
		if(document.changepasswordform.new_password2.value!=document.changepasswordform.new_password.value)
		{
			alert("New password and confirm password not match");
			document.changepasswordform.new_password2.focus();
			return false;
		}
}
//************************************************************

function ConfirmItemsforsaleDelete(id) {
	if(confirm("Please confirm deletion of my classified?")) {
		document.location = "myclassified.php?id="+id+"&action=del";
	}
}

function ConfirmWishlistDelete(id) {
	if(confirm("Please confirm deletion of Wishlist item?")) {
		document.location = "mywishlist.php?id="+id+"&action=del";
	}
}

function ConfirmCarDelete(id) {
	if(confirm("Are you sure to delete car?")) {
		document.location = "mycar.php?id="+id+"&action=del";
	}
}

function ConfirmCarArchive(id) {
	if(confirm("Are you sure to make this car Archive?")) {
		document.location = "mycar.php?id="+id+"&action=arc";
	}
}

function ConfirmCarSoldOut(id) {
	if(confirm("Are you sure to make this car sold?")) {
		document.location = "mycar.php?id="+id+"&action=sold";
	}
}

function ConfirmCarActive(id) {
	if(confirm("Are you sure to make this car UnArchive?")) {
		document.location = "archivecar.php?id="+id+"&action=una";
	}
}


function ConfirmSupplierLogoDelete(id)
{
	if(confirm("Are you sure to delete logo?")) {
		document.location = "edit_supplier.php?id="+id+"&action=logo";
	}
}

function ConfirmClubLogoDelete(id)
{
	if(confirm("Are you sure to delete logo?")) {
		document.location = "edit_club.php?id="+id+"&action=logo";
	}
}

function deleteSpecialisation(id)
{
	if(confirm("Are you sure to delete Specialisation?")) {
		document.location = "specialist_area.php?id="+id+"&action=del";
	}
}

function ConfirmSupplierImageDelete(id,count)
{
	if(confirm("Are you sure to delete Image"+count+"?")) {
		document.location = "edit_supplier.php?id="+id+"&action=image"+count;
	}
}

function ConfirmClubImageDelete(id,count)
{
	if(confirm("Are you sure to delete Image"+count+"?")) {
		document.location = "edit_club.php?id="+id+"&action=image"+count;
	}
}

function ConfirmEditLogoDelete(id)
{
	if(confirm("Are you sure to delete logo?")) {
		document.location = "edit_logo.php?id="+id+"&action=logo";
	}
}

function ConfirmEditImageDelete(id,count)
{
	if(confirm("Are you sure to delete Image"+count+"?")) {
		document.location = "edit_logo.php?id="+id+"&action=image"+count;
	}
}

function ConfirmClubEditImageDelete(id,count)
{
	if(confirm("Are you sure to delete Image"+count+"?")) {
		document.location = "edit_logo.php?id="+id+"&action=clubimage"+count;
	}
}

function SelectSpecialistArea(val) {
	
	if(val=="0"){
		document.getElementById("specialist").style.display='none';
	} else {
		document.getElementById("specialist").style.display='block';
	}
}

function showcountry(val) {
	if(val==1) {
		document.getElementById("country").style.display = "block";
		document.getElementById("country_id").value = "";
		var selectbox = document.getElementById("manufacturer_id");
		var i;
		for(i=selectbox.options.length-1;i>=0;i--)
		{
			selectbox.remove(i);
		}
		var selectbox = document.getElementById("model_id");
		var i;
		for(i=selectbox.options.length-1;i>=0;i--)
		{
			selectbox.remove(i);
		}
		document.getElementById("carparts").innerHTML = '';
	}
	else {
		document.getElementById("country").style.display = "none";
		UpdateManufacturerList('all');
		var selectbox = document.getElementById("model_id");
		var i;
		for(i=selectbox.options.length-1;i>=0;i--)
		{
			selectbox.remove(i);
		}
		document.getElementById("carparts").innerHTML = '';
	}
}

function ratethis() {
	if(document.getElementById("feedback").style.display=='none') {
		new Effect.SlideDown("feedback");
	}
	else{
		new Effect.SlideUp("feedback");
	}
}

function ratethissupplier(userid,supplierid) {
	if(document.rating.feed_text.value=='')
	{
		alert("Please fill feedback comment.");
		document.rating.feed_text.focus();
		return false;
	}
	if(!document.rating.feed_rate[0].checked&&!document.rating.feed_rate[1].checked&&!document.rating.feed_rate[2].checked&&!document.rating.feed_rate[3].checked&&!document.rating.feed_rate[4].checked)
	{
		alert("Please select feedback rating.");
		return false;
	}
	var rate = 0;
	if(document.rating.feed_rate[0].checked)
		rate = 1;
	if(document.rating.feed_rate[1].checked)
		rate = 2;
	if(document.rating.feed_rate[2].checked)
		rate = 3;
	if(document.rating.feed_rate[3].checked)
		rate = 4;
	if(document.rating.feed_rate[4].checked)
		rate = 5;

	var postdate = "feed_text="+encodeURIComponent(document.rating.feed_text.value)+"&feed_rate="+rate;
	var url = 'addfeedback.php?userid='+userid+'&supplierid='+supplierid;
	new Ajax.Request(url, {
		method: 'post',
		parameters: postdate,
		onSuccess: function(transport) {   
			document.getElementById("loader").style.display='none';
			if(transport.responseText!="Feedback has been submitted.") {
				alert(transport.responseText); 
			} else {
				window.location = window.location.href;
			}
		}, 
		onLoading: function(){document.getElementById("loader").style.display='block';}
	});
	return false;
}
///////////////////// new version of supplier rating///////
function ratethissupplier_new(userid,supplierid) {
	if(document.rating.feed_text.value=='')
	{
		alert("Please fill feedback comment.");
		document.rating.feed_text.focus();
		return false;
	}
	if(!document.rating.feed_rate[0].checked&&!document.rating.feed_rate[1].checked&&!document.rating.feed_rate[2].checked)
	{
		alert("Please select feedback rating.");
		return false;
	}
	var rate = 0;
	if(document.rating.feed_rate[0].checked)
		rate = -1;
	if(document.rating.feed_rate[1].checked)
		rate = 0;
	if(document.rating.feed_rate[2].checked)
		rate = 1;	

	var postdate = "feed_text="+encodeURIComponent(document.rating.feed_text.value)+"&feed_rate="+rate;
	var url = 'addfeedback.php?userid='+userid+'&supplierid='+supplierid;
	new Ajax.Request(url, {
		method: 'post',
		parameters: postdate,
		onSuccess: function(transport) {   
			document.getElementById("loader").style.display='none';
			if(transport.responseText!="Feedback has been submitted.") {
				alert(transport.responseText); 
				location.reload(true);
			} else {
				window.location = window.location.href;
			}
		}, 
		onLoading: function(){document.getElementById("loader").style.display='block';}
	});
	return false;
}
///////////////////// new version of supplier rating ends//////////////
function addtomyclub(userid,clubid) {
	if (userid==0)
	{
		alert("Please login to add.");
	} else {
		var url = 'addtomyclub.php?userid='+userid+'&clubid='+clubid;
		new Ajax.Request(url, {   
			method: 'get', 
			onSuccess: function(transport) {   
				alert(transport.responseText); 
			}, 
			onLoading: function(){}
		});
	}
}

function addtomysupplier(userid,supplierid) {
	if (userid==0)
	{
		alert("Please login to add.");
	} else {
		var url = 'addtomysupplier.php?userid='+userid+'&supplierid='+supplierid;
		new Ajax.Request(url, {   
			method: 'get', 
			onSuccess: function(transport) {   
				alert(transport.responseText); 
			}, 
			onLoading: function(){}
		});
	}
}

function addtomyevent(userid,eventid) {
	if (userid==0)
	{
		alert("Please login to add.");
	} else {
		var url = 'addtomyevent.php?userid='+userid+'&eventid='+eventid;
		new Ajax.Request(url, {   
			method: 'get', 
			onSuccess: function(transport) {   
				alert(transport.responseText); 
			}, 
			onLoading: function(){}
		});
	}
}


function addtowishlist(userid,classifiedid) {
	if (userid==0) {
		alert("Please login to add.");
	} else {
		var url = 'addtowishlist.php?userid='+userid+'&classifiedid='+classifiedid;
		new Ajax.Request(url, {   
			method: 'get', 
			onSuccess: function(transport) {   
				alert(transport.responseText); 
			}, 
			onLoading: function(){}
		});
	}
}


function UpdateManufacturerList(val) {
	if (val!=''){
		var selectbox = document.getElementById("model_id");
		var i;
		for(i=selectbox.options.length-1;i>=0;i--)
		{
			selectbox.remove(i);
		}
		document.getElementById("carparts").innerHTML = '';
		var url = 'ajaxmanufacturer.php?countries='+val;
		new Ajax.Request(url, {   
			method: 'get', 
			onSuccess: function(transport) {   
				document.getElementById("loader").style.display='none';
				document.getElementById("manufacturer").innerHTML = transport.responseText; 
			}, 
			onLoading: function(){document.getElementById("loader").style.display='block';}
		}); 
	}
}

function UpdateModelList(val,id) {
	if (val!=''){
		var url = 'ajaxmodel.php?manu='+val+"&id="+id;
		new Ajax.Request(url, {   
			method: 'get', 
			onSuccess: function(transport) {   
				document.getElementById("loader1").style.display='none';
				document.getElementById("model").innerHTML = transport.responseText; 
				UpdateCarPartList();
			}, 
			onLoading: function(){document.getElementById("loader1").style.display='block';}
		}); 
	}
}

function UpdateModelList2(id) {
	val = '';
	var manu = document.getElementById("supplier_associated_car_manufacturers");
	for(var i=0;i<manu.length;i++) {
		if(document.myform.supplier_associated_car_manufacturers[i].selected) {
			val += document.myform.supplier_associated_car_manufacturers[i].value+",";
		}
	}
	if (val!=''){
		var url = 'multiajaxmodel.php?manu='+val;
		new Ajax.Request(url, {   
			method: 'get', 
			onSuccess: function(transport) {   
				document.getElementById("loader1").style.display='none';
				document.getElementById("model").innerHTML = transport.responseText; 
			}, 
			onLoading: function(){document.getElementById("loader1").style.display='block';}
		}); 
	}
}

function UpdateModelList3(id) {
	val = '';
	var manu = document.getElementById("supplier_associated_car_manufacturers");
	for(var i=0;i<manu.length;i++) {
		if(document.myform.supplier_associated_car_manufacturers[i].selected) {
			val += document.myform.supplier_associated_car_manufacturers[i].value+",";
		}
	}
	if (val!=''){
		var url = 'multiajaxmodel2.php?manu='+val;
		new Ajax.Request(url, {   
			method: 'get', 
			onSuccess: function(transport) {   
				document.getElementById("loader1").style.display='none';
				document.getElementById("model").innerHTML = transport.responseText; 
			}, 
			onLoading: function(){document.getElementById("loader1").style.display='block';}
		}); 
	}
}


function selectallmodel(val) {
	var selectall = false;
	var mode = document.getElementById("club_associate_car_model");
	for(var i=0;i<mode.length;i++) {
		if(document.myform.club_associate_car_model[i].selected && document.myform.club_associate_car_model[i].value=="") {
			selectall = true;
		}
	}
	if (selectall) {
		for(var i=0;i<mode.length;i++) {
			document.myform.club_associate_car_model[i].selected = true;
		}
	}
}

function UpdateCarPartList(val,id) {
	if (val!=''){
		var url = 'ajaxcarparts.php?model='+val+"&id="+id;
		new Ajax.Request(url, {   
			method: 'get', 
			onSuccess: function(transport) {   
				document.getElementById("loader2").style.display='none';
				document.getElementById("carparts").innerHTML = transport.responseText; 
			}, 
			onLoading: function(){document.getElementById("loader2").style.display='block';}
		}); 
	}
}

function checkall() {
	var total = document.getElementById("totalparts").value;
	for(var i=0;i<total;i++){
		var part = eval('"part'+i+'"'); 
		document.getElementById(part).checked=true;
	}
}

function uncheckall() {
	var total = document.getElementById("totalparts").value;
	for(var i=0;i<total;i++){
		var part = eval('"part'+i+'"'); 
		document.getElementById(part).checked=false;
	}
}

function add_specialist_area()
{
	var specialisation = 2;
	if(document.myform.specialisation[0].checked)
		specialisation = 1;
	if(document.myform.specialisation[1].checked)
		specialisation = 2;
	if(specialisation==1 && document.myform.country_id.value=="") {
		alert("Please select country name.");
		document.myform.country_id.focus();
		return false;
	}
	if(document.myform.manufacturer_id.value=="") {
		alert("Please select manufacturer name.");
		document.myform.manufacturer_id.focus();
		return false;
	}
	if(document.myform.model_id.value=="") {
		alert("Please select model name.");
		document.myform.model_id.focus();
		return false;
	}
	return true;
}

function modelview(id){
	divid = eval('"view'+id+'"');
	if(document.getElementById(divid).style.display=='none') {
		new Effect.SlideDown(divid);
	}
	else{
		new Effect.SlideUp(divid);
	}
}



function showcountrysupplier(val) {
	if(val==1) {
		document.getElementById("country").style.display = "block";
		var country = document.getElementById("country_id");
		for(var i=0;i<country.length;i++) {
			if(document.myform.country_id[i].selected) {
				document.myform.country_id[i].selected=false;
			}
		}
		var selectbox = document.getElementById("manufacturer_id");
		for(var i=selectbox.options.length-1;i>=0;i--)
		{
			selectbox.remove(i);
		}
		var selectbox = document.getElementById("model_id");
		for(var i=selectbox.options.length-1;i>=0;i--)
		{
			selectbox.remove(i);
		}
	}
	else {
		document.getElementById("country").style.display = "none";
		UpdateManufacturerListByCountry(1);
		var selectbox = document.getElementById("model_id");
		for(var i=selectbox.options.length-1;i>=0;i--)
		{
			selectbox.remove(i);
		}
	}
}

function UpdateManufacturerListByCountry (ch) {
	val = '';
	var country = document.getElementById("country_id");
	for(var i=0;i<country.length;i++) {
		if(document.myform.country_id[i].selected) {
			val += document.myform.country_id[i].value+",";
		}
	}
    if (ch==1)
    {
		val ='all';
    }
	if (val!=''){
		var url = 'ajaxmultimanufacturer.php?countries='+val;
		new Ajax.Request(url, {   
			method: 'get', 
			onSuccess: function(transport) {   
				document.getElementById("loader1").style.display='none';
				document.getElementById("manufacturer").innerHTML = transport.responseText; 
			}, 
			onLoading: function(){document.getElementById("loader1").style.display='block';}
		}); 
	}
}

function UpdateModelListByManu () {
	val = '';
	var manu = document.getElementById("manufacturer_id");
	for(var i=0;i<manu.length;i++) {
		if(document.myform.manufacturer_id[i].selected) {
			val += document.myform.manufacturer_id[i].value+",";
		}
	}
	if (val!=''){
		var url = 'ajaxmultimodel.php?manu='+val;
		new Ajax.Request(url, {   
			method: 'get', 
			onSuccess: function(transport) {   
				document.getElementById("loader2").style.display='none';
				document.getElementById("model").innerHTML = transport.responseText; 
			}, 
			onLoading: function(){document.getElementById("loader2").style.display='block';}
		}); 
	}
}

function SelectEditSpecialistArea (val,id) {
	var div = document.getElementById("specialist");
	var old = document.myform.suppliertype.value;
	if (val==1 || val==2)
	{
		div.style.display = '';
		div.innerHTML = '<a href="supplier_manufacturer_popup.php" title="Choose Specialisation" onclick="return GB_showPage(\'Choose Specialisation\', \'../supplier_manufacturer_popup.php?username='+id+'\')" class="orange12">Choose Specialisation</a>';

	} else {
		div.innerHTML = "";
	}
}

function checkusername(val) {
	var url = 'ajaxuservalidate.php?username='+val;
	var msg = "";
	new Ajax.Request(url, {   
		method: 'get', 
		onSuccess: function(transport) {
			document.getElementById("usermessage2").innerHTML=transport.responseText;
		}, 
		onLoading: function(){document.getElementById("usermessage2").innerHTML='<img src="images/loader.gif" />';}
	});
}

function checkuseremail(val,type) {
	if(!val.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
	{
		document.getElementById("usermessage1").innerHTML="<img src='images/b_drop.png' align='left' /><font color='#ff0000'><b>e-mail format is not correct</b></font><input type='hidden' value='0' name='checkemail'>";
	} else {
		var url = 'ajaxuservalidate.php?email='+val+"&type="+type;
		var msg = "";
		new Ajax.Request(url, {   
			method: 'get', 
			onSuccess: function(transport) {
				document.getElementById("usermessage1").innerHTML=transport.responseText;
			}, 
			onLoading: function(){document.getElementById("usermessage1").innerHTML='<img src="images/loader.gif" />';}
		});
	}
}

function checkusergemail(val,type) {
	if(!val.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
	{
		document.getElementById("usermessage3").innerHTML="<img src='images/b_drop.png' align='left' /><font color='#ff0000'><b>e-mail format is not correct</b></font><input type='hidden' value='0' name='checkemail'>";
	} else {
		var url = 'ajaxuservalidate.php?gemail='+val+"&type="+type;
		var msg = "";
		new Ajax.Request(url, {   
			method: 'get', 
			onSuccess: function(transport) {
				document.getElementById("usermessage3").innerHTML=transport.responseText;
			}, 
			onLoading: function(){document.getElementById("usermessage3").innerHTML='<img src="images/loader.gif" />';}
		});
	}
}

function UpdateSupplierClicks(type,id) {
	var url = 'ajaxprofileclciks.php?type='+type+"&id="+id;
	new Ajax.Request(url, {   
		method: 'get', 
		onSuccess: function(transport) {
		
		}, 
		onLoading: function(){}
	});
}

function UpdateClubClicks(type,id) {
	var url = 'ajaxclubclciks.php?type='+type+"&id="+id;
	new Ajax.Request(url, {   
		method: 'get', 
		onSuccess: function(transport) {
		
		}, 
		onLoading: function(){}
	});
}

function UpdateEventClicks(type,id) {
	var url = 'ajaxeventclciks.php?type='+type+"&id="+id;
	new Ajax.Request(url, {   
		method: 'get', 
		onSuccess: function(transport) {
		
		}, 
		onLoading: function(){}
	});
}

function UpdateClassifiedClicks(type,id) {
	var url = 'ajaxclassifiedclciks.php?type='+type+"&id="+id;
	new Ajax.Request(url, {   
		method: 'get', 
		onSuccess: function(transport) {
		
		}, 
		onLoading: function(){}
	});
}

function checkpostcode1(val) {
	document.myform.user_postcode2.value = (document.myform.user_postcode2.value).toUpperCase();
	document.myform.user_postcode1.value = (document.myform.user_postcode1.value).toUpperCase();
	var post2 = document.myform.user_postcode2.value;
	if(post2!="") {
		if(!checkPostCode(val+" "+post2))
			document.getElementById("userpostcode").innerHTML="<img src='images/b_drop.png' align='left' /><font color='#ff0000'><b>Invalid Post Code format</b></font><input type='hidden' value='0' name='checkpost'>";
		else
			document.getElementById("userpostcode").innerHTML="<img src='images/active.gif' align='left' /><font color='#00ff00'><b>Post Code format is ok</b></font><input type='hidden' value='0' name='checkpost'>";
	}
}
function checkpostcode2(val) {
	document.myform.user_postcode2.value = (document.myform.user_postcode2.value).toUpperCase();
	document.myform.user_postcode1.value = (document.myform.user_postcode1.value).toUpperCase();
	var post1 = document.myform.user_postcode1.value;
	if(post1!="") {
		if(!checkPostCode(post1+" "+val))
			document.getElementById("userpostcode").innerHTML="<img src='images/b_drop.png' align='left' /><font color='#ff0000'><b>Invalid Post Code format</b></font><input type='hidden' value='0' name='checkpost'>";
		else
			document.getElementById("userpostcode").innerHTML="<img src='images/active.gif' align='left' /><font color='#00ff00'><b>Post Code format is ok</b></font><input type='hidden' value='0' name='checkpost'>";
	}
}


function checkclubpostcode1(val) {
	document.myform.club_postcode1.value = (document.myform.club_postcode1.value).toUpperCase();
	document.myform.club_postcode2.value = (document.myform.club_postcode2.value).toUpperCase();
	var post2 = document.myform.club_postcode2.value;
	if(post2!="") {
		if(!checkPostCode(val+" "+post2))
			document.getElementById("userpostcode").innerHTML="<img src='images/b_drop.png' align='left' /><font color='#ff0000'><b>Invalid Post Code format</b></font><input type='hidden' value='0' name='checkpost'>";
		else
			document.getElementById("userpostcode").innerHTML="<img src='images/active.gif' align='left' /><font color='#00ff00'><b>Post Code format is ok</b></font><input type='hidden' value='0' name='checkpost'>";
	}	
}
function checkclubpostcode2(val) {
	document.myform.club_postcode1.value = (document.myform.club_postcode1.value).toUpperCase();
	document.myform.club_postcode2.value = (document.myform.club_postcode2.value).toUpperCase();
	var post1 = document.myform.club_postcode1.value;
	if(post1!="") {
		if(!checkPostCode(post1+" "+val))
			document.getElementById("userpostcode").innerHTML="<img src='images/b_drop.png' align='left' /><font color='#ff0000'><b>Invalid Post Code format</b></font><input type='hidden' value='0' name='checkpost'>";
		else
			document.getElementById("userpostcode").innerHTML="<img src='images/active.gif' align='left' /><font color='#00ff00'><b>Post Code format is ok</b></font><input type='hidden' value='0' name='checkpost'>";
	}
}


function checksuppostcode1(val) {
	document.myform.supplier_postcode1.value = (document.myform.supplier_postcode1.value).toUpperCase();
	document.myform.supplier_postcode2.value = (document.myform.supplier_postcode2.value).toUpperCase();
	var post2 = document.myform.supplier_postcode2.value;
	if(post2!="") {
		if(!checkPostCode(val+" "+post2))
			document.getElementById("userpostcode").innerHTML="<img src='images/b_drop.png' align='left' /><font color='#ff0000'><b>Invalid Post Code format</b></font><input type='hidden' value='0' name='checkpost'>";
		else
			document.getElementById("userpostcode").innerHTML="<img src='images/active.gif' align='left' /><font color='#00ff00'><b>Post Code format is ok</b></font><input type='hidden' value='0' name='checkpost'>";
	}
}
function checksuppostcode2(val) {
	document.myform.supplier_postcode1.value = (document.myform.supplier_postcode1.value).toUpperCase();
	document.myform.supplier_postcode2.value = (document.myform.supplier_postcode2.value).toUpperCase();
	var post1 = document.myform.supplier_postcode1.value;
	if(post1!="") {
		if(!checkPostCode(post1+" "+val))
			document.getElementById("userpostcode").innerHTML="<img src='images/b_drop.png' align='left' /><font color='#ff0000'><b>Invalid Post Code format</b></font><input type='hidden' value='0' name='checkpost'>";
		else
			document.getElementById("userpostcode").innerHTML="<img src='images/active.gif' align='left' /><font color='#00ff00'><b>Post Code format is ok</b></font><input type='hidden' value='0' name='checkpost'>";
	}
}

function checkuseremailbylogin(val,username) {
	if(!val.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
	{
		document.getElementById("usermessage1").innerHTML="<img src='images/b_drop.png' align='left' /><font color='#ff0000'><b>e-mail format is not correct</b></font><input type='hidden' value='0' name='checkemail'>";
	} else {
		var url = 'ajaxuservalidate.php?log=1&email='+val+"&username="+username;
		var msg = "";
		new Ajax.Request(url, {   
			method: 'get', 
			onSuccess: function(transport) {
				document.getElementById("usermessage1").innerHTML=transport.responseText;
			}, 
			onLoading: function(){document.getElementById("usermessage1").innerHTML='<img src="images/loader.gif" />';}
		});
	}
}

function checkusergemailbylogin(val,username) {
	if(!val.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
	{
		document.getElementById("usermessage2").innerHTML="<img src='images/b_drop.png' align='left' /><font color='#ff0000'><b>e-mail format is not correct</b></font><input type='hidden' value='0' name='checkgemail'>";
	} else {
		var url = 'ajaxuservalidate.php?log=1&gemail='+val+"&username="+username;
		var msg = "";
		new Ajax.Request(url, {   
			method: 'get', 
			onSuccess: function(transport) {
				document.getElementById("usermessage2").innerHTML=transport.responseText;
			}, 
			onLoading: function(){document.getElementById("usermessage2").innerHTML='<img src="images/loader.gif" />';}
		});
	}
}

function checkPostCode(val){
	if((val.toUpperCase().match(/GIR 0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]|[A-HK-Y][0-9]([0-9]|[ABEHMNPRV-Y]))|[0-9][A-HJKS-UW]) [0-9][ABD-HJLNP-UW-Z]{2}/))){
		return true;
	}else{
		return false;
	}
}

function removemessageboard() {
	var url = 'removemessageboard.php';
	var msg = "";
	document.getElementById("messageboard").innerHTML='<img src="images/loader.gif" />';
	new Ajax.Updater("messageboard",url);
}

function supplier_track() {
	   if(document.form1.start_date.value=="")
	   {
		   alert("Please choose start date");
		   document.form1.start_date.focus();
		   return false;
	   }
	   if(document.form1.end_date.value=="")
	   {
		   alert("Please choose end date");
		   document.form1.end_date.focus();
		   return false;
	   }
	    if(!(document.form1.track_type[0].checked)&&!(document.form1.track_type[1].checked)&&!(document.form1.track_type[2].checked))
	   {
		   alert("Please choose tracking for");
		   return false;
	   }
	   return true;
 }

 function event_track() {
	   if(document.form1.event_id.value=="")
	   {
		   alert("Please choose a event.");
		   return false;
	   }
	   if(document.form1.start_date.value=="")
	   {
		   alert("Please choose start date");
		   document.form1.start_date.focus();
		   return false;
	   }
	   if(document.form1.end_date.value=="")
	   {
		   alert("Please choose end date");
		   document.form1.end_date.focus();
		   return false;
	   }
	    if(!(document.form1.track_type[0].checked)&&!(document.form1.track_type[1].checked)&&!(document.form1.track_type[2].checked))
	   {
		   alert("Please choose tracking for");
		   return false;
	   }
	   return true;
 }

function classified_track() {
	   if(document.form1.start_date.value=="")
	   {
		   alert("Please choose start date");
		   document.form1.start_date.focus();
		   return false;
	   }
	   if(document.form1.end_date.value=="")
	   {
		   alert("Please choose end date");
		   document.form1.end_date.focus();
		   return false;
	   }
	    if(!(document.form1.track_type[0].checked)&&!(document.form1.track_type[1].checked))
	   {
		   alert("Please choose tracking for");
		   return false;
	   }
	   return true;
 }

function addownedcar() {
	if(document.mycar.nickname.value=="") {
		alert("Please enter car nickname.");
		document.mycar.nickname.focus();
		return false;
	}
	if(document.mycar.manufacturer.value=="") {
		alert("Please choose one manufacturer name.");
		document.mycar.manufacturer.focus();
		return false;
	}
	if(document.mycar.model_id.value=="") {
		alert("Please choose one model name.");
		document.mycar.model_id.focus();
		return false;
	}
}

function adddonorcar() {
	if(document.mycar.nickname.value=="") {
		alert("Please enter car nickname.");
		document.mycar.nickname.focus();
		return false;
	}
	if(document.mycar.car_owned.value=="") {
		alert("Please choose one owned car name.");
		document.mycar.car_owned.focus();
		return false;
	}
	if(document.mycar.manufacturer.value=="") {
		alert("Please choose one manufacturer name.");
		document.mycar.manufacturer.focus();
		return false;
	}
	if(document.mycar.model_id.value=="") {
		alert("Please choose one model name.");
		document.mycar.model_id.focus();
		return false;
	}
}

function addcar() {
	if(document.mycar.manufacturer.value=="") {
		alert("Please choose one manufacturer name.");
		document.mycar.manufacturer.focus();
		return false;
	}
	if(document.mycar.model_id.value=="") {
		alert("Please choose one model name.");
		document.mycar.model_id.focus();
		return false;
	}
}

function ConfirmCarImageDelete(id)
{
	if(confirm("Are you sure to delete Image?")) {
		document.location = "edit_owned_car.php?id="+id+"&action=image";
	}
}

function AddCarModelList(val,type) {
	if (val!=''){
		var url = 'ajaxcarmodel.php?manu='+val+"&type="+type;
		new Ajax.Request(url, {   
			method: 'get', 
			onSuccess: function(transport) {   
				document.getElementById("loader").style.display='none';
				document.getElementById("model").innerHTML = transport.responseText; 
			}, 
			onLoading: function(){document.getElementById("loader").style.display='block';}
		}); 
	}
}

function AddCarModelYear(val) {
	if (val!=''){
		var url = 'ajaxcarmodelyear.php?model='+val;
		new Ajax.Request(url, {   
			method: 'get', 
			onSuccess: function(transport) {   
				document.getElementById("loader1").style.display='none';
				document.getElementById("year").innerHTML = transport.responseText; 
			}, 
			onLoading: function(){document.getElementById("loader1").style.display='block';}
		}); 
	}
}


function ClassifiedModelList(val,name,loader) {
	var load = eval('"loader'+loader+'"');
	var model = eval('"model'+loader+'"');
	if (val!=''){
		var url = 'classified_ajaxcarmodel.php?manu='+val+'&name='+name+'&loader='+loader;
		new Ajax.Request(url, {   
			method: 'get', 
			onSuccess: function(transport) {   
				document.getElementById(load).style.display='none';
				document.getElementById(model).innerHTML = transport.responseText; 
			}, 
			onLoading: function(){document.getElementById(load).style.display='block';}
		}); 
	}
}

function ClassifiedPartList(val) {
	if (val!=''){
		var url = 'classified_ajaxcarpart.php?manu='+val;
		new Ajax.Request(url, {   
			method: 'get', 
			onSuccess: function(transport) {   
				document.getElementById("loader2").style.display='none';
				document.getElementById("part").innerHTML = transport.responseText; 
			}, 
			onLoading: function(){document.getElementById("loader2").style.display='block';}
		}); 
	}
}

function checkclassifiedpostcode1(val) {
	document.myform.classified_postcode1.value = (document.myform.classified_postcode1.value).toUpperCase();
	document.myform.classified_postcode2.value = (document.myform.classified_postcode2.value).toUpperCase();
	var post2 = document.myform.classified_postcode2.value;
	if(post2!="") {
		if(!checkPostCode(val+" "+post2))
			document.getElementById("userpostcode").innerHTML="<img src='images/b_drop.png' align='left' /><font color='#ff0000'><b>Invalid Post Code format</b></font><input type='hidden' value='0' name='checkpost'>";
		else
			document.getElementById("userpostcode").innerHTML="<img src='images/active.gif' align='left' /><font color='#00ff00'><b>Post Code format is ok</b></font><input type='hidden' value='0' name='checkpost'>";
	}	
}
function checkclassifiedpostcode2(val) {
	document.myform.classified_postcode1.value = (document.myform.classified_postcode1.value).toUpperCase();
	document.myform.classified_postcode2.value = (document.myform.classified_postcode2.value).toUpperCase();
	var post1 = document.myform.classified_postcode1.value;
	if(post1!="") {
		if(!checkPostCode(post1+" "+val))
			document.getElementById("userpostcode").innerHTML="<img src='images/b_drop.png' align='left' /><font color='#ff0000'><b>Invalid Post Code format</b></font><input type='hidden' value='0' name='checkpost'>";
		else
			document.getElementById("userpostcode").innerHTML="<img src='images/active.gif' align='left' /><font color='#00ff00'><b>Post Code format is ok</b></font><input type='hidden' value='0' name='checkpost'>";
	}
}
function showDesc(divid,tagid){
var i;
var today = new Date();
today.setTime( today.getTime() );
expires = 30 * 1000 * 60 * 60 * 24;
var expires_date = new Date( today.getTime() + (expires) );

	for(i=1;i<6;i++){
		document.getElementById('country'+i).style.display='none';
		document.getElementById('anc'+i).className = 'nav_button';
	}
	document.getElementById('country'+divid).style.display='';
	if(tagid=='anc1'){
	document.getElementById('anc1').className = 'testanchor';
	document.cookie = "search_type=1; expires="+expires_date.toGMTString()+";";
	}
	if(tagid=='anc2'){
	document.getElementById('anc2').className = 'testanchor';
	document.cookie = "search_type=2; expires="+expires_date.toGMTString()+";";
	}
	if(tagid=='anc3'){
	document.getElementById('anc3').className = 'testanchor';
	document.cookie = "search_type=3; expires="+expires_date.toGMTString()+";";
	}
	if(tagid=='anc4'){
	document.getElementById('anc4').className = 'testanchor';
	document.cookie = "search_type=4; expires="+expires_date.toGMTString()+";";
	}
	if(tagid=='anc5'){
	document.getElementById('anc5').className = 'testanchor';
	document.cookie = "search_type=5; expires="+expires_date.toGMTString()+";";
	}
}

function newsletter_subscribe() {
	var name = document.newsletter.news_name.value;
    if(name=="" || name=="Enter Your Name")
    {
		alert("The enter your name.");
		document.newsletter.news_name.focus();
		return false;
    }
	var email = document.newsletter.news_email.value;
    if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
    {
		alert("The e-mail format is not correct.");
		document.newsletter.news_email.focus();
		return false;
    }
	var news = document.getElementById("news");
	
	var url = 'newsletter.php?email='+email+'&name='+name;
	new Ajax.Request(url, {   
		method: 'get', 
		onSuccess: function(transport) {   
			news.innerHTML = transport.responseText; 
		}, 
		onLoading: function(){news.innerHTML ="<img src='images/loader.gif' />";}
	});

	return false;
}

function pageurl(id,action) {
	var argList = "?";

    if(window.location != null && window.location.search.length > 1) {
        var urlParms = window.location.search.substring(1);
        var argPairs = urlParms.split('&');

        for(var i = 0; i < argPairs.length; i++) {
            var pos = argPairs[i].indexOf('=')

            if(pos == -1)
                continue;
            else {
                var argName = argPairs[i].substring(0, pos);
                var argVal = argPairs[i].substring(pos + 1);

                if(argVal.indexOf('+') != -1)
                    argVal = argVal.replace(/\+/g, ' ');
				if(argName!="id" && argName != "action") {
					argList += argName+"="+unescape(argVal);
					argList += "&";
				}
            }
        }
    }
	argList += "id="+id+"&action="+action;
    
    window.location.href = argList;
}
