function MouseOver(pObj, strBackground)
{
	pObj.style.background = strBackground;
	return true;
}
var aGalleryItems = new Array;
var aGalleryImg = new Array;
var aGalleryExp = new Array;
var nGalleryIndex;
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

nGalleryIndex = 0;

function CGalleryItem(nIndex, strImg, strExplanation, strThumbnailLink)
{
	this.nIndex = nIndex;
	this.strImg = strImg;
	this.strExplanation = strExplanation;
	this.strThumbnailLink = strThumbnailLink;
}

function iecompattest()
{
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function ShowGalleryItem(nIndex)
{
	var strHTML;

	document.getElementById("darkBackgroundLayer").style.display = "";
	document.getElementById("galleryWindow").style.display = "";
	
	document.getElementById("galleryWindow").innerHTML = "";
	strHTML = "<table cellspacing='0' cellpadding='0'><tr><td height='5px' width='5px'></td><td></td><td height='5px' width='5px'></td></tr>";
	strHTML += "<tr><td colspan='2' align='right'><a href='javascript:HideGalleryItem();' class='menu_baslik'>Close</a></td></tr>";
	strHTML += "<tr><td></td><td align='center'><img src='" + aGalleryItems[nIndex].strImg + "'></td><td></td></tr>";
	strHTML += "<tr><td></td><td align='left'></td><td></td></tr>"
	strHTML += "<tr><td></td><td><font class='menu_baslik'>" + aGalleryItems[nIndex].strExplanation + "</font></td><td></td></tr>";
	strHTML += "<tr><td></td><td>";
	if (nIndex > 0)
		strHTML += "<a href='javascript:ShowGalleryItem(" + (nIndex-1) + ");' class='menu_baslik'>< Prev</a>&nbsp;";
	if (nIndex < (aGalleryItems.length - 1))
		strHTML += "<a href='javascript:ShowGalleryItem(" + (nIndex+1) + ");' class='menu_baslik'>Next ></a>&nbsp;";
	strHTML += "</td><td></td></tr>";
	strHTML += "<tr><td height='5px' colspan='3'></td></tr></table>";
	document.getElementById("galleryWindow").innerHTML = strHTML;
	document.getElementById("galleryWindow").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px";
}
function DisablePage()
{
    document.getElementById("transparentBackgroundLayer").style.display = "";
}
function HideGalleryItem()
{
	document.getElementById("darkBackgroundLayer").style.display = "none";
	document.getElementById("galleryWindow").style.display = "none";
}
function GalleryGoRight(nItem)
{
	nGalleryIndex += nItem;
	if (nGalleryIndex > (aGalleryItems.length - 6))
		nGalleryIndex = aGalleryItems.length - nItem;
	GalleryReorganize();
}
function GalleryGoLeft(nItem)
{
	nGalleryIndex -= nItem;
	if (nGalleryIndex < 0)
		nGalleryIndex = 0;
	GalleryReorganize();
}
function GalleryReorganize()
{
	var nIndex, nTemp;
	var strHTML;
	
	nTemp = 0;
	document.getElementById("gallery").innerHTML = "";
	strHTML = "";
	for (nIndex = 0; nIndex < nGalleryIndex; ++nIndex)
		strHTML += aGalleryItems[nIndex].strThumbnailLink;
	strHTML += "<table cellspacing='0' cellpadding='0' border='0'><tr><td width='5px'>&nbsp;</td>";
	for (nIndex = nGalleryIndex; nIndex < aGalleryItems.length && nIndex < (nGalleryIndex + 6); ++nIndex)
	{
		strHTML += "<td>" + aGalleryItems[nIndex].strThumbnailLink + "</td>";
		strHTML += "<td width='8px'>&nbsp;</td>";
	}
	nTemp = nIndex;
	strHTML += "</tr></table>";
	for (nIndex = nIndex; nIndex < aGalleryItems.length; ++nIndex)
		strHTML += aGalleryItems[nIndex].strThumbnailLink;
	document.getElementById("gallery").innerHTML = strHTML;
	
	var strItem;
	for (nIndex = nTemp; nIndex < aGalleryItems.length; ++nIndex)
	{
		strItem = "galleryitem"+nIndex;
		document.getElementById(strItem).style.display = "none";
	}
	for (nIndex = 0; nIndex < nGalleryIndex; ++nIndex)
	{
		strItem = "galleryitem"+nIndex;
		document.getElementById(strItem).style.display = "none";
	}
	
	if (nGalleryIndex == 0)
		document.getElementById("left_arrow").innerHTML = "<img src='images/gallery_left_disabled.gif' border='0'>";
	else
		document.getElementById("left_arrow").innerHTML = "<a href='javascript:GalleryGoLeft(6);'><img src='images/gallery_left_enabled.gif' border='0'></a>";

	if (aGalleryItems.length > nTemp)
		document.getElementById("right_arrow").innerHTML = "<a href='javascript:GalleryGoRight(6);'><img src='images/gallery_right_enabled.gif' border='0'></a>";
	else
		document.getElementById("right_arrow").innerHTML = "<img src='images/gallery_right_disabled.gif' border='0'>";
}
document.onkeyup = function(e) { 	
	if (e == null) 
	{ // ie
		keycode = event.keyCode;
	} 
	else 
	{ // mozilla
		keycode = e.which;
	}
	if(keycode == 27)
	{ // close
		HideGalleryItem();
	}	
};
document.onscroll = function(e){
	if (document.getElementById("galleryWindow"))
		document.getElementById("galleryWindow").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px";
};
