/**
* --------------------------------------------------------------------
* UCI-KINOWELT "global.js"
* Version: 1.0, 18.06.2009
* by Martin Grögor (schwedensoft) KRANKIKOM GmbH
*
* Copyright (c) 2009 UCI-KINOWELT
*
* Changelog:
*    18.06.2009 initial Version 1.0
*    12.11.2009 initial Version 1.01 changeCinema
* --------------------------------------------------------------------
*/
$(document).ready(function() {
	/*
	alert($.browser.msie);

	jQuery.each(jQuery.browser, function(i, val) {
	$("<div>" + i + " : <span>" + val + "</span>")
	.appendTo(document.body);
	});
	*/
	//$('a[rel*=facebox]').facebox();
	var urllparam = location.href.split("/");

	if(!$.cookie('cookie_cinemaid')) {
		$("#fbanner").fadeOut("fast");
		$(".cinema_select").not(".oesterreich").load("/fb_cinema_select.php");
		$(".oesterreich").load("/fb_cinema_select_at.php");
		$(".cinema_select").show();
		return false;
	}

	$("#cinema_select li a").click( function() {
		if(urllparam[4] == 'buchung') return false;
		$("#fbanner").fadeOut("fast");
		$(".cinema_select").not(".oesterreich").load("/fb_cinema_select.php");
		$(".oesterreich").load("/fb_cinema_select_at.php");
		$(".cinema_select").show();
		return false;
	});

	$("#cinema_select li a img").not("#cinema_select li a").click( function() {
		var loc= $(this).attr("alt");
		var url= "/"+loc+"/Programm/Kinoinformation";
		window.location.href = url;
		return false;
	});
	$("#detail-tabs a.Info, #detail-tabs a.Preise, #detail-tabs a.Saele").click( function() {
		ReloadPixelImages('ProgrammKinoinformation'+ $(this).attr("class"),'Krankikom');
		$("#LLageplan").fadeOut("fast");
		$("#Content").html("<div style='text-align: center'><img src='/_includes/facebox/loading.gif'></div>");
		$("#detail-tabs li").removeClass("active");
		$(this).parent("li").addClass("active");
		$.post("/_lib/ajax/centerinfos.php", { siteid:$.cookie('cookie_cinemaid'),content:$(this).attr("href"),format: "json" },
		function(data){
			$("#Intro").html(data.intro);
			$("#Headline").html(data.headline);
			$("#Content").html($.base64Decode(data.content));
			$("#HeadlineAdresse").html('');
			$("#HeadlineAdresse").html(data.headlineadresse);
			$("#Adresse").html(data.adresse);

		}, "json");

		return false;
	});

	$("#trailer-tab a.top5, #trailer-tab a.previews, #trailer-tab a.neustarts, #trailer-tab a.empfehlungen").click( function() {
		$("#liste").html("<div style='text-align: center'><br /><br /><br /><br /><br /><br /><br /><img src='/_includes/facebox/loading.gif'></div>");
		$("#trailer-tab li").removeClass("active");
		$(this).parent("li").addClass("active");
		$.post("/_lib/ajax/trailerlseiten.php", { siteid:$.cookie('cookie_cinemaid'),content:$(this).attr("href"),format: "json" },
		function(data){
			$("#liste").html($.base64Decode(data.Content));

			$(".holder img").show();
			$("#small").fadeOut("fast");

		}, "json");

		return false;
	});

	$("#B2BKinoID").change( function() {
		var url= "/"+ $("#infolink").attr("alt") +"/B2B/KinoMieten/" + $("#B2BKinoID").val();
		window.location.href = url;
		return false;
	});
	$("#B2BMegaposterID").change( function() {
		var url= "/"+ $("#infolink").attr("alt") +"/B2B/Megaposter/" + $("#B2BMegaposterID").val();
		window.location.href = url;
		return false;
	});

	$(".perfbookable span, .changeCinema span").click( function() {
		var v = $(this).parent("a").attr("href");
		var newcinema = gup('site_id',v);
		if(newcinema && newcinema != $.cookie('cookie_cinemaid'))
			return confirm("Wollen Sie wirklich in ein anderes Kino wechseln und Ihr Stammkino verlassen? Bitte überprüfen Sie vor der Buchung, ob das gewählte Kino korrekt ist!");
	});
});

function gup( name,link ){  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  var regexS = "[\\?&]"+name+"=([^&#]*)";  var regex = new RegExp( regexS );  var results = regex.exec( link );  if( results == null )    return "";  else    return results[1];}