traceable=false;
var AjaxaRepositoryBaseUrl="http://videos.timmaelzer.bulldocs.de/";
function rptReady(objr,ctx){
     $get(ctx.container).innerHTML=RenderRepeater(ctx.name, objr);
     if(ctx.ToDo) window.setTimeout(ctx.ToDo,ctx.Time?ctx.Time:20);
}
function LoadInitialVideo(){
    if(FirstLoadVideo){
        ShowVideo(FirstLoadVideo);
    } else if(VideoLists["Newest"].collection.length!=0){
        ShowVideo(VideoLists["Newest"].collection[0]);
    }
}

function VideoRated(html){
    //$get("videoRate").innerHTML=html;
}

function RefreshRate(video){
    
}

function RateIsRefreshed(obj,ctx){
    if(obj && ctx.obj){
        for(var key in obj)
            ctx.obj[key]=obj[key];
        $get("videoRate").innerHTML = obj["AvgRatableImg"];
        ctx.obj.nextRefreshDate=new Date();
        ctx.obj.nextRefreshDate.setSeconds(ctx.obj.nextRefreshDate.getSeconds() + 10);
    }
}
function searchFull(txt){
    Search(txt);
    document.getElementById("RChannel").style.display="none";    
    document.getElementById("RSearch").style.display="block";    
}

function searchFullBottom(txt){
    searchFull(txt);
}

function Search(searchStr){
      VideoLists["searchList"].Search(searchStr);
}
var RENDER_IPAD_HTML5Video = navigator.userAgent.toLowerCase().indexOf("ipad") > -1 && !!document.createElement('video').canPlayType;

function ShowVideo(video){
    if(!video) return;
    if(!video.nextRefreshDate || video.nextRefreshDate<new Date())
        RefreshRate(video);
    currentVideo=video;
    rptReady([video],{name:"player",container:"videoDiv",ToDo:Increment});
    if (RENDER_IPAD_HTML5Video && video.InterfaceId == 0)
        WriteHTML5Video(video);
    else
    	WriteFlashContent(video.Id,video.InterfaceId,video.InterfaceInfo);
}
function WriteHTML5Video(video, autoplay) {
    $get('flash-content').innerHTML = '<video src="' + AjaxaRepositoryBaseUrl + video.Id +'.DBig.mp4' + '" autobuffer="true" onplay="SendLog(this,1);" ontimeupdate="SendLog(this);" controls="true" width="' + PlayerDim.Width + '" height="' + PlayerDim.Height + '" poster="' + AjaxaRepositoryBaseUrl + video.Id + '.b.jpg' + '" />';
}
function SendLog(vobj, typ) {
    if (!typ) {
        if (vobj.currentTime == 0) return;
        var typ = Math.round(100 * vobj.currentTime / vobj.duration);
        if (typ % 10 <= 8) return;
        typ = 200 + (Math.ceil(typ / 10) * 10);
    }
    if (vobj.tracked && vobj.tracked["L" + typ]) return;
    PrepareLog(vobj);
    var src = "http://b2b.splaytv.de/Comp/nI2UN7S4oac70p_HhzfbV0/PlayerComm.ashx?InfoType=" + typ + "&Info=" + vobj.currentTime;
    for (var key in vobj.logParams)
        src += "&" + key + "=" + vobj.logParams[key];
    LogFrame.src = src;
    
}
var LogFrame = null;
function PrepareLog(vid) {
    if (LogFrame && vid.prms) return;
    vid.logParams = { Psession: GetSession(), ClientId: "", Action: "L", Type: "10", VideoId: currentVideo.Id };
    vid.tracked = {};
    if (LogFrame) return;
    LogFrame = document.createElement("IFRAME");
    LogFrame.style.position = "absolute";
    LogFrame.style.visibility = "hidden";
    document.body.appendChild(LogFrame);
}
function GetSession() {
        var result, i;
        result = '';
        var guid = new Date().getTime().toString(16).toUpperCase();
        for (var j = 0; j < 32; j++) {
            if (j == 8 || j == 12 || j == 16 || j == 20)
                result = result + '-';
            if (j < guid.length) i = guid.charAt(j);
            else i = Math.floor(Math.random() * 16).toString(16).toUpperCase();
            result = result + i;
        }
        return result;
    }
function changeChannel(cid, videoList, ind, video) {

    if (videoList)
        FirstLoadVideo = VideoLists[videoList].collection[ind];
    else if (video)
        FirstLoadVideo = video;
    else
        FirstLoadVideo = null;
    if(SetChannel(CurrentChannel,cid))
        InitializeLists();
}
function SetChannel(oldChannel,cid){
    if(oldChannel==cid) return true;
    if(cid!=-1 && !Channels["C" + cid]){
        changeChannel(-1);
        return false;
    }
    var oldCh=$get("channel" + oldChannel);
    if(oldCh)
        oldCh.className="inactive";
    CurrentChannel=cid;
    var cTitle=cid<0?"ALL":Channels["C" + cid].ChannelTitle.toUpperCase().substr(3);
    $get("ChannleTitle").innerHTML=cTitle;
    $get("channel" + cid).className="active";
    return true;
}
new VideoList("videos","movieList","videos",OrderType.Title,0,PagingType.Sliding,5,{
              PreviousItem:'<a href="#" class="pagination-backward" onclick="VideoLists[\'videos\'].ChangePage({1});return false;"><img width="20" border="0" height="15" alt="vor" src="/static/imgs/btn-pagination-blank.gif"/></a>',
              NextItem:'<a href="#" class="pagination-forward" onclick="VideoLists[\'videos\'].ChangePage({1});return false;"><img width="15" border="0" height="15" alt="vor" src="/static/imgs/btn-pagination-blank.gif"/></a>'
              },3);
new VideoList("Top5","Top5_List","Top5",OrderType.MostViewed,5,PagingType.Navigation,5,{
    PreviousItem:'<a href="#" class="pagination-backward" onclick="VideoLists[\'Top5\'].ChangePage({1});return false;"><img width="20" border="0" height="15" alt="vor" src="/static/imgs/btn-pagination-blank.gif"/></a>',
    SelectedItem:'',
    NormalItem:'',
    Seperator:'',
    NextItem:'<a href="#" class="pagination-forward" onclick="VideoLists[\'Top5\'].ChangePage({1});return false;"><img width="15" border="0" height="15" alt="vor" src="/static/imgs/btn-pagination-blank.gif"/></a>'
    });
VideoLists["Top5"].Render = function(list,totalRecs,currentRow){
    this.collection = list;
    
    if(totalRecs>this.top){
    	this.totalRecs=this.top;
    	if(currentRow!=1)
    		this.collection.length=this.totalRecs-currentRow+1;
    }
    else
    	this.totalRecs = totalRecs;
    this.currentRow = currentRow;
    $get(this.container).innerHTML=RenderRepeater(this.template, this.collection);
    this.prepareNavigation();
}
new VideoList(null,null,"Newest",OrderType.Date,1,PagingType.None,1,null);
new VideoList("Recomended","Recomended","Recomended",OrderType.TopVideos,0,PagingType.Navigation,3,{
              PreviousItem:'<a href="#" class="pagination-backward" onclick="VideoLists[\'Recomended\'].ChangePage({1});return false;"><img width="20" border="0" height="15" alt="vor" src="/static/imgs/btn-pagination-blank.gif"/></a>',
              SelectedItem:'',
              NormalItem:'',
              Seperator:'',
              NextItem:'<a href="#" class="pagination-forward" onclick="VideoLists[\'Recomended\'].ChangePage({1});return false;"><img width="15" border="0" height="15" alt="vor" src="/static/imgs/btn-pagination-blank.gif"/></a>'
              },3);
              
new VideoList("searchList","searchList","searchList",OrderType.Search,0,PagingType.Navigation,3,{
              PreviousItem:'<a href="#" class="pagination-backward" onclick="VideoLists[\'searchList\'].ChangePage({1});return false;"><img width="20" border="0" height="15" alt="vor" src="/static/imgs/btn-pagination-blank.gif"/></a>',	      
              SelectedItem:'',
              NormalItem:'',
              Seperator:'',
              NextItem:'<a class="pagination-forward" onclick="VideoLists[\'searchList\'].ChangePage({1});return false;" href="#"><img width="15" border="0" height="15" alt="vor" src="/static/imgs/btn-pagination-blank.gif"/></a>'
              },-1,false,-1,true);
              
function InitializeLists(setChannel){
    if(setChannel && !SetChannel(-1,CurrentChannel)) return;        
    VideoLists["videos"].GetList();
    VideoLists["Newest"].GetList(LoadInitialVideo);
    VideoLists["Top5"].GetList();
    VideoLists["Recomended"].GetList();
    
}
function Initialize(){
    JS.Objects.GetChannels(rptReady,{name:'channels',container:'Channels', ToDo:"InitializeLists(true)"});
}


function PrepareRepeaters(){	
RepeaterTemplates.Add('videos',
//Header Template
null,
//Item Template'                           
'							<div class="clip_container" onclick="RenderVideo(\'[{this.Template.Name}]\',[{this.CurrentItemIndex}]);" onmouseover="switchStyleClass(this,\'clip_container_hover\')" onmouseout="switchStyleClass(this,\'clip_container\')">'+
'								<div class="mini-clip-bild"><img alt="" src="[{AjaxaRepositoryBaseUrl}][{this.CurrentItem.Id}].jpg" width="40" height="26" border="0" /></div>'+
'									<div class="text_container">'+
'										<p class="filmcliptitle">[{this.CurrentItem.Title}]</p>'+
'										<p class="filmclipdate">[{this.CurrentItem.DisplayDate.format("DD/MM/YYYY")}] ([{this.CurrentItem.Duration}] min)</p>'+
'									</div>'+
'								</div>'+
'							</div>',
							
//Alternate Item Template
null,
//Seperator Template
null,
//Footer Template
null);

RepeaterTemplates.Add('Top5',null,
//Item Template

'<div class="top5clip" onclick="RenderVideo(\'[{this.Template.Name}]\',[{this.CurrentItemIndex}]);" onmouseover="switchStyleClass(this,\'top5clip_hover\')" onmouseout="switchStyleClass(this,\'top5clip\')">'+
'	<div class="top5thumb" [{!RENDER_IPAD_HTML5Video && this.CurrentItem.InterfaceId==0?\'style="display:none"\':\'\'}]><span onclick="RenderVideo(\'[{this.Template.Name}]\',[{this.CurrentItemIndex}]);return false;" class="bild" style="position:relative;"><img alt="" src="[{AjaxaRepositoryBaseUrl}][{this.CurrentItem.Id}].jpg" width="90" height="60" /></span></div>'+
'	<div class="top5thumb" [{RENDER_IPAD_HTML5Video || this.CurrentItem.InterfaceId!=0?\'style="display:none"\':\'\'}]><embed height="60" width="90" type="application/x-shockwave-flash" src="[{AjaxaRepositoryBaseUrl}][{this.CurrentItem.Id}].Tumb.swf" bgcolor="#000000" quality="high" wmode="window" allowscriptaccess="always" flashvars="href=javascript:RenderVideo(\'[{this.Template.Name}]\',[{this.CurrentItemIndex}])"/></div>' +	
'			<div class="top5text">'+
'		<p class="top5cliptitle"><a class="title4" href="#" title="[{this.CurrentItem.Title}]" onclick="RenderVideo(\'[{this.Template.Name}]\',[{this.CurrentItemIndex}]);return false;">[{this.CurrentItem.Title}]</a></p>'+
'		<p class="top5clipdate">[{this.CurrentItem.DisplayDate.format("dd/MM/yyyy")}] ([{this.CurrentItem.Duration}] min)</p>'+
'	</div>'+
'</div>',
null,null,null);
RepeaterTemplates.Add('Recomended',null,
//Item Template
		'<div class="recommendclip" onclick="RenderVideo(\'[{this.Template.Name}]\',[{this.CurrentItemIndex}]);" onmouseover="switchStyleClass(this,\'recommendclip_hover\')" onmouseout="switchStyleClass(this,\'recommendclip\')">'+
		'	<div class="recommendthumb" [{!RENDER_IPAD_HTML5Video && this.CurrentItem.InterfaceId==0?\'style="display:none"\':\'\'}]><span onclick="RenderVideo(\'[{this.Template.Name}]\',[{this.CurrentItemIndex}]);return false;" class="bild" style="position:relative;"><img alt="" src="[{AjaxaRepositoryBaseUrl}][{this.CurrentItem.Id}].jpg" width="90" height="60" /></span></div>'+
		'	<div class="recommendthumb" [{RENDER_IPAD_HTML5Video || this.CurrentItem.InterfaceId!=0?\'style="display:none"\':\'\'}]><embed height="60" width="90" type="application/x-shockwave-flash" src="[{AjaxaRepositoryBaseUrl}][{this.CurrentItem.Id}].Tumb.swf" bgcolor="#000000" quality="high" wmode="window" allowscriptaccess="always" flashvars="href=javascript:RenderVideo(\'[{this.Template.Name}]\',[{this.CurrentItemIndex}])"/></div>' +	
		'			<div class="recommendtext">'+
		'		<p class="recommendcliptitle"><a class="title4" href="#" title="[{this.CurrentItem.Title}]" onclick="RenderVideo(\'[{this.Template.Name}]\',[{this.CurrentItemIndex}]);return false;">[{this.CurrentItem.Title}]</a></p>'+
		'		<p class="recommendclipdate">[{this.CurrentItem.DisplayDate.format("dd/MM/yyyy")}] ([{this.CurrentItem.Duration}] min)</p>'+
		'	</div>'+
		'</div>',
null,null,null);
RepeaterTemplates.Add('searchList',null,
//Item Template
		'<div class="recommendclip" onclick="RenderVideo(\'[{this.Template.Name}]\',[{this.CurrentItemIndex}]);" onmouseover="switchStyleClass(this,\'recommendclip_hover\')" onmouseout="switchStyleClass(this,\'recommendclip\')">'+
		'	<div class="recommendthumb" [{!RENDER_IPAD_HTML5Video && this.CurrentItem.InterfaceId==0?\'style="display:none"\':\'\'}]><span onclick="RenderVideo(\'[{this.Template.Name}]\',[{this.CurrentItemIndex}]);return false;" class="bild" style="position:relative;"><img alt="" src="[{AjaxaRepositoryBaseUrl}][{this.CurrentItem.Id}].jpg" width="90" height="60" /></span></div>'+
		'	<div class="recommendthumb" [{RENDER_IPAD_HTML5Video || this.CurrentItem.InterfaceId!=0?\'style="display:none"\':\'\'}]><embed height="60" width="90" type="application/x-shockwave-flash" src="[{AjaxaRepositoryBaseUrl}][{this.CurrentItem.Id}].Tumb.swf" bgcolor="#000000" quality="high" wmode="window" allowscriptaccess="always" flashvars="href=javascript:RenderVideo(\'[{this.Template.Name}]\',[{this.CurrentItemIndex}])"/></div>' +	
		'			<div class="recommendtext">'+
		'		<p class="recommendcliptitle"><a class="title4" href="#" title="[{this.CurrentItem.Title}]" onclick="RenderVideo(\'[{this.Template.Name}]\',[{this.CurrentItemIndex}]);return false;">[{this.CurrentItem.Title}]</a></p>'+
		'		<p class="recommendclipdate">[{this.CurrentItem.DisplayDate.format("dd/MM/yyyy")}] ([{this.CurrentItem.Duration}] min)</p>'+
		'	</div>'+
		'</div>',
null,null,null);

RepeaterTemplates.Add('TAGS',null,
'<a href="#" onclick="searchTag(\'[{this.CurrentItem}]\');return false;">[{this.CurrentItem}]</a>',
null,", ",null);

window.Channels = [];

RepeaterTemplates.Add('channels',
//Header Template
null,
//Item Template
'[{(E)>Channels["C" + this.CurrentItem.ChannelId]=this.CurrentItem;}]'+
'                <div class="clip_padding">'+
'                  <div id="channel[{this.CurrentItem.ChannelId}]" class="inactive">'+
'                    <div class="out">'+
'                      <div class="channel_container" onclick="changeChannel([{this.CurrentItem.ChannelId}]);" onmouseover="objhover(this.parentNode,\'over\');" onmouseout="objout(this.parentNode,\'out\');">'+
'                        <div class="bild_container"> <span class="text" title="[{this.CurrentItem.ChannelTitle.substr(3).toUpperCase()}]">[{this.CurrentItem.ChannelTitle.substr(3).toUpperCase()}]</span><br />'+
'                          <span class="subtext">'+
'                          </span> </div>'+
'                      </div>'+
'                    </div>'+
'                  </div>'+
'                </div>',
//Alternate Item Template

null,
//Seperator Template
null,
//Footer Template
null);

RepeaterTemplates.Add('player',
//Header Template
null,
//Item Template
'<div id="videowrapper">'+
'<div id="videoplayer">'+
'            <div class="player_container">'+
'              <div id="playing" style="height:[{PlayerDim.Height}]px">'+
'                <div id="flash-content"> To view a video, at least Flash Player version 9.0.28.0 is required!<br />'+
'                  <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"><img alt="" src="[{AJAX_WebBaseURL}]static/imgs/get_flash_player.gif" alt="Flash Player" /></a> </div>'+
'</div></div></div>'+
'<div id="playertext" class="clearfix">'+
//'	<p class="movietitle">[{this.CurrentItem.Title}]</p>'+
//'	<p class="moviedate">[{this.CurrentItem.DisplayDate.format("DD/MM/YYYY")}] ([{this.CurrentItem.Duration}] min)</p>'+
'    <p class="relatedvideos">Video-Tags : <span style="font-weight:bold; text-transform: none;">[{RenderRepeater(\'TAGS\',this.CurrentItem.UserTagList) }]</span></p>'+
'</div><!-- /playertext -->'+
'</div><!-- /videowrapper -->',
null,null,null);

}

