var popup_visible = false;
var popup_count = 0;

function adler_event_add( obj, event, func ) {
	if ( obj.addEventListener ) {
		obj.addEventListener( event, func, false );
		return true;
	} else if ( obj.attachEvent ) {
		var r = obj.attachEvent( 'on'+event, func );
		return r;
	} else {
		return false;
	}
}
function adler_event_del( obj, event, func ) {
	if ( obj.removeEventListener ) {
		obj.removeEventListener( event, func, false );
		return true;
	} else if ( obj.detachEvent ) {
		var r = obj.detachEvent( 'on'+event, func );
	   return r;
	} else {
		return false;
	}
}

function element_position(element) {
		var elem=element,tagname="",x=0,y=0;
		
		while ((typeof(elem)=="object")&&(typeof(elem.tagName)!="undefined")) {
			y+=elem.offsetTop;
			x+=elem.offsetLeft;
			tagname=elem.tagName.toUpperCase();
			if (tagname=="BODY") elem=0;
			if (typeof(elem)=="object")
			if (typeof(elem.offsetParent)=="object")
			elem=elem.offsetParent;
		}
		
		position=new Object();
		position.x=x;
		position.y=y;
		return position;
}
	
function show_popup( container ) {
	adler_hide_popup();
	adler_event_add( document.body, 'click', adler_hide_popup );
	popup_visible = true;
	popup_count = 0;
	if ( typeof( timeout ) != 'undefined' ) clearTimeout( timeout );
	var anchor = element_position( document.getElementById( container+'_anchor' ) );
	var popup = document.getElementById( "quicklinks_popup" );
	popup.className = "quicklinks_popup";
	popup.style.display = 'block';
	popup.style.left = anchor.x + 20;
	popup.style.top = anchor.y + 5;
	popup.innerHTML = '<TABLE class=quicklinks cellSpacing=0 cellPadding=0 border=0>'+document.getElementById( container ).innerHTML+'</table>';
	timeout = setTimeout("adler_hide_popup()", 3500);
}

function adler_hide_popup() {
	if ( popup_visible && popup_count == 1 ) {
		adler_event_del( document.body, 'click', adler_hide_popup );
		document.getElementById( 'quicklinks_popup' ).style.display = 'none';
		popup_visible = false;
		popup_count = 0;
	} else {
		popup_count++;
	}
}

function hide_category() {
	var ary = document.getElementsByTagName("TABLE");
	for (i = 1; i < ary.length; i++) {
		if (ary[i].className == "cat") {
			ary[i].style.display ="none";
		}
	}
	current_id = 0;
	current_alt = 0;
	document.getElementById('map-description').style.display = "none";
}

var hide;
var current_id = 0;
var current_alt = 0;
function show_category(anchor, which, alt) {
	if ( current_id != which || current_alt != alt ) {
		hide_category();
		current_id = which;
		current_alt = alt;
		document.getElementById('map-description').appendChild( document.getElementById( which ) );
		document.getElementById(which).style.display = "block";
		document.getElementById('map-description').style.display = "block";
		document.getElementById('map-description').style.top = anchor.getAttribute('coords').split(',')[1];
		document.getElementById('map-description').style.left = anchor.getAttribute('coords').split(',')[0];
	}
	window.clearTimeout(hide);
	hide = window.setTimeout("hide_category()", 7000);
	return false;
}

function popup_site( url, name ) {
	window.open( url, typeof name == 'undefined' ? 'info' : name, 'width=750,height=650,scrollbars=yes,resizable=yes' );
}

