$(document).ready(function(){

	// NAVIGATION - sidebar
		$("dd:not(#active)").hide();
		$("dt a").click(function(){
		$(this).parent().next().siblings("dd:visible").slideUp("slow");
		$(this).parent().next().slideDown("slow");
		$(".current").removeClass("current");
		$(this).addClass("current");
		return false;
		});
				
	// CART STEP 2 - shipping address for pickup ----------------------------------------------------------- //

	var shipMethod = function(){
	    if ($("input[@type=radio][@name=SHIPMENT_METHOD]:checked").val() == "PICKUP|In-Store Pickup|0|0|0") {
			$("input[@name=USER_SHIP_COMPANY]").val('RV Supply Warehouse').attr("readonly","readonly");								    
			$("input[@name=USER_SHIP_ADDR_LINE1]").val('107 S. First St.').attr("readonly","readonly");								    
			$("input[@name=USER_SHIP_ADDR_LINE2]").val('').attr("readonly","readonly");								    
			$("input[@name=USER_SHIP_CITY]").val('Coldwater').attr("readonly","readonly");								    
			$("input[@name=USER_SHIP_ZIP]").val('45828').attr("readonly","readonly");	
   			$("select#USER_SHIP_STATE").val("OH").attr("readonly","readonly");
			$("tr.USER_BILL_ADDR_DEFAULT").hide();
		}
	    else if ($("input[@type=radio][@name=SHIPMENT_METHOD]:checked").val() != "PICKUP|In-Store Pickup|0|0|0") {
			$("input[@name=USER_SHIP_COMPANY]").val('').removeAttr("readonly","readonly");								    
			$("input[@name=USER_SHIP_ADDR_LINE1]").val('').removeAttr("readonly","readonly");								    
			$("input[@name=USER_SHIP_ADDR_LINE2]").val('').removeAttr("readonly","readonly");								    
			$("input[@name=USER_SHIP_CITY]").val('').removeAttr("readonly","readonly");								    
			$("input[@name=USER_SHIP_ZIP]").val('').removeAttr("readonly","readonly");								    
			$("select#USER_SHIP_STATE").val("").removeAttr("readonly","readonly");				
			$("tr.USER_BILL_ADDR_DEFAULT").show();
	    };
	};
	
	$('input[@type=radio][@name=SHIPMENT_METHOD]').click(shipMethod);
	// shipMethod();
	
	// CART STEP 3 - payment type selector ----------------------------------------------------------- //

	var userCardType = function(){
		
		var cardTypeVal = $('select[@name=USER_CARD_TYPE]').val();
		
	    if (cardTypeVal == "American Express") {
			$("div#card16").hide(); // hide the 16 digit input
			$('div#card16 input').val(''); // set the value to blank
			$("div#card15").show(); // show the 15 digit input			
		}
	    else {
			$("div#card16").show(); // show the 16 digit input
			$("div#card15").hide();	 // hide the 15 digit input
			$("div#card15 input").val(''); // set the value to blank		
	    };
	};	
	
	$('select[@name=USER_CARD_TYPE]').change(userCardType);
	userCardType();
	
	/*
		Company Name: RV Supply Warehouse
		Address Line 1: 6101 St. Rt. 219
		Address Line 2: Blank
		City/Town: Celina
		State/Province: OH
		Zip/Postal Code: 45822
		Country: US
	 */
	
	 $("ul.dropdown li").hover(function(){
	   $(this).addClass("hover");
	   $('> .dir',this).addClass("open");
	   $('ul:first',this).css('visibility', 'visible');
	 },function(){
	   $(this).removeClass("hover");
	   $('.open',this).removeClass("open");
	   $('ul:first',this).css('visibility', 'hidden');
	 });		
	
});	
