function loadMovie(container,url,linknum,highres,noAutoplay){
	if(linknum!==false){
		link_num=linknum;
		var linkstotal = $('movie_link_container').getElementsByTagName('a').length;
		for(var i=0;i<linkstotal;i++){
			if(i%2==0){
				$('movie_item_'+i).className 			= 'movie_item row1';
			} else {
				$('movie_item_'+i).className 			= 'movie_item';
			}
			$('movie_pointer_'+i).style.display 	= 'none';
		}
		$('movie_item_'+linknum).className 			= 'movie_item active_movie';
		$('movie_pointer_'+linknum).style.display 	= 'block';
	}
		
	var oc = new SWFObject("/includes/swf/flvplayer.swf", "flvplayer", highres?640:320, highres?380:200, "7");
	if(noAutoplay){
		oc.addVariable("autoStart","false");
	} else {
		if(linknum===false){
			oc.addVariable("bg","white");
			oc.addVariable("autoStart","false");
		}
	}
	oc.addVariable("file","/uploads/flvs/"+url);
	oc.addParam("menu","false");
	oc.addVariable("lang",lang);
	oc.write(container);
}
function popUp(page,width,height,noScroll){
	var sw = screen.availWidth;	
	var sh = screen.availHeight;
	var l = (sw-width)/2;
	var t = (sh-height)/2;
	var win = window.open(page,'win_pop','width='+width+',height='+height+',left='+l+',top='+t+',resizable=yes,'+(noScroll?'scrollbars=yes,':'scrollbars=no,')+'location=no,status=no,screenX='+l+',screenY='+t+',');
	if(win) win.focus();
}
function pageWidth() {
	return screen.availWidth;
}
function pageHeight() {
	return screen.availHeight;
}
var movie_project_id;

var frameWidth;
var frameHeight;

function getWinSize() {
  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];
}

function showHighres(){
	
	$('highres').style.display = 'block';
	
	if (window.innerWidth){
		iWidth 	= window.innerWidth;
		iHeight = window.innerHeight;
	} else {
		iWidth 	= document.body.clientWidth;
		iHeight = document.body.clientHeight;
	}
	var size 	= getWinSize();
	frameWidth 	= size[0];
	frameHeight = size[1];
	iWidth 	= $('highres').width - iWidth;
	iHeight = $('highres').height - iHeight;
	try{
		window.resizeBy(iWidth, iHeight);
	} catch(e) {};
}
function hideHighres(){
	$('highres').style.display = 'none';
	resizeWindow(725,430);
}
function blinkSector(id,project_id){
	$('project_td_'+project_id).style.backgroundColor = '#fff';
	if(sectoren.length>0){
		for(var i=0;i<sectoren.length;i++){
			$('sector_'+sectoren[i]).style.backgroundColor = '';
		}
	}
	$('sector_'+id).style.backgroundColor = '#fff';
}
function unblinkSector(project_id){
	$('project_td_'+project_id).style.backgroundColor = '';
	if(sectoren.length>0){
		for(var i=0;i<sectoren.length;i++){
			$('sector_'+sectoren[i]).style.backgroundColor = '';
		}
	}
}
var movie_url;
function viewProject(id,lang,current,section){
	var uri;
	var w = 725;
	var h = 425;
	var sw=screen.availWidth;	
	var sh=screen.availHeight;
	var l=(sw-w)/2;
	var t=(sh-h)/2;
	if(!current){
		current = 0;
	}
	switch(section){
		case 'illustratie':
			uri = '/artist-impression';
		break;
		case 'animatie':
			uri = '/3d-animaties';
		break;
		case 'campagnes':
			uri = '/campagnes';
		break;
		case 'corporate':
			uri = '/corporate-identity';
		break;
		case 'grafisch':
			uri = '/grafisch-ontwerp';
		break;
		case 'media':
			uri = '/nieuwe-media';
		break;
		case 'film':
			//stop the currently playing movie
			loadMovie('movie',movie_url,link_num,false,true);
			uri = '/3d-films';
		break;
		default:
			uri = '/pages';
	}
	var theWin = document.open(uri+'/project.php?id='+id+'&lang='+lang+'&current='+current,'popup_project','width='+w+',height='+h+', status=yes, location=no, resizable=no, scrollbars=no, left='+l+',top='+t+',screenX='+l+',screenY='+t+',');
	if(theWin){
		theWin.focus();
	} else {
		if(lang=='nl'){
			alert('Om onze projecten te kunnen bekijken dient u uw popup-blocker uit te schakelen');
		} else {
			alert('You should disable your popup-blocker in order to view our projects');
		}
	}
}
function resizeWindow(iWidth, iHeight){
    var resizeRef = $('resizeReference');
    var iOuterWidth = iWidth + 10;
    var iOuterHeight = iHeight + 29;
    if (resizeRef) {
        var iPreWidth = resizeRef.offsetWidth;
        var iPreHeight = resizeRef.offsetHeight;
        window.resizeTo(iPreWidth,iPreHeight);
        var iPostWidth = resizeRef.offsetWidth;
        var iPostHeight = resizeRef.offsetHeight;
        iOuterWidth = iWidth + (iPreWidth-iPostWidth);
        iOuterHeight = iHeight + (iPreHeight-iPostHeight);
    }
    window.resizeTo(iOuterWidth, iOuterHeight);
}
function stopSliding(){
	var element;
	var movieName = 'portfolio_flash';
	if (window.document[movieName]) {
		element = window.document[movieName];
	} else {
		if (navigator.appName.indexOf("Microsoft Internet")==-1){
			if (document.embeds && document.embeds[movieName]){
				element = document.embeds[movieName];
			}
		}
		else {
			element = document.getElementById(movieName);
		}
	}
	if(element){
		try{
			element.SetVariable("stopSliding","true");
		} catch(e){};
	}
}
function setCookie(c_name,value,expiredays){
	var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=(c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString()))+";path=/;";
}
function getCookie(c_name){
	if (document.cookie.length>0){
  		c_start=document.cookie.indexOf(c_name + "=");
		if(c_start!=-1){ 
    		c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
    	if(c_end==-1) c_end=document.cookie.length;
		return unescape(document.cookie.substring(c_start,c_end));
    	} 
	  }
	return "";
}
function closeXmasCard(){
	setTimeout(function(){
		try{ document.getElementById('portfolio_flash').style.visibility = 'visible';} catch(e){};
		var div = document.getElementById('xmas');
		div.innerHTML = '';
		div.style.width = div.style.height = 0 ;
		setCookie('xmascard','1',99);
	},100);
}
/*Event.observe(window,'load',function(){
	if(!getCookie('xmascard')){
		try{
			document.getElementById('portfolio_flash').style.visibility = 'hidden';
		} catch(e){};
		
		var div = document.createElement('div');
		div.setAttribute('id','xmas');
		document.body.appendChild(div);
	
		var divObj = document.getElementById('xmas');
		if(divObj){
			divObj.style.position 			= 'absolute';
			divObj.style.left 				= 0;
			divObj.style.top 				= 0;
			divObj.style.width 				= '100%';
			divObj.style.height				= '100%';
			divObj.style.textAlign 			= 'center';
			divObj.style.verticalAlign 		= 'middle';
		
			var x = new SWFObject("/includes/swf/kerstkaart.swf", "xmascard", "600", "400", "7");
			x.addParam('menu','false');
			//x.addParam('wmode','transparent');
			x.write('xmas');

			document.getElementById('xmascard').style.marginTop = '8%';
		}
	}
});*/