if (self.parent.frames.length != 0)
	self.parent.location.replace(document.location.href);

function em(box, server, zone) {
	var at = String.fromCharCode(64);
	document.write('<a href="'+'mai'+'lto'+':'+box+at+server+'.'+zone+'">'+box+at+server+'.'+zone+'<'+'/a>');
}

function show_window_size(window_url, width, height) {
	var left = Math.round((screen.width-width)/2),
		top = Math.round((screen.height-height)/2)-30
	var window_param =	'ontop=yes,status=yes,menubar=no,toolbar=no,directories=no,resizable=yes,scrollbars=yes,location=no,'+
						'width='+width+',height='+height+','+
						'left='+left+',top='+top;
	var window_name = 'win_'+Math.floor(Math.random()*1000);
	var win = window.open(window_url, window_name, window_param);
	win.focus();
	return false;
}

function services_create_popup() {
	var obj = document.createElement("div");
	obj.setAttribute("id", "services-popup");
	obj.innerHTML = '<span></span><img src="/i/popup-arrow.gif" width="17" height="33" class="arrow" alt="">';
	document.body.appendChild(obj);
}

function getNextSibling(startBrother) {
	endBrother = startBrother.nextSibling;
	while (endBrother && endBrother.nodeName != startBrother.nodeName)
		endBrother = endBrother.nextSibling;
	if (!endBrother)
		return false;
	return endBrother;
}


function services_init() {
	var services = document.getElementById("services-list");
	if (!services) return;
	services_create_popup();

	var current_li = services.getElementsByTagName("li")[0];
	do {
		current_li.getElementsByTagName("a")[0].onmouseover = function() {
			var ul = this.parentNode.getElementsByTagName("ul");
			services_hide();
			if (ul.length)
				services_show(ul[0].innerHTML, this);
		}
	} while (current_li = getNextSibling(current_li));
}

function services_hide() {
	var popup = document.getElementById("services-popup");
	if (!popup) return;
	popup.style.display = "none";
}

function services_show(html, placeholder) {
	var popup = document.getElementById("services-popup");
	if (!popup) return;
	popup.getElementsByTagName("span")[0].innerHTML = "<ul>"+html+"</ul>";
	popup.style.display = "block";
	services_set_position(popup, placeholder);
	return false;
}

function services_set_position(popup, placeholder) {
	if (!popup || !placeholder) return;
	var coord = get_position(placeholder);
	popup.style.left = (coord["x"]-popup.offsetWidth-15)+"px";
	popup.style.top = (coord["y"]-20)+"px";
}

function get_position(obj) {
	var coord = {x:0, y:0};
	do {
		coord["x"] += obj.offsetLeft;
		coord["y"] += obj.offsetTop;
		if (/^div$/i.test(obj.tagName)) {
			if (obj.scrollLeft)	coord["x"] -= obj.scrollLeft;
			if (obj.scrollTop)	coord["y"] -= obj.scrollTop;
		}
		obj = obj.offsetParent;
	} while(obj);
	return coord;
}

/*** DOCUMENT EVENTS *********************************************************/
function add_event_listener_element(element, event, func) {
	if (element.addEventListener)
		element.addEventListener(event, func, false);
	else if (element.attachEvent)
		element.attachEvent("on"+event, func);
	else
		return false;
	return true;
}

function add_event_listener(event, func) {
	var root_listener = window.addEventListener || window.attachEvent ? window : document.addEventListener ? document : null;
	if (!root_listener)
		return false;
	return add_event_listener_element(root_listener, event, func);
}

function domReady(i) { /* Copyright http://ajaxian.com/ */
	var u = navigator.userAgent;
	var e = /*@cc_on!@*/false;
	var st = setTimeout;
	if (/webkit/i.test(u)) {
		st(
			function() {
				var dr=document.readyState;
				if(dr=="loaded"||dr=="complete") i();
				else st(arguments.callee,10);
			}, 10
		);
	} else if ((/mozilla/i.test(u)&&!/(compati)/.test(u)) || (/opera/i.test(u))) {
		document.addEventListener("DOMContentLoaded", i, false);
	} else if (e) {(
		function(){
			var t=document.createElement('doc:rdy');
			try {
				t.doScroll('left');	i(); t=null;
			} catch(e) {st(arguments.callee,0);}
		})();
	} else window.onload=i;
}

add_event_listener("resize", function() {
	services_hide();
});

domReady(function(){
	services_init();
});

