﻿var nu = true;
var hostname = "www.modern.nl";
//var hostname = "localhost:44300";

function valizoek(boxname) {
    var ele = document.getElementById(boxname)
    if (ele) {
        if (ele.value == '') {
            alert('U moet een zoekterm invullen svp.')
            return false
        }
    }
}


function SetAlreadyExist(email) {
    var login = document.getElementById('ctl00_Main_Email_Login');
    login.value = email;
    checkradio('ctl00_Main_rbJa');
    alert('Het ingevulde e-mail adres komt al voor in onze database.');
}

function clientSlideEnd(sender, eventArgs) {
    //  alert(sender.get_id());
    var minValue = sender.get_selectionStart();
    var maxValue = sender.get_selectionEnd();
    if (sender.get_element().getAttribute("Soort") == "prijs") {
        minPrijs = minValue;
        maxPrijs = maxValue;
    } else {
        Filter2Min = minValue;
        Filter2Max = maxValue;
    }
    setHash();
    
}

function setSlider(minValue, maxValue, slider) {
    slider.set_selectionStart(minValue);
    slider.set_selectionEnd(maxValue);
}

function clientValueChange(sender, eventArgs) {
    var minValue = sender.get_selectionStart();
    var maxValue = sender.get_selectionEnd();
    var hulp = document.getElementById(sender.get_element().getAttribute("FieldValues"));
    var eenheid = sender.get_element().getAttribute("Eenheid");
    var eenheidAfter = sender.get_element().getAttribute("Eenheidafter");
    var valuefield = "";
    if (eenheidAfter == "True") {
        valuefield = minValue + eenheid + " - " + maxValue + eenheid;
    } else {
        valuefield = eenheid + minValue + " - " + eenheid + maxValue;
    }
    //   alert(valuefield);
    hulp.innerHTML = valuefield;
}



function checkradio(radiobutton) {
    
   // document.getElementById(radiobutton).click();
}

var oldpane = "";

//function getWebcollageLink() {
//    if (jQuery(".wcsb-button.wcsb-sonynl")) {
//        var hulp = jQuery(".wcsb-button.wcsb-sonynl").get(0).attributes;
//        for (i = 0; i < hulp.length; i++) {
//            if (hulp[i].value != "null" && hulp[i].value != "" && hulp[i].value != "()" ) {
//                alert(hulp[i].name + ":" + hulp[i].value);
//            }
//        }
////        for (i = 0; i < jQuery("span[class|='wcsb-button']").attr(); i++) {
////            alert(jQuery("span[class|=wcsb-button]").attr(i));
////        }
//    }
//}

function setSession(key, value) {
    wsSession.setSession(key, value, OnErrorDojo, OnTimeOutDojo);
}

function setCalenderTekst(BezorgType) {
    if (BezorgType == "afhalen") {
        jQuery("#lblBezorgDatum").html("Afhaaldatum");
        jQuery("#lblBezorgTekst").html("Het kan zijn dat uw geselecteerde afhaallocatie niet op zaterdag is geopend terwij u deze wel heeft geselecteerd in onderstaande kalender. In dat geval kan u <span style=\"text-decoration: underline;\">de eerstvolgende werkdag</span> uw bestelling afhalen.");
    } else {
        jQuery("#lblBezorgDatum").html("Bezorgdatum");
        jQuery("#lblBezorgTekst").html("De eerstvolgende bezorgdatum is gemarkeerd. Wenst u een andere bezorgdatum klikt u dan op de dag van uw keuze.");
    }
}

function SelectPane2(SelectedPane) {
    // jQuery(".ActivePane").attr("class", "InActivePane");
    SelectedPane.parentNode.className = "ActivePane";

}

function setActiveBezorgOpties() {
    jQuery(".ActivePane").attr("class", "InActivePane");
    var hulp = jQuery("input:checked");
    for (i = 0; i < hulp.length; i++) {
        SelectPane2(hulp[i].parentNode);
    }
}

function SelectPane(SelectedPane, UnSelectedPane) {
    var hulp1 = document.getElementById(SelectedPane);
    hulp1.className = 'ActivePane';
    var hulp2 = document.getElementById(UnSelectedPane);
    hulp2.className = 'InActivePane';
    ValidatorEnable(ctl00_Main_KlantInvoer1_RequiredFieldValidator2, (UnSelectedPane == 'LeftColumn'));
    ValidatorEnable(ctl00_Main_KlantInvoer1_RequiredFieldValidator3, (UnSelectedPane == 'LeftColumn'));
    ValidatorEnable(ctl00_Main_KlantInvoer1_RequiredFieldValidator4, (UnSelectedPane == 'LeftColumn'));
    ValidatorEnable(ctl00_Main_KlantInvoer1_RequiredFieldValidator5, (UnSelectedPane == 'LeftColumn'));
    ValidatorEnable(ctl00_Main_KlantInvoer1_RequiredFieldValidator8, (UnSelectedPane == 'LeftColumn'));
    ValidatorEnable(ctl00_Main_KlantInvoer1_RequiredFieldValidator6, (UnSelectedPane == 'LeftColumn'));
    ValidatorEnable(ctl00_Main_KlantInvoer1_RequiredFieldValidator9, (UnSelectedPane == 'LeftColumn'));
    ValidatorEnable(ctl00_Main_KlantInvoer1_RequiredFieldValidator10, (UnSelectedPane == 'LeftColumn'));
    ValidatorEnable(ctl00_Main_KlantInvoer1_RequiredFieldValidator12, (UnSelectedPane == 'LeftColumn'));
    ValidatorEnable(ctl00_Main_KlantInvoer1_cmpPasswords, (UnSelectedPane == 'LeftColumn'));
    ValidatorEnable(ctl00_Main_KlantInvoer1_revEmail, (UnSelectedPane == 'LeftColumn'));
    ValidatorEnable(ctl00_Main_KlantInvoer1_regExpWachtwoord, (UnSelectedPane == 'LeftColumn'));
    ValidatorEnable(ctl00_Main_KlantInvoer1_RegularExpressionValidator4, (UnSelectedPane == 'LeftColumn'));
    ValidatorEnable(ctl00_Main_KlantInvoer1_RegularExpressionValidator5, (UnSelectedPane == 'LeftColumn'));
    ValidatorEnable(ctl00_Main_KlantInvoer1_RegularExpressionValidator1, (UnSelectedPane == 'LeftColumn'));
    ValidatorEnable(ctl00_Main_KlantInvoer1_RegularExpressionValidator3, (UnSelectedPane == 'LeftColumn'));
    ValidatorEnable(ctl00_Main_KlantInvoer1_rfvVoorletters, (UnSelectedPane == 'LeftColumn'));

    /*ValidatorEnable(ctl00_Main_KlantInvoer1_RequiredFieldValidator2, (hulp1 != 'LeftColumn'));*/
}

function selectTab(text, TabStrip) {
    //alert(jQuery('.Midden').innerHeight());
    var tabStrip = $find(TabStrip);
    var tab = tabStrip.findTabByText(text);
    if (tab) {
        tab.select();
    }
}

var strProductTitle = ''

function OnClientTabSelected(sender, eventArgs) {
    var tab = eventArgs.get_tab();
    _gaq.push(['_trackEvent', 'tabs', tab.get_text(), strProductTitle]);
}

//if (top.location != location) {
if (window.name == "iframeOnline") {
    if (top.location == "https://" + hostname) {
        top.location = "http://" + hostname;
    } else {
        top.location = document.location.href;
    }
}

function ClickRadio(RadioButton) {
    var Radio = document.getElementById(RadioButton);
    Radio.click();
}


/*function PositionDiv(div) {
if ($get(div) != null) {
var height = $get(div).offsetHeight - 44;
//     $get('div10').style.marginBottom = height + "px";
/*alert($get('ctl00_Main_MiddenCenterContentBottomContent').style.bottom);// = "10px";
$get('ctl00_Main_MiddenCenterContentBottomContent').style.top = jQuery('#div10').innerHeight() + "px";
}
}*/

var DeltaPx = 0;

function PositionDiv(div) {
    var middenContent = $get(div);
    if (middenContent != null) {
        var height = parseInt($get(div).offsetHeight) + parseInt($get('div10').offsetHeight);
        if (navigator.appVersion.indexOf("MSIE") >= 0) {
            height -= 40;
        } else {
            if (DeltaPx > 0) {
                DeltaPx -= 35;
            }
        }
        height += parseInt(DeltaPx);
        $get('div11').style.minHeight = height + "px";
        middenContent.style.visibility = "visible";
    }
}


function Slide(div) {
    //  var hulp = document.getElementById("contentmeerinfo");
    if (nu) {
        nu = false;
        jQuery('#ctl00_Main_hlLeesmeer').css("visibility", "hidden");
        jQuery('.' + div).slideDown("slow");
    } else {
        nu = true;
        jQuery('.' + div).slideUp("slow");
        jQuery('#ctl00_Main_hlLeesmeer').css("visibility", "visible");
    }
}


var imagewidth = 93;
var imageviews = 5;
var currentimageposition = 1;
var maximageposition = 0;

function ScrollLeftRight(div, direction) {
    var step = imagewidth * imageviews;
    maximageposition = ImageCount - (imageviews - 1);
    if (direction == "left") {
        if (currentimageposition < maximageposition) {
            if (maximageposition - currentimageposition >= imageviews) {
                step = imageviews * imagewidth;
            } else {
                step = (maximageposition - currentimageposition) * imagewidth;
            }
            document.getElementById('btnFotoScrollRight').style.visibility = "visible";
            jQuery('#' + div).animate({ "left": "-=" + step + "px" }, "slow");
            currentimageposition += step / imagewidth;
        }
    } else {
        document.getElementById('ctl00_Main_Product1_ProductInfo1_btnFotoScrollLeft').style.visibility = "visible";
        if (currentimageposition > 1) {
            if (currentimageposition > imageviews) {
                step = imageviews * imagewidth;
            } else {
                step = (currentimageposition - 1) * imagewidth
            }
            jQuery('#' + div).animate({ "left": "+=" + step + "px" }, "slow");
            currentimageposition -= step / imagewidth;
        }
    }
    if (currentimageposition == maximageposition) {
        document.getElementById('ctl00_Main_Product1_ProductInfo1_btnFotoScrollLeft').style.visibility = "hidden";
        document.getElementById('btnFotoScrollRight').style.visibility = "visible";
    }
    if (currentimageposition == 1) {
        document.getElementById('ctl00_Main_Product1_ProductInfo1_btnFotoScrollLeft').style.visibility = "visible";
        document.getElementById('btnFotoScrollRight').style.visibility = "hidden";
    }
}


function loadWebCollage(URL) {
    document.body.style.overflow = "hidden";
    var flixheader = document.getElementById("flixheader");
    ModalWin = document.getElementById("FlixFrame");
    ModalWin.src = URL;
    $find('mpFlixMedia').show();
}

function loadBoschDemo(URL) {
    document.body.style.overflow = "hidden";
    var flixheader = document.getElementById("flixheader");
    flixheader.style.width = "700px"
    ModalWin = document.getElementById("FlixFrame");
    ModalWin.style.width = "708px";
    ModalWin.style.height = "530px";
    ModalWin.style.backgroundColor = "#FFFFFF";
    ModalWin.src = "http://webapps.easy2.com/cm/masterflash/generic_index.asp?page_id=36118726&splashpage=1'"; //,'','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=467";
    //$find('FlixMedia').show();
    jQuery('#FlixMedia').css('display', 'block');
}

function CloseFlixFrame() {
    jQuery('#FlixMedia').css('display', 'none');
}


function ShowFullProductDescription() {
    var ShortDesc = document.getElementById('ctl00_Main_Product1_ShortDescription');
    var Beschrijving = document.getElementById('ctl00_Main_Product1_Beschrijving');
    var productbeschrijvingvolgende = document.getElementById('ctl00_Main_Product1_productbeschrijvingvolgende');
    var LinkButton5 = document.getElementById('ctl00_Main_Product1_LinkButton5');
    ShortDesc.style.display = "none";
    Beschrijving.style.display = "block";
    productbeschrijvingvolgende.style.display = "block";
    LinkButton5.style.display = "none";
}

function trim(value) {
    value = value.replace(/^\s+/, '');
    value = value.replace(/\s+$/, '');
    return value;
}

function SetMinValue(sender, eventArgs) {
    var MinBox = document.getElementById("ctl00_Main_TextMin");
    MinBox.value = sender.get_value();

}

function SetMaxValue(sender, eventArgs) {
    var MaxBox = document.getElementById("ctl00_Main_TextMax");
    MaxBox.value = sender.get_value();
}
function submitform() {
    //document.forms[0].action = "";
    return true;
}

function EndRequestHandler() {
    addWkColumn();
}

function ShowActions(actie, link) {
    var elements = document.getElementsByTagName("div");
    for (i = 0; i < elements.length; i++) {
        if (elements[i].name == actie) {
            elements[i].style.display = "block";
        }
    }
    var hulp = document.getElementById(link);
    hulp.parentNode.parentNode.parentNode.style.display = "none";
}

var olddiv = null;
var oldplayer = null;
var player = null;

function addWkColumn(tblId, wkStart) {
    var tbl = document.getElementById(tblId);

    var tblBodyObj = tbl.tBodies[0];
    var newCell = null;
    for (var i = 0; i < tblBodyObj.rows.length; i++) {
        // Month Header
        if (i == 0) {
            // Add extra colspan column
            tblBodyObj.rows[i].cells[0].colSpan = 8;
        }
        // Week Header
        if (i == 1) {
            // Add week column headline
            newCell = tblBodyObj.rows[i].insertCell(0);
            newCell.innerHTML = 'Wk';
            newCell.style.fontSize = '8pt';
            newCell.style.fontWeight = 'bold';
            newCell.style.verticalAlign = 'bottom';
            newCell.style.backgroundColor = '#ffffff';
        }

        // Normal row
        if (i >= 2) {
            // Add the weeknumbers
            newCell = tblBodyObj.rows[i].insertCell(0);
            if (tblBodyObj.rows[i].cells[1].style.color != 'white' || tblBodyObj.rows[i].cells[2].style.color != 'white' || tblBodyObj.rows[i].cells[3].style.color != 'white' || tblBodyObj.rows[i].cells[4].style.color != 'white' || tblBodyObj.rows[i].cells[5].style.color != 'white' || tblBodyObj.rows[i].cells[6].style.color != 'white' || tblBodyObj.rows[i].cells[7].style.color != 'white') {
                if (wkStart == 54) {
                    wkStart = 1;
                }
                newCell.innerHTML = wkStart;
                wkStart += 1;
            }
            newCell.style.fontSize = '8pt';
            newCell.style.backgroundColor = '#ffffee';
        }
    }
}

function fnClickOK(sender, e) {
    __doPostBack(sender, e);
}

function swapImage(afbeelding, src) {
    var hulp = document.getElementById(afbeelding);
    hulp.src = src;
}

function hover(what, classname) {
    var hulp = document.getElementById(what);
    hulp.className = classname;
}

function checkme(checkbox) {
    var hulp = document.getElementsByName("radio1")
    hulp[checkbox].checked = true;
}

var interval;

function setScrolling(div, direction) {
    interval = setInterval("scrolldiv('" + div + "','" + direction + "')", 1);
}

function stopScrolling() {
    clearInterval(interval);
}

function scrolldiv(div, direction) {
    var hulp = document.getElementById(div);
    // alert(hulp.scrollHeight);
    if (direction == 'up') {
        if (hulp.scrollTop < hulp.scrollHeight) {
            hulp.scrollTop += 4;
        }
    }
    if (direction == 'down') {
        if (hulp.scrollTop > 0) {
            hulp.scrollTop += -4;
        }
    }
}

function UpdateCheckBoxListMerk(CBL, values, length) {
    for (i = 0; i < length; i++) {
        var item = document.getElementById(CBL + '_' + i);
        if (values.indexOf(';' + i + ';') >= 0) {
            item.checked = true
        } else {
            item.checked = false;
        }
    }
}

function LoadMeerImages() {

}

function loadinfo(ContentId, Soort) {
    //ret = getinfo.getinfo(ContentId, Soort, OnCompleteDojo, OnTimeOutDojo, OnErrorDojo);
    scrollTo(0, 0);
    jQuery('#Overlay').load('/informatie/default2.aspx', { "ContentId": ContentId, "Soort": Soort });

}

function showbanners() {

    var hulp = document.getElementById('banner4');
    if (hulp != null) {
        hulp.style.visibility = 'visible';
    }
    hulp = document.getElementById('banner3');
    if (hulp != null) {
        hulp.style.visibility = 'visible';
    }
}

function showdivhideold(Div, display) {
    if (player) {
        //  document.getElementById(oldplayer).sendEvent('STOP');
        try {
            player.sendEvent('STOP');
            player.sendEvent('REDRAW');
        } catch (ex) {

        }
        //player = null;
    }
    /*    if (olddiv != null) {
    olddiv.style.display = 'none';
    }
    var hulp = document.getElementById(Div);
    hulp.style.display = display;
    olddiv = hulp;*/


}

function showdivhideoldreset(Div, display, element) {
    if (olddiv != null) {
        olddiv.style.display = 'none';
    }
    var hulp = document.getElementById(Div);
    hulp.style.display = display;
    olddiv = hulp;
    if (player) {
        try {
            player.sendEvent('STOP');
        } catch (err) {
            alert(" Error2");
        }
    }
    //  player = null;
}

function playerReady(obj) {
    player = document.getElementById(obj['id']);
    player.addModelListener("STATE", "playerStarted");
    player.addControllerListener("PLAY", "playerStartPressed");
    player.addViewListener("STOP", "playerStopPressed");
};

function PlayPlayListItem(index) {
    if (olddiv != null) {
        olddiv.style.display = 'none';
    }
    var hulp = document.getElementById("Movies");
    hulp.style.display = 'block';
    olddiv = hulp;
    if (player) {
        player.sendEvent("ITEM", index);
        //   player.sendEvent("PLAY");
    }
}


function OnCompleteDojo(arg) {

    document.getElementById('Overlay').innerHTML = arg;
    window.scrollTo(0, 0);
}

function playerStopPressed(obj) {
    _gaq.push(['_trackEvent', 'videos', 'stop', player.getConfig().file]);
}

function playerStarted(obj) {
    switch (obj.newstate) {
        case "BUFFERING": { _gaq.push(['_trackEvent', 'videos', 'play', player.getConfig().file]); }
    }
}

function playerStartPressed(obj) {
    if (obj.state) {
        _gaq.push(['_trackEvent', 'videos', 'play', player.getConfig().file]);
    } else {
        _gaq.push(['_trackEvent', 'videos', 'pauze', player.getConfig().file]);
    }
}



function OnTimeOutDojo(arg) {
}

function OnErrorDojo(arg) {
}

function liftprodimg(img, div, productimage, url) {
    var hulp1 = document.getElementById(img);
    var prodimg = document.getElementById(productimage);
    prodimg.src = url;
    hulp1.style.width = "38px";
    hulp1.style.height = "38px";
    hulp1.style.top = "2px";
    var hulp2 = document.getElementById(div);
    hulp2.className = "imgdivhover";
}

function downprodimg(img, div) {
    var hulp1 = document.getElementById(img);
    hulp1.style.width = "28px";
    hulp1.style.height = "28px";
    hulp1.style.top = "6px";
    var hulp2 = document.getElementById(div);
    hulp2.className = "imgdiv";
}

function HoverTab(Tab) {
    Tab.className = "ProductTabsActiveTab"
}

function show(div, Tab) {
    var hulp = document.getElementById(div);
    hulp.style.display = "block";
    var myTab = document.getElementById(Tab);
    ActiveProductTab = Tab;
    //   alert(ActiveProductTab.id);
    HoverTab(myTab)
    /* ctl00_Main_Product1_Menu1n1.childNodes[0].className = "ProductTabsActiveTab";
    ctl00_Main_Product1_Menu1n0.childNodes[0].className = "ProductTabsInactivetab";*/
}

function showallReviews(Datalist, HLink) {
    var dl3 = document.getElementById(Datalist);
    if (dl3) {
        dl3.style.display = "block";
    }
    var link = document.getElementById(HLink);
    if (link) {
        link.style.display = "none";
    }
}

function hide(div, Tab) {
    var hulp = document.getElementById(div);
    if (hulp) {
        hulp.style.display = "none";
    }
    var myTab = document.getElementById(Tab);
    if (Tab) {
        UnHoverTab(myTab);
    }
}

function ShowModalPopup(ModalPopup) {
    $find(ModalPopup).show();
}

function HideModalPopup(ModalPopup) {
    document.body.style.overflow = "auto";
    $find(ModalPopup).hide();
}

function UnHoverTab(Tab) {
    if (Tab) {
        if (Tab.id != ActiveProductTab) {
            Tab.className = "ProductTabsInactivetab"
        }
    }
}

var ActiveProductTab = "ctl00_Main_Product1_tabBeschrijving";

ActiveTab = '';
ActiveLeft = ''
ActiveRight = '';

function changeclassname(left, right, content, action) {
    var tableft = document.getElementById(left);
    var tabright = document.getElementById(right);
    var tabcontent = document.getElementById(content);
    if (ActiveTab != content) {
        if (action == 'hover') {
            tableft.className = 'tablefthover';
            tabright.className = 'tabrighthover';
            tabcontent.className = 'tabcontenthover'
        }
        else {
            tableft.className = 'tableft';
            tabright.className = 'tabright';
            tabcontent.className = 'tabcontent'
        }
    }
}

function ClickTab(Id, Content, Left, Right) {
    if (ActiveTab != '') {
        document.getElementById(ActiveTab).className = 'tabcontent';
        document.getElementById(ActiveLeft).className = 'tableft';
        document.getElementById(ActiveRight).className = 'tabright';
    }
    ActiveTab = Content;
    ActiveLeft = Left;
    ActiveRight = Right;
    LoadMenu(Id);
}

function updateDisplay(event) {
    var ele = document.getElementById("ctl00_xpos");
    if (ele) {
        document.getElementById("ctl00_xpos").value = event.clientX;
        document.getElementById("ctl00_ypos").value = event.clientY;
    }
}

var foto = 0
var div_old = ""
function hideall() {
    var hulp
    for (i = 0; i <= Layers.length; i++) {
        hulp = document.getElementById(Layers[i]);
        if (hulp == "undefined") {
            hulp.style.display = "none";
        }
    }
}
function togglediv(Div, display) {
    if (div_old != "") {
        var hulp2 = document.getElementById(div_old);
        hulp2.style.display = "none";
    }
    div_old = Div
    hideall();
    var hulp = document.getElementById(Div);
    hulp.style.display = display;
    if (display == "block") {
        location.hash = 'Bijkoop';
    }
}




function popFotoZoom(pic) {
    mywin = window.open('/winkel/productinfo/zoom.aspx?foto=' + pic, 'mycal', 'width=550, height=570, left=25, top=25')
}

function myprint(artikel) {
    mywin = window.open('http://' + hostname + '/winkel/Productinfo/productinfo.aspx?Print=1&ProdId=' + artikel, 'Print', 'width=564, height=610, left=25, top=15')
}
function Pictogram(image) {
    myWin = window.open('http://' + hostname + '/Informatie/Pictogrammen/?image=' + image, 'pictogram', 'width=625, height=400, scrollbars=Yes, left=25, top=25')
}

var div_old = ""

function hideall() {
    var hulp
    for (i = 0; i <= Layers.length; i++) {
        hulp = document.getElementById(Layers[i]);
        if (hulp == "undefined") {
            hulp.style.display = "none";
        }
    }
}

function showmovie(filename, div, Artikelnr, _strhost) {
    var result = "";
    var hoogte = 260;
    result = "<p id=\"player\"" + Artikelnr + "\"><a href=\"http://www.macromedia.com/go/getflashplayer\">Get the Flash Player</a> to see this movie2.</p>\n";
    result += "<script type=\"text/javascript\">\n";
    result += " var so = new SWFObject('" + _strhost + "/lib/swf/flvplayer.swf','Player" + Artikelnr + "','300','" + hoogte + "','8');\n";
    result += " so.addParam(\"allowfullscreen\",\"false\");\n";
    result += " so.addParam(\"showfsbutton\",\"false\");\n";
    result += " so.addVariable(\"file\",\"" + filename + "\");";
    //'If start Then result += " so.addParam(\"autostart\",\"true\");" + vbCrLf
    result += " so.addParam(\"showdownload\",\"false\");\n";
    result += " so.addVariable(\"enablejs\",\"true\");\n";
    result += " so.addVariable(\"javascriptid\",'mpl');\n";
    result += " so.addVariable(\"width\",\"300\");\n";
    result += " so.addVariable(\"height\",\"" + hoogte + "\");\n";
    result += " so.addVariable(\"displaywidth\",\"300\");\n"
    result += " so.addVariable(\"displayheight\",\"240\");\n"
    result += " so.addVariable(\"backcolor\",\"0xFFFFFF\");\n"
    result += " so.addVariable(\"frontcolor\",\"0x40506E\");\n"
    result += " so.addVariable(\"lightcolor\",\"0x40506E\");\n"
    result += " so.write('player" + Artikelnr + "');\n"
    result += "</script>2"
    // '    alert(result);
    var hulp = document.getElementById(div);
    hulp.innerHTML = result;
}

var aantal2mansbezorging = 0;
var aantal1mansbezorging = 0;
var visiblediv = '';

function checkEenmansbezorging(rb) {
    var hulp = document.getElementsByTagName("input");
    for (i = 0; i < hulp.length; i++) {
        if (hulp[i].type == "radio" && hulp[i].id.indexOf('rblEenmansbezorging') >= 0) {
            if (hulp[i].value == rb.value) {
                hulp[i].checked = true;
            }
        }
    }
}

function showdiveenmansbezorging(div, display) {
    if (visiblediv != '' && visiblediv != div) {
        div = visiblediv;
    }
    var hulp = document.getElementById(div)
    if (display == 'none') {
        aantal2mansbezorging += 1;
    } else {
        if (aantal2mansbezorging > 0) {
            aantal2mansbezorging -= 1;
        }
    }
    if (aantal2mansbezorging > 0) {
        hulp.style.display = 'none';
        visiblediv = '';
    } else {
        hulp.style.display = 'block';
        visiblediv = div;
    }
}

function setAantal2mansbezorging(Aantal, Aantal1) {
    aantal2mansbezorging = Aantal;
    aantal1mansbezorging = Aantal1;
}

function togglediv(Div, display) {
    if (div_old != "") {
        var hulp2 = document.getElementById(div_old);
        hulp2.style.display = "none";
    }
    div_old = Div
    hideall();
    var hulp = document.getElementById(Div);
    hulp.style.display = display;
    if (display == "block") {
        location.hash = 'Bijkoop';
    }
}

function showdiv(Div, display) {
    var hulp = document.getElementById(Div);
    hulp.style.display = display;
}


function closeMicrosite(MicroSiteId) {
    var hulp = document.getElementById(MicroSiteId);
    hulp.src = '';
}

function loadMicrosite(MicroSiteId, mpMicroSiteId) {
    var hulp = document.getElementById(MicroSiteId);
    hulp.src = '" & URL & "';
    $find(mpMicroSiteId).show();
}

function DisableDemo() {
    jQuery(".DemoHolder").css("display", "none");
}

var playerid = ''
var blnMorenImages = false;
function ShowMoreImages(Artikel, SelectedImage) {
    playerid = 'player' + Artikel;
    blnMorenImages = true
    ret = meerafbeeldingen.GetAfbeeldingen(Artikel, SelectedImage, OnCompleteDojo, OnTimeOutDojo, OnErrorDojo);
}


function showmore(Div, display) {
    var hulp = document.getElementById(Div);
    hulp.style.display = display;
    //location.href='#BijArt';
}


function toggleinfo(id, tal, txt, na) {
    document.getElementById(id + "_TabText1" + na).style.display = "none";
    document.getElementById(id + "_TabText2" + na).style.display = "none";
    document.getElementById(id + "_TabText3" + na).style.display = "none";
    document.getElementById(id + "_TabText4" + na).style.display = "none";
    document.getElementById(id + "_TabText5" + na).style.display = "none";
    document.getElementById(id + "_TabTextG" + na).style.display = "none";
    document.getElementById(id + "_TabTextPA" + na).style.display = "none";
    document.getElementById(id + "_TabTextP1" + na).style.display = "none";
    document.getElementById(id + "_TabTextP2" + na).style.display = "none";
    document.getElementById(id + "_TabTextP3" + na).style.display = "none";
    document.getElementById(id + "_TabTextP4" + na).style.display = "none";
    document.getElementById(id + "_TabKop1" + na).style.zIndex = 130;
    document.getElementById(id + "_TabKop2" + na).style.zIndex = 130;
    document.getElementById(id + "_TabKop3" + na).style.zIndex = 130;
    document.getElementById(id + "_TabKop4" + na).style.zIndex = 130;
    document.getElementById(id + "_TabKop5" + na).style.zIndex = 130;

    document.getElementById(id + "_TabText" + txt + na).style.display = "block";
    document.getElementById(id + "_TabKop" + tal + na).style.zIndex = 140;
}

function doprint() {
    mywin = window.open('/informatie/cadeaubon.aspx?Print=1', 'Print', 'width=644, height=370, left=25, top=25')
}

function ClearOverlay() {
    document.getElementById('Overlay').innerHTML = '';
    var hulp = document.getElementById("banner4");
    if (hulp != null) {
        hulp.style.visibility = "visible";
    }
    hulp = document.getElementById("banner3");
    if (hulp != null) {
        hulp.style.visibility = "visible";
    }
}


var VergelijkArr = [];
var VergelijkProd = [];

function LoadCheck() {
    VergelijkArr = [];
    VergelijkProd = [];
    var frm = document.aspnetForm;
    var el = frm.elements;
    for (i = 0; i < el.length; i++) {
        if (el[i].type == "checkbox") {
            if ((el[i].checked) && (el[i].getAttribute('ArtNr') != null)) {
                VergelijkArr[VergelijkArr.length] = el[i].getAttribute('ArtNr');
                VergelijkProd[VergelijkProd.length] = el[i].getAttribute('ProdTitle');
            }
        }
    }
}



function VergelijkCheck(box, waarde) {
    LoadCheck();
    if (VergelijkArr.length > 3) {
        alert('U kunt maximaal 3 producten vergelijken');
        document.getElementById(box).checked = false;
    }
}


function DoVergelijk() {
    LoadCheck();
    if (VergelijkArr.length > 1) {
        var strVergelijkProducten = '/vergelijkfunctie';
        for (i = 0; i < VergelijkProd.length; i++) {
            strVergelijkProducten += '/' + VergelijkProd[i];
        }
        _gaq.push(['_trackPageview', strVergelijkProducten]);
        ret = VergelijkSrv.Switch(VergelijkArr, OnCompleteDojo, OnTimeOutDojo, OnErrorDojo);
    }
    else {
        alert('U moet minimaal 2 producten aanvinken om te vergelijken');
    }
}



function Click(RadioID, Link) {
    document.getElementById(RadioID).checked = true;
    //    label = document.getElementById('ctl00_Main_Label5');
    //    attr = document.getElementById(Link).getAttribute('extra');
    //    if (attr != '')
    //    { label.innerHTML = attr }
}
function checkme2(box) {
    Radios = ['ctl00_Main_RadioPin', 'ctl00_Main_RadioContant', 'ctl00_Main_HyperLinkPin', 'ctl00_Main_RadioCredit', 'ctl00_Main_RadioModern',
     'ctl00_Main_RadioAbn', 'ctl00_Main_RadioPostbank', 'ctl00_Main_RadioRabo', 'ctl00_Main_RadioSns', 'ctl00_Main_RadioFortis',
     'ctl00_Main_RadioVisa', 'ctl00_Main_RadioMaster', 'ctl00_Main_RadioAmerican', 'ctl00_Main_ctl01_Radio10plan', 'ctl00_Main_ctl03_RadioZomer',
     'ctl00_Main_ctl03_RadioUitstel3', 'ctl00_Main_ctl03_RadioUitstel6', 'ctl00_Main_ctl03_RadioUitstel18', 'ctl00_Main_ctl05_RadioTermijnen12',
     'ctl00_Main_ctl05_RadioTermijnen24', 'ctl00_Main_RadioTermijnen36', 'ctl00_Main_ctl07_RadioVast'];
    for (i = 0; i < Radios.length; i++) {
        if (document.getElementById(Radios[i]) != null) {
            document.getElementById(Radios[i]).checked = false;
        }
    }
    //if (document.getElementById('ctl00_Main_ctl03_RadioUitstel12') != null){
    // document.getElementById('ctl00_Main_ctl03_RadioUitstel12').checked=false};
    checkme(box);
}


/*  functies t.b.v. de locatie kiezer pakjegemak   */
var initialAddress;
var srcUrlAddress;
var srcUrlMode;
var srcUrlProductLabel;
var srcUrl;
var Host = "https://www.locatiekiezer.nl";

function getAddress() {
    var add
    try {
        var address = jQuery("#ctl00_Main_LabelAdres").text() + " " + jQuery("#ctl00_Main_LabelPlaats").text(); //' document.getElementById("txtAddressToPass").value;
        if (address.length > 0) {
            return address;  // return jQuery(address[0]).text();
        }
    } catch (e) {
        throw new Error("Please fill in Address");
    }
    return "";
}

function initializeUrl() {
    srcUrl = Host + "/default.aspx?apikey=e583a2b41120769d&stylesheet=&passdataurl=https://" + hostname + "/locatiekiezer/PassData.aspx"
}

function ShowPopup() {
    jQuery(".PakjeGemakRadio input").attr("checked", "checked");

    initializeUrl();
    srcUrlAddress = "&address=" + getAddress();
    if ((srcUrlAddress != "") && (srcUrlAddress != null)) {
        srcUrl += srcUrlAddress;
    }

    var productLabel = document.getElementById("txtProductLabelToPass").value;
    if ((srcUrlProductLabel != "") && (srcUrlProductLabel != undefined)) {
        srcUrlProductLabel = "&productlabel=ZAD";  // + productLabel;
    } else {
        srcUrlProductLabel = "&productlabel=ZAD";
    }
    srcUrl += srcUrlProductLabel;
    var gmapsVariant = "gmaps";
    /*document.getElementsByName("gmapsVariant");
    if(gmapsVariant[0].checked) {
    srcUrlMode = "&mode=" + gmapsVariant[0].value;
    } else {
    srcUrlMode = "&mode=" + gmapsVariant[1].value;
    }*/
    srcUrlMode += srcUrlMode;

    var locatiekiezer = document.getElementById("divLocatieKiezer");
    var popup = document.getElementById("divPopup");
    locatiekiezer.style.display = "block";
    popup.innerHTML = "<iframe id='iFramePopup' name='iFramePopup' src='" + srcUrl + "' frameborder='0' scrolling='no' style='width: 100%; height: 100%;'></iframe>";
}

function ClosePopup() {
    var locatiekiezer = document.getElementById('divLocatieKiezer');
    locatiekiezer.style.display = "none";
}


function Querystring(qs) { // optionally pass a querystring to parse
    this.params = new Object()
    this.get = Querystring_get
    if (qs == null)
        qs = location.search.substring(1, location.search.length)
    if (qs.length == 0) return
    qs = qs.replace(/\+/g, ' ')
    var args = qs.split('&') // parse out name/value pairs separated via &
    for (var i = 0; i < args.length; i++) {
        var value;
        var pair = args[i].split('=')
        var name = unescape(pair[0])
        if (pair.length == 2)
            value = unescape(pair[1])
        else
            value = name
        this.params[name] = value
    }
}

function Querystring_get(key, default_) {
    // This silly looking line changes UNDEFINED to NULL
    if (default_ == null) default_ = null;
    var value = this.params[key]
    if (value == null) value = default_;
    return value
}

function passData() {
    var name;
    var name2;
    var pos;
    var productCode;
    var street;
    var houseNr;
    var houseNrAdd;
    var postalCodeNum;
    var postalCodeAlpha;
    var city;
    var locationType;
    var qs = new Querystring();
    if (qs.get("action") == "confirm") {
        name = qs.get("name");
        street = qs.get("street");
        houseNr = qs.get("housenumber");
        houseNrAdd = qs.get("housenumberadd");
        postalCodeNum = qs.get("postalcodenum");
        postalCodeAlpha = qs.get("postalcodealpha");
        productCode = qs.get("productcode");
        city = qs.get("city");
        locationType = qs.get("locationType");
        name2 = name.replace("&nbsp;", " ").toLowerCase(); //.substring(name.toLowerCase().indexOf("postkantoor van tnt post") + "postkantoor van tnt post".length);
        pos = name2.indexOf("postkantoor van tnt post")
        if (pos >= 0) {
            pos += "postkantoor van tnt post".length;
            name2 = name.replace("&nbsp;", " ").substring(pos).trim();
        } else {
            name2 = name.replace("&nbsp;", " ");
        }
        //parent.parent.document.getElementById("txtAddress").value = street + " " + houseNr + " " + houseNrAdd;
        //parent.parent.document.getElementById("txtPostalCode").value = postalCodeNum + " " + postalCodeAlpha;
        //parent.parent.document.getElementById("txtCity").value = city;
        //parent.parent.document.getElementById("lblLocationName").innerHTML = name;
        //parent.parent.document.getElementById("txtProductCode").value = productCode;
        //parent.parent.document.getElementById("lblLocationType").innerHTML = locationType;

        parent.parent.document.getElementById("ctl00_Main_PakjeGemakLocatie").innerHTML = "Uw afhaallocatie:<br/>" + name2 + "<br />";
        parent.parent.document.getElementById("ctl00_Main_PakjeGemakLocatie").innerHTML += street + " " + houseNr + " " + houseNrAdd + "<br />";
        parent.parent.document.getElementById("ctl00_Main_PakjeGemakLocatie").innerHTML += postalCodeNum + " " + postalCodeAlpha + " ";
        parent.parent.document.getElementById("ctl00_Main_PakjeGemakLocatie").innerHTML += city + "<br />";
        if (parent.parent.document.getElementById("ctl00_Main_btnLocatieKiezer") != null) {
            parent.parent.document.getElementById("ctl00_Main_btnLocatieKiezer").style.display = "none";
        }
        parent.parent.document.getElementById("ctl00_Main_lnkLocatieKiezer").style.display = "block";


        parent.parent.document.getElementById("ctl00_Main_PakjeGemakAdres").value = street;
        parent.parent.document.getElementById("ctl00_Main_PakjeGemakHuisnummer").value = houseNr;
        parent.parent.document.getElementById("ctl00_Main_PakjeGemakToevoeging").value = houseNrAdd;
        parent.parent.document.getElementById("ctl00_Main_PakjeGemakPostcode").value = postalCodeNum + postalCodeAlpha;
        parent.parent.document.getElementById("ctl00_Main_PakjeGemakPlaats").value = city;
        parent.parent.document.getElementById("ctl00_Main_PakjeGemakName").value = name;
        //parent.parent.document.getElementById("PakjeGemakLocatie").innerHTML += productCode + "<br />";
        //parent.parent.document.getElementById("PakjeGemakLocatie").innerHTML += locationType + "<br />";
    }
    var parentPopup = parent.parent.document.getElementById("divLocatieKiezer");
    if (parentPopup) {
        parent.parent.ClosePopup();
    }
}

function PakjeGemakSet(Result) {
    alert(Result);
}


function OnSliderLoad(sender, args) {
    var secondHandle = $get("RadSliderEndDrag_" + sender.get_id());
    Sys.UI.DomElement.addCssClass(secondHandle, "rslDraghandle2");
    sliders[sliders.length] = sender;
}

function SetWebCollageDEMO(URL) {
    jQuery('a[name="DemoLink"]').attr('href', '#Top');
    jQuery('a[name="DemoLink"]').click(function () {
        window.open(URL, 'WebCollage', 'width=600, height=500');
    });
    jQuery('.DemoHolder').css('display', 'block');
}

jQuery(document).ready(function () {
    var re = new RegExp("utm_campaign=([A-Za-z0-9\.\-]*)");
    var match = re.exec(window.location.hash);
    if (match != null) {
        var c = match[1];
        var url = window.location;

        if (Modern.Webshop.Cookie != null) {

            $.ajax({
                type: 'POST',
                contentType: 'application/json',
                dataType: 'json',
                url: '/Service/Cookie.asmx/SetCampaignAndUrl',
                data: '{ campaign: "'+c+'", url: "'+url+'" }'
            });

        }
    }
});
