// START #############################################################################################
// Buttonvorbereitung - Linkentfernung und Änderung in ein span
var movieTitel= jQuery('a.boxtitel').text();


jQuery(function(jQuery){
	jQuery('a.boxtitel').replaceWith('<span class="boxtitel">'+movieTitel+'</span>');
	
	// ON +++++++++++++++++++++++++
	jQuery('.boxtitel').click(function(){
		jQuery('#moviebox').animate({
			top: [130, 'easeOutCirc']
		}, 500);
			
		jQuery('#overlay').animate({
			top: [0, 'easeOutCirc']
		}, 500);
	});
	
	// OFF +++++++++++++++++++++++++
	jQuery('#overlay').click(function(){
		/*
		jQuery('#moviebox').animate({
			top: [-462, 'easeOutCirc']
		}, 500);
		
		jQuery('#overlay').animate({
			top: ['-135%', 'easeOutCirc']
		}, 500);
		
		jQuery('#flashkatalog').animate({
			top: [-800, 'easeOutCirc']
		}, 500)
		
		//bei Schließen Startbild wiederherstellen
		jQuery('#movie').replaceWith('<div id="movie"><img src="tl_files/images/client/movies/sample_1_en.png" /></div>');
		*/
	});
	jQuery('span#close').click(function(){
		jQuery('#moviebox').animate({
			top: [-462, 'easeOutCirc']
		}, 500);
		jQuery('#overlay').animate({
			top: ['-135%', 'easeOutCirc']
		}, 500);
		jQuery('#flashkatalog').animate({
			top: [-800, 'easeOutCirc']
		}, 500)
		//bei Schließen Startbild wiederherstellen
		jQuery('#movie').replaceWith('<div id="movie"><img src="tl_files/images/client/movies/sample_1_en.png" /></div>');
	});
	
	
	// Movies Abspielen
	var menge=jQuery('a#movbut').length;
		//alert(menge);

		jQuery.each(jQuery('#movielist a'), function(){
		//alert(this);
		//Liest den href-Wert aus 
		var movielink=jQuery(this).attr('href');
						
		//speichert den href-Wert ins Atribut rel ab
		jQuery(this).attr('rel', movielink);
						
		// auslesen des rel-Attributs
		var newRel=jQuery(this).attr('rel');
						
		// Bei Klick, öffnet richtigen Inhalt
		jQuery(this).click(function(){
			//window.open(newRel);
			var newReplacement='<div id="movie">';
			newReplacement += '<embed src="system/modules/ce_jw_media/html/mediaplayer/player.swf" width="500" height="350" allowfullscreen="true" allowscriptaccess="always" fullscreen="true" flashvars="file=http://www.indoorcycling.com/icg/'+newRel+'&autostart=true&fullscreen=true" />';
			newReplacement+='</div>';
							
			jQuery('#movie').replaceWith(newReplacement);
		});
						
		// Entfernt die Links aus href
		jQuery(this).removeAttr('href');
		//alert(movielink);
	});
		
		// Scroll
		jQuery('#movielist').jScrollPane({showArrows:false});
		jQuery('#scrollbox').jScrollPane({showArrows:false});
		jQuery('#servicesite').jScrollPane({showArrows:false});
		jQuery('#kontakt').jScrollPane({showArrows:false});
		
		
		
		
		// Flashkatalog ####################################################################################################################
	jQuery('#imagekatalog').click(function(){
		jQuery('#flashkatalog').animate({
			top: [0, 'easeOutCirc']
		}, 500)
		jQuery('#overlay').animate({
			top: [0, 'easeOutCirc']
		}, 500);
		
		// Imagekatalog laden #######
		var newFlashDE='<div id="flashinclude-de">';
		newFlashDE+='<object width="1200" height="650"><param name="movie" value="tl_files/fla/imagekatalog_1/swf/book.swf"><PARAM NAME=FlashVars VALUE="xmlFile=tl_files/fla/imagekatalog_1/xml/pages.xml"><embed src="tl_files/fla/imagekatalog_1/swf/book.swf" width="1198" height="650" FlashVars="xmlFile=tl_files/fla/imagekatalog_1/xml/pages.xml"></embed></object>';
		newFlashDE+='</div>';
		
		var newFlashEN='<div id="flashinclude-en">';
		newFlashEN+='<object width="1200" height="650"><param name="movie" value="tl_files/fla/imagekatalog_2/swf/book.swf"><PARAM NAME=FlashVars VALUE="xmlFile=tl_files/fla/imagekatalog_2/xml/pages.xml"><embed src="tl_files/fla/imagekatalog_2/swf/book.swf" width="1198" height="650" FlashVars="xmlFile=tl_files/fla/imagekatalog_2/xml/pages.xml"></embed></object>';
		newFlashEN+='</div>';
		
		var newFlashES='<div id="flashinclude-es">';
		newFlashES+='<object width="1200" height="650"><param name="movie" value="tl_files/fla/imagekatalog_ES/swf/book.swf"><PARAM NAME=FlashVars VALUE="xmlFile=tl_files/fla/imagekatalog_ES/xml/pages.xml"><embed src="tl_files/fla/imagekatalog_ES/swf/book.swf" width="1198" height="650" FlashVars="xmlFile=tl_files/fla/imagekatalog_ES/xml/pages.xml"></embed></object>';
		newFlashEN+='</div>';
		
		jQuery('#flashinclude-de').replaceWith(newFlashDE);
		jQuery('#flashinclude-en').replaceWith(newFlashEN);
		jQuery('#flashinclude-es').replaceWith(newFlashES);
		
	});
	
	jQuery('#haendlerkatalog').click(function(){
		jQuery('#flashkatalog').animate({
			top: [0, 'easeOutCirc']
		}, 500)
		jQuery('#overlay').animate({
			top: [0, 'easeOutCirc']
		}, 500);
		
		// Händlerkatalog laden #######
		var newFlashDE='<div id="flashinclude-de">';
		newFlashDE+='<object width="1200" height="700"><param name="movie" value="tl_files/fla/haendlerkatalog_DE/swf/book.swf"><PARAM NAME=FlashVars VALUE="xmlFile=tl_files/fla/haendlerkatalog_DE/xml/pages.xml"><embed src="tl_files/fla/haendlerkatalog_DE/swf/book.swf" width="1198" height="700" FlashVars="xmlFile=tl_files/fla/haendlerkatalog_DE/xml/pages.xml"></embed></object>';
		newFlashDE+='</div>';
		
		var newFlashEN='<div id="flashinclude-en">';
		newFlashEN+='<object width="1200" height="700"><param name="movie" value="tl_files/fla/haendlerkatalog_EN/swf/book.swf"><PARAM NAME=FlashVars VALUE="xmlFile=tl_files/fla/haendlerkatalog_EN/xml/pages.xml"><embed src="tl_files/fla/haendlerkatalog_EN/swf/book.swf" width="1198" height="700" FlashVars="xmlFile=tl_files/fla/haendlerkatalog_EN/xml/pages.xml"></embed></object>';
		newFlashEN+='</div>';
		
		var newFlashES='<div id="flashinclude-es">';
		newFlashES+='<object width="1200" height="700"><param name="movie" value="tl_files/fla/haendlerkatalog_ES/swf/book.swf"><PARAM NAME=FlashVars VALUE="xmlFile=tl_files/fla/haendlerkatalog_ES/xml/pages.xml"><embed src="tl_files/fla/haendlerkatalog_ES/swf/book.swf" width="1198" height="700" FlashVars="xmlFile=tl_files/fla/haendlerkatalog_ES/xml/pages.xml"></embed></object>';
		newFlashES+='</div>';
		
		jQuery('#flashinclude-de').replaceWith(newFlashDE);
		jQuery('#flashinclude-en').replaceWith(newFlashEN);
		jQuery('#flashinclude-es').replaceWith(newFlashES);
		
	});
});

