// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function nospam(user,domain) {
	locationstring = "mailto:" + user + "@" + domain + "?subject=I have a question";
	window.location = locationstring;
}

$(document).ready(function() {
	
	// Home
	$("#application li a").hover(
		function(){
			$(this).find("strong").stop().fadeTo("normal", 0.8);
		}, function(){
			$(this).find("strong").stop().fadeTo("normal", 0);
	});
  
  // Stripe Tables
  $("#existing_coupons tbody tr:odd, #orders tbody tr:even, #product_list tbody tr:even").css("background-color", "#EEE");
  
  // Ading percentage toggle
  $("#form_percentage_check").click(function () {
    $("label.discount_type").toggle();
  });
  
  // Store help section toggle
  $("#help").toggle(
    function () {
      $("#faq").slideDown("slow");
    },
    function () {
      $("#faq").slideUp("slow");
    }
  );
  
  // Swap Values
  swapValues = [];
  $(".swap_value").each(function(i){
    swapValues[i] = $(this).val();
    $(this).focus(function(){
      if ($(this).val() == swapValues[i]) {
        $(this).val("").css({ color: "#111"});
      }
    }).blur(function(){
      if ($.trim($(this).val()) == "") {
        $(this).val(swapValues[i]).css({ color: "#999"});
      }
    });
  });
});