// JavaScript Document

function embed(index, obj) {
	var html = jQuery(obj.parentNode).html();
	var parent = obj.parentNode;
	var thumb = jQuery(obj).children("param[name='thumb']").first();
	if (thumb.attr('value')){
		jQuery(parent).html("<a href='javascript:void(0);' class='embed' id='embed"+index+"'><img src='"+jQuery(thumb).attr('value')+"' alt='Video &ouml;ffnen' /></a> ");
	} else {
		jQuery(parent).html("<a href='javascript:void(0);' class='embed' id='embed"+index+"'>Video &ouml;ffnen</a> ");
	}
	jQuery(jQuery('#embed'+index)).click(function(){
		jQuery('#player-content').html(html);
		jQuery('#player').slideDown('slow', function(){
			jQuery.scrollTo(jQuery('#player'));
		});
		return false;
	});
}

function embedQuicktime(index, obj) {
	var html = '<object CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="780" height="439" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab"><param name="src" value="'+jQuery(obj).attr('href')+'"><param name="autoplay" value="true"><param name="loop" value="false"><param name="controller" value="true"><embed src="'+jQuery(obj).attr('href')+'" width="780" height="439" autoplay="true" loop="false" controller="true" pluginspage="http://www.apple.com/quicktime/"></embed></object>';
	jQuery(obj).click(function(){
		jQuery('#player-content').html(html);
		jQuery('#player').slideDown('slow');
		return false;
	});
}

function embedYoutube(index, obj) {
	var html = '<object CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="780" height="439" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab"><param name="src" value="'+jQuery(obj).attr('href')+'"><param name="autoplay" value="true"><param name="loop" value="false"><param name="controller" value="true"><embed src="'+jQuery(obj).attr('href')+'" width="780" height="439" autoplay="true" loop="false" controller="true" pluginspage="http://www.apple.com/quicktime/"></embed></object>';
	jQuery(obj).click(function(){
		jQuery('#player-content').html(html);
		jQuery('#player').slideDown('slow');
		return false;
	});
}

function quicktimestart() {
	jQuery('a[href$=mov]').each(function(index, obj) { embedQuicktime(index, this); });
	jQuery('object').each(function(index, obj) { jQuery(obj).wrap("<div />"); });
	jQuery('object').each(function(index, obj) { embed(index, obj); });
	jQuery('#player-close a').click(function(){ jQuery('#player').slideUp();jQuery('#player-content').html(); });
}

jQuery(document).ready(function(){
	quicktimestart();
});