function submitSpecialOffers(){
var email = $('#special_offers_input').val();

//ajax it
$.ajax({
   type: "POST",
   url: "submitEmail.php",
   data: "email="+email,
   success: function(msg){
     $('#special_offers_msg').val('You now will receive our special offers!');
	 $('#special_offers_input').val("Enter Your Email Address");
   }
 });

}

function submitForgotEmail(){
var email = $('#forgot_password_email_input').val();

//ajax it
$.ajax({
   type: "GET",
   dataType: 'json',
   url: "/store/forgotpassword.html",
   data: "email="+email,
   async: false,
   success: function(msg){
      $('#emailforgotmsg').html("<p>"+ msg.message+"</p>");
   }
 });

return false;
}

function applyDiscountPromoCode(code){



$.getJSON("validateCode.html?code="+code, 
	function(result){
	 $('#discountmsg').html="Validated.";
});



}

function submitFilterSearch(){
	if($('#z_within').attr('checked')){
		$('#filter_q').val(lastquery+' '+$('#filter_q').val());
	}
	return true;
}

function getStateSelector(whichOne,whatCountry,selectThis){
var stateDiv = document.getElementById(whichOne+'_input');
if((whatCountry == 'US') || (whatCountry == 'CA')){
	//ajax it
	$.ajax({
   		type: "GET",
   		url: "/store/get_states.html",
   		data: "country="+whatCountry,
   		async:   false,
		success: function(allStates){
			var stateSelect = '<select id="'+whichOne+'" name="'+whichOne+'"><option value=""> -- Select -- </option>';
			var statesOpts = allStates.split("|");
			for(var sx = 0;sx < statesOpts.length;sx++){
				var stateSplit = statesOpts[sx].split(":");
				if(stateSplit[0] && stateSplit[1]){
					if(stateSplit[0] == selectThis){stateSelect += '<option value="'+stateSplit[0]+'" selected>'+stateSplit[1]+'</option>';}
					else{stateSelect += '<option value="'+stateSplit[0]+'">'+stateSplit[1]+'</option>';}
				}
			}//end for
			stateSelect += '</select>';
			stateDiv.innerHTML = stateSelect;
   		}
 	});
}else{
	stateDiv.innerHTML = '<input type="text" name="'+whichOne+'" id="'+whichOne+'">';
}//end else

if($('#same_billing_shipping').attr('checked')==true) {
 //set the state
  $('#state').val($('#b_state').val());
 }
}//end func

$(document).ready(function() {

$('li.dir').click(function() { $('ul', this).css('visibility', 'visible'); });
$('li.dir').bind('mouseleave',function() { $('ul', this).css('visibility', 'hidden'); });
		

});

