// menu link handler

function followLink(obj) {
	// follow the first link inside
	var n=0;
	if (!obj) return true;
	if ((obj.childNodes) && (obj.childNodes.length)) {
		// DOM approcah
		while (obj.childNodes[n].nodeType!=1 && obj.childNodes.length<n+1) n++;
		if (obj.childNodes[n].href) {
			self.location.href=obj.childNodes[n].href;
			return false;
		}
	}
	else if ((obj.children) && (obj.children.length)) {
		// older versions of MSIE
		while (obj.children[n].nodeType!=1 && obj.children.length<n+1) n++;
		if (obj.children[n].href) {
			self.location.href=obj.children[n].href;
			return false;
		}
	}
	return true;
}

var microSite;

function openMicroWin(url, baseWidth, baseHeight) {
	var w=baseWidth;
	var h=baseHeight;
	if (self.innerWidth && self.outerWidth) {
		w+=self.outerWidth-self.innerWidth;
	}
	if (self.innerHeight && self.outerHeight) {
		h+=self.outerHeight-self.innerHeight;
	}
	else {
		h+=60;
	}
	if (window.screen) {
		if (screen.availWidth && screen.availWidth<w) w=screen.availWidth;
		if (screen.availHeight && screen.availHeight<h) h=screen.availHeight;
	}
	if (microSite && !microSite.closed) microSite.close();
	microSite=window.open(url,'MicroPage','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width='+w+',height='+h);
	return (microSite)? false:true;
}


// iPhone/iPad/iPod fix (limited support for position:fixed)

function safariMobileLayoutFix() {
	var footer=document.getElementById('footer');
	footer.style.position='static';
	var bottomspacer=document.getElementById('bottomspacer');
	bottomspacer.style.height='0px';
}

var ua=navigator.userAgent;
if (ua && (ua.indexOf('Safari')>=0 || ua.indexOf('WebKit')>=0) && ua.indexOf('Mobile')>=0) {
	document.addEventListener( "DOMContentLoaded", safariMobileLayoutFix, false );
}
