﻿String.prototype.trim = function () {
    return this.replace(/^\s+|\s+$/g, "");
}
String.prototype.ltrim = function () {
    return this.replace(/^\s+/, "");
}
String.prototype.rtrim = function () {
    return this.replace(/\s+$/, "");
}

function SetSelected(cntToSelect) {
    document.getElementById(cntToSelect).select();
    return true;
}
function ShowLogin() {
    oWebDialogWindow1 = $find('ctl00_ctl00_wdwLogon');
    oWebDialogWindow1.set_windowState($IG.DialogWindowState.Normal);
    document.getElementById('ctl00_ctl00_wdwLogon_tmpl_inpLogonScreenVisible').value = 1;
    document.getElementById('ctl00_ctl00_wdwLogon_tmpl_txtCustomerCode').select();

    if (document.getElementById('ctl00_ctl00_wdwLogon_tmpl_imgErrorLogon') != null) {
        document.getElementById('ctl00_ctl00_wdwLogon_tmpl_imgErrorLogon').style.display = 'none';
    }
    return true;
}
function HideLogin() {
    oWebDialogWindow1 = $find('ctl00_ctl00_wdwLogon');
    oWebDialogWindow1.set_windowState($IG.DialogWindowState.Hidden);
    document.getElementById('ctl00_ctl00_wdwLogon_tmpl_inpLogonScreenVisible').value = 0;
    return false;
}
function ShowGeneralConditions() {
    oWebDialogWindow1 = $find('ctl00_ctl00_wdwGeneralConditions');
    oWebDialogWindow1.set_windowState($IG.DialogWindowState.Normal);
    return false;
}
function HideGeneralConditions() {
    oWebDialogWindow1 = $find('ctl00_ctl00_wdwGeneralConditions');
    oWebDialogWindow1.set_windowState($IG.DialogWindowState.Hidden);
    return true;
}
function ShowInfo() {
    //oWebDialogWindow1 = $find('ctl00_ctl00_wdwInfo');
    //oWebDialogWindow1.set_windowState($IG.DialogWindowState.Normal);
    document.getElementById('divInfo').style.display = 'block';
    return true;
}
function HideInfo() {
    //oWebDialogWindow1 = $find('ctl00_ctl00_wdwInfo');
    //oWebDialogWindow1.set_windowState($IG.DialogWindowState.Hidden);
    document.getElementById('divInfo').style.display = 'none';
    return true;
}
function ShowWait(sender, args) {
    document.getElementById('divWait').style.display = 'block';    
    return true;
}
function HideWait() {
    document.getElementById('divWait').style.display = 'none';
    return true;
}
function clickButton(e, buttonid) {
    var evt = e ? e : window.event;
    var bt = document.getElementById(buttonid);
    if (bt) {
        if (evt.keyCode == 13) {
            bt.click();
            return false;
        }
    }
}
function ShowLostPwd() {
    oWebDialogWindow1 = $find('ctl00_ctl00_wdwLogon');
    oWebDialogWindow1.set_windowState($IG.DialogWindowState.Hidden);
    oWebDialogWindow1 = $find('ctl00_ctl00_wdwLostPassword');
    oWebDialogWindow1.set_windowState($IG.DialogWindowState.Normal);
    return false;
}
function HideLostPwd() {
    oWebDialogWindow1 = $find('ctl00_ctl00_wdwLostPassword');
    oWebDialogWindow1.set_windowState($IG.DialogWindowState.Hidden);
    return false;
}

function ShowPDFDocument(filename) {
    window.open(filename, "_blank", "");
}

function ShowCommercInfoDiv(divName) {
    if (document.getElementById(divName).style.display == 'block') {
        document.getElementById(divName).style.display = 'none';
    }
    else {
        // verberg alle andere divs
        var arr = document.getElementsByTagName("div");
        for (i = 0; i < arr.length; i++) {
            if (arr[i].id.startsWith('divCommercInfo') == true) {
                arr[i].style.display = 'none';
            }
        }
        document.getElementById(divName).style.display = 'block';
    }
    return true;
}

function HideCommercInfoDiv(divName) {
    document.getElementById(divName).style.display = 'none';
    return true;
}

function ShowOptionInfoDiv(divName) {
    if (document.getElementById(divName).style.display == 'block') {
        document.getElementById(divName).style.display = 'none';
    }
    else {
        // verberg alle andere divs
        var arr = document.getElementsByTagName("div");
        for (i = 0; i < arr.length; i++) {
            if (arr[i].id.startsWith('divInfo') == true) {
                arr[i].style.display = 'none';
            }
        }
        document.getElementById(divName).style.display = 'block';
    }
    return true;
}

function HideOptionInfoDiv(divName) {
    document.getElementById(divName).style.display = 'none';
    return true;
}

function alertSize() {
    var myWidth = 0, tabWidth = 0;
    // testen of div divBody op pagina bestaat
    if (document.getElementById('divBody') != null && document.getElementById('ctl00_ctl00_cphBody_cphMasterPage_wtaOvername') != null) {
        if (typeof (window.innerWidth) == 'number') {
            //Non-IE
            myWidth = window.innerWidth;
            myHeight = window.innerHeight;
        } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
            //IE 6+ in 'standards compliant mode'
            myWidth = document.documentElement.clientWidth;
            myHeight = document.documentElement.clientHeight;
        } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
            //IE 4 compatible
            myWidth = document.body.clientWidth;
            myHeight = document.body.clientHeight;
        }

        tabWidth = myWidth - (document.getElementById('ctl00_ctl00_cphBodyRight_cphBodyRight_udpBoxes').offsetWidth * 2) - 60;
        //document.getElementById('ctl00_ctl00_cphBody_cphMasterPage_wtaOvername').style.width = tabWidth + 'px';
        document.getElementById('divWtaOvername').style.width = tabWidth + 'px';
    }
}

function validateEmail(elementValue) {
    var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
    return emailPattern.test(elementValue);
}
