/**************************************************************
*												              *
*   Copyright: TWIinteractive                                 *
*	Author: Laurent Muchacho                                  *
*                                                             *
***************************************************************/
if(bw.ns){
	scrX= innerWidth; scrY= innerHeight;
	onresize= function(){if(scrX!= innerWidth || scrY!= innerHeight){history.go(0)} }
}
function createObjCss(divId,nest){var obj = (bw.ns&&nest)? document.layers[nest].document.layers[divId]:(bw.ns)?d.layers[divId]:(bw.ie4)?d.all[divId]:(bw.ie5Plus||bw.ns6)?d.getElementById(divId):false;return obj;}
function createObjStyle(divId,nest){var obj = (bw.ns&&nest)? document.layers[nest].document.layers[divId]:(bw.ns)?d.layers[divId]:(bw.ie4)?d.all[divId].style:(bw.ie5Plus||bw.ns6)?d.getElementById(divId).style:false;return obj;}
function createImgObj(imgId,nest){var obj = (bw.ns && nest)? d.layers[nest].document.images[imgId] : d.images[imgId];return obj;}

function xLeft_pos (obj){var xLeft = (bw.ns)? obj.pageX : obj.offsetLeft;return xLeft;}
function yTop_pos (obj){var yTop = (bw.ns)? obj.pageY : obj.offsetTop;return yTop;}
function get_Height (obj){var iHeight = (bw.ns)? obj.clip.height : obj.offsetHeight;return iHeight;}
function get_Width (obj){var iWidth = (bw.ns)? obj.clip.right : obj.offsetWidth;return iWidth;}

function writeInObj(objN,nest,sTxt){
var obj=(bw.ns)? createObjCss(objN,nest) : createObjCss(objN);
	if (bw.ns){	obj.document.open();obj.document.write(sTxt);obj.document.close();}
	else{obj=createObjCss(objN);obj.innerHTML = sTxt;}
}

function flipImg(imgName,nest){
var obj = createImgObj(imgName,nest)
var imgSrc = obj.src
var iN = imgSrc.split('/')
var iName = iN[iN.length-1].split('.')
	if (iName[0].indexOf("_sel")==-1){
		var imgOn = (iName[0].indexOf("_on") > -1)? true : false;
		var state = imgSrc.replace('.gif','_on.gif')
			if (imgOn){
			state = imgSrc.replace('_on.gif','.gif')
			}		
		obj.src = state
		return true
	}
}

function openWindow(){
var openWin;
openWin = window.open('/football/register.sps','Promotion_2','width=600,height=400,top=0,left=0,resizable=no,status=no,location=no,menubar=no');
openWin.focus();
}

function openwin(url){
	window.open(url, 'clipwin', 'width=640,height=540,top=0,left=0,toolbar=no,scrollbars=no,resizable=no,menubar=no,statusbar=no,locationbar=no');
}

var popupWin
function openNewWindow(wFile,wTitle,wWidth,wHeight){
	popupWin = window.open(wFile,wTitle,"top=0,left=0,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=" + wWidth + ",height=" + wHeight);
	popupWin.focus();
}
function openPixWindow(wFile,wTitle,wWidth,wHeight){
	popupWin = window.open(wFile,wTitle,"top=0,left=0,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + wWidth + ",height=" + wHeight);
	popupWin.focus();
}
function openRadioWindow(wFile,wTitle,wWidth,wHeight){
	// we used to escape, as we were passing a url - no need to now as we are just passing radioid. tb 1/11/02
	popupWin = window.open(wFile,wTitle,"top=0,left=0,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + wWidth + ",height=" + wHeight);
	popupWin.focus();
}
function closeWindow(){
	if (window.opener){
		window.opener.focus();
	}
window.close();
}
function openBrWindow(theURL,winName,features) {
window.open(theURL,winName,features);
}
var RMAwinW = 770; 
var RMAwinH = 425; 

var RMAwinX = (screen.width-RMAwinW)/2; 
var RMAwinY = (screen.height-RMAwinH)/2;

var NFW = "";var loadWin="";
function LaunchRMA(section,skin){
var urlPop = RMA_URL + 'frameset/dispatch.asp?site=manutd&sSection=' + section + '&skin=' + skin  
var stayOpenFor=13000;
var urlLoading = RMA_URL + 'loading.sps?howLong='+stayOpenFor;
var loadingWin = (section=='matchPack' || section=='comparison' || section=='matchTracker' )? true:false;
NFW=window.open(urlPop,'RMA','width=' + RMAwinW + ',height=' + RMAwinH + ',left=' + RMAwinX + ',top=' + RMAwinY + ',resizable=yes,status=no,location=no,menubar=no');
	if(loadingWin){
	    loadWin = window.open(urlLoading,'loading_rma','width=' + RMAwinW + ',height=' + RMAwinH + ',left=' + RMAwinX + ',top=' + RMAwinY + ',resizable=yes,status=no,location=no,menubar=no');
	}    
}

var megastoreWin = ""
function launchMegastore (){
var iWidth = RMAwinW+30;
var iHeight = RMAwinH-25;
var whereX = RMAwinX;
var whereY = RMAwinY;
var strUrl = 'http://store.manutd.com/';
	if (!megastoreWin==''){
		megastoreWin.focus();
	}else{
		megastoreWin = window.open(strUrl,'megastore','width=' + iWidth + ',height=' + iHeight + ',left=' + whereX + ',top=' + whereY + ',resizable=yes,status=yes,location=yes,scrollbars=yes,menubar=yes');
	}
}

//********************************************************************************

var strImagePath = "";
strImagePath = "/";

function browser_Over(){
	if (document.images){return(true);}
	else{return(false);}
}
canRollover = browser_Over();

function img (name){this.name = name;}

if (canRollover){
	im = new Array();
	im['menuArrow'] = new img (strImagePath + "pix/menu/m_arrow");	
	im['more'] = new img (strImagePath + "pix/SPSLEPix/more");
	im['more2'] = new img (strImagePath + "pix/SPSLEPix/more2");
	im['more_gold'] = new img (strImagePath + "pix/SPSLEPix/more_gold");
	im['more2_gold'] = new img (strImagePath + "pix/SPSLEPix/more2_gold");
	im['go'] = new img (strImagePath + "pix/d_go");	
	im['dVoteNow'] = new img (strImagePath + "pix/SPSLEPix/d_vote_now"+strColor);
	im['back'] = new img (strImagePath + "pix/SPSLEPix/title_back")	;
	im['next'] = new img (strImagePath + "pix/SPSLEPix/next")	;
	im['previous'] = new img (strImagePath + "pix/SPSLEPix/previous")	;
	im['send'] = new img (strImagePath + "pix/SPSLEPix/f_send")	;
	
	im['t_sub_teams'] = new img (strImagePath + "pix/SPSLEPix/t_sub_teams")	;
	im['t_sub_bio'] = new img (strImagePath + "pix/SPSLEPix/t_sub_bio")	;
	im['close'] = new img (strImagePath + "pix/SPSLEPix/d_close");
}

function flipIm(imageTag,imageArray,state){
	var tmp, o;
	tmp = '';
	tmp = tmp + '.gif';
	if (typeof(imageTag) == 'string'){
		o = eval('document.' + imageTag);
	}
	else{
		o = imageTag;
	}
	if (state == 0){o.src = im[imageArray].name + tmp }
	else if (state == 1){o.src = im[imageArray].name + '_on' + tmp}
	else if (state == 2){o.src = im[imageArray].name + '_sel' + tmp}
}



function flipImageOff(imgName){flipIm(imgName,imgName,0);}
function flipImageOn(imgName){flipIm(imgName,imgName,1);}
function flipImageSel(imgName){flipIm(imgName,imgName,2);}

function flipImageMenuOff(imgName){flipIm(imgName,'menuArrow',0);}
function flipImageMenuOn(imgName){flipIm(imgName,'menuArrow',1);}
function flipImageMenuSel(imgName){flipIm(imgName,'menuArrow',2);}

function flipImageMoreOff(imgName){flipIm(imgName,'more',0);}
function flipImageMoreOn(imgName){flipIm(imgName,'more',1);}

function flipImageMore2Off(imgName){flipIm(imgName,'more2',0);}
function flipImageMore2On(imgName){flipIm(imgName,'more2',1);}

function flipImageMore_goldOff(imgName){flipIm(imgName,'more_gold',0);}
function flipImageMore_goldOn(imgName){flipIm(imgName,'more_gold',1);}

function flipImageMore2_goldOff(imgName){flipIm(imgName,'more2_gold',0);}
function flipImageMore2_goldOn(imgName){flipIm(imgName,'more2_gold',1);}

function flipImageBackOff(imgName){flipIm(imgName,'back',0);}
function flipImageBackOn(imgName){flipIm(imgName,'back',1);}

function flipImageNextOff(imgName){flipIm(imgName,'next',0);}
function flipImageNextOn(imgName){flipIm(imgName,'next',1);}

function flipImagePreviousOff(imgName){flipIm(imgName,'previous',0);}
function flipImagePreviousOn(imgName){flipIm(imgName,'previous',1);}

function flipImageSendOff(imgName){flipIm(imgName,'send',0);}
function flipImageSendOn(imgName){flipIm(imgName,'send',1);}

function flipImageGoOff(imgName){flipIm(imgName,'go',0);}
function flipImageGoOn(imgName){flipIm(imgName,'go',1);}

function flipImageSqOff(imgName){flipIm(imgName,'t_sub_teams',0);}
function flipImageSqOn(imgName){flipIm(imgName,'t_sub_teams',1);}

function flipImageSqOff2(imgName){flipIm(imgName,'t_sub_bio',0);}
function flipImageSqOn2(imgName){flipIm(imgName,'t_sub_bio',1);}

function flipImagedVoteNowOff(imgName){flipIm(imgName,'dVoteNow',0);}
function flipImagedVoteNowOn(imgName){flipIm(imgName,'dVoteNow',1);}



function b_refer(){
	window.history.back ();
}

function ShowHide_select(objName, visState){
if(bw.ie){
		var obj, visSetting;
		if (visState.toUpperCase() == "HIDDEN")	{visSetting="hidden"}
		else									{visSetting="visible"}
	
		for (i = 0; i < document.all.tags(objName).length; i++){
			obj = document.all.tags(objName)[i];
			if (obj.className.toUpperCase() == "normalformcentral1".toUpperCase()) {obj.style.visibility = visSetting}
		}
	}
}
function stadwin(){
	win = window.open('/swopshop/plan.sps','stadium','width=589 height=508')
	win.focus();
}

var menuActive = false;var appletHere=false;
var selects = (bw.ie)?document.getElementsByTagName('select'):'';
function hideSel(){
if(selects.length&&selects.length==0)clearInterval(id)
	if(bw.ie){
	var vis = menuActive?'hidden':'visible'
		for(i=0;i<selects.length;i++){
			selects[i].style.visibility=vis
			if(appletHere){
				d.getElementById('newsreutersTicker').style.visibility = vis
			}
		}	
	}
}
//for manu banner ad- generates random number

function banner(){
var ord = Math.random()*1000000000;
ord=Math.floor(ord)
var str="";
str+='<SCR';
str+='IPT';
str+=' SRC="http\://ad.uk.doubleclick.net\/adj\/manutd\.com\.uk\/manu\;cat\=manu\;tile\=6\;sz=468x60\;ord='+ord+'\?" \>';
str+='</SCR';
str+='IPT>';
document.write(str);
}

var win
function openDownloads(which){
win = window.open('/oldTrafford/downloads/'+which+'.sps','Downloads','width=298,height=385,scrollbars=yes,top=0,left=0');
}


var valForm
function check_email(elemName){return valForm[elemName].value.match(/.+@.+\..+/)? true:valForm[elemName].dispName+' is valid';}
function check_numeric(elemName){return (valForm[elemName].value==''||valForm[elemName].value.match(/[^\d| |\/|-]/))?valForm[elemName].dispName+' is numeric': true ;}
function check_numericifcompleted(elemName){return (valForm[elemName].value!=''&&valForm[elemName].value.match(/\D/))?valForm[elemName].dispName+' is numeric': true ;}
function check_mandatory(elemName){return valForm[elemName].value.length>0? true:valForm[elemName].dispName+' is completed';}
function check_longer(elemName){return valForm[elemName].value.length>valForm[elemName].args? true: valForm[elemName].dispName+' is longer than '+valForm[elemName].validate.longer+' characters';}
function check_shorter(elemName){return valForm[elemName].value.length>0&&valForm[elemName].value.length<valForm[elemName].validate.shorter? true:valForm[elemName].dispName+' is shorter than '+valForm[elemName].validate.shorter+' characters';}
function check_confirm(elemName){return(valForm[elemName].value==valForm[valForm[elemName].validate.confirm[0]].value)?true:valForm[elemName].dispName+' is the same as '+valForm[elemName].validate.confirm[1];}
function validate(frm){
valForm=frm;
var errMsg='';
var retVal=false;
	for(i=0;i<frm.length;i++){
		for(j in frm[i].validate){
		retVal=eval('check_'+j+'(i)');
			if(retVal===true){
				if(frm[i].style){frm[i].style.backgroundColor='#999999'};
				continue;
			}else{
				errMsg+=' - '+retVal+'\t\n';
				if(frm[i].style){frm[i].style.backgroundColor='#dddddd'};
			}
		}
	}
	if(errMsg!=''){
		errMsg='Please ensure that:\n\n'+errMsg;
		alert(errMsg);
	}else{
		frm.submit();
	}
}

function doUk(elem){
	if(elem.options[elem.selectedIndex].text=="United Kingdom"){
		createObjStyle('ast').visibility="visible";
		elem.form.postCode.validate={mandatory:true};
		elem.form.postCode.dispName='Post Code';
	}else{
		createObjStyle('ast').visibility="hidden";
		elem.form.postCode.validate=null;
	}
}

function lycostag(type, cat, bannertype) { 
	var ad_pos=new Array();
	var ad_dbg=0;
	var ts=new Date();
	lt = '<'
	document.writeln ('<center>'+lt+'scr'+'ipt language="JavaScript1.1" type="text/javascript" '+'src="http://fe.lea.lycos.co.uk/js.ng/country=uk&affiliate=manu&svc='+cat+'&btype='+bannertype+'&adpos='+type+'&refurl='+location.protocol+'//'+location.host.toLowerCase()+location.pathname.substr(0,100)+'&rannumber='+Date.parse(ts)+'?"></center>'+lt+'/scr'+'ipt>');			    
} 
			
/*********************************************************************************************/			
	function advert_item(src,href){
		this.src = src;
		this.href = href;
		this.item_type=get_extension;
		this.href = href;
		this.build_item = build_item_str;
		this.build_launch_button = build_button_str;
	}

	function get_extension(){
		var ext = this.src.match(/\w{3}$/);
		return ext;
	}
	
	
	function build_item_str(){
	var str = "";
		if(this.item_type()=='swf'&&detectFlash()){
			str += '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" WIDTH=266 HEIGHT=93 id=ShockwaveFlash1>'
				+  '<PARAM NAME=movie VALUE="'+this.src+'">'
				+  '<PARAM NAME=quality VALUE=high>'
				+  '<EMBED src="'+this.src+'" quality=high WIDTH=266 HEIGHT=93 NAME="flash" ALIGN="absmiddle" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>'
				+  '</OBJECT>';
		}else {
		this.src = this.src.replace(this.item_type(),'gif');
			str += '<a href="'+this.href+'"><img src="' + this.src + '" width="266" height="93" border="0"></a>';		
		}
		return str;
	}

	function build_button_str(){
	var href_match_http = this.href.match(/^\w{4}/);
	var href_str = (href_match_http=='http')? this.href : 'javascript:' + this.href;
		var str='<table cellspacing="0" cellpadding="0" border="0" class="homeBody"><tr><td><a href="'+href_str+'"><img src="/pix/home/seered_launch.gif" width="267" height="14" alt="Launch" border="0"></a></td></tr></table>';
		return str
	}

	function launch_compId(compId){
	window.open ('/competitions/compIntro.sps?compid='+compId,'Competition_'+compId,'width=241,height=550,top=0,left=0,resizable=no,status=no,location=no,menubar=no');
	}

	
function openRMA(iAssetId){
	if (iAssetId && xRMA_URL)
	{
	var xRMAWIN;
	xRMAWIN = window.open(xRMA_URL + '&asset_id=' + iAssetId,'MediaPopup',"resizable=no,status=no,location=no,scrollbars=no,menubar=no,toolbar=no,width=340,height=481");
	xRMAWIN.focus();
	}
}
function fnset(){
	if(bw.ie){
		window.external.AddFavorite(d.location.href, d.title)
	}
}

