// JavaScript Document
function ShowDiv(Id)
{
	//alert(Id);
	try{
	document.getElementById(Id).style.display = "block";
	}
	catch(e){}
}

function HideDiv(Id)
{
	try{
	document.getElementById(Id).style.display = "none";
	}
	catch(e){}
}

function ShowHideDiv(Id)
{
	if (document.getElementById(Id).style.display == "none")
		document.getElementById(Id).style.display = "block";
	else
		document.getElementById(Id).style.display = "none";
}

function ChangeStyle(Obj,className)
{
	try
	{
		Obj.setAttribute("class",className);
	}
	catch(e){};
	
	try
	{
		Obj.setAttribute("className",className);
	}
	catch(e){}
}

var arrOnLoadFunctions = new Array();
function OnLoad()
{
	//alert(arrOnLoadFunctions.length);
	for (i=0; i < arrOnLoadFunctions.length; i++)
	{
		eval(arrOnLoadFunctions[i]);
	}
}

function ShowPopup(pPage, pId)
{
	var objPopup = document.getElementById("Popup");
	objPopup.style.display = "block";
	objPopup.style.top = document.body.scrollTop;
	window.open("./?page=" + pPage + "&id=" + pId,"PopupFrame");
}

function HidePopup()
{
	window.open("./loading.html","PopupFrame");
	HideDiv("Popup");
}

var TaskBar_TimeOut;

function MoveTaskBar_Start()
{
	var obj = document.getElementById("TaskBar");
	obj.style.display = "block";
	obj.style.bottom = 0;
	TaskBar_TimeOut = setTimeout("MoveTaskBar()",0);
}

function MoveTaskBar()
{
	clearTimeout(TaskBar_TimeOut);
	//Move Task Bar
	var obj = document.getElementById("TaskBar");
	//obj.style.bottom = - document.body.scrollTop;
	obj.style.bottom = parseInt(obj.style.bottom) - Math.round((document.body.scrollTop + parseInt(obj.style.bottom))/2);
	TaskBar_TimeOut = setTimeout("MoveTaskBar()",50);
}

function WindowResize()
{
	//MoveTaskBar();
	
}


	

function openPopup(tPage)
{
	w = 800;
	h = 800;
	if (document.all) {
	   /* the following is only available after onLoad */
	   w = document.body.clientWidth;
	   h = document.body.clientHeight;
	}
	else if (document.layers) {
	   w = window.innerWidth;
	   h = window.innerHeight;
	}
	//---------------
	var src=tPage.split("popup.php?imageName=");
	var newImg = new Image();
	newImg.src = src[1];
	//alert(newImg.width+" "+newImg.height);
	
	if (newImg.width <= w)
	{
		var popW = newImg.width+20;
		var popH = newImg.height+20;
	}
	else
	{
		var popW = (newImg.width+20)/2;
		var popH = (newImg.height+20)/2;
	}
	//---------------
	
	/*var popW =540;
	var popH = 360;*/
	if(popW>20)
	{
		var leftPos = (w-popW)/2;
		var topPos = (h-popH)/2;
		
		var myPage =	tPage + "&imgW=" +  newImg.width;
		popupWindow = window.open(myPage,"popup","status=no, location=no, width=" + popW + ",height=" + popH + ",top=" + topPos + ",left=" + leftPos + ", scrollbars=yes");	
		
		/*if(!popupWindow) 
		{
			alert("no windown");
           	getSwf(swfId).openWindowFromSwf(tPage);
        }*/
		
		if (window.focus) 
			popupWindow.focus();
	}
}

var viewportwidth;
var viewportheight;
var windowHeight;

function getViewPort()
{
	if( typeof( window.innerWidth ) == 'number' ) 
	{
		//Non-IE
		viewportwidth = window.innerWidth;
		viewportheight = window.innerHeight;
		
		windowHeight = window.outerHeight;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
		//IE 6+ in 'standards compliant mode'
		viewportwidth = document.documentElement.clientWidth;
		viewportheight = document.documentElement.clientHeight;
		
		windowHeight = document.documentElement.scrollHeight;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
		//IE 4 compatible
		viewportwidth = document.body.clientWidth;
		viewportheight = document.body.clientHeight;
	
		windowHeight = document.body.scrollHeight;
	}
	//window.alert( 'Width = ' + viewportwidth );
	//window.alert( 'Height = ' + windowHeight );
}


//=========================================================
function createDiv(pXmlSlideShowUrl, pCurrIdPhoto)
{
	
	getViewPort();
	
	var divTag = document.createElement("div");
	
	divTag.id = "divSlideShow";
	
	divTag.setAttribute("align","center");
	
	divTag.style.margin = "0px auto";
	divTag.style.width	=	viewportwidth;
	divTag.style.height	=	windowHeight;
	
	var objectTop	=	(viewportheight - 490 ) /2;
	divTag.className ="dynamicDiv";
	
	divTag.innerHTML = '<div style="padding-top:' + objectTop + '"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="660" height="490" id="slideshow" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="movie" value="flash/slideshow.swf?" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="FlashVars" value="xmlURL=' + pXmlSlideShowUrl +'&currPhoto=' + pCurrIdPhoto + '" /><embed src="flash/slideshow.swf" quality="high" bgcolor="#ffffff"  FlashVars="xmlURL=' + pXmlSlideShowUrl + '&currPhoto=' + pCurrIdPhoto + '" width="660" height="490" name="slideshow" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object></div>';
	
	document.body.appendChild(divTag);
	
	
	var timer = setInterval(animateAlpha,20); // One function which will loop and animate all items - better
}



function closeSlideShow()
{	 
	var divTag	=	document.getElementById("divSlideShow");
	document.body.removeChild(divTag);
}


window.onresize = WindowResize;

arrOnLoadFunctions.push("MoveTaskBar_Start();");
