
	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 var 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 eraseCookie(name) {
	createCookie(name,"",-1);
}






	var indertoolbar;
function einklappen() {

if(window.indertoolbar != "1")
{
  switch(jQuery("#shoppingcartcontents").css("display")) {
    case 'block':
 	shopping_cart_collapser();
	break;
	}

  switch(jQuery("#logindivcontents").css("display")) {
    case 'block':
	login_collapser();
	break;
	}
	
}

}


function resizeText(multiplier) { 


  if (document.body.style.fontSize == "") { 

    document.body.style.fontSize = "0.875em"; 

  } 



	if(multiplier == "-1") {
		if(parseFloat(document.body.style.fontSize) > 0.775) {
		jQuery("#resize_plus").css("color","#ccc");
		jQuery("#resize_minus").css("color","#ccc");

		
				var fontsize = parseFloat(document.body.style.fontSize) + (multiplier * 0.1) + "em";

	    document.body.style.fontSize = fontsize;

	    createCookie('fontsize', fontsize, 7 );
		}
		if(parseFloat(document.body.style.fontSize) == 0.775) {
		jQuery("#resize_minus").css("color","#222");
		}
		
	}
	

	
	if(multiplier == "1") {
		if(parseFloat(document.body.style.fontSize) < 1.075) {
		jQuery("#resize_plus").css("color","#ccc");
		jQuery("#resize_minus").css("color","#ccc");
		
				var fontsize = parseFloat(document.body.style.fontSize) + (multiplier * 0.1) + "em";

	    document.body.style.fontSize = fontsize;
	
		createCookie('fontsize', fontsize, 7 );
				}
		if(parseFloat(document.body.style.fontSize) == 1.075) {				
		jQuery("#resize_plus").css("color","#222");
		}
	}
	



}



function platzieren(objekt) {

if(objekt == "1") {
var position = jQuery("#warenkorbfeld").position();
var breite = position.left + parseFloat(jQuery("#shoppingcartcontents").width()) + 20;

if(jQuery(window).width() < breite) {
jQuery("#shoppingcartcontents").css("right","0");
}else {
jQuery("#shoppingcartcontents").css("right","auto");
}

}


if(objekt == "2") {
var position = jQuery("#loginfeld").position();
var breite = position.left + parseFloat(jQuery("#logindivcontents").width()) + 20;

if(jQuery(window).width() < breite) {
jQuery("#logindivcontents").css("right","0");
}else {
jQuery("#logindivcontents").css("right","auto");
}

}


}

window.onresize = function() {

if(jQuery("#shoppingcartcontents").css("display") == "block"){
platzieren(1);
}

if(jQuery("#logindivcontents").css("display") == "block"){
platzieren(2);
}

if(jQuery("#zusammenfassung").css("position") == "fixed") {
jQuery("#zusammenfassung").css("position","relative");
jQuery("#zusammenfassung").css("top","auto");
jQuery("#zusammenfassung").css("left","auto");
jQuery("#zusammenfassung").css("width","auto");

}
if(jQuery("#zusammenfassung").css("position") == "absolute") {
jQuery("#zusammenfassung").css("position","relative");
jQuery("#zusammenfassung").css("top","auto");
jQuery("#zusammenfassung").css("left","auto");
jQuery("#zusammenfassung").css("width","auto");

}

var browserkopf = jQuery(document).scrollTop();

var navipos = jQuery("#sidenavi").position();
var navihoehe = jQuery("#sidenavi").outerHeight();

var position12 = jQuery("#zusammenfassung").position();
var beitragkopf = jQuery("#inhalt").position();
var hoehe = jQuery("#zusammenfassung").height();
var weite = jQuery("#zusammenfassung").width();

var beitraghoehe = jQuery("#inhalt").height();
var summe = parseFloat(browserkopf)+parseFloat(hoehe);
var summebeitrag = parseFloat(beitragkopf.top)+parseFloat(beitraghoehe);
var browserkopfsumme = parseFloat(navipos.top)+parseFloat(navihoehe);


if(beitraghoehe > hoehe) {
if(browserkopf > browserkopfsumme) {
if(summe >= summebeitrag-70){
jQuery("#zusammenfassung").css("position","absolute");
jQuery("#zusammenfassung").css("top",summebeitrag-hoehe-70);
jQuery("#zusammenfassung").css("left",position12.left);
jQuery("#zusammenfassung").css("width",weite);

}else{
jQuery("#zusammenfassung").css("position","fixed");
jQuery("#zusammenfassung").css("top","0");
jQuery("#zusammenfassung").css("left",position12.left);
jQuery("#zusammenfassung").css("width",weite);
}
}
}


}





window.onscroll = function versetzen() {

	if(jQuery("#zusammenfassung").css("position") == "fixed") {
	jQuery("#zusammenfassung").css("position","relative");
	jQuery("#zusammenfassung").css("top","auto");
	jQuery("#zusammenfassung").css("left","auto");
	jQuery("#zusammenfassung").css("width","auto");
	
	}
	
	if(jQuery("#zusammenfassung").css("position") == "absolute") {
	jQuery("#zusammenfassung").css("position","relative");
	jQuery("#zusammenfassung").css("top","auto");
	jQuery("#zusammenfassung").css("left","auto");
	jQuery("#zusammenfassung").css("width","auto");
	
	}

var browserkopf = jQuery(document).scrollTop();

var navipos = jQuery("#sidenavi").position();
var navihoehe = jQuery("#sidenavi").outerHeight();

var position12 = jQuery("#zusammenfassung").position();
var beitragkopf = jQuery("#inhalt").position();
var hoehe = jQuery("#zusammenfassung").height();
var weite = jQuery("#zusammenfassung").width();

var beitraghoehe = jQuery("#inhalt").height();
var summe = parseFloat(browserkopf)+parseFloat(hoehe);
var summebeitrag = parseFloat(beitragkopf.top)+parseFloat(beitraghoehe);
var differenz = summe-summebeitrag;

var browserkopfsumme = parseFloat(navipos.top)+parseFloat(navihoehe)-parseFloat(hoehe)-27;


	if(beitraghoehe > hoehe) 
	{
	
		if(browserkopf > browserkopfsumme) 
		{
		
			if(summe >= summebeitrag-10){
			
				jQuery("#zusammenfassung").css("position","absolute");
				jQuery("#zusammenfassung").css("top",summebeitrag-hoehe-10);
				jQuery("#zusammenfassung").css("left",position12.left);
				jQuery("#zusammenfassung").css("width",weite);
	
			}else{
			
				jQuery("#zusammenfassung").css("position","fixed");
				jQuery("#zusammenfassung").css("top","0");
				jQuery("#zusammenfassung").css("left",position12.left);
				jQuery("#zusammenfassung").css("width",weite);
	
			}
	
	
		}
	
	
			if(browserkopf < browserkopfsumme) {
			jQuery("#anmeldungergebnis").css("position","relative");
			jQuery("#anmeldungergebnis").css("top","auto");
			jQuery("#anmeldungergebnis").css("left","auto");
			}
	}
}








 $(document).ready(function(){


	 document.body.style.fontSize = readCookie('fontsize');
	
		if(parseFloat(document.body.style.fontSize) == 0.775) {
		jQuery("#resize_minus").css("color","#222");
		}
		
		if(parseFloat(document.body.style.fontSize) == 1.075) {				
		jQuery("#resize_plus").css("color","#222");
		}
		



 });







function getanf() {
var n=0;
var neu=0;
var myVar=0;
var x=0;

  $("input[name='anf']").each(function(id) { 


	myVar = $("input[name='anf']").get(id); 
	yourInt = parseInt(myVar.value);
    n = n + yourInt; 
	x = formatZahl(n, '2', true);

	
 });        

jQuery(".ergebnis").html('&euro; '+x);


}


function geterf() {
var n=0;
var neu=0;
var myVar=0;
var x=0;


  $("input[name='erf']:checked").each(function(id) { 


	myVar = $("input[name='erf']:checked").get(id); 
	yourInt = parseInt(myVar.value);
    n = n + yourInt; 
	x = formatZahl(n, '2', true);
	
 });        

jQuery(".ergebnis").html('&euro; '+x);


}

function getspa() {
var n=0;
var neu=0;
var myVar=0;
var x=0;


  $("input[name='spa']:checked").each(function(id) { 


	myVar = $("input[name='spa']:checked").get(id); 
	yourInt = parseInt(myVar.value);
    n = n + yourInt; 
	x = formatZahl(n, '2', true);
	
 });        

jQuery(".ergebnis").html('&euro; '+x);


}


function formatZahl(zahl, k, fix) {
    if(!k) k = 0;
    var neu = '';
 
	var dec_point = '.';
	var thousands_sep = ',';
 
    var f = Math.pow(10, k);
    zahl = '' + parseInt(zahl * f + (.5 * (zahl > 0 ? 1 : -1)) ) / f ;
 
    var idx = zahl.indexOf('.');
 
    if(fix)    {
         zahl += (idx == -1 ? '.' : '' )
         + f.toString().substring(1);
    }
	var sign = zahl < 0;
	if(sign) zahl = zahl.substring(1);
    idx = zahl.indexOf('.');
 
    if( idx == -1) idx = zahl.length;
    else neu = dec_point + zahl.substr(idx + 1, k);
 
 
    while(idx > 0)    {
        if(idx - 3 > 0)
        neu = thousands_sep + zahl.substring( idx - 3, idx) + neu;
        else
        neu = zahl.substring(0, idx) + neu;
        idx -= 3;
    }
    return (sign ? '-' : '') + neu;
}





   function checkall()
   {
      $("INPUT[name='erf']").attr('checked', true);   
		geterf();
   }


   function uncheckall()
   {
      $("INPUT[name='erf']").attr('checked', false);   
		geterf();

   }



function setarten(name) {

	    createCookie('ausbildungsart', name, 1);

}

function gehzurart() {
var ausbildungsart = readCookie('ausbildungsart');
var url;

  switch (ausbildungsart) {
    case "quereinsteiger": 
	url = "quereinsteiger/";
	window.location = url;
    break;
    case "erfahrene": 
	url = "erfahrene/";
	window.location = url;
    break;
    case "hotels": 
	url = "hotels/";
	window.location = url;
	break;

}
}



function hinzu(holkurs,x) {
var fortschritt = "#fortschritt-"+x;

$(fortschritt).attr("src","/wp-content/themes/lastone/images/fortschritt.gif");
$("#fortschrittright").attr("src","/wp-content/themes/lastone/images/fortschritt.gif");



$.post("/wp-content/themes/lastone/addkurs.php", { kurs: holkurs }, 
function(data) {


 
$(".ergebnis").html(data);
$(".ergebnis").css("opacity","0");
$(".ergebnis").animate({ opacity: 1 }, 500 ); 
$("#kursbuchen").css("display","block"); 
$("#kursliste1").css("display","block"); 
$("#weitere").css("display","block"); 

$(".kursliste").css("opacity","0");

$.post("/wp-content/themes/lastone/holkurse.php", { }, 
function(data) { 
$(".kursliste").html(data);
$(".kursliste").animate({ opacity: 1 }, 500 );
$(fortschritt).attr("src","/wp-content/themes/lastone/images/spacer.gif");
$("#fortschrittright").attr("src","/wp-content/themes/lastone/images/spacer.gif");

},"html");


$("#zusammenfassung").animate({ opacity: 1 }, 500 ); 


},"html");





}

function delkurs() {
Check = confirm("Wenn Sie den Warenkorb leeren, werden alle ausgewählten Schulungen entfernt.");
if(Check == true){
$.post("/wp-content/themes/lastone/delkurs.php", { }, 
function(data) { 
location.reload();

$("input[type=radio]:checked").attr('checked', false);

});
}else{
}

}

function delkurs_now(holkurs12) {
Check = confirm("Wollen Sie diesen Kurs wirklich löschen?");
if(Check == true){
$.post("/wp-content/themes/lastone/delkursnow.php", { kurs: holkurs12 }, 
function(data) { 

location.reload();

});
}else{
return false;
}

}


function delkurs_spa() {
Check = confirm("Wenn Sie den Warenkorb leeren, werden alle ausgewählten Schulungen entfernt.\n\nUm einzelne Workshops zu entfernen, klicken Sie bitte auf 'Workshops' buchen.");
if(Check == true){
$.post("/wp-content/themes/lastone/delkurs_spa.php", { }, 
function(data) { 
location.reload();

});
}else{
}

}

function delkursspa_now(holkurs12) {
Check = confirm("Wollen Sie diesen Workshop wirklich löschen?");
if(Check == true){
$.post("/wp-content/themes/lastone/delkursspanow.php", { kurs: holkurs12 }, 
function(data) { 

location.reload();

});
}else{
return false;
}

}

function hinzu_spa(holkurs,x) {
var fortschritt = "#fortschritt-"+x;

$(fortschritt).attr("src","/wp-content/themes/lastone/images/fortschritt.gif");
$("#fortschrittright").attr("src","/wp-content/themes/lastone/images/fortschritt.gif");



$.post("/wp-content/themes/lastone/addkurs_spa.php", { kurs: holkurs }, 
function(data) {


 
$(".ergebnis").html(data);
$(".ergebnis").css("opacity","0");
$(".ergebnis").animate({ opacity: 1 }, 500 ); 
$("#kursbuchen").css("display","inline"); 
$("#kursliste1").css("display","inline"); 
$("#weitere1").css("display","inline"); 

$(".kursliste").css("opacity","0");

$.post("/wp-content/themes/lastone/holkurse_spa.php", { }, 
function(data) { 
$(".kursliste").html(data);
$(".kursliste").animate({ opacity: 1 }, 500 );
$(fortschritt).attr("src","/wp-content/themes/lastone/images/spacer.gif");
$("#fortschrittright").attr("src","/wp-content/themes/lastone/images/spacer.gif");

},"html");


$("#zusammenfassung").animate({ opacity: 1 }, 500 ); 


},"html");





}


function login_collapser() {
  switch(jQuery("#sliding_login").css("display")) {
    case 'none':
		
	jQuery("#logindivcontents").css("display","block");
    jQuery("#sliding_login").slideToggle("fast",function(){

    jQuery("#login_collapser_area").attr("src", ("/wp-content/themes/lastone/images/minus.png"));

	
	});
		
	jQuery('#logindivcontents').attr("onmouseout",""); //onmouseout des Divs wieder auf null zuruecksetzen!//

    break;
    
    default:
    jQuery("#sliding_login").slideToggle("fast",function(){

    jQuery("#login_collapser_area").attr("src", ("/wp-content/themes/lastone/images/plus.png"));
			
	jQuery("#logindivcontents").css("display","none");
	});
	jQuery('#logindivcontents').attr("onmouseout",""); //onmouseout des Divs wieder auf null zuruecksetzen!//

    break;
	}
  return false;
}
function loeschtimer() {
window.clearTimeout(timer_einklappen);
window.clearTimeout(timer_warenkorbhide);
}


function savetermin(holtermin,holname) {
$.post("/wp-content/themes/lastone/savetermin.php", { termin: holtermin, name: holname }); 
}

function showradios() {
$.post("/wp-content/themes/lastone/checktermin.php", {  }, function(data) { if(data == '0'){ window.location = "/checkout-kurs?id=1"; }else{ alert("Bitte wählen Sie einen passenden Termin für jeden einzelnen Kursteil.");} },"html"); 

}
