// JavaScript Document

function initNav(){
	var imgObj;	
	for(i=0;i<navImgHoverArr.length;i++){
		imgObj = new Image();
		imgObj.src = navImgHoverArr[i];
	}
}

function navOver(navImgID, srcOver){
	document.getElementById(navImgID).src=srcOver;
}
function navOut(navImgID, srcOut){
	document.getElementById(navImgID).src=srcOut;	
}

function txtboxInit(txtboxObj, initVal){
	if (txtboxObj.value == initVal){
		txtboxObj.value = '';		
	}
	if (txtboxObj.className.substr(txtboxObj.className.length-4,4) == "init"){
		//txtboxObj.className = txtboxObj.className.substr(0,txtboxObj.className.length-4);// Bug in IE
		txtboxObj.style.color='#003366';
	} else if (txtboxObj.className.substr(txtboxObj.className.length-4,4) == "warn"){
		txtboxObj.style.color='#003366';
	}
}

function setStyle_func(obj, stylevar, styleval){
	if (navigator.userAgent.toLowerCase().indexOf("msie") > -1){
		obj.style[stylevar]=styleval;
	} else {
		obj.style[stylevar]=styleval;
	}
}

function search_func(crit){
	location.href="search.asp?s="+crit;
}

// ***** JOURNEY PLANNER FUNCTIONS ******

function jpStartAgain(){	
	location.href="jplanner1.asp";
}

function gotoJPlanner(fromtxt,totxt){
	frm = document.getElementById('minijplanner');
	frm.addrfrom.value = fromtxt;
	frm.addrto.value = totxt;
	frm.submit();
}

function jpTimesEarlier(){
	location.href="jplanner3.asp?planjourney=1&earlier=1"
}

function jpTimesLater(){
	location.href="jplanner3.asp?planjourney=1&later=1"
}

function showOnMap(mode,markerID,fromOSX,fromOSY,toOSX,toOSY,txt){
	var ptFrom = OS2LatLonWGS84_func(fromOSX,fromOSY);
	ptFrom = new GLatLng(ptFrom.lat, ptFrom.lng);
	var ptTo = OS2LatLonWGS84_func(toOSX,toOSY);
	ptTo = new GLatLng(ptTo.lat, ptTo.lng);
	if (mode == "walk"){
		imageUrl = "images/mapicon_walk.png";
		lineColor = "#817bb9";
	} else if (mode == "rail"){
		imageUrl = "images/mapicon_rail.png";
		lineColor = "#67bc77";
	} else if (mode == "bus" || mode == "coach"){
		imageUrl = "images/mapicon_bus.png";
		lineColor = "#f17278";
	}
	
	map.addOverlay(new GPolyline([ptFrom, ptTo], lineColor, 6, 0.6, {geodesic:true}));
	
	// Create our marker icon
	var icon = new GIcon();
	icon.image = imageUrl
	icon.shadow = "http://labs.google.com/ridefinder/images/mm_40_shadow.png";
	icon.iconSize = new GSize(45, 47);
	//icon.shadowSize = new GSize(22, 20);
	icon.iconAnchor = new GPoint(0, 47);
	//icon.infoWindowAnchor = new GPoint(5, 1);	
	
	
	addJMarker2Map(ptFrom,16,icon,markerID,imageUrl,txt);
}