var fb, currFlashPluginVersion="10.0.32.18";


function fb_animateBox()
	{
	this.currOffset+=this.step;
	if (this.currOffset>0) 
		this.currOffset=0;
	else if (this.currOffset<this.maxOffset)
		this.currOffset=this.maxOffset;
		 
	this.boxObj.style.right=this.currOffset+"px";
	if (this.currOffset==0 || this.currOffset==this.maxOffset)
		{
		clearInterval(this.timerId);
		this.timerId=null;	
		}
	}
	
	
function fb_mouseOver()
	{
	var tmp;
	
	with(this.parentObj)
		{
		if (isOpened) return;
		isOpened=true;
		step=10;
		if (!timerId) timerId=setInterval(fnAnimate,10);
		}
	}
	
	
function fb_mouseOut()
	{
	var tmp;
	
	with(this.parentObj)
		{
		if (!isOpened) return;
		isOpened=false;
		step=-10;
		if (!timerId) timerId=setInterval(fnAnimate,10);
		}
	}
	
	
function facebookClass(id,width,fnAnimate)
	{
	this.isOpened=false;
	this.boxObj=document.getElementById(id);
	this.maxOffset=-width;
	this.currOffset=this.maxOffset;
	this.step=0;
	this.timerId=null;
	this.fnAnimate=fnAnimate;
	
	this.mouseOver=fb_mouseOver;
	this.mouseOut=fb_mouseOut;
	this.animateBox=fb_animateBox;
	
	if (!this.boxObj) return;
	this.boxObj.parentObj=this;
	this.boxObj.onmouseover=this.mouseOver;
	this.boxObj.onmouseout=this.mouseOut;
	}


//**********************************************	

function redirectRepertoire()
	{
	var obj=document.getElementById("repertoire1");
		
	if (!obj || document.getElementById("repertoire2")) return;
	obj.onclick();
	}
	
	
function announcement(url,ctgNick,hasContent)
	{
	if (hasContent==1)
		{
		window.location=url;
		return;
		}
		
	switch(ctgNick)
		{
		case "zapkino":
			url="doc_kinostart.html";
			break;
		case "zapwystawy":
			url="doc_wystawystart.html";
			break;
		case "zapkoncerty":
			url="doc_koncertystart.html";
			break;
		case "zapteatr":
			url="doc_teatrstart.html";
			break;
		case "zapdj":
			url="doc_djstart.html";
			break;
		case "zapstrefa":
			url="doc_strefastart.html";
			break;
		case "zapwarsztaty":
			url="doc_warsztatystart.html";
			break;
		}
		
	window.location=url;
	}


function clearField()
	{
	this.value="";
	this.onclick=null;
	}


function clearField2()
	{
	var obj=document.getElementById("panel_text2");
	if (obj.onclick) obj.value="";
	obj=document.getElementById("panel_director");
	if (obj.onclick) obj.value="";
	}
	
	
function removeBillboard()
	{
	var obj=document.getElementsByTagName("body");
	var obj2=document.getElementById("billboard");
	
	if (!obj2) return;
	obj=obj[0];
	obj.removeChild(obj2);
	}
	

//called by Gallery.swf
function showBillboard(pictURL,w,h)
	{
	var element=document.createElement("div");
	var tmp;

	element.id="billboard";
	element.onclick=removeBillboard;
	tmp=document.getElementsByTagName("body");
	tmp=tmp[0];
	tmp.appendChild(element);
	
	tmp=document.createElement("div");
	element.appendChild(tmp);
	element=tmp;
	
	tmp=document.createElement("img");
	tmp.src=pictURL;
	tmp.width=w;
	tmp.height=h;
	tmp.style.marginTop=parseInt(Math.max(0,(document.documentElement.clientHeight-h)/2))+"px";
	element.appendChild(tmp);
	}
	
	
function animateFbBox()
	{
	fb.animateBox();	
	}
	

function initPage()
	{
	var color, obj,tmp;

	redirectRepertoire();
	fb=new facebookClass("facebook",320,animateFbBox);	
	
	obj=document.getElementById("topGalleryEmbed");
	tmp=typeof(documentId)=="undefined" ? -1 : documentId;
	color=typeof(sectionColor)=="undefined" ? "FFFFFF" : sectionColor;
	if (obj) 
		swfobject.embedSWF("Skins/pl/photos/Gallery.swf","topGalleryEmbed",530,270,currFlashPluginVersion,"/common/expressInstall.swf",{docId:tmp,color:color},{quality:"high",wmode:"transparent",menu:"false"},{id:"topGalleryFlash"});
	
	obj=document.getElementById("verPL");
	if (obj) obj.onclick=function () {window.location="/"};
	obj=document.getElementById("verEN");
	if (obj) obj.onclick=function () {window.location="/en/"};
	if (typeof(headerMode)=="undefined") headerMode="full";
	swfobject.embedSWF("Skins/pl/photos/header.swf","headerEmbed",250,324,currFlashPluginVersion,"/common/expressInstall.swf",{mode:headerMode},{quality:"high",wmode:"transparent",menu:"false"},{id:"headerFlash"});
	
	obj=document.getElementById("promotionEmbed");
	if (obj) 
		swfobject.embedSWF("Skins/pl/photos/Promotion.swf","promotionEmbed",400,152,currFlashPluginVersion,"/common/expressInstall.swf",false,{quality:"high",wmode:"transparent",menu:"false"},{id:"promotionFlash"});
	
	obj=document.getElementById("homeEmbed");
	if (obj) 
		swfobject.embedSWF("Skins/pl/photos/Home.swf","homeEmbed",111,170,currFlashPluginVersion,"/common/expressInstall.swf",false,{quality:"high",wmode:"opaque",menu:"false"},{id:"homeFlash"});
		
	obj=document.getElementById("panel_text");
	if (obj && obj.value=="") 
		{
		obj.value="szukaj w serwisie";
		obj.onclick=clearField;
		}
		
	obj=document.getElementById("panel_text2");
	if (obj && obj.value=="") 
		{
		obj.value="szukaj w tytule";
		obj.onclick=clearField;
		}
		
	obj=document.getElementById("panel_director");
	if (obj && obj.value=="") 
		{
		obj.value="szukaj autora";
		obj.onclick=clearField;
		}
		
	MM_preloadImages("Skins/pl/pictures/icnDocGray.png");
	}


window.onload=init;
initClassObj.registerFunction(initPage);	
