$(document).ready(function(){
	//dim_pop('images/popup.jpg', 'Rondo Guggeball 2011 - Jetzt Tickets sichern');
	$(window).resize(function(){img_load();});
	//Zaehlerstand();
});

/* function WertHolen() {
 var Wert = "";
 if(document.cookie) {
  Wertstart = document.cookie.indexOf("=") + 1;
  Wertende = document.cookie.indexOf(";");
  if(Wertende == -1) Wertende = document.cookie.length;
  Wert = document.cookie.substring(Wertstart,Wertende);
 }
 return Wert;
}

function WertSetzen(Bezeichner, Wert, Verfall) {
 var jetzt = new Date();
 var Auszeit = new Date(jetzt.getTime() + Verfall);
 document.cookie = Bezeichner+"="+Wert+"; expires="+Auszeit.toGMTString()+";";
}

function Zaehlerstand() {
 var Verfallszeit = 1000*60*60*24*365;
 var Anzahl = WertHolen();
 var Zaehler = 0;
 if(Anzahl != "") Zaehler = parseInt(Anzahl);
 if(document.cookie) {
  Zaehler = Zaehler + 1;
  WertSetzen("Zaehler",Zaehler,Verfallszeit);
 } 
 else {
  Zaehler = 1;
  WertSetzen("Zaehler",Zaehler,Verfallszeit);
 } 
//alert("Dies ist Ihr " + Zaehler + ". Besuch auf dieser Seite!");
 return (Zaehler);
}


var besuche = Zaehlerstand();

function dim_pop(img, alt) {
	if (besuche == 1 || besuche == 10) {
		$('#bla').remove();
		if($("#dim").css("display")=="none") {
			var filter="Alpha(opacity=70)";
			var perc=0.7;
			var el=document.getElementById("dim").style;
			el.filter=filter; el.MozOpacity=perc; el.KhtmlOpacity=perc; el.opacity=perc;
			$('#dim').fadeIn(100,function(){
				$("#lightbox-content").css('top',($(window).scrollTop()+100)+'px').html('<img src='+img+' onload="img_load();" /><div class="close" onclick="dim();">').show().click(function(){ dim(); });
				$('#dim').click(function(){ dim(); });
		});
		}
		else {
			$('#lightbox-content').hide().unbind();
			$('#dim').unbind().fadeOut(100);
			$('.close').hide();
		}
	}
}
*/




function dim(img, alt) {
	$('#bla').remove();
	if($("#dim").css("display")=="none") {
		var filter="Alpha(opacity=70)";
		var perc=0.7;
		var el=document.getElementById("dim").style;
		el.filter=filter; el.MozOpacity=perc; el.KhtmlOpacity=perc; el.opacity=perc;
		$('#dim').fadeIn(100,function(){
			$("#lightbox-content").css('top',($(window).scrollTop()+100)+'px').html('<img src='+img+' onload="img_load();" /><div class="close" onclick="dim();">').show().click(function(){ dim(); });
			$('#dim').click(function(){ dim(); });
	});
	}
	else {
		$('#lightbox-content').hide().unbind();
		$('#dim').unbind().fadeOut(100);
		$('.close').hide();
	}
}

function img_load() {
	$('.close').css('left',(parseInt($("#lightbox-content").width()/2)+parseInt($("#lightbox-content img").width()/2)-15)+'px');
	$('.close').css('top','-15px').show();
}
