<!--
var currentFile_str = "home";
var path_str = window.location.pathname;
var page_str = path_str.substring(path_str.lastIndexOf('/') + 1);
page_str = page_str.substring(0, page_str.lastIndexOf('.'));
if ((page_str != "") && (page_str != "index") && (page_str != "home")) {
	currentFile_str = page_str;
}

//alert("page_str: " + page_str);

var fadeTime_num = 500;
var growTime_num = 500;
var slideTime_num = 500;
var LoadStatus = 'ready';

if (IE_str == 'ie') {
	oh = 3;
	nh = 18;
} else {
	oh = 1;
	nh = 18;	
}

Element.setStyle('content', {visibility: 'visible'});

function loadParam(target, newFile_str, cat, tec, offset, projectID)
{
	if (newFile_str == 'home') {
		Spry.Utils.updateContent(target, newFile_str + '.inc.asp?visible=false');
	} else if (newFile_str == 'portfolio') {
		if ((cat != null) && (cat != 0)) {
			Spry.Utils.updateContent(target, newFile_str + '.inc.asp?visible=false&categoryID=' + cat +'&offset='+ offset);
		} else if ((tec != null) && (tec != 0)) {
			Spry.Utils.updateContent(target, newFile_str + '.inc.asp?visible=false&techniqueID=' + tec +'&offset='+ offset);
		} else {
			Spry.Utils.updateContent(target, newFile_str + '.inc.asp?visible=false');
		}
	} else if (newFile_str == 'vacatures') {
		Spry.Utils.updateContent(target, newFile_str + '.inc.asp?visible=false');
	} else if (newFile_str == 'contact') {
		Spry.Utils.updateContent(target, newFile_str + '.inc.asp?visible=false');
	} else if (newFile_str == 'portfolio_details') {
		if ((cat != null) && (cat != 0)) {
			Spry.Utils.updateContent(target, newFile_str + '.inc.asp?visible=false&categoryID=' + cat +'&offset='+ offset + '&projectID=' + projectID);
		} else if ((tec != null) && (tec != 0)) {
			Spry.Utils.updateContent(target, newFile_str + '.inc.asp?visible=false&techniqueID=' + tec +'&offset='+ offset + '&projectID=' + projectID);
		} else {
			Spry.Utils.updateContent(target, newFile_str + '.inc.asp?visible=false&projectID=' + projectID);
		}
	}	
}

var projectID_num;
var pe;
var pe2;

function loadNewContent(newFile_str, cat, tec, offset, projectID)
{
	if (LoadStatus == 'ready') {

		LoadStatus = 'active';
		
		var sub3Exists = document.getElementById("sub3");
		
		subHeight_num1 = Element.getHeight('subnav1');
		subHeight_num2 = Element.getHeight('subnav2');
		if ((sub3Exists != null)) {
			subHeight_num3 = Element.getHeight('subnav3');
		}
		
		// Main content
		contentHeight_num = Element.getHeight('content');
		
		loadParam('heightCheck', newFile_str, cat, tec, offset, projectID);
		
		contentNewHeight_num = Element.getHeight('heightCheck') - 20;
		Spry.Utils.updateContent('heightCheck', 'empty.html');
		Spry.Effect.AppearFade('content', {duration: fadeTime_num, from: 100, to: 0, finish:growContent});
		
		if ((currentFile_str == 'portfolio')) {
			if (pe != null) {
				pe.stop();
			}
		}
		if ((currentFile_str == 'portfolio_details')) {
			if (pe2 != null) {
				pe2.stop();
			}
		}
		
		if (newFile_str == 'home') {
			if (currentFile_str != 'home') {
				Sub('1', newFile_str, subHeight_num1);
				Sub('2', newFile_str, subHeight_num2);
				Sub('3', newFile_str, subHeight_num3);
			}
		} else if (newFile_str == 'portfolio') {

			if (cat != null) {
				if (pe != null) {
					pe.stop();							
				}
			} else {			
				 reloadPortfolioImg();
			}
			
			if ((currentFile_str != 'portfolio') && (currentFile_str != 'portfolio_details')) {
				Sub('1', newFile_str, subHeight_num1, cat);
				Sub('2', newFile_str, subHeight_num2, cat);
				
				if (sub3Exists != null) {
					fadeSub3();		// Hide sub3
				}
			} else {									
				ReloadSubCatOnly('1', 'portfolio', cat);
				ReloadSubTecOnly('2', 'portfolio', tec);
			}
		} else if (newFile_str == 'portfolio_details') {

			projectID_num = projectID;
			reloadPortfolioDetailsImg();

			if (currentFile_str == 'portfolio') {
				
			} else if (currentFile_str == "portfolio_details") {
				
			} else {
				Sub('1', newFile_str, subHeight_num1);
				Sub('2', newFile_str, subHeight_num2);
				
				if (sub3Exists != null) {
					fadeSub3();		// Hide sub3
				}
			}
		} else if (newFile_str == 'vacatures') {
			if (currentFile_str != 'vacatures') {
				Sub('1', newFile_str, subHeight_num1);
				Sub('2', newFile_str, subHeight_num2);
				
				if (sub3Exists != null) {
					fadeSub3();		// Hide sub3
				}
			}
		} else if (newFile_str == 'contact') {
			if (currentFile_str != 'contact') {
				Sub('1', newFile_str, subHeight_num1);
				Sub('2', newFile_str, subHeight_num2);
				
				if (sub3Exists != null) {
					fadeSub3();		// Hide sub3
				}
			}
		} else {
			Sub('1', newFile_str, subHeight_num1);
		}
	}
	
	function fadeSub3() {
		Spry.Effect.AppearFade('sub3', {duration: 50, from: 100, to:0, finish:slideSub3});
	}
	
	function slideSub3() {
		Spry.Effect.Slide('nav3', {duration: 300,from: '100%',to: '0%', horizontal:true, finish:hideSub3});
	}
	
	function hideSub3()	{
		Element.setStyle('subnav3', {visibility: 'hidden'});
	}

	function growContent()
	{
		if (IE_str == 'ie6')
		{
			Spry.Utils.updateContent('content', 'empty.html'); //ie6 ivm fade nog checken ?!!!
		}
		
		if (cat == null) {
			if (currentFile_str == "portfolio_details") {
				Element.setStyle("portfolio", {color: '#4C90CA'});
				Element.setStyle(newFile_str, {color: '#A0A0A0'});
			} else {
				Element.setStyle(currentFile_str, {color: '#4C90CA'});
				Element.setStyle(newFile_str, {color: '#A0A0A0'});
			}
		} else {
			if (newFile_str == "portfolio_details") {
				if (currentFile_str != "portfolio_details") {
					Element.setStyle(currentFile_str, {color: '#4C90CA'});
				}
				Element.setStyle("portfolio", {color: '#A0A0A0'});
			}
		}
		currentFile_str = newFile_str;
		
		Element.setStyle('content', {height: (contentHeight_num-40) + 'px'});		
		Element.setStyle('content', {width: '10px'});	// voorkomt horizontale scrollbar

		// bij minder dan 25 pixel verschil in hoogte geen grow anim
		hvar = Math.abs(contentHeight_num - contentNewHeight_num);
		if (hvar > 25) {
			Spry.Effect.GrowShrink('content',{duration: growTime_num,from: (contentHeight_num-40) + 'px',to: (contentNewHeight_num-20) + 'px',referHeight:true , growCenter:false, finish:fadeContent});
		} else {
			fadeContent();
		}
		
	}
	function fadeContent()
	{
		loadParam ('contentbck', newFile_str, cat, tec, offset, projectID);

//		Spry.Utils.updateContent('contentbck', newFile_str + '.inc.asp?visible=false&categories=' + cat +'&projectID='+ offset );		
		Spry.Effect.AppearFade('content',{duration: fadeTime_num,from: 0,to:100, finish:updateFinish});	
	}
	function updateFinish()
	{
//		Spry.Utils.updateContent('contentbck', newFile_str + '.inc.asp');
		LoadStatus = 'ready';		
	}	
}
	function Sub(sub_nr, newFile_str, subHeight_num, cat)
	{
		params_str = "";
		if (cat != null) {
			params_str = "?categoryID=" + cat;
		}
		
		Spry.Utils.updateContent('heightCheckSub' + sub_nr, newFile_str + '_sub' + sub_nr + '.inc.asp' + params_str);
		subNewHeight_num = Element.getHeight('heightCheckSub' + sub_nr);	
		Spry.Utils.updateContent('heightCheckSub' + sub_nr, 'empty.html');		
	
		//alert("Sub!! subHeight_num: " + subHeight_num);
		//Element.setStyle('contentsub' + sub_nr, {height: subHeight_num + 'px'});
	
		if ((sub_nr == 3) && (newFile_str == 'home')) {
			Spry.Effect.AppearFade('sub' + sub_nr, {duration: 100, from: 0, to:0, finish:slideSubIn(sub_nr, newFile_str, subHeight_num, subNewHeight_num, cat)});
		} else {
			Spry.Effect.AppearFade('sub' + sub_nr, {duration: 100, from: 100, to:0, finish:slideSubIn(sub_nr, newFile_str, subHeight_num, subNewHeight_num, cat)});
		}
		//Spry.Effect.AppearFade('sub' + sub_nr, {duration: fadeTime_num, from: 100, to:0, finish:slideSubIn});
	}

	function slideSubIn(sub_nr, newFile_str, subHeight_num, subNewHeight_num, cat) {
		
		if (sub_nr == 3) {
			Spry.Effect.Slide('nav' + sub_nr, {duration: slideTime_num,from: '0%',to: '0%', horizontal:true, finish:hideSub});
		} else {
			Spry.Effect.Slide('nav' + sub_nr, {duration: slideTime_num,from: '100%',to: '0%', horizontal:true, finish:hideSub});
		}

		params_str = "";
		if (cat != null) {
			params_str = "categoryID=" + cat;
		}

		function hideSub() {
			Element.setStyle('subnav'+sub_nr, {visibility: 'hidden'});
			Spry.Utils.updateContent('contentsub'+sub_nr, newFile_str + '_sub'+sub_nr+'.inc.asp?visible=false&' + params_str);
			
			slideSubOut();
		}
		
		function slideSubOut() {	
			Element.setStyle('contentsub'+sub_nr, {height: (subNewHeight_num+oh) + 'px'});	
			Element.setStyle('nav'+sub_nr, {height: (subNewHeight_num+nh) + 'px'});
			Element.setStyle('subnav'+sub_nr, {visibility: 'visible'});
			Spry.Effect.Slide('nav'+sub_nr,{duration: slideTime_num,from: '0',to: '115px', horizontal:true, finish:fadeSub});
		}
		
		function fadeSub() {
			Spry.Effect.AppearFade('sub'+sub_nr,{duration: fadeTime_num,from: 0,to:100, finish:ReloadSub});	
		}
		
		function ReloadSub() {
			Spry.Utils.updateContent('contentsub'+sub_nr, newFile_str + '_sub'+sub_nr+'.inc.asp?' + params_str);	
		}
	}
	
	function ReloadSubCatOnly(sub_nr, newFile_str, cat) {
		params_str = "";
		if (cat != null) {
			params_str = "categoryID=" + cat;
		}
		Spry.Utils.updateContent('contentsub' + sub_nr, newFile_str + '_sub' + sub_nr + '.inc.asp?' + params_str);	
	}
	
	function ReloadSubTecOnly(sub_nr, newFile_str, tec) {
		params_str = "";
		if (tec != null) {
			params_str = "techniqueID=" + tec;
		}
		Spry.Utils.updateContent('contentsub' + sub_nr, newFile_str + '_sub' + sub_nr + '.inc.asp?' + params_str);	
	}
	
	
/* delete */
function ReloadContent(newFile_str, cat) {
	Spry.Utils.updateContent('contentbck', newFile_str + '.inc.asp?visible=true&categories=' + cat );
}

function ReloadSubNewsletter(sub_nr, newFile_str, param_str) {
	//alert(newFile_str + '_sub' + sub_nr + '.inc.asp?email=' + 'tuuuuut');
	Spry.Utils.updateContent('contentsub' + sub_nr, newFile_str + '_sub' + sub_nr + '.inc.asp?newsletter=daan');	
}
	
function ShowPopup(nr) {
	Element.setStyle('popup' + nr, {top: (yPos - 260) + 'px'});		
	Element.setStyle('popup' + nr, {left: (xPos - 75) + 'px'});	
	Element.setStyle('popup' + nr, {display: 'block'});	
}

function HidePopup(nr) {
	Element.setStyle('popup' + nr, {display: 'none'});		
}
	
function showPosition(e) {
	xPos = Event.pointerX(e);
	yPos = Event.pointerY(e);
}

Event.observe(document, "mousedown", showPosition, false);
//-->

function reloadPortfolioImg() {
	pe = new PeriodicalExecuter(reloadImg, 5);
}
function reloadImg() {
	Spry.Effect.AppearFade('portfolioImg',{duration: fadeTime_num,from: 100,to:0, finish:reloadImgFinish});
}
function reloadImgFinish() {
	Spry.Utils.updateContent('portfolioImg', 'portfolio_img.inc.asp' );
	Spry.Effect.AppearFade('portfolioImg',{duration: fadeTime_num,from: 0,to:100});
}

function reloadPortfolioDetailsImg() {
	pe2 = new PeriodicalExecuter(reloadDetailsImg, 5);
}
function reloadDetailsImg(projectID) {
	Spry.Effect.AppearFade('portfolioImg', {duration: fadeTime_num,from: 100,to:0, finish:reloadDetailsImgFinish});	
}
function reloadDetailsImgFinish() {
	Spry.Utils.updateContent('portfolioImg', 'portfolio_details_img.inc.asp?projectID=' + projectID_num);
	Spry.Effect.AppearFade('portfolioImg',{duration: fadeTime_num,from: 0,to:100});		
}

if ((page_str != '') && (page_str != 'home')) {
	Element.setStyle('subnav3', {visibility: 'hidden'});
}