/* 
 * contains code for jQuery ready and some functions
 */

$(document).ready(function(){
	// TOGGLE CONTENT
	$(".toggle_content").hide();
	$(".toggle_btn").click(function(){
		$(this).parent().next(".toggle_content").slideToggle(300);
		$(this).toggleClass("open");
	});
	
	// SITEMAP
	$(".stoggle_btn").click(function(){ // toggle one
		$(this).parent().next(".toggle_content").slideToggle(300);
		$(this).toggleClass("open");
	});	
	$("#open_sitemap").click(function(){ // toggle all				
		if($("#open_sitemap").hasClass(".open")) { 
			$(".sitemapitem_toggle").nextAll(".toggle_content").slideUp(300);
			$(".stoggle_btn").removeClass("open");	
			$("#open_sitemap").removeClass("open");
			$("#open_sitemap").html("alles &ouml;ffnen");
		} else { 
			$(".sitemapitem_toggle").nextAll(".toggle_content").slideDown(300);
			$(".stoggle_btn").addClass("open");	
			$("#open_sitemap").addClass("open");
			$("#open_sitemap").html("alles schlie&szlig;en");
		}	
	});
	
	// Activate FancyBox		
	$("a#tellafriend").fancybox({
		'zoomSpeedIn':	0, 
		'zoomSpeedOut':	0,
		'frameWidth': 520,
		'frameHeight': 620,
		'overlayShow': true,
		'overlayOpacity': 0.7
	});
			  
	// FLYOUT NAV	
	$("#mainnav li li:last").addClass("last"); // flag last item	
	IE="\v"=="v" // true only in IE 
	if (IE) {						
		$("#mainnav li").hover(function(){ // enable li:hover in IE6 (inspired by SuckerFish)
			$(this).addClass("sfhover");			
			//$("a img", this).show();
			//$("a img.active", this).css("positio");
			//$("a img.inactive", this).hide();
		}, function(){
			$(this).removeClass("sfhover");
			
			//$("a img.inactive", this).show();
			//$("a img.active", this).hide();
		});
	}
	$("#mainnav li li").hover( // correct borders
		function(){ 																					
			// hide border of the next element
			n = $(this).next();										
			$("a span", n).addClass("border-hide");					
		},function(){
			// show all borders
			$("#mainnav a span").removeClass("border-hide");
			n = $("#mainnav li li.active").next();
			$("a span", n).addClass("border-hide");
		}
	);
	n = $("#mainnav li li.active").next();
	$("a span", n).addClass("border-hide");	
});

function swapImg(imgSrc, imgId){
	document.getElementById(imgId).src = imgSrc;
}

function toggleContent(tb,tc){
	$(document.getElementById(tc)).slideToggle(300,jumpToMark);
	$(document.getElementById(tb)).toggleClass("open");
 }

function jumpToMark(){
	document.location.href="#"+this.id+"_jm";
}

function popupGGI(url) {
	fenster=window.open(url, "Allianz24Popup");
	fenster.focus();
	return false;
}

function hideWebsites(){
 	$("#websites").hide();
}
			 
function showWebsites(){
 	$("#websites").show();
}

