/**
* Futureweb Javascript include File (c)2007 futureweb.at
**/

/**
* Function to open window correct and still be xhtml strict conform. area doesn't allow rel, so used class.
* Also added Google Analytics to track external links. 
**/

$(document).ready(function(){
	initListeners();
});


function initListeners(){

			$('a[@rel$="top"]').attr("target","_top");						   
			$('area[@class$="top"]').attr("target","_top");	
			$('a[@rel$="external"]').attr("target","_blank");
			$('a[@rel$="external"]').click(function() { pageTracker._trackPageview(this.title); });			   
			$('area[@class$="external"]').attr("target","_blank");			   
			$('area[@class$="external"]').click(function() { pageTracker._trackPageview(this.title); });	
			
			$('a[@rel$="paging"]').click(function() { 
			page = this.id.substring(1);
			getCB();
			return false;
			});
			$('a[@rel$="paging2"]').click(function() { 
			page = this.id.substring(1);
			getCB();
			window.location.href='#Branchen';
			return false;
			});
		
			$('#map').click(function() { 
				mapRequest = 1;
				xml = 0;
				firstLoad = 1;
				getCB();
				//initialize();
				return false;
			});	
			$('#firmen').click(function() { 
				GUnload();
				mapRequest = 0;
				getCB();
				return false;
			});	
		
			$('#cform').submit(function() { 
				Sval = $('#csearch').val(); 
				if (Sval != "") {
				page = 0;
				getCB();
				}
			return false;
			});
			$('#creset').click(function() { 
				Sval = ""; 
				page = 0;
				getCB();
			return false;
			});

}
/**
function to control menu. 
if href has #: only open up child menu
if href is a page: page loads, and current li has an id current added. (according to up['pid']. if up['pid'] is not set, first menuentry will have the current value. 
according to this id the parent and child menues are opened. 
this way we catch pageloads aswell as menues without link. 
unlimited recursive. 

todo: external links if they have submenues - not opened at the moment, necessary?

**/

function templateMenu(){
		$("#templatemenu li ul").not($("#current").children()).not($("#current").parents()).hide();
			$("#templatemenu li a").click(function(){
				if ($(this).parent().children("ul").is(":hidden") && $(this).attr("href") == "#") {
						$("#menu li ul:visible").not($(this).parent().parents()).slideUp("slow");
						$(this).parent().children("ul").slideDown("slow"); 
						return false;
 				}
			});
}
