//foldouts
$(document).ready(function() {
	$( ".foldoutHeader a" ).each(
		function( intIndex ){
			$( this ).bind ("click",function(){
				if($(this).parent().next().css('display')=='block'){
					$(this).css('background-image', 'url(/site_files/img/arrow_left.gif)');
				}else{
					$(this).css('background-image', 'url(/site_files/img/arrow_down.gif)');
				}
				$(this).parent().next().slideToggle();
				return false;
			});
		}
	);	
});



function popUp(URL,w,h) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=" + w + ",height=" + h + ",left = 628.5,top = 500.5');");
}

function showDiv(whichLayer, visible) // 1 visible, 0 hidden
{
	if (document.getElementById) {
		var style2 = document.getElementById(whichLayer).style;
		style2.display = visible ? "block":"none";
	} else if (document.all) {
		var style2 = document.all[whichLayer].style;
		style2.display = visible ? "block":"none";
	} else if (document.layers) {
		var style2 = document.layers[whichLayer].style;
		style2.display = visible ? "block":"none";
	}

	// verplaats div omhoog als het niet in het venster staat
	if( visible )
	{
		document.getElementById(whichLayer).style.top = "0px";
		var bottomDiv = getAbsoluteTop(whichLayer) + document.getElementById(whichLayer).offsetHeight;
		var screenHeight = getWidthHeight()[1] + getScrollXY()[1];
		if( bottomDiv > screenHeight )
		{
			var obj = document.getElementById(whichLayer);
			document.getElementById(whichLayer).style.top = -(bottomDiv - screenHeight) + "px";
		}
	}

}

function getAbsoluteTop(objectId) {
	// Get an object top position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId)
	oTop = o.offsetTop            // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent  // Get parent object reference
		oTop += oParent.offsetTop // Add parent top position
		o = oParent
	}
	// Return top position
	return oTop
}

function getScrollXY() {
	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;
	}
	return [ scrOfX, scrOfY ];
}

function getWidthHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [myWidth, myHeight ];
}
/************************ FOTOBLOK *************************/
var currentPhoto;

function switchClass(activeID,photo){
    setPhoto(photo);
	moveArrow(activeID);
}

function setPhoto(photo) {
    if(this.currentPhoto != photo)
        document.getElementById('homeFoto').style.background="url(\'/site_files/imgc/" + photo + "\') 0 0 no-repeat";
    this.currentPhoto = photo;
}

function moveArrow(activeID){
	document.getElementById('firstElement').className='homeFotoKeuzeOptieOff';
	document.getElementById('secondElement').className='homeFotoKeuzeOptieOff';
	document.getElementById('thirdElement').className='homeFotoKeuzeOptieOff';

	if(activeID == 1){
		document.getElementById('homeFoto').style.height='219px';
		document.getElementById('homeFoto').style.paddingTop='35px';
		document.getElementById('firstElement').className='homeFotoKeuzeOptieOn';
	}
	if(activeID == 2){
		document.getElementById('homeFoto').style.height='135px';
		document.getElementById('homeFoto').style.paddingTop='119px';
		document.getElementById('secondElement').className='homeFotoKeuzeOptieOn';
	}
	if(activeID == 3){
		document.getElementById('homeFoto').style.height='51px';
		document.getElementById('homeFoto').style.paddingTop='203px';
		document.getElementById('thirdElement').className='homeFotoKeuzeOptieOn';
	}
}