function setShipMethod(id) {
	
	var delivdate;
	var shipId;
	var stOverNight;
	var stPrioNight;
	var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
	var is_safari = navigator.userAgent.toLowerCase().indexOf('safari') > -1;
	var s2day;
	var state;
	var shipState;
	var sonFlag;
	
	if(id > 0){
		shipId=  'id-aw_deliverydate_date-' + id;
		
		s2day = 's_method_' + id + '_fedex_FEDEX2DAY';
		stPrioNight = 's_method_' + id + '_fedex_PRIORITYOVERNIGHT';
		stOverNight  = 's_method_' + id + '_fedex_STANDARDOVERNIGHT';
		li2day = 's_' + id + '_fedex_FEDEX2DAY';
		liPrioNight = 's_' + id + '_fedex_PRIORITYOVERNIGHT';
		liOverNight  = 's_' + id + '_fedex_STANDARDOVERNIGHT';
		shipState = 'shipping-destination-state_'+ id;
		sonFlag = 'standard_on_flag_'+ id;
	}
	else{
		shipId =  'id-aw_deliverydate_date';
		
		s2day =  's_method_fedex_FEDEX2DAY';
		stPrioNight = 's_method_fedex_PRIORITYOVERNIGHT';
		stOverNight = 's_method_fedex_STANDARDOVERNIGHT';
		li2day = 's_fedex_FEDEX2DAY';
		liPrioNight = 's_fedex_PRIORITYOVERNIGHT';
		liOverNight  = 's_fedex_STANDARDOVERNIGHT';
		shipState = 'shipping-destination-state';
		sonFlag = 'standard_on_flag';
	}
	
	state = document.getElementById(shipState).value;
	var stOverNightflag = document.getElementById(sonFlag).value;
	
	delivdate = document.getElementById(shipId).value;
	myDate=new Date(eval('"' + delivdate + '"'))
	var day = myDate.getDay();
	if((is_chrome || is_safari) && day == 6)
		day = 0;
	
		if(day == 0){
			//alert(stOverNightflag);
			if(state == "Hawaii"){
				
				document.getElementById(stPrioNight).removeAttribute("checked");
				document.getElementById(liPrioNight).style.display =  "none";
				document.getElementById(s2day).checked =  "checked";
				document.getElementById(li2day).style.display =  "block";
				
			}else{
				if(stOverNightflag == 1){
					document.getElementById(stPrioNight).checked =  "checked";
					document.getElementById(stOverNight).removeAttribute("checked");
					document.getElementById(liOverNight).style.display =  "none";
					document.getElementById(liPrioNight).style.display =  "block";
				}else{
					document.getElementById(stPrioNight).checked =  "checked";
					document.getElementById(liPrioNight).style.display =  "block";
				}
				
			}
	
		}
		else{
			//alert(stOverNightflag);
			if(state == "Hawaii"){
				//alert("here");
				document.getElementById(stPrioNight).checked =  "checked";
				document.getElementById(liPrioNight).style.display =  "block";
				document.getElementById(s2day).removeAttribute("checked");
				document.getElementById(li2day).style.display =  "none";
			}else{
				if(stOverNightflag == 1){
					document.getElementById(stPrioNight).removeAttribute("checked");
					document.getElementById(stOverNight).checked =  "checked";
					document.getElementById(liOverNight).style.display =  "block";
					document.getElementById(liPrioNight).style.display =  "none";
				}else{
					document.getElementById(stPrioNight).checked =  "checked";
					document.getElementById(liPrioNight).style.display =  "block";
				}
			}
		}
	return true;
}
var jqmin = jQuery.noConflict();

	

      
jqmin(document).ready(function($) {
	//var rec_name = document.getElementById('prod-options').value;

	//if(rec_name != 'product')
		//FSFaddPrice();
	

  		

	var popupStatus2 = 0;
	//loading popup with jQuery magic!
	function loadPopup2(){
	    //loads popup only if it is disabled    

	    if(popupStatus2==0){
	        $("#bodyWrap2").css({
	            "opacity": "0.5"
	        });
			
			//if($('input[name="onepageLost"]').val() == "yes") $('p .back-link a').hide(); else $('p .back-link a').show();
			
	        $("#bodyWrap2").fadeIn("slow");
	        $("#contentWrap2").fadeIn("slow");
	        popupStatus2 = 1;
	    }
	}

	
	function disablePopup2(){
	    //disables popup only if it is enabled
	    if(popupStatus2==1){
	        $("#bodyWrap2").fadeOut("slow");
	        $("#contentWrap2").fadeOut("slow");
	        popupStatus2 = 0;
	    }
	}

	//centering popup
	function centerPopup2(){
	    //request data for centering
	    var windowWidth = document.documentElement.clientWidth;
	    var windowHeight = document.documentElement.clientHeight;
	    var popupHeight = $("#contentWrap2").height();
	    var popupWidth = $("#contentWrap2").width();
	    
	    //centering
	    $("#contentWrap2").css({
	        "position": "fixed",
	        "top": windowHeight/2-popupHeight/2,
	        "left": windowWidth/2-popupWidth/2
	    });

	    
	    //only need force for IE6
		
	    $("#bodyWrap2").css({
	        "height": windowHeight
	    });
		
	}
    
    
    
    
   
	$(window).bind('beforeunload', function() {
        $(".formcontent").hide();
		$(".lostForm").hide();
		$(".change_add").hide();
		$(".select_bill").hide();
			 $(".imgloader").show();
			 centerPopup2();
	});
	
		//Code for Delivery Date With Shipping on Saturdays by Leny

	$(".btShipMethod").click(function(){
		var delivdate;
		delivdate = $("#id-aw_deliverydate_date").val();
		var state = $("#shipping-destination-state").val();
		myDate=new Date(eval('"' + delivdate + '"'))
		
		if(myDate.getDay() == 0){
			if(state == "Hawaii"){
				$("#s_method_fedex_PRIORITYOVERNIGHT").removeAttr("checked");
				$("#s_method_fedex_STANDARDOVERNIGHT").removeAttr("checked");
				$("#s_method_fedex_FEDEX2DAY").attr("checked", "checked");
			
			}else{
				$("#s_method_fedex_PRIORITYOVERNIGHT").attr("checked", "checked");
				$("#s_method_fedex_STANDARDOVERNIGHT").removeAttr("checked");
				$("#s_method_fedex_FEDEX2DAY").removeAttr("checked");
			}

		}
	});
	
	
	$("#cemail_address").blur(function(){
		var cemail = $("#cemail_address").val();
		var email = $("#email_address").val();
	if( cemail != email){
		$(".email-error").attr("style" , 'color:#8C3731');
		$(".email-error").show('slow');
		$(".email-error").html(' Email Address Should Be Identical. ');
		$("#email_address").focus();
		return false;
	}
	else
		$(".email-error").hide('slow');
		return true;
	});
	$("#btn-register").click(function(){

		var cemail = $("#cemail_address").val();
		var email = $("#email_address").val();
		
		if($("#showadd").val() == 'add'){
		var len = ($("#zip").val().length );
		if(len != 5){
			$(".zip-error").attr("style" , 'color:#8C3731');
			$(".zip-error").show('slow');
			
			$(".zip-error").html('Please enter 5 characters for Zip Code. ');
			$("#zip").focus();
			return false;
	    	}
		}
	if(email != cemail){
		$(".email-error").attr("style" , 'color:#8C3731');
			$(".email-error").show('slow');
			$(".email-error").html('Emails should be identical. ');
			$("#email_address").focus();
			return false;
		}
		else {
			$(".email-error").hide('slow');
			$(".zip-error").hide('slow');
			return true;
		}
	return true;
			
});	
	$("#btn-edit").click(function(){

		
		if($("#showadd").val() == 'add'){
		var len = ($("#zip").val().length );
		if(len != 5){
			$(".zip-error").attr("style" , 'color:#8C3731');
			$(".zip-error").show('slow');
			
			$(".zip-error").html('Please enter 5 characters for Zip Code. ');
			$("#zip").focus();
			return false;
	    	}
		}

	return true;
			
});	
	
	$(".btZip").click(function(){
		var has = document.getElementById('has-address').value;
		if(has == 1){
		var cemail = document.getElementById('billing:confirmemail').value;
		var email = document.getElementById('billing:email').value;
		$(".bkZip").val().length;
		$(".zip-billing").attr("style" , 'color:#8C3731');
		if($(".bkZip").val().length != 5){
			$(".zip-billing").show('slow');
			
			$(".zip-billing").html('Please enter 5 characters for Zip Code. ');
			$(".bkZip").focus();
			return false;
		}
		else if(cemail != email){
			$(".email-error").attr("style" , 'color:#8C3731');
			$(".email-error").show('slow');
			$(".email-error").html('Emails should be identical. ');
			document.getElementById('billing:email').focus();
			return false;
		}
	else {
		$(".zip-billing").hide('slow');
		return true;
	}
		}
		else
			return true;
			
	});	
	$(".btSkZip").click(function(){

		$(".skZip").val().length;
		$(".zip-shipping").attr("style" , 'color:#8C3731');
		if($(".skZip").val().length != 5){
			$(".zip-shipping").show('slow');
			
			$(".zip-shipping").html('Please enter 5 characters for Zip Code. ');
			$(".skZip").focus();
		
		}

	else {
	
		$(".zip-shipping").hide('slow');
		return true;
	}
			
	});	
	$(".skZip").change(function(){
		$(".skZip").val().length;
		$(".zip-shipping").attr("style" , 'color:#8C3731');
		if($(".skZip").val().length != 5){
			$(".zip-shipping").show('slow');
			
			$(".zip-shipping").html('Please enter 5 characters for Zip Code. ');
			$(".skZip").focus();
			return false;
		}
	else {
		$(".zip-shipping").hide('slow');
		return true;
	}
			
	});	

	$(".bkZip").change(function(){
	$(".bkZip").val().length;
	$(".zip-billing").attr("style" , 'color:#8C3731');
	if($(".bkZip").val().length != 5){
		$(".zip-billing").show('slow');
		
		$(".zip-billing").html('Please enter 5 characters for Zip Code. ');
		$(".bkZip").focus();
	return false;
	}
else {
	$(".zip-billing").hide('slow');
	return true;
}
		
});	

	
	$("#zip").change(function(){
		$(".zip-error").attr("style" , 'color:#8C3731');
		var len = ($("#zip").val().length );
		if(len != 5){
			$(".zip-error").show('slow');
		
			$(".zip-error").html('Please enter 5 characters for Zip Code. ');
			$("#zip").focus();
			return false;
		}
	else {
		$(".zip-error").hide('slow');
		return true;
	}
			
});	
	

	$(".showloginform").click(function(){
			$(".newLoginForm").attr("id","login-form2");
			$(".loginFormbtn-set2").show();
			$(".loginFormbtn-set").hide();
			$(".closeForm_text").show();
			
			$(".closeForm-btn").fadeIn("slow");
			$(".validateData").fadeIn("slow");
			$(".origLoginSend").fadeOut("slow");
			
			
			

			$('input[name="login[isajax]"]').val("yes");
		
    		centerPopup2();
 	        loadPopup2();
    });
	
	$(".showmultiloginform").click(function(){
			$(".newLoginForm").attr("id","login-form2");
			$(".loginFormbtn-set2").show();
			$(".loginFormbtn-set").hide();
			$(".closeForm_text").show();
			
			$(".closeForm-btn").fadeIn("slow");
			$(".validateData").fadeIn("slow");
			$(".origLoginSend").fadeOut("slow");
			$(".regLink").hide();
			$(".regLink2").show();
			
			$(".formultilogin").show();
			$(".notformultilogin").hide();
			$('input[name="multipleLogin"]').val("yes");

			$('input[name="login[isajax]"]').val("yes");
		
    		centerPopup2();
 	        loadPopup2();
    });
	
	$(".showLostOne").click(function(){
			$('input[name="isajaxLost"]').val("yes");
			$('input[name="onepageLost"]').val("yes");
			$('.back-link').hide();
			
			$(".loginformcontent").hide();
			$(".lostForm").show();
			
			$(".closeLost_text").show();
			$(".closeLost_text .closeLost_A").hide();
			$(".closeForm_text").fadeOut("slow");
			$(".closeLost-btn").show();
			
    		centerPopup2();
 	        loadPopup2();
			
			
		});
	
	
	
	$(".cancelLoginform").click(function(){
		//$(".newLoginForm").attr("id","login-form");
	
			$('input[name="login[isajax]"]').val("");
			
			$('input[name="multipleLogin"]').val("no");
			$('input[name="onepageLost"]').val("no");
			$('input[name="isajaxLost"]').val("no");
			$(".closeLost_text").hide();
				$(".closeLost-btn").hide();
			//$(".loginformcontent").show();
			$(".lostForm").hide();
			$(".formultilogin").hide();
			$(".notformultilogin").show();
			
			
    	popupStatus2 = 1;
        disablePopup2();
		$(".closeForm-btn").fadeOut("slow");
		$(".validateData").fadeOut("slow");
		
		$(".origLoginSend").fadeIn("slow");

		$(".closeForm_text").fadeOut("slow");
		$(".loginFormbtn-set").show();
		$(".loginFormbtn-set2").hide();
		$(".loginformcontent").fadeIn("slow");
		$('.back-link').fadeIn("slow");
		$(".regLink2").hide();
		//	$(".regLink").show();
		
		
			//$(".closeForm-btn").hide();
			//$(".closeForm_text").hide();
			
		
    });
	
	$(".backtoformLost").click(function(){
		$('input[name="isajaxLost"]').val("no");
		$(".closeLost_text").hide();
			$(".closeLost-btn").hide();
    	$(".loginformcontent").show();
		$(".lostForm").hide();
    });
	
		
	$(function() {
	    var maxHeight = 0;
	    $('.shipcol').each(function(){
	        if (maxHeight < $(this).height()) {maxHeight = $(this).height()}
	    });
	

	    $('.shipcol').each(function(){
	        $(this).height(maxHeight);
	    });
	});
	
	$(".bill_select").click(function(){
			
				
				$(".formcontent").hide();
				$(".select_bill").show();
				
				centerPopup2();
 	        	loadPopup2();
				
				
				
	});
	
	if($(".ispopup").val()==1){
		$(".formcontent").hide();
				$(".select_bill").show();
				
				centerPopup2();
 	        	loadPopup2();
	}
	
	
		
		$(".shipchange").click(function(){
			
				var arr_id = $(this).attr('id');
				id_arr = arr_id.split("_");
				
				
				$("#firstname").val($("#fname_"+id_arr[1]).val());
				$("#lastname").val($("#lname_"+id_arr[1]).val());
				$("#company").val($("#company_"+id_arr[1]).val());
				$("#telephone").val($("#phone_"+id_arr[1]).val());
				$("#fax").val($("#fax_"+id_arr[1]).val());
				$("#street_1").val($("#add1_"+id_arr[1]).val());
				$("#street_2").val($("#add2_"+id_arr[1]).val());
				$("#city").val($("#city_"+id_arr[1]).val());
				$("#region_id option[value='" + $("#regionid_"+id_arr[1]).val() + "']").attr("selected", "selected");
				$("#region").val($("#region_"+id_arr[1]).val());
				$("#zip").val($("#zip_"+id_arr[1]).val());
				
				if( $("#default_shipid").val() != id_arr[1] && $("#default_billid").val() != id_arr[1] ){
					  $("div.dummy_opt")
					.show();
					$("#otherAddress").attr('checked', true);
				}else{
					 $("div.dummy_opt")
					.hide();
				}
				
				
				if( $("#default_billid").val() == id_arr[1] ){
					$("div.billing_opt").hide();
					$("div.dummy_billing_text").html('<p style="color:#05196c">This is your Default Billing Address</p>');
					$("#primary_billing").attr('checked', true);
					
				}else{
					
					$("div.billing_opt").show();
					$("div.dummy_billing_text").html('');
					$("#primary_billing").attr('checked', false);
				}
				
				if( $("#default_shipid").val() == id_arr[1] ){
					$("div.shipping_opt").hide();
					$("div.dummy_shipping_text").html('<p style="color:#05196c">This is your Default Shipping Address</p>');
					$("#primary_shipping").attr('checked', true);
				}else{
					
					$("div.shipping_opt").show();
					$("div.dummy_shipping_text").html('');
					$("#primary_shipping").attr('checked', false);
				}
				
				
				
				$("#form-validate2").attr('action', $("#saveURL").val() + "id/" + id_arr[1] + "/");
				
				
				
				
				
				$("input[name=success_url]'").val($("#successURL_prime_"+id_arr[1]).val()+'id/'+id_arr[1]+'/');
				$("input[name=error_url]'").val($("#errorURL_prime_"+id_arr[1]).val());
				
				$("h2.popup_head").text('Edit Shipping Address');
				
				/*
				alert($("#form-validate2").attr('action'));
				alert($("input[name=success_url]'").val());
				alert($("input[name=error_url]'").val());
				
				alert($("#firstname").val());
				alert($("#lastname").val());
				alert($("#company").val());
				alert($("#telephone").val());
				alert($("#fax").val());
				alert($("#street_1").val());
				alert($("#street_2").val());
				alert($("#city").val());
				alert($("#region_id").val());
				alert($("#region").val());
				alert($("#zip").val());
				alert($("#country").val());
				alert($("#primary_billing").val());
				alert($("#primary_shipping").val());*/
				$(".formcontent").hide();
				$(".change_add").show();
				
				centerPopup2();
 	        	loadPopup2();
				
				
				
			});
			
			
			
			$(".editBillingAdd").click(function(){
			
				var arr_id = $(this).attr('id');
				id_arr = arr_id.split("_");
				
				
				$("#firstname").val($("#fname_"+id_arr[1]).val());
				$("#lastname").val($("#lname_"+id_arr[1]).val());
				$("#company").val($("#company_"+id_arr[1]).val());
				$("#telephone").val($("#phone_"+id_arr[1]).val());
				$("#fax").val($("#fax_"+id_arr[1]).val());
				$("#street_1").val($("#add1_"+id_arr[1]).val());
				$("#street_2").val($("#add2_"+id_arr[1]).val());
				$("#city").val($("#city_"+id_arr[1]).val());
				$("#region_id option[value='" + $("#regionid_"+id_arr[1]).val() + "']").attr("selected", "selected");
				$("#region").val($("#region_"+id_arr[1]).val());
				$("#zip").val($("#zip_"+id_arr[1]).val());
				
				if( $("#default_shipid").val() != id_arr[1] && $("#default_billid").val() != id_arr[1] ){
					  $("div.dummy_opt")
					.show();
					$("#otherAddress").attr('checked', true);
				}else{
					 $("div.dummy_opt")
					.hide();
				}
				
				
				if( $("#default_billid").val() == id_arr[1] ){
					$("div.billing_opt").hide();
					$("div.dummy_billing_text").html('<p style="color:#05196c">This is your Default Billing Address</p>');
					$("#primary_billing").attr('checked', true);
					
				}else{
					
					$("div.billing_opt").show();
					$("div.dummy_billing_text").html('');
					$("#primary_billing").attr('checked', false);
				}
				
				if( $("#default_shipid").val() == id_arr[1] ){
					$("div.shipping_opt").hide();
					$("div.dummy_shipping_text").html('<p style="color:#05196c">This is your Default Shipping Address</p>');
					$("#primary_shipping").attr('checked', true);
				}else{
					
					$("div.shipping_opt").show();
					$("div.dummy_shipping_text").html('');
					$("#primary_shipping").attr('checked', false);
				}
				
				
				
				$("#form-validate2").attr('action', $("#saveURL").val() + "id/" + id_arr[1] + "/");
				
				
				
				
				
				$("input[name=success_url]'").val($("#successURL_prime_"+id_arr[1]).val());
				$("input[name=error_url]'").val($("#errorURL_prime_"+id_arr[1]).val());
				
				$("h2.popup_head").text('Edit Billing Address');
				
				/*
				alert($("#form-validate2").attr('action'));
				alert($("input[name=success_url]'").val());
				alert($("input[name=error_url]'").val());
				
				alert($("#firstname").val());
				alert($("#lastname").val());
				alert($("#company").val());
				alert($("#telephone").val());
				alert($("#fax").val());
				alert($("#street_1").val());
				alert($("#street_2").val());
				alert($("#city").val());
				alert($("#region_id").val());
				alert($("#region").val());
				alert($("#zip").val());
				alert($("#country").val());
				alert($("#primary_billing").val());
				alert($("#primary_shipping").val());*/
				$(".select_bill").hide();
				$(".change_add").show();
				
				centerPopup2();
 	        	loadPopup2();
				
				
				
			});
			
			$(".backBillSel").click(function(){
				$(".select_bill").show();
				$(".change_add").hide();
				
				centerPopup2();
 	        	loadPopup2();
				
				});
			
			$(".newBillingAdd").click(function(){
			
				//var arr_id = $(this).attr('id');
				//id_arr = arr_id.split("_");
				
				
				$("#firstname").val("");
				$("#lastname").val("");
				$("#company").val("");
				$("#telephone").val("");
				$("#fax").val("");
				$("#street_1").val("");
				$("#street_2").val("");
				$("#city").val("");
				//$("#region_id option[value='" + $("#regionid_"+id_arr[1]).val() + "']").attr("selected", "selected");
				$("#region").val("");
				$("#zip").val("");
				
				//if( $("#default_shipid").val() != id_arr[1] && $("#default_billid").val() != id_arr[1] ){
					  $("div.dummy_opt")
					.show();
					$("#otherAddress").attr('checked', true);
				//}else{
				//	 $("div.dummy_opt")
				//	.hide();
			//	}
				
				
				/*if( $("#default_billid").val() == id_arr[1] ){
					$("div.billing_opt").hide();
					$("div.dummy_billing_text").html('<p><strong>Default Billing Address</strong></p>');
					$("#primary_billing").attr('checked', true);
					
				}else{*/
					
					$("div.billing_opt").show();
					$("div.dummy_billing_text").html('');
					$("#primary_billing").attr('checked', false);
				//}
				
			/*	if( $("#default_shipid").val() == id_arr[1] ){
					$("div.shipping_opt").hide();
					$("div.dummy_shipping_text").html('<p><strong>Default Shipping Address</strong></p>');
					$("#primary_shipping").attr('checked', true);
				}else{*/
					
					$("div.shipping_opt").show();
					$("div.dummy_shipping_text").html('');
					$("#primary_shipping").attr('checked', false);
				//}
				
				
				
				$("#form-validate2").attr('action', $("#saveURL").val());
				
				
				
				
				
				$("input[name=success_url]'").val($("#successURL_prime").val());
				$("input[name=error_url]'").val($("#errorURL_prime").val());
				
				$("h2.popup_head").text('Add Billing Address');
				
				/*
				alert($("#form-validate2").attr('action'));
				alert($("input[name=success_url]'").val());
				alert($("input[name=error_url]'").val());
				
				alert($("#firstname").val());
				alert($("#lastname").val());
				alert($("#company").val());
				alert($("#telephone").val());
				alert($("#fax").val());
				alert($("#street_1").val());
				alert($("#street_2").val());
				alert($("#city").val());
				alert($("#region_id").val());
				alert($("#region").val());
				alert($("#zip").val());
				alert($("#country").val());
				alert($("#primary_billing").val());
				alert($("#primary_shipping").val());*/
				$(".select_bill").hide();
				$(".change_add").show();
				
				centerPopup2();
 	        	loadPopup2();
				
				
				
			});
			
			
			$(".billchange").click(function(){
			
				var arr_id = $(this).attr('id');
				id_arr = arr_id.split("_");
				
				
				$("#firstname").val($("#bfname_"+id_arr[1]).val());
				$("#lastname").val($("#blname_"+id_arr[1]).val());
				$("#company").val($("#bcompany_"+id_arr[1]).val());
				$("#telephone").val($("#bphone_"+id_arr[1]).val());
				$("#fax").val($("#bfax_"+id_arr[1]).val());
				$("#street_1").val($("#badd1_"+id_arr[1]).val());
				$("#street_2").val($("#badd2_"+id_arr[1]).val());
				$("#city").val($("#bcity_"+id_arr[1]).val());
				$("#region_id option[value='" + $("#bregionid_"+id_arr[1]).val() + "']").attr("selected", "selected");
				$("#region").val($("#bregion_"+id_arr[1]).val());
				$("#zip").val($("#bzip_"+id_arr[1]).val());
				
				if( $("#default_shipid").val() != id_arr[1] && $("#default_billid").val() != id_arr[1] ){
					  $("div.dummy_opt")
					.show();
					$("#otherAddress").attr('checked', true);
				}else{
					 $("div.dummy_opt")
					.hide();
				}
				
				
				if( $("#default_billid").val() == id_arr[1] ){
					$("div.billing_opt").hide();
					$("div.dummy_billing_text").html('<p style="color:#05196c">This is your Default Billing Address</p>');
					$("#primary_billing").attr('checked', true);
					
				}else{
					
					$("div.billing_opt").show();
					$("div.dummy_billing_text").html('');
					$("#primary_billing").attr('checked', false);
				}
				
				if( $("#default_shipid").val() == id_arr[1] ){
					$("div.shipping_opt").hide();
					$("div.dummy_shipping_text").html('<p style="color:#05196c">This is your Default Shipping Address</p>');
					$("#primary_shipping").attr('checked', true);
				}else{
					
					$("div.shipping_opt").show();
					$("div.dummy_shipping_text").html('');
					$("#primary_shipping").attr('checked', false);
				}
				
				
				
				$("#form-validate2").attr('action', $("#saveURL").val() + "id/" + id_arr[1] + "/");
				
				
				
				
				
				$("input[name=success_url]'").val($("#bsuccessURL_prime_"+id_arr[1]).val()+'id/'+id_arr[1]+'/');
				$("input[name=error_url]'").val($("#berrorURL_prime_"+id_arr[1]).val());
				
				$("h2.popup_head").html('Edit Billing Address');
				
				/*
				alert($("#form-validate2").attr('action'));
				alert($("input[name=success_url]'").val());
				alert($("input[name=error_url]'").val());
				
				alert($("#firstname").val());
				alert($("#lastname").val());
				alert($("#company").val());
				alert($("#telephone").val());
				alert($("#fax").val());
				alert($("#street_1").val());
				alert($("#street_2").val());
				alert($("#city").val());
				alert($("#region_id").val());
				alert($("#region").val());
				alert($("#zip").val());
				alert($("#country").val());
				alert($("#primary_billing").val());
				alert($("#primary_shipping").val());*/
				$(".formcontent").hide();
				$(".change_add").show();
				
				centerPopup2();
 	        	loadPopup2();
				
				
				
			});
			
			
			
			$(".cancelchangeform").click(function(){
				//$(".closeForm_text").fadeOut("slow");
				$(".change_add").fadeOut("slow");
				popupStatus2 = 1;
       			disablePopup2();
			});
			
			
			
			
			$(".cancelbillsel").click(function(){
				//$(".closeForm_text").fadeOut("slow");
				$(".select_bill").fadeOut("slow");
				popupStatus2 = 1;
       			disablePopup2();
			});
			
			
			
			
			
			$(".ajax_submit").click(function(){
				var postval = "";
				postval += "firstname=" + $("#firstname").val();
				postval += "&lastname=" + $("#lastname").val();
				postval += "&company=" + $("#company").val();
				postval += "&telephone=" + $("#telephone").val();
				postval += "&fax=" + $("#fax").val();
				postval += "&street_1=" + $("#street_1").val();
				postval += "&street_2=" + $("#street_2").val();
				postval += "&city=" + $("#city").val();
				postval += "&region_id=" + $("#region_id").val();
				postval += "&region=" + $("#region").val();
				postval += "&postcode=" + $("#zip").val();
				postval += "&country_id=" + $("#country").val();
				postval += "&form_key=" + $("input[name=form_key]'").val();
				
				if($("#primary_billing").is(':checked')){
					postval += "&default_billing=1";
				}
				
				
				if($("#primary_shipping").is(':checked')){
					postval += "&default_shipping=1";
				}
				
			
				
				
				
			});
			
			
			$(".dummy_second").click(function(){
				var n = $(".dummy_second:checked").length;
				if(n>0){
					$('.dummy_first').attr('checked', false);
				}
				
			});
			
			$(".dummy_first").click(function(){
				var n = $(".dummy_first:checked").length;
				if(n>0){
					$('.dummy_second').attr('checked', false);
				}
				
			});
			

			
		
		

	
	
 

}); 

		




