var currFlashPluginVersion="10.0.32.18";
var searchMode=1;
var voteSrcPictures=Array();
var picturePath;


function showFlashGallery()
	{
	var obj2, offset, obj=document.getElementById("gallery");
	
	if (!obj) return;
	obj2=document.getElementsByTagName("html");
	obj2=obj2[0];
	
	obj.style.height=(document.body.clientHeight+20)+"px";
	obj.style.visibility="visible";	
	
	obj=document.getElementById("showGalleryFlash");
	offset=obj2.scrollTop;
	if (document.documentElement.clientHeight>600)
		offset+=parseInt((document.documentElement.clientHeight-600)/2);
	obj.style.marginTop=offset+"px";
	}


function hideFlashGallery()
	{
	var obj=document.getElementById("gallery");
	
	if (!obj) return;
	obj.style.visibility="hidden";	
	}
	

function resizeFlashGallery(height)
	{
	var obj=document.getElementById("galleryPickFlash");
	
	if (!obj) return;
	if (height==0)
		obj.style.display="none";
	else
		obj.style.height=height+"px";	
	}
	
	
function showAdvanced()
	{
	var obj=document.getElementById("searchBoxSmall");
		
	if (!obj) return;
	obj.style.display="none";
	obj=document.getElementById("searchBox");
	obj.style.display="table-cell";
	updateSearchPanel();
	}
	
	
function updateSearchPanel()
	{
	var obj, i;
	
	switch(searchMode)
		{
		case 1:	
			for(i=1; i<=6; i++)
				{
				obj=document.getElementById("mode3_"+i);
				obj.style.display="none";
				}
			break;
		case 2:	
			for(i=1; i<=6; i++)
				{
				obj=document.getElementById("mode3_"+i);
				obj.style.display="none";
				}
			break;
		case 3:	
			for(i=1; i<=6; i++)
				{
				obj=document.getElementById("mode3_"+i);
				obj.style.display="inherit";
				}
			break;
		case 4:	
			for(i=1; i<=6; i++)
				{
				obj=document.getElementById("mode3_"+i);
				obj.style.display="none";
				}
			break;
		}
	}
	
	
function switchSearchMode()
	{
	var i, obj;
	
	for(i=1; i<=4; i++)
		{
		obj=document.getElementById("mode"+i);
		obj.style.fontWeight = obj==this ? "bold" : "normal";
		if (obj==this) searchMode=i;
		}
		
	updateSearchPanel();
	}
	
	
function bookmarkPage()
	{
	if (window.external.AddFavorite)
		window.external.AddFavorite(location.href, document.title)		
	else if (window.sidebar)
		window.sidebar.addPanel(document.title, location.href,"");
	}


function updateMediaForm()
	{
	var obj, obj2, ctg, str="";
	if (!document.getElementById("etnoAddMediaForm")) return;
	
	obj=document.getElementById("category");
	ctg=obj.options[obj.selectedIndex].value;
	obj=document.getElementById("attRow");
	obj2=document.getElementById("urlRow");
	
	switch(parseInt(ctg))
		{
		case 1:	//video
			str="FLV";
			obj2.style.display="none";
			break;
		case 2:	//audio
			str="MP3";
			obj2.style.display="none";
			break;
		case 3:	//zdjecia
			str="PNG, JPG, GIF - max. 640x480";
			obj2.style.display="none";
			break;
		case 4:	//zewnetrzny URL
			obj2.style.display="table-row";
			obj.style.display="none";
			return;
		}
		
	obj.style.display="table-row";
	obj=document.getElementById("extensionInfo");
	obj.innerHTML=str;
	}
	
	
function setSize(idx)
	{
	var obj=document.getElementById("docSizer");
	
	if (!obj) return;
	switch(idx)
		{
		case 1:
			obj.style.fontSize="12px";
			break;
		case 2:
			obj.style.fontSize="14px";
			break;
		case 3:
			obj.style.fontSize="16px";
			break;
		}
	}
	
	
function voteOver(obj)
	{
	var i, obj2, idx=obj.id.substr(4);
	
	for(i=1; obj2=document.getElementById("vote"+i); i++)
		obj2.src=(i<=idx ? picturePath+"starSelected.png" : voteSrcPictures[i]);
	}
	
	
function voteOut(obj)
	{
	var i;
	
	for(i=1; obj=document.getElementById("vote"+i); i++)
		obj.src=voteSrcPictures[i];
	}
	

function initPage()
	{
	var i, obj;
	
	swfobject.embedSWF("Skins/pl/photos/showGallery.swf","showGalleryEmbed",600,600,currFlashPluginVersion,"/common/expressInstall.swf",{docId:documentId},{quality:"high",wmode:"transparent",menu:"false"},{id:"showGalleryFlash"});
	
	obj=document.getElementById("zasobyEmbed");
	if (obj)
		{
		obj.innerHTML='<div id="zasoby1Embed"></div><div id="zasoby2Embed"></div>';
		swfobject.embedSWF("Skins/pl/photos/zasoby.swf","zasoby1Embed",310,330,currFlashPluginVersion,"/common/expressInstall.swf",false,{quality:"high",wmode:"opaque",menu:"false"},{id:"zasoby1Flash"});
		swfobject.embedSWF("Skins/pl/photos/zasobyEtno.swf","zasoby2Embed",310,330,currFlashPluginVersion,"/common/expressInstall.swf",false,{quality:"high",wmode:"opaque",menu:"false"},{id:"zasoby2Flash"});
		}
	
	if (document.getElementById("playerEmbed"))
		swfobject.embedSWF("Skins/pl/photos/player.swf","playerEmbed",340,255,currFlashPluginVersion,"/common/expressInstall.swf",{docId:documentId},{quality:"high",wmode:"opaque",menu:"false"},{id:"playerFlash"});
	
	if (document.getElementById("audioPlayerEmbed"))
		swfobject.embedSWF("Skins/pl/photos/playerMP3.swf","audioPlayerEmbed",340,255,currFlashPluginVersion,"/common/expressInstall.swf",{docId:documentId},{quality:"high",wmode:"opaque",menu:"false"},{id:"audioPlayerFlash"});
	
	for(i=1; obj=document.getElementById("vote"+i); i++)
		{
		if (i==1)
			{
			picturePath=obj.src.split("/");
			picturePath.pop();
			picturePath=picturePath.join("/")+"/";
			}
		obj.onmouseover=function () {voteOver(this);};	
		obj.onmouseout=function () {voteOut(this);};	
		voteSrcPictures[i]=obj.src;
		}
			
	
	updateMediaForm();
	}
	

window.onload=init;
initClassObj.registerFunction(initPage);
