//var images="http://alpinelodge.jumpclaimer.com/images/";
var images="images/";

var mapInitActivities=false;  // hack to only init and draw google map after first time on that page  
var mapInitFindus=false;

//var menuDiv=new Array("topic1","topic2","topic3","topic4","topic5");
//var menuDivContent=new Array("mainAccom","mainFacil","mainStArnaud","mainLocation","mainGallery");  
//var menuOn=new Array("bedroom_thumb.jpg","conference_thumb.jpg","starnaud_thumb.jpg","location_thumb.gif","gallery_thumb.jpg");
//var menuOff=new Array("bedroom_grey_thumb.jpg","conference_grey_thumb.jpg","starnaud_grey_thumb.jpg","location_grey_thumb.gif","gallery_grey_thumb.jpg");

var accomDiv=new Array("accomInfo","accomRates","accomStandard","accomStandardFamily","accomSuperior","accomSelfCont","accomStudio","accomChalet");
var facilDiv=new Array("facilRestaurant","facilCafe","facilConference","facilLaundry","facilPlayground","facilSpapool");  // "facilBar" removed
var galleryDiv=new Array("gallery360","galleryArea");
var starnaudDiv=new Array("starnaudHistory","starnaudWeather","starnaudWebcam","starnaudActivities","starnaudTransport","starnaudEvents");
var swDiv=new Array("swGourmetDayWalk","swDayWalks","swTraversSabine","swNelsonLakesAdv");   // southern wilderness page


// implement slideshow on front page

var timeDelay = 12; // change delay time in seconds 
//var Pix = new Array ("images/startup/rotoitiwharf01.jpg","images/startup/starnaudview02.jpg","images/startup/fern01.jpg","images/startup/SnowyLakeMtn.jpg","images/startup/coffeetruffle01.jpg","images/startup/snowycreek04.jpg");

var Pix = new Array ("images/startup/frontdoor.jpg","images/startup/nighttime.jpg","images/startup/starnaudview03.jpg","images/startup/sepiaLake.jpg","images/startup/SnowyLakeMtn.jpg","images/startup/coffeetruffle01.jpg","images/startup/LeightsAlex01.jpg","images/startup/snowytables.jpg");

var howMany = Pix.length; 
timeDelay *= 500; 
var PicCurrentNum = 0; 

//var PicCurrent = new Image(); 
//PicCurrent.src = Pix[PicCurrentNum]; 



function startup() {
	Effect.Grow('crestimage');
	setTimeout("Effect.Appear('mainImage');", 1000); 
	setTimeout("Effect.SlideDown('slidedown')", 2000);
	//setTimeout("Effect.SlideUp('slideacross')", 1000);
	//setTimeout("document.getElementById('promoblock').style.display='block'", 1000);    // not used yet
	setTimeout("document.getElementById('topicimages').style.display='block'", 1000);
	setTimeout("document.getElementById('footer').style.display='block'", 500);
	setTimeout("Effect.Appear('booknowicon');", 2000);
	//setTimeout("Effect.Fade('mainImage')", 6000);
	//document.getElementById('mainImage').style.backgroundImage="url('images/starnaudview02.jpg')";
	//Effect.Appear('mainImage');
	startPix();  
}



function changeTitle(text) {
	if (text=="" || text==null) { text="St. Arnaud, Lake Rotoiti, Nelson Lakes National Park, New Zealand. Accommodation and Restaurant, Visitor Information and Activities."; }
	document.title = "Alpine Lodge: "+text;
}



function toggleTab(topic,id,text) {
	changeTitle(text);
	if (topic=="accomm") { topicDiv=accomDiv } else
	if (topic=="facil") { topicDiv=facilDiv } else     // maybe able to replace these arrays by dynamically DOM created ones
	if (topic=="gallery") { topicDiv=galleryDiv } else
	if (topic=="starnaud") { topicDiv=starnaudDiv } 
	//if (topic=="southernwilderness") { topicDiv=swDiv }
	for (i=0; i<topicDiv.length; i++) { 
		document.getElementById(topicDiv[i]).style.display="none";
	}
	document.getElementById(id).style.display="block";
	//Effect.Appear(id);
}



function changeBigPhoto(id,imageName,captionText,captionId) {
	//var tmp = "";
	//if(imageName.indexOf("http://")!=-1) { tmp = "url('"+imageName+"')" } else { tmp = "url('"+images+imageName+"')" } 
	//document.getElementById(id).style.backgroundImage=tmp;
	document.getElementById(id).style.backgroundImage="url('"+imageName+"')";
	document.getElementById(id).style.backgroundRepeat="no-repeat";
	
	if (captionText.length>1) {
		document.getElementById(captionId).innerHTML=captionText;
		//Effect.Appear(captionId);
		document.getElementById(captionId).style.display="block";
	} else { document.getElementById(captionId).style.display="none"; }  // clear caption strip
}


function changeData(id,text) {
	document.getElementById(id).innerHTML=text;
}


/* 
function changePage(idOn,idOff) { // currently only for gallery images
	document.getElementById(idOff).style.display="none";
	document.getElementById(idOn).style.display="block";
}
*/

function changePage(idOn) { // currently only for gallery images
	document.getElementById("galleryAreaPage1").style.display="none";
	document.getElementById("galleryAreaPage2").style.display="none";
	document.getElementById("galleryAreaPage3").style.display="none";
	document.getElementById("galleryAreaPage4").style.display="none";	
	document.getElementById(idOn).style.display="block";
}



function resize(which, max) {
  var elem = document.getElementById(which);
  if (elem == undefined || elem == null) return false;
  if (max == undefined) max = 100;
  if (elem.width > elem.height) {
    if (elem.width > max) elem.width = max;
  } else {
    if (elem.height > max) elem.height = max;
  }
}


// 360deg photo stuff
function insert360(id,ivrName) {
	tmpHtml="";
	myBrowser = navigator.appName;
	myVersion = parseFloat(navigator.appVersion);
	if (myBrowser == 'Netscape' && myVersion < 4.0) {
		tmpHtml="<applet archive='lpjpanoNS3.zip' code='LPPano.class' width='440' height='270'>";
	} else {
		tmpHtml="<applet archive='lpjpano.zip' code='LPPano.class' width='440' height='270'>";
	}
	document.getElementById(id).innerHTML=tmpHtml+"<param name='cabbase' value='lpjpano.cab'><param name='file' value='"+images+ivrName+"'><param name='autoSpin' value='30'><param name='minZoomAngle' value='16'><param name='toolbar' value='collapsed'></applet>"; 
}



// insert little photos dynamically
function insertLittlePhoto(imageId,imageName,captionText,captionId) {
	document.write("<img src='"+imageName+"' height='48px' width='80px' alt='"+captionText+"' onmouseover='changeBigPhoto(\""+imageId+"\" , \""+imageName+"\" , \""+captionText+"\" , \""+captionId+"\");' class='littlePhotoImage' />");
}


function startPix() { 
	setInterval("slideshow()", timeDelay); 
} 
	
function slideshow() { 
	PicCurrentNum++; 
	if (PicCurrentNum == howMany) { PicCurrentNum = 0; } 
	document.getElementById("mainImage").style.backgroundImage="url('"+Pix[PicCurrentNum]+"')"; 
}



// Get URL Parameters   eg.   var frank_param = gup( 'frank' );
function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

