/*	JavaScript Source File
	for http://www.usamega.com
	Authored by Todd Northrop
	E-mail: webmaster (at) usamega (dot) com
	Copyright (c) 2005. All Rights Reserved.
------------------------------------------------------*/

var rootURL = 'http://www.usamega.com/';
var thisURL = unescape(window.location.pathname);
var bRefresh = false;
var _dynArrayID = new Array();
var _dynArrayShow = new Array();
var _dynArrayShowObjs = new Array();
var _dynArrayHideObjs = new Array();
var _dynArrayShowCode = new Array();
var _dynArrayHideCode = new Array();
var ttlJA = "Jackpot Alert";
var tipJA = "Never miss out on a big jackpot again!&nbsp; We'll send you an e-mail when the Mega Millions and/or Powerball jackpot reaches the size you specify.";
var ttlLP = "Lottery Post";
var tipLP = "The #1 lottery community, including forums, news, results, predictions, jackpots, and much more!";
var ttlSearch = "Search";
var tipSearch = "Search for text on USA Mega (not used for searching drawing results).";
var ttlNews = "Archived News";
var tipNews = "See all lottery news posted on USA Mega";
var ttlScams = "Lottery Scams";
var tipScams = "Did you get a letter claiming that you won a big prize?  The Lottery Scams page could prevent you from handing your life savings to a theif.";
var ttlTell = "Tell a Friend";
var tipTell = "Tell a friend about USA Mega";
var ttlMMOnline = "Play Mega Millions Online";
var tipMMOnline = "Betslips.com purchases lottery tickets from a state-licensed lottery retailer on your behalf";
var ttlMMPhone = "Mobile Results";
var tipMMPhone = "Get the Mega Millions lottery results delivered to your cell phone right after each drawing";
var ttlMMResults = "Mega Millions Previous Results";
var tipMMResults = "The entire Mega Millions drawing history, including previous versions of the game";
var ttlMMWays = "Ways to Win Mega Millions";
var tipMMWays = "See all the different match combinations that will produce a Mega Millions winner.";
var ttlMMFAQ = "Mega Millions FAQ";
var tipMMFAQ = "We answer your most frequently asked questions about Mega Millions.";
var ttlMMStats = "Mega Millions Statistics";
var tipMMStats = "View Mega Millions drawing statistics, including sorting and date ranges.";
var ttlMMSR = "Search Past Results";
var tipMMSR = "Search the Mega Millions drawing history for up to five sets of numbers at a time.";
var ttlMMPS = "Mega Millions PowerSearch";
var tipMMPS = "Search the Mega Millions drawing history using our powerful and flexible search engine.";
var ttlMMJA = "Mega Millions Jackpot Analysis";
var tipMMJA = "See what your jackpot prize would actually be after taxes for both the Annuity and Cash options.";
var ttlMMQP = "Mega Millions Quick Picks";
var tipMMQP = "Our web server will generate up to 50 Mega Millions Quick Picks (random-number tickets) for you.";
var ttlMMHow = "How to Play Mega Millions";
var tipMMHow = "Learn how to play Mega Millions.";
var ttlMMWhere = "Where to Play Mega Millions.";
var tipMMWhere = "The twelve Mega Millions states, plus play <strong>online</strong>.";
var ttlPBOnline = "Play Powerball Online";
var tipPBOnline = "Betslips.com purchases lottery tickets from a state-licensed lottery retailer on your behalf";
var ttlPBPhone = "Mobile Results";
var tipPBPhone = "Get the Powerball lottery results delivered to your cell phone right after each drawing";
var ttlPBResults = "Powerball Previous Results";
var tipPBResults = "The entire Powerball drawing history, including previous versions of the game";
var ttlPBWays = "Ways to Win Powerball";
var tipPBWays = "See all the different match combinations that will produce a Powerball winner.";
var ttlPBFAQ = "Powerball FAQ";
var tipPBFAQ = "We answer your most frequently asked questions about Powerball.";
var ttlPBStats = "Powerball Statistics";
var tipPBStats = "View Powerball drawing statistics, including sorting and date ranges.";
var ttlPBSR = "Search Past Results";
var tipPBSR = "Search the Powerball drawing history for up to five sets of numbers at a time.";
var ttlPBPS = "Powerball PowerSearch";
var tipPBPS = "Search the Powerball drawing history using our powerful and flexible search engine.";
var ttlPBJA = "Powerball Jackpot Analysis";
var tipPBJA = "See what your jackpot prize would actually be after taxes for both the Annuity and Cash options.";
var ttlPBQP = "Powerball Quick Picks";
var tipPBQP = "Our web server will generate up to 50 Powerball Quick Picks (random-number tickets) for you.";
var ttlPBHow = "How to Play Powerball";
var tipPBHow = "Learn how to play Powerball.";
var ttlPBWhere = "Where to Play Powerball.";
var tipPBWhere = "The 31 Powerball jurisdictions, plus play <strong>online</strong>.";
var ttlDrawPetition = "Help Eliminate Computerized Drawings";
var tipDrawPetition = "Learn about computerized lottery drawings, and why the lotteries should never have allowed them to exist. Then sign the Petition for True Lottery Drawings to insist that the lotteries get rid of them entirely.";
var ttlMegaplier = "Sign the Megaplier Petition!";
var tipMegaplier = "<strong>Mega Millions players unite!</strong>&nbsp; Do you want to be able to multiply your non-jackpot prizes like Powerball players have been able to do for years?<br><br>Take 30 seconds and sign the petition to add the Megaplier feature to all Mega Millions states.";
var ttlWW = "Win Cash Playing Games!";
var tipWW = "Not a casino! 100% legal!<br><br>We'll give you <strong>$5.00 free credit</strong> to try out our fun games area.<br><br>Hundreds, if not thousands, of people are playing <strong>right now</strong>&nbsp;- play your favorite games head-to-head or in multi-player tournaments and when you win, you win real money!  The more people in a tournament, the more money you can win!";
var ttlAdCell = "Lottery Results on your Cell Phone";
var tipAdCell = "Lottery results delivered straight to your cell phone after each drawing!<br><br>Thanks to this amazing new service, you'll get the latest lottery results delivered to you instantly &mdash; you don't even need a PC.&nbsp; Try it right now, quit whenever you like.";
var ttlNC = "The Northrop Computer Ultimate PC";
var tipNC = "<strong>Compact &amp; Powerful - The Ultimate PC!</strong><br><br>From it's 1/4&quot; thick aluminum construction to it's powerful components, the Northrop Computer Ultimate PC is the best PC you can buy!<br><br>Click over to the Northrop Computer web site to try one of their Ultimate PCs <strong>risk free</strong>.";

function bookmarksite(title, url){
	if (window.sidebar) {
		window.sidebar.addPanel(title, url, "");
	}
	else {
		if (window.opera && window.print) {
			var elem = document.createElement('a');
			elem.setAttribute('href',url);
			elem.setAttribute('title',title);
			elem.setAttribute('rel','sidebar');
			elem.click();
		}
		else {
			if (document.all) {
				window.external.AddFavorite(url, title);
			}
		}
	}
}

function startupTasks() {
	setTimeout("refrsh()", 300*1000);
	// Look for external links
	if (document.getElementsByTagName) {
		var $ae = document.getElementsByTagName("a");
		var $e, $txt;

		for (var i=0; i<$ae.length; i++) {
			$e = $ae[i];

			if ($e.getAttribute("href")) {
				$txt = $e.getAttribute("rel");

				if ($txt == "external")
					$e.target = "_blank";
			}
		}

		var $found = false;
		$ae = document.getElementsByTagName("input");

		for (i=0; i<$ae.length; i++) {
			$e = $ae[i];

			if ($e.className.match(/( |^)(focus)( |$)/)) {
					$e.focus();
					$found = true;
			}
		}

		if (!$found) {
			$ae = document.getElementsByTagName("textarea");

			for (i=0; i<$ae.length; i++) {
				$e = $ae[i];
	
				if ($e.className.match(/( |^)(focus)( |$)/)) {
						$e.focus();
						$found = true;
				}
			}
		}
	}
}

window.onload = startupTasks;

function refrsh() {
	if (bRefresh) {
		window.location.reload(false);
	}
}

function dynCount() {
	return _dynArrayID.length;
}

function dynAdd(id,show,showobjs,hideobjs,showcode,hidecode) {
	var x = _dynArrayID.length;
	_dynArrayID.length = (x + 1);
	_dynArrayShow.length = (x + 1);
	_dynArrayShowObjs.length = (x + 1);
	_dynArrayHideObjs.length = (x + 1);
	_dynArrayShowCode.length = (x + 1);
	_dynArrayHideCode.length = (x + 1);
	_dynArrayID[x] = id;
	_dynArrayShow[x] = show;
	_dynArrayShowObjs[x] = showobjs;
	_dynArrayHideObjs[x] = hideobjs;
	_dynArrayShowCode[x] = showcode;
	_dynArrayHideCode[x] = hidecode;
}

function dynFind(id) {
	var x=0;

	for (i=0; i<dynCount(); i++) {
		if (_dynArrayID[i] == id) {
			x = i;
			i = dynCount();
		}
	}

	return x;
}

function dynTagOpen(id,show,showobjs,hideobjs,showcode,hidecode) {
	dynAdd(id,show,showobjs,hideobjs,showcode,hidecode);

	if (document.layers)
		document.write('<layer id='+id+(show?'':' style=\"display:none\"')+'>');
	else
		document.write('<div id='+id+(show?'':' style=\"display:none\"')+'>');
}

function dynTagClose() {
	if (document.layers)
		document.write('</layer>');
	else
		document.write('</div>');
}

function dynToggle(id) {
	var x = dynFind(id);

	if (_dynArrayShow[x] == true) {
		dynHide(id);

		if (_dynArrayHideObjs[x].length > 0)
			dynShowObjs(_dynArrayHideObjs[x]);

		if (_dynArrayHideCode[x] != '')
			eval(_dynArrayHideCode[x]);

		_dynArrayShow[x] = false;
	}
	else {
		dynShow(id);

		if (_dynArrayShowObjs[x].length > 0)
			dynShowObjs(_dynArrayShowObjs[x]);

		if (_dynArrayShowCode[x] != '')
			eval(_dynArrayShowCode[x]);

		_dynArrayShow[x] = true;
	}
}

function dynShowObjs(ary) {
	var x = ary.length;

	for (var i=0; i<x; i+=2) {
		if (ary[i] == 'show') {
			if (document.layers)
				eval('document.forms[\'frm\'].'+ary[i+1]+'.visibility = \"show\"');
			else if (document.all)
				document.all[ary[i+1]].style.visibility = 'visible';
			else if (document.getElementById)
				document.getElementById(ary[i+1]).style.visibility = 'visible';
		}
		else if (ary[i] == 'hide') {
			if (document.layers)
				eval('document.forms[\'frm\'].'+ary[i+1]+'.visibility = \"hide\"');
			else if (document.all)
				document.all[ary[i+1]].style.visibility = 'hidden';
			else if (document.getElementById)
				document.getElementById(ary[i+1]).style.visibility = 'hidden';
		}
	}
}

function dynShow(id) {
	if (document.layers)
		document.layers[id].display = 'block';
	else if (document.all)
		document.all[id].style.display = 'block';
	else if (document.getElementById)
		document.getElementById(id).style.display = 'block';
}

function dynHide(id) {
	if (document.layers)
		document.layers[id].display = 'none';
	else if (document.all)
		document.all[id].style.display = 'none';
	else if (document.getElementById)
		document.getElementById(id).style.display = 'none';
}

function GoURL(URL) {
	self.location.href = URL;
}

function openWin(theURL,winName,features) {
	window.open(theURL,winName,features)
}

function validEmail(str) {
	var regexp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return regexp.test(str);
}

