  /************************************************************************/
 /*************************** Google functies********************************/
/************************************************************************/
/* checkLatLon
Description:	Function checks address and sets latitude and longitude in given fields
Author:		René Weteling (rene@click.nl)
Date:			2009-09-17
Call: 			checkLatLon("address string", "id of lat input field", "id o lon input field", "callback");
*/
var geocoder;
function checkLatLon(address, lat, lon, callback) {
	if(address == ""){
		return true;
	}
  if (!geocoder) {
	  geocoder = new GClientGeocoder();
	  setTimeout(function(){checkLatLon(address, lat, lon, callback)},150);
  }else{
	geocoder.getLatLng(
	  address,
	  function(point) {
		  if(point){
			  document.getElementById(lat).value = point['y'];
			  document.getElementById(lon).value = point['x'];
			  if(callback != ''){
				eval(callback);
			  }
		  }else{
			alert("Helaas het adres is niet gevonden heeft u het goed geschreven?");  
		  }
	  }
	);
  }
}


/************************
            * Lightbox functies
           *************************/
function addOverlay(boxw,boxh) {
    var body = document.getElementsByTagName("body")[0];
    var tmp = document.createElement('div');
    tmp.id = 'overlayDiv';
    tmp.onclick = function() {
        removeLightbox();
    };

    tmp.style.top = '0px';
    tmp.style.cursor = 'pointer';
    tmp.style.position = 'absolute';
    tmp.style.height = getPageHeight() + "px";
    tmp.style.width = '100%';
    tmp.style.backgroundColor = '#000';
    tmp.style.zIndex = 200;
    body.appendChild(tmp);
    changeOpac(70, 'overlayDiv');
 
    var ymargin = Math.floor((document.body.clientHeight - boxh) / 2);    
    ymargin = (ymargin > 0 ? ymargin : 0);
    
    var tmp2 = document.createElement('div');
    tmp2.id = 'overlayDivContent';
    tmp2.style.top = ((window.pageYOffset || document.documentElement.scrollTop || 0) + ymargin) + "px";
    tmp2.style.left = (((window.pageXOffset || document.documentElement.scrollWidth || 0) - boxw) / 2) + "px";
    tmp2.style.position = 'absolute';
    tmp2.style.width = boxw+"px";
    tmp2.style.backgroundColor = '#fff';
    tmp2.style.height = boxh+"px";
    tmp2.style.border = '0px';
    tmp2.style.zIndex = 210;
    body.appendChild(tmp2);
}
function removeLightbox() {
    var body = document.getElementsByTagName("body")[0];
    body.removeChild(getElement('overlayDiv'));
    body.removeChild(getElement('overlayDivContent'));
}
function lightbox(boxw,boxh,url, data) {
    addOverlay(boxw,boxh); // divs dr in stoppen
    var content = (url ? "<iframe src='" + url + "' width='100%' height='100%' border='' style='border:solid 3px #fff;' FRAMEBORDER=0 SCROLLING=no></iframe>": data);
    getElement('overlayDivContent').innerHTML = "<div id='overlayDivClose'><a onclick='removeLightbox();'></a></div><div id='overlayDivInnerContent'></div>";
    getElement('overlayDivInnerContent').innerHTML = content;

    return false;
}

function getPageHeight() {
    if (window.innerHeight && window.scrollMaxY) { // Firefox
        yWithScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
        yWithScroll = document.body.scrollHeight;
    } else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
        yWithScroll = document.body.offsetHeight;
    }
    return yWithScroll;
}

function changeOpac(opacity, id) {
    var object = getElement(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function getElement(id) {
    if (document.getElementById(id)) {
        return document.getElementById(id);
    } else {
        //alert('Element ' + id + ' is niet gevonden!');
    }
}



function doOver(id,url){

	object = document.getElementById(id);
	object.src=url ;
 
	}

function setFormValue(object,value){
		var elm = document.getElementById(object);
		elm.value= value;
	}

function showOnly(showId, parentId, tagName) {

                var parObj = document.getElementById(parentId);
                var tagType = "DIV";
                if (tagName) {
                    tagType = tagName.toUpperCase();
                }
                if (parObj) {
                    var children = parObj.childNodes;
                    // alert(db_DumpTree(children, ''));
                    for(c = 0; c < children.length; c++) {

                        if (children[c].nodeName == tagType ) {
                            if (children[c].id == showId) {
                                children[c].style.display = 'block';
                            } else {
                                children[c].style.display = 'none';
                            }
                        }
                    }
                }
            }

function doTaalkeuze(classname){
document.getElementById('selectLc').className = classname;
}


function setDivSize(){
		
	var theHeight = document.body.scrollHeight ;
	var mainWidth= document.getElementById('main').scrollWidth;
	
	if(mainWidth < 1001){
	document.getElementById('levelNull').style.width = "1001px";
	document.getElementById('mainHolder').style.width = "1001px";
	document.getElementById('main').style.width = "1001px";

	}

	else{
	document.getElementById('levelNull').style.width = "100%";
	document.getElementById('mainHolder').style.width = "100%";
	document.getElementById('main').style.width = "100%";
	}
	
	document.getElementById('levelNull').style.height = theHeight+"px";
	document.getElementById('mainHolder').style.height = theHeight+"px";
	document.getElementById('main').style.height = theHeight+"px";

	if (getPageHeight() > 800){document.getElementById('marginmaker').style.height = 1+"px";}
	else{document.getElementById('marginmaker').style.height = 80+"px";}
 
	var footerpos = (getPageHeight()-89);
	document.getElementById('footer').style.top = footerpos+"px";

	}

function setContentBorder(){
	var contentHeight = document.getElementById('contentHolder').scrollHeight;
	borderleft = document.getElementById('conBorderLeft');
	borderleft.style.height = contentHeight+"px";

	borderbot = document.getElementById('conBorderBottom');
	borderbot.style.top = contentHeight+"px";

	document.getElementById('contentHolder').style.height = contentHeight+"px";

	}

/************************
            * Input onFocus/onBlur
           *************************/

function inpFocus(obj, stdText) {
	if (obj.value == stdText) {
	obj.value = '';
	}
}
 
function inpBlur(obj, stdText) {
	if (obj.value == '') {
	obj.value = stdText;
	}
} 

