var myWidth = 0, myHeight = 0;
var imgArr = new Array();
var timer;
function writeFlash(id, url, width, height, wmode, vars, writeTo, useWriteTo)
{
	var writeString = '';
	hasFlash = true;
	// Controleer ECHT of er Flash is
	if(hasFlash)
	{
		
		var widthStr = '';
		var heightStr = '';
		if (width > 0 )
		{
			widthStr = ' width="'+width+'"';
		}
		if (height > 0 )
		{
			heightStr = ' height="'+height+'"';
		}
		writeString='<object id="flashmovie" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"' + widthStr + heightStr + ' id="'+url+'" align="middle">';
		writeString+='<param name="allowScriptAccess" value="sameDomain" />';
		writeString+='<param name="movie" value="'+url+'" />';
		writeString+='<param name="quality" value="high" />';
		writeString+='<param name="wmode" value="'+wmode+'" />';
		writeString+='<param name="FlashVars" value="'+vars+'" />';
		writeString+='<embed id="'+url+'" FlashVars="'+vars+'" src="'+url+'" quality="high" wmode="'+wmode+'"' + widthStr + heightStr + ' name="main" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		writeString+='</object>';		
	}
	else
	{
		if (width > 0 )
		{
			widthStr = width +'px';
		}
		if (height > 0 )
		{
			heightStr = height+'px';
		}
		writeString='<div class="noFlashHolder" style="width:'+widthStr+';height:'+heightStr+';">U heeft geen Flashspeler ge&iuml;nstalleerd/No flashplayer installed. <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">Klik hier om te downloaden/Click here to download.</a></div>';
	}
	if(useWriteTo)
	{
		if(writeTo)
			writeTo.innerHTML = writeString;
	}
	else
		document.write(writeString);
}

function getWindowSize() {
		
		if( typeof( window.innerWidth ) == 'number' ) {
		 myWidth = window.innerWidth;
		 myHeight = window.innerHeight;
		} else if( document.documentElement &&
		   ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		 myWidth = document.documentElement.clientWidth;
		 myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		 myWidth = document.body.clientWidth;
		 myHeight = document.body.clientHeight;
		}  
		
	}
function getPos(theObj){
	  x = y = 0;
	  	var oldstyle = theObj.style.display;	
	  	theObj.style.display = 'block';
	  h = theObj.offsetHeight;
	  w = theObj.offsetWidth;
  		theObj.style.display = oldstyle;
	  while(theObj){
	    x += theObj.offsetLeft;
	    y += theObj.offsetTop;
	    theObj = theObj.offsetParent;
	  }
	  return {height:h,width:w,x:x,y:y}
	}
	

window.onload=function()
{
	//IE6 flicker bug solution:
	try {
		document.execCommand("BackgroundImageCache", false, true);

	} catch(err) {}
  
	// Controleer of er uberhaupt Flash beschikbaar is
	var hasReqestedVersion = DetectFlashVer(7,0,0);
	if (hasReqestedVersion) 
	{
		loadFlash();
	}
	else
	{ 
		// doe wat?er nodig is om de non flash content te tonen
		document.getElementById('flashFooter').style.display = "none";
		document.getElementById('nonFlashFooter').style.display = "block";
	}		
	
};

window.onresize=function()
{
	clearTimeout(timer);
	timer = setTimeout(loadFlash, 100);	
};

function loadFlash()
{
	getWindowSize();
	var breedte = myWidth < 950 ? 950 : myWidth ;
	/*var pos = getPos(document.getElementById('wrapper'));
	if((pos.height+50)>myHeight)
	{		
		document.getElementById('flashFooter').style.top = pos.height+50+ 'px';
		document.getElementById('flashFooter').style.bottom = "";
	}
	else
	{
		document.getElementById('flashFooter').style.top = '';
		document.getElementById('flashFooter').style.bottom = 0 + 'px';
	}*/	
	
	writeFlash('flashFooter', '/flash/amcity.swf', breedte, 100, 'transparent', 'breedte='+breedte, document.getElementById('flashFooter'), true);	

}
function goHome()
{
	window.location.href=('/home.aspx');
}

var currentPos = 0;
var imgArr = new Array();

function slideImg(richting)
{	
	var maxlength=imgArr.length;
	if (richting=='forward')
	{
		currentPos+=1;
		if(currentPos>maxlength-1)
		{
			currentPos = 0;
		}		
	}
	else
	{
		currentPos-=1;
		if(currentPos<0)
		{
			currentPos = maxlength-1
		}		
	}
	showImageOnCurrentPos();
}

function showImageOnCurrentPos()
{
	var currentImg=document.getElementById('slideImg');
	currentImg.src=imgArr[currentPos].url;
	document.getElementById('slideShowNavigationPageLabel').innerHTML = 'afbeelding '+(currentPos+1)+' van '+imgArr.length;
}

function SlideshowImage(id, url)
{
	this.id = id;	
	this.url = url;
}
function changeCase()
{
	var sel = document.getElementById('caseSelect')
	tar=sel.options[sel.selectedIndex].value;
	if(tar!='')
	{
		location.href=tar;
	}
	
}

//nieuwe slideshow functies voor meerdere slideshows zichtbaar op de pagina:
function slideImg(projectId, projectImgArr, projectCurrentPos, richting)
{	
	var maxlength=projectImgArr.length;
	if (richting=='forward')
	{
		projectCurrentPos+=1;
		if(projectCurrentPos>maxlength-1)
		{
			projectCurrentPos = 0;
		}		
	}
	else
	{
		projectCurrentPos-=1;
		if(projectCurrentPos<0)
		{
			projectCurrentPos = maxlength-1
		}		
	}
	showImageOnCurrentPos(projectId, projectImgArr, projectCurrentPos);
	return projectCurrentPos;
}


function showImageOnCurrentPos(projectId, projectImgArr, projectCurrentPos)
{
	var currentImg=document.getElementById('slideImg_'+projectId);
	currentImg.src=projectImgArr[projectCurrentPos].url;
	document.getElementById('slideShowNavigationPageLabel_'+projectId).innerHTML = 'afbeelding '+(projectCurrentPos+1)+' van '+projectImgArr.length;
}