// methods and variable that are only called/used/manipulated on this page have a preseeding sub_
// some variable definitions and functions are moved to octoshape.js:
//  - variable defi of client
//  - sub_get_octoclient and its subroutine mimetypes
//  - sub_startup_rec
//  - 
var mplayer;        // holds the embedded player
var variant = "";   // holds the variant
var lang 	= "en";  // holds the language, defalt is english
var install = false;


//metode kaldt i ONBEFOREUNLOAD i body
//n?r body bliver unloaded ved tryk p? external-player-link skal alert ikke komme
var sub_cl = "ok";
var sub_enabled = false;
var sub_warntext = "You are about to navigate away from the Octoshape Channel Selector. Any stream playing will be disconnected.";
function confirm_close() {
	if (sub_enabled){
		if (sub_cl == "ok"){
			if (window.event) { // IE
				event.returnValue = sub_warntext;
				return;
			} 
			// Fixme how to cancel this? Not possible?
			alert(sub_warntext);
			return true;
		}
		else if (sub_cl == "oknext"){
			sub_cl = "ok";
		}
		else {
			sub_cl = "oknext";
		}
	}
}

function set_confirm_close(enable) {
	sub_enabled = enable;
}


// the argement is just for easy switch between play_link_external/embedded and this function
function play_link_disabled(link){
	if (lang == "da"){
		alert("Denne kanal er midlertidigt ude af drift.\n    Pr\xf8v igen senere.");
	}
	else{
		alert("This channal is temporarily disabled.\n     Try agian later.");
	}
}


function selector_force_install(grouparg, typicalfile, customfile){
		set_confirm_close(false);
	
		// Clear of the mplayer div
		document.write("<div id=clear></div><br>")

	var html = get_plugin_selector(grouparg, typicalfile, "");
	var divmplayer = document.getElementById('divmplayer');
		divmplayer.innerHTML = html;

	var divchannels;
	try {
		divchannels = document.getElementById('divchannels');
		divchannels.style.width = "250px"; 
	}
	catch (exception) {
		divchannels = document.getElementById('divchannels_small');
		divchannels.style.width = "250px"; 
	}
}


	function open_channel_select_single(varia,lang){
		//alert("hurra");
		var ny = window.open("/play/selector/channels_single.asp?variant="+variant+"&lang="+lang+"","Octoshape", "height=250, width=520"); 
		ny.focus();
	}		

	function open_channel_select(varia,lang){
		var ny = window.open("/play/selector/channels.asp?variant="+variant+"&lang="+lang+"","Octoshape", "height=260, width=580"); 
		ny.focus();
	}		

	function open_channel_select_INTTEST(group,lang){
//		alert("open_channel_select\nLANG: "+lang+"\nGROUP; "+group);
		var ny = window.open("/play/selector/channelsINTTEST.asp?group="+group+"&lang="+lang+"","Octoshape", "height=260, width=580"); 
		ny.focus();
	}		


