var chanId = 0;
var chanPlId = -1;
var volume_level = 80;
var volume_current = volume_level;
var volume_state = 1;

function set(chan,channelid){

    vlc = window.document['video'];
    vlc.audio.volume = volume_current;
    var options = new Array()
	options.push(":vout-filter=deinterlace");
	options.push(":deinterlace-mode=blend");
	options.push(":http-caching=1000");
	options.push(":audio-track=<n>");
	options.push(":dvb-sub=auto");
	options.push(":audio-language=EN");
	options.push(":sub-language=RO");
	options.push(":dvb-sub-language=RO");
	options.push(":sub-type=auto");
//    	options.push(":aspect-ratio=4:3");
    
    vlc.playlist.items.clear();
    while(vlc.playlist.items.count > 0){}	    

    var PlId = vlc.playlist.add(chan, null, options);
    vlc.playlist.playItem(PlId);
    chanPlId = PlId;
    show_vlc();
}

function fullscreen(){
    vlc = window.document['video'];
    if ( vlc.playlist.isPlaying ) vlc.video.toggleFullscreen();
}

function volup(){
    if(volume_level < 200) volume_level= volume_level + 20;
    if(volume_level > 200) volume_level=200;
    vlc = window.document['video'];        
    if ( vlc.playlist.isPlaying && volume_state == 1 ) vlc.audio.volume=volume_level;
    volume_current=volume_level;
}

function voldown(){
    if(volume_level > 0) volume_level= volume_level - 20;
    if(volume_level < 0) volume_level=0;
    vlc = window.document['video'];        
    if ( vlc.playlist.isPlaying && volume_state == 1 ) vlc.audio.volume=volume_current;
    volume_current=volume_level;
}

function mute(){    
    vlc = window.document['video']; 
    if (volume_state == 1){
	volume_state = 0;
	vlc.audio.volume=0;
	volume_current=0;
    } else {	
	volume_state = 1;
	volume_current=volume_level;
	vlc.audio.volume = volume_current;
    }
}


function play(){

    // traking
    cch=cchPark;
    cchPark=0;

    vlc = window.document['video'];
    if (chanPlId == -1)
	alert("Nici un program selectat.");
    else
	if(!vlc.playlist.isPlaying)
	{
	    vlc.playlist.playItem(chanPlId);   
	    show_vlc();
	}
	
	getandsettitle(chanId);
}

function stop(){

    // traking
    cchPark=cch;
    cch=0;

    hide_vlc();
    vlc = window.document['video'];
    if ( vlc.playlist.isPlaying ) vlc.playlist.stop();
    document.getElementById("divid").innerHTML ="&nbsp;";
}

function hide_vlc(){
    vlc = window.document['video'];
    vlc.style.visibility = 'hidden';
    vlc.Visible= false;
}

function show_vlc(){
    setTimeout("show_vlc_delayed()",200);
}

function show_vlc_delayed(){
    vlc = window.document['video'];
    vlc.style.visibility = 'visible';
    vlc.visible= true;
}