
/// <reference path="jquery-1.4.1-vsdoc.js" />

$(document).ready(function () {
    var pi = $('#productInfo');
    if (pi.length < 1) //check the length of the returned jq collection
    {
        var content = $('#mainContent');
        var home = $('.home');
        if (content.height() < '450' && home.length < 1) {
            content.height('480px');
        }
    }

});


//Franchising form additional info
$(document).ready(function () {
    $('#optionalInfo').hide();
    $('#plusIcon').bind('mouseover', function () {
        $('#optionalInfo').toggle();
    });
});

//Locations
$(document).ready(function () {
    var usa = $('#usa');
    var usa_lrg = $('#usa_lrg');

    usa.bind('mouseenter', function () {
        usa_lrg.show();
    });
    usa_lrg.bind('mouseleave', function () {
        usa_lrg.hide();
    });

});

//Checkout Ship or Pickup
$(document).ready(function () {
    var ship = $('#ctl00_ctl00_CPHMainContent_CPHMainContentInternal_radShipToAddress');
    var pickup = $('#ctl00_ctl00_CPHMainContent_CPHMainContentInternal_radPickupInStore');
    var pdiv = $('#pickup');
    var sdiv = $('#ship');

    ship.bind('click', function () {
        sdiv.show();
        pdiv.hide();
    });

    pickup.bind('click', function () {
        sdiv.hide();
        pdiv.show();
    });
});

//Admin IntlShipping Countries
$(document).ready(function () {
    var cbxcountries = $('#ctl00_CPH_MainContent_cbxAllCountries');
    var gvcountries = $('.jq-gvcountries');

    cbxcountries.bind('click', function () {

        if (cbxcountries.attr('checked') == true) //it is checked after the click
        {
            gvcountries.hide(); 
        }
        else {
            gvcountries.show();
        }
    });

});

//Product Details Page - Before and After Images
$(document).ready(function () {
    var title = $('#lnkbna');
    var text = $('.nodecoration');
    var img = $('.beforeandafter');
    var close = $('.closebna');

    text.bind('click', function () {
        img.show();
    });

    close.bind('click', function () {
        img.hide();
    });

});

//Product Details Page - Replenish selector
$(document).ready(function () {
    var btn = $('#btnpurchase');
    var div = $('#replenishProduct');
    var cls = $('#cls');

    var btn2 = $('#btnpurchase_2');
    var div2 = $('#replenishProduct_2');
    var cls2 = $('#cls_2');

    btn.bind('click', function () {
        div.show();
    });

    cls.bind('click', function () {
        div.hide();
    });

    btn2.bind('click', function () {
        div2.show();
    });

    cls2.bind('click', function () {
        div2.hide();
    });
});

//Product Details Page - Email to Friend
$(document).ready(function () {

    var close = $('.closeemailform');
    var div = $('#emailtofriendform');
    var lnk = $('#emailtofriendlnk');
    var lnk2 = $('#emailtofriendlnk2');

    close.bind('click', function () {
        div.hide();
    });

    lnk.bind('click', function () {
        div.center();
        div.show();
    });

    lnk2.bind('click', function () {
        div.center();
        div.show();
    });


});

//Product Details Page - Hide close text on Interval Selector
$(document).ready(function () {
    $('#cls').hide();
    $('#cls_2').hide();
});

//General Function to Center Elements on the Screen
//Implement it like this --> $(element).center(); 
jQuery.fn.center = function () {
    var variantheight = $('#header').height(); //things that make absolute height vary
    this.css("position", "absolute");
    this.css("z-index", "1000");
    this.css("top", ($(window).height() - this.outerHeight()) / 2 + $(window).scrollTop() - variantheight + "px");
    this.css("left", ($('body').width() - this.outerWidth()) / 2 + $(window).scrollLeft() + "px");
    return this;
}

/*

*/
