/* <![CDATA[ */

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = ""; 
    expires= date.toGMTString();
  }else{
 	expires = "";
	}
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') {
    	c = c.substring(1,c.length);
    }
    if (c.indexOf(nameEQ) === 0){
    	return c.substring(nameEQ.length,c.length);
    	}
  }
  return null;
}


		
function skip_flash(){
	document.getElementById("product").style.display = "block";
	document.getElementById("search").style.zIndex = "11";
	$('#search').css({display: "block"});
	$('#search').css({opacity:"1"});   			
	document.getElementById("flashintro").style.display = "none";
}
				
function startFlash () {
    var params = {
        wmode: 'transparent', //true
        movie: '/_inc/20090622_Intro.swf',
        allowscriptaccess: 'always'
    };
    var flashvars = {};
    var attributes = {};
    swfobject.embedSWF("/_inc/20090622_Intro.swf", "flashintro", "1200", "325", "9.0.0", false, flashvars, params, attributes);
}

function hide_flash(){
	document.getElementById("product").style.display = "block";
					
	document.getElementById("search").style.zIndex = "11";
				
	$('#search').css({display: "block"});
	$('#search').animate({opacity:"1"},250,
		function(){
			document.getElementById("flashintro").style.display = "none";
		}
	);
}
			

$(document).ready(function(){
	var alredy_visited = "";
	alredy_visited = readCookie("faktu_akut");
	if (alredy_visited == "1") {
		skip_flash(); 
	}
	else {
		createCookie("faktu_akut", 1);
		startFlash();
	}

	var vpos = 0;
	$('.menu_top_active').each(function(){
		vpos = $(".menu_top_active").position();
	});
	$('.act1').each(function(){
		vpos = $(".act1").position();
	});
	$('.lvl3act3').each(function(){
		vpos = $(".lvl3act3").position();
	});
	$('.lvl2act2').each(function(){
		vpos = $(".lvl2act2").position();
	});
	$('.lvl2act2_1').each(function(){
		vpos = $(".lvl2act2_1").position();
	});
	if(vpos.top < 160){
		$('#menuGraW').attr("id", 'menuGraWA');
	}
	
	
	var postleft = 0;
	
	var pos = $('#menuGra').position();
	var sBrowser = navigator.userAgent;
	if (sBrowser.toLowerCase().indexOf('msie 6.0') > 0){
		posleft = 0;
	}else{
		posleft = 24;
	}
	
	var postop = pos.top   + vpos.top -585;
	
	var a = document.URL.split("//"); // split at protocol
	a = (a[1] ? a[1] : a[0]).split("/"); 
	// use last element of a; split at /
	// host is a[0]; path is a[1..(n-1)]; a[n] is page
	if(a[1] != 'index.php'){
		$('#menuGra').css({backgroundPosition: posleft +'px ' + postop + 'px' });
	}
	$('#menuGra').css({visibility: 'visible' });
	$('#menuGraW').each(function(){
		$('#menuGraW').css({visibility: 'visible' });
	});
	$('#menuGraWA').each(function(){
		$('#menuGraWA').css({visibility: 'visible' });
	});
	if(vpos === 0){
		$('#menuGra').css({visibility: 'hidden' });
		}
	
	var temp;
	
	$("li.menu_top").mouseover(function(){		
		$(this).css({'background-image': 'url(/design_images/btn_navi_main_on.gif)' });
    });
	$("li.menu_top").mouseout(function(){		
		$(this).css({'background-image': 'url(/design_images/btn_navi_main_off.gif)' });
    });
	
	$("li.lvl2").mouseover(function(){		
		$(this).css({'background-image': 'url(/design_images/menLi3Act.gif)' });
		temp = $(this).children();
		temp.css({'color': '#FFF' });
    });
	$("li.lvl2").mouseout(function(){		
		$(this).css({'background-image': 'url(/design_images/menSep2.gif)' });
		temp = $(this).children();
		temp.css({'color': '' });
    });
    
	$("li.lvl22").mouseover(function(){		
		$(this).css({'background-image': 'url(/design_images/menLi3Act.gif)' });
		$(this).css({'background-repeat': 'no-repeat' });
		temp = $(this).children();
		temp.css({'color': '#FFF' });
    });
	$("li.lvl22").mouseout(function(){		
		$(this).css({'background-image': 'url()' });
		$(this).css({'width': '161px' });
		temp = $(this).children();
		temp.css({'color': '' });
    });
	$("li.lvl3").mouseover(function(){		
		$(this).css({'background-image': 'url(/design_images/menLi3Act.gif)' });
		$(this).css({'background-repeat': 'repeat' });
		$(this).css({'width': '161px' });
		$(this).css({'border-left': '1px solid #06234D' });
		$(this).css({'border-right': '1px solid #06234D' });	
		temp = $(this).children();
		temp.css({'color': '#FFF' });
    });
	$("li.lvl3").mouseout(function(){		
		$(this).css({'background-image': 'url(/design_images/menSep.gif)' });
		$(this).css({'background-repeat': 'no-repeat' });
		$(this).css({'width': '159px' });
		$(this).css({'border-left': '1px solid #CAD026' });
		$(this).css({'border-right': '1px solid #CAD026' });	
		temp = $(this).children();
		temp.css({'color': '' });
    });
	$("li.lvl21").mouseover(function(){		
		$(this).css({'background-image': 'url(/design_images/menLi2_32.gif)' });
		$(this).css({'background-repeat': 'no-repeat' });
		$(this).css({'width': '161px' });
		temp = $(this).children();
		temp.css({'color': '#FFF' });
    });
	$("li.lvl21").mouseout(function(){		
		$(this).css({'background-image': 'url(/design_images/menLi2_3.gif)' });
		$(this).css({'background-repeat': 'no-repeat' });
		$(this).css({'width': '161px' });
		temp = $(this).children();
		temp.css({'color': '' });
    });
	$("li.lvl221").mouseover(function(){		
		$(this).css({'background-image': 'url(/design_images/menLi2_32.gif)' });
		$(this).css({'background-repeat': 'no-repeat' });
		$(this).css({'display': 'inline' });
		$(this).css({'width': '161px' });
		temp = $(this).children();
		temp.css({'color': '#FFF' });
    });
	$("li.lvl221").mouseout(function(){		
		$(this).css({'background-image': 'url(/design_images/menLi2_31.gif)' });
		$(this).css({'background-repeat': 'no-repeat' });
		$(this).css({'width': '161px' });
		temp = $(this).children();
		temp.css({'color': '' });
    });
});



/*
function hide_flash(){
	document.getElementById("product").style.display = "block";
	
	//Scrollbalken horizontal ausblenden
	//document.getElementsByTagName("body")[0].setAttribute("style", "overflow-x:hidden;");
	//document.getElementsByTagName("html")[0].setAttribute("style", "overflow-x:hidden;");
	
	document.getElementById("search").style.zIndex = "11";

	$('#search').css({display: "block"});
	$('#search').animate({opacity:"1"},250,
	function(){
		document.getElementById("flashintro").style.display = "none";
		//document.getElementsByTagName("body")[0].setAttribute("style", "overflow-x:auto;");
		//document.getElementsByTagName("html")[0].setAttribute("style", "overflow-x:auto;");
	}
	);
}
*/

//�ndern der Schriftgr��en auf der gesamten Webseite
var global_font_size = 11;
function supersize_me(value){
	//Schriftgr��en:
	//normal: 11, klein: 8, gro�: 14
	//Pr�fen, ob + oder - gew�hlt wurde
	if (value == "+") { global_font_size = global_font_size+3; value = global_font_size; }
	if (value == "-") { global_font_size = global_font_size-3; value = global_font_size; }

	if (value > 14){
		value = 14;
	}
	if (value < 8){
		value = 8;
	}

	document.getElementsByTagName('body')[0].style.fontSize = value + "px";

	tags = document.getElementsByTagName('p');
	for (i=0; i<tags.length; i++){
		document.getElementsByTagName('p')[i].style.fontSize = value + "px";
	}

	tags = document.getElementsByTagName('ul');
	for (i=0; i<tags.length; i++){
		document.getElementsByTagName('ul')[i].style.fontSize = value + "px";
	}
	for (i=0; i<tags.length; i++){
		document.getElementsByTagName('ul')[i].style.lineHeight = value + "px";
	}

	tags = document.getElementsByTagName('li');
	for (i=0; i<tags.length; i++){
		document.getElementsByTagName('li')[i].style.fontSize = value + "px";
	}
	for (i=0; i<tags.length; i++){
		document.getElementsByTagName('li')[i].style.lineHeight = value + "px";
	}

	tags = document.getElementsByTagName('h4');
	for (i=0; i<tags.length; i++){
		document.getElementsByTagName('h4')[i].style.fontSize = (value+2) + "px";
	}
	for (i=0; i<tags.length; i++){
		document.getElementsByTagName('h4')[i].style.lineHeight = (value+2) + "px";
	}

	global_font_size = value;
}

function PrintContent(parameter_div) {
	var DocumentContainer = document.getElementById(parameter_div);
	var WindowObject = window.open('', "FormularDrucken", 
     	                 "width=740,height=325,top=200,left=250,toolbars=no,scrollbars=yes,status=no,resizable=no");
	
	logo = "<div style='height: 64px;'><img src='/design_images/faktu_logo_print.gif' width='311' /></div>";
	headline = "Faktu akut";
	if (parameter_div != "content_home"){
		headline = document.getElementsByTagName("h1")[0].firstChild.data;
	}
	footer = document.getElementById('footer_left').innerHTML;

	if (parameter_div == "poblem_check_fomular") {
		/*printer_content = "<h1>Ergebnis meines Poblem-Checks</h1>" + DocumentContainer.innerHTML;
		formatierung_anfang = "<span style='font-family:Verdana,Arial,Helvetica,sans-serif; font-size:0.71em;'>";
		formatierung_ende = "</span>";*/
	}
	else {
		//Standard-Formationierungen und mittlerer Content
		printer_content = logo + "<h1>" + headline + "</h1>" + DocumentContainer.innerHTML + "<br /><br /><small>" + footer + "</small>";
		formatierung_anfang = "<span style='font-family:Verdana,Arial,Helvetica,sans-serif; font-size:1em;'>";
		formatierung_ende = "</span>";
	}

	//text f�r den drucker ausgeben: textformmatierungen, content, end-tags der formatierungen
	WindowObject.document.writeln(formatierung_anfang + printer_content + formatierung_ende);

	WindowObject.document.close();
	WindowObject.focus();
	WindowObject.print();
	//WindowObject.close();
}

function getActiveStyleSheet() {
	
/*
	var i, a;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("href") && !a.disabled){
			//	alert(a.getAttribute("href"));
			return a.getAttribute("href");
		}
	}
*/
 return $('body').css('font-size');
}

function setActiveStyleSheet(title) {
/*
	var i, a, main;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("href")) {
			a.setAttribute("href", title);
		}
	}
*/
	$('body').css('font-size', title +"px");
	$('p').css('font-size', title +"px");
}


function getLower(active){
	
	var retV  = 0;
	
	switch (active) {
		case "11": retV = 11;
		break;
		case "12": retV = 11;
		break;
		case "13": retV = 12;
		break;
		default: retV = 11;
	}
	return retV;

}


function getHigher(active){
	
	var retV  = 0;
	
	switch (active) {
		case "11": retV = "12";
		break;
		case "12": retV = "13";
		break;
		case "13": retV = "13";
		break;
		default: retV = "13";
	}
	return retV;
}

function switchStyle(size){
	var active = getActiveStyleSheet();
	active = active.slice(0, 2);
	
	switch (size) {
		case "-": setActiveStyleSheet(getLower(active));
		break;

		case "+": setActiveStyleSheet(getHigher(active));
		break;

		case 11: setActiveStyleSheet("11");
		break;

		case 12: setActiveStyleSheet("12");
		break;

		case 13: setActiveStyleSheet("13");
		break;

		default: setActiveStyleSheet("11");
	}
}

window.onload = function(e) {
	var cookie = readCookie("style");
	var title = cookie ? cookie : getActiveStyleSheet();
	setActiveStyleSheet(title.slice(0, 2));
};

window.onunload = function(e) {
	var title = getActiveStyleSheet();
	createCookie("style", title, 365);
	//alert("cookie beim unload"); 
};

var cookie = readCookie("style");
var title = cookie ? cookie : getActiveStyleSheet();
setActiveStyleSheet(title);

/* ]]> */