//Function zum Vorladen

try {
	(function(jQuery) {
		var cache = [];
		// Arguments are image paths relative to the current page.
		jQuery.preLoadImages = function() {
			var args_len = arguments.length;
			for (var i = args_len; i--;) {
				var cacheImage = document.createElement('img');
				cacheImage.src = arguments[i];
				cache.push(cacheImage);
			}
		}
	})(jQuery)
}
catch (e) {
	//Fehlerbehandlung
}

try {
	jQuery(document).ready(function() {
		//Hier zwischen Bilder zum Vorladen einfuegen (nur Bilder, die nicht sofort sichtbar werden ohne Interaktion!)
		jQuery.preLoadImages(
			'images/hg-sprung.png'
			,
			'images/hg-sprung-marked.png'
			,
			'images/hg-li-button.png'
		);
		jQuery(".lavaLamp").lavaLamp(
			{
				fx: "easeout",
				speed: 400
			}
		);
		jQuery('img').live('contextmenu',
			function(e) {
	     		return false;
			}
		);
	});
}
catch (e) {
	//Fehlerbehandlung
}

function getFirstMenu(activeId) {
	if (jQuery('#kopf-2').length == 1)
		jQuery('#kopf-2').attr('id','kopf-2-js');
	content = '<ul class="lavaLamp">';
	if (activeId == 'fm-null') {
		classNull = ' current';
		classEins = '';
		classZwei = '';
		classDrei = '';
		classVier = '';
		classFuenf = '';		
	}
	if (activeId == 'fm-eins') {
		classNull = '';
		classEins = ' current';
		classZwei = '';
		classDrei = '';
		classVier = '';
		classFuenf = '';
	}
	else if (activeId == 'fm-zwei') {
		classNull = '';
		classEins = '';
		classZwei = ' current';
		classDrei = '';
		classVier = '';
		classFuenf = '';
	}
	else if (activeId == 'fm-drei') {
		classNull = '';
		classEins = '';
		classZwei = '';
		classDrei = ' current';
		classVier = '';
		classFuenf = '';
	}
	else if (activeId == 'fm-vier') {
		classNull = '';
		classEins = '';
		classZwei = '';
		classDrei = '';
		classVier = ' current';
		classFuenf = '';
	}
	else if (activeId == 'fm-fuenf') {
		classNull = '';
		classEins = '';
		classZwei = '';
		classDrei = '';
		classVier = '';
		classFuenf = ' current';
	}
	content += '<li class="fm-null' + classNull + '"></li>';
	content += "\n";
	content += '<li class="fm-eins lavaLamp-no-bg' + classEins + '" id="homea"><a href="index.html">Willkommen</a></li>';
	content += "\n";
	content += '<li class="fm-zwei lavaLamp-no-bg' + classZwei + '" id="rundgang-bordell-hannovera"><a href="rundgang-bordell-hannover.htm">Rundgang</a></li>';
	content += "\n";
	content += '<li class="fm-drei lavaLamp-no-bg' + classDrei + '" id="girls-sex-hannovera"><a href="girls-sex-hannover.htm">Girls</a></li>';
	content += "\n";
	content += '<li class="fm-vier lavaLamp-no-bg' + classVier + '" id="preise-bordell-hannovera"><a href="preise-bordell-hannover.htm">Preise</a></li>';
	content += "\n";
	content += '<li class="fm-fuenf lavaLamp-no-bg' + classFuenf + '" id="events-bordell-hannovera"><a href="events-bordell-hannover.htm">Events</a></li>';

	document.write(content);
}



function putMBRequirements() {
	try {
			jQuery('span.mbinit').each(
				function() {
					imgTitle = jQuery(this).attr('title');
					jQuery('img',this).each(function() {
						orgImage = jQuery(this).attr('src');
						bigImage = orgImage.replace('.jpg','-gr.jpg');
						bigImage = bigImage.replace('images/','images/vergroesserung/');
					});
					jQuery(this).html(
						' <a href="' + bigImage + '" class="multibox" title="' + imgTitle + '" id="linkohne">' + jQuery(this).html() + '</a>'
					);
				}
			);
	}
	catch (e) {
		//Fehlerbehandlung
	}
}

function loadMultibox() {
	 window.addEvent('domready', function(){
	 	putMBRequirements();
		var box = new multiBox('multibox', {
			overlay: new overlay()
		});
	});
}


function showNewsPopup() {
	 jQuery(document).ready(function() {
		// ohne Timestamp: jQuery.get("events-bordell-hannover.htm", function(data){
		jQuery.get("events-bordell-hannover.htm?ts="+Number(new Date()), function(data){
		// Aktuelles Datum holen
		var heute = new Date();
		var aktJahr = heute.getFullYear();
		var aktMon = heute.getMonth()+1;
		// Wenn Schrittwert kleiner als 2, dann füge '0' hinzu.
		if(aktMon < 10)
			aktMon = '0'+aktMon;
		var aktTag = heute.getDate();
		if(aktTag < 10)
			aktTag = '0'+aktTag;
		var aktDatum = aktJahr +''+ aktMon + '' + aktTag;
		var aktuelleEintraege = new Array();
		var popupPfad = ''; 
		 
		 // Alle Einträge finden
		 jQuery(data).find('#content-mi .eintrag').each(function(index) {
			// Datum des Eintrags
			var datumZeit = jQuery(this).find('.xs').text().split("-");
			var datum = datumZeit[0].replace(/ /g, "");
			var datumParts = datum.split(".");
			var eintragDatum = datumParts[2]+''+datumParts[1]+''+datumParts[0];
			// Eintrag von heute oder in der Zukunft liegend
			if(eintragDatum >= aktDatum){
				// Falls ein Bild vorkommt
				if(jQuery(this).find('img').attr('src') != null && jQuery(this).find('img').attr('src') != undefined)
					aktuelleEintraege.push(jQuery(this).find('img').attr('src').replace(/-kl/g, ""));
			}
				
		 });

		 popupPfad = aktuelleEintraege[0];	   
		   if(popupPfad != '' && popupPfad != null){
		       jQuery('<div class="eventPopup" style="display:none;width:500px;background-color:transparent;position:absolute;top:0px;left:250px;z-index:1000;"><div class="eventPopupInner" style="width:500px;position:relative;text-align:center;"><img onmouseout="this.style.cursor=\'default\';" onmouseover="this.style.cursor=\'pointer\';" onclick="jQuery(\'.eventPopup\').fadeOut(\'slow\');" width="500" src="'+popupPfad+'" /><img onmouseout="this.style.cursor=\'default\';" onmouseover="this.style.cursor=\'pointer\';" onclick="jQuery(\'.eventPopup\').fadeOut(\'slow\');" style="position:absolute;top:0px;right:0px;" src="others/multibox/img/close.png" /></div></div>').appendTo('.dokument');		 
		       jQuery('.eventPopup').fadeIn('slow');
		   }
		   
		 });
	 });
}


// Cookie Funktion
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

// Popup für aktuelles Eventbild anzeigen
// Variante 1: Popup wird nur angezeigt, wenn Cookie bereits nicht gesetzt ist
/*
jQuery(document).ready(function() {
	if(jQuery.cookie("revisit") !== null){
		// wiederkehrender Besucher - nix tun
	}
	else {
		// Event Popup zeigen
		showNewsPopup();
		// Besucht Cookie setzen, beim nächsten Besuch gibt's kein alert
		jQuery.cookie("revisit", "ja");
	}
});
*/

// Variante 2: Popup wird nur angezeigt, wenn Variabel "skipPopupCookie" definiert und auf "true" gesetzt ist
jQuery(document).ready(function() {
	// Überprüfung ob Variabel skipPopupCookie definiert ist
	if(typeof skipPopupCookie!='undefined') {
		// Bei "true" Popup anzeigen
		if(skipPopupCookie == true) {
			showNewsPopup();
			skipPopupCookie = false;
		}
	}
});

