﻿
function switchTeaserView(strTeaser){
    var objImg = document.getElementById(strTeaser + "Img");
    var objLink = document.getElementById(strTeaser + "Link");
    var objFullText = document.getElementById(strTeaser + "FullText");
    if (objFullText != null){
        if (objFullText.style.display == "none"){
            // Show full text
            objImg.setAttribute("src", "../images/box_arrow_close.gif");
            objLink.style.display = "none";
            objFullText.style.display = "inline";
        }else{
            // Hide full text
            objImg.setAttribute("src", "../images/box_arrow_open.gif");
            objLink.style.display = "inline";
            objFullText.style.display = "none";
        }
    }
}

function dn(){
    // do nothing
}

function setButtonActive(objSender, strControl){
    //alert(document.getElementById(strControl).id);
    if (objSender.checked){
        document.getElementById(strControl).removeAttribute("disabled");
    }else{
        document.getElementById(strControl).setAttribute("disabled", "disabled");
    }
}

function preloadImages() {
    var d=document; if(d.images){ if(!d.pic) d.pic=new Array();
    var i,j=d.pic.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.pic[j]=new Image; d.pic[j++].src=a[i];}}
}

preloadImages('../images/box_arrow_open.gif');
preloadImages('../images/box_arrow_close.gif');

function FormatButtons(ctlCountries, strProduct){
    var strValues = ctlCountries.options[ctlCountries.options.selectedIndex].value;
    if (strValues != "-1"){
        var arrValues = strValues.split(",");
        SetAction("ctl" + strProduct + "Order", arrValues[0]);
        SetAction("ctl" + strProduct + "Download", arrValues[1]);
        if (strProduct == "Office"){
            SetAction("ctl" + strProduct + "Testdrive", arrValues[2]);
        }
    }else{
        SetAction("ctl" + strProduct + "Download","");
        SetAction("ctl" + strProduct + "Order","");
        if (strProduct == "Office"){
            SetAction("ctl" + strProduct + "Testdrive","");
        }
    }
}

function SetAction(strButtonCtrl, strAction){
    var ctlButton = document.getElementById(strButtonCtrl);
    if(strAction != ""){
        ctlButton.setAttribute("strAction", strAction);
        ctlButton.onclick = function() { location.href=this.getAttribute("strAction"); }
        ctlButton.removeAttribute("disabled");
    }else{
        ctlButton.onclick = function() { }
        ctlButton.setAttribute("disabled","disabled");
    }
}

function InitDoc(ctlDoc){
    FormatButtonsInit(ctlDoc, "Office");
    FormatButtonsInit(ctlDoc, "Vista");
}

function FormatButtonsInit(ctlDoc, strProduct){
    if(ctlDoc.getElementById("ctl" + strProduct + "Countries")){
        FormatButtons(ctlDoc.getElementById("ctl" + strProduct + "Countries"),strProduct);    
    }
}