
function getDHTMLObj(objName)
{
	if (document.getElementById)
		return document.getElementById(objName);
	else if (document.all)
		return document.all[objName];
	else if (document.layers)
		return document.layers[objName];
	else
		return null;
} 

function cacheImages()
{
	var i;
	
	var oImages = new Array(document.images.length);			//array of image objects
	//reset all rollover images to their "off" state
	for (i=0; i<document.images.length; i++)
	{
		if ( document.images[i].src.search(/\_off\.(gif|jpg)/) > 0 )
		{	
			oImages[i] = new Image();
			oImages[i].src = document.images[i].src.replace("_off.", "_on.");
		}
	}
	return;
}

function setImage(oImage)
{

	var i;

	//first reset all rollover images to their "off" state
	for (i=0; i<document.images.length; i++)
	{
		if ( document.images[i].src.search(/\_on\.(gif|jpg)/) )
			document.images[i].src.replace("_on.", "_off.");
	}
	
	//now set the image to be in the "on" state		
	eval(oImage).src = eval(oImage).src.replace("_off.", "_on.");
				
	return;
}

function clearImages()
{
	var i;
	
	//reset all rollover images to their "off" state
	for (i=0; i<document.images.length; i++)
	{
		if ( document.images[i].src.search(/\_on\.(gif|jpg)/) > 0 )
			document.images[i].src = document.images[i].src.replace("_on.", "_off.");
	}
	return;
}

function openWindow(url, name, width, height, resize, scroll, center)
{
	var sParams = '';
	name = (name == null) ? '' : name;

	sParams += 'width=' + width;
	sParams += ',height=' + height;
	sParams += (resize || resize == 'true') ? ',resizable=yes' : ',resizable=no';
	sParams += (scroll || scroll == 'true') ? ',scrollbars=yes' : ',scrollbars=no';
	sParams += (center || center == 'true') ? ',left=' + ((screen.width - width) / 2) : '';
	sParams += (center || center == 'true') ? ',top=' + ((screen.height - height) / 2) : '';

	window.name = 'opener';
	var popupWin = window.open(url, name, sParams);
	popupWin.focus();
	return;
}

// PRELOADING IMAGES
if (document.images) {
 img_ah =new Image();  img_ah.src ="/images/maptest_ah.jpg"; 
 img_dp =new Image();  img_dp.src ="/images/maptest_dp.jpg"; 
 img_im =new Image();  img_im.src ="/images/maptest_im.jpg"; 
 img_ps =new Image();  img_ps.src ="/images/maptest_ps.jpg"; 
 img_oz =new Image();  img_oz.src ="/images/maptest_oz.jpg"; 
 img_zh =new Image();  img_zh.src ="/images/maptest_zh.jpg"; 
 img_off=new Image();  img_off.src="/images/maptest_main.jpg"; 
}

function rollAH() { 
 if (document.images) document.imgName.src=img_ah.src;
}

function rollDP() { 
 if (document.images) document.imgName.src=img_dp.src;
}

function rollIM() { 
 if (document.images) document.imgName.src=img_im.src;
}

function rollOZ() { 
 if (document.images) document.imgName.src=img_oz.src;
}

function rollPS() { 
 if (document.images) document.imgName.src=img_ps.src;
}

function rollZH() { 
 if (document.images) document.imgName.src=img_zh.src;
}

function rollMain() {
 if (document.images) document.imgName.src=img_off.src;
}

function OpenContestRules()
{
	window.open('/Contest/ContestRules.aspx','ContestRules','scrollbars=yes,status=no,width=500,height=500')
}

function OpenWiiRules()
{
	window.open('/Contest/Wii-Instant-Win-Official-Rules.aspx','WiiInstantWinRules','scrollbars=yes,status=no,width=500,height=500')
}

function OpenSweepstakesRules()
{
	window.open('/Contest/SweepstakesRules.aspx','SweepstakesRules','scrollbars=yes,status=no,width=500,height=500')
}

function OpenPrivacy()
{
	window.open('/Privacy.aspx','Privacy','scrollbars=yes,status=no,width=500,height=500')
}

function OpenConditionsOfUse()
{
	window.open('/ConditionsOfUse.aspx','ConditionsOfUse','scrollbars=yes,status=no,width=500,height=500')
}
function OpenCommercial()
{
	window.open('/flash/tvad/default.aspx','Commercial','scrollbars=no,status=no,width=490,height=370')
}


//-->
//Goes to top of page - (Used for ajax section which cant postback)
function sTop()
{
    window.scroll(0,0);
}


function GetCode()
{
    var txt = document.getElementById('hiddenCode2').Text;
    var tbox = document.getElementById('txtGameCode');
    
    if(tbox)
    {
        tbox.value = txt;
    }
}

function GetCode2()
{
    alert('1');
    var txt = document.getElementById('hiddenCode').Text;
    alert('txt');
    var tbox = document.getElementById('txtGameCode2');
    alert('2');
    if(tbox)
    {
        tbox.value = txt;
    }
}
