/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * JavaScript:				jQuery Goodies										   	   *
 * Version:					1.1													       *
 * Author:					cove/re-lounge (http://www.re-lounge.com)				   *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

$(document).ready(function(){

	// Fading in der Navigation (F�r alle au�er IE<=6)
	if($.browser!='msie' && $.browser.version!='6.0'){
		$('#head ul.nav li a:not(.active)').each(function(n){
			// Hilfsvariablen
			var content = $(this).text();
			var url = $(this).attr('href');
			// Markup einf�gen
			$(this).append('<div class="text">'+content+'</div>');
			$(this).find('div.text').css({'width': $(this).width()+40});
			$(this).append('<div class="bg">'+content+'</div>');
			$(this).find('div.bg').css({'width': $(this).width()+40,'opacity': 0});
			// Maushand forcieren (IE vergisst manchmal das Link-Verhalten)
			$(this).find('div.text,div.bg').css({'cursor': 'pointer'});
			// Hover-Funktion (fade)
			$(this).hover(
				function(){
					$(this).find('div.bg').stop();
					$(this).find('div.bg').fadeTo(300, 1);
				},
				function(){
					$(this).find('div.bg').stop();
					$(this).find('div.bg').fadeTo(300, 0);
				}
			);
			// Weiterleitung forcieren (IE vergisst manchmal das Link-Verhalten)
			$(this).find('div.text,div.bg').click(function(){
				window.location.href = url;
			});
		});
	}

	// Beispieltext (PLZ-Suche)
	if($('input#form_zip').attr('value')=='Ihre Postleitzahl'){
		$('input#form_zip').attr('value','');
		$('input#form_zip').example('Ihre Postleitzahl');
	}
	
	// Flash (Startseite)
	$("#promotion-screen").flashembed({
		src:'img/promotion.swf',
		width:'263',
		height:'312',
		allowfullscreen:'false',
		allowscriptaccess:'false',
		wmode:'transparent'}, {version:'6,0'});

	// Externe Links in neuem Fenster �ffnen (falls m�glich)
	$("a[@rel~='external']").click(function(){
		var blank = window.open(this.href);
		return (blank)?false:true;
	});

	// Leerzeichen (CMS-bedingt) aus Textarea entfernen
	if($("p.textarea textarea").text().length<=1){
		$("p.textarea textarea").text("");
	}
	
	$('a[@rel*=lightbox]').lightBox({
		imageLoading: 'img/lightbox/loading.gif',
		imageBtnClose: 'img/lightbox/close.gif',
		imageBtnPrev: 'img/lightbox/prev.gif',
		imageBtnNext: 'img/lightbox/next.gif',
		containerResizeSpeed: 350,
		txtImage: 'Bild',
		txtOf: 'von'
   });
   
   $("#mailform_field_15").val("Ermöglicht schnellere Kontaktaufnahme").css({
   		color: '#999'
   }).toggleDefaultText();

});

$.fn.toggleDefaultText = function(){
	var defaultValue = $(this).val();
	
	$(this).focus(function(){
		$(this).css('color','#000');
		
		if($(this).val() == defaultValue){
			$(this).val('');
		}
		
	});
	
	$(this).blur(function(){
		
		if($(this).val() == ""){
			$(this).val(defaultValue).css('color','#999');
		}
		
	});
};
