// Menu:hover with delay
// ---------------------

// This script will enable the :hover for the submenu's within
// the menu's. Besides enabling the :hover it will also set
// a delay on the submenu.

// Credits: Tino Zijdel (crisp), crisp(at)tweakers.net


var menu = null;

function init_menu() {
	menu = document.getElementById('menu');
	var li = menu.getElementsByTagName('li'), i = li.length;
	while (i--) li[i].onmouseover = showMenu;
	menu.onmouseout = timeout;
	menu.onmouseover = cleartimer;
}

var timer = null;
function timeout() {
	timer = setTimeout('hideMenus(menu, null)', 1000);
}

function cleartimer() {
	if (timer) {
		clearTimeout(timer);
		timer = null;
	}
}

function showMenu()	{
	var ul = this.parentNode;
	while (ul) {
		if (ul.tagName.toLowerCase() == 'ul') {
			hideMenus(ul, this);
			break;
		}

		ul = ul.parentNode;
	}

	ul = this.firstChild;
	while (ul) {
		if (ul.nodeType == 1 && ul.tagName.toLowerCase() == 'ul') {
			ul.style.display = 'block';
			ul.style.visibility = ''; // necessary for IE
			break;
		}

		ul = ul.nextSibling;
	}
}

function hideMenus(level, skipli) {
	var stack = [level], i = 0, li, j, el, tag;
	do {
		li = stack[i].childNodes, j = li.length;
		while (j--) {
			el = li[j];
			if (el.nodeType == 1 && el != skipli) {
				tag = el.tagName.toLowerCase();
				if (tag == 'li') {
					stack[i++] = el;
				}
				else if (tag == 'ul' && el.style.display == 'block') {
					stack[i++] = el;
					el.style.display = 'none';
					el.style.visibility = 'hidden'; // necessary for IE
				}
			}
		}
	}
	while (i--);
}

// RANDOM IMAGE SCRIPT //
var theImages = new Array()
theImages[0] = '/templates/akyolfoto/images/header_new1.jpg'
theImages[1] = '/templates/akyolfoto/images/header_new2.jpg'
theImages[2] = '/templates/akyolfoto/images/header_new3.jpg'
theImages[3] = '/templates/akyolfoto/images/header_new4.jpg'
theImages[4] = '/templates/akyolfoto/images/header_new5.jpg'
theImages[5] = '/templates/akyolfoto/images/header_new6.jpg'
theImages[6] = '/templates/akyolfoto/images/header_new7.jpg'
var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'" height="250" width="798" alt="Düz Çit | Bahçe Çitleri & Spor Kompleksleri">');
}
// RANDOM IMAGE SCRIPT //