var initColorboxes = function () {

    /* colorbox-popup CSS class is used for videos (and automatically posts back when closed) */

    var width, height;

    if (jQuery.browser.msie && jQuery.browser.version.substr(0, 1) < 8) {
        width = 560;
        height = 435;
    }
    else {
        width = 560;
        height = 407;
    }

    jQuery('a.colorbox-popup').colorbox({
        iframe: true,
        width: width,
        height: height,
        opacity: 0.6,
        onClosed: function () {
            location.reload();
        }
    });

    jQuery('a.cBoxiFrame').colorbox({
        iframe: true,
        width: width,
        height: height,
        opacity: 0.6        
    });

    /* help-popup CSS class is used for "Help me choose a ..." popups on Select a Faucet pages */

    jQuery('a.help-popup').colorbox({
        iframe: true,
        opacity: 0.6,
        width: 416,
        height: 479
    });

    /* image-popup CSS class is used for the large image popups on the product catalog pages */

    if (jQuery.browser.msie && jQuery.browser.version.substr(0, 1) < 8) {
        width = 412;
        height: 418;
    }
    else {
        width = 412;
        height = 390;
    }

    jQuery('a.image-popup').colorbox({
        iframe: true,
        opacity: 0.6,
        width: width,
        height: height
    });

    /* enlarge-button CSS class is used for the product detail image enlargements */

    if (jQuery.browser.msie && jQuery.browser.version.substr(0, 1) < 8) {
        width = 746;
        height = 668;
    }
    else {
        width = 746;
        height = 630;
    }

    jQuery('a.enlarge-button').colorbox({
        iframe: true,
        opacity: 0.6,
        width: width,
        height: height
    });

}

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(initColorboxes);

Sys.Application.add_init(initColorboxes);
