﻿function AsyncPostBack_ShowProduct(sender, args) {
    var $ctx = $('#Product');

    $(".btnAddToCart", $ctx).mouseenter(function () { $(this).attr('src', '/Images/Buttons/btnAddToCart_On.png'); })
    .mouseleave(function () { $(this).attr('src', '/Images/Buttons/btnAddToCart.png'); });

    $("#MainContent_PaymentPrestoBox", $ctx).click(function () { Popup_Presto("http://www.cetelem.fr/univers/presto/simulation/simulation.php?id=piscinex&montant=500&mois=20&projet=745") });
    $("#MainContent_PaymentNxCBBox", $ctx).click(function () { Popup_NxCB("https://partenariat.bnpparibas-pf.com/nxcb/landing/index.php?id=piscinex") });
}

$(function () {

    //Préchargement des images
    $.preLoadImages('/Images/Buttons/btnAddToCart_On.png');

    //Ajout d'une fonction à chaque AsyncPostBack
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(AsyncPostBack_ShowProduct);

    var $ctx = $('#Product');

    var PicturesPanel = $(".PicturesPanel");
    $("a[href$='jpg']", PicturesPanel).colorbox({ current: "{current} / {total}", rel: 'PicturesCollection', slideshow: false, maxHeight: '80%', maxWidth: '80%', title: function () { var altText = $("img", this).attr('alt'); return altText; } });
    $(".PictureBox", PicturesPanel).hover(function () { $(this).addClass("selected"); }, function () { $(this).removeClass("selected"); });

    /*var PicturesCollection = $('.pnlPicturesCollection', $ctx);
    $("a[href$='jpg'],a[href$='gif']", PicturesCollection)
    .click(function() { $("[id$='_imgProduct']", $ctx).attr("src", $("img", this).attr("srcmedium")); return false; });*/

    /*   if (typeof (products) != 'undefined') {*/
    var models = $('.rdlModelSelector td');
    models.hover(function () {

        $(this).toggleClass("highlight", true);
    }, function () {
        $(this).toggleClass("highlight", false);
    }).click(function () {
        $('input:radio:enabled', this).prop("checked", true);
        $('.rdlModelSelector td').toggleClass("selected", false);
        $(this).toggleClass("selected", true);
    });
    /*}*/
});


function Popup_Presto(url) {
    var params = "resizable=yes, status=no, directories=no, addressbar=no, toolbar=no, scrollbars=no, menubar=no, location=no, statusbar=no, width=568, height=490";
    var win = window.open(url, "Popup_Cetelem_Presto", params);
    win.focus();
}

function Popup_NxCB(url) {
    var params = "resizable=yes, status=no, directories=no, addressbar=no, toolbar=no, scrollbars=no, menubar=no, location=no, statusbar=no, width=630, height=680";
    var win = window.open(url, "Popup_Cetelem_NxCB", params);
    win.focus();
}
