
// ***** window onload *****
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}




// *** start popup window ***

var popClass	= "popup";
var popName		= "popWin";
var popPrefix	= "pup-";
var popW	= 400;
var popH	= 300;

function popupHandler() { 
	var cl=popClass.length;
	var a=document.getElementsByTagName("a");
	for(var i=0; i<a.length; i++) { 
		var ca=document.getAttribute?a[i].getAttribute("class").split(" "):a[i].className.split(" ");
		if(ca[0]===popClass) { 
			a[i].onclick=function () { 
				var w = popW;  var h = popH; var s='';
				var ca2=document.getAttribute ? this.getAttribute("class").split(" ") : this.className.split(" ");
				for (var i=0; i<ca2.length; i++) {
					if (ca2[i].substring(0,popPrefix.length) === popPrefix) {
						var aaa = ca2[i].substring(popPrefix.length,ca2[1].length);
						c = aaa.split("_");
						for (var z=0; z<c.length; z++) {
							if (c[z].substring(0,1)=='w') { w = c[z].substring(1,c[z].length); }
							else if (c[z].substring(0,1)=='h') { h = c[z].substring(1,c[z].length); }
							else { s += c[z] +"=1,"; }
						}					
					}
				}
				var t=this.getAttribute("target")?this.getAttribute("target"):popName;
				popUp(this.getAttribute("href"),t,w,h,s);
				return false;
			}
		}
	}
}

function popUp(winURL,t,w,h,s){
	var specs="width="+w+",height="+h+",";
	if (s && s!='') {
		specs += s;
	}
	var scrX=Math.round((screen.width/2)-(w/2));
	var scrY=Math.round((screen.height/2)-(h/2));
	if(scrY>100){
		scrY=scrY-40;
	}
	specs+='top='+scrY+',left='+scrX;
	var win=window.open(winURL,t,specs);
	win.focus();
}

// *** end popup window ***


// *** start lang select ***

function langSelect()
{
	var sel_selectlang = document.getElementById('sel_selectlang');
	sel_selectlang.onchange = function()
	{
		location.href = sel_selectlang.options[sel_selectlang.selectedIndex].value;
	}
}

// *** end lang select ***


// *** start widget switcher ***

function switchWidgets()
{

	var h3_activities = 	document.getElementById('h3_activities');
	var tab_activities = 	document.getElementById('tab_activities');
	var h3_tips = 			document.getElementById('h3_tips');
	var tab_tips = 			document.getElementById('tab_tips');
	var h3_buy = 			document.getElementById('h3_buy');
	var tab_buy = 			document.getElementById('tab_buy');

	tab_tips.style.display = 'none';
	tab_buy.style.display = 'none';

	h3_activities.onclick = function()
	{
		turnElementsOff();
		tab_activities.style.display = 'block';
		return false;
	}
	h3_tips.onclick = function()
	{
		turnElementsOff();
		tab_tips.style.display = 'block';
		return false;
	}
	h3_buy.onclick = function()
	{
		turnElementsOff();
		tab_buy.style.display = 'block';
		h3_buy.className = 'in';
		return false;
	}

	function turnElementsOff()
	{
		tab_activities.style.display = 'none';
		tab_tips.style.display = 'none';
		tab_buy.style.display = 'none';
		h3_activities.className = '';
		h3_tips.className = '';
		h3_buy.className = '';
	}

}

// *** end widget switcher ***


// *** start video gallery ***

function runVideoGallery()
{
	// init vars
	var gallery =			document.getElementById('gallery');
	var galleryLI =			gallery.getElementsByTagName('li');
	var inVideo =			'thumb_' + video;
	var inInfo =			'info_' + video;
	if (document.getElementById(inVideo))
	{
		document.getElementById(inVideo).className = 'in';
		document.getElementById(inInfo).style.display = 'block';
	}
}

// *** end video gallery ***


// *** start Flash activities ***

function doFlashActivity()
{
	// init vars
	var infobubble =			document.getElementById('infobubble');
	var infobubbleDIV =			infobubble.getElementsByTagName('div');
	var activitieslist =		document.getElementById('activitieslist');
	var activitieslistA =		activitieslist.getElementsByTagName('a');
	var activitieslistLI =		activitieslist.getElementsByTagName('li');
	// init page display
	turnElementsOnOff(defaultActivity);

	for (var i = 0; i < activitieslistA.length; i++)
	{
		activitieslistA[i].onclick = function()
		{
			var thisID = this.id.replace("link_","");
			turnElementsOnOff(thisID);
			return false;
		}
	}

	function turnElementsOnOff(activity)
	{
		//turn elements off
		for (var i = 0; i < infobubbleDIV.length; i++)
		{
			infobubbleDIV[i].style.display = 'none';
		}
		for (var i = 0; i < activitieslistLI.length; i++)
		{
			activitieslistLI[i].className = '';
		}
		//turn elements on
		document.getElementById('info_' + activity).style.display = 'block';
		document.getElementById('link_' + activity).parentNode.className = 'in';
		writeSWF(activity);
	}

}
// *** end Flash activities ***


// *** start global load events ***

//addLoadEvent(langSelect);

addLoadEvent(popupHandler);

// *** end global load events ***

