// JavaScript Document

<!--

var clipTop;
var clipWidth;
var clipBottom ;
var topper;
var lyrheight;
var time,amount,theTime,theHeight,DHTML;

// Preload Images
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_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.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_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


var xmlhttp = null;
if(window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
}else{
   try{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   }catch(e){
		window.alert("Uw browser ondersteunt het XMLHttpRequest object niet!");
   }
}

function verwerk() {
if (xmlhttp.readyState == 2) {
	document.getElementById("showcontent").style.visibility = "visible";
	document.getElementById("showcontent").innerHTML = "Gegevens worden geladen...";
 }
if (xmlhttp.readyState == 4) {
	document.getElementById("showcontent").style.visibility = "visible";
	document.getElementById("showcontent").innerHTML = xmlhttp.responseText;
	Behaviour.apply();
 }
}

function getData(target) {
 if (xmlhttp) { 
  target= "http://www.hzabv.nl"+target;
  xmlhttp.open("GET", target, true);
  xmlhttp.onreadystatechange=verwerk;
  xmlhttp.send(null)
 }
}

function Bestaat(bestand){
	xmlhttp.open("HEAD", bestand, false);
	xmlhttp.send(null)
	return bestaat = xmlhttp.status;
}

function Achtergrond(cat, subcat, project, nummer){
	if (cat == "projecten" && project){
		if(!nummer){
			nummer = 1;
		}
		Bestaat("joomla/images/stories/projecten/"+subcat+"/"+project+"/"+nummer+".jpg");
		if (bestaat == 200){
			document.getElementById("achtergrond").src = "/joomla/images/stories/projecten/"+subcat+"/"+project+"/1.jpg";
		} 
	} else {
		projectbg = "joomla/images/stories/achtergronden/"+cat+"_"+subcat+"_"+project+".jpg";
		paginabg = "joomla/images/stories/achtergronden/"+cat+"_"+project+".jpg";
		subcatbg = "joomla/images/stories/achtergronden/"+cat+"_"+subcat+".jpg";
		catbg = "joomla/images/stories/achtergronden/"+cat+".jpg";
		bgs = new Array(projectbg, paginabg, subcatbg, catbg);
		
		for (i=0; i<bgs.length; i++){
			Bestaat(bgs[i]);
			if (bestaat == 200){
				document.getElementById("achtergrond").src = bgs[i];
				break;
			} 
		}
	}
}

var div = new Array('bureau', 'partners', 'samenwerking', 'projecten', 'projectensub');
function showDiv(cat, subcat) {
	if (cat == "contact" || cat == "downloads" || cat == "nieuws"  || cat=="topic"){
		for (i = 0; i <div.length ; i++){
			document.getElementById(div[i]).style.visibility = "hidden";
			document.getElementById(div[i]).style.display = "none";
		}
		return void(0);
	} else {
		for (i = 0; i <div.length ; i++){
			if(cat == "projecten" && subcat){
				document.getElementById("projectensub").style.visibility = "visible";
				document.getElementById("projectensub").style.display = "block";
				document.getElementById("projecten").style.visibility = "visible";
				document.getElementById("projecten").style.display = "block";
			} else if (div[i] == cat || div[i] == subcat ){
				document.getElementById(div[i]).style.visibility = "visible";
				document.getElementById(div[i]).style.display = "block";
			} else {
				document.getElementById(div[i]).style.visibility = "hidden";
				document.getElementById(div[i]).style.display = "none";
			}
		}
		return void(0);
	}
}

function transp(cat, subcat, project){
	if (cat == "contact" || cat == "downloads" || cat == "nieuws"  || cat=="topic"){
		document.getElementById("nav").style.opacity = "1";
		document.getElementById("nav").style.filter = "alpha(opacity=100)";
	} else {	
		document.getElementById("nav").style.opacity = ".70";
		document.getElementById("nav").style.filter = "alpha(opacity=70)";
		if (project){
			document.getElementById("projecten_container").style.opacity = ".70";
			document.getElementById("projecten_container").style.filter = "alpha(opacity=70)";
		} 
		if (document.getElementById(subcat)){
			document.getElementById(cat).style.opacity = ".70";
			document.getElementById(cat).style.filter = "alpha(opacity=70)";
		} else {
			document.getElementById(cat).style.opacity = "1";
			document.getElementById(cat).style.filter = "alpha(opacity=100)";
		}
	}
}

function transpReset(cat, subcat){
	if(cat == "contact" || cat == "downloads" || cat == "nieuws" || cat=="topic") {
		document.getElementById("nav").style.opacity = "1";
		document.getElementById("nav").style.filter = "alpha(opacity=100)";
	} else {
		if (document.getElementById(subcat)){
			if(cat == "projecten"){
				document.getElementById("projecten_container").style.opacity = "1";
				document.getElementById("projecten_container").style.filter = "alpha(opacity=100)";
			}
			document.getElementById(subcat).style.opacity = "1";
			document.getElementById(subcat).style.filter = "alpha(opacity=100)";
		} else {
			document.getElementById(cat).style.opacity = "1";
			document.getElementById(cat).style.filter = "alpha(opacity=100)";
		}
	}
}

function getObj(name) {
  if (document.getElementById) {
	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all) {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers) {
	this.obj = document.layers[name];
	this.style = document.layers[name];
  }
}

function showScroller(status){
	document.getElementById("pijl_omhoog").style.visibility = status;
	document.getElementById("pijl_omlaag").style.visibility = status;
}

function clipper(){
	clipTop = 0;
	clipWidth = 293;
	clipBottom = 129;
	topper = 0;
	lyrheight = 0;
	time,amount,theTime,theHeight,DHTML;
	x = new getObj("projectensub");
	lyrheight = document.getElementById("projectensub").style.clip.bottom;
	lyrheight = x.obj.offsetHeight;
	lyrheight += 10;
	x.style.clip.top = clipTop;
	x.style.clip.left = 0;
	x.style.clip.right = clipWidth;
	x.style.clip.bottom = clipBottom;
	x.style.clip = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)';
	
	if (document.getElementById || document.all)	{
		clipstring = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)';
		x.style.clip = clipstring;
		x.style.top = topper + 'px';
	}
	else if (document.layers)	{
		x.style.clip.top = clipTop;
		x.style.clip.bottom = clipBottom;
		x.style.top = topper;
	}
}

function klik(cat, subcat){
	document.getElementById("ismlogo").style.visibility = "hidden";
	Achtergrond(cat, subcat);
	showDiv(cat, subcat); 
	transpReset(cat, subcat);
	transp(cat, subcat); 
	document.getElementById("showcontent").style.visibility = "hidden";
	document.getElementById("project_details").style.visibility = "hidden";
	document.getElementById("project_fotos").style.visibility = "hidden";
	
	
	if(cat == "projecten" && subcat){
		target = "/joomla/projecten/"+subcat+"/";
		xmlhttp.open("GET", target, true);
		xmlhttp.onreadystatechange = function(){
			if (xmlhttp.readyState == 2) {
				document.getElementById(cat).style.opacity = ".70";
				document.getElementById(cat).style.filter = "alpha(opacity=70)";
				document.getElementById("projecten_container").style.opacity = "1";
				document.getElementById("projecten_container").style.filter = "alpha(opacity=100)";
				document.getElementById("projecten_container").style.visibility = "visible";
				document.getElementById("projecten").style.visibility = "visible";
				document.getElementById("projectensub").style.zIndex  = "5";
				document.getElementById("projectensub").style.visibility = "visible";
				document.getElementById("projectensub").innerHTML = "Gegevens worden geladen...";
				
			}
			if (xmlhttp.readyState == 4) {
				document.getElementById("projectensub").innerHTML = xmlhttp.responseText;
				Behaviour.apply();
				clipper();
				showScroller("visible");
			}
		}
		xmlhttp.send(null)
	} else {
		showScroller("hidden");
		document.getElementById("projecten_container").style.visibility = "hidden";
	}

}

function openPage(pagina, cat, subcat){
	document.getElementById("ismlogo").style.visibility = "hidden";

	if (cat=="contact" || cat=="nieuws" || cat=="downloads"  || cat=="topic"){
		document.getElementById("projecten_container").style.visibility = "hidden";
		document.getElementById("project_details").style.visibility = "hidden";
		document.getElementById("project_fotos").style.visibility = "hidden";
	} 
	if(subcat){
		showDiv(cat, subcat);
		transp(cat, subcat); 
		transpReset(cat, subcat);
	} else {
		showDiv(cat);
		transpReset(cat);
		transp(cat); 
	}
	Achtergrond(cat, subcat, pagina);
	if(cat == "nieuws"){
		target = "/joomla/"+cat+"/"+subcat+"/"+pagina+".html";
	} else {
		target = "/joomla/"+pagina+".html";
	}
	//window.open(target,'contentframe')
	getData(target);
	if(pagina=="is-maatwerk" || pagina=="community_planning"){
		document.getElementById("ismlogo").style.visibility = "visible";
	}
	
	if(cat == "projecten" && subcat){
		document.getElementById("projecten_container").style.visibility = "visible";
		document.getElementById(subcat).style.zIndex  = "5";	
		clipper();
		showScroller("visible");
		
	} else {
		showScroller("hidden");
	}
}



function showProject(project, cat, subcat){
	document.getElementById("ismlogo").style.visibility = "hidden";
	target = "/joomla/projecten/"+subcat+"/"+project+".html";
	xmlhttp.open("GET", target, true);
	xmlhttp.onreadystatechange = function(){
		if (xmlhttp.readyState == 2) {
		document.getElementById("project_details").style.visibility = "visible";
		document.getElementById("project_details").innerHTML = "Gegevens worden geladen...";
		}
		if (xmlhttp.readyState == 4) {
			document.getElementById("project_details").innerHTML = xmlhttp.responseText;
			Behaviour.apply();
			Achtergrond(cat, subcat, project);
			projectFotos(project, cat, subcat);
		}
	}
	xmlhttp.send(null)
	showDiv(cat, subcat);
	transpReset(cat, subcat, project);
	transp(cat, subcat, project); 
	document.getElementById(cat).style.opacity = ".70";
	document.getElementById(cat).style.filter = "alpha(opacity=70)";

	document.getElementById("project_details").style.overflow = "auto";
	document.getElementById("projecten_container").style.visibility = "visible";
	document.getElementById("projectensub").style.zIndex  = "5";
	showScroller("visible");
}

function projectFotos(project, cat, subcat){
	fotos = 1;
	fotostring = "";
	for(i=1; i<10; i++){
		Bestaat("joomla/images/stories/projecten/"+subcat+"/"+project+"/"+i+".jpg");
		if (bestaat == 200){
			fotostring += "<a href=\"#\" onClick=\"javascript:wisselPlaatje('"+subcat+"', '"+project+"', '"+i+"'); return false;\"><img src=\"joomla/images/stories/projecten/"+subcat+"/"+project+"/"+i+".jpg\" border=\"3\" bordercolor=\"#2A368C\" width=\"75\" height=\"56\"></a> ";
			fotos ++;
		} 
	}
	if (fotos > 1){
		document.getElementById("project_fotos").innerHTML = fotostring;
		document.getElementById("project_fotos").style.visibility = "visible";
	}
	
}


function wisselPlaatje(subcat, project, nummer){
		document.getElementById("achtergrond").src = "/joomla/images/stories/projecten/"+subcat+"/"+project+"/"+nummer+".jpg";
		next = window.location.hash + nummer;
		track = "projecten/"+subcat+"/"+project+"/"+nummer;
		urchinTracker(track);
}

function scroller(richting){
	if(richting == "up"){
		scrollayer("projectensub", 10, 100);
	} else if(richting == "down") {
		scrollayer("projectensub", -10, 100);
	}
}


function scrollayer(layername, amt, tim){
	thelayer = document.getElementById(layername);
	if (!thelayer) return;
	amount = amt;
	theTime = tim;
	realscroll();
}

function realscroll(){
	clipTop += amount;
	clipBottom += amount;
	topper -= amount;
	if (clipTop < 0 || clipBottom > lyrheight)	{
		clipTop -= amount;
		clipBottom -= amount;
		topper += amount;
		return;
	}
	if (document.getElementById || document.all)	{
		clipstring = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)';
		thelayer.style.clip = clipstring;
		thelayer.style.top = topper + 'px';
	}
	else if (document.layers)	{
		thelayer.style.clip.top = clipTop;
		thelayer.style.clip.bottom = clipBottom;
		thelayer.style.top = topper;
	}
	time = setTimeout('realscroll()',theTime);
}

function stopScroll(){
	if (time) clearTimeout(time);
}

function init(){
	cat = "projecten";
	clipper();
}

function Laden(){
	if(window.location.hash){
		var bookmark = window.location.hash;
		var cat;
		var subcat;
		var pagina;
		var gev;
		var gegevens = new Array();
		gegevens = bookmark.split('#');
		if (gegevens[2]){
			cat = gegevens[1];
			gev = gegevens[2].split('/');
			subcat = gev[0];
			pagina = gev[1];
		} else {
			gev = gegevens[1].split('/');
			cat = gev[0];
			pagina = gev[1];
		}
		if(pagina){
			if (cat == "projecten"){
				document.getElementById(cat).style.opacity = ".70";
				document.getElementById(cat).style.filter = "alpha(opacity=70)";
				document.getElementById("projecten_container").style.visibility = "visible";
				document.getElementById("projecten").style.visibility = "visible";
				document.getElementById("projectensub").style.zIndex  = "5";
				target = "/joomla/projecten/"+subcat+"/";
				xmlhttp.open("GET", target, true);
				xmlhttp.onreadystatechange = function(){
					if (xmlhttp.readyState == 2) {
						document.getElementById("projectensub").style.visibility = "visible";
						document.getElementById("projectensub").innerHTML = "Gegevens worden geladen...";
					}
					if (xmlhttp.readyState == 4) {
						document.getElementById("projectensub").innerHTML = xmlhttp.responseText;
						Behaviour.apply();
						javascript:showProject(pagina, cat, subcat);
					}
				}
				xmlhttp.send(null)
			} else {
				javascript:openPage(pagina, cat, subcat);
			}
		} else if(!pagina && cat || subcat ) {
			javascript:klik(cat, subcat);
		}
		var track;
		track = cat;
		if(subcat){
			track = track + "/" + subcat;
		}
		if(pagina){
			track = track + "/" + pagina;
		} 
		urchinTracker(track);	
	}
}
//-->