/**
 * Custom javascript file
 *
 * Contains custom actions needed in Streamlike Luxe webTV
 *
 * Can be customized for personal needs.
 *
 * @package    webTV Luxe
 * @author     Antony Simonneau <support@mediatech.fr>
 * @version $LastChangedDate: 2009-04-28 13:37:00 +0200 (mar 28 avr 2009) $ -- $LastChangedRevision: 111 $
 * @copyright  Copyright (c) 2009, {@link http://www.mediatech.fr Mediatech}
*/

function list_action(elem){
	upd_results(elem.options[elem.selectedIndex].value, 0, '', ''); 
	upd_rss(elem.options[elem.selectedIndex].value, '', Jlang);
	get_med_id(elem.options[elem.selectedIndex].value, '', '');
	$('seek_text').value = '';
}

function set_orderClause(orderClause) {
	$(orderClause).selected = true;
}

function choose_upd_method(value) {
	if (Jplaylist) {
		upd_results(Jplaylist, 0, value, Jlang);
		get_med_id(Jplaylist, value, Jlang);
	} else {
		search_media(Jlang, SeekValue, 0)
		get_med_id('', '', '', 1);
	}
}


// Chaining media functions
function thisMovie(movieName) {
     if (navigator.appName.indexOf("Microsoft") != -1) {
          return window[movieName]
     }
     else {
          return document[movieName]
     }
}

// Play
function VideoPlay() {
	thisMovie("remoteControl").callVideoPlay();
}

// Pause
function VideoPause() {
	thisMovie("remoteControl").callVideoPause();
}

// Stop
function VideoStop() {
	thisMovie("remoteControl").callVideoStop();
}

// Media seeking (tc = timecode in seconds)
function VideoScrub(tc) {
	thisMovie("remoteControl").callVideoScrub(tc);
}

function VideoSwitchCC(lng, timecode) {
	tc=s2hms(timecode);
	alert(tc);
}

// Timecode transformations in hh:mm:ss
function s2hms(sec) {
	h = parseInt(sec / 3600);
	m = parseInt((sec - 3600 * h) / 60);
	s = parseInt(sec - 3600 * h - 60 * m);
	if (s < 10) s = "0" + s;
	if (m < 10) m = "0" + m;
	if (h > 1) h = "h" + ":";
	else h = "";
	return h + m + ":" + s;
}

// Get end of media signal
function sendAction(action) {
	/*$('grr').innerHTML = action ;*/
	if (action == 'end' && $('chain_yes').checked) {
		if (MediaPointer > 0 ) MediaPointer = MediaPointer + 1; else MediaPointer =1;
		if(typeof(ListMedias[MediaPointer]) != 'undefined'){
			new_media(ListMedias[MediaPointer]); 
			upd_information(ListMedias[MediaPointer]); 
			related_medias(ListMedias[MediaPointer], Jlang)	;
		}
	}
}


function activateAutostart() {
	if ($('chain_yes').checked) $('autostart_yes').checked = true;
}

