$(function()
{
	if (document.getElementById("news-detail")){
		$('#news-detail').jScrollPane({showArrows:true, scrollbarMargin:10});
	}
	if (document.getElementById("formular-detail")){
		$('#formular-detail').jScrollPane({showArrows:true, scrollbarMargin:10});
	}
	
	$('.bezahlart').click(function () {
			
		$('.bezahlart1').hide();
		$('.bezahlart2').hide();
		$('.bezahlart3').hide();		
									  
		var type = this.value;
		switch (type) {
			case '1': $('.bezahlart1').show(); break;
			case '2': $('.bezahlart2').show(); break;
			case '3': $('.bezahlart3').show(); break;			
		}
	});		
});
		
function showH(el)
{
	hideAllH();	
	$("#"+el).css("display","block");

}

function hideAllH()
{
	for (i=1;i<10;i++)
	{
		var el = "heart" + i;
		$("#"+el).css("display","none");
	}
}

function showLupe(el)
{
	$("#lupe").css("display","block");
	var htmlcontent = "";
	switch (el) {
		case "lupe-shoppingmall": file = 'shoppingmall.html'; break;
		case "lupe-shows": file = 'shows.html'; break;
		case "lupe-nightlife": file = 'nightlife.html'; break;
	}
	$.get("ajax/" + file, function(data) { $("#lupe").html(data); });
}

function closeLupe()
{
	$("#lupe").html("");
	$("#lupe").css("display","none");
}

function jumpto(uid)
{
	document.location.href = "index.php?page=news&uid=" + uid;
}

function newBanner()
{
	var banner2_content = $("#banner2").html();
	var banner3_content = $("#banner3").html();
	var banner4_content = $("#banner4").html();
	var field_id;
	var banner;
	
	if (banner2_content == "")
	{
		field_id = "#banner2";
		banner = 2;
	}
	else if (banner3_content == "")
	{
		field_id = "#banner3";
		banner = 3;
	}
	else if (banner4_content == "")
	{
		field_id = "#banner4";
		banner = 4;
	}
	
	if (banner > 1 && banner < 5)
	{	
		$.get("ajax/setNewBannerform.php", {banner:banner},
					function(data) {
						$(field_id).html(data);
						$('#formular-detail').jScrollPane({showArrows:true, scrollbarMargin:10});
					}
				);
	}
	else
	{
		$("#hilfslink").html("&nbsp;");
	}
}

function checkForm()
{	   
	var services = $("#form_buchung").serialize();	
	$.post("ajax/saveBanner.php", { services: services },
			   function(data){
					$("#result").html(data);
					$('#formular-detail').jScrollPane({showArrows:true, scrollbarMargin:10});
				}
		   );
}

function tooltip(uid,type)
{
	switch (uid)
	{
		case 1: id = "#tt_sexkino"; break;
		case 2: id = "#tt_cams"; break;
		case 3: id = "#tt_amateure"; break;
		case 4: id = "#tt_fetish"; break;
		case 5: id = "#tt_sextoys"; break;
		case 6: id = "#tt_club"; break;
		case 7: id = "#tt_flirtpoint"; break;
		case 8: id = "#tt_nightlife"; break;
		case 9: id = "#tt_sauna"; break;
		case 10: id = "#tt_shows"; break;
		case 11: id = "#tt_video"; break;
		case 12: id = "#tt_cabaret"; break;
		case 13: id = "#tt_salons"; break;
		case 14: id = "#tt_books"; break;
		case 15: id = "#tt_escort"; break;
		case 16: id = "#tt_bar"; break;
		case 17: id = "#tt_buero"; break;
		case 18: id = "#tt_shopping"; break;
	}
	
	if (type == 1)
	{
		$(id).css("display","block");
	}
	else
	{
		$(id).css("display","none");
	}
}

function popup(ziel) {
	var w = 600;
	var h = 400;
	h = h - 20; var x=0, y=0, parameter="";
	if (w < screen.availWidth || h < screen.availHeight) {
	x = (screen.availWidth - w - 12) / 2;
	y = (screen.availHeight - h - 104) / 2;
	if (window.opera) y = 0; // Opera positioniert unter den Symbolleisten
	if (x<0 || y<0) { x=0; y=0; }
	else parameter = "width=" + w + ",height=" + h + ",";
	}
	parameter += "left=" + x + ",top=" + y;
	parameter += ",menubar=yes,location=yes,toolbar=no,status=no";
	parameter += ",resizable=yes,scrollbars=yes";
	var Fenster = window.open(ziel,"PopUp",parameter);
	if (Fenster) Fenster.focus();
	return !Fenster;
}

function showBuchungsformular(bereich)
{
	//Grundsätzlich Buchungsformular anzeigen
	$("#buchungsformular").css("visibility","visible");
	$('#formular-detail').jScrollPane({showArrows:true, scrollbarMargin:10});		
	var anzahl = 0;	
	var title = "";
	
	if (bereich == 1) {
		var txt_bp1 = $("#txt-bp1").val();
		var txt_bp2 = $("#txt-bp2").val();
		var txt_bp3 = $("#txt-bp3").val();
		var txt_bp4 = $("#txt-bp4").val();
		var txt_bp5 = $("#txt-bp5").val();
		
		//Sexkino
		if (anzahl < 4) {
			if (txt_bp1) {
				anzahl = new Number(txt_bp1);
				abfrage(anzahl,7);
				if (title == "") { title = "Sexkino"; }
			}
		}
		
		//Hotline & Cams
		if (anzahl < 4) {
			if (txt_bp2) {
				anzahl += new Number(txt_bp2);
				abfrage(anzahl,4)
					if (title == "") { title = "Hotline & Cams"; }
			}
		}
		
		//Cabaret
		if (anzahl < 4) {
			if (txt_bp3) {
				anzahl += new Number(txt_bp3);
				abfrage(anzahl,3)
				if (title == "") { title = "Cabaret"; }
			}
		}
		//private Amateure
		if (anzahl < 4) {
			if (txt_bp4) {
				anzahl += new Number(txt_bp4);
				abfrage(anzahl,8)
				if (title == "") { title = "Amateure"; }
			}
		}
		//Salons
		if (anzahl < 4) {
			if (txt_bp5) {
				anzahl += new Number(txt_bp5);
				abfrage(anzahl,9)
				if (title == "") { title = "Salons"; }
			}
		}
		
	}
	
	//Bereich Date & Nightlife
	if (bereich == 2) {
		var txt_bp6 = $("#txt-bp6").val();
		var txt_bp7 = $("#txt-bp7").val();
		var txt_bp8 = $("#txt-bp8").val();
		
		//Bar
		if (anzahl < 4) {
			if (txt_bp6) {
				anzahl = new Number(txt_bp6);
				abfrage(anzahl,12);
				if (title == "") { title = "Bar";}
			}
		}
		//Sauna
		if (anzahl < 4) {
			if (txt_bp7) {
				anzahl += new Number(txt_bp7);
				abfrage(anzahl,10);
				if (title == "") { title = "Sauna";}
			}
		}
		//Club
		if (anzahl < 4) {
			if (txt_bp8) {
				anzahl += new Number(txt_bp8);
				abfrage(anzahl,5);
				if (title == "") { title = "Sexy Club";}
			}
		}
	}
	
	//Bereich Shopping
	if (bereich == 3) {
		var txt_bp9 = $("#txt-bp9").val();
		var txt_bp10 = $("#txt-bp10").val();
		var txt_bp11 = $("#txt-bp11").val();
		
		//Sexshop
		if (anzahl < 4) {
			if (txt_bp9) {
				anzahl = new Number(txt_bp9);
				abfrage(anzahl,11);
				if (title == "") { title = "Sextoys";}
			}
		}
		//Videos
		if (anzahl < 4) {
			if (txt_bp10) {
				anzahl += new Number(txt_bp10);
				abfrage(anzahl,13);
				if (title == "") { title = "Video";}
			}
		}
		//Fetish
		if (anzahl < 4) {
			if (txt_bp11) {
				anzahl += new Number(txt_bp11);
				abfrage(anzahl,6);
				if (title == "") { title = "Fetish";}
			}
		}
	}	
	
	//Bereich Escort & Drive
	if (bereich == 4) {
		var txt_bp12 = $("#txt-bp12").val();
		
		//Escort
		if (anzahl < 4) {
			if (txt_bp12) {
				anzahl = new Number(txt_bp12);
				abfrage(anzahl,1);
				if (title == "") { title = "Escort";}
			}
		}
	}	
	
	//Bereich Books
	if (bereich == 5) {
		var txt_bp13 = $("#txt-bp13").val();
		
		//Sexshop
		if (anzahl < 4) {
			if (txt_bp13) {
				anzahl = new Number(txt_bp13);
				abfrage(anzahl,2);
				if (title == "") { title = "Books";}
			}
		}
	}
	
	//erste Selectbox setzen
	$("#select_1").each(function(){
		$("#select_1 option:contains('"+title+" - 12 Monate')").attr("selected", true);
	});


}


function abfrage(anzahl,cid)
{
	var banner2_content = $("#banner2").html();
	var banner3_content = $("#banner3").html();
	var banner4_content = $("#banner4").html();
	
	if (anzahl > 1) //2
	{
		if (banner2_content == "")
		{
			$.get("ajax/setNewBannerform.php", {banner:2,cid:cid},
						function(data) {
							$("#banner2").html(data);
							$('#formular-detail').jScrollPane({showArrows:true, scrollbarMargin:10});
						}
					);
		}
	}
	
	if (anzahl > 2) //3
	{
		if (banner3_content == "")
		{
			$.get("ajax/setNewBannerform.php", {banner:3,cid:cid},
						function(data) {
							$("#banner3").html(data);
							$('#formular-detail').jScrollPane({showArrows:true, scrollbarMargin:10});
						}
					);
		}
	}
	
	if (anzahl > 3) // 4
	{
		if (banner4_content == "")
		{
			$.get("ajax/setNewBannerform.php", {banner:4,cid:cid},
						function(data) {
							$("#banner4").html(data);
							$('#formular-detail').jScrollPane({showArrows:true, scrollbarMargin:10});
						}
					);
		}
	}
	
	return false;
}

function showBannerausgabe(uid)
{
	var el = "bannerausgabe_" + uid;
	$("#" + el).toggle();
}

function closeHelper() {
	$("#textbox-helper").hide();
}

