$(document).ready(function() {
	$(".teaserlink").colorbox({'initialWidth':555, 'initialHeight':260,inline:true, href:"#dyn_singlebon"});
	$(".freebonlink").colorbox({'initialWidth':555, 'initialHeight':260,inline:true, href:"#freebon"});
	$("#lostpassword").colorbox({'initialWidth':450, 'initialHeight':260,inline:true, href:"#dyn_lostpassword"});
	$("div#cont1,div#cont2,div#freebonbox").click(function() {
		document.location='https://www.sparbon.de/kunden/registrierung.php';
	})
	$("ul.faq li").click(function() {
		$(this).find("p").slideToggle(200);
		$("ul.faq li").siblings("li").not(this).find("p").slideUp(200);
	});
});
var sparcontnr=1;
function SparCont(nr) {
	if(nr==sparcontnr)return;
	$("#contnav"+(nr-1)).addClass("aktiv");
	$("#contnav"+(sparcontnr-1)).removeClass("aktiv");
	if(sparcontnr==4) {
		$("#cont4").toggle();
		$("#cont"+nr).slideToggle(100);
	}else $("#cont"+sparcontnr+",#cont"+nr).slideToggle(200);
	
	sparcontnr=nr;
}
function showBetaSticky(){
	$("#beta-sticky").slideToggle(1200);
}
function dyn_BonProps(teasertyp,BON_ID)	{
	senddata = {"BON_ID": BON_ID, "CLICKTYP":"T" }
	var dataString = JSON.stringify(senddata);
	clicked = 0;
	$.post("/bons/?todo=dyn_bonprops", { Dyndata: dataString }, function(retstatement){
		/*alert("Script meint: " + retstatement.msg);*/
		if(retstatement.msg == "ERROR")	{
			alert("Unknown: " + retstatement.msg);
			}
		else	{
			if(retstatement.BON_IMAGE != '') {
				$("#dyn_image").html('<img src="/media/' + retstatement.BON_IMAGE + '" alt="" class="bonlogo">');
				}
			if(retstatement.BON_CODE == '') werttyptext="prozent";
			else werttyptext="tipp";
			
			if(retstatement.BON_WERTTYP == '%') werttyp = "%";
			else werttyp = "&euro;";
			if(retstatement.BON_WERTTEXT != '')	{ werttyp = retstatement.BON_WERTTEXT; }
			$("#dyn_werttyp_image").attr('src', '/images/sb/bon-1-' + werttyptext + '.gif');
			$("#dyn_headline").html(retstatement.BON_HEADLINE);
			$("#dyn_teaser").html(retstatement.BON_TEASER);
			$("#dyn_stopd").html(retstatement.STOPD);
			$("#dyn_wert").html(retstatement.BON_WERT);
			$("#dyn_werttyp").html(werttyp);
			Klicker(teasertyp,BON_ID);
			return false;
			}
		}, "json");
	
	}

function Klicker(teasertyp, BON_ID)	{
	linktag = "#"+teasertyp+"_"+BON_ID;
	if(clicked == 0)	{
		$(linktag).attr("href","#dyn_singlebon");
		$(linktag).click();
		clicked = 1;
		}
	return false;
	}


$.cookie("SPcontrol", "on");
if($.cookie("SPcontrol") == "on" && (!$.cookie("SPvisit") || $.cookie("SPvisit") == ''))	{
	//alert( $.cookie("SPcontrol") );
	$.getJSON('bon.php?todo=dyn_setvisit', { response: "json" }, function(data) {
		$.cookie("SPvisit","1");
		//alert(data);
		if(!data) { 
			return true;
			}
		if(data)	{
			return true;
			}
		});	
	}


