﻿// JScript-Datei

function cstyle(s)
{
    $get("hstyle").href = s;
}

var lp = true;
var quali = 15;
var video = 0;
var channel = 2;
var content_r = 1;
var big = false;
var aktz = 0;


function mp_big()
{
    big = !big;
    if (big)
    {
        $get("rechts").style.width = 10;
        $get("rechts").style.visibility = "hidden";
    }
    else
    {
        $get("rechts").style.visibility = "visible";
    }
    play(video);
}


function set_quali(q)
{
    quali = q;
    set_lp(video,channel);
}

function set_lp(vid,cid)
{
    video = vid;
    channel = cid;
    $get("Label_player").innerHTML = "<img width=\"33\" height=\"33\" src=\"images/spinner.gif\">";
    var br
    if (Sys.Browser.agent == Sys.Browser.InternetExplorer)
    {
        $get("navi").style.visibility = "visible";
        br = "IE";
    }
    else
    {
        
        $get("navi").style.visibility = "hidden";
        br="FF";
        if (Sys.Browser.agent == Sys.Browser.Firefox) br = "FF"
        if (Sys.Browser.agent == Sys.Browser.Safari) br = "saf"
        if (Sys.Browser.agent == Sys.Browser.Opera) br = "ope";
    }
    lp = true;
    
    if (vid > 0)
    {
        $get("navi").style.visibility = "hidden";
    }
    
    PageMethods.get_player(vid,br,cid,quali,big,get_lp_result,onError);
    if (content_r == 1) get_akt();
    
}

function get_lp_result(result,userContext,methodName)
{
    
    $get("Label_player").innerHTML = result ;
    
}

function get_ph(cid)
{
    //$get("Label_header_akt").innerHTML = "&nbsp;";
    PageMethods.get_phinweis(0,quali,cid,get_ph_result,onError);
    
    
}

function show_detail(id,typ)
{
     window.open('details.aspx?typ=' + typ + '&vid=' + id,'','width=600,height=250')
}

function get_ph_result(result,userContext,methodName)
{
    
    $get("content_ri").innerHTML = result;
    
}

var od_links = 0;
var od_kat = 0;

function get_akt()
{
    if (big) return;
    if ((video == 0) && (lp))
    {
        PageMethods.get_text(0,quali,channel,get_text_result,onError);
    }
    else
    {
        PageMethods.get_text(video,quali,channel,get_text_result,onError);
    }
}

function get_text_result(result,userContext,methodName)
{
    //alert(result)
    $get("content_ri").innerHTML = result;
}

function get_content(fname)
{
    PageMethods.get_content(fname,get_content_result,onError);
    
}

function get_content_result(result,userContext,methodName)
{
    //alert(result)
    $get("Label_player").innerHTML = result;
}


var logged_in = true;
function get_od(root,kat,start)
{
    
    od_links = start;
    od_kat = kat;
    $get("od").innerHTML = "<img widht=\"33\" height=\"33\" src=\"images/spinner.gif\">";
    
    PageMethods.get_od(root,kat,start,logged_in,get_od_result,onError);
    
    
}

function get_od_result(result,userContext,methodName)
{
    
    
    $get("od").innerHTML = result;
    
}

function od_close()
{
    
    
    $get("od").innerHTML = "";
    
}

function onError(error,userContext,methodName)
{
    alert(error.get_message());
}

function nav_left()
{
    get_od(od_kat, od_links -5);
}

function nav_right()
{
    get_od(od_kat, od_links +5);
}

function play(id)
{
    video = id;
    if (Sys.Browser.agent == Sys.Browser.InternetExplorer)
    {
        
        //mp_setfile('act_video.aspx?v=' + id + "&q=" + quali)
        set_lp(id,2);
    }
    else
    {
        set_lp(id,2);
    }
}

function do_search()
{
    $get("od").innerHTML = "<img widht=\"33\" height=\"33\" src=\"images/spinner.gif\">";
    
    PageMethods.do_search(document.form1.suche.value,0,true,get_search_result,onError);
}

function search_next(se,st)
{
    $get("od").innerHTML = "<img widht=\"33\" height=\"33\" src=\"images/spinner.gif\">";
    //alert(document.form1.suche.value)
    PageMethods.do_search(se,st,logged_in,get_search_result,onError);
}


function get_search_result(result,userContext,methodName)
{
    
    
    $get("od").innerHTML = result;
    
}


function is_aktuell()
{
    if (big) return;
    if ((video == 0) && (lp))
    {
        
        PageMethods.is_aktuell(aktz,quali,channel,get_is_aktuell_result,onError);
    }
    else
    {
    }
}

function get_is_aktuell_result(result,userContext,methodName)
{
    //$get("od").innerHTML = result + new Date;
    if (result != aktz)
    {
        aktz = result;
        get_akt();
    }
}

function refresh_ph()
{
  if (lp) is_aktuell();
}


function start_t()
{
window.setInterval ("refresh_ph()",10000);
}



