
/*
$ = function(id) { 
	return document.getElementById(id);
}
*/




function toggle(obj) {
	var el = $(obj);
	el.style.display = el.style.display != 'none' ? 'none' : '';
}

function MM_openBrWindow(theURL,winName,features) {
	window.open(theURL,winName,features);
}

function externalLinks() {
	if (!document.getElementsByTagName) 
		return;
		
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
		
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "top")
			anchor.target = "_top";
	}
}


function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number')
		windowHeight = window.innerHeight;
	
	else {
		if (document.documentElement && document.documentElement.clientHeight)
			windowHeight = document.documentElement.clientHeight;
		
		else {
			if (document.body && document.body.clientHeight)
				windowHeight = document.body.clientHeight;
			
		}
	}
	return windowHeight;
}


function setFooter() {
	var windowHeight = getWindowHeight();
	
	if (windowHeight > 0) {
		var wrapperHeight = $('wrapper').offsetHeight;
		var footerElement = $('footer');
		var footerHeight  = footerElement.offsetHeight;

		if (windowHeight - (wrapperHeight + footerHeight) >= 0) {
			footerElement.style.position = 'relative';
			footerElement.style.top = (windowHeight - (25 + wrapperHeight + footerHeight)) + 'px';
		} else
			footerElement.style.position = 'static';
	}
}


function showAddress(address) { 
	var places = ['usa', 'uk'];
	if(address == null) {
		for(var i = 0; i < places.length; i++) { 
			$(places[i] +'-contact').style.borderBottom = '5px solid #ffffff';
			setOpacity($(places[i] +'-contact'), 10);
		}

	} else { 
		var other = address == 'usa' ? 'uk' : 'usa';
		showAddress(null);
		setOpacity($(other +'-contact'), 3);
		$(address +'-contact').style.borderBottom = address == 'usa' ? '5px solid #4991d9' : '5px solid #d0e92f';
	}
}


function setOpacity(el, value) { 
	el.style.opacity = value/10;
	el.style.filter = 'alpha(opacity=' + value*10 + ')';
}

window.onload = function() {
	setFooter();
	externalLinks(); 
	showAddress(null);
}

window.onresize = function() {
	setFooter();
}