var domain = "http://cms.wanderhotels.com";

path = new Array();
path.push('/static/js/lib/prototype.js');
path.push('/static/js/lib/animator.js');
path.push('/static/js/lib/swfobject.js');
path.push('/static/js/imgReplace.js');
path.push('/static/js/src/scriptaculous.js');
path.push('/static/js/lightbox.js');
path.push('/static/js/tabbing.js');

loadScrips(path);

function onDocumentLoad ()
{
	replaceHeading("em");
	replaceHeading("h2");
	replaceHeading("h1");
	prepareMetaNav();
	initLightbox();
}

window.onload = onDocumentLoad;

function loadScrips (path)
{
	for(i=0;i<path.length;i++)
	{
		document.write('<script type="text/javascript" src="' + domain + path[i] + '"></script>');
	}
}

function prepareMetaNav ()
{
	lis = $$('#metanavlist li');
	for(i=0;i<lis.length;i++)
	{
		if(lis[i].parentNode == $('metanavlist'))
		{
			if(lis[i].getElementsByTagName("ul")[0])
			{
				lis[i].onmouseover = function ()
				{
					this.getElementsByTagName("ul")[0].style.display = 'block';
					this.getElementsByTagName("a")[0].className = 'active';
				}
				
				lis[i].onmouseout = function ()
				{
					this.getElementsByTagName("ul")[0].style.display = 'none';
					this.getElementsByTagName("a")[0].className = '';
				}
			}
		}
	}
}


function gotoLink (htmlElement) {
	var destinationURL = "";
	var target = "";
	
	if(htmlElement.href) {
		destinationURL = htmlElement.href;
		target = htmlElement.getAttribute("target");
	}
	else {
		if(htmlElement.childNodes) {
			if(htmlElement.getElementsByTagName("a")) {
				destinationURL = htmlElement.getElementsByTagName("a")[0].href;
				target = htmlElement.getElementsByTagName("a")[0].getAttribute("target");
			}
		}
	}
	
	if(target == "_blank") {
		window.open(destinationURL);
	}
	else {
		location.href = destinationURL;
	}
}
