// <SCRIPT language="Javascript">
// FCM Start
// File: default.js
// Description: Various client side javascript functions
//
// Date		Who	Audit	Ver	Comments
// 20020301	BM	ISxxxx	0.01	Created
// 20020320	ARU	ISxxxx	0.02	Added function OpenWin()
// 20020404	AJC	ISxxxx	0.03	Added function addToFavorites()
//								try is not recongised by NS4
// FCM End

//sniffer
w3c	= ( document.getElementById	) ? 1 : 0;
ie	= ( document.all	&& !w3c ) ? 1 : 0;	//meaning ie4
ns	= ( document.layers	&& !w3c ) ? 1 : 0;	//meaning ns4

agt	= navigator.userAgent.toLowerCase();
win	= ( agt.indexOf( 'win' ) != -1 ) ? 1 : 0;
mac	= ( agt.indexOf( 'mac' ) != -1 ) ? 1 : 0;


var cacheBuster = (new Date()).valueOf();


//frames
if( location.href != top.location.href )
	{
//	top.location.href = "../";
	}
	
//gallery popups
viewimgnum = 0;
function viewimage1( url )
	{
	top.focus();
	window.open( url
		, "viewport" + viewimgnum
		, "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=550,height=460"
		);
	viewimgnum++;
	}

function viewimage2( url )
	{
	top.focus();
	window.open( url
		, "viewport" + viewimgnum
		, "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=600,height=450"
		);
	viewimgnum++;
	}

// Andrew Urquhart 2002-03-20
// Example use: (change all 4 parameters!)
// <a href="someFile.asp" target="_blank" onclick="OpenWin('someFile.asp', 'windowName', 640, 480); return false;" title="A text description of link">Open window</a>
function OpenWin( url, windowName, width, height )
	{
	if( url )
		{
		window.open( url
			, windowName
			, "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height
			);
		}
	else
		status = "Unable to open pop-up window " + url;
	return( false );
	}

//print version popup
function showPrintVersion( url )
	{
	top.focus();
	window.open( url
		, "printwin"
		, "toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=570,height=460"
		);
	}

var navFlip = new Object();

navFlip.subSections	= [
	  "multi"
	, "sony"
	, "xbox"
	, "nintendo"
	, "pc"
	];

navFlip.sections	= [
	  "headlines"
	, "news"
	, "reviews"
	, "previews"
	, "tips"
	, "downloads"
	, "specials"
	];

navFlip.directory	= "/images/nav/";
navFlip.imageCache	= new Array();
navFlip.cacheImages	= function()
	{
	var arrayIndex = 0;
	var subsectionDirectory = navFlip.directory + subsection;

	// Cache images for the top of the nav
	for( var i = 0 ; i < navFlip.subSections.length ; i++ )
		{
		if( navFlip.subSections[ i ] != subsection )
			{
			var src = navFlip.directory + navFlip.subSections[ i ] + "/hover.gif";
			navFlip.imageCache[ arrayIndex ] = new Image();
			navFlip.imageCache[ arrayIndex++ ].src = src;
			}
		}

	// Cache images for the bottom of the nav
	for( var i = 0 ; i < navFlip.sections.length ; i++ )
		{
		if( navFlip.sections[ i ] != section )
			{
			var src = navFlip.directory + subsection + "/sections/" + navFlip.sections[ i ] + ".gif";
			navFlip.imageCache[ arrayIndex ] = new Image();
			navFlip.imageCache[ arrayIndex++ ].src = src;
			}
		}

	// Keep NS6 and Opera happy
	// cache the default section images (which should already be cached as they are origionaly on the screen)
	for( var i = 0 ; i < navFlip.sections.length ; i++ )
		{
		if( navFlip.sections[ i ] != section )
			{
			var src = navFlip.directory + "sections/" + navFlip.sections[ i ] + ".gif";
			navFlip.imageCache[ arrayIndex ] = new Image ();
			navFlip.imageCache[ arrayIndex++ ].src = src;
			}
		}
	}

navFlip.getInfo = function()
	{
	var str = "navFlip.imageCache:\n";
	for( var i = 0 ; i < navFlip.imageCache.length ; i++)
		{
		str += "\n" + i + " : " + navFlip.imageCache[ i ].src;
		}
	return( str );
	}

navFlip.flipSection = function( name, state )
	{
	if( section == name )
		{
		return;
		}
	var img = document.images[ name ];
	if( state && img )
		{
		img.src = navFlip.directory + subsection + "/sections/" + name + ".gif";
		}
	if( !state && img )
		{
		img.src = navFlip.directory + "sections/" + name + ".gif";
		}
	}

navFlip.flipSubSection = function( name, state )
	{
	if( subsection == name )
		{
		return;
		}
	var img = document.images[name];
	if( state && img )
		{
		img.src = navFlip.directory + name + "/hover.gif";
		}
	if( !state && img )
		{
		img.src = navFlip.directory + name + "/default.gif";
		}
	}

function initialise()
	{
	navFlip.cacheImages();
	if( window.thisPageHasTicker )
		{
		initTicker();
		}
	//alert( navFlip.getInfo() ) //Remove to see what's being cached
	// readParams();
	// MSN Versione IFRAME
 //	window.parent.document.getElementById("radarframe").style.height=document.body.scrollHeight;
	}

function emailfriend()
	{
	url='/inc/emailfriend.asp?ref=' + escape(document.location);
	window.open(url
		,'emailfriend'
		,'width=200,height=250,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no'
		);
	}

function fnSet()
	{ 
	oHomePage.setHomePage( 'http://www.gamesradar.it' );
	event.returnValue = false;
	}

function openWindow( url )
	{
  	popupWin = window.open( url
		, 'remote'
		, 'location=no,scrollbars=yes,width=570,height=550,left=0,top=0'
		);
	}

function openPopup( url )
	{
	popupWin2 = window.open( url
		, 'remote'
		, 'location=no,scrollbars=yes,width=250,height=300,left=0,top=0'
		);
	}

function JumpList( obj )
	{
        i = obj.selectedIndex;
        obj.selectedIndex = 0;
        if( obj.options[ i ].value != "-" )
		{
                window.location.href = "" + obj.options[ i ].value;
		}
	}

function toPage( url )
	{
	window.location.href = url;
	}

// V0.03 Start
// Andrew Urquhart looked at the Mac platform error but was unable to provide a script solution: 2002-04-17 18:00
function addToFavorites( urlAddress, pageName ) {
	if (window.external) {
		window.external.AddFavorite( urlAddress, pageName );
	}
	else {
		alert( "Sorry! Your browser doesn't support this function." );
	}
}
// V0.03 End

//eyeblaster ad code
function readParams()
	{
	var szSrc = "http://www.eyeblaster-ds.com/BurstingScript/ReadParametersPipe.asp";
	
// V0.03 Start
	if( parent && parent.parent && parent.parent.location )
		{
		szSrc += "?pageLocation=" + escape( parent.parent.location );
		}
	else
		{
		szSrc += "?pageLocation=invalid";
		}
		
//	try
//		{
//		szSrc = szSrc + "?pageLocation=" + escape(parent.parent.location);
//		}
//	catch( e ) 
//		{
//		szSrc = szSrc + "?pageLocation=invalid";
//		}
// V0.03 End

	var newTag = document.createElement( "script" );
	newTag.id = "readParametersPipe";
	newTag.src = szSrc;

	document.body.appendChild( newTag );
	}

if( document.layers )
	{
	widthCheck = window.innerWidth;
	heightCheck = window.innerHeight;
	window.captureEvents( Event.RESIZE );
	window.onresize = function()
		{
		if( widthCheck != window.innerWidth || heightCheck != window.innerHeight )
			document.location.reload();
		}
	}

// end of text
// </SCRIPT>