$(function() 	// Document is ready
{
var videoname = $("#CRhelper_videoname").text();
videoname = $.trim(videoname);
var bildname = $("#CRhelper_bildname").text();
bildname = $.trim(bildname);
var haus = $("#CRhelper_haus").text();
haus = $.trim(haus);

$('#link_'+haus+'').remove();

$('#CRcontainer_middle_left_startseite').mousewheel(); 
//$("#startseite_videoleiste").jCarouselLite({ speed: 600, visible: 5, mouseWheel: true, btnPrev: "#next_button", btnNext: "#prev_button" });
$("#haus_videoleiste").jCarouselLite({ vertical: true, speed: 600, visible: 6, scroll: 3, mouseWheel: true, btnPrev: "#up_button", btnNext: "#down_button", circular: false });

$('#CRcontainer_startseite_flash').flashembed({src: "./ContentRex/project/videomaterial/startseite.swf", wmode: 'transparent'});

if (videoname == '') 
{
$('#CRcontainer_haus_flash').css({border: '1px solid #1F222B', width: '650px', height: '240px'})
$('#CRcontainer_haus_flash').flashembed({src:"./ContentRex/project/videomaterial/"+haus+".swf", wmode: 'transparent'});
}
else
{
$('#CRcontainer_haus_flash').flashembed({src:"./ContentRex/project/videomaterial/player.swf", wmode: 'transparent'} ,
    {
        'flv':'http://www.theater-tv.com/flv/'+haus+'/'+videoname+'.flv' ,
        'showfullscreen': '1',
        'bgcolor':'000000',
        'bgcolor1':'363636',
        'bgcolor2':'363636',
        'videobgcolor':'000000',
        'sliderovercolor':'7994ec',
        'buttonovercolor':'7994ec',
        'showiconplay':'1',
        'startimage':'http://www.theater-tv.com/flv/'+haus+'/'+bildname+''

    });
}    

$(".video_eintrag img").hover(function ()
            {
               var imglink = $(this).attr('src');
                     var imgalt = $(this).attr('alt');
                
               fadetimer= $.timer(600, function ()
               {
                     
                    $("#info").html("<img id='info_bild' src='"+imglink+"' width='420' height='256' alt='' /><div id='info_text'>"+imgalt+"</div>");
                    $("#info").fadeIn(500);
                });
                
            },
            function ()
            {
                $("#info").fadeOut(600);
               fadetimer.stop();
               
            }
            );

/**
 * $(".hausvideo_eintrag img").hover(function ()
            {
                
                var imgalt = $(this).attr('alt');
                $("#videoinfo").html("<div id='videoinfo_text'>"+imgalt+"</div>");

                $("#videoinfo").fadeIn();
            },
            function ()
            {
                $("#videoinfo").fadeOut(100);
            }
            );
 */


$("#impressum").click(function()
{
    $("#impressumbox").fadeIn();
    return false;
});
$("#impressumbox").live("click",function()
{
    $("#impressumbox").fadeOut(100);
});

$("#ueberuns").click(function()
{
    $("#ueberunsbox").fadeIn();
    return false;
});
$("#ueberunsbox").click(function()
{
    $("#ueberunsbox").fadeOut(100);
});


$("#videopopupbox_close").click(function()
{
    $("#videopopupbox").fadeOut(100);
});

});

jQuery.timer = function (interval, callback)
 {
	var interval = interval || 100;

	if (!callback)
		return false;
	
	_timer = function (interval, callback) {
		this.stop = function () {
			clearInterval(self.id);
		};
		
		this.internalCallback = function () {
			callback(self);
		};
		
		this.reset = function (val) {
			if (self.id)
				clearInterval(self.id);
			
			var val = val || 100;
			this.id = setInterval(this.internalCallback, val);
		};
		
		this.interval = interval;
		this.id = setInterval(this.internalCallback, this.interval);
		
		var self = this;
	};
	
	return new _timer(interval, callback);
 };