﻿



                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();
    
}



function OpenProductSheetReport(codeArticle, codeAgence, Pro) {
    
    window.open('/productSheetReport.aspx?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;
}                