function getpage(pageid){	
	document.getElementById("content").innerHTML="<table width='99%' border='0' height='99%'><tr><td align='center' valign='middle'><img src='sitePics/loader.gif'></td></tr></table>";
	xmlHttp=getXMLHttpRequest();
	if(xmlHttp==null){
		alert("Your browser dose not support Ajax");
		return;
	}
		
	var url= 'functions/page.php?id=' + pageid;
	
	xmlHttp.onreadystatechange=function(){ 
		if (xmlHttp.readyState==4){ 
			document.getElementById("content").innerHTML=xmlHttp.responseText;//get id txtBrand to change inner HTML
			get_newsitems();
		}
	}
	xmlHttp.open("GET",url,true);	
	xmlHttp.send(null);
	
}


function HidePepperman(){
	t1 = new Tween(document.getElementById('pepperdude_speakbox').style,'top', Tween.elasticEaseIn, 0, 380, 1,'px');
	t1.start();
	t1.onMotionFinished = function(){
		document.getElementById("peppermanbox").style.visibility = 'hidden';
	};
}

function ShowPepperman(SpeakboxtextID){
	document.getElementById("peppermanbox").style.visibility = 'visible';
	xmlHttp8=getXMLHttpRequest();
	if(xmlHttp8==null){
		alert("Uw browser ondersteund geen Ajax javascript functies, controleer uw beveiligingsinstellingen.");
		return;
	}
	
	var url= 'functions/page.php?id=' + SpeakboxtextID;
	
	xmlHttp8.onreadystatechange=function(){
		if (xmlHttp8.readyState==4){
			document.getElementById("speakboxtext").innerHTML = xmlHttp8.responseText;
			document.getElementById('balloon').src = "sitePics/speakbox_" + SpeakboxtextID + ".png";
			t1 = new Tween(document.getElementById('pepperdude_speakbox').style,'top', Tween.elasticEaseOut, 380, 0, 1,'px');
			t1.start();
		}
	}
	xmlHttp8.open("GET",url,true);
	xmlHttp8.send(null);
}

var photoid = Math.floor(Math.random()*3);

function ChangePhotoBar(){
	//Copying orginal to second photo (b 2 a)
	document.getElementById('p'+photoid+'a').src = document.getElementById('p'+photoid+'b').src;
	
	//Setting fading div
	changeOpac(0, 'p'+photoid+'b');
	
	photoid = Math.floor(Math.random()*3);
	
	document.getElementById('p'+photoid+'b').src  = photobarimages[imagerun];
	
	imagerun = (imagerun + 1) % photobarimages.length;
	
	//fade in image 
    var speed = Math.round(3000 / 100); 
    var timer = 0;
	for(i = 0; i <= 100; i++) { 
	    setTimeout("changeOpac(" + i + ",'" + 'p'+photoid+'b' + "')",(timer * speed)); 
	    timer++; 
	}
	setTimeout('ChangePhotoBar()', 5000);
}

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 

//Getting & Setting newsitems
function get_newsitems(){
	document.getElementById("newsclippie").style.top = 10;
	
	xmlHttp2=getXMLHttpRequest();
	if(xmlHttp2==null){
		alert("Your browser dose not support Ajax");
		return;
	}
		
	var url= 'functions/get_news.php?active=1';
	
	xmlHttp2.onreadystatechange=function(){ 
		if (xmlHttp2.readyState==4){ 
			document.getElementById("nieuwsitems").innerHTML=xmlHttp2.responseText;//get id txtBrand to change inner HTML
		}else if(xmlHttp2.readyState==3){
			document.getElementById("nieuwsitems").innerHTML="<table width='99%' border='0' height='99%'><tr><td align='center' valign='middle'><img src='sitePics/news-loader.gif'></td></tr></table>";
		}
	}
	xmlHttp2.open("GET",url,true);	
	xmlHttp2.send(null);
}

function readnews(newsid){	
	xmlHttp=getXMLHttpRequest();
	if(xmlHttp==null){
		alert("Your browser dose not support Ajax");
		return;
	}
		
	var url= 'functions/build_newsitem.php?id=' + newsid;
	
	xmlHttp.onreadystatechange=function(){ 
		if (xmlHttp.readyState==4){ 
			document.getElementById("content").innerHTML=xmlHttp.responseText;//get id txtBrand to change inner HTML
		}
	}
	xmlHttp.open("GET",url,true);	
	xmlHttp.send(null);
}

function get_joboffers_oud(){
	getpage(6);
	get_newsitems();
}

function get_openapplication(){
	document.getElementById("content").innerHTML="<table width='99%' border='0' height='99%'><tr><td align='center' valign='middle'><img src='sitePics/loader.gif'></td></tr></table>";
	xmlHttp=getXMLHttpRequest();
	if(xmlHttp==null){
		alert("Your browser dose not support Ajax");
		return;
	}
		
	var url= 'functions/opensolicitatieformulier.php';
	
	xmlHttp.onreadystatechange=function(){ 
		if (xmlHttp.readyState==4){ 
			document.getElementById("content").innerHTML=xmlHttp.responseText;//get id txtBrand to change inner HTML
			document.getElementById("nieuwsitems").innerHTML = "<br><b>Vesting Finance</b><br>Bonairelaan 4<br>1213 VH Hilversum<br>Postbus 1080<br>1200 BB Hilversum<br><br>[T] 035 7999100<br>[F] 035 7999123<br><br><b>Gegevens van onze Recruiters:</b><br>Matthijs Dinkla: 035 7999120<br>Sander Kenter: 035 7999122<br>Marjolein Hamoen: 035 7999175";
			document.getElementById("newsclippie").style.top = 180;
			get_newsitems();
		}
	}
	xmlHttp.open("GET",url,true);	
	xmlHttp.send(null);
}

function get_joboffers(){
	document.getElementById("content").innerHTML="<table width='99%' border='0' height='99%'><tr><td align='center' valign='middle'><img src='sitePics/loader.gif'></td></tr></table>";
	xmlHttp=getXMLHttpRequest();
	if(xmlHttp==null){
		alert("Your browser dose not support Ajax");
		return;
	}
		
	var url= 'functions/get_jobboffers.php';
	
	xmlHttp.onreadystatechange=function(){ 
		if (xmlHttp.readyState==4){ 
			document.getElementById("content").innerHTML=xmlHttp.responseText;//get id txtBrand to change inner HTML
		}
	}
	xmlHttp.open("GET",url,true);	
	xmlHttp.send(null);
}

function showpromovideo(){
	var WindowWidth = 460;
	var WindowHeight = 360;
	var iLeft = (screen.width - WindowWidth ) / 2 ;
	var iTop  = (screen.height - WindowHeight ) / 2 ;
	var url = "video.php";

	var sOptions = "toolbar=no,status=no,resizable=no,dependent=yes,scrollbars=no" ;
	sOptions += ",width=" + WindowWidth ;
	sOptions += ",height=" + WindowHeight ;
	sOptions += ",left=" + iLeft ;
	sOptions += ",top=" + iTop ;

	window.open(url, 'PromoVideo', sOptions );
}

function contactus(){	
	document.getElementById("content").innerHTML="<table width='99%' border='0' height='99%'><tr><td align='center' valign='middle'><img src='sitePics/loader.gif'></td></tr></table>";
	xmlHttp=getXMLHttpRequest();
	if(xmlHttp==null){
		alert("Your browser dose not support Ajax");
		return;
	}
		
	var url= 'functions/contactformulier.php';
	
	xmlHttp.onreadystatechange=function(){ 
		if (xmlHttp.readyState==4){ 
			document.getElementById("content").innerHTML=xmlHttp.responseText;//get id txtBrand to change inner HTML
			document.getElementById("nieuwsitems").innerHTML = "<br><b>Vesting Finance</b><br>Bonairelaan 4<br>1213 VH Hilversum<br>Postbus 1080<br>1200 BB Hilversum<br><br>[T] 035 7999100<br>[F] 035 7999123<br><br><b>Gegevens van onze Recruiters:</b><br>Matthijs Dinkla: 035 7999120<br>Marjolein Hamoen: 035 7999175";
			document.getElementById("newsclippie").style.top = 180;
		}
	}
	xmlHttp.open("GET",url,true);	
	xmlHttp.send(null);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function hide_msgbox(){
	document.getElementById("msgwindow").style.display = 'none';
}

function numbersonly(myfield, e, dec) {
	var key;
	var keychar;
	
	if (window.event)
	   key = window.event.keyCode;
	else if (e)
	   key = e.which;
	else
	   return true;
	keychar = String.fromCharCode(key);
	
	// control keys
	if ((key==null) || (key==0) || (key==8) || 
	    (key==9) || (key==13) || (key==27) )
	   return true;
	
	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
	   return true;
	
	// decimal point jump
	else if (dec && (keychar == "."))
	   {
	   myfield.form.elements[dec].focus();
	   return false;
	   }
	else
	   return false;
	}

function hide_msgbox2(){
	document.getElementById("msgwindow").style.display = 'none';
	document.getElementById("webfader").style.visibility = 'hidden';
}
	
function createmsgbox(wh,ww,tit,msg,ico){
	//Hiding displayer
	document.getElementById("msgwindow").style.display = 'none';
	
	//Calculating style
	var newheight = parseFloat(wh) + 24 + 6;
	var newwidth = parseFloat(ww) + 12;
	var marg_left = parseFloat(newwidth) / 2;
	var marg_top = parseFloat(newheight) / 2;
	
	//Setting style
	document.getElementById("msgwindow").style.width = newwidth;
	document.getElementById("msgwindow").style.height = newheight;
	document.getElementById("msgwindow").style.left = '60%';
	document.getElementById("msgwindow").style.top = '50%';
	document.getElementById("msgwindow").style.marginLeft = - marg_left;
	document.getElementById("msgwindow").style.marginTop = - marg_top;
	
	//Activating Ajax	
	xmlHttp2=getXMLHttpRequest();
	if(xmlHttp2==null){
		alert("Your browser dose not support Ajax");
		return;
	}
	
	var url= "functions/createmsgbox.php?wh=" + wh + "&ww=" + ww + "&tit=" + tit + "&msg=" + msg + "&ico=" + ico;
	
	xmlHttp2.onreadystatechange=function(){ 
		if (xmlHttp2.readyState==4){ 
			document.getElementById("msgwindow").innerHTML = xmlHttp2.responseText;//get id txtBrand to change inner HTML
			document.getElementById("msgwindow").style.display = 'block';
		}
	}
	xmlHttp2.open("GET",url,true);	
	xmlHttp2.send(null);
}

function CreateNewCapcha(){
	document.getElementById("captchacodeimage").innerHTML="<table width='180' border='0' height='70'><tr><td align='center' valign='middle'><img src='sitePics/page-loader.gif'></td></tr></table>";
	xmlHttp=getXMLHttpRequest();
	if(xmlHttp==null){
		alert("Your browser dose not support Ajax");
		return;
	}
		
	var url= 'functions/createnewcapcha.php';
	
	xmlHttp.onreadystatechange=function(){ 
		if (xmlHttp.readyState==4){ 
			document.getElementById("captchacodeimage").innerHTML=xmlHttp.responseText;//get id txtBrand to change inner HTML
			document.getElementById("aanmeldcode").value = "";
		}
	}
	xmlHttp.open("GET",url,true);	
	xmlHttp.send(null);	
}
	
setTimeout('ChangePhotoBar()', 2000);
