var ie=document.all;
var dom=document.getElementById;
var wbtv=navigator.appName.indexOf("WebTV")!=-1;
var mac=navigator.appVersion.indexOf("Mac")!=-1;

// var imghost = 'http://ols.loopy.net';
var plusimg = new Image;
plusimg.src = '/static/images/base/plus.gif';
plusimg.title = 'Remove';
var minusimg = new Image;
minusimg.src = '/static/images/base/minus.gif';
minusimg.title = 'Add';
var numcount = 0;
var tabCurrent = '';
var moSweepdiv = 0;
var baseUrl = '';


var tabMouseOut = function(oEvent) {
	if (tabCurrent!=tabDefault) {
		moSweepdiv = 1;
		var to = setTimeout('hideTab()', 3000);
	}
}

var cancelMO = function() {
	moSweepdiv = 0;
}

function hideTab() {
	if (moSweepdiv&&tabCurrent!=tabDefault) {
		document.getElementById('sweep').onmouseover = '';
		document.getElementById(tabDefault).className = 'current';
		document.getElementById(tabDefault + '2').className = 'current';
		document.getElementById(tabCurrent).className = '';
		document.getElementById(tabCurrent + '2').className = '';
		tabCurrent = tabDefault;
		moSweepdiv = 0;
	}
}

var tabHandler = function(oEvent) {
	var thisEvent = (oEvent||window.event);
	if (thisEvent.type=='click') {
		document.getElementById('sweep').onmouseover = '';
		if (this.id=='tabOptions') { return false; }
		tabDefault = this.id;
	}
	else if (this.id!=tabCurrent) {
		document.getElementById('sweep').onmouseover = tabMouseOut;
		document.getElementById(tabCurrent).className = '';
		document.getElementById(tabCurrent + '2').className = '';
		document.getElementById(this.id + '2').className = 'current';
		this.className = 'current';
		tabCurrent = this.id;
	}
}

/*
var tab2Handler = function(oEvent) {
	if (!this.id) { return false; }
	var thisEvent = (oEvent||window.event);
	var tab2 = document.getElementById(this.id);
	if (thisEvent.type=='mouseover'&&tab2Default!=''&&this.id!=tab2Default) {
		document.getElementById(tab2Default).className = '';
	}
	else if (thisEvent.type=='mouseout'&&this.id!=tab2Default) {
		if (tab2Default!='') { document.getElementById(tab2Default).className = 'currenttab'; }
		tab2.className = '';
	}
	else if (thisEvent.type=='click') {
		document.getElementById('sweep').onmouseover = '';
		tab2.onmouseout = '';
		document.getElementById(tabCurrent + '2').className = 'current';
		tab2.className = 'currenttab';
		tab2Default = this.id;
	}
}
*/

var pageInit = function() {
	if (document.all||document.getElementById) {
		tabCurrent = tabDefault;
		var tabs = document.getElementById('tabs');
		for (i=0; i<tabs.childNodes.length; i++) {
			var node = tabs.childNodes[i];
			if (node.nodeName=='LI'&&node.className!='tab_disabled') {
				node.onmouseover=node.onclick=tabHandler;
			}
		}
/*
		var tabs2 = document.getElementById('tabs2');
		for (i=0; i<tabs2.childNodes.length; i++) {
			node = tabs2.childNodes[i];
			for (h=0; h<node.childNodes.length; h++) {
				var subnode = node.childNodes[h];
				if (subnode.nodeName=='LI') {
					subnode.onmouseover=subnode.onmouseout=subnode.onclick=tab2Handler;
				}
			}
		}
*/
		document.getElementById('topdiv').onmouseover = cancelMO;
	}
}


function womInit(){
	window.onload = womRun;
}
function womRun(){  
	for(var i = 0;i < wom.length;i++)
	    eval(wom[i]);
}
function womAdd(func){
	wom[wom.length] = func;
}

var wom = new Array();

if (typeof notabs=='undefined') { womAdd('pageInit()'); }
womInit();


// window.onload = (typeof notabs!='undefined') ? '' : pageinit;


function createNavbar(thisurl,pages,thispage,fromsearch) {
if (pages > 1) {
	baseUrl = thisurl;
	var searchbit = (typeof fromsearch!='undefined') ? fromsearch : '';
	document.write('<span id="nav"><form>Page ');

	if (thispage > 1) {
		var thisnum = (thispage==2) ? '' : (thispage-1); 
		document.write('<span class="pnav1"><a href="' + thisurl + '"><img src="/static/images/base/page_first.gif" width="26" height="16" border="0" title="First Page" /></a></span>');
		document.write('<span class="pnav2"><a href="' + thisurl + searchbit + thisnum + '"><img src="/static/images/base/page_previous.gif" width="26" height="16" border="0" title="Previous Page" /></a></span>');
	}

	document.write('<select name="navmenu" class="text" onchange="goNav(this,\''+thisurl+'\',\''+searchbit+'\')">');
	for (i=1; i<=pages; i++) {
		tmp = (i!=thispage) ? '' : ' selected="selected"';
		document.write('<option'+tmp+'>'+i+'</option>');
	}
	document.write('</select>');

	if (thispage < pages) {
		document.write('<span class="pnav2"><a href="' + thisurl + searchbit + (thispage+1) + '"><img src="/static/images/base/page_next.gif" width="26" height="16" border="0" title="Next Page" /></a></span>');
		document.write('<span class="pnav1"><a href="' + thisurl + searchbit + pages + '"><img src="/static/images/base/page_last.gif" width="26" height="16" border="0" title="Last Page" /></a></span>');
	}
	document.write(' of <strong>'+pages+'</strong></form></span>');
}
}

function navbar2() {
	document.write(findObj('nav').innerHTML);
}

function goNav(thisform,thisurl,fromsearch) {
	var tmp = thisform.options[thisform.selectedIndex].text;
	var tmpurl = (typeof fromsearch!='undefined') ? thisurl + fromsearch : thisurl;
	var gourl = (tmp>1) ? tmpurl + tmp : thisurl;
	if (gourl!='') { self.location.href = gourl; }
}




/**
* Confirms log-out request
*
* @param	string	Log-out confirmation message
*
* @return	boolean
*/
function log_out(confirmation_message)
{
	var ht = document.getElementsByTagName("html")[0];
	ht.style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
	if (confirm(confirmation_message))
	{
		return true;
	}
	else
	{
		ht.style.filter = "";
		return false;
	}
}


// Main Cookie Functions.

function setCookie(name, value, days) {
	var expires = '';
	if (typeof days!='undefined') {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires = "; expires="+date.toGMTString();
	}
	document.cookie = name + '=' + escape(value) + expires + '; path=/;';
}

function getCookie(name) {
	var cname = name + "=";               
	var dc = document.cookie;             
	if (dc.length > 0) {              
		begin = dc.indexOf(cname);
		if (begin != -1) {           
			begin += cname.length;
			end = dc.indexOf(";", begin);
			if (end == -1) end = dc.length;
			return unescape(dc.substring(begin, end));
		} 
	}
	return null;
}

function delCookie(name) {
	document.cookie = name + "=; expires=Fri, 28 Mar 1998 02:47:11 UTC; path=/";
	if (getCookie(name)) { document.cookie = name + "=; expires=Fri, 28 Mar 1998 02:47:11 UTC; path=/; domain=.online-sweepstakes.com"; }
	if (getCookie(name)) { document.cookie = name + "=; expires=Fri, 28 Mar 1998 02:47:11 UTC; path=/; domain=.4ols.com"; }
}

// Miscellaneous Functions.

function notEmpty(value) { return (value != null && value.length != 0); }

function changeSort(thisform) {
	var thiscookie = (self.location.href.indexOf('top100')!=-1) ? 'topsort' : 'sort';
	if (notEmpty(thiscookie,thisform.options[thisform.selectedIndex].value))
	{ 
		setCookie(thiscookie,thisform.options[thisform.selectedIndex].value);
		setCookie('pg',1);
		self.location.href = baseUrl;
		//self.location.reload();
	}
	else { return false; }
}

function changeDisplay(thisform) {
	setCookie('dsply',thisform.options[thisform.selectedIndex].value);
	setCookie('pg',1);
	self.location.href = baseUrl;
	//self.location.reload();
}

function goThere(thisform) {
	var gourl = thisform.options[thisform.selectedIndex].value;
	if (gourl!='') { self.location.href = gourl; }
}

function doSearch(thisform) {
	var loc,newwin;
	var query = escape(thisform.query.value);
	var dothis = thisform.db.options[thisform.db.selectedIndex].value;
	if ((dothis==""||dothis=="expired"||dothis=="mysweeps"||dothis=="expiredmysweeps")&&thisform.date)  { thisform.date.value = ''; }
	if (query!='') {
		if (typeof thisform.nwin!='undefined') { newwin = (thisform.nwin.checked) ? true : false; }
		else { newwin = false; }
		if (dothis=='f') { loc = '/forums/search.php?do=process&query=' + query; }
		else if (dothis=='f2') { loc = '/search.php?do=process&query=' + query; }
		else if (dothis=='g') { loc = 'http://www.google.com/search?q=' + query; }
		else if (dothis=='gn') { loc = 'http://news.google.com/news?q=' + query; }
		else if (dothis=='d') { loc = 'http://dictionary.reference.com/search?q=' + query; }
		else if (dothis=='w') { loc = 'http://en.wikipedia.org/wiki/Special:Search?search=' + query; }
		else if (dothis=='y') { loc = 'http://search.yahoo.com/search?p=' + query; }
		else if (dothis=='m') { loc = 'http://search.msn.com/results.aspx?q=' + query; }
		else if (dothis=='i') { loc = 'http://www.imdb.com/find?q=' + query; }
		else {
			if (newwin) { thisform.target = '_blank'; }
			else { thisform.target = ''; }
			thisform.submit();
//		if (newwin) { thisform.target = "_blank"; thisform.nwin.checked=true; }
			return false;
		}
		if (newwin) { window.open(loc); }
		else { self.location.href = loc; }
	}
	return false;
}

function checkNWin(thisform) {
	var dothis = thisform.db.options[thisform.db.selectedIndex].value;
	if (self.location.href.indexOf('forums')!=-1) { 
		if (dothis!='f') { thisform.nwin.checked = true; }
	}
	else if (dothis!=''&&dothis.length<3) { thisform.nwin.checked = true; }
	return false;
}

var br=0,fu=self.location.href;

function clearFrame (frameID,closeID) {
	var theframe = document.getElementById(frameID);
	var theclose = document.getElementById(closeID);
	theframe.src = "";
	theframe.className = "hideme";
	theclose.style.display = "none";
}


function loadFrame (page,linkID,expired){
	var bckgrd = (typeof nohlt!='undefined') ? '&bckgrd=1' : '';
	var loc = (expired) ? '/' + page + '.php?db=expired&ID=' + linkID + bckgrd : '/' + page + '.php?ID=' + linkID + bckgrd; 
	if (typeof olshomeurl!='undefined') { loc = olshomeurl + loc; }
	if (dom&&!wbtv) {
		var frameID = 'main' + linkID;
		var closeID = 'mclose' + linkID;
		var theframe = document.getElementById(frameID);
		var theclose = document.getElementById(closeID);
		theframe.src=loc;
		theclose.innerHTML = '<a href="javascript:{}" class="close" onclick="clearFrame(\''+frameID+'\',\''+closeID+'\');return false;">[close]</a> &nbsp; ';
		theclose.style.display = 'block';
		// if (typeof nohlt=='undefined'&&page!='rules') { theframe.style.border = '1px solid transparent'; }
		// theframe.className = (user>0) ? page : 'login';
		if (typeof guest=='undefined') {
			if (page!='rules') { theframe.style.border = '1px solid transparent'; }
			else if (page=='rules') { theframe.style.border = '1px solid #999'; }
			theframe.className = page;
		}
		else {
			theframe.style.border = '1px solid transparent';
			theframe.className = 'login';
		}
		return false;
	}
	else if (wbtv) { self.location.href = loc + '&popup=1'; }
	else {
		var hght,wdth;
		loc = loc + '&popup=1';
		if (page=="rules") { hght=400; wdth=620; }
		else if (page=="notes") { hght=400; wdth=620; }
		else { hght=300; wdth=520; }
		window.open(loc,'os'+page,'toolbar=no,menubar=no,location=no,directories=no,status=no,scrollbars=yes,resizeable=yes,height='+hght+',width='+wdth,top=100,left=100);
	}
}	

function findObj(el){if(document.getElementById){m=document.getElementById(el)}else if(document.all){m=document.all[el]}else if(document.layers){m=document[el]}return m;}function ee(){if(br>0)setCookie('fubr',fu+'@'+br);}function my(){br+=1;}
