// rollover script for "how to tie a tie" page

var currentPage = "atlantic";
var currentLink = null;

/*
TIE INSTRUCTION STEP COUNT:

 3-step
	2 point
 4-step:
	 small
	 1 point
	 presidential
	 puff
	 reverse
 5-step
 	3 point
 6-step
 	atlantic
 	bow tie
 	diagonal
 	four-in-hand
 	kelvin
 	oriental
 	pratt
 	simple double
 7-step
 	persian
 8-step
 	half windsor
 	plattsburg
 	st andrew
 9-step
 	windsor

*/


var knotPages = new Array( ); 	// associative array of page-specific values
								// each return value is an Array of { stepCount }

knotPages[ '2_point' ] = { "stepCount": 3, "pdfName": "OneAndTwoPoint.pdf" };
knotPages[ 'small' ] = { "stepCount": 4, "pdfName": "Small.pdf"  };
knotPages[ '1_point' ] = { "stepCount": 4, "pdfName": "OneAndTwoPoint.pdf" };
knotPages[ 'presidential' ] = { "stepCount": 4, "pdfName": "Presidential.pdf" };
knotPages[ 'puff' ] = { "stepCount": 4, "pdfName": "PuffAndReverse.pdf" };
knotPages[ 'reverse' ] = { "stepCount": 4, "pdfName": "PuffAndReverse.pdf" };
knotPages[ '3_point' ] = { "stepCount": 5, "pdfName": "ThreePoint.pdf" };
knotPages[ 'atlantic' ] = { "stepCount": 6, "pdfName": "Atlantic.pdf" };
knotPages[ 'bow_tie' ] = { "stepCount": 6, "pdfName": "Bowtie.pdf" };
knotPages[ 'diagonal' ] = { "stepCount": 6, "pdfName": "Diagonal.pdf" };
knotPages[ 'four-in-hand' ] = { "stepCount": 6, "pdfName": "FourInTheHand.pdf" };
knotPages[ 'kelvin' ] = { "stepCount": 6, "pdfName": "Kelvin.pdf" };
knotPages[ 'oriental' ] = { "stepCount": 6, "pdfName": "Oriental.pdf" };
knotPages[ 'pratt' ] = { "stepCount": 6, "pdfName": "Pratt.pdf" };
knotPages[ 'simple_double' ] = { "stepCount": 6, "pdfName": "SimpleDouble.pdf" };
knotPages[ 'persian' ] = { "stepCount": 7, "pdfName": "Persian.pdf" };
knotPages[ 'half_windsor' ] = { "stepCount": 8, "pdfName": "HalfWindsor.pdf" };
knotPages[ 'plattsburg' ] = { "stepCount": 8, "pdfName": "Plattsburg.pdf" };
knotPages[ 'st_andrew' ] = { "stepCount": 8, "pdfName": "StAndrew.pdf" };
knotPages[ 'windsor' ] = { "stepCount": 9, "pdfName": "Windsor.pdf" };

function setKnotPage( link )
{
	var img = document.getElementById( 'KnotInstruction' );
	var stepList = document.getElementById( "TieSteps" );
	var printLink = document.getElementById( "TieaTiePrintPdf" );
	currentPage = link.innerHTML.toLowerCase( ).replace( /\ /, "_");	

	// error checking	
	if( img == null || link == null )
	{
		alert( "instruction image doesn't exist" );
		return;
	}
	
	var count = knotPages[ currentPage ][ 'stepCount' ];

	img.src = "/images/TieaTie/" + currentPage + "/" + currentPage + "01.gif";
	
	// display correct # of step images
	
	var liSet = "";
	for( var i = 1; i <= count; i++ )
	{
		var liTemp = "<li><a onMouseOver=\"setStep( " + i + " );\">";
		liTemp += "<img src=\"/images/TieaTie/step_0" + i + ".jpg\" /></a></li>\n";
		liSet += liTemp;
	}
	stepList.innerHTML = liSet;
	
	// change link hilighting
	if( currentLink != null )
	{
		currentLink.className = "";
	}
	currentLink = link;
	link.className = "selected";
	
	printLink.href = "/images/TieaTie/pdf/" + knotPages[ currentPage ][ 'pdfName' ];
}

function setStep( stepNum )
{
	var img = document.getElementById( 'KnotInstruction' );
	img.src = "/images/TieaTie/" + currentPage + "/" + currentPage + "0" + stepNum + ".gif";
}

function setupH2TaT( )
{
	currentLink = document.getElementById( "atlantic" );
	currentLink.className = "selected";
}