﻿// JScript-Datei


var channel = 0;

function cstyle(s)
{
    $get("hstyle").href = s;
}



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)
    {
        
        br = "IE";
        $get("nav").style.visibility = "visible";
    }
    else
    {
        
        $get("nav").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
    PageMethods.get_player(vid,br,cid,quali,big,logged_in,get_lp_result,onError);
    if (content_r == 1) get_akt();
    
}

function get_lp_result(result,userContext,methodName)
{
    $get("cheader").innerHTML = "";
    if (result[0] == "True")
    {
        $get("Label_player").innerHTML = result[1] ;
        $get("cheader").innerHTML = "Channel:&nbsp;" + result[2];
    }
    else
    {
        $get("Label_player").innerHTML = result[1] ;
    }
    
}

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_text_big()
{
    if ((video == 0) && (lp))
    {
        PageMethods.get_text_big(0,quali,channel,get_text_big_result,onError);
    }
    else
    {
    }
}

function get_text_big_result(result,userContext,methodName)
{
    //alert(result)
    $get("od").innerHTML = result[0];
    $get("content_ri").innerHTML = result[1];    
}
function is_aktuell()
{
    if (big) return;
    if ((video == 0) && (lp))
    {
        
        PageMethods.is_aktuell(aktz,quali,channel,get_is_aktuell_result,onError);
    }
    else
    {
    }
}

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_is_aktuell_result(result,userContext,methodName)
{
    //$get("od").innerHTML = result + new Date;
    if (result != aktz)
    {
        aktz = result;
        get_akt();
    }
}

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;
}

function get_weitere()
{
    var con = $get("weitere").innerHTML;
    if (con == "")
    {
    PageMethods.get_content("weitere_sender",get_weitere_result,onError);
    }
    else
    {
    $get("weitere").innerHTML = "";
    }
    
}

function get_weitere_result(result,userContext,methodName)
{
    //alert(result)
    $get("weitere").innerHTML = result;
}



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").style.bgColor = "#000000";
    $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 refresh_ph()
{
if (lp) is_aktuell();
}



function start_t()
{
 window.setInterval ("refresh_ph()",10000);
}

function do_login()
{
    //alert(document.form2.pw.value);
    PageMethods.do_login(document.form2.pw.value,get_pw_result,onError);
}

function get_pw_result(result,userContext,methodName)
{
    
    logged_in = result[0];
    $get("Label_player").innerHTML = result[1];
    uid = result[2];
    
}

function do_search()
{
    $get("od").innerHTML = "<img widht=\"33\" height=\"33\" src=\"images/spinner.gif\">";
    //alert(document.form1.suche.value)
    PageMethods.do_search(document.form1.suche.value,0,logged_in,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 get_no_loggin(result,userContext,methodName)
{
    
    
    $get("od").innerHTML = result;
    
}

function start_rec()
{
    if (! logged_in)
    {
        PageMethods.no_loggin(get_no_loggin,onError);
        return;
    }
    //alert(uid);
    //alert(ip);
    //alert(sid);
    //alert(channel);
    
}

