jQuery().ready(function(){
		var wizard = $("#wizard").accordion({
			header: '.title',
			event: false,
			autoheight: false 

		});


		
		var wizardButtons = $([]);
		$("div.title", wizard).each(function(index) {
			wizardButtons = wizardButtons.add($(this)
			.next()
			.children(":button")
			.filter(".next, .previous")
			.click(function() {
				wizard.accordion("activate", index + ($(this).is(".next") ? 1 : -1))
			}));
		});
		
		// bind to change event of select to control first and seconds accordion
		// similar to tab's plugin triggerTab(), without an extra method
		var accordions = jQuery('#list1a, #list1b, #list2, #list3, #navigation, #wizard');
		
		jQuery('#switch select').change(function() {
			accordions.accordion("activate", this.selectedIndex-1 );
		});
		jQuery('#close').click(function() {
			accordions.accordion("activate", -1);
		});
		jQuery('#switch2').change(function() {
			accordions.accordion("activate", this.value);
		});
		jQuery('#enable').click(function() {
			accordions.accordion("enable");
		});
		jQuery('#disable').click(function() {
			accordions.accordion("disable");
		});
		jQuery('#remove').click(function() {
			accordions.accordion("destroy");
			wizardButtons.unbind("click");
		});
	});




             


		function SetasShipping(isChecked) {				

		if (isChecked) {	

												document.getElementById('txt_shipping_firstname').value = window.document.billing.txtfirstname.value;
												document.getElementById('txt_shipping_lastname').value = window.document.billing.txtlastname.value;
												document.getElementById('txt_shipping_Address1').value =window.document.billing.txtAddress.value;
												document.getElementById('txt_shipping_Address2').value = window.document.billing.txtAddress2.value;
												document.getElementById('txt_shipping_city').value =window.document.billing.txtCity.value;
												document.getElementById('txt_shipping_zip').value =window.document.billing.txtZip.value;
												document.getElementById('txt_shipping_state').value =window.document.billing.txtState.value;
		
			}
		}

		function hidediv() {
		
		document.getElementById('paypal_button').style.visibility = 'hidden'; 
		document.getElementById('normal_checkout').style.visibility = 'visible'; 
		}

		function showdiv() {
		
		document.getElementById('paypal_button').style.visibility = 'visible'; 
		document.getElementById('normal_checkout').style.visibility = 'hidden'; 
		
		}

		function register_redirect() {
		
		window.location = "http://www.masterdealers.com/customer/register";
		
		}

		function check() {
		
		document.getElementById('paypal_button').style.visibility = 'hidden'; 
		
		}

		
		function Form1_Validator(theForm)
		{
		var alertsay = "";
		if (theForm.txtfirstname.value == "")
		{
		alertsay = alertsay+"Please enter First name.\n";
		theForm.txtfirstname.focus();
		document.getElementById("txtfirstname").style.borderColor="#FF0000";
		
		// return (false);
		}
		if (theForm.txtlastname.value == "")
		{
		alertsay = alertsay+"Please enter last name.\n";
		theForm.txtlastname.focus();
		document.getElementById("txtlastname").style.borderColor="#FF0000";
		
		}
		
		if (theForm.txtEmail.value == "")
		{
		
		alertsay = alertsay+"Please enter Email address.\n";
		theForm.txtEmail.focus();
		document.getElementById("txtEmail").style.borderColor="#FF0000";
		
		}
		
		if (theForm.txtAddress.value == "")
		{
		
		alertsay = alertsay+"Please enter address 1.\n";
		theForm.txtAddress.focus();
		document.getElementById("txtAddress").style.borderColor="#FF0000";
		
		}
		if (theForm.txtCity.value == "")
		{
		alertsay = alertsay+"Please enter city name.\n";
		theForm.txtCity.focus();
		document.getElementById("txtCity").style.borderColor="#FF0000";
		
		}
		if (theForm.txtZip.value == "")
		{
		alertsay = alertsay+"Please enter zipcode.\n";
		theForm.txtZip.focus();
		document.getElementById("txtZip").style.borderColor="#FF0000";
		
		}
		
		
		/*if (theForm.txtAddress2.value == "")
		{
		alertsay = alertsay+"Please enter Address 2.\n";
		theForm.txtAddress2.focus();
		document.getElementById("txtAddress2").style.borderColor="#FF0000";
		
		}*/
		if (theForm.txtState.value == "")
		{
		alertsay = alertsay+"Please enter state.\n";
		theForm.txtState.focus();
		document.getElementById("txtState").style.borderColor="#FF0000";
		
		}
		

		if(alertsay) {
		document.getElementById("bil").innerHTML='';
		alert(alertsay);
		return (false);
		}
		else {
		document.getElementById("bil").innerHTML='';
		// theForm.txt_shipping_firstname.focus();
		loadXMLDoc();
		return (false);
		// return(true);
		}
		
		}
		
		function loadXMLDoc()
		{

		var xmlhttp;

		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
		}
		else
		{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function()
		{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
		document.getElementById("bil").innerHTML=xmlhttp.responseText;
		
		if(xmlhttp.responseText) {
		
		document.getElementById("con_bil").style.visibility = 'visible';
		document.getElementById("bil_status").className = 'title error';
		}
		
		}
		else {
		document.getElementById("bil").innerHTML= '<img src="http://www.masterdealers.com/images/ajax-loader.gif"  />';
		}
		}
		
		var txtfirstname =  document.getElementById("txtfirstname").value;
		var txtlastname =  document.getElementById("txtlastname").value;
		var txtAddress =  document.getElementById("txtAddress").value;
		var txtAddress2 =  document.getElementById("txtAddress2").value;
		var txtEmail =  document.getElementById("txtEmail").value;
		var txtState =  document.getElementById("txtState").value;
		var txtCity =  document.getElementById("txtCity").value;
		var txtZip =  document.getElementById("txtZip").value;



// var e = document.getElementById("country");
// 		
// 		var country = e.options[e.selectedIndex].value;




		//var txtAddress2 =  document.getElementById("txtAddress2").value;
		xmlhttp.open("POST","http://www.masterdealers.com/checkout/billing",true);
		xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		xmlhttp.send("txtfirstname="+txtfirstname+"&txtlastname="+txtlastname+"&txtAddress="+txtAddress+"&txtAddress2="+txtAddress2+"&txtState="+txtState+"&txtCity="+txtCity+"&txtZip="+txtZip+"&txtEmail="+txtEmail);
		// xmlhttp.send();
		}

		
		function Ajax_call()
		{
		var xmlhttp;
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
		}
		else
		{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function()
		{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
		document.getElementById("ship").innerHTML=xmlhttp.responseText;
		
		if(xmlhttp.responseText) {
		
		document.getElementById("con_ship").style.visibility = 'visible';
		
		document.getElementById("ship_status").className = 'title error';
		}
		
		}
		
		else {
		document.getElementById("ship").innerHTML= '<img src="http://www.masterdealers.com/images/ajax-loader.gif"  />';
		}
		}
		
		var txt_shipping_firstname =  document.getElementById("txt_shipping_firstname").value;
		var txt_shipping_lastname =  document.getElementById("txt_shipping_lastname").value;
		var txt_shipping_Address1 =  document.getElementById("txt_shipping_Address1").value;
		var txt_shipping_Address2 =  document.getElementById("txt_shipping_Address2").value;
		var txt_shipping_state =  document.getElementById("txt_shipping_state").value;
		var txt_shipping_city =  document.getElementById("txt_shipping_city").value;
		var txt_shipping_zip =  document.getElementById("txt_shipping_zip").value;
		xmlhttp.open("POST","http://www.masterdealers.com/checkout/shipping",true);
		xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		xmlhttp.send("txt_shipping_firstname="+txt_shipping_firstname+"&txt_shipping_lastname="+txt_shipping_lastname+"&txt_shipping_Address1="+txt_shipping_Address1+"&txt_shipping_Address2="+txt_shipping_Address2+"&txt_shipping_state="+txt_shipping_state+"&txt_shipping_city="+txt_shipping_city+"&txt_shipping_zip="+txt_shipping_zip);
		// xmlhttp.send();
		}


		
		function shippingrate2()
		{
		
		document.getElementById("ship_method").innerHTML= '';
		
		var e = document.getElementById("states");
		
		var state = e.options[e.selectedIndex].value;
		
		var zipcode =  document.getElementById("zipcode").value;
		
		var str =  document.getElementById("method").value;
		
		
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
		}
		else
		{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function()
		{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
		document.getElementById("ship_method").innerHTML='<div class="successBar">Updated shipping cost. Shipping cost is  '+xmlhttp.responseText+'</div>';
		
		document.getElementById("inreview").innerHTML='$'+xmlhttp.responseText;
		
		//  document.getElementById("estimate").style.visibility = 'hidden';
		
		document.getElementById("ship_type").className = 'title error';
		
		}
		else {
		document.getElementById("ship_method").innerHTML= '<img src="http://www.masterdealers.com/images/ajax-loader.gif"  />';
		}
		}
		
		xmlhttp.open("POST","http://www.masterdealers.com/checkout/calcUPSShippingRate2",true);
		xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		xmlhttp.send("method="+str+"&states="+state+"&zipcode="+zipcode);
		
		}

		
		function shippingrate(str)
		{
		
		document.getElementById("ship_method").innerHTML= '';
		
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
		}
		else
		{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function()
		{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
		document.getElementById("ship_method").innerHTML=xmlhttp.responseText;
		}
		else {
		document.getElementById("ship_method").innerHTML= '<img src="http://www.masterdealers.com/images/ajax-loader.gif"  />';
		}
		}
		
		xmlhttp.open("POST","http://www.masterdealers.com/checkout/shippingrate",true);
		xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		xmlhttp.send("method="+str);
		}
		
		function validate_shippingrate2(theForm) {
		
		var alertsay = "";
		
		if (theForm.states.value == "")
		{
		alertsay = alertsay+"Please enter state name.\n";
		theForm.states.focus();
		document.getElementById("states").style.borderColor="#FF0000";
		
		// return (false);
		}
		if (theForm.zipcode.value == "")
		{
		alertsay = alertsay+"Please enter zip code.\n";
		theForm.zipcode.focus();
		document.getElementById("zipcode").style.borderColor="#FF0000";
		
		}
		
		if(alertsay) {
		
		document.getElementById("ship_method").innerHTML='';
		
		alert(alertsay);
		
		return (false);
		
		}
		else {
		
		document.getElementById("ship_method").innerHTML='';
		
		shippingrate2();
		
		return (false);
		// return(true);
		}
		
		
		}
		
		function Form2_Validator(theForm)
		{
		var alertsay = "";
		if (theForm.txt_shipping_firstname.value == "")
		{
		alertsay = alertsay+"Please enter First name.\n";
		theForm.txt_shipping_firstname.focus();
		document.getElementById("txt_shipping_firstname").style.borderColor="#FF0000";
		
		// return (false);
		}
		if (theForm.txt_shipping_lastname.value == "")
		{
		alertsay = alertsay+"Please enter last name.\n";
		theForm.txt_shipping_lastname.focus();
		document.getElementById("txt_shipping_lastname").style.borderColor="#FF0000";
		
		}
		
		if (theForm.txt_shipping_Address1.value == "")
		{
		
		alertsay = alertsay+"Please enter address.\n";
		theForm.txt_shipping_Address1.focus();
		document.getElementById("txt_shipping_Address1").style.borderColor="#FF0000";
		
		}
		/*if (theForm.txt_shipping_Address2.value == "")
		{
		alertsay = alertsay+"Please enter address 2.\n";
		theForm.txt_shipping_Address2.focus();
		document.getElementById("txt_shipping_Address2").style.borderColor="#FF0000";
		
		}*/
		if (theForm.txt_shipping_state.value == "")
		{
		alertsay = alertsay+"Please enter state.\n";
		theForm.txt_shipping_state.focus();
		document.getElementById("txt_shipping_state").style.borderColor="#FF0000";
		
		}
		
		if (theForm.txt_shipping_city.value == "")
		{
		alertsay = alertsay+"Please enter city.\n";
		theForm.txt_shipping_city.focus();
		document.getElementById("txt_shipping_city").style.borderColor="#FF0000";
		
		}
		
		if (theForm.txt_shipping_zip.value == "")
		{
		alertsay = alertsay+"Please enter zipcode.\n";
		theForm.txt_shipping_zip.focus();
		document.getElementById("txt_shipping_zip").style.borderColor="#FF0000";
		
		}
		
		if(alertsay) {
		document.getElementById("ship").innerHTML='';
		alert(alertsay);
		return (false);
		}
		else {
		// theForm.txt_shipping_firstname.focus();
		document.getElementById("ship").innerHTML='';
		Ajax_call();
		return (false);
		// return(true);
		}
		
		
		}



		/*     select all check box in wishlist  */

		
		function checkAll(theForm)
		{
		
		if(theForm.wish_chk.checked) {
		
		
		for (i=0; i<theForm.elements.length; i++) {
			if (theForm.elements[i].name=='cart_pro[]')
			theForm.elements[i].checked = 1;
		}
		
		} else {
		
		
		for (i=0; i<theForm.elements.length; i++) {
			if (theForm.elements[i].name=='cart_pro[]')
			theForm.elements[i].checked = 0;
		
			}
		
		
		}
		
		
		}
		
		function validate_paymentmethod(theForm) {
		
		var alertsay = "";
		
		if (theForm.payment.value == "")
		{
		alertsay = alertsay+"Please enter payment method.\n";
		
		}
		
		if(alertsay) {
		
		
		alert(alertsay);
		
		return (false);
		
		}
		else {
		
		
		pay_method();
		
		return (false);
		// return(true);
		}
		
		
		}



		
		function pay_method()
		{
		
		document.getElementById("pay").innerHTML= '';
		
		var selection =  document.paymethod.payment;
		
		for (i=0; i<selection.length; i++) { 
		
		if (selection[i].checked == true)
		var payment = selection[i].value;
		
		}
		
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
		}
		else
		{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function()
		{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
		document.getElementById("pay").innerHTML='<div class="successBar">Updated payment method. Payment method is  '+xmlhttp.responseText+'</div>';
		
		document.getElementById("paytype").innerHTML= xmlhttp.responseText;
		
		
		//  document.getElementById("estimate").style.visibility = 'hidden';
		
		//  document.getElementById("ship_type").className = 'title error';
		
		}
		else {
		document.getElementById("pay").innerHTML= '<img src="http://www.masterdealers.com/images/ajax-loader.gif"  />';
		}
		}
		
		xmlhttp.open("POST","http://www.masterdealers.com/checkout/payment_method",true);
		
		xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		
		xmlhttp.send("payment="+payment);
		
		}

		
		function getState(countryId)
		{
		
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
		}
		else
		{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function()
		{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
		
		document.getElementById('statediv').innerHTML=xmlhttp.responseText;
		
		} else {
		
				}
		}
		
		xmlhttp.open("POST","http://www.masterdealers.com/checkout/getstate",true);
		
		xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
		
		xmlhttp.send("country="+countryId);
		
		}

