var iScrollLeft = document.body.scrollLeft;
var iClientWidth = document.body.clientWidth;
var iWidthOffset = 1024;

/************************************
//Öğeerin dizideki indeksi
*************************************/
iApMenuTop = 0
iApMenuLeft = 1
iApMenuWidth = 2
iApMenuNormalTxtColor = 3
iApMenuOnMouseOverBgColor = 4
iApMenuOnMouseOverTxtColor = 5

iLAST_CONFIGURATION_VALUE_INDEX = 5
/************************************/
sMenuBodyBorderColor = '#CCCCCC';
sMenuBodyBorderStyle = 'outset';
MenuBorderWidth = 1;
sMenuBodyBackgroundColor = '';
sMenuBodyBackgroundImage = 'images/TransparentBg.png'
iMenuLineHeight = 20;
TimeOutValue = 500;
timeOutTimerID = 0;
iMenuLinkMarginLeftRight = 5

var sMenu1 = Array(240, 315, 200, '#FFFFFF', '#999999', '#FFFFFF', 
				   	'Mobil Mini Onarım Hizmeti', 'genel.asp?Page=TW9iaWxNaW5pT25hcmltSGl6bWV0aS5hc3A',
					'Su ve Yangın Hasarları Acil Müdahalesi ve Restorasyonu', 'genel.asp?Page=U3VWZVlhbmdpbkhhc2FybGFyaUFjaWxNdWRhaGFsZXNpVmVSZXN0b3Jhc3lvbnUuYXNw');

function refreshWindowInfo() {
		var iScrolLeft = document.body.scrollLeft;
		var iScrolWidth = document.body.scrollWidth;
		var iPageWidth = 750
		var iMenuLeft = (iScrolWidth - iPageWidth) / 2
	
		var objMenu = document.getElementById("MainMenu");
		var objDuyuru = document.getElementById("objDuyuru");
		with (objMenu.style) {
			position='absolute';
			top = 170;
			left = iMenuLeft;
		}
		
		with (objDuyuru.style) {
			position='absolute'	
			top=230;
			left=(iMenuLeft + iPageWidth) - 220;
		
		}
		
	}


//Menü gövdesi
function CreateMenuBody(sID, iTop, iLeft, iWidth, sBorderColor, sBgColor, sBgImage) {
	var obj = document.createElement("div");
	with (obj) {
		if (sID) {id=sID} else {id=''};
		if (iTop) {style.top = iTop} else {style.top = 0};
		if (iLeft) {style.left = (iLeft / iWidthOffset) * (iScrollLeft + iClientWidth)} else {style.left = 0};

		if (iWidth) {style.width = iWidth}  else {style.width = 0};
		style.position='absolute';
		style.borderWidth = MenuBorderWidth;
		style.borderStyle = sMenuBodyBorderStyle;
		if (sBorderColor) {style.borderColor=sBorderColor} ;
		if (sBgColor) {style.backgroundColor=sBgColor}; 
//		if (sBgImage) {style.backgroundImage='url(' + sBgImage + ')'};
//		style.cssText="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + sBgImage + "',sizingMethod='scale'); "
		style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + sBgImage + "', sizingMethod='scale')";
		onmouseover = function() {cancelTimeOutTimer();}
		onmouseout = function() {setCloseTimer(sID);}
	};
	
	return obj;
};
	
//Menü öğeleri
function MakeMenuItems(sMenu) {
	var sArrMenu = eval(sMenu);
	var sObjBodyName = 'obj' + sMenu.substr(1, sMenu.length-1);
	var i=iLAST_CONFIGURATION_VALUE_INDEX+1;
	var obj = document.createElement("ul");
	
	with (obj.style) {
		listStyleType='none';
		lineHeight = iMenuLineHeight + 'px';
		margin=5;
		}
	
	while(i<sArrMenu.length) {
		var oLi = document.createElement("li");		//List Item
		var oLink = document.createElement("a"); //link
		var sText = document.createTextNode(sArrMenu[i]);
		
		oLink.appendChild(sText);	//Link text
		oLink.href = sArrMenu[i+1];	//link yolu
		oLink.className = 'Arial_11';		
		
		with (oLink.style) {
				marginLeft = iMenuLinkMarginLeftRight;
				marginRight = iMenuLinkMarginLeftRight;
				color = sArrMenu[iApMenuNormalTxtColor];
			}
		
		oLi.onmouseover = function() {
								this.style.backgroundColor = sArrMenu[iApMenuOnMouseOverBgColor];		//Mouse link üstüne geldiğinde satırı renklendir.
								this.childNodes[0].style.color = sArrMenu[iApMenuOnMouseOverTxtColor];
							};
		oLi.onmouseout = function() {
								this.style.backgroundColor = ''//sArrMenu[iApMenuNormalBgColor];			//mouse ayrıldığında satırı normal renge dönüştür.
								this.childNodes[0].style.color = sArrMenu[iApMenuNormalTxtColor];
							};
		
		with (oLi.style) {
			backgroundColor = ''//sArrMenu[iApMenuNormalBgColor];	//Satırın normal arka plan rengi
			width = sArrMenu[iApMenuWidth];
			borderBottomStyle='solid';
			borderBottomColor = '#CCCCCC';
			borderBottomWidth = 1;
			};
		oLi.appendChild(oLink);
		obj.appendChild(oLi);
		i=i+2;
	};
	return obj;
};

function killMenu(sMenuID) {
		var obj = document.getElementById(sMenuID)
		obj.parentNode.removeChild(obj);
	}

function cancelTimeOutTimer() {
//	if (timeOutTimerID) {window.clearTimeout(timeOutTimerID)};
	if (timeOutTimerID) {
			window.clearTimeout(timeOutTimerID);
			timeOutTimerID = null;
		}
};

function setCloseTimer(sID) {
	//timeOutTimerID = window.setTimeout(sID + ".parentNode.removeChild(objDiv);timeOutTimerID=0", TimeOutValue);
	timeOutTimerID = window.setTimeout("killMenu('" + sID + "')", TimeOutValue);
}


function showMenu(sMenuID) {
	cancelTimeOutTimer();
	
	var sMenuArr = eval(sMenuID);
	var iMenuTop = sMenuArr[iApMenuTop];
	var iMenuLeft = sMenuArr[iApMenuLeft];
	var iMenuWidth = sMenuArr[iApMenuWidth];
	var sObjBodyName = 'obj' + sMenuID.substr(1, sMenuID.length-1);
	
	if (!document.getElementById(sObjBodyName)) {
		var objMenuBody = CreateMenuBody(sObjBodyName, iMenuTop, iMenuLeft, iMenuWidth, sMenuBodyBorderColor, sMenuBodyBackgroundColor, sMenuBodyBackgroundImage);
		var objMenuItems = MakeMenuItems(sMenuID)
		
		objMenuBody.appendChild(objMenuItems);
		document.body.appendChild(objMenuBody);
	}
};

function hideMenu(sMenuID) {
	var sObjName = 'obj' + sMenuID.substr(1, sMenuID.length-1);
	setCloseTimer(sObjName);
	
};
