///////////////////////////
// Tubeplanner menu functions
// copyright Studio 24 Ltd
// www.studio24.net
//
// tech@studio24.net
///////////////////////////

function menuRoll(ID, sref) {
  	// swaps shading on TD menu elements for rollovers
	if (document.all) {
  		if (sref == "default") {
    		eval('document.all.' + ID + '.style.background="#FFFFCC"');
  		} else {
    		eval('document.all.' + ID + '.style.background="' + getColour(sref) + '"');
		}
  	} 
}

function getColour(sref) {
  	// gets tube line colour from station ref (sref)
  	switch (sref) {   
		case "central" :     
	 		return "#FF0000";       
			break;   
		case "district" :     
	 		return "#339900";       
			break;  
		case "east" :       
			return "#FFCC00";       
			break;    
		case "hammersmith" :     
	 		return "#FF99FF";       
			break;  
		case "jubilee" :       
			return "#999999";       
			break;    
		case "victoria" :     
		 	return "#66CCFF";       
			break;  
		case "waterloo" :       
			return "#33CC99";       
			break;    
		default :     
		 	// circle line 
			return "FFFF00"; 
 	}
}

function gotoURL(href) {
  	// loads up new page,so if user clicks on TD menu element link still works
  	self.location.href=href;
}

/////////////////////
// Bookmark functions
////////////////////

var bookmark_title="Tubeplanner.com - the underground journey planner for London";

function getBookmark() {
	if (navigator.appName == "Microsoft Internet Explorer") {
		var link = "javascript:addbookmark()";
	} else {
		var link = "/bookmark.shtml";
	}
	
	 // print extra table row with correct link  
	 document.write("<tr>");
     document.write("<td bgcolor=\"#FFFFCC\" class=\"mainbody\" align=\"center\" id=\"bookmark\" onMouseOver=\"menuRoll('bookmark','waterloo')\" onMouseOut=\"menuRoll('bookmark','default')\" onClick=\"gotoURL('");
	 document.write(link);
	 document.write("')\"><a href=\"");
	 document.write(link);
	 document.write("\">Bookmark page</a></td>");
     document.write("</tr>");
}

function addbookmark() {
	if (document.all) {
		window.external.AddFavorite(location.href,bookmark_title);
	}
}
