﻿var isIE = navigator.appName.indexOf("Microsoft") > -1;

function GetParam(name)
{
	var start=location.search.indexOf("?"+name+"=");
	if (start<0) start=location.search.indexOf("&"+name+"=");
 	if (start<0) return '';
 	start += name.length+2;
 	var end=location.search.indexOf("&",start)-1;
 	if (end<0) end=location.search.length;
 	var result=location.search.substring(start,end);
 	var result='';
 	for(var i=start;i<=end;i++)
 	{
 		var c=location.search.charAt(i);
 		result=result+(c=='+'?' ':c);
 	}
 	//alert(unescape(result));
 	return unescape(result);
}

function getSharpParam()
{
	var str = location.toString();
	var result = str.split('#')[1];
	
	if (str.indexOf('?')!=-1)
		{
			result = str.split('?')[1];
		}
	//alert(result);
 	return unescape(result);
}

function checkURL(array)
{
	var url = window.top.location.href;
	var id;
	var va = [["/", "/"], ["=", ""]];
	
	for (var item=0; item<va.length; item++)
	{
		for (var i=0; i<array.length; i++)
		{
			if (url.indexOf((va[item][0] + array[i] + va[item][1])) >= 0)
			{
				id = array[i];
				break;
			}
		}
	}
	
	return id;
}

function changeLanguage(target)
{
	var array = new Array("en", "tc", "sc");
	var nowL = checkURL(array);
	var va = [["/", "/"], ["=", ""]];
	var url = window.top.location.href;
	for (var item=0; item<va.length; item++)
	{
		if (url.indexOf((va[item][0] + nowL + va[item][1])) >= 0)
		{
			url = url.replace((va[item][0] + nowL + va[item][1]), (va[item][0] + target + va[item][1]));
			break;
		}
	}
	if (url.substring((url.length-1), url.length) == '#')	url = url.substring(0, (url.length-1))
	window.top.location.href = url;
}

function NewWindow(mypage, myname, w, h, scroll,resizable) {
	if (isIE)
	{
		w = w - 4;
		h = h - 4;
	}
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+resizable+','
	win = window.open(mypage, myname, winprops)
	win.self.focus()
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function genFlash(file, width, height, id, vars) {
	var tempHtml = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+width+'" height="'+height+'" id="'+id+'" name="'+id+'">';
	tempHtml += '<param name="movie" value="'+file+'">';
	tempHtml += '<param name="quality" value="high">';
	tempHtml += '<param name="menu" value="false">';
	tempHtml += '<param name="wmode" value="transparent">';
	//tempHtml += '<param name="scale" value="noscale">';
	tempHtml += '<param name="salign" value="TL">';
	
	//alert(vars);
	if (vars != null) {
		tempHtml += '<param name="flashVars" value="'+vars+'">';
		tempHtml += '<embed src="'+file+'" flashVars="'+vars+'" salign="TL" quality="high" wmode="transparent" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" id="'+id+'" name="'+id+'"></embed>';
	} else {
		tempHtml += '<embed src="'+file+'" salign="TL" quality="high" wmode="opaque" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" id="'+id+'" name="'+id+'"></embed>';
	}
	
	tempHtml += '</object>';
	
	document.write(tempHtml);
}

function innerFlash(file, width, height, id, vars) {
	tempHtml += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+width+'" height="'+height+'" id="'+id+'" name="'+id+'">';
	tempHtml += '<param name="movie" value="'+path+file+'">';
	tempHtml += '<param name="quality" value="high">';
	tempHtml += '<param name="menu" value="false">';
	tempHtml += '<param name="wmode" value="noscale">';
	tempHtml += '<param name="scale" value="noscale">';
	tempHtml += '<param name="salign" value="TL">';
	
	if (vars != null) {
		tempHtml += '<param name="flashVars" value="'+vars+'">';
		tempHtml += '<embed src="'+path+file+'" flashVars="'+vars+'" salign="TL" quality="high" scale="noscale" wmode="noscale" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" id="'+id+'" name="'+id+'"></embed>';
	} else {
		tempHtml += '<embed src="'+path+file+'" salign="TL" quality="high" scale="noscale" wmode="noscale" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" id="'+id+'" name="'+id+'"></embed>';
	}
	
	tempHtml += '</object>';
	
//	document.write(tempHtml);
}


var motion;
var goSpeed = 20;
var tempNum;
var frameBody;
var tempX;
var tempY;
var isIFrame = false;

function scrollStart(name, goNum, iFrame) {
	tempNum = goNum;
	if (navigator.appName.indexOf("Microsoft") > -1) {
		if (iFrame != null) {
    		frameBody  = document.frames(name).document.body;
    		isIFrame = true;
    	} else {
    		frameBody  = document.getElementById(name);
    	}
	} else {
		if (iFrame != null) {
    		frameBody  = document.all(name);
    	//	frameBody.contentWindow.scrollTo(0, 0);
    		isIFrame = true;
    	} else {
    		frameBody  = document.getElementById(name);
    	}
	}
	scrollMotion();
}

function scrollMotion(){
//	window.status = document.getElementById("contentIFrame").document.body.scrollHeight +"  :  "+ frameBody.offsetHeight;
	if (navigator.appName.indexOf("Microsoft") > -1) {
		frameBody.scrollTop += tempNum;
	} else {
		if (isIFrame) {
			tempX = frameBody.contentWindow.pageXOffset;
			tempY = frameBody.contentWindow.pageYOffset;
			tempY += tempNum;
			frameBody.contentWindow.scrollTo(tempX, tempY);
		} else {
			frameBody.scrollTop += tempNum;
		}
	}
	
	motion = setTimeout("scrollMotion()", goSpeed);
}

function scrollStop() {
	clearTimeout(motion);
}

function popupVideo(file, w, h, name) {
 var popUpPage2 = window.open('', ''+name+'', 'width='+(Number(w)+20)+',height='+h+',left=0,top=0,screenX=0,screenY=0,scrollbars=1,resizable=0');
 popUpPage2.document.open();
 popUpPage2.document.write('<html>');
 popUpPage2.document.write('<head><title>Arsenal Soccer Schools</title></head>');
 
 
 popUpPage2.document.write(' <scri');
 popUpPage2.document.write('pt language="Jav');
 popUpPage2.document.write('aScript">');
				
 popUpPage2.document.write('function changeHomeVideo(link) {');
 popUpPage2.document.write('	var homeVideo = document.getElementById("mediaPlayer");');
 popUpPage2.document.write('	var video = videoArray[(link-1)];');
 popUpPage2.document.write('	homeVideo.fileName = video;');
  
 popUpPage2.document.write('}');

 popUpPage2.document.write('function showVideoControl(flag) {');
 popUpPage2.document.write('	var homeVideo = document.getElementById("mediaPlayer");');
 popUpPage2.document.write('	homeVideo.showControls = (flag==1);');
 popUpPage2.document.write('}');

  popUpPage2.document.write('</sc');
  popUpPage2.document.write('ript>');
 
 
 popUpPage2.document.write('<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
 
 popUpPage2.document.write('<div style="background:transparent;display:block;width:320px;height:240px;" onmouseout="showVideoControl(0)" onmouseover="showVideoControl(1)">');
 
  popUpPage2.document.write('<OBJECT id="mediaPlayer" width="'+w+'" height="'+h+'" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">');
 popUpPage2.document.write('						<param name="fileName" value="'+path+file+'">');
 popUpPage2.document.write('						<param name="animationatStart" value="true">');
 popUpPage2.document.write('						<param name="transparentatStart" value="true">');
 popUpPage2.document.write('						<param name="autoStart" value="true">');
 popUpPage2.document.write('						<param name="showControls" value="'+!(isIE)+'">');
 popUpPage2.document.write('						<param name="loop" value="true">');
 popUpPage2.document.write('						<EMBED type="application/x-mplayer2"pluginspage="http://microsoft.com/windows/mediaplayer/en/download/" id="mediaPlayer" name="mediaPlayer" displaysize="4" autosize="-1" bgcolor="darkblue" showcontrols="true" showtracker="-1" showdisplay="0" showstatusbar="-1" videoborder3d="-1" width="'+w+'" height="'+h+'" src="'+path+file+'" autostart="true" designtimesp="5311" loop="true"> </EMBED>');
 popUpPage2.document.write('					</OBJECT>');
popUpPage2.document.write('<div');
 popUpPage2.document.write('</body>');
 popUpPage2.document.write('</html>');
 popUpPage2.document.close();
 popUpPage2.focus();
}

var videoSection = 1;

function changeVideo(i)
{
	if (videoSection == i)	return;
	var btn = document.getElementById('tv_photo_'+i);
	var btn1 = document.getElementById('tv_photo_'+videoSection);
	
	btn.src = path + 'images/home/tvPhotoframe_on.png';
	btn1.src = path + 'images/home/tvPhotoframe.png';
	
	videoSection = i;
	
	changeHomeVideo(i);
}