var dateObj = new Date();
var curTime = addZero_func(dateObj.getHours(),2)+""+addZero_func(dateObj.getMinutes(),2);
var curYear = dateObj.getFullYear();
var curDate = dateObj.getDate();
var curMonth = dateObj.getMonth()+1; //Add 1 to get it in format 1-12, javascript uses 0-11

function setStyle_func(obj, stylevar, styleval){
	if (navigator.userAgent.toLowerCase().indexOf("msie") > -1){
		obj.style[stylevar]=styleval;
	} else {
		obj.style[stylevar]=styleval;
	}
}

function init_func(){	
	navObjs = document.getElementsByTagName("a")
	navL = navObjs.length;
	for(i=0;i<navL;i++){
		if (navObjs[i].className == "anav"){
			navObjs[i].onmouseover = navOver_func;
			navObjs[i].onmouseout = navOut_func;
		} else if (navObjs[i].className == "subnav"){
			navObjs[i].onmouseover = subnavOver_func;
			navObjs[i].onmouseout = subnavOut_func;		
		}
	}
	//setDateTime_func(curYear+""+addZero_func(curMonth,2)+""+addZero_func(curDate,2), curTime, document.forms.tfljp);
}

function navOver_func(){
	setStyle_func(this, 'background', '#'+this.id);
}

function navOut_func(){
	setStyle_func(this, 'background', '#B2B2B2');
}

function subnavOver_func(){
	setStyle_func(this, 'color', pgColor);
}

function subnavOut_func(){
	setStyle_func(this, 'color', '#B2B2B2');
}

function showDepDetails_func(selObj){
	if (selObj.value.length > 0){
		loc = location.href.split("?")
		if (loc.length < 1){
			location.href=location.href+"?depart="+selObj.value
		} else {
			location.href=loc[0]+"?depart="+selObj.value
		}
	}
}

function keyEnter_func(e, form) {	
	if (e.keyCode && e.keyCode == 13){	
		return true;
	} else {
		return false;
	}
}

function txtfocus_func(txtobj){
	if (txtobj.init == undefined){
		txtobj.init=1;
		txtobj.value="";
	}
}


// *** TFL JOURNEY PLANNER FUNCTIONS ***
function submitfrm_func(frm){
	frm.target="_blank";
	frm.action="http://www.journeyplanner.org/user/XSLT_TRIP_REQUEST2";
	frm.submit();
}

function setDateTime_func(dateVal, TimeVal, frm){ // dateVal must be in format yyyymmdd
	frm.itdDate.value = dateVal;
	frm.itdTime.value = TimeVal;
}

function OpenBrWindow(url, wname, topleft, fullscreen, appw, apph, scroll) {
	if (fullscreen == 1){
		fscreen = "fullscreen"
	} else {
		fscreen = ""
	}
	if (topleft == 1){
		screenx = 0
		screeny = 0
	} else {
		sreenw = screen.width
		sreenh = screen.height
		screenx = (sreenw - appw)/2
		screeny = (sreenh - apph)/2
	}	
	newWin = window.open(url, wname, "toolbar=no,status=yes,"+fscreen+",scrollbars="+scroll+",resizable=yes,menubar=no,width="+appw+",height="+apph+",left="+screenx+",top="+screeny+", maximize=yes");
	return newWin;	
}

function addZero_func(no, digits){
	if (String(no).length >= Number(digits)){
		return no;
	} else {		
		no_no = Number(digits) - String(no).length
		zeros = ""
		for(p=1;p<=no_no;p++){
			zeros += "0";
		}
		return zeros+no;
	}
}

function gotoJplanner_func(to, from){
	window.open("http://www.dundeetravelinfo.com/dccweb/bin/query.exe/en?from="+from+"&to="+to)
}

function gotoWalkLeaflet_func(from, name){
	window.open("http://www.dundeetravelinfo.com/dccleaf/bin/query.exe/en?from="+from+"&enquiryName="+name);
}

function gotoCyclePlanner_func(to, from){
	window.open("http://www.dundeetravelinfo.com/dcccyclepl/bin/query.exe/en?S="+from+"&Z="+to)
}

function gotoWalkPlanner_func(to, from){
	window.open("http://www.dundeetravelinfo.com/dccwalkpl/bin/query.exe/en?S="+from+"&Z="+to)
}


function chgImg_func(imgobj, imgsrc){
	imgobj.src = imgsrc;
}

var but_go_h = new Image();
but_go_h.src = "images/but_go_h.gif";

function preloadImgs_func(arr){
	for(i=0;i<arr.length;i++){
			
	}
}