jQuery.noConflict();
var secnavAcitve = false;
var timing = false;
jQuery(document).ready(function() {

	/* init navigation */
	jQuery("#primnav li").mouseover( function() {
		window.clearTimeout(timing);
		timing = false;
		
		var linkName = jQuery(this).children('a').attr('name');

		// set all to default
		jQuery("#primnav li").removeClass('active');
		jQuery("#secnav ul").hide();

		// set current active
		jQuery(this).addClass('active');
		jQuery("#sub_" + linkName).show();

	});
	jQuery("#secnav li, #secnav ul, #secnav a").mouseover( function() {
		window.clearTimeout(timing);
		timing = false;

	});

	
	/* Set Timeout of mouse leaves navigation */
	jQuery("#nav").mouseout( function() {
		if(!timing){
			timing=window.setTimeout("reMainNav()", 3000);
		}
	});
	
	
	jQuery("#content, #service, #header").mouseover( function() {
		reMainNav();
	});

	jQuery("#content").css("visibility", "visible");
	jQuery(":submit").addClass("submitbt");
	jQuery(":text").addClass("textfield");
});

function reMainNav() {
	window.clearTimeout(timing);
	timing = false;
	
	jQuery("#primnav li").removeClass('active');
	jQuery("#secnav ul").hide();

	var linkName = jQuery("#primnav li.current").children('a').attr('name');

	jQuery('#primnav').find('.current').addClass('active');
	jQuery("#sub_" + linkName).show();
}

function switchMomme(url) {
	if(url != undefined) {
		jQuery.get(url, function(data){
			
			jQuery("#momme").html(data).animate({opacity: 1.0}, 500);

			findTabs = "div[name='demTabs']";
			
			if(jQuery(findTabs)) {
				generateTabs();
			}
			
			jQuery("#momme").fadeIn("slow", function() {
				jQuery.scrollTo(('#map'),800);
			});
		});
	}
}


function switchMommeBack(url) {
	if(url != undefined) {
		jQuery.get(url, function(data){
			jQuery("#momme").html(data).animate({opacity: 1.0}, 500);
						
			findTabs = "div[name='demTabs']";
			
			if(jQuery(findTabs)) {
				generateTabs();
			}
			
			jQuery("#momme").fadeIn("slow", function() {
				jQuery.scrollTo(('#map'),800);
			});
		});
	}
}

function clearMomme() {
	jQuery("#momme").fadeOut();
	jQuery("#momme").html("");
}

function generateTabs(){

	// ie-workaround / very dirty - ask cwa
	elm = jQuery("#momme div div div").attr("id");
	
	var tabs = new SimpleTabs ($(elm), {
		entrySelector: 'h4'
	});
}