// JavaScript Document
// Netscape CSS Bug Fix
if (document.layers) {
   origWidth = innerWidth;
   origHeight = innerHeight;
   }
 function reloadPage() {
    if (innerWidth != origWidth || innerHeight != origHeight)
	   location.reload();
	}
if (document.layers) onresize = reloadPage;

// findDOM.js
var isDHTML = 0;
var isLayers = 0; // Netscape (N)
var isAll = 0;    // IE (I)
var isID = 0;     // DOM

if (document.getElementById) {isID = 1; isDHTML = 1;}
else {
browserVersion = parseInt(navigator.appVersion);
if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {isLayers = 1; isDHTML = 1;}
else {
if (document.all) {isAll = 1; isDHTML = 1;}
}}

function modifyInner(tagId, strVal) {
if (document.layers)
   {
   eval('document.' + tadId + '.document.open()');
   eval('document.' + tagId + '.document.write(strVal)');
   eval('document.' + tagId + '.document.close()');
   }
else if(isAll)
   {
   eval('document.all' + tagId + '.innerHTML = strVal');
   }
else if(isID)
   {
   eval('document.getElementById(\'' + tagId + '\').innerHTML = strVal');
   }
}
function findDOM(objectID,withStyle) {
var menuArea = "menuArea";
	if (withStyle == 1) {
		if (isID) { return (document.getElementById(objectID).style) ; }
		else { 
			if (isAll) { return (document.all[objectID].style); }
		else {
			if (isLayers) { return (document.layers[menuArea].layers[objectID]); }
		};}
	}
	else {
		if (isID) { return (document.getElementById(objectID)) ; }
		else { 
			if (isAll) { return (document.all[objectID]); }
		else {
			if (isLayers) { return (document.layers[menuArea].layers[objectID]); }
		};}
	}
}

function setVisibility(objectID,state) {
   var dom = findDOM(objectID,1);
   dom.visibility = state;
}
function setImage(objectID,isrc) {
// alert (objectID + " " + isrc);
//   var dom = findDOM(objectID,1);
//   var dom =document.getElementById(objectID);
//   dom.setAttribute("src",eval(isrc));
   img1 = new Image();
   img1.src = isrc;
   document.images.subPic.src = img1.src;
}
function setText(objectID,str) {
   var dom = findDOM(objectID,1);
   dom.location = "javascript:document.write('" + str + "');";
//   alert ("Set text to" + str );
}

// Global variables
// curDispVal is used by chooseAndGo
var curDispVal = ""
var curDispDiv = "Division 1"
function chooseAndGo(myDropdown){
// Set Division value ## this doesnt work
   curDispDiv = myDropdown.options[myDropdown.selectedIndex].value;
   if (curDispVal == "schedule") {
      DisplaySchedule();
   } else {
      DisplayStandings();
   }
}


function DisplayStandings(division)
{
//setVisibility('subName','visibile');
//setText('subName','standings');
var div=document.form1.division.selectedIndex;
// Reverse index for now where Advanced 1 is 0 Recreational is 5
// Add new REC div to make it now 6
// div=(div-6)*-1;
// div=Math.abs(div-6);
// div=div-1;
// Little problem figuring out why I can't pass index directly. The following 
// makes it work
div=div+1;
if ( div == 1 ) divcode = "1";
if ( div == 2 ) divcode = "2";
if ( div == 3 ) divcode = "3";
if ( div == 4 ) divcode = "4";
if ( div == 5 ) divcode = "5";
if ( div == 6 ) divcode = "6";
if ( div == 7 ) divcode = "7";
if ( div == 8 ) divcode = "8";
if ( div == 9 ) divcode = "9";
// var url="../cgi-bin/stanDisplay.pl?div="+div+"&tag=spring";
//var url="../cgi-bin/stanDisplay.pl?div="+divcode+"&tag=spring";
var url="../cgi-bin/stanDisplay.pl?div="+divcode+"&tag=fall";
parent.frames['frame_main'].window.location=url;
modifyInner('subName','standings');
//subName.innerHTML="standings";
//parent.frames['frame_subname'].window.location="javascript:document.write('standings');";
curDispVal = "standings";
}

function DisplayCalendar()
{
//setVisibility('subName','visibile');
//setText('subName','month at a glance');
var url="../cgi-bin/calDisplay.pl?init=yes"
parent.frames['frame_main'].window.location=url;
modifyInner('subName','month at a glance');
//subName.innerHTML="month at a glance";
//  parent.frames['frame_subname'].window.location="javascript:document.write('month at a glance');";
}

function DisplayEvents()
{
//setVisibility('subName','visibile');
//setText('subName','upcoming events');
var url="../cgi-bin/eventsDisplay.pl?init=yes"
parent.frames['frame_main'].window.location=url;
modifyInner('subName','upcoming events');
// subName.innerHTML="upcoming events";
// parent.frames['frame_subname'].window.location="javascript:document.write('upcoming evnents');";
}

function DisplaySummer()
{
var url="../cgi-bin/eventsDisplay.pl?init=yes"
parent.frames['frame_main'].window.location=url;
modifyInner('subName','summer info');
}

function DisplayPhotos()
{
modifyInner('subName','Fire Island');
// var url="../cgi-bin/eventsDisplay.pl?init=yes"
// var url="../cgi-bin/calDisplay.pl?init=yes"
var url="../photo/index.php"
parent.frames['frame_main'].window.location=url;
}

function DisplayRosters()
{
var url="../cgi-bin/eventsDisplay.pl?init=yes"
parent.frames['frame_main'].window.location=url;
modifyInner('subName','season rosters');
}

function DisplaySchedule(division)
{
//setVisibility('subName','visibile');
//setText('subName','schedule');
var div=document.form1.division.selectedIndex;
//form.country.options[form.country.selectedIndex].value 
//var divname=document.form1.division.options[document.form1.division.selectedIndex].value;
// Reverse index for now where Advanced 1 is 0 Rec B is 6
// div=(div-5)*-1;
// div=Math.abs(div-6);
// div=div-1;
// Changed indexin Division 1 = 1
div=div+1;
if ( div == 1 ) divcode = "1";
if ( div == 2 ) divcode = "2";
if ( div == 3 ) divcode = "3";
if ( div == 4 ) divcode = "4";
if ( div == 5 ) divcode = "5";
if ( div == 6 ) divcode = "6";
if ( div == 7 ) divcode = "7";
if ( div == 8 ) divcode = "8";
if ( div == 9 ) divcode = "9";
//// var url="../cgi-bin/schedDisplay.pl?div="+div+"&tag=spring";
//var url="../cgi-bin/schedDisplay.pl?div="+divcode+"&tag=spring";
var url="../cgi-bin/schedDisplay.pl?div="+divcode+"&tag=fall";
parent.frames['frame_main'].window.location=url;
modifyInner('subName','schedule');
//subName.innerHTML="schedule";
//parent.frames['frame_subname'].window.location="javascript:document.write('<i>schedule</i>');";
curDispVal = "schedule";
}
