function fProject(nProjectID,sTitle){
	this.nProjectID=nProjectID;
	this.sTitle=sTitle;
}


nPozTop=330

function fOpenProject(nProjectID){
	$("#oLBContent").html($("#oWork"+nProjectID).html())
	fPopupLayer("",false,nPozTop)
}
 
function fFlashMovie(sVideoUrl, bPlay){
	var sAutoPlay=(bPlay?"true":"false");
	var str='<object width="640" height="376" codebase="http://www.apple.com/qtactivex/qtplugin.cab" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B">'
	str+='<param name="src" value="http://aha-media.de'+ sVideoUrl +'">';
	str+='<param name="autoplay" value="true">';
	str+='<param name="loop" value="false">';
	str+='<param name="type" value="video/quicktime" height="640" width="376">';
	str+='<param name="controller" value="true">';
	str+='<embed src="'+ sVideoUrl +'" width="640" height="376" loop="false" controller="true" autoplay="true" type="video/quicktime" PLUGINSPAGE="http://www.apple.com/quicktime/"></embed>';
	str+='</object>';

	return str
}

/*
function fFlashMovie(sVideoUrl, bPlay){
	var sAutoPlay=(bPlay?"true":"false");
	var str='<object id="oFlashMovie" width="640" height="376" swLiveConnect="true" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">'
	str+='<param name="movie" value="/flash/player.swf">';
	str+='<param name="allowFullScreen" value="true" />';
	str+='<param name="wmode" value="transparent" />';
	str+='<param name="bgcolor" value="#000000" />';
	str+='<param name="quality" value="high">';		
	str+='<param name="flashvars" value="file=http://aha-media.de'+ sVideoUrl +'&autoplay='+ sAutoPlay +'&pic=http://aha-media.de/images/logo.gif">';
	str+='<embed id="oFlashMovie" src="/flash/player.swf" width="640" height="376" allowFullScreen="true" bgcolor="#000000" flashvars="file=http://aha-media.de'+ sVideoUrl +'&autoplay='+ sAutoPlay +'&pic=http://aha-media.de/images/logo.gif" wmode="transparent" quality="high" type="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></embed>';
	str+='</object>';

	return str
}
*/
 
var bWebsiteLoaded=false;
var bPopupVisiable=false, nPopupWidth=0, nPopupHeight=0;

function fPopupLayerPosition(bAutoPoz,nPozTop){
	if(!nPozTop) nPozTop=505;
	if(!bPopupVisiable) return;
	var obj=document.getElementById("oPopupLayerFrame");
	var nLeft=(document.body.offsetWidth-nPopupWidth)/2 +"px";
	var nTop=(document.documentElement.clientHeight-nPopupHeight)/2;
	nTop+=document.documentElement.scrollTop;
	nTop=(nTop<=0 ? 0 : nTop+"px");
	
	obj.style.width=nPopupWidth;
	//obj.style.height=nPopupHeight;
	obj.style.left=nLeft;
	if(bAutoPoz){
		obj.style.top=nTop;
	}
	else{
		obj.style.top=(nPozTop+10)+"px";
		var nScrollTo=(nPozTop?nPozTop:505)
		$("html:not(:animated),body:not(:animated)").animate({scrollTop:nScrollTo}, 800);
	}

	//document.getElementById("oPopupLayer").style.height=document.body.offsetHeight;
	//$("#oPopupLayer").css("height",$(".clsPageAlign").outerHeight()+215)
}

function fPopupLayer(nHeight,bAutoPoz,nPozTop){
	if(!bWebsiteLoaded) return;   // making sure everything is loaded
	nPopupWidth=730;
	nPopupHeight=(nHeight||716);
	var obj=document.getElementById("oPopupLayerFrame");
	bPopupVisiable=true;
	fPopupLayerPosition(bAutoPoz,nPozTop);

	obj.style.width=nPopupWidth +"px";
	//obj.style.height=nPopupHeight +"px";
	
	//document.getElementById("oPopupLayer").style.height=document.body.offsetHeight;
	document.getElementById("oPopupLayer").style.display="block";
	
	bLoopImages=false
	$("#oPopupLayer").show();
	$("#oPopupLayerFrame").fadeIn("slow",function(){
		$(".clsPopupLayerFrame").removeClass("clsPopupLayerFrameTrans");
		$(".clsPopupLayerFrameBody").removeClass("clsPopupLayerFrameBodyTrans");
		$(".clsLbBorder").show();
		$("#oLBContent .clsLBPlayer").html(fFlashMovie($("#oLBContent .clsLBPlayer").html(),true))
	});
	
}

function fClosePopupLayer(){
	$("#oLBContent .clsLBPlayer").html("");
	bPopupVisiable=false;
	nPopupWidth=0;
	nPopupHeight=0;
	$(".clsLbBorder").hide();
	$(".clsPopupLayerFrame").addClass("clsPopupLayerFrameTrans");
	$(".clsPopupLayerFrameBody").addClass("clsPopupLayerFrameBodyTrans");
	$("#oPopupLayerFrame").fadeOut("slow", function(){
		$("#oPopupLayer").hide();
	});
	bLoopImages=true;
	setTimeout(fLoopPromoImages,1000);
}


// ie7 & ffx uses fixed positioning which is not supperted in ie6
//if(bIE6) window.attachEvent("onscroll", fPopupLayerPosition)
//window.attachEvent("onresize", fPopupLayerPosition)