var currFlashPluginVersion="10.0.22.87", ppc, fb;

function setSubmenuPosition()
	{
	var pos,obj=document.getElementById("header");
	
	if (!obj) return;
	pos=elementPosition(obj);
	obj=document.getElementById("submenu");
	obj.style.top=(pos[1]+210)+"px";
	obj.style.left=pos[0]+"px";
	}


function showSubmenu()
	{
	var obj=document.getElementById("header");

	if (!obj) return;
	setSubmenuPosition();
	obj=document.getElementById("submenu");
	obj.style.visibility="visible";
	}


function hideSubmenu()
	{
	var obj=document.getElementById("submenu");

	if (!obj) return;
	obj.style.visibility="hidden";
	}


function fixBackground()
	{
	var h, tmp=document.getElementsByTagName("html");
	
	h=tmp[0].offsetHeight;
	tmp=document.getElementsByTagName("body")
	if (tmp[0].clientHeight < h ) tmp[0].style.height=h+"px";
	}
	
	
function windowResized()
	{
	fixBackground();
	setSubmenuPosition();
	}
//*****************************************	
	

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(animateFbBox,10);
		}
	}
	
	
function fb_mouseOut()
	{
	var tmp;
	
	with(this.parentObj)
		{
		if (!isOpened) return;
		isOpened=false;
		step=-10;
		if (!timerId) timerId=setInterval(animateFbBox,10);
		}
	}
	
	
function facebookClass()
	{
	this.isOpened=false;
	this.boxObj=document.getElementById("facebook");
	this.maxOffset=-320;
	this.currOffset=this.maxOffset;
	this.step=0;
	this.timerId=null;
	
	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 animateFbBox()
	{
	fb.animateBox();	
	}	


function initPage()
	{
	var obj=typeof(gallerySetup)=="undefined" ? null : gallerySetup;
	
	ppc=new picturePresenterClass(obj);
	fb=new facebookClass();	
	
	fixBackground();
	swfobject.embedSWF("Skins/pl/photos/Header.swf","menuEmbed",969,210,currFlashPluginVersion,"/common/expressInstall.swf",false,{quality:"high",wmode:"opaque",menu:"false"},{id:"menuFlash"});
	swfobject.embedSWF("Skins/pl/photos/Menu.swf","submenuEmbed",969,300,currFlashPluginVersion,"/common/expressInstall.swf",false,{quality:"high",wmode:"transparent",menu:"false"},{id:"submenuFlash"});
	
	if (document.getElementById("galleryEmbed"))
		{
		obj=new Object();
		if (typeof(documentId)!="undefined") obj.docId=documentId;
		swfobject.embedSWF("Skins/pl/photos/gallery.swf","galleryEmbed",188,448,currFlashPluginVersion,"/common/expressInstall.swf",obj,{quality:"high",wmode:"transparent",menu:"false"},{id:"galleryFlash"});
		}
		
	setSubmenuPosition();
	}


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