var editorVerslag = false;
var editorReactie = false;

function aan(simple,el){
    //gastenboek
    if(simple){
        var buttons = 'bold,italic,smileys';
    //verslag
    }else{
        var buttons = 'bold,italic,underline,|,undo,redo,|,bullist,numlist,|,link,unlink,|,afbeelding,smileys,|,cleanup,|,justifyleft,justifycenter,justifyright,justifyfull';        
    }
    tinyMCE.init({
	    mode : "exact",
	    theme : "advanced",
        theme_advanced_toolbar_location : "top",
        content_css : "http://www.reisprofiel.nl/style/beheer.css",
        elements : el,
        cleanup: true,
        cleanup_on_startup : true,
        theme_advanced_toolbar_location : "top",
        theme_advanced_buttons1 : buttons,
       setup : function(ed) {  
           // Register example button
          ed.addButton('afbeelding', {
             title : 'Insert image',
             image : '../js/tiny_mce/themes/advanced/img/image.gif',
             onclick : function() {
                window.open('../js/tiny_mce/afbeeldingen.php?id='+profielId,'afbeeldingenWindow','width=650,height=500,scrollbars=1');
             }
          });
           // Register example button
          ed.addButton('smileys', {
             title : 'Insert emoticon',
             image : '../js/tiny_mce/themes/advanced/img/emotions.gif',
             onclick : function() {
                window.open('../js/tiny_mce/smileys.php?id='+profielId+'&editor='+el,'smileyWindow','width=180,height=180,scrollbars=1');
             }
          });
       }
    });
    tinyMCE.execCommand('mceCleanup', false);
}

var IE = document.all?true:false;

function ajaxFunction()
  {
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    return xmlHttp;
  }
 
function updateAdres() {
    var adresSpan = document.getElementById('adres');
    var tipSpan = document.getElementById('tipSpan');
    var adresInput = document.getElementById('profielnaam');
    var re = /\$|,|ë|é|è|á|ä|à|ó|ö|ò|ú|ü|ù|í|ï|ì|@|#|~|`|\/|\%|\*|\^|\&|\(|\)|\+|\=|\[|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|\./g;
    
    if ((adresInput.value.search(re) != -1) ||(adresInput.value.search(" ") != -1) ) {
        tipSpan.innerHTML = "<strong>Let op:</strong> spaties en leestekens behalve een min-teken zijn niet toegestaan.";
    }
    
    tekst = adresInput.value.replace(re, "");
    tekst = tekst.replace(" ", "");
    tekst = tekst.replace("  ", "");
    tekst = tekst.substr(0, 30);

    if (tekst == undefined) tekst = "";
    if (tekst == "undefined") tekst = "";
    
    if (tekst != "") {
        adresInput.value = tekst;
        adresSpan.innerHTML = tekst+".";
    }else{
        if (adresInput.value != "") {
            adresInput.value = "";
        }
        adresSpan.innerHTML = tekst;
    }
    url = 'http://www.reisprofiel.nl/classes/ajax/avaiProfiel.php?profielNaam='+tekst;
    checkAv(url);
}

var elementNaam=false;

function getScrollXY(type) {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  if(type=='y'){
    return scrOfY;
  }
  return [ scrOfX, scrOfY ];
}

function herladen(id,string,locatie){
    //3de argument was userId, maar wordt nu gebruikt als hash voor location #
    xmlHttp = ajaxFunction();
    /*
    __HOE TE GEBRUIKEN__
    roep deze functie aan vanuit een link
    gebruik voor het id argument de element naam, wordt gebruikt om de div te vinden waar de data in moet komen
    gebruik voor de string argument de normaaal te gebruiken url string, alles achter het ? teken
    
    BIJV. onclick="herladen('".$this->naam."','&el=2&sp=235&it=1895');"
    Ziezo het element wordt met de nieuwe data gevuld, aan de hand van de opgegeven string waarde
    
    Returnwaarde
    Wanneer de browser geen AJAX ondersteunt wordt de waarde TRUE geretourneerd en wordt de link nornaal uit gevoerd, herladen van de nieuwe pagina
    Waneer alles goed is verlopen wordt de waarde FALSE geretourneerd de pagina zelf herlaad niet, wel wordt d.m.v. deze functie het element van nieuwe inhoud voorzien, hergeladen dus
    */
       
    if(xmlHttp){
        var d = new Date();
        //var milisecStart = (d.getSeconds()*1000)+d.getMilliseconds();

        //venster weergave
        document.body.style.cursor="wait";
        loadUploading();
        elementNaam=id;
        
        var subdomein = document.getElementById('profielNaam').value;
                        
        xmlHttp.onreadystatechange=function()
          {
          if(xmlHttp.readyState==4)
            {
                if(xmlHttp.status=='200'){
                    //opruimer
                    var t=setTimeout("sluitloadUploading()",250);
                    
                    sluitloadUploading();
                    if(textSpanStatus){
                        sluitTextSpan(textSpanStatus);
                    }
                    if ((document.getElementById('sluitDiv') != undefined) && (document.getElementById('sluitDiv').style.visibility != "hidden")) {
                        sluitFotoNav();
                    }
                    
                    document.getElementById(elementNaam).innerHTML=xmlHttp.responseText;
                    document.body.style.cursor="auto";
                    if(isNaN(locatie) && locatie.length>=2){
                        location.hash=locatie;
                    }else{
                        location.hash=id;
                    }
                    if(xmlHttp.responseText.search(/<form action/)>1){
                        if(xmlHttp.responseText.search(/verslagForm/)>1){
                            aan(false,'reisverslag');
                        }else if(xmlHttp.responseText.search(/reactieForm/)>1){
                            aan(true,'reactie');
                            if(string.search(/&r=/)>1){
                                location.hash='reactieForm_melding';
                            }
                        }else if(xmlHttp.responseText.search(/gastenboekForm/)>1){
                            aan(true,'bericht');
                        }
                    }
                    sluitloadUploading();
                }else{
                    alert('Kon de gegevens nu niet verzenden.\nProbeer het later nog eens.'+xmlHttp.status);
                    sluitloadUploading();
                    document.body.style.cursor="auto";
                    return false;
                }
            }
          }
        urlQuery = string; //BIJV. &el=2&sp=235&it=1895
        var query = "http://"+subdomein+".reisprofiel.nl/classes/ajax/cls_profiel_config.php?herladen=1&profielId="+profielId+urlQuery+"&rnd="+Math.random();
        xmlHttp.open("GET",query,true);
        xmlHttp.send(null);
        return false;
    }else{
        return true;
    }
}

var nieuwVerslag=false;

function verslagOpslaan(tt,element,formName,checkFormString,textArea){
    xmlHttp = ajaxFunction();
    if(checkFormString){
        if(!checkForm(checkFormString)){
            return false;
        }
    }
    if(xmlHttp){//&& (userId==2 || userId==1)
        
        //venster weergave
        if(!tt){
            document.body.style.cursor="wait";
            loadUploading();
        }
        var subdomein = document.getElementById('profielNaam').value;
                        
        xmlHttp.onreadystatechange=function()
          {
          if(xmlHttp.readyState==4)
            {
                if(xmlHttp.status=='200'){
                    if(tt){
                        if(xmlHttp.responseText!='leegVeld'){
                            var today=new Date();
                            var h=today.getHours();
                            var m=today.getMinutes();
                            var s=today.getSeconds();
                            if(m<10){ m = "0"+m; }
                            if(s<10){ s = "0"+s; }
                            document.getElementById("ttMelding").innerHTML="Verslag opgeslagen, "+h+":"+m+":"+s;
                            document.getElementById("ttMelding").style.display="block";
                            document.body.style.cursor="auto";
                            
                            //als het een nieuwe verslag is en er wordt tussen tijds opgeslagen
                            //dan altijd weergeven op false
                            //action url wel veranderen, in a=2 en it=insertId
                            if(stringAction.indexOf("&a=1")!=-1){
                                //verander de action
                                x.action = stringAction.replace(/&a=1/,"&a=2")+"&it="+xmlHttp.responseText;
                            }
                        }else{
                            document.getElementById("ttMelding").innerHTML="Verslag niet opgeslagen, omdat niet alle verplichte velden ingevuld waren.";
                            document.getElementById("ttMelding").style.display="block";
                            document.body.style.cursor="auto";                        
                        }
                    }else{
                        if(textSpanStatus){
                            sluitTextSpan(textSpanStatus);
                        }
                        //opruimer
                        var t=setTimeout("sluitloadUploading()",250);
                        sluitloadUploading();
                        document.body.style.cursor="auto";
                        document.getElementById(element).innerHTML=xmlHttp.responseText;

                        if(formName=='reactieForm'){
                            location.hash='reactieForm_melding';
                        }else{
                            location.hash=element;
                        }
                        
                        if(xmlHttp.responseText.search(/<form action/)>1){
                            if(xmlHttp.responseText.search(/verslagForm/)>1){
                                aan(false,'reisverslag');
                            }else if(xmlHttp.responseText.search(/reactieForm/)>1){
                                aan(true,'reactie');
                            }else if(xmlHttp.responseText.search(/gastenboekForm/)>1){
                                aan(true,'bericht');
                            }
                        }
                        sluitloadUploading();
                        
                        //if(textArea && textArea!=''){
                            //tinyMCE.execCommand('mceRemoveControl',false,textArea);
                        //}                        
                    }
                }else{
                    alert('Kon de gegevens nu niet verzenden.\nProbeer het later nog eens.');
                    sluitloadUploading();
                    document.body.style.cursor="auto";
                    return false;
                }
            }
          }
        
        //Het verslag formulier bij elkaar sprokkelen
        var par = "";
        if(document.getElementById(formName)){
            var x = document.getElementById(formName);
        }
        
        //urlQuery = string; //BIJV. &el=2&sp=235&it=1895
        var stringAction = x.action;
        if(stringAction.search(/&herladen=/) != -1){
            stringAction = stringAction.substr((stringAction.search(/&herladen=/)+11));
        }else if(stringAction.search(/.nl/) != -1){
            stringAction = stringAction.substr((stringAction.search(/.nl/)+5));
        }
        
        if(stringAction.indexOf("&a=1")!=-1){
            nieuwVerslag=true;
        }else{
            nieuwVerslag=false;
        }
         
        for (var i=0;i<x.length;i++){
            if(textArea && x.elements[i].name==textArea && window.tinyMCE && tinyMCE.get(textArea).getContent()){
                var content = tinyMCE.get(textArea).getContent().replace(/\+/g, "&#43");
	            content = content.replace(/\\/g, "&#92");
	            content = escape(content);
                x.elements[i].value = content;
            } 
          if(x.elements[i].type=="checkbox" || x.elements[i].type=="radio"){
            if(x.elements[i].checked && nieuwVerslag && tt){
                var checkboxChecked = 0;
            }else if(x.elements[i].checked==true && !(tt && x.elements[i].name=='contact')){
                var checkboxChecked = 1;
            }else{
                var checkboxChecked = 0;
            }
            par = par+"&"+x.elements[i].name+"="+checkboxChecked;
          }else{
            //alert(x.elements[i].type+"="+x.elements[i].name+"="+x.elements[i].value);
            par = par+"&"+x.elements[i].name+"="+x.elements[i].value;
          }
        }
        //return true;
        if(tt){
            var ttString = "&tt=1";
        }else{
            var ttString = "";
        }
        
        
        var query = "http://"+subdomein+".reisprofiel.nl/classes/ajax/cls_profiel_config.php?herladen=2&profielId="+profielId+ttString+"&"+stringAction+"&rnd="+Math.random();
        xmlHttp.open("POST",query,true);
        
        //Send the proper header information along with the request
        xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xmlHttp.setRequestHeader("Content-length", par.length);
        xmlHttp.setRequestHeader("Connection", "close");
        xmlHttp.send(par);
        return false;
    }else{
        return true;
    }
}

function stopLaden(){
    document.body.style.cursor="auto";
    document.getElementById('venster').style.display="none";
    return false;
}

var req;

function checkAv(url) 
{
    // branch for native XMLHttpRequest object (Dus voor FireFox, Safari + IE7)
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChangeAv;
        req.open("GET", url, true);
        req.send(null);
    // branch for IE/Windows ActiveX version (IE < 7)
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChangeAv;
            req.open("GET", url, true);
            req.send();
        }
    }
}

function processReqChangeAv(){
    // alleen als req shows "complete"
    if (req.readyState == 4){
        // alleen als "OK"
        if (req.status == 200){
            var vink = document.getElementById('vink');
            if (req.responseText == "av") {
                if (vink.src != "http://www.reisprofiel.nl/images/edit/av.gif") {
                    vink.src = "http://www.reisprofiel.nl/images/edit/av.gif";
                }
                vink.onmouseover = function() {
                    textSpan('Deze profielnaam is nog beschikbaar', 'vink');
                }
            }else{
                if (vink.src != "http://www.reisprofiel.nl/images/edit/nav.gif") {
                    vink.src = "http://www.reisprofiel.nl/images/edit/nav.gif";
                }
                vink.onmouseover = function() {
                    textSpan('Deze profielnaam <strong>niet</strong> meer beschikbaar', 'vink');
                }
            }
        }
    }
}

function sluitloadUploading(){
    if ((document.getElementById('loadDiv') != undefined) && (document.getElementById('loadDiv').style.visibility != "hidden")) {
        var loadDiv = document.getElementById("loadDiv");
        loadDiv.style.visibility = "hidden";
        document.body.removeChild(loadDiv);
    }
    if ((document.getElementById('loadDiv') != undefined) && (document.getElementById('loadDiv').style.visibility != "hidden")) {
        var loadDiv = document.getElementById("loadDiv");
        loadDiv.style.visibility = "hidden";
        document.body.removeChild(loadDiv);
    }
}

function loadUploading() {
    var loadDiv = document.createElement('div');
    loadDiv.id = "loadDiv";
    loadDiv.style.width = "150px";
    loadDiv.style.height = "130px";
    loadDiv.style.backgroundColor = "Silver";
    loadDiv.style.color = "White";
    loadDiv.style.position = "absolute";
    loadDiv.style.opacity = "0.8";
    loadDiv.style.zIndex = "3";
    loadDiv.style.verticalAlign = "middle";
    loadDiv.style.textAlign = "center";
    loadDiv.style.border = "1px solid gray";
    loadDiv.style.left = (document.body.offsetWidth/2)-100+"px";
    
    var scrOfY = 0;
      if(typeof(window.pageYOffset) == 'number') {
        scrOfY = window.pageYOffset;
      }else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        scrOfY = document.body.scrollTop;
      }else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop) ) {
        scrOfY = document.documentElement.scrollTop;
      }                               

    loadDiv.style.top = (scrOfY+(screen.availHeight/2) )-250+"px";
                                                             
    a1234 = new Image();
    a1234.src = "http://www.reisprofiel.nl/images/edit/loading.gif";
    window.setTimeout(function() {
        loadDiv.innerHTML = '<br /><br /><img width="54" height="55" src="http://www.reisprofiel.nl/images/edit/loading.gif" id="Laden1234" alt="Laden" /><br /><strong>Bezig met laden...</strong>';
        document.body.appendChild(loadDiv);
    }, 10);
    loadDiv.style.filter = "alpha(opacity=80)";    
    
    if (IE) {
        //iframe om alles te verbergen over selects heen
        var loadDivIframe = document.createElement('iframe');  
        loadDivIframe.id = "loadDivIframe";
        loadDivIframe.style.height = loadDiv.offsetHeight+"px"; 
        loadDivIframe.style.width = loadDiv.offsetWidth+"px";
        loadDivIframe.style.position = 'absolute';
        loadDivIframe.style.top = loadDiv.style.top;
        loadDivIframe.style.left = loadDiv.style.left;
        loadDivIframe.src = "about:blank";
        loadDivIframe.scrolling = "no";
        loadDivIframe.frameBorder = 0;
        loadDivIframe.style.zIndex = 2;

        document.body.appendChild(loadDivIframe);
    }
}

function hoverTemplateKeuze(td, id, manier) {
    var templateTD = document.getElementById(td);
    var classOud = templateTD.className;
    
    if (manier == 0 && templateTD.className !=  "templateKeuzeFocus") {
        templateTD.className = "templateKeuzeHover";
        
        templateTD.onmouseout = function() {
            templateTD.className =  classOud;
        }
    }if (manier == 1){
        templateTD.className = "templateKeuzeFocus";
        kiesTemplate(id, td);

        templateTD.onmouseout = function() {
            templateTD.className =  "templateKeuzeFocus";
        }
    } 
}

function templatePreload(template){
    var extensie
    if(template==3){
        extensie = ".png";
    }else{
        extensie = ".gif";
    }
    img_hover_l=new Image();
    img_hover_l.src="http://www.reisprofiel.nl/images/templates/"+template+"/l_tab_hover"+extensie;
    img_hover_m=new Image();
    img_hover_m.src="http://www.reisprofiel.nl/images/templates/"+template+"/m_tab_hover"+extensie;
    img_hover_r=new Image();
    img_hover_r.src="http://www.reisprofiel.nl/images/templates/"+template+"/r_tab_hover"+extensie;
}

function kiesTemplate(radio, td) {
    //rest unchecken
    var aantal = document.getElementById('templateForm').length;

    for (var i=0; i<aantal; i++) {       
		var element = document.getElementById('templateForm').elements[i];
        var id = document.getElementById('templateForm').elements[i].id;
        var type = document.getElementById('templateForm').elements[i].type;
        
        if (type == "radio") {
            element.checked = false;
        }
        if ((radio != id) && (id != "")) {
            document.getElementById(id+'TD').className = "templateKeuzeBlur";
        }
    }
    
    //juiste checken
    var radioButton = document.getElementById(radio);
    radioButton.checked=true;
}

function elementHover(id,agtur){
    var button = document.getElementById(id);
    var className = button.className;
    button.className = className+agtur;
    
    button.onmouseout = function() {
        button.className = className;
    }
}

function hoverLand(id, text, foto) {
    if ((document.getElementById('textSpan') != undefined) && (document.getElementById('textSpan').style.visibility != "hidden")) {
            sluitTextSpan(id);
    }

    var hoverLand = document.createElement('span');
        
    if (foto != 0) {
        text = text+ '<img id="kaartImg" src="http://www.reisprofiel.nl/reisgids/'+foto+'/images/'+foto+'.jpg" alt="" />';
    }else{
        var spHeight=100;
    }
    

        
    hoverLand.id = "textSpan";
    hoverLand.name = "img";
    hoverLand.className = "textSpan";
    hoverLand.innerHTML = text;
    hoverLand.style.width = "260px";
    
    var selectVeld = document.getElementById(id);
           
    if(tempX >= (screen.availWidth/2) && screen.availWidth <= 1100){
        hoverLand.style.left = tempX-280+"px";
    }else{
        hoverLand.style.left = tempX+20+"px";
    }
    hoverLand.style.top = tempY-10+"px";

    document.body.appendChild(hoverLand);
    
    selectVeld.onmouseout = function() {
        sluitTextSpan(id);
    }
}

/* Tekst span hover gedoe */
function sluitTextSpan(id) {
    if ((document.getElementById('textSpan') != undefined) && (document.getElementById('textSpan').style.visibility != "hidden")) {
        textSpanStatus=false;
        var textSpan = document.getElementById("textSpan");
        
        //Verwijderen in FireFox
        textSpan.style.visibility = "hidden";
        
        //Verwijderen in IE
        document.body.removeChild(textSpan);
    }
}

var textSpanStatus = false;
function textSpan(text, id) {
    textSpanStatus=id;
    if (text != "") {
        if ((document.getElementById('textSpan') != undefined) && (document.getElementById('textSpan').style.visibility != "hidden")) {
            sluitTextSpan(id);
        }

        var aantalTemp = (text.length/40);
        var aantal = Math.floor(aantalTemp);

        if (aantal > 0) {
           b = 40;
           for(i=1;i<=aantal;i++) {
                beginTemp = text.substring(0, b);
                laatsteSpatie = beginTemp.lastIndexOf(" ");
                begin = text.substring(0, laatsteSpatie);
                
                if (laatsteSpatie) {
                    einde = text.substring(laatsteSpatie);
                }else{
                    einde = text.substring(b);
                }
                
                tussen = "<br />";
                text = begin+tussen+einde;
                b = (b+40);
           }
        }
                                                                     
        var textSpan = document.createElement('span');
        textSpan.id = "textSpan";
        textSpan.name = "tekst";
        textSpan.className = "textSpan";
        textSpan.innerHTML = text;

        var selectVeld = document.getElementById(id);
        //cursor parent wijzigen
        //selectVeld.style.cursor = "hand";

        textSpan.style.top = tempY-10+"px";
        textSpan.style.left = tempX+20+"px";

        document.body.appendChild(textSpan);  
        
        selectVeld.onmouseout = function() {
            sluitTextSpan(id);
        }
    }
}


function emailCheck(veld, input) {
    if (input == true) {
        str = input;
    }else{
        var str = document.getElementById(veld).value;
    }
    var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
    var errorText = "Je moet wel een geldig emailadres opgeven :)"
	if (str.indexOf(at)==-1){
	   alert(errorText)
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert(errorText)
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert(errorText)
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		alert(errorText)
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert(errorText)
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		alert(errorText)
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		alert(errorText)
		return false
	 }
 	 return true					
}
    
function hoverPagina(td) {
    var paginaTD = document.getElementById(td);
    var classPagina = paginaTD.className;

    if (paginaTD.className != "paginaFocus") {
        paginaTD.className = "paginaHover";
    }
    
    paginaTD.onmouseout = function() {
        paginaTD.className = classPagina;
    } 
}

function hoverPaginaImg(td) {
    var paginaTD_left = document.getElementById(td+'_left');
    var paginaTD_mid = document.getElementById(td+'_mid');
    var paginaTD_right = document.getElementById(td+'_right');
    var classPagina = paginaTD_mid.className;
    if(classPagina == 'paginaFocus_mid'){
        var toestand = 'paginaFocus';
    }else{
        var toestand = 'paginaBlur';
    }
    //alert(classPagina);
    
    if (toestand != "paginaFocus") {
        paginaTD_left.className = "paginaHover_left";
        paginaTD_mid.className = "paginaHover_mid";
        paginaTD_right.className = "paginaHover_right";
    }
    
    paginaTD_left.onmouseout = function() {
        paginaTD_left.className = toestand+'_left';
        paginaTD_mid.className = toestand+'_mid';
        paginaTD_right.className = toestand+'_right';
    } 
    paginaTD_mid.onmouseout = function() {
        paginaTD_left.className = toestand+'_left';
        paginaTD_mid.className = toestand+'_mid';
        paginaTD_right.className = toestand+'_right';
    }
    paginaTD_right.onmouseout = function() {
        paginaTD_left.className = toestand+'_left';
        paginaTD_mid.className = toestand+'_mid';
        paginaTD_right.className = toestand+'_right';
    }
}

/* ONDERSTAANDE IS VOOR CLASS FORMULIER */
function checkForm(input) {
    var leeg = 0;
    
    var lijst = input.split(",");
    for (x in lijst) {
        if (lijst[x] != "") {
            //als editor aangeroepen anders aanpakken
            if ((lijst[x].toString() == "reisverslag") || (lijst[x].toString() == "reactie") || (lijst[x].toString() == "bericht")) {
                var editor = document.getElementById('mce_editor_0'); 
                //alert(editor.contentWindow.document.body.innerHTML);
                if ((editor.contentWindow.document.body.innerHTML == "") || (editor.contentWindow.document.body.innerHTML == "<br>")) {
                    editor.style.border = "1px solid red";
                    leeg++
                }
            }
            var veld = document.getElementById(lijst[x]);
            //types checken
            //als textarea
            if ((veld.type == "textarea") && (lijst[x] != "reisverslag") && (lijst[x] != "reactie") && (lijst[x] != "bericht")) {
                if(veld.value == "") {
                    veld.style.border = "1px solid red";
                    leeg++
                }
            //input
            }if (veld.type == "text") {
                if(veld.value == "") {
                    veld.style.border = "1px solid red";
                    leeg++
                }
            }
        }
    }
    if (leeg > 0) {
        alert("Je moet wel alle verplichte velden invullen!"); 
        return false;
    }else{
        return true;
    }
}

function checkContact(){
    var fout = false;
    if(emailCheck("emailadres",false)==false){
        document.getElementById('emailadres').style.border = "1px solid red";
        return false;
    }else{
        var veld1 = document.getElementById('onderwerp');
        var veld2 = document.getElementById('bericht');
        if(veld1.value == ""){
            veld1.style.border = "1px solid red";
            fout=true;
        }
        if(veld2.value == ""){
            veld2.style.border = "1px solid red";
            fout=true;
        }
    }
    if(fout){
        alert('Niet alle verplichte velden zijn ingevuld.')
        return false;
    }else{
        return true;
    }
}

/* VOOR GEGEVENS */
function popupLand(landId) {
    var left = (screen.availWidth/2)-175;
    var top = (screen.availHeight/2)-100;
    window.open('http://www.reisprofiel.nl/includes/view.php?land='+landId,'afbeeldingenWindow','scrollbars=0,left='+left+',top='+top);
}

/* ONDERSTAANDE IS VOOR VERSLAG */
function popupAfbeelding(afbeeldingInput, profielId) {
    var left = (screen.availWidth/2)-175;
    var top = (screen.availHeight/2)-100;
    window.open('http://www.reisprofiel.nl/includes/view.php?img='+afbeeldingInput+'&id='+profielId,'afbeeldingenWindow','scrollbars=0,left='+left+',top='+top);  
}

function verwijderItem(type) {
    var b = confirm("Weet je zeker dat je dit "+type+" wilt verwijderen?");
    
    if (b==true) {
        return true;
    }else{
        return false;
    }
} 

//Vars neerzetten zodat buiten functies om beschikbaar
var curleft = curtop = 0;
//positie pakken
function findPos(obj) {
	if (obj.offsetParent) {
        curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
            curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
} 

function firefoxCheck() {
    var ffDiv = document.getElementById('firefoxDiv');
    if (navigator.appName == "Microsoft Internet Explorer") {
		if (window.XMLHttpRequest) {
			//niks	
		}else{
			ffDiv.style.display = 'block';
		}
    }else{
        ffDiv.style.display = 'none';
    }
}
//muis pakken
document.onmousemove = getMouseXY;
        

/* mouse bewegingen pakken */
var tempX = 0;
var tempY = 0;

function getMouseXY(e) {
  if (IE) {
    tempX = event.clientX;
    tempY = event.clientY + document.documentElement.scrollTop;
    tempYOrg=event.clientY-40;
  } else {
    tempX = e.pageX;
    tempY = e.pageY;
    tempYOrg=e.pageY - document.documentElement.scrollTop;
  }  

  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}
  
  //als textSpan open staat plek updaten ->
  if ((document.getElementById("textSpan") != "undefined") && (document.getElementById("textSpan") != null)) {
    if(document.getElementById("textSpan").name=='img' && screen.availWidth < (tempX+310)){
        document.getElementById("textSpan").style.left = tempX-280+"px";    
    }else{
        document.getElementById("textSpan").style.left = tempX+20+"px";    
    }
    if(document.getElementById("textSpan").name=='img' && document.getElementById("kaartImg") != "undefined" && document.getElementById("kaartImg") != null && screen.availHeight < (tempYOrg+document.getElementById("kaartImg").height)+210){
        document.getElementById("textSpan").style.top = tempY-((tempYOrg+document.getElementById("kaartImg").height)-screen.availHeight)-210+"px";
    }else{
        document.getElementById("textSpan").style.top = tempY-10+"px";
    }
  }else if((document.getElementById("elementDiv") != "undefined") && (document.getElementById("elementDiv") != null)) {
    //oplossen zijkanten tegen scrollbars
    if ((screen.availWidth - tempX) < 300) {
        document.getElementById("elementDiv").style.left = tempX-270+"px";
        document.getElementById("elementDivIframe").style.left = tempX-270+"px";
    }else{
        document.getElementById("elementDiv").style.left = tempX+20+"px";
        document.getElementById("elementDivIframe").style.left = tempX+20+"px";
    }

    if ((screen.availHeight - tempY) < ((document.getElementById("elementDiv").offsetHeight + 130))){
        document.getElementById("elementDiv").style.top = tempY-210+"px";   
        document.getElementById("elementDivIframe").style.top = tempY-210+"px";
    }else{
        document.getElementById("elementDiv").style.top = tempY-40+"px";   
        document.getElementById("elementDivIframe").style.top = tempY-40+"px";
    }
  }

  return true
}