/*
 biggie small is not my hero
 Bartek Ciszkowski
*/
$(document).ready(function() {
    
    // Highlighter!
    $("#writeup li").hover(
        function () {
            //$(this).css("background-color", "#D1E5EF");
            $(this).addClass("highlight");
        },
        function () {
           // $(this).css("background-color", "#D9ECF6");
            $(this).removeClass("highlight");
        }
    );


    $('a[rel*=pretty]').facebox();
      
    $("#product_info > li").click(function() {

		var type = $(this).attr('rel');

		// Switch our tab
		$("#product_info > li").removeClass('selected');
		$(this).addClass('selected');


		$.get('/products/fetch_summary/' + type, function(data) {
			
			$("#ax_product_info").html(data);
			$("img#ax_product_image").attr('src','/m/img/promo_' + type + '.jpg');
			
		});

		// This stops the link from going
		return false;
    });

    /* Part of simple_cart's "copy address" functionality. Copies the address info to the billing fields */
    if (typeof(obj_address_copy)) {
        $("#id_address_copy_p").show();
    }

    $("#id_address_copy").click(function() {
        $.each(obj_address_copy, function(id, value) {
            $("#" + id).val(value);
        });
    });
      
      
    $("#registration_form :input").focus(function() {
            
            var help_id = $(this).attr("id") + "_help";
            
            $("#" + help_id).removeClass("hidden")
            $("#" + help_id).addClass("help_text");
    });
      
    $("#registration_form :input").blur(function() {
           var help_id = $(this).attr("id") + "_help";
           
           $("#" + help_id).removeClass("help_text");
           $("#" + help_id).addClass("hidden");
    });
      
    $("#details_cdn_link").click(function() {
            $("#details_cdn").toggle();
    });
      
    $("#details_usa_link").click(function() {
            $("#details_usa").toggle();
    });


    // Map / Directions
    if ($("#submit_map").length > 0) {
        $("#submit_map").click(function() {
            console.log('clicked map');
            from = $("#address").val() + ' ' + 
                        $("#city").val() + ' ' +
                        $("#province").val() + ' ' +
                        $("#postal"). val();

            $("#saddr").val(from);

            $("#mapForm").submit();
        });
    }
});

      
