// JavaScript Document
 if (GBrowserIsCompatible()) {
  map = new GMap(document.getElementById("map"));
  map.addControl(new GLargeMapControl());
  map.addControl(new GMapTypeControl());
  
}
function virtualTourSelected(obj){
	var value = obj.value;
	//if(window.XMLHttpRequest) {
  //  	window.location.href="movingMap1.php?trailName="+value;	
    // branch for IE/Windows ActiveX version
   // } else if(window.ActiveXObject) {
		var params = value.split(":");
		var trailName = params[0];
		var trailPos = params[1];
		var orientation = FRONT;
		if(params.length == 3){
			orientation = params[2];
		}
		moveToLocation(trailName, trailPos, orientation, INCREMENT, STRAIGHT);
	//}
}

function changeTrailListener(trailName, trailPos){
	var obj = document.getElementById("trail");
	
	if(obj.value.substring(0, trailName.length) == trailName){
		return;
	}
	
	for(i = 0; i < obj.options.length; i++){
		var optionTrailName = obj.options[i].value.substring(0, obj.options[i].value.indexOf(':'));
		if(optionTrailName == trailName){		
			obj.selectedIndex = i;
			break;
		}
	}
}

function updateAds(fileName){
	var keywords = document.getElementById("keywords").innerHTML.split(',');
	//var newKeyword = "";
	//if(keywords.length > 1){
		//newKeyword = keywords[0];
		//newKeyword = replace(' ', newKeyword, '+');
		//window.frames['Ad1_frame'].location.replace("clorTopAd.php?keyword=" + escape(newKeyword));
	//}else if(firstLoad){
		//window.frames['Ad1_frame'].location.replace("clorTopAd.php?keyword=New+York");
		//firstLoad = false;
	//}
	
	
	//var html = document.getElementById("allFeedsAd").innerHTML;
	//document.getElementById("allFeedsAd").innerHTML = html;
	
	//window.frames['Ad2_frame'].location.replace(fileName + "_ad2.htm");
	//window.frames['Ad3_frame'].location.replace(fileName + "_ad3.htm");
	//loadAd(fileName + "_ad1.htm", processAd1, Ad1Request);
	//loadAd(fileName + "_ad2.htm", processAd2, Ad2Request);
	//loadAd(fileName + "_ad3.htm", processAd3, Ad3Request);
}

function switchMode(mode){
	document.getElementById("virtualPhoto").innerHTML="";
	if(mode== 'large'){
		document.getElementById("topBorder").style.backgroundImage="url(images/corners/TopBorder_lg.gif)";
		document.getElementById("bottomBorder").style.backgroundImage="url(images/corners/bottomBorder_lg.gif)";
		document.getElementById("virtualPhotoTable").width=848;
		document.getElementById("virtualPhoto").width=811;
		document.getElementById("dashboard").width=1244;
		document.getElementById("topBorder").width=1244;
		document.getElementById("bottomBorder").width=1244;
		document.getElementById("rightShadow").height=596;
		document.getElementById("descriptionTable").height=381;
		document.getElementById("descriptionText").style.height='320px';
		document.getElementById("descriptionTable").style.backgroundImage="url(images/description_bg_lg.jpg)";
		document.getElementById("rightShadow").src="images/image_right_shadow_lg.jpg";
		document.getElementById("navToolbar").style.backgroundImage="url(images/nav_toolbar_lg.jpg)";
		document.getElementById("btnLarge").src="images/btnLarge_sel.jpg";
		document.getElementById("btnNormal").src="images/btnNormal.jpg";
	}else{
		document.getElementById("topBorder").style.backgroundImage="url(images/corners/TopBorder.gif)";
		document.getElementById("bottomBorder").style.backgroundImage="url(images/corners/bottomBorder.gif)";
		document.getElementById("virtualPhotoTable").width=585;
		document.getElementById("virtualPhoto").width=548;
		document.getElementById("dashboard").width=981;
		document.getElementById("topBorder").width=981;
		document.getElementById("bottomBorder").width=981;
		document.getElementById("rightShadow").height=410;
		document.getElementById("descriptionTable").height=221;
		document.getElementById("descriptionText").style.height='165px';
		document.getElementById("descriptionTable").style.backgroundImage="url(images/description_bg.jpg)";
		document.getElementById("rightShadow").src="images/image_right_shadow.jpg";
		document.getElementById("navToolbar").style.backgroundImage = "url(images/nav_toolbar.jpg)";
		document.getElementById("btnLarge").src="images/btnLarge.jpg";
		document.getElementById("btnNormal").src="images/btnNormal_sel.jpg";
	}
	updateVirtualPanel();
}
	

function editDescription(){
	var url = 'editDescription.php?';
	url = url + 'trailId=' + trailState.route.trailId;
	url = url + '&direction=' + trailState.direction;
	url = url + '&orientation=' + trailState.orientation;
	url = url + '&point=' + trailState.currentPoint;
	url = url + '&sequence=' + trailState.route.getTrailPoint(trailState.currentPoint).sequence;
	window.open(url, "_blank", "width=910,height=600,resizable=yes");
}

function addReview(){
	var url = 'addReview.php?';
	url = url + 'trailId=' + trailState.route.trailId;
	url = url + '&direction=' + trailState.direction;
	url = url + '&orientation=' + trailState.orientation;
	url = url + '&point=' + trailState.currentPoint;
	url = url + '&sequence=' + trailState.route.getTrailPoint(trailState.currentPoint).sequence;
	window.open(url, "_blank", "width=910,height=600,resizable=yes");
} 


function generalUpdateListener(){
	
	if(urlFixer == null){
		
		urlFixer = getAjaxUrlFixer();
		urlFixer.linkIds[0] = "cell1_href";
		urlFixer.linkIds[1] = "cell2_href";
		urlFixer.linkIds[2] = "cell3_href";
		urlFixer.linkIds[3] = "cell4_href";
		urlFixer.linkIds[4] = "cell5_href";
		urlFixer.linkIds[5] = "cell6_href";
		urlFixer.linkIds[6] = "cell7_href";
		urlFixer.linkIds[7] = "cell8_href";
		urlFixer.linkIds[8] = "cell9_href";
		urlFixer.fixLinks();
		urlFixer.startTimer();
	}else{
		urlFixer.fixLinks();
	}
}