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
var bShowGalery;

nGalleryIndex = 0;
bShowGalery = false;

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;
	
	bShowGalery = true;

	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></td><td><table cellpadding='0' cellspacing='0' width='100%'><tr><td align='left'>";
	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 align='right'><a href='javascript:HideGalleryItem();' class='menu_baslik'>Close</a></td></tr></table></td><td></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 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 getOffsetTop(oElement) 
{
	var iResult = oElement.offsetTop;
	while (oElement.offsetParent)
	{
		oElement = oElement.offsetParent;
		iResult += oElement.offsetTop;
	}	
	return iResult;
}
function getOffsetLeft(oElement) 
{
	var iResult = oElement.offsetLeft;

	while (oElement.offsetParent)
	{
		oElement = oElement.offsetParent;
		iResult += oElement.offsetLeft;
	}

	return iResult;
}	
function getOffsetRight(oElement) 
{
	var iResult = oElement.offsetLeft + 5 + oElement.width;

	while (oElement.offsetParent)
	{
		oElement = oElement.offsetParent;
		iResult += oElement.offsetLeft;
	}

	return iResult;
}	
function ShowImageWithLink(strImage, pThis, bShowWindow)
{
	var bIE = document.all?true:false
	var strHTML;

	if (bShowWindow)
	{
		document.getElementById("galleryWindow").innerHTML = "";
		
		strHTML = "<img border='0' src='" + strImage + "'>";
		
		document.getElementById("galleryWindow").innerHTML = strHTML;
		document.getElementById("galleryWindow").style.top = getOffsetTop(pThis) + "px";
		document.getElementById("galleryWindow").style.left = getOffsetRight(pThis) + "px";
		
		var objImage;
		
		objImage = new Image();
		objImage.onload = function() {
			var nWndWidth = 0;
			
			document.getElementById("galleryWindow").style.display = "";
			
			if (typeof window.innerWidth != "undefined")
				nWndWidth = window.innerWidth;
			else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
				nWndWidth = document.documentElement.clientWidth;
			else
				nWndWidth = document.getElementsByTagName('body')[0].clientWidth;
			if (nWndWidth < (getOffsetRight(pThis) + this.width))
				document.getElementById("galleryWindow").style.left = (getOffsetLeft(pThis) - this.width - 5) + "px";
		}
		objImage.src = strImage;
		
//		objImage = null;
	}
	else
		document.getElementById("galleryWindow").style.display = "none";
}
function DisablePage()
{
    document.getElementById("transparentBackgroundLayer").style.display = "";
}
function HideGalleryItem()
{
	bShowGalery = false;
	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 (bShowGalery == true && document.getElementById("galleryWindow"))
//		document.getElementById("galleryWindow").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px";
};
function GetWindowRect(objWnd)
{
	var _width = 0, _height = 0, _top = 0, _left = 0;
	
	if (objWnd != null)
	{
		if (typeof objWnd.innerWidth != "undefined")
			_width = objWnd.innerWidth;
		else
			_width = objWnd.clientWidth;
			
		if (typeof objWnd.innerHeight != "undefined")
			_height = objWnd.innerHeight;
		else
			_height = objWnd.clientHeight;
		_top = getOffsetTop(objWnd);
		_left = getOffsetLeft(objWnd);
	}

	return {top:_top,left:_left,width:_width,height:_height};
}
function GetScrollTop() {
	return FilterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function FilterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

