//<![CDATA[


//	To display multiple images on click (Resort Guide) and
//	pisteMap on new window + close that if main page closed


var images= new Array();

function imgAdd(img)
{
	var pos = images.length
	images[pos]=new Image;
	images[pos].src= img;
	images[pos].name= img;
}

var imageDirPath;
function ImagePath(imagePath)
{
	imageDirPath = imagePath;
}

var cur = 0;

function Toggle(condition){
	if (condition == 'next'){
		cur = cur + 1;
		if (cur > images.length-1){
			cur = 0;
		}
	}
	if (condition == 'prev'){
		cur = cur - 1;
		if (cur < 0){
			cur = images.length-1;
		}
	}
	
	var imgPath = images[cur].src;
	var imgSubPath = images[cur].name;
	if(imgSubPath.indexOf("//")>0)
	{
		document.resortimages.src = imgSubPath; 
	}
	else if(imgPath.indexOf("/")>0){
		if(imageDirPath.indexOf("dbimages")>0)
			document.resortimages.src = imageDirPath + imgSubPath; 
		else
			document.resortimages.src = imageDirPath +"dbimages" + imgSubPath; 
		
	}else{
		if(imageDirPath.indexOf("dbimages")>0)
			document.resortimages.src = imageDirPath + imgPath; 
		else
			document.resortimages.src = imageDirPath + "dbimages" + imgPath; 
	}
	
}

// For piste map
var mapWindow = null;

function closePopup() 
{
if (mapWindow && mapWindow.open && !mapWindow.closed) mapWindow.close("Map");
}

function openMap(mapName) {
  //var subStart = mapName.lastIndexOf("/");
  if(imageDirPath.indexOf("dbimages")>0)
	  mapWithPath = imageDirPath + "/" + mapName; 
  else
	  mapWithPath = imageDirPath + "dbimages/" + mapName; 
  mapWindow = window.open('', "Map", 'width=520,height=400,status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0');
  mapWindow.document.write('<html><head><script language="javascript">function resizeWindow() { var pMap=document.getElementById("imgPisteMap"); top.resizeTo(pMap.width+50,pMap.height+100);} </script><title>Piste Map</title>');
  mapWindow.document.write('</head><body onload="resizeWindow();"><center>');
  mapWindow.document.write('<img src="' +  mapWithPath  + '" id="imgPisteMap"><br/>');
  mapWindow.document.write('<a href="javascript:self.close()">Close</a></center>');
  mapWindow.document.write('</body></html>');
  mapWindow.document.close();
  mapWindow.focus();
}

//]]>