var vwidth = 426;
var vheight = 350;
var color1 = '0xe6a6cc';
var color2 = '0xc61981';

function over(item) {
	item.style.color = "#c61981";
	item.style.borderColor = "#c61981";
	item.style.fontWeight = "bold";
}
function out(item) {
	item.style.color = "#e6a6cc";
	item.style.borderColor = "#e6a6cc";
	item.style.fontWeight = "normal";
}

function getVideoHtml(videoId) {
	var html = '';
	html += '<object width="' + vwidth + '" height="' + vheight + '">';
	html += '<param name="movie" value="http://www.youtube.com/v/' + videoId;
	html += '&hl=de&fs=1&rel=0&color1=' + color1 + '&color2=' + color2 + '&border=1"/>';
	html += '<param name="allowFullScreen" value="true"/>';
	html += '<embed src="http://www.youtube.com/v/' + videoId + '&hl=de&fs=1&rel=0&color1=' + color1;
	html += '&color2=' + color2 + '&border=1" type="application/x-shockwave-flash" ';
	html += 'allowfullscreen="true" width="' + vwidth + '" height="' + vheight + '">';
	html += '</embed></object>';
	
	return html;
}

function clear() {	
	$('div#overlayBackground').fadeOut(1000, function(){
		$("div#showTime").remove();
     	$(this).remove();
    });
}

function darken() {
	var background = $('<div/>');
	$(background).attr('id', 'overlayBackground')
		.animate({'opacity' : '.8'}, 1000)
		.css({'width' : $(document).width(),'height' : $(document).height()});
	$(background).click(clear);               
	$('body').append(background);
}



$(document).ready(function(){
	$('.videoLink').click(function(){
		var videoId = $(this).attr('id');
		darken();
                                
        var showTime = $('<div/>');
        $(showTime).attr('id', 'showTime');
        var width = $('body').width();
        var height = $('body').height();
        
        //$(showTime).css({'position': 'fixed', 'left': (width-vwidth)/2, 'top': (height-vheight)/2 });
        //$(showTime).css({'position': 'absolute', 'left': (width-vwidth)/2, 'top': (height-vheight)/2 });
       	
        if (jQuery.browser.msie && jQuery.browser.version < 8) {
        	$(showTime).css({'position': 'absolute'});
        	$(showTime).css({'left': (width-vwidth)/2, 'top': 300});
        	$('html,body').animate({scrollTop: 0}, 1000);
        } else {
        	$(showTime).css({'position': 'fixed'});          	   	
        	$(showTime).css({'left': (width-vwidth)/2, 'top': (height-vheight)/2});
        }
        
        $(showTime).html(getVideoHtml(videoId));
                    
       $('body').append(showTime);
	});
});
