/// <reference path="jquery-1.3.2.js" />

//AJAXCART
// The following code will run once page has loaded
$(function() {
    var randomNum = Math.floor(Math.random() * 100000);
    var url = '/Cart/DropDownCart/' + randomNum;

    // hides the dynamic cart
    $('#cart_down').removeClass('hideCart').hide();
    //shows/hides the cart when arrow is clicked
    if ($.browser.safari) {
        if ($.browser.version <= 499) {
            $('#clickMe').attr('href', '/Cart');
        } else {
            $('#cart_down').removeClass('hideCart').hide();
            //displays tooltip to click arrow to show/hide cart
            $('#clickMe').tooltip({
                delay: 0,
                showURL: false,
                fade: 200
            });
            $('.showHide').toggle(function() {
                $('#cart_down').animate({ height: 'show' }, 'fast');
                $(this).addClass('sh_down').removeClass('sh_right');
                $('#cart_contents').load(url);
                $('#clickMe').attr('title', 'Click to Close Your Shopping Cart');
                //resets tooltip to click arrow to show/hide cart
                $('#clickMe').tooltip({
                    delay: 0,
                    showURL: false,
                    fade: 200
                });
            }, function() {
                $('#cart_down').hide();
                $(this).addClass('sh_right').removeClass('sh_down');
                $('#clickMe').attr('title', 'Click to View Your Shopping Cart');
                //resets tooltip to click arrow to show/hide cart
                $('#clickMe').tooltip({
                    delay: 0,
                    showURL: false,
                    fade: 200
                });
            });
        }
    } else {
        $('#cart_down').removeClass('hideCart').hide();
        //displays tooltip to click arrow to show/hide cart
        $('#clickMe').tooltip({
            delay: 0,
            showURL: false,
            fade: 200
        });
        $('.showHide').toggle(function() {
            $('#cart_down').animate({ height: 'show' }, 'fast');
            $(this).addClass('sh_down').removeClass('sh_right');
            $('#cart_contents').load(url);
            $('#clickMe').attr('title', 'Click to Close Your Shopping Cart');
            //resets tooltip to click arrow to show/hide cart
            $('#clickMe').tooltip({
                delay: 0,
                showURL: false,
                fade: 200
            });
        }, function() {
            $('#cart_down').hide();
            $(this).addClass('sh_right').removeClass('sh_down');
            $('#clickMe').attr('title', 'Click to View Your Shopping Cart');
            //resets tooltip to click arrow to show/hide cart
            $('#clickMe').tooltip({
                delay: 0,
                showURL: false,
                fade: 200
            });
        });
    }

    //jQModal code for pop-up div, content page is set as href of link
    $('#jQM').jqm({ ajax: '@href', trigger: 'a.popme', overlay: 50, toTop: true, ajaxText: 'Loading...' }).jqmAddClose('.close');
    $('#jQMBN').jqm({ ajax: '@href', trigger: 'a.popmeBN', overlay: 50, toTop: true, ajaxText: 'Loading...' }).jqmAddClose('.close');
    $('#jQMsurvey').jqm({ ajax: '@href', trigger: 'a.popmeSM', overlay: 50, toTop: true, ajaxText: 'Loading...' }).jqmAddClose('.close');
    $('#jQMBuyNow').jqm({ ajax: '@buynowurl', trigger: 'a.buynowtrigger', overlay: 50, modal: true, toTop: true, ajaxText: 'Loading...' }).jqmAddClose('.close');
    //Dynamicly take ID and trigger class.
    //Find all a tags with a ID that begins with jqm. ex.) jqmCUS1, pull value of popme attribute and assign an a tag with that class as the trigger.
    var curID = "";
    //added code to prevent duplicate lightboxes, which we started seeing on 1/30/09
    $('[id^=jqm]').each(function() {
        var pop = $(this).attr('popme');
        //console.log(curID);
        if ($(this).attr('id') == curID) {
        } else {
            curID = $(this).attr('id');
            //console.log(pop);
            $(this).jqm({ trigger: 'a.' + pop, overlay: 50, toTop: true, ajaxText: 'Loading...' }).jqmAddClose('.close');
        };
    });
    //resets main page body background to original color, script was causing it to turn white without this line
    $('body').css('background', '#f2f0ed');


});

//LIGHTBOX
// The following code will run once page has loaded	 
$(function() {
    //jQModal code for pop-up div, content page is set as href of link
    $('#jQM').jqm({ ajax: '@href', trigger: 'a.popme', overlay: 50, toTop: true, ajaxText: 'Loading...' }).jqmAddClose('.close');
    $('#jQMBN').jqm({ ajax: '@href', trigger: 'a.popmeBN', overlay: 50, toTop: true, ajaxText: 'Loading...' }).jqmAddClose('.close');
    $('#jQMsurvey').jqm({ ajax: '@href', trigger: 'a.popmeSM', overlay: 50, toTop: true, ajaxText: 'Loading...' }).jqmAddClose('.close');
    $('#jQMBuyNow').jqm({ ajax: '@buynowurl', trigger: 'a.buynowtrigger', overlay: 50, modal: true, toTop: true, ajaxText: 'Loading...' }).jqmAddClose('.close');
    //Dynamicly take ID and trigger class.
    //Find all a tags with a ID that begins with jqm. ex.) jqmCUS1, pull value of popme attribute and assign an a tag with that class as the trigger.
    var curID = "";
    //added code to prevent duplicate lightboxes, which we started seeing on 1/30/09
    $('[id^=jqm]').each(function() {
        var pop = $(this).attr('popme');
        //console.log(curID);
        if ($(this).attr('id') == curID) {
        } else {
            curID = $(this).attr('id');
            //console.log(pop);
            $(this).jqm({ trigger: 'a.' + pop, overlay: 50, toTop: true, ajaxText: 'Loading...' }).jqmAddClose('.close');
        };
    });
    //resets main page body background to original color, script was causing it to turn white without this line
    $('body').css('background', '#f2f0ed');
});


