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

$(document).ready(function(){

	// Beispieltext für das Kontaktformular + minimales Errorhandling vor dem Abschicken
	var example_tmp = [];
	$("form#contact-form p:not(.empty) input.text, form#contact-form textarea").each(function(){
		example_tmp[$(this).attr('name')] = $(this).attr('value');
		$(this).focus(function(){
			if($(this).attr('value')==example_tmp[$(this).attr('name')] && !$(this).hasClass('sent')){
				$(this).attr('value', '');
			}
			$(this).css({color: '#565650'});
			//$(this).css({'background-image': 'none'});
		});
		$(this).blur(function(){
			if($(this).attr('value')==''){
				$(this).attr('value', example_tmp[$(this).attr('name')]);
				//$(this).css({'background-image': 'none'});
				$(this).css({color: '#e0ded8'});
			}
			/*
			else {
				// Name (nicht unter 5 Zeichen)
				if($(this).attr('name')=='form_name'){
					var right = $.trim($(this).attr('value')).length > 5;
				}
				// E-Mail (Syntax)
				else if($(this).attr('name')=='form_mail'){
					var right = /[a-z0-9\.\-_]+\@[a-z0-9\.\-_]\.[a-z]{2,4}/i.test($(this).attr('value'));
				}
				// Text (nicht unter 5 Zeichen)
				else if($(this).attr('name')=='form_msg'){
					var right = $.trim($(this).attr('value')).length > 5;
				}
				// Richtig/Falsch-Icon zeigen
				if(right){$(this).css({'background-image': 'url(/img/form-input-right.png)'});}
				else {$(this).css({'background-image': 'url(/img/form-input-wrong.png)'});}
				$(this).css({'background-position': 'right top','background-repeat': 'no-repeat'});
			}
			*/
			//$(this).css({color: '#e0ded8'});
		});
	});
	
	// Externe Links in neuem Fenster öffnen
	$("a[@rel~='external']").click(function(){
		window.open(this.href);
		return false;
	});
	
	// Flashfilm laden
	if($('#flashcontainer img').attr('class')){
		// Filename vom Flashmovie aus den Klassen des Bildes extrahieren.
		// Groß-/Kleinschreibung und Zahlen erlaubt. Präfix "loadmovie-".
		//var swf = $('#flashcontainer img').attr('class').replace(/^loadmovie-([a-zA-Z0-9]*)$/, '/swf/$1.swf');
		var swf = $('#flashcontainer img').attr('class');
		var flvs = $('#flashcontainer img').attr('class').split("?");
		var flv = 'videos/'+flvs[1];
		// Statischen Content durch Flashmovie ersetzen (Rückgabewert: Embed-Objekt)
		var api = flashembed('flashcontainer',{src:swf,width:'533',height:'400',version:[9,0],allowfullscreen:'false',allowscriptaccess:'always'},{videoURL:flv});
	}
	
	// Kommunikation der Navigation mit dem Flashfilm
	$("a[@rel~='flash-play']").each(function(){
		$(this).click(function(){
			// URL senden und bei Erfolg normales Linkverhalten deaktivieren		
			if(api.loadPage($(this).attr('href'))){return false;}
			else {return true;}
		});
	});
	
	// Flashfilm austauschen
	$("ul li a[@rel~='flash-replace']").each(function(){
		$(this).click(function(){	
			alert('Flash-Film austauschen: '+$(this).text());
			return false;
		});
	});

});
