/* Interface Script  */

//variabelen//
var arrTab = new Array();
var splashWindow;

//functions//
function registerTab(strName,nTabs){
    var i = arrTab.length
    arrTab[i] = new Array();
    for(var j=0; j<nTabs;j++){
       arrTab[i][j] = new Array();
       arrTab[i][j][0] = strName + j + "_left";
       arrTab[i][j][1] = strName + j;
    }
}

function changeTab(el){
    var bFound = false;
    if(el&&el.id){
        for(var i=0; i<arrTab.length; i++){
            for(var j=0; j<arrTab[i].length; j++){
                if(arrTab[i][j].length==2&&(el.id==arrTab[i][j][0]||el.id==arrTab[i][j][1])){
                    setClass(arrTab[i][j][0],"tableft_active");
                    setClass(arrTab[i][j][1],"tab_active");
                    bFound = true;
                    break;
                }
            }
            if(bFound){
               for(var k=0; k<arrTab[i].length; k++){
                    if(k!=j&&arrTab[i][j].length==2){
                        setClass(arrTab[i][k][0],"tableft");
                        setClass(arrTab[i][k][1],"tab");
                    }
               }
               return;
            }
        }
    }
}

function setClass(strID,strClass){
    var el = document.getElementById(strID);
    if(el){
        el.className = strClass;
    }
}

function setFrame(strID,strUrl){
    var el = document.getElementById(strID);
    if(el){
       if(el.tagName.toLowerCase()=="iframe")el.src = strUrl;
    }
}

function openPopUp(strURL,intWidth,intHeight){
    if(intHeight==undefined||intWidth==undefined){
        childWindow = window.open(strURL,"_blank","location=0,menubar=0,toolbar=0,status=0,top=100,left=100,resizable=1,scrollbars=1,width=400,height=400;");
    }else{ 
        childWindow = window.open(strURL,"_blank","location=0,menubar=0,toolbar=0,status=0,top=100,left=100,resizable=1,scrollbars=1,width="+intWidth+",height="+intHeight+";");
    }
}

function openMail(strURL,box,to){
    var dummy =  showModalDialog(strURL+"?box="+box+"&to="+to,"_blank","dialogLeft:100px; dialogTop:200px;dialogWidth:700px; dialogHeight:750px; status:no; scroll:no;help:no;");
}

function openReturnWindow(strURL,toField,intWidth,intHeight){
   if(intHeight==undefined||intWidth==undefined){
       var returnValue = showModalDialog(strURL,"_blank","center: yes; dialogWidth:350px; dialogHeight:620px; status:no; scroll: auto; help: no;");
   }else{
       var returnValue = showModalDialog(strURL,"_blank","center: yes; dialogWidth:"+intWidth+"px; dialogHeight:"+intHeight+"px; status:no; scroll: auto; help: no;");
   }
    if(returnValue!=null&&returnValue!=""){

        if(document.getElementById("data")&&document.getElementById(toField)){
                //exception -> value start with / -> must be  an uri for an internal jump
               if(returnValue.indexOf("/") ==0){
                    window.open(returnValue,"_top");
               }else{
                    document.getElementById(toField).value = returnValue;
                    document.getElementById("data").submit();
               }
        }
    }
}

function getReturnValueDialog(strURL,intWidth,intHeight){
   if(intHeight==undefined||intWidth==undefined){
       var returnValue = showModalDialog(strURL,"_blank","dialogLeft:200px; dialogTop:100px; dialogWidth:350px; dialogHeight:620px; status:no; scroll:no;help:no;");
   } else {
       var returnValue = showModalDialog(strURL,"_blank","dialogLeft:200px; dialogTop:100px; dialogWidth:"+intWidth+"px; dialogHeight:"+intHeight+"px; status:no; scroll:no;help:no;");
   }
   if(returnValue && returnValue.indexOf("/") == 0) {  //must be an uri for an internal jump
            window.open(returnValue,"_top");
            return false;
   } else {
        return returnValue;
   }
}

function openSplash(strURL){
    if(splashWindow!=null){
        splashWindow.close();
        splashWindow = null;
    }
    splashWindow = window.open(strURL,"_blank","location=0,menubar=0,toolbar=0,scrollbars=1,status=0,top=0,left=0,width="+(screen.width-10)+",height="+(screen.height-30));
}

function postTo(strURL,strTarget,strID,strValue){
    var myForm = document.getElementById("data");
    var myEl = document.getElementById(strID); 
    if(myForm){
        myForm.action = strURL;
        myForm.target = strTarget;
        if(myEl)myEl.value = strValue;
        myForm.submit();
    }
}

function setAccount(){
  if(document.getElementById("txtUsername")!=null&&document.getElementById("txtPassword")!=null){
    date = new Date();
    if(base64encode&&utf16to8){
        document.cookie = "account=" + base64encode(utf16to8( document.getElementById("txtUsername").value + "||" + document.getElementById("txtPassword").value));
    }
    document.getElementById("txtUsername").value = "";
    document.getElementById("txtPassword").value = "";
  }
}

function setBtnOK(el){
   if(el.options&&document.getElementById("btnOK")){
       var bSelected = false;
       for(var i=0; i<el.options.length; i++){
            if(el.options[i].selected){
                bSelected = true;
                break;
            }
        }
        if(bSelected){
            document.getElementById("btnOK").disabled = false;
            document.getElementById("btnOK").className = "button";
        }else{
            document.getElementById("btnOK").disabled = true;
            document.getElementById("btnOK").className = "buttondisabled";
        }
    }
}

function setReturnValueFromId(id){
    var el = document.getElementById(id);
    if(el.options){
        window.returnValue = "";
        for(var i=0; i<el.options.length; i++){
            if(el.options[i].selected){
                if(window.returnValue!="")window.returnValue+=",";
                window.returnValue+=el.options[i].value;
            }
        }
    }else if(el.value){
        window.returnValue = el.value;
    }
    window.close();
}

function setReturnValue(strValue){
    window.returnValue = strValue;
    window.close();
}

function setElementValue(strID,strValue){
    var el = document.getElementById(strID); 
   if(el)try{el.value=strValue}catch(e){}; 
}

function postToMailList(mailBox,mailStatus,misc,target,url){
    var el = document.getElementById("data"); 
    var elparam1 = document.getElementById("mailboxID");  
    var elparam2 = document.getElementById("mailstatusID");   
    var elparam3 = document.getElementById("miscID");   
    if(el){
        if(mailBox!=undefined && elparam1)elparam1.value = mailBox;
        if(mailStatus!=undefined && elparam2)elparam2.value = mailStatus;
        if(misc!=undefined && elparam3)elparam3.value = misc;
        if(target!=undefined)el.target = target;
        if(url!=undefined)el.action = url;
        el.submit();
   } 
}

function maxLength(el,aantal){
	var objectstring = new String(el.value);
	if(objectstring.length > Number(aantal)){
		while(objectstring.length > Number(aantal)){
			objectstring=objectstring.substring(0,(objectstring.length-1));
		}
		el.value = objectstring;
	}
}
//events//
window.onload = function() {
    var intIFrameHeight;
    var frameObjects = parent.document.getElementsByTagName("iframe");
    if (frameObjects) {
        for (var i = 0; i < frameObjects.length; i++) {
            intIFrameHeight = 0;
            if (frameObjects[i].Document && frameObjects[i].Document.body) intIFrameHeight = frameObjects[i].Document.body.scrollHeight;
            if (frameObjects[i].contentDocument && frameObjects[i].contentDocument.body) intIFrameHeight = frameObjects[i].contentDocument.body.scrollHeight;         
            if (intIFrameHeight != 0 && frameObjects[i].id != "popup" && frameObjects[i].id != "inlogbox" && frameObjects[i].id.indexOf("edit_") == -1) {
                if (intIFrameHeight > 560) frameObjects[i].style.height = intIFrameHeight + "px";
                else frameObjects[i].style.height = "560px";  
            }
            if (frameObjects[i].id == "inlogbox") frameObjects[i].style.height = intIFrameHeight;
        }
    }
};

//exe//
