//Instructions
//Feature No.: contains 'info' for specific feature vehicles, fill out accordingly
//
//Feature Names & Layout: displays the layout of the features on the home page.
//
//Features To Use: All usingFeatures[0-x] will be used.
//	 When using "template_std(x)" a 'Feature No.' must be used, in place of 'x'.


//Features To Use
var usingFeatures = new Array();
	usingFeatures[0] = "template_ttvid()";
	usingFeatures[1] = "template_vtrn()";
	usingFeatures[2] = "template_mfrs()";
	usingFeatures[3] = "template_std(0)";
	usingFeatures[4] = "template_std(1)";
	usingFeatures[5] = "template_std(2)";
	
var availFeatureLocations = 6;

//Feature No. (0-x)
var Features = new Array();
Features[0] = new Array();
Features[0][0] = "2006 Krystal Bus";
Features[0][1] = "28 Passenger";
Features[0][2] = "sale price: $59,500";
Features[0][3] = "../features/media/03998.jpg";
Features[0][4] = "http://www.tescobus.com/search.aspx?UserRestriction=03998";
Features[1] = new Array();
Features[1][0] = "2009 Girardin MB-I";
Features[1][1] = "14 passenger";
Features[1][2] = "lease for $559/mo";
Features[1][3] = "../features/media/927393.jpg";
Features[1][4] = "http://www.tescobus.com/search.aspx?UserRestriction=927393";
Features[2] = new Array();
Features[2][0] = "2009 Turtle Top VanTerra";
Features[2][1] = "14 Passenger";
Features[2][2] = "sale price: $49,900";
Features[2][3] = "../features/media/394506.jpg";
Features[2][4] = "http://www.tescobus.com/search.aspx?UserRestriction=394506";
Features[3] = new Array();
Features[3][0] = "2003 Goshen Coach";
Features[3][1] = "24 Passenger";
Features[3][2] = "sale price: $29,750";
Features[3][3] = "../features/media/04003-1c.jpg";
Features[3][4] = "http://www.tescobus.com/search.aspx?UserRestriction=04003";


//Feature Names & Layout
//////////////////////////////
///[feature1]	[feature2]////
///[feature3]	[feature4]////
///[feature5]	[feature6]////
//////////////////////////////

function getFeatures()
{	
	//used to keep track of locations already being used
	var usedFeatureLocations = new Array();
	//randomly grab a feature location
	var ranNum = Math.ceil(Math.random() * availFeatureLocations);
	
	//used to keep track of features being used
	var usedAvailableFeatures = new Array();
	//randomly grab a feature
	var ranAvailableFeature = Math.ceil(Math.random() * usingFeatures.length);

	for(i=1;i<=availFeatureLocations;i++)
	{
		//check that feature wasn't used
		while(contains(usedAvailableFeatures,ranAvailableFeature))
		{
			ranAvailableFeature = Math.ceil(Math.random() * usingFeatures.length);			
		}
		usedAvailableFeatures.push(ranAvailableFeature);
		//check that location wasn't used
		while(contains(usedFeatureLocations,ranNum))
		{
			ranNum = Math.ceil(Math.random() * availFeatureLocations);
			
		}
		usedFeatureLocations.push(ranNum);
		
		var divFeatures = document.getElementById("feature"+ranNum);		
		divFeatures.innerHTML = eval(usingFeatures[ranAvailableFeature-1]);			
	}	
}

function contains(obj, search)
{		
	for( y in obj )
	{		
		if(obj[y] == search){
		return true;
		}
	}
	return false;	
}

function template_std(f_no)
{	
	var sTemplate = "<table border='0' cellpadding='0' cellspacing='0'>";
	sTemplate += "<tr>";
	sTemplate += "<td background='media/feature_topleft.png' width='9'><img src='media/spacer.gif' width='9' height='9' border='0'></td><td background='media/feature_top.png'><img src='media/spacer.gif' width='130' height='9' border='0'></td><td background='media/feature_topright.png' width='10'><img src='media/spacer.gif' width='10' height='9' border='0'></td>";
	sTemplate += "</tr><tr>";
	sTemplate += "<td background='media/feature_left.png' width='9' rowspan='2'><img src='media/spacer.gif' width='9' height='164' border='0'></td><td background='media/feature_body.png' valign='top'><a href='"+Features[f_no][4]+"'><img src='"+Features[f_no][3]+"' width='128' height='96' border='1' style='border-color:#FFFFFF'></a></td><td background='media/feature_right.png' width='10' rowspan='2'><img src='media/spacer.gif' width='10' height='164' border='0'></td>";
	sTemplate += "</tr><tr>";
	sTemplate += "<td background='../media/feature_body.png' valign='top'><a href='"+Features[f_no][4]+"'><span class='home_body'><b>"+Features[f_no][0]+"</b><br>"+Features[f_no][1]+"<br>"+Features[f_no][2]+"<br>view details</span></a></td>";
	sTemplate += "</tr><tr>";
	sTemplate += "<td background='media/feature_bottomleft.png' width='9'><img src='media/spacer.gif' width='9' height='10' border='0'></td><td background='media/feature_bottom.png'><img src='media/spacer.gif' width='130' height='10' border='0'></td><td background='media/feature_bottomright.png' width='10'><img src='media/spacer.gif' width='10' height='10' border='0'></td>";
	sTemplate += "</tr></table>";
	
	return sTemplate;
}

function template_mfrs()
{	
	var sTemplate = "<table border='0' cellpadding='0' cellspacing='0'>";
	sTemplate += "<tr>";
	sTemplate += "<td background='../media/feature_topleft.png' width='9'><img src='../media/spacer.gif' width='9' height='9' border='0'></td><td background='../media/feature_top.png'><img src='../media/spacer.gif' width='130' height='9' border='0'></td><td background='../media/feature_topright.png' width='10'><img src='../media/spacer.gif' width='10' height='9' border='0'></td>";
	sTemplate += "</tr><tr>";
	sTemplate += "<td background='../media/feature_left.png' width='9'><img src='../media/spacer.gif' width='9' height='164' border='0'></td><td background='../media/feature_body.png' valign='top'><img src='/features/media/mfr_logos2.jpg' width='130' height='164' style='border-color:#FFFFFF' usemap='#mfr_logosf550b76' border='0'></td><td background='../media/feature_right.png' width='10'><img src='../media/spacer.gif' width='10' height='164' border='0'></td>";
	sTemplate += "</tr><tr>";
	sTemplate += "<td background='../media/feature_bottomleft.png' width='9'><img src='../media/spacer.gif' width='9' height='10' border='0'></td><td background='../media/feature_bottom.png'><img src='../media/spacer.gif' width='130' height='10' border='0'></td><td background='../media/feature_bottomright.png' width='10'><img src='../media/spacer.gif' width='10' height='10' border='0'></td>";	
	sTemplate += "</tr></table><map name='mfr_logosf550b76'><area shape='rect' coords='44,144,128,159' href='http://www.tescobus.com/bus/goshen/goshen.html' alt='Goshen Coach Bus Manufacturer'><area shape='rect' coords='79,89,121,113' href='http://www.tescobus.com/bus/elkhart/ecii.html' alt='Elkhart Coach Bus Manufacturer'><area shape='rect' coords='45,47,90,77' href='http://www.tescobus.com/bus/girardin/girardin.html' alt='Girardin Bus Manufacturer'><area shape='rect' coords='3,114,74,127' href='http://www.tescobus.com/bus/mobilityworks/van.html' alt='MobilityWorks Bus Manufacturer'><area shape='rect' coords='5,133,32,162' href='http://www.tescobus.com/bus/braun/braun.html' alt='Braun Bus Manufacturer'><area shape='circle' coords='110,64,14' alt='Federal Coach Bus Manufacturer' href='http://www.tescobus.com/bus/federal_coach/federal_coach.html'><area shape='rect' coords='7,18,65,41' alt='Arboc Mobility Bus Manufacturer' href='http://www.tescobus.com/bus/arboc_mobility/spirit_of_mobility.html'><area shape='rect' coords='73,124,126,141' href='http://www.tescobus.com/bus/turtletop/turtletop.html' alt='Turtle Top Bus Manufacturer'><area shape='rect' coords='5,52,40,78' href='http://www.tescobus.com/bus/collins/collins.html' alt='Collins/MidBus Bus Manufacturer'><area shape='rect' coords='71,17,127,43' href='http://www.tescobus.com/bus/eldorado_national/eldorado_national.html' alt='ElDorado National - California Bus Manufacturer'><area shape='rect' coords='6,88,72,108' href='http://www.tescobus.com/bus/ameritrans/ameritrans.html' alt='Ameritrans Bus Manufacturer'></map>";
	
	return sTemplate;
}

function template_vtrn()
{	
	var sTemplate = "<table border='0' cellpadding='0' cellspacing='0' width='150'>";
	sTemplate += "<tr>";
	sTemplate += "<td background='../media/feature_topleft.png' width='9'><img src='../media/spacer.gif' width='9' height='9' border='0'></td><td background='../media/feature_top.png'><img src='../media/spacer.gif' width='130' height='9' border='0'></td><td background='../media/feature_topright.png' width='10'><img src='../media/spacer.gif' width='10' height='9' border='0'></td>";
	sTemplate += "</tr><tr>";
	sTemplate += "<td background='../media/feature_left.png' width='9' rowspan='2'><img src='../media/spacer.gif' width='9' height='164' border='0'></td><td background='features/media/veteran2.jpg' valign='bottom' rowspan='2' ><div align='center'><b><span class='home_body'>Officially recognized<br /></span></b><b><span class='home_body'>as a veteran<br /></span></b><b><span class='home_body'>owned company</b><br />&nbsp</span></div></td><td background='../media/feature_right.png' width='10' rowspan='2'><img src='../media/spacer.gif' width='10' height='164' border='0'></td>";
	sTemplate += "</tr><tr></tr><tr>";
	sTemplate += "<td background='../media/feature_bottomleft.png' width='9'><img src='../media/spacer.gif' width='9' height='10' border='0'></td><td background='../media/feature_bottom.png'><img src='../media/spacer.gif' width='130' height='10' border='0'></td><td background='../media/feature_bottomright.png' width='10'><img src='../media/spacer.gif' width='10' height='10' border='0'></td>";
	sTemplate += "</tr></table>";
	
	return sTemplate;
}

function template_limo()
{	
	var sTemplate = "<table border='0' cellpadding='0' cellspacing='0' width='150'>";
	sTemplate += "<tr>";
	sTemplate += "<td background='../media/feature_topleft.png' width='9'><img src='../media/spacer.gif' width='9' height='9' border='0'></td><td background='../media/feature_top.png'><img src='../media/spacer.gif' width='130' height='9' border='0'></td><td background='../media/feature_topright.png' width='10'><img src='../media/spacer.gif' width='10' height='9' border='0'></td>";
	sTemplate += "</tr><tr>";
	sTemplate += "<td background='../media/feature_left.png' width='9' rowspan='2'><img src='../media/spacer.gif' width='9' height='164' border='0'></td><td background='../media/feature_body.png' valign='top' rowspan='2'><A HREF='http://www.tescobus.com/promo/2008_closeout.html'><img src='features/media/2008_closeout.gif' border='0'></A></td><td background='../media/feature_right.png' width='10' rowspan='2'><img src='../media/spacer.gif' width='10' height='164' border='0'></td>";
	sTemplate += "</tr><tr></tr><tr>";
	sTemplate += "<td background='../media/feature_bottomleft.png' width='9'><img src='../media/spacer.gif' width='9' height='10' border='0'></td><td background='../media/feature_bottom.png'><img src='../media/spacer.gif' width='130' height='10' border='0'></td><td background='../media/feature_bottomright.png' width='10'><img src='../media/spacer.gif' width='10' height='10' border='0'></td>";
	sTemplate += "</tr></table>";
	
	return sTemplate;
}

function template_ttvid()
{	
	var sTemplate = "<table border='0' cellpadding='0' cellspacing='0'>";
	sTemplate += "<tr>";
	sTemplate += "<td background='../media/feature_topleft.png' width='9'><img src='../media/spacer.gif' width='9' height='9' border='0'></td><td background='../media/feature_top.png'><img src='../media/spacer.gif' width='130' height='9' border='0'></td><td background='../media/feature_topright.png' width='10'><img src='../media/spacer.gif' width='10' height='9' border='0'></td>";
	sTemplate += "</tr><tr>";
	sTemplate += "<td background='../media/feature_left.png' width='9'><img src='../media/spacer.gif' width='9' height='164' border='0'></td><td background='../media/feature_body.png' valign='top'><a href='http://www.tescobus.com/pages/turtletopvideo.html'><img src='/features/media/TT_Video2.jpg' width='130' height='164' style='border-color:#FFFFFF' border='0'></a></td><td background='../media/feature_right.png' width='10'><img src='../media/spacer.gif' width='10' height='164' border='0'></td>";
	sTemplate += "</tr><tr>";
	sTemplate += "<td background='../media/feature_bottomleft.png' width='9'><img src='../media/spacer.gif' width='9' height='10' border='0'></td><td background='../media/feature_bottom.png'><img src='../media/spacer.gif' width='130' height='10' border='0'></td><td background='../media/feature_bottomright.png' width='10'><img src='../media/spacer.gif' width='10' height='10' border='0'></td>";
	sTemplate += "</tr></table>";
	
	return sTemplate;
}

function template_ttvid_notused()
{	
	var sTemplate = "<table border='0' cellpadding='0' cellspacing='0' width='150'>";
	sTemplate += "<tr>";
	sTemplate += "<td background='../media/feature_topleft.png' width='9'><img src='../media/spacer.gif' width='9' height='9' border='0'></td><td background='../media/feature_top.png'><img src='../media/spacer.gif' width='130' height='9' border='0'></td><td background='../media/feature_topright.png' width='10'><img src='../media/spacer.gif' width='10' height='9' border='0'></td>";
	sTemplate += "</tr><tr>";
	sTemplate += "<td background='../media/feature_left.png' width='9' rowspan='2'><img src='../media/spacer.gif' width='9' height='164' border='0'></td><td background='features/media/tt_video.jpg' valign='bottom' rowspan='2' ><a href='http://www.tescobus.com/pages/turtletopvideo.html'><div align='center'><b><span class='home_body'>Check out the<br /></span></b><b><span class='home_body'>Turtle Top video</b><br />&nbsp<br /></span></a></div></td><td background='../media/feature_right.png' width='10' rowspan='2'><img src='../media/spacer.gif' width='10' height='164' border='0'></td>";
	sTemplate += "</tr><tr></tr><tr>";
	sTemplate += "<td background='../media/feature_bottomleft.png' width='9'><img src='../media/spacer.gif' width='9' height='10' border='0'></td><td background='../media/feature_bottom.png'><img src='../media/spacer.gif' width='130' height='10' border='0'></td><td background='../media/feature_bottomright.png' width='10'><img src='../media/spacer.gif' width='10' height='10' border='0'></td>";
	sTemplate += "</tr></table>";
	
	return sTemplate;
}

