// browser check

is = new Object()
is.agent = navigator.userAgent.toLowerCase()
is.op = (is.agent.indexOf("opera") != -1)
if (is.op) {
	is.op7 = (is.op && is.agent.indexOf("opera 7") != -1)
	is.op8 = (is.op && is.agent.indexOf("opera 8") != -1)
	is.op9 = (is.op && is.agent.indexOf("opera/9") != -1)
} else {
	is.ie7 = (is.agent.indexOf("msie 7") != -1)
	is.ie6 = (is.agent.indexOf("msie 6") != -1)
	is.ie55 = (is.agent.indexOf("msie 5.5") != -1)
	is.ie5 = (!is.ie55 && is.agent.indexOf("msie 5") != -1)
	is.ns7 = (is.agent.indexOf("netscape/7") != -1)
	is.ns6 = (is.agent.indexOf("netscape/6") != -1)
	is.moz = (!is.ns7 && !is.ns6 && is.agent.indexOf("gecko") != -1)
	is.ffox = (is.agent.indexOf("firefox") != -1)
}
is.ie = (is.ie5 || is.ie55 || is.ie6 || is.ie7)
is.ns = (is.ns6 || is.ns7 || is.moz || is.ffox)
is.dom = (is.ie || is.ns || is.op7 || is.op8 || is.op9)

//window.focus()

/*
if (!is.dom && !is.op) {
	alert("You are not using a standards compliant browser or are using an older browser.\r\nYou may not be able to view ITP.net in it's entirety and will not be able to use certain functions as intended or not at all.\r\n\r\nPlease upgrade you browser to one of the latest versions of either Internet Explorer, Netscape, Mozilla or Opera.")
}
*/

// set cell bg

function setBoxTitleBg() {
	for(i = 0; i <= 20; i++) {
		if (document.getElementById("bTitle" + i)) {
			menuItems = document.getElementById("bTitle" + i).getElementsByTagName("TD");
			rowColor = document.getElementById("bTitle" + i).getAttribute("setColor");
			color2 = document.getElementById("bTitle" + i).getAttribute("setColor2")
			color3 = document.getElementById("bTitle" + i).getAttribute("setColor3")
			for(j = 0; j < menuItems.length; j++) {
				if (menuItems.length > 3 && color2) {
					if (j == 3) { j = 4; rowColor = color2; }
					if (j == 7) { j = 8; rowColor = color3; }
				}
				if (rowColor) {
					menuItems[j].style.backgroundColor = rowColor
				} 
				else {
					menuItems[j].style.backgroundColor = "#CC0000";
				}
			}
		}
	}
} 


// menu functions


function menuOn(n,sText) {
	wCell = document.getElementById("mTd" + n);
	wLayer = document.getElementById("mLayer" + n);
	if (wCell) wCell.style.backgroundColor = "#F0F0F0";
	if (wLayer) wLayer.style.visibility = "visible";
/*	if (n >= 6 && n <= 8) {
		document.getElementById('topSearchList').style.visibility = "hidden";
	}
	else {
		document.getElementById('topSearchList').style.visibility = "visible";
	}*/
	if (is.ie) {
		allSelect = document.body.getElementsByTagName("SELECT");
		for(i = 0; i < allSelect.length; i++) {
			allSelect[i].style.visibility = "hidden";
		}
		allObject = document.body.getElementsByTagName("OBJECT");
		for(i = 0; i < allObject.length; i++) {
			allObject[i].style.visibility = "hidden";
		}
	}
	document.getElementById('hider').style.visibility = "visible";
	setStatus(sText);
	for(i = 1; i <= 12; i++) {
		wCell = document.getElementById("mTd" + i);
		wLayer = document.getElementById("mLayer" + i);
		if (i != n) {
			if (wCell) wCell.style.backgroundColor = "#FFFFFF";
			if (wLayer) wLayer.style.visibility = "hidden";
		}
	}
}

function menuOff() {
	for(i = 1; i <= 12; i++) {
		wCell = document.getElementById("mTd" + i);
		wLayer = document.getElementById("mLayer" + i);
		if (wCell) wCell.style.backgroundColor = "#FFFFFF";
		if (wLayer) wLayer.style.visibility = "hidden";
	}
	//document.getElementById('topSearchList').style.visibility = "visible";
	if (is.ie) {
		allSelect = document.body.getElementsByTagName("SELECT");
		for(i = 0; i < allSelect.length; i++) {
			allSelect[i].style.visibility = "visible";
		}
		allObject = document.body.getElementsByTagName("OBJECT");
		for(i = 0; i < allObject.length; i++) {
			allObject[i].style.visibility = "visible";
		}
	}
	document.getElementById('hider').style.visibility = "hidden";
	setStatus( "Time Out Dubai");
}


// set status bar text

window.defaultStatus = "Time Out Dubai";

function setStatus(sText) {
  window.status = sText;
  return true;
}


// cell click function

function cellClick(cLink) {
	self.location.href = cLink;
}


// search 

function setSearch(wForm) {
	//wForm = document.searchForm
	if (wForm.srh.value == '' || wForm.srh.value == 'search') {
		alert('Please enter a valid value in the Search field before clicking GO ')
		wForm.srh.focus()
		return (false)
	}
	else {
		if (wForm.tblsrh.options[wForm.tblsrh.selectedIndex].value == '') {
			wForm.action = "/search/search.php"
			return (true)
		}
		else {
			wForm.action = wForm.tblsrh.options[wForm.tblsrh.selectedIndex].value
			return (true)
		}
	}
}


// date

var d = new Date()
var dyArray=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
var mtArray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
dt = d.getDate()
mn = d.getMinutes()
hr = d.getHours()
dy = d.getDay()
mt = d.getMonth()
yr = d.getFullYear()

function writeDate() {
	document.write(dyArray[dy] + ", " + mtArray[mt] + " " + dt + ", " + yr)
}

function writeYear() {
	if (yr != 2001) y = document.write("-" + yr)
}


// cookie

function cookieMaker(wAd,nameAd,wPath) {
	var cookieChk = 'yes'
	var cmt = mt
	var cdt = dt
	var chr = hr
	var cmn = mn
	if(mt < 10) {
		cmt = '0' + mt
	}
	if(dt < 10) {
		cdt = '0' + dt
	}
	if(hr < 10) {
		chr = '0' + hr
	}
	if(mn < 10) {
		cmn = '0' + mn
	}
	var sp = cmt + cdt + chr + cmn
	var cck = cookieChk
	if(cck == 'yes') {
		document.cookie = 'noAd=blank; path=/' + wPath + ';'
	}
	var ck = document.cookie
	osp = ck.substr(ck.indexOf(nameAd + '_x||') + nameAd.length + 4,ck.indexOf('||y_' + nameAd) - ck.indexOf(nameAd + '_x||') - nameAd.length - 4)
 	if(sp - osp >= minTimeOut && (cck == 'no' || (cck == 'yes' && ck.indexOf('d=bl') > 0)))  {
		d.setTime(d.getTime() + (minTimeOut * 60 * 1000))
		document.cookie = wAd + '=' + nameAd + '_x||' + sp + '||y_' + nameAd + '; path=/' + wPath + '; domain=www.timeoutdubai.com; expires=' + d.toGMTString()
		return true
	}
}


// popup and eyeblaster

function getPopupAd(wPopup){
	setAttr = 'width=' + ppWidth + ',height=' + ppHeight + ',top=' + ppTop + ',left=' + ppLeft
	setAttr += ',titlebar=1,toolbar=0,location=0,menubar=0,scrollbars=0,resizable=0,channelmode=0,directories=0,status=0,maximize=no'
	var ppWin = window.open("", wPopup, setAttr, true)
	ppWin.location = ppURL
	ppWin.focus()
}

function getEyeblasterAd(wLayer) {
	if(is.ie) {
		document.getElementById(wLayer).style.visibility = "visible"
		setTimeout('document.getElementById(\'' + wLayer + '\').style.visibility = "hidden"',maxDisplay * 60 * 1000)
	}
}


// open external sites

function popSite(wPage) {
	openWindow(wPage,600,400,'yes');
}


// window opener

function openWindow(wPage,width,height,resize) {
  window.open(wPage,'window','toolbar=yes,location=no,status=no,menubar=yes,scrollbars=yes,resizable=' + resize + ',channelmode=no,directories=no,width=' + width + ',height=' + height + ',top=10,left=10');
}

function openFilmPicWindow(wPage) {
  picWindow = window.open(wPage,'','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,channelmode=no,directories=no,width=460,height=310,top=' + screen.height/3 + ',left=' + screen.width/3 );
	picWindow.bgcolor = "#000000";
}

function selectOff() {

	if (is.ie) {
		allSelect = document.body.getElementsByTagName("SELECT");
		for(i = 0; i < allSelect.length; i++) {
			allSelect[i].style.visibility = "hidden";
		}
	}
}

function selectOn() {
	if (is.ie) {
		allSelect = document.body.getElementsByTagName("SELECT");
		for(i = 0; i < allSelect.length; i++) {
			allSelect[i].style.visibility = "visible";
		}
	}

}