/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

var oldDiv = null;
var xmlhttp = null;

function openRef()
{
	wind = window.open("images/ref.jpg","",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=884,height=722');
}

function openRef1()
{
	wind = window.open("images/ref1.jpg","",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=873,height=881');
}

function openRef2()
{
	wind = window.open("images/ref2.jpg","",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=937,height=752');
}

function verzendOfferte(){
	var els = document.forms[0].elements;
	for(var x = 0; x < els.length; x++){
		if(els[x].type == "text" || els[x].type == "textarea"){
			if(els[x].name == "naam" || els[x].name == "email"){
				if(els[x].value == ""){
					els[x].select();
					els[x].focus();
					alert('Uw bent vergeten het veld ' + els[x].name + ' vergeten in te vullen.');
					return false;
				}
			}
		}
	}
	return true;
}

function preload(){

    var preload = document.getElementById('preload');
    preload.style.display = "none";
    
    var images = ["bg1.jpg","btn_home.png", "btn_ezplanner.png",
                   "btn_ezrecreatie.png","btn_portfolio.png","btn_referenties.png",
                    "btn_contact.png"];

   for(var x = 0; x < images.length; x++){
       var img = document.createElement("img");
       img.setAttribute("src", "images/" +  images[x]);
       preload.appendChild(img);
   }
      
}

function leesMeer(id){
    var p = document.getElementById('mod_' + id);
    p.style.display = (p.style.display == "none" ? "block" : "none" );
}

function openScreenshots(naam){
    var win = window.open('images/screenshots/' + naam + '.php', 'Screenshots', 'toolbar=0, menubar=0, scrollbars=1');
    win.focus();
}

function nieuwsBrief(frm){
    submitForm(frm,'includes/add_nieuwsbrief.php');
    alert('Uw aanmelding is ontvangen.');
    annuleren();
    return false;
}

function createDiv(file_url){
    annuleren();    
    var div = document.createElement('div');
    div.setAttribute("id", 'oldDiv');
    div.innerHTML = getXML(file_url);
    div.style.position = "absolute";
    document.body.appendChild(div);
    div.className = 'inner_div';
    div.style.left = ( (screen.width/2)-(div.offsetWidth/2) + (document.body.scrollLeft/2) ) + "px";
    div.style.top = ( (screen.height/2)-(div.offsetHeight/2) + (document.body.scrollTop/2) ) + "px";
    oldDiv = 1;
    return;
}

function annuleren(){
    try
    {
        var oldDiv = document.getElementById('oldDiv');
        if(oldDiv != null){
            document.body.removeChild(oldDiv);
            oldDiv = 0;
        }
    }
    catch (e)
    {
            //alert(e);
    }
}

function getLeftTop(e){
    if(!e) e = window.event;
    var tempX,tempY;
    var res = Array();

    var IE = document.all?true:false;

      if (IE) { // grab the x-y pos.s if browser is IE
            tempX = e.clientX + document.body.scrollLeft;
            tempY = e.clientY + document.body.scrollTop;
      } else {  // grab the x-y pos.s if browser is NS
            tempX = e.pageX;
            tempY = e.pageY;
      }
      if (tempX < 0){tempX = 0}
      if (tempY < 0){tempY = 0}

    res["left"] = tempX;
    res["top"] = tempY;
    return res;
}

function aanmelden(){
    createDiv('nieuwsbrief.php');
}

function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,fullscreen=1,statusbar=0,menubar=0,resizable=1,menubar=0');");
}

function openFolder(FOLDER) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(FOLDER, '" + id + "', 'toolbar=0,scrollbars=0,location=0,fullscreen=0,statusbar=0,menubar=0,resizable=1,width=700,height=500,left = 370,top = 200');");
}

function btnOver(btn, image){
    btn.src=image;
}

function btnOut(btn, image){
    btn.src=image;
}

function btnClick(tab){
    window.location.href='?tab=' + tab;
}

function ajaxRequest(){
 var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
 if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
  for (var i=0; i<activexmodes.length; i++){
   try{
    return new ActiveXObject(activexmodes[i])
   }
   catch(e){
    //suppress error
   }
  }
 }
 else if (window.XMLHttpRequest) // if Mozilla, Safari etc
  return new XMLHttpRequest()
 else
  return false
}

function getXML(url){
    var xmlhttp = ajaxRequest();
    if(xmlhttp != null){
        xmlhttp.open("GET",url, false)
        xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
        xmlhttp.send(null)
        if(xmlhttp.responseText.length > 0){
            return xmlhttp.responseText;
        }else{
            return "";
        }
    }else{
        return "";
    }
}

