/* Version: 1.1 */
/* whatDay returns the day we are on. 0 = PreEvent
   This needs to be updated daily to keep the site accurate */
function whatDay(){
	return 5;
}
/* whatRound also help us keep track of the current round
   number in a single place.
   1 through 4 are obvious
   Quarters = 5
   Semis = 6
   Final = 7    */
function whatRound(){
	return 7;
}
function currentRound(){
	return 7;
}
function whatRoundPage(){
	var myRound = whatRound();
	if (myRound < 1) myRound = 1;
	if (myRound < 5) return 'mr' + myRound + '.asp';
	if (myRound == 5) return 'mqf.asp';
	if (myRound == 6) return 'msf.asp';
	return 'mfi.asp';
}

/*  writeResults writes links to the doc depending on what round we are on */
function writeResults(){
	var myRound = whatRound();
	if (myRound == 0) {
		document.write('<b>No Results Yet</b>');
	}
	if (myRound >= 1){
		document.write('<a href="results.asp?view=round&feed=1">Round 1</a>');
	}
	if (myRound >= 2){
		document.write('<a href="results.asp?view=round&feed=2">Round 2</a>');
	}
	if (myRound >= 2){
		document.write('<a href="results.asp?view=round&feed=3">Round 3</a>');
	}
	if (myRound >= 2){
		document.write('<a href="results.asp?view=round&feed=4">Round 4</a>');
	}
	if (myRound >= 2){
		document.write('<a href="results.asp?view=round&feed=5">Quarter Final</a>');
	}
	if (myRound >= 2){
		document.write('<a href="results.asp?view=round&feed=6">Semi Final</a>');
	}
	if (myRound >= 2){
		document.write('<a href="results.asp?view=round&feed=7">Final</a>');
	}
}

/*  writeHead2Head writes links to the doc depending on what round we are on */
function writeHead2Head(){
	var myRound = whatRound();
	if (myRound <= 1) {
		document.write('<b>Head To Head Will<br>Start in Round Two</b>');
	}
	if (myRound >= 2){
		document.write('<a href="results.asp?view=h2h&feed=2">Men\'s Round 2</a>');
	}
	if (myRound >= 3){
		document.write('<a href="results.asp?view=h2h&feed=3">Men\'s Round 3</a>');
	}
	if (myRound >= 4){
		document.write('<a href="results.asp?view=h2h&feed=4">Men\'s Round 4</a>');
	}
	if (myRound >= 5){
		document.write('<a href="results.asp?view=h2h&feed=5">Men\'s Quarter Final</a>');
	}
	if (myRound >= 6){
		document.write('<a href="results.asp?view=h2h&feed=6">Men\'s Semi-Final</a>');
	}
	if (myRound >= 7){
		document.write('<a href="results.asp?view=h2h&feed=7">Men\'s Final</a>');
	}
	
}
/* use the param reader to decide what should be shown in the main content area */
/* v1.5: updated to make is possible to set parameters from the call instead of relying on the url
	now able to change the default display page from the js call */
function writeResultsBody(){
	document.write('<iframe id="results_feed" width="520" height="750" scrolling="auto" frameborder="0" marginheight="0" marginwidth="0" allowtransparency="true" onload="insertResultsCSS()" style="display:none" src="'); //now procede to determin the source
	var myShow = paramReader('view');
	var myFeed = paramReader('feed');
	if (!myShow){
		myShow = arguments[0];
		if (arguments[1] == 'day') myFeed = whatDay();
		else if (arguments[1] == 'round') myFeed = currentRound();
		else myFeed = arguments[1];
	}
	if (myShow == 'round'){
		if (myFeed == '1'){
			document.write('http://www.beachbyte.com/live08/trestles08/mr1.asp');
		}
		else if (myFeed == '2'){
			document.write('http://www.beachbyte.com/live08/trestles08/mr2.asp');
		}
		else if (myFeed == '3'){
			document.write('http://www.beachbyte.com/live08/trestles08/mr3.asp');
		}
		else if (myFeed == '4'){
			document.write('http://www.beachbyte.com/live08/trestles08/mr4.asp');
		}
		else if (myFeed == '5'){
			document.write('http://www.beachbyte.com/live08/trestles08/mqf.asp');
		}
		else if (myFeed == '6'){
			document.write('http://www.beachbyte.com/live08/trestles08/msf.asp');
		}
		else if (myFeed == '7'){
			document.write('http://www.beachbyte.com/live08/trestles08/mfi.asp');
		}
	}
	else if (myShow == 'h2h'){
		if (!myFeed) myFeed = whatRound();
		document.write('http://64.78.18.131/live/trestles08/Show_HH.asp?rRound=' + myFeed);
	}
	else if (myShow == 'stats'){
		if (myFeed == 'event'){
			document.write('http://www.beachbyte.com/live08/trestles08/event.asp');  //  GOOD
		}
		else if (myFeed == 'daily'){
			document.write('http://www.beachbyte.com/live08/trestles08/daily.asp');  // GOOD
		}
	}
	else if (myShow == 'details'){
		document.write('http://64.78.18.131/live/trestles08/1Show_HH.asp?rEvent=trestles08&rCode=' + myFeed);
	}
	document.write('"></iframe>');//end the script write
}
/* use the param reader to decide how many photo-day links should be shown */
function writePhotoLinks(){
	document.write('<span style="font-size:15px;color:white; font-weight:bold; margin-left:15px">SHOW FROM DAY:</span> ');
	var myDay = whatDay();
	if (myDay > 0){
		document.write('<img style="border:none; position: relative; top: 5px;" src="images/vr_separator.gif" height="20px" width="1px"> ');
	}
	if (myDay >= 7){
		document.write('<a href="photos.asp?rday=7" class="day_link">7</a> <img style="border:none; position: relative; top: 5px;" src="images/vr_separator.gif" height="20px" width="1px"> ');
	}
	if (myDay >= 6){
		document.write('<a href="photos.asp?rday=6" class="day_link">6</a> <img style="border:none; position: relative; top: 5px;" src="images/vr_separator.gif" height="20px" width="1px"> ');
	}
	if (myDay >= 5){
		document.write('<a href="photos.asp?rday=5" class="day_link">5</a> <img style="border:none; position: relative; top: 5px;" src="images/vr_separator.gif" height="20px" width="1px"> ');
	}
	if (myDay >= 4){
		document.write('<a href="photos.asp?rday=4" class="day_link">4</a> <img style="border:none; position: relative; top: 5px;" src="images/vr_separator.gif" height="20px" width="1px"> ');
	}
	if (myDay >= 3){
		document.write('<a href="photos.asp?rday=3" class="day_link">3</a> <img style="border:none; position: relative; top: 5px;" src="images/vr_separator.gif" height="20px" width="1px"> ');
	}
	if (myDay >= 2){
		document.write('<a href="photos.asp?rday=2" class="day_link">2</a> <img style="border:none; position: relative; top: 5px;" src="images/vr_separator.gif" height="20px" width="1px"> ');
	}
	if (myDay >= 1){
		document.write('<a href="photos.asp?rday=1" class="day_link">1</a> <img style="border:none; position: relative; top: 5px;" src="images/vr_separator.gif" height="20px" width="1px"> ');
	}
	document.write('<a href="photos.asp?rday=0" class="day_link">PRE-EVENT</a> <img style="border:none; position: relative; top: 5px;" src="images/vr_separator.gif" height="20px" width="1px"> ');
	document.write('<a href="photos.asp?rday=15" class="day_link">BOOST PIX</a><div style="height:5px"></div>');
}
/* use the param reader to decide how many video-day links should be shown */
function writeVideoLinks(){
	document.write('<span style="font-size:15px;color:white; font-weight:bold; margin-left: 15px">SHOW FROM DAY:</span> ');
	var myDay = whatDay();
	if (myDay > 0){
		document.write('<img style="border:none; position: relative; top: 5px;" src="images/vr_separator.gif" height="20px" width="1px"> ');
	}
	if (myDay >= 7){
		document.write('<a href="videos.asp?rday=7" class="day_link">7</a> <img style="border:none; position: relative; top: 5px;" src="images/vr_separator.gif" height="20px" width="1px"> ');
	}
	if (myDay >= 6){
		document.write('<a href="videos.asp?rday=6" class="day_link">6</a> <img style="border:none; position: relative; top: 5px;" src="images/vr_separator.gif" height="20px" width="1px"> ');
	}
	if (myDay >= 5){
		document.write('<a href="videos.asp?rday=5" class="day_link">5</a> <img style="border:none; position: relative; top: 5px;" src="images/vr_separator.gif" height="20px" width="1px"> ');
	}
	if (myDay >= 4){
		document.write('<a href="videos.asp?rday=4" class="day_link">4</a> <img style="border:none; position: relative; top: 5px;" src="images/vr_separator.gif" height="20px" width="1px"> ');
	}
	if (myDay >= 3){
		document.write('<a href="videos.asp?rday=3" class="day_link">3</a> <img style="border:none; position: relative; top: 5px;" src="images/vr_separator.gif" height="20px" width="1px"> ');
	}
	if (myDay >= 2){
		document.write('<a href="videos.asp?rday=2" class="day_link">2</a> <img style="border:none; position: relative; top: 5px;" src="images/vr_separator.gif" height="20px" width="1px"> ');
	}
	if (myDay >= 1){
		document.write('<a href="videos.asp?rday=1" class="day_link"">1</a> <img style="border:none; position: relative; top: 5px;" src="images/vr_separator.gif" height="20px" width="1px"> ');
	}
	document.write('<a href="videos.asp?rday=0" class="day_link">PRE-EVENT</a>');
}