//   #################################################
//  #                                                 #
//  #    STANDARD DOM SETUP                           #
//  #                                                 #
//   #################################################

if (document.all)
{
	dom1='document.all["';
	dom2='"]';
	isIE = true;
} else {
	dom1='document.getElementById("';
	dom2='")';
	isIE = false;
}














preload = new Array();
for (x=1;x<=15;x++) preload[x] = new Image();
preload[1].src = "http://www.whatsmyscore.org/images/nav-1on.gif";
preload[2].src = "http://www.whatsmyscore.org/images/nav-2on.gif";
preload[3].src = "http://www.whatsmyscore.org/images/nav-3on.gif";
preload[4].src = "http://www.whatsmyscore.org/images/nav-4on.gif";
preload[5].src = "http://www.whatsmyscore.org/images/nav-5on.gif";
preload[6].src = "/images/search-go.gif";
preload[7].src = "/images/search-pad.gif";
preload[8].src = "/images/search-bg.png";
preload[9].src = "/images/search-back.gif";
preload[10].src = "/images/downloads-downa0.gif";
preload[11].src = "/images/downloads-downa1.gif";
preload[12].src = "/images/downloads-downb0.gif";
preload[13].src = "/images/downloads-downb1.gif";
preload[14].src = "/images/downloads-up0.gif";
preload[15].src = "/images/downloads-up1.gif";



function rollover(which)
{
	document.images["nav"+which].src = "http://www.whatsmyscore.org/images/nav-"+which+"on.gif";
}

function rollout(which)
{
	document.images["nav"+which].src = "http://www.whatsmyscore.org/images/nav-"+which+"off.gif";
}

searchState = false;

function searchToggle()
{
	searchState = !searchState;
	if (searchState)
	{
		document.getElementById('searchInner').className = "shownSearch";
	} else {
		document.getElementById('searchInner').className = "hiddenSearch";
	}
}


















function init()
{
	videoPos = 1;
	videoPage = 0;
	lastOne = (videoTotal > 4) ? 4 : videoTotal;
	for (loop=2;loop<=lastOne;loop++)
	{
		document.images["vIcon"+loop].src = vidIconSource[loop].src;
	}
	document.images["vIcon"+videoPos].src = vidIconAltSource[videoPos].src;
	document.images["vPhoto"].src = vidPhotoSource[videoPos].src;
	eval(dom1+"videoInfo1"+dom2+".className = 'vidInfo'");
	eval(dom1+"videoLink"+dom2+".innerHTML = "+dom1+"videoLink1"+dom2+".innerHTML");
	eval(dom1+"videoLinkAlt"+dom2+".innerHTML = "+dom1+"videoLink1Alt"+dom2+".innerHTML");
	eval(dom1+"videoMore"+dom2+".className = 'vidInfoLink'");
	if (videoTotal > 4)
	{
		document.images["dl-downb"].src = "/images/downloads-downb0.gif";
		document.images["dl-downa"].src = "/images/downloads-downa0.gif";
		document.images["dl-up"].src = "/images/downloads-up0.gif";
		videoShowMore = true;
		totalPages = (Math.ceil(videoTotal/4))-1;
	}
	setTimeout("newVideo();",videoDelay);
}

function videoSwap(which)
{
	goFreely = false;
	whichVideo = which+(4*videoPage);
	if ((videoPos != 0) && (whichVideo <= videoTotal))
	{
	
		document.images["vIcon"+videoPos].src = vidIconSource[(videoPos+(4*videoPage))].src;

		document.images["vIcon"+which].src = vidIconAltSource[whichVideo].src;
		document.images["vPhoto"].src = vidPhotoSource[whichVideo].src;
		eval(dom1+"videoInfo"+videoPos+dom2+".className = 'vidInfo-hidden'");
		eval(dom1+"videoInfo"+which+dom2+".className = 'vidInfo'");
		eval(dom1+"videoLink"+dom2+".innerHTML = "+dom1+"videoLink"+whichVideo+dom2+".innerHTML");
		eval(dom1+"videoLinkAlt"+dom2+".innerHTML = "+dom1+"videoLink"+whichVideo+"Alt"+dom2+".innerHTML");
		videoPos = which;
	}
}

function newVideo()
{
	which = videoPos + 1;
	if ((which > 4) || (which > videoTotal)) which = 1;
	if ((videoPos != which) && (goFreely == true))
	{
		document.images["vIcon"+videoPos].src = vidIconSource[videoPos].src;
		document.images["vIcon"+which].src = vidIconAltSource[which].src;
		document.images["vPhoto"].src = vidPhotoSource[which].src;
		eval(dom1+"videoInfo"+videoPos+dom2+".className = 'vidInfo-hidden'");
		eval(dom1+"videoInfo"+which+dom2+".className = 'vidInfo'");
		eval(dom1+"videoLink"+dom2+".innerHTML = "+dom1+"videoLink"+which+dom2+".innerHTML");
		eval(dom1+"videoLinkAlt"+dom2+".innerHTML = "+dom1+"videoLink"+which+"Alt"+dom2+".innerHTML");
	videoPos = which;
	}
	setTimeout("newVideo();",videoDelay);
}

function videoMoreLink()
{
	where = vidMore[videoPos];
	document.location = where;
}

function videoPageUp()
{
	goFreely = false;
	if (videoShowMore)
	{
		videoPage--;
		if (videoPage < 0) videoPage = totalPages;
		showNewVids();
	}
}

function videoPageDown()
{
	goFreely = false;
	if (videoShowMore)
	{
		videoPage++;
		if (videoPage > totalPages) videoPage = 0;
		showNewVids();
	}
}

function showNewVids()
{
	for (loop=1;loop<=4;loop++)
	{
		which = loop + (4*videoPage);
		if (which <= videoTotal)
		{
			document.images["vIcon"+loop].src = vidIconSource[which].src;
		} else {
			document.images["vIcon"+loop].src = "/images/downloads-temp.gif";
		}
	}

}

function openVideo(which)
{
	window.open(which,"vidsubwin","width=400,height=340,location=no,menubar=no,resizeable=no,scrollbars=no,status=no,toolbar=no");
}

function downOver()
{
	if (videoShowMore)
	{
		document.images["dl-downb"].src = "/images/downloads-downb1.gif";
		document.images["dl-downa"].src = "/images/downloads-downa1.gif";
	}
}

function downOut()
{
	if (videoShowMore)
	{
		document.images["dl-downb"].src = "/images/downloads-downb0.gif";
		document.images["dl-downa"].src = "/images/downloads-downa0.gif";
	}
}

function upOver()
{
	if (videoShowMore)
	{
		document.images["dl-up"].src = "/images/downloads-up1.gif";
	}
}

function upOut()
{
	if (videoShowMore)
	{
		document.images["dl-up"].src = "/images/downloads-up0.gif";
	}
}








//   #################################################
//  #                                                 #
//  #    STANDARD FORM ROUTINES                       #
//  #                                                 #
//   #################################################

//  ######################################
//  #  setup form defaults
//  ######################################

inputID = new Array();
inputName = new Array();
inputRequired = new Array();
inputDefault = new Array();
inputError = new Array();

function formDefaults(thisField,thisRequired,thisDefault,thisError)
{
	doSetup = true;
	if (thisField.charAt(0) == "-")
	{
		doSetup = false;
		thisField = thisField.substring(1);
	}
	which = inputName.length;
	inputID[thisField] = which;
	inputName[which] = thisField;
	inputRequired[which] = thisRequired;
	inputDefault[which] = thisDefault;
	inputError[which] = thisError;
	if (doSetup)
	{
		eval("currentValue = "+dom1+thisField+dom2+".value");
		if (currentValue == '')
		{
			eval(dom1+thisField+dom2+".value = '"+thisDefault+"'");
			eval(dom1+thisField+dom2+".className = 'unfilledForm'");
		}
	}
}



//  ######################################
//  #  functions for form interaction
//  ######################################

function formFocus(thisID)
{
	eval("currentValue = "+dom1+thisID+dom2+".value");
	if (currentValue == inputDefault[inputID[thisID]])
	{
		eval(dom1+thisID+dom2+".value = ''");
	}
	eval(dom1+thisID+dom2+".className = 'filledForm'");
}

function formBlur(thisID)
{
	eval("currentValue = "+dom1+thisID+dom2+".value");
	if ((currentValue == null) || (currentValue == ""))
	{
		eval(dom1+thisID+dom2+".value = '"+inputDefault[inputID[thisID]]+"'");
		eval(dom1+thisID+dom2+".className = 'unfilledForm'");
	}
}



//  ######################################
//  #  form submission check
//  ######################################

otherErrors = "";

function formValidate(thisForm)
{
	errors = "";
	if (checkToday)
	{
		selectedYear = document.forms[thisForm].elements[checkTodayYear].value;
		selectedMonth = document.forms[thisForm].elements[checkTodayMonth].value-1;
		selectedDay = document.forms[thisForm].elements[checkTodayDay].value;
		selectedDate = new Date(selectedYear,selectedMonth,selectedDay,0,0,0,0);
		nowDate = new Date();
		if ((selectedDate - nowDate) < 0)
		{
			errors += "'Date to Start' must be no sooner than tomorrow, "
		}
	}
	for (loop = 0; loop < inputName.length; loop++)
	{
		if (inputRequired[loop] == 1)
		{
			if (inputName[loop].charAt(0) == "-")
			{
				tempArg = inputName[loop].substring(1);
				whichIndex = document.forms[thisForm].elements[tempArg].selectedIndex;
				testValue = document.forms[thisForm].elements[tempArg].options[whichIndex].value;
			} else {
				testValue = document.forms[thisForm].elements[inputName[loop]].value;
			}
			if ((testValue == inputDefault[loop]) || (testValue == "") || (testValue == " ") || (testValue == null))
			{
				errors += inputError[loop]+", ";
			}
		}
	}
	errors = otherErrors+errors;
	if (errors == "")
	{
		for (loop = 0; loop < inputName.length; loop++)
		{
			if (inputName[loop].charAt(0) != "-")
			{
				testValue = document.forms[thisForm].elements[inputName[loop]].value;
				if (testValue == inputDefault[loop])
				{
					document.forms[thisForm].elements[inputName[loop]].value = "";
				}
			}
		}
		document.forms[thisForm].submit();
	} else {
		errors = errors.slice(0,-2);
		alert('Please provide the following required information:\r\r'+errors);
		return false;
	}
}



//  ######################################
//  #  form reset
//  ######################################

function formReset(thisForm)
{
	for (loop = 0; loop < inputName.length; loop++)
	{
		if (inputName[loop].charAt(0) == "-")
		{
			tempArg = inputName[loop].substring(1);
			document.forms[thisForm].elements[tempArg].selectedIndex = 0;
		} else {
			eval(dom1+inputName[loop]+dom2+".className = 'unfilledForm'");
			eval(dom1+inputName[loop]+dom2+".value = '"+inputDefault[loop]+"'");
		}
	}
}

//  ######################################
//  #  today dropdown check
//  ######################################

checkToday = false;
checkTodayMonth = false;
checkTodayDay = false;
checkTodayYear = false;

function todayCheck(year,month,day)
{
	checkToday = true;
	checkTodayMonth = month;
	checkTodayDay = day;
	checkTodayYear = year;
}

function formElementFocus(thisID,defaultValue)
{
	eval("currentValue = "+dom1+thisID+dom2+".value");
	if (currentValue == defaultValue)
	{
		eval(dom1+thisID+dom2+".value = ''");
		eval(dom1+thisID+dom2+".className = 'filledForm'");
	}
}

function formElementBlur(thisID,defaultValue)
{
	eval("currentValue = "+dom1+thisID+dom2+".value");
	if ((currentValue == null) || (currentValue == ""))
	{
		eval(dom1+thisID+dom2+".value = defaultValue");
		eval(dom1+thisID+dom2+".className = 'unfilledForm'");
	}
}


 function PopUp(url, Hor, Vrt){
  var now = new Date()
     var hours = now.getHours()
     var minutes = now.getMinutes()
     var seconds = now.getSeconds()
  var NameOfWin = hours*minutes*seconds*Hor*Vrt
  msgWindow = window.open(url, NameOfWin,"resizable=yes,width="+Hor+",height="+Vrt+", status=no,location=no,toolbar=no,menubar=no,directories=no,scrollbars=no,screenX=0,screenY=0");
   msgWindow.focus();
         }