// JavaScript Utilities Document for WG3

function viewMore(div) {
	obj = document.getElementById(div);
	col = document.getElementById("x" + div);
	col2 = document.getElementById(div);
	
	
	if (obj.style.display == "none") {
		obj.style.display = "block";
		col.innerHTML = 'Show Map <img src="images/map_arrow_down.gif" alt="map"/>';
		col2.innerHTML = '<img src="images/map.gif" alt="map"/>';
	
		
	} else {
		obj.style.display = "none";
		col.innerHTML = 'Show Map <img src="images/map_arrow_up.gif" alt="map"/>';
		col2.innerHTML = "";
	}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  	if (restore) selObj.selectedIndex=0;
	}
	//-->	
function popUp(URL) {
	window.open(URL,'ph','width=885,height=605,toolbar=no,personalbar=no,location=no,directories=no,statusbar=no,menubar=no,status=no,resizable=no,left=60,screenX=60,top=100,screenY=100');
	}
	
	
		var curTab = "";
		function showTab(idx, destId) {
			if (document.getElementById("Tab_"+idx) != undefined)
			{
				document.getElementById("Tab_"+idx).style.display = "block";
			}
			if (document.getElementById("TabHeader_"+idx) != undefined)
			{
				document.getElementById("TabHeader_"+idx).className = "activeTab";
			}
			
			//Video
			if (idx == "videos"){
				var iframe = document.getElementById("videoMap");
				if (typeof iframe != 'undefined')
				{
					if (iframe.contentWindow != undefined)
					{
						if (typeof eval (iframe.contentWindow.onLoad) == 'function')
						{
							iframe.contentWindow.onLoad();
						}
					}
				}
			}
			
			//Map
			if (idx == "map"){
				var iframe = document.getElementById("googleMap");
				if (typeof iframe != 'undefined')
				{
					if (iframe.contentWindow != undefined)
					{
						if (typeof eval (iframe.contentWindow.onLoad) == 'function')
						{
							iframe.contentWindow.onLoad();
						}
					}
				}
			}
		
			if (curTab != idx && curTab != "") {
				document.getElementById("Tab_"+curTab).style.display = "none";
				document.getElementById("TabHeader_"+curTab).className = "";
			}
		
			curTab = idx;
		
		}
		
		//The method is used on the events page.
		function displayEvents(monthId)
		{
			
			document.getElementById("JAN").style.display = "none";
			document.getElementById("FEB").style.display = "none";
			document.getElementById("MAR").style.display = "none";
			document.getElementById("APR").style.display = "none";
			document.getElementById("MAY").style.display = "none";
			document.getElementById("JUN").style.display = "none";
			document.getElementById("JUL").style.display = "none";
			document.getElementById("AUG").style.display = "none";
			document.getElementById("SEP").style.display = "none";
			document.getElementById("OCT").style.display = "none";
			document.getElementById("NOV").style.display = "none";
			document.getElementById("DEC").style.display = "none";
			
			document.getElementById(monthId).style.display = "block";
			
		}
	
		function showEvents(){
			
			var theList = document.getElementById("wg_events_select");
			var theElements = theList.getElementsByTagName("a");
			
			for (var i=0; i<theElements.length; i++) {
				
				//init
				if (i == 0){
					theElements[i].className = "current"
				}
				
				//else{theElements[i].className = ""}
				
				theElements[i].onclick=function(e){
				clearEvents();
				this.className+=" current";
				var theLink = this.title.toUpperCase();
				//alert(theLink);
				displayEvents(theLink);
				cancelEvent(e);

		}
				
			}
				
		}
		
		function clearEvents(){
			
			var theList = document.getElementById("wg_events_select");
			var theElements = theList.getElementsByTagName("a");
			
			for (var i=0; i<theElements.length; i++) {
				theElements[i].className = "";
				
			}
			
			
		}
		
		function cancelEvent(e)
		{
		 if (!e) var e = window.event;
		 
		 //e.cancelBubble is supported by IE - this will kill the bubbling process.
		 e.cancelBubble = true;
		 e.returnValue = false;
		 
		 //e.stopPropagation works only in Firefox.
		 if (e.stopPropagation) {
		  e.stopPropagation();
		  e.preventDefault();
		 }
		}
		
		
			
function externalLinksPopUp()
{

//alert("in");
 var classToFind = "gl_external";
 var links = document.getElementsByTagName("a");
 
 for(i=0;i<links.length;i++)
 {
  if(links.item(i).className == classToFind)
  {
   links.item(i).onclick = function(e){
		window.opener.location='http://www.lonelyplanet.com/travelstories/author/sponsor_nokia/';
		window.opener.focus();
		cancelEvent(e);};
  }
  
  
  }
}	



//addLoadListener(showEvents);	
