// JavaScript Document
jQuery(document).ready(function ()
{
    //this is for the menu bar ajax ...
    jQuery('#add_to_cart').live('click', function ()
    {
        jQuery('#illustration').replaceWith('<img height="15" width="128" src="/wp-content/themes/msm/images/icon/ajax-loader.gif" alt="Loading..." id="loading" />');
        var select_size = jQuery('input[@name=select_size]:checked').val();
        var add_to_cart = jQuery('#add_to_cart').val();
        var add_image_number = jQuery('#add_image_number').val();
        var plus_1 = jQuery('#plus_1').val();
        jQuery.ajax(
        {
            url: '/msm_ajax.php',
            type: 'POST',
            data: 'add_to_cart=' + add_to_cart + '&add_image_number=' + add_image_number + '&plus_1=' + plus_1 + '&select_size=' + select_size + '&ajax_post=true',
            success: function (result)
            {
                jQuery('#price_table_container').replaceWith(result);
                var new_cart_num = jQuery('#new_cart_total').val();
                jQuery('#cart_num').replaceWith('<span>(' + new_cart_num + ')</span>');
                jQuery('#user_cart').removeClass("full_cart cart");
                jQuery('#user_cart').addClass("cart full_cart highlight_text");
                jQuery('#loading').fadeOut(500);
            }
        });
        return false;

    });
});
jQuery(document).ready(function ()
{
    jQuery(function ()
    {
        // Some simple jQuery to remove the default search value when the user clicks the box, plus other main doc features
        search_box = jQuery(".enter_keyword");
        // If the user clicks the input box and the text is "search here!",
        //    set it to blank
        search_box.click(function (e)
        {
            if (search_box.attr("value") == "enter keyword(s)")
            {
                // Set it to an empty string
                search_box.attr("value", "");
            }
        });
    });
});
jQuery(document).ready(function ()
{
    //modal window... http://www.queness.com/post/77/simple-jquery-modal-window-tutorial
    jQuery('.modal').click(function (e)
    {
        //Cancel the link behavior
        e.preventDefault();
        var id = jQuery(this).attr('id');
        //Get the screen height and width
        var maskHeight = jQuery(document).height();
        var maskWidth = jQuery(window).width();
        //Set height and width to mask to fill up the whole screen
        jQuery('#mask').css(
        {
            'width': maskWidth,
            'height': maskHeight
        });
        //transition effect    
        jQuery('#mask').fadeIn(1000);
        jQuery('#mask').fadeTo("slow", 0.8);
        //Get the window height and width
        var winH = jQuery(window).height();
        var winW = jQuery(window).width();
        //Set the popup window to center
        jQuery(id).css('top', winH / 2 - jQuery(id).height() / 2);
        jQuery(id).css('left', winW / 2 - jQuery(id).width() / 2);
        //transition effect
        jQuery(id).fadeIn(2000);
    });
    //if close button is clicked
    jQuery('.login-window .close').click(function (e)
    {
        //Cancel the link behavior
        e.preventDefault();
        jQuery('#mask, .login-window').hide();
    });
    //if mask is clicked
    jQuery('#mask').click(function ()
    {
        jQuery(this).hide();
        jQuery('.window').hide();
    });
});
//for cart, if submit button is pushed, decide destination - 
jQuery(document).ready(function ()
{
    jQuery(function ()
    {
        jQuery('#edit_cart').click(function ()
        {
            jQuery('#cart_form').attr('action', '');
        });
    });
});
