//function to allow more than one window.onload event
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}


//CloseMap
function CloseMap() {
	//alert('CLOSE MAP');	
	var element = document.getElementById("mapContainer");
	if(element){
		element.style.display = 'none';
		//window.frames.GoogleMapiFrame.initialize();
	}
}


//OpenClose
function OpenClose(id) {
	var element = document.getElementById(id);
	if (element.style.display != 'block') {
		element.style.display = 'block';
	}
	else {
		element.style.display = 'none';
	}	
	if(id=="mapContainer") window.frames.GoogleMapiFrame.initialize();
}

// SelectThis(elementToShow)
// A function to show/hide elements according to selection of a radio button.
// The value of the radio button should be the same as the id of the element you want to show/hide
function SelectThis(id) {
	if(id){
		var displayThis = document.getElementById(id);
		var radios = new Array();
		var radios = document.qs.browseBy;
		for (i=0;i<radios.length;i++) {		
			if (radios[i].value != displayThis) {
				var hideThisEl = radios[i].value;
				var hideThis = document.getElementById(hideThisEl);
				hideThis.style.display = 'none';
				hideThis.value='';
				displayThis.style.display = 'block';
			}
		}
	}
}

// Prepare Image Gallery
function prepareGallery() {
	var galleryList = document.getElementById("thumbs");
	var images = galleryList.getElementsByTagName("img");
	
	for (i=0;i<images.length;i++) {
		//images[i].onclick = showPic;
		images[i].style.cursor = "pointer";
		};
	
		/*
	function showPic() {
		var source = this.getAttribute("name");
		var title = this.getAttribute("title");
		var caption = document.getElementById("caption");
		var placeholder = document.getElementById("placeholder");
		placeholder.setAttribute("src",source);
		caption.innerHTML = title;
	};*/
}