//Globale vars
var vfxWindow;
var vgcDivName          = "";
var vgcActiveDivName    = "";
var vgcImageName        = "";
var vgcSite             = "";

bw=new checkBrowser()

//_____________________________________________________________________________
//___________ Functions _______________________________________________________

function fgOpenWindow(vpcURL, vplXsize, vplYsize, vpbShowScrollbar) {
    var vlcCommand = 'width=' + vplXsize + ',height=' + vplYsize + ',dependent=1, status=yes,resizable=yes,toolbar=yes,menubar=yes,location=yes,scrollbars=auto';
    if (vpbShowScrollbar) vlcCommand += ',scrollbars';
    if (vfxWindow) if (!vfxWindow.closed) vfxWindow.close();
    vfxWindow = window.open(vpcURL,'LCsubsite',vlcCommand);
    vfxWindow.focus();
}
//_____________________________________________________________________________
function fgOpenNewWindow(vpcName, vpcURL, vplXsize, vplYsize, vpbShowScrollbar) {
    var vlcCommand = 'width=' + vplXsize + ',height=' + vplYsize + ',dependent=1, status=yes,resizable=yes,toolbar=yes,menubar=yes,location=yes,scrollbars=auto';
    if (vpbShowScrollbar) vlcCommand += ',scrollbars';
    //if (!vpcName.closed) vpcName.close();

    vpcName = window.open(vpcURL,vpcName,vlcCommand);
    vpcName.focus()
}

function fgOpenLC(vpcURL, vplXsize, vplYsize, vpbShowScrollbar) {
    var vlcCommand = 'width=' + vplXsize + ',height=' + vplYsize + ',dependent=1, status=yes,resizable=yes,toolbar=yes,menubar=yes,location=yes';
    if (vpbShowScrollbar) vlcCommand += ',scrollbars';
    if (vfxWindow) if (!vfxWindow.closed) vfxWindow.close();
    vfxWindow = window.open(vpcURL,'LC',vlcCommand);
    vfxWindow.focus();
}
//_____________________________________________________________________________

function fgOpenPopup(vpcURL, vplXsize, vplYsize, vpbShowScrollbar) {
    var vlcCommand = 'width=' + vplXsize + ',height=' + vplYsize; 
    //alert('site:' + vgcSite);
    if (vgcSite != ""){
        if (vpcURL.indexOf("?") == -1){ 
            vpcURL = vpcURL + '?site=' + vgcSite;
        }
        else
        {
            vpcURL = vpcURL + '&site=' + vgcSite;
        }
    }
    if (vpbShowScrollbar) vlcCommand += ',scrollbars';
    if (vfxWindow) if (!vfxWindow.closed) vfxWindow.close();
    vfxWindow = window.open(vpcURL,'LCpopup',vlcCommand);
    vfxWindow.focus();
}
//_____________________________________________________________________________

function plCheckOpener() {
    if (typeof window.opener != "undefined"){
        if (window.opener == null){
            window.open('../', 'LC', 'height="800", width="600",resizable=yes, status=yes,toolbar=yes,menubar=yes,location=yes,scrollbars=auto')
            window.focus()
        } else if ((window.opener.closed) && (bw.ie4 || bw.ie5 || bw.ie6 || bw.ie7 || bw.moz)){
            window.open('../', 'LC', 'height="800", width="600",resizable=yes, status=yes,toolbar=yes,menubar=yes,location=yes,scrollbars=auto')
            window.focus()
        } else if (window.opener.parent.vgcLC != 'yes'){
            window.open('../', 'LC', 'height="800", width="600",resizable=yes, status=yes,toolbar=yes,menubar=yes,location=yes,scrollbars=auto')
       //     window.opener.location.replace("../lc/")
            window.opener.focus();
        } else {
            window.opener.focus();
        }
    } else {
        fgOpenLC ('../',800,600,true);
    }
}
//_____________________________________________________________________________

function plCheckNewOpener(vpcSite) {

     window.open('../', vpcSite, 'height="800", width="600",resizable=yes, status=yes,toolbar=yes,menubar=yes,location=yes,scrollbars=auto')

}
//_____________________________________________________________________________

function pgValidate (){

var vllElements = window.document.forms[0].elements.length
var vlcElementName 
var vllPublicaties = 0

for (var vllCounter =0;vllCounter < vllElements; vllCounter ++){
    if(window.document.forms[0].elements[vllCounter].type == "checkbox"){
        var vlcElementName = window.document.forms[0].elements[vllCounter].name
        if (vlcElementName.indexOf("cch_") == -1){
            if (window.document.forms[0].elements[vllCounter].checked == 1){
                vllPublicaties ++
            }
        }
    }
}

if (vllPublicaties == 0){
    alert("U heeft geen publicatie geselecteerd")
    return
}


for (var vllCounter =0;vllCounter < vllElements; vllCounter ++){
    if(window.document.forms[0].elements[vllCounter].type == "text"){
        //Een aantal velden is niet verplicht
        if (window.document.forms[0].elements[vllCounter].value == ""){
            alert('U heeft een verplicht veld niet ingevuld')
            window.document.forms[0].elements[vllCounter].select()
            window.document.forms[0].elements[vllCounter].focus()
            return
        }
    } else {
        if (window.document.forms[0].elements[vllCounter].name == "cch_Factuuradresgelijk"){
            if (window.document.forms[0].elements[vllCounter].checked){
                break
            }
        }
    }
}
window.document.forms[0].submit()
}
//_____________________________________________________________________________

function fgValBijeenkomst(){

var vllElements = window.document.forms[0].elements.length
var vlcElementName 
var vllPublicaties = 0

for (var vllCounter =0;vllCounter < vllElements; vllCounter ++){
    if(window.document.forms[0].elements[vllCounter].type == "text"){
        //Een aantal velden is niet verplicht
        if (window.document.forms[0].elements[vllCounter].value == ""){
            alert('U heeft een verplicht veld niet ingevuld')
            window.document.forms[0].elements[vllCounter].select()
            window.document.forms[0].elements[vllCounter].focus()
            return
        }
    }
}
window.document.forms[0].submit()
}

//_____________________________________________________________________________
function checkBrowser(){
	var agent = navigator.userAgent.toLowerCase();
	this.ver=navigator.appVersion; 
	this.dom=document.getElementById?1:0; 
	this.ie7=(this.ver.indexOf("MSIE 7")>-1 && this.dom)?1:0;
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.moz=(agent.indexOf("firefox")>-1)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5 || this.ie7 || this.moz); 
	return this; 
}
//_____________________________________________________________________________

function pgAddPicture(vpcPath, vpcButton, vpbActive) {
    // add to array
    this.button = vpcButton;
    this.normal = new Image();
    this.normal.src = vpcPath + vpcButton + "_uit.jpg";        
    this.over = new Image();
    this.over.src = vpcPath + vpcButton + "_aan.jpg";
    //verberg alle divs in ie
    if(bw.ie4 || bw.ie5 || bw.ie6 || bw.ie7 || bw.moz){
        if (!vpbActive) plHideNavDiv(vpcButton);
    }
    
}

//_____________________________________________________________________________

function plSwitchImageToActive(vpcImageName){
var vlcImageSource

    //Als de var nog niet gevuld is dan is er nog geen item actief
    if (vgcImageName != ""){
        vlcImageSource = eval("vlaImages." + vgcImageName + ".normal.src")
        eval("document.images['" + vgcImageName + "'].src='" + vlcImageSource + "'");
    }
        //selecteer de goede div en zet deze op hidden    
    if (vgcDivName != ""){
        plHideNavDiv(vgcDivName)
    }
    vgcImageName = vpcImageName
    vgcDivName = vpcImageName
    vlcImageSource = eval("vlaImages." + vgcImageName + ".over.src")
    eval("document.images['" + vgcImageName + "'].src='" + vlcImageSource + "'");

    //selecteer de goede div en zet deze op visible    
    plHideNavDiv(vgcActiveDivName)
    plShowNavDiv(vgcImageName)
}
//_____________________________________________________________________________

function plHideDiv(){
    //selecteer de goede div en zet deze uit    

    if (vgcDivName != ""){
        plHideNavDiv(vgcDivName)
        plShowNavDiv(vgcActiveDivName)
    }
    //Als een topmenuplaatje actief is, moet deze naar inactief worden gezet
    if (vgcImageName != ""){
        vlcImageSource = eval("vlaImages." + vgcImageName + ".normal.src")
        eval("document.images['" + vgcImageName + "'].src='" + vlcImageSource + "'");
    }
}

//_____________________________________________________________________________

function plShowDiv(vpcImageName){
    //Deze functie zet het vorige op inaktief en de div bij het huidige plaatje op visible

    if (vgcImageName != ""){
        vlcImageSource = eval("vlaImages." + vgcImageName + ".normal.src")
        eval("document.images['" + vgcImageName + "'].src='" + vlcImageSource + "'");
    }

    if (vgcDivName != ""){
        plHideNavDiv(vgcDivName)
        plHideNavDiv(vgcActiveDivName)
    }

    vgcImageName = vpcImageName
    plShowNavDiv(vpcImageName)

    vgcImageName = ""
    vgcDivName = vpcImageName
}

//_____________________________________________________________________________

function plShowNavDiv(vpcDivName){

    //Deze functie zet een div uit adhv een browser
    if (vpcDivName != ""){
        if (bw.ie4){
            eval("div" + vpcDivName + ".style.visibility = 'visible';")
        }else if (bw.ie5 || bw.ie6 || bw.ie7 || bw.moz) {
    	    eval("div" + vpcDivName + ".style.display = '';")
    	}else{
    	    eval("document.div" + vpcDivName +".visibility='show';")
    	}
    }
}

//_____________________________________________________________________________

function plHideNavDiv(vpcDivName){

    //Deze functie zet een div uit adhv een browser
    if (vpcDivName != ""){
        if (bw.ie4){
            eval("div" + vpcDivName + ".style.visibility = 'hidden';")
        }else if (bw.ie5 || bw.ie6 || bw.ie7 || bw.moz) {
    	    eval("div" + vpcDivName + ".style.display = 'none';")
    	}else{
    	    eval("document.div" + vpcDivName + ".visibility = 'hide'")
    	}
    }
}
  
//_____________________________________________________________________________
    
function fgbValMail(){
    if (window.document.forms[0].ctxEmail.value == ""){
        alert("Het emailadres is verplicht");
        window.document.forms[0].ctxEmail.focus();
        return false;
    }
    if (window.document.forms[0].ctxOnderwerp.value == ""){
        alert("Het onderwerp is verplicht");
        window.document.forms[0].ctxOnderwerp.focus();
        return false;
    }
    if (window.document.forms[0].ctxBericht.value == ""){
        alert("Het bericht is verplicht");
        window.document.forms[0].ctxBericht.focus();
        return false
    }
window.document.forms[0].submit()
}

//_____________________________________________________________________________
    
function pgValidVote(){
	var vlbActive = false;
	var vlxForm = window.document.hfsPoll;

    for (var i=0; i < vlxForm.cobPoll.length; i++) {
        if (vlxForm.cobPoll[i].checked) vlbActive = true; 
    }
    if (!vlbActive) {
        alert("Kies eerst een van de opties");
    } else {
        // als we hier zijn is alles goed gegaan: submit
    vlxForm.submit()
    }

}

//_____________________________________________________________________________

function pgSetCursor(vpcDestination){
    if (bw.ie5 || bw.ie6 || bw.ie7 || bw.moz) {
        vpcDestination.style.cursor = 'default';
    } else if(bw.ie4) {
        vpcDestination.style.cursor = 'default';
    } else {
    }
    
}

//_____________________________________________________________________________



