﻿



                function OnClientLoaded(sender, args) {
                    var label1 = $get("MinSelected");
                    var label2 = $get("MaxSelected");
                    label1.innerHTML = sender.get_selectionStart() + " €";
                    label2.innerHTML = sender.get_selectionEnd() + " €";
                }
                function OnClientValueChange(sender, args) {

                    var label1 = $get("MinSelected");
                    var label2 = $get("MaxSelected");
                    label1.innerHTML = sender.get_selectionStart() + " €";
                    label2.innerHTML = sender.get_selectionEnd() + " €";
                }


                /* OLD BEWISE*/
                /*function OnClientValueChange(sender, args) {
                    
                    var tooltip = $find("<%= RadToolTip1.ClientID %>");

                    if (!tooltip.isVisible()) {
                        var activeHandle = sender.get_activeHandle();
                        if (!activeHandle) return;

                        tooltip.set_targetControl(activeHandle);
                        tooltip.show();
                    }
                    else {
                        tooltip.updateLocation();
                    }

                    tooltip.set_text(args.get_newValue());
                }

                function OnClientSlideStart(sender, args) {
                    var tooltip = $find("<%= RadToolTip1.ClientID %>");
                    tooltip.hide();
                }*/
                

function ret(sender, eventArgs) 
{
    var item = eventArgs.get_item();
    if (item == null)
        return;
    var combo = item.get_comboBox();
    var combo2;

    if (combo.get_id == 'RadComboBoxAutocompleteNbResult1') {
        combo2 = document.getElementById("RadComboBoxAutocompleteNbResult1");
    }
    else (combo.get_id == 'RadComboBoxAutocompleteNbResult2')
    {
        combo2 = document.getElementById("RadComboBoxAutocompleteNbResult2");

    }
    if(combo2 != null)
    combo2.set_value = combo.get_value();
// sender.set_text("You selected " + item.());

}

function IAmSelected(source, eventArgs) {
    $get("TextBoxSearch").click();
    
}

//Url = function() { }

//Url.prototype =
//{
//    _relativeRoot: '<%= ResolveUrl("~/") %>',
//    resolve: function(relative) {
//        var resolved = relative;
//        if (relative.charAt(0) == '~') resolved = _relativeRootp + relative.substring(2);
//        return resolved;
//    }
//}

//$Url = new Url();

function OpenProductSheetReport(codeArticle, codeAgence, Pro, urlp) {

    //window.open('/productSheetReport.aspx?p1=' + codeArticle + '&p2=' + codeAgence + '&p3=' + Pro);
    
    window.open((urlp == null || urlp == '' ? '/productSheetReport.aspx' : urlp) + '?p1=' + codeArticle + '&p2=' + codeAgence + '&p3=' + Pro);
}

function DisplayProductDetail(btnId) {
    if (document.getElementById(btnId))
        document.getElementById(btnId).click();
}

function MerchandisingClick(btnIdUrl, UrlHref) {

    if (btnIdUrl != null && btnIdUrl != "") DisplayProductDetail(btnIdUrl);
    if (UrlHref != null && UrlHref != "") document.location.href = UrlHref;

}


var timer;
var dir = -1;
var margin;
var content;
var hiddenMargin;
var leftCtrl;
var rightCtrl;
var niv_0_container;


function Init() {
    
    
    
    content = $get("niv_0");
    leftCtrl = $get('niv_0_left');
    rightCtrl = $get('niv_0_right');
    niv_0_container = $get('niv_0_container');

    max = max - (niv_0_container.offsetWidth - (11 * 84));
    margin = parseInt(hiddenMargin.value);

    marginSelected = marginSelected - (niv_0_container.offsetWidth - 1 - (11 * 84));

    if (marginSelected > -1 && ((marginSelected) * -1) < max) margin = (marginSelected) * -1;

    CheckCtrlVisibility();
    if (content != null && content.style != null) content.style.marginLeft = margin + "px";
}

function scroll(direction) {
    dir = direction;
    if (timer != null) { stop(); }
    timer = window.setInterval(DoScroll, 30);
}

function DoScroll() {

    if (dir == 1 && margin == 0) return;
    if (dir == -1 && (margin * -1) >= max) return;
    //alert(margin);
    margin = margin + 6 * dir;
    if (content != null && content.style != null) {
        content.style.marginLeft = margin + "px";
        SaveValue(content.style.marginLeft);
    }
    CheckCtrlVisibility();
}

function CheckCtrlVisibility() {
    if (leftCtrl != null && leftCtrl.style != null && rightCtrl != null && rightCtrl.style != null) {
        if (margin < 0) { leftCtrl.style.visibility = 'visible'; }
        else { leftCtrl.style.visibility = 'hidden'; }
        if (margin * -1 >= max) { rightCtrl.style.visibility = 'hidden'; }
        else { rightCtrl.style.visibility = 'visible'; }
    }
}

function stop() { if (timer != null) { window.clearInterval(timer); timer = null; } }
function SaveValue(val) { hiddenMargin.value = val; }


function affectMargin(idtemp) {
    document.getElementById(idtemp).style.visibility = "hidden";

    document.getElementById(idtemp).value = document.getElementById("ID-BODY").offsetLeft;
}




function isScrolledIntoView(elem) { var docViewTop = $(window).scrollTop(); var docViewBottom = docViewTop + $(window).height(); var elemTop = $(elem).offset().top; var elemBottom = elemTop + $(elem).height(); return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom)); }
var imgZoomEncours;
function chargeimgGlobal(imgacharger, idimg, imagelg, widthimagelg, heightimagelg, AfficherZoom) {

    jQuery('#' + idimg).get(0).src = imgacharger;
    jQuery('#' + idimg).get(0).alt = '';
    chargeimgpourzoom(idimg, imagelg, widthimagelg, heightimagelg);
}
String.prototype.bool = function() { return (/^true$/i).test(this); };

function chargeimgpourzoom(idimg, imagelg, widthimagelg, heightimagelg) {
    /*alert(widthimagelg);
    alert(heightimagelg);*/
    var widthbloc = 400;
    var heightbloc = 400;

    if (heightimagelg != 0) {
        if (heightimagelg > heightbloc && heightimagelg>widthimagelg) {	
            widthimagelg = parseInt((widthimagelg * heightbloc) / heightimagelg);
        }
    }

    if (widthimagelg != 0) {
        if (widthimagelg > widthbloc && widthimagelg>heightimagelg ){
            heightimagelg = parseInt((heightimagelg * widthbloc) / widthimagelg);
        }
    }

    if (heightimagelg != 0) {
        if (heightimagelg < heightbloc) heightbloc = heightimagelg;
    }
    if (widthimagelg != 0) {
        if (widthimagelg < widthbloc) widthbloc = widthimagelg;
    }
// widthbloc = 400;
 //heightbloc = 400;

    //zoomrange: [rangezoommin, rangezoommax],

    if (imagelg != null && imagelg != "") {
        imgZoomEncours = jQuery('#' + idimg).addimagezoom({
            loadinggif: 'http://www.richardson.fr/img/loading.gif',
            magnifycursor: 'hand',
            magnifiersize: [widthbloc, heightbloc],
            magnifierpos: 'right',
            cursorshade: true,
            cursorshadecolor: '#fff',
            cursorshadeopacity: 0.3,
            cursorshadeborder: '1px solid gray',
            leftoffsetcontainers: 0,
            borderwidth: 1,
            leftoffset: 0, //offsets here are used (added to) the width of the magnifyarea when
            rightoffset: 10,
            largeimage: imagelg //<-- No comma after last option!
        });
    } else {
        widthbloc = jQuery('#' + idimg).width();
        heightbloc = jQuery('#' + idimg).height();

        imgZoomEncours = jQuery('#' + idimg).addimagezoom({
            loadinggif: 'http://www.richardson.fr/img/loading.gif',
            magnifycursor: 'hand',
            magnifiersize: [widthbloc, heightbloc],
            magnifierpos: 'right',
            cursorshade: true,
            cursorshadecolor: '#fff',
            cursorshadeopacity: 0.3,
            cursorshadeborder: '1px solid gray',
            leftoffsetcontainers: 0,
            borderwidth: 1,
            leftoffset: 0, //offsets here are used (added to) the width of the magnifyarea when
            rightoffset: 10,
            largeimage: imagelg //<-- No comma after last option!
        });
    }

    //}
}


