/* Javascript file created by Brandon Harada for Meridian PAL */
var http_request = false;
var openMADC;
function reloadMiddle(url){                                 
	http_request = false;
	if (window.XMLHttpRequest){ // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType){
			http_request.overrideMimeType('text/xml');
		}
	}else if (window.ActiveXObject){ // IE
		try{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			try{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}catch (e){}
		}
	}
	if (!http_request){
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}  
	var randomnum=Math.random();  
	url = url + '?rnd=' + randomnum;
	http_request.onreadystatechange = loadContents;
	http_request.open('GET', url, true);
	http_request.send(null);
}

function loadContents(){
  if (http_request.readyState == 4){
      document.getElementById('centerarea').innerHTML=http_request.responseText;
	  getStyleClass('pdadiv').style.display = 'none';
	  if (document.getElementById('theYearSpan')){
		  var newDate = new Date
		  var yearVal = newDate.getYear();
		  var theMonth = newDate.getMonth();
		  if ((theMonth == 10) || (theMonth == 11)){
			  yearVal ++;
		  }		  
		  document.getElementById('theYearSpan').innerHTML = "<span>" +  yearVal + "</span>";
	  }
  }
}
  
function popWeather(){
	window.open('/soccer/weather.html', 'weather', 'width=300,height=250,directories=no,location=no,menubar=no,status=no,toolbar=no');	
}
function reloadPageWord(url){	
	document.getElementById('headerlinks').innerHTML = "";
	var SoccerHeaderlinksText = "<p>|&nbsp;<a href=\"javascript:reloadCenter('soccer/rec/rec.html');\">Rec Soccer</a> | <a href=\"javascript:reloadCenter('soccer/select/select.html');\">Select Soccer</a> | <a href=\"javascript:reloadCenter('soccer/coaches.html');\">Coaches</a> | <a href=\"javascript:reloadCenter('referee/referee.html');\">Referees Page</a> | <a href=\"javascript:reloadCenter('soccer/registration.html');\">Registration</a> | <a href=\"javascript:reloadCenter('soccer/forms.html');\">Forms</a> | <a href=\"javascript:reloadCenter('/soccer/sponsors.html');\">Sponsorships</a> | <a href=\"javascript:popWeather();\">Weather</a> | <a href=\"javascript:reloadCenter('soccer/soccer_links.html');\">SOCCER&nbsp;LINKS</a>&nbsp;|<br></p>";
	var FootballHeaderlinksText = "<p class=\"footballwords\">|&nbsp;<a href=\"javascript:reloadCenter('football/camps.html');\">Camps</a> |&nbsp;<a href=\"javascript:reloadCenter('football/info.html');\">League Information</a> |&nbsp;<a href=\"javascript:reloadCenter('football/age_groups.html');\">Age Groups</a> |" + /* <a href=\"http://www.meridianpal.org/schedules/football/fall09/schedules.htm\" target=\"_blank\">Schedules</a> |*/" <a href=\"http://www.meridianpal.org/pdf/2009/football/FlagPositiveCoach Alliance20090217.pdf\" target=\"_blank\">Positive Coach Alliance</a> | <a href=\"javascript:reloadCenter('football/sponsors.html');\">Sponsors</a> &nbsp;|&nbsp;<a href=\"javascript:reloadCenter('football/forms.html');\">Forms</a> &nbsp;|</p>";
	if(url.match('home')){
		document.getElementById('pageword').innerHTML = 'Meridian PAL';
	}else if (url.match('soccer') || url.match('rec') || url.match('select') || url.match('referee') || url.match('coaches')){
		document.getElementById('headerlinks').innerHTML = SoccerHeaderlinksText;
		document.getElementById('bottomLeftbar').style.height = "100%";
		if (url.match('rec'))document.getElementById('pageword').innerHTML = 'MPAL Rec Soccer';
		else if (url.match('select'))document.getElementById('pageword').innerHTML = 'MPAL Select Soccer';
		else if (url.match('referee'))document.getElementById('pageword').innerHTML = 'Referees Page';
		else if (url.match('coaches'))document.getElementById('pageword').innerHTML = 'MPAL Coach&rsquo;s Corner';
		else document.getElementById('pageword').innerHTML = 'MPAL Soccer';
	}else if (url.match('football')){
		document.getElementById('pageword').innerHTML = 'MPAL Football';
		document.getElementById('headerlinks').innerHTML = FootballHeaderlinksText;
	}else if (url.match('baseball'))document.getElementById('pageword').innerHTML = 'MPAL Baseball';
	else if (url.match('basketball'))document.getElementById('pageword').innerHTML = 'MPAL Basketball';
	else if (url.match('karate'))document.getElementById('pageword').innerHTML = 'MPAL Karate';
	else if (url.match('hockey'))document.getElementById('pageword').innerHTML = 'MPAL Hockey';
	else if (url.match('about'))document.getElementById('pageword').innerHTML = 'About MPAL';
	else if (url.match('contact'))document.getElementById('pageword').innerHTML = 'Contact MPAL';
	else if (url.match('about'))document.getElementById('pageword').innerHTML = 'About Meridian PAL';
	else{
		document.getElementById('pageword').innerHTML = 'Meridian PAL';
	}
}
function reloadCenter(url){
	reloadMiddle(url);
	reloadPageWord(url);
}

function norobotmail(aUser, aDomain) { 
	var locString = "mailto:" + aUser + "@" + aDomain;
	document.location = locString;
};

function getStyleClass (className) {
	for (var s = 0; s < document.styleSheets.length; s++){
		if(document.styleSheets[s].rules){
			for (var r = 0; r < document.styleSheets[s].rules.length; r++){
				if (document.styleSheets[s].rules[r].selectorText == '.' + className){
					return document.styleSheets[s].rules[r];
				}
			}
		}else if(document.styleSheets[s].cssRules){
			for (var r = 0; r < document.styleSheets[s].cssRules.length; r++){
				if (document.styleSheets[s].cssRules[r].selectorText == '.' + className)
					return document.styleSheets[s].cssRules[r];
			}
		}
	}	
	return null;
}

function moveDiv()
{
	if(navigator.appName == "Netscape")
	{
		var t = setTimeout("isNet()",1300);
	}	
}
/**
 *  Javascript page created by DreamWeaver for Meridian PAL (www.meridianpal.org)
 *      Modifications by Brandon Harada (PAL webmaster)
 *
 *
 * mm_menu 20MAR2002 Version 6.0
 * Andy Finnell, March 2002
 * Copyright (c) 2000-2002 Macromedia, Inc.
 *
 * based on menu.js
 * by gary smith, July 1997
 * Copyright (c) 1997-1999 Netscape Communications Corp.
 *
 * Netscape grants you a royalty free license to use or modify this
 * software provided that this copyright notice appears on all copies.
 * This software is provided "AS IS," without a warranty of any kind.
 */
 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 PALpreload(){
	MM_preloadImages('images/Buttons/SoccerButtonDown.jpg','#soccerbtn');
	MM_preloadImages('images/Buttons/BaseballButtonDown.jpg','#baseball');
	MM_preloadImages('images/Buttons/KarateButtonDown.jpg','#karate');
	MM_preloadImages('images/Buttons/HockeyButtonDown.jpg','#hockey');
	MM_preloadImages('images/Buttons/FootballButtonDown.jpg','#football');
	MM_preloadImages('images/Buttons/BasketballButtonDown.jpg','#basketbtn');
	MM_preloadImages('images/Buttons/AboutButtonDown.jpg','#about');
	MM_preloadImages('images/Buttons/ContactButtonDown.jpg','#contact');
	MM_preloadImages('images/RedoneLogoDown.gif','#logo');
}

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_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_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 getExplorerVersion() {
	var ieVers = parseFloat(navigator.appVersion);
	if( navigator.appName != 'Microsoft Internet Explorer' ) return ieVers;
	var tempVers = navigator.appVersion;
	var i = tempVers.indexOf( 'MSIE ' );
	if( i >= 0 ) {
		tempVers = tempVers.substring( i+5 );
		ieVers = parseFloat( tempVers ); 
	}
	return ieVers;
}

function MM_clearTimeout() {
	if (mmHideMenuTimer) clearTimeout(mmHideMenuTimer);
	mmHideMenuTimer = null;
	mmDHFlag = false;
}

function MM_startTimeout() {
	if( window.ActiveMenu ) {
		mmStart = new Date();
		mmDHFlag = true;
		mmHideMenuTimer = setTimeout("mmDoHide()", window.ActiveMenu.Menu.hideTimeout);
	}
}

function NS4resize() {
	if (NS4sIW != window.innerWidth || NS4sIH != window.innerHeight) window.location.reload();
}

function FIND(item) {
	if( window.mmIsOpera ) return(document.getElementById(item));
	if (document.all) return(document.all[item]);
	if (document.getElementById) return(document.getElementById(item));
	return(false);
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {
		if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
			document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; 
		}
	}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH){ location.reload();}
	MM_reloadPage(true);
}

function isNet(){	
	//alert("You're using a Netscape browser.");
	document.getElementById('leftcontent').style.left='99%';
	document.getElementById('rightcontent').style.left='99%';
	document.getElementById('headerlinks').style.top=58;
}

function setMADC(){
	openMADC = window.open('http://www.meridiancity.org/madc/', 'madc');
	setTimeout("madc2()", 1000);
}

function madc2(){
	openMADC.location.href = "http://www.meridiancity.org/madc/";
}