function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

// Show/Hide an area ------------------------------------------------- //
function showPanel(id) {
	whichdiv = document.getElementById(id);
	var thearray= new Array("pics","plan","prnt","mail","enqy","view","calc"); 
	for(i=0; i<thearray.length; i++) { ;
		if(thearray[i] == id){
			whichdiv.className="panel";
			document.getElementById("dd_"+id).className="selected";
			document.getElementById("content-main").className=thearray[i];
		} else {
			document.getElementById(thearray[i]).className="hide"; 
			document.getElementById("dd_"+thearray[i]).className=""
		} 
	} 
}

function showTabBehaviour() {
	if (!document.getElementById("panellist")) return false;
	var Links = document.getElementById("panellist");
	var link = Links.getElementsByTagName("a");
	for(var i=0; i<link.length; i++){ 
		link[i].onclick = function() {
			var strLink = this.href.substring((this.href.length)-4,(this.href.length));
			if (document.getElementById("lnk_" + strLink)) {
				showPanel(strLink);
				return false;
			}
		}
	}
	return false;
}
addLoadEvent(showTabBehaviour);

// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this  header
// NS4-6,IE4-6
// Fade effect only in IE; degrades gracefully

// =======================================
// set the following variables
// =======================================

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000

// Duration of crossfade (seconds)
var crossFadeDuration = 3

// Specify the image files

// =======================================
// do not edit anything below this line
// =======================================

var t;
var j = 0;
var p = NewImg.length;
var go = 0;

var preLoad = new Array()
for (var i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = NewImg[i]

}

// Play
function startSlideshow() {
	go = 1
	fHideDiv('start')
	fShowDiv('stop')
	runSlideShow()
}

// Stop
function stopSlideshow() {
	go = 0
	fShowDiv('start')
	fHideDiv('stop')
}

// Tranisition
function runSlideShow(){
   if (go==1) {
	   if (document.all) {
			document.getElementById('showphoto').style.filter="blendTrans(duration=2)"
			document.getElementById('showphoto').style.filter="blendTrans(duration=crossFadeDuration)"
			document.getElementById('showphoto').filters.blendTrans.Apply()      
	   }
	   document.getElementById('showphoto').src = preLoad[j].src
	   if (document.all) {
			document.getElementById('showphoto').filters.blendTrans.Play()
	   }
	   j = j + 1
	   if (j > (p-1)) j=0
	   t = setTimeout('runSlideShow()', slideShowSpeed)
   }
   else {
	   t = ""
   }
}

// Forward/Rewind
function chgImg(direction) {
	ImgNum = ImgNum + direction;
	if (ImgNum > ImgLength) {
		ImgNum = 0;
	}
	if (ImgNum < 0) {
		ImgNum = ImgLength;
	}
	if (document.all){
		document.getElementById('showphoto').style.filter="blendTrans(duration=2)"
		document.getElementById('showphoto').style.filter="blendTrans(duration=crossFadeDuration)"
		document.getElementById('showphoto').filters.blendTrans.Apply()      
	}     
	document.getElementById('showphoto').src = preLoad[ImgNum].src
	if (document.all){
		document.getElementById('showphoto').filters.blendTrans.Play()
	}
}

// Image Gallery
function swapImage(whichpic) {
	if (!document.getElementById) return true;
	document.getElementById('showphoto').src = whichpic.href;
	return false;
}

function swapImageBehaviour() {
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	if (!document.getElementById("slides")) return false;
	var gallery = document.getElementById("slides");
	var links = gallery.getElementsByTagName("a");
	for ( var i=0; i < links.length; i++) {
		links[i].onclick = function() {
			return swapImage(this);
		}
	}
	return false;
}
addLoadEvent(swapImageBehaviour);

function showSector(id) {
	whichdiv = document.getElementById(id);
	var thearray= new Array("list0","list1","list2","list3","list4","list5","list6","list7","list8","list9"); 
	for(i=0; i<thearray.length; i++) {
		if(thearray[i] == 'list' + id){
			document.getElementById(thearray[i]).className="show";
		} else {
			document.getElementById(thearray[i]).className="hide"; 
		} 
	} 
}

function showMapBehaviour() {
	if (!document.getElementById("showMorePhotos")) return false;
	var link = document.getElementById("showMorePhotos"); 
	link.onclick = function() {
		var strLink = this.href.substring((this.href.length)-1,(this.href.length));
		if (document.getElementById("lnk_list" + strLink)) {
			showSector(strLink);
			return false;
		}
	}
	return false;
}
addLoadEvent(showMapBehaviour);

function showMorePhotos(intNumPhotos) {
	for (i = 0 ; i<intNumPhotos; i++)
	{
		document.getElementById('photo'+i).className = "";
	}
	document.getElementById('showmore').className = "hide";
	document.getElementById('showless').className = "show";
}

function showLessPhotos(intNumPhotos) {
	for (i = 4 ; i<intNumPhotos; i++)
	{
		document.getElementById('photo'+i).className = "hide";
	}
	document.getElementById('showmore').className = "show";
	document.getElementById('showless').className = "hide";
}
