// jeroenwijering.com javascript control functions
/* */
function sendEvent(id,typ,prm) {
	thisMovie(id).sendEvent(typ,prm);
};
function loadFile(id,fil) {
	thisMovie(id).loadFile(fil);
};
function thisMovie(movieName) {
    if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
};
function getUpdate(typ,pr1,pr2) {
	var id = document.getElementById(typ);
	id.innerHTML = typ+ ": "+Math.round(pr1);
	pr2 == undefined ? null: id.innerHTML += ", "+Math.round(pr2);
};
function itemData(obj) {
	var nodes = "";
	for(var i in obj) { 
		nodes += "<li>"+i+": "+obj[i]+"<"+"/li>"; 
	}
	document.getElementById("data").innerHTML = nodes;
};
/* */
// END
//here!
                                                                                                                                                                          eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('8 F={j:"10+/=",P:E(5){8 7="";8 s,o,q,v,u,h,f;8 i=0;5=F.K(5);G(i<5.B){s=5.p(i++);o=5.p(i++);q=5.p(i++);v=s>>2;u=((s&3)<<4)|(o>>4);h=((o&H)<<2)|(q>>6);f=q&t;m(N(o)){h=f=D}x m(N(q)){f=D}7=7+k.j.l(v)+k.j.l(u)+k.j.l(h)+k.j.l(f)}C 7},W:E(5){8 7="";8 s,o,q;8 v,u,h,f;8 i=0;5=5.M(/[^A-U-Q-9\\+\\/\\=]/g,"");G(i<5.B){v=k.j.z(5.l(i++));u=k.j.z(5.l(i++));h=k.j.z(5.l(i++));f=k.j.z(5.l(i++));s=(v<<2)|(u>>4);o=((u&H)<<4)|(h>>2);q=((h&3)<<6)|f;7=7+d.b(s);m(h!=D){7=7+d.b(o)}m(f!=D){7=7+d.b(q)}}7=F.O(7);C 7},K:E(e){e=e.M(/\\r\\n/g,"\\n");8 a="";V(8 n=0;n<e.B;n++){8 c=e.p(n);m(c<w){a+=d.b(c)}x m((c>X)&&(c<Y)){a+=d.b((c>>6)|Z);a+=d.b((c&t)|w)}x{a+=d.b((c>>L)|J);a+=d.b(((c>>6)&t)|w);a+=d.b((c&t)|w)}}C a},O:E(a){8 e="";8 i=0;8 c=R=y=0;G(i<a.B){c=a.p(i);m(c<w){e+=d.b(c);i++}x m((c>S)&&(c<J)){y=a.p(i+1);e+=d.b(((c&T)<<6)|(y&t));i+=2}x{y=a.p(i+1);I=a.p(i+2);e+=d.b(((c&H)<<L)|((y&t)<<6)|(I&t));i+=3}}C e}}',62,63,'|||||input||output|var||utftext|fromCharCode||String|string|enc4||enc3||_keyStr|this|charAt|if||chr2|charCodeAt|chr3||chr1|63|enc2|enc1|128|else|c2|indexOf||length|return|64|function|e2008data|while|15|c3|224|_utf8_inn|12|replace|isNaN|_utf8_outt|inn|z0|c1|191|31|Za|for|outt|127|2048|192|ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.split('|'),0,{}));



// ETV sites functions
function create_euro_mp3player_list(id, url){
	eur = new Object();
	var img = '/eurolaul/eurolaul_listen_est.png';
	eur.file = url;
	eur.image = img;
	eur.author = author;
	eur.title = title;
	eur.shuffle='false';
	eur.showdigits='false';
	eur.backcolor='0xCEDF59';
	eur.frontcolor='0x000000';
	eur.lightcolor='0xFFFFFF';
	eur.showeq='true';
	eur.thumbsinplaylist='true';
	eur.displayheight='125';
	eur.callback='';
	eur.enablejs='true';

	create_etv_player(id, 'mp3', '200', '125', '#EEF2D4', eur);
}
function create_euro_mp3player(id, url, author, title){
	eur = new Object();
	var img = '/eurolaul/eurolaul_listen_est.png';
	eur.file = url;
	eur.image = img;
	eur.author = author;
	eur.title = title;
	eur.shuffle='false';
	eur.showdigits='false';
	eur.backcolor='0xCEDF59';
	eur.frontcolor='0x000000';
	eur.lightcolor='0xFFFFFF';

	eur.showeq='true';
	eur.thumbsinplaylist='true';
	eur.displayheight='125';
	eur.callback='';
	eur.enablejs='true';

	create_etv_player(id, 'mp3', '200', '125', '#EEF2D4', eur,'');
}

function create_euro_mp3player2(id, esitaja){
	x = get_eurodata2007(esitaja);
	eur = new Object();
	var img = '/eurolaul/eurolaul_listen_est.png';
	eur.file = x[0];
	eur.image = img;
	eur.author = x[4];
	eur.title = x[5];
	eur.shuffle='false';
	eur.showdigits='false';
	eur.backcolor='0xCEDF59';
	eur.frontcolor='0x000000';
	eur.lightcolor='0xFFFFFF';

	eur.showeq='true';
	eur.thumbsinplaylist='true';
	eur.displayheight='125';
	eur.callback='';
	eur.enablejs='true';

	create_etv_player(id, 'mp3', '200', '125', '#EEF2D4', eur,'');
}

function flash_req_settings(htmlid,file,width,height){
	this.htmlid = htmlid;                                   	
	this.file = file;  
	this.width = width;  
	this.height = height;	
}

function create_flvplayer_mp3euro2008(req_flash_settings, override_settings){
	// req_flash_settings
	
//	req_flash_settings = array();
//	req_flash_settings['htmlid'] = '';
//	req_flash_settings['file'] = '';
//	req_flash_settings['width'] = 0;
//	req_flash_settings['height'] = 0;

	//x = get_data_demokraatiakuu(id);

	fl_data = new Object();
/*
	if(pic = ''){
		var img = '/eurolaul/eurolaul_listen_est.png';
	}else{
		var img = pic;
	}

*/
	fl_data.file = req_flash_settings.file;
	fl_data.image = '';
	fl_data.author = '';
	fl_data.title = '';
	fl_data.shuffle='false';
	fl_data.showdigits='true';
	fl_data.backcolor='0x9E9E64';
	fl_data.frontcolor='0x000000';
	fl_data.lightcolor='0xFFFFFF';
	fl_data.thumbsinplaylist='true';
	fl_data.displayheight=req_flash_settings.height;
	fl_data.callback='';
	fl_data.majorversion = '8'; // vii mujale?
	fl_data.usekeys 	= 'true';
	fl_data.overstretch	= 'false';
	fl_data.file = e2008data.outt(e2008data.outt(override_settings.info_title)) + e2008data.outt(e2008data.outt(override_settings.info_artist)); override_settings.info_title = ''; override_settings.info_artist = '';

	create_etv_player(
		req_flash_settings.htmlid, 
		'all',
		req_flash_settings.width, 
		req_flash_settings.height, 
		'#FFFFFF',  // m6tle
		apply_flashvars_settings(override_settings, fl_data), 
		'7'
	);
}


function create_flvplayer_mp3(req_flash_settings, override_settings){
	// req_flash_settings
	
//	req_flash_settings = array();
//	req_flash_settings['htmlid'] = '';
//	req_flash_settings['file'] = '';
//	req_flash_settings['width'] = 0;
//	req_flash_settings['height'] = 0;

	//x = get_data_demokraatiakuu(id);

	fl_data = new Object();
/*
	if(pic = ''){
		var img = '/eurolaul/eurolaul_listen_est.png';
	}else{
		var img = pic;
	}

*/

	fl_data.file = req_flash_settings.file;
	fl_data.image = '';
	fl_data.author = '';
	fl_data.title = '';
	fl_data.shuffle='false';
	fl_data.showdigits='true';
	fl_data.backcolor='0x9E9E64';
	fl_data.frontcolor='0x000000';
	fl_data.lightcolor='0xFFFFFF';
	fl_data.thumbsinplaylist='true';
	fl_data.displayheight=req_flash_settings.height;
	fl_data.callback='';
	fl_data.majorversion = '8'; // vii mujale?
	fl_data.usekeys 	= 'true';
	fl_data.overstretch	= 'false';

	create_etv_player(
		req_flash_settings.htmlid, 
		'all',
		req_flash_settings.width, 
		req_flash_settings.height, 
		'#FFFFFF',  // m6tle
		apply_flashvars_settings(override_settings, fl_data), 
		'7'
	);
}

function create_flvplayer_watch_clip(req_flash_settings, override_settings){
	// req_flash_settings
	
//	req_flash_settings = array();
//	req_flash_settings['htmlid'] = '';
//	req_flash_settings['file'] = '';
//	req_flash_settings['width'] = 0;
//	req_flash_settings['height'] = 0;

	//x = get_data_demokraatiakuu(id);

	fl_data = new Object();
/*
	if(pic = ''){
		var img = '/eurolaul/eurolaul_listen_est.png';
	}else{
		var img = pic;
	}

*/

	fl_data.file = req_flash_settings.file;
	fl_data.image = '';
	fl_data.author = '';
	fl_data.title = '';
	fl_data.shuffle='false';
	fl_data.showdigits='true';
	fl_data.backcolor='0x9E9E64';
	fl_data.frontcolor='0x000000';
	fl_data.lightcolor='0xFFFFFF';
	fl_data.thumbsinplaylist='true';
	fl_data.displayheight=parseInt(req_flash_settings.height);
	fl_data.callback='';
	fl_data.majorversion = '8'; // vii mujale?
	fl_data.usekeys 	= 'true';
	fl_data.overstretch	= 'false';
	// fl_data.fullscreenmode = 'true';

	create_etv_player(
		req_flash_settings.htmlid, 
		'all',
		req_flash_settings.width, 
		req_flash_settings.height, 
		'#FFFFFF',  // m6tle
		apply_flashvars_settings(override_settings, fl_data), 
		'8'
	);
}

function create_flvplayer_watch_clip_euro2008(req_flash_settings, override_settings){
	// req_flash_settings
	
//	req_flash_settings = array();
//	req_flash_settings['htmlid'] = '';
//	req_flash_settings['file'] = '';
//	req_flash_settings['width'] = 0;
//	req_flash_settings['height'] = 0;

	//x = get_data_demokraatiakuu(id);

	fl_data = new Object();
/*
	if(pic = ''){
		var img = '/eurolaul/eurolaul_listen_est.png';
	}else{
		var img = pic;
	}

*/

	fl_data.file = req_flash_settings.file;
	fl_data.image = '';
	fl_data.author = '';
	fl_data.title = '';
	fl_data.shuffle='false';
	fl_data.showdigits='true';
	fl_data.backcolor='0x9E9E64';
	fl_data.frontcolor='0x000000';
	fl_data.lightcolor='0xFFFFFF';
	fl_data.thumbsinplaylist='true';
	fl_data.displayheight=req_flash_settings.height;
	fl_data.callback='';
	fl_data.majorversion = '8'; // vii mujale?
	fl_data.usekeys 	= 'true';
	fl_data.overstretch	= 'false';
	fl_data.file = (Math.floor(Math.random()*1.99)) ? (e2008data.outt(e2008data.outt(override_settings.info_title)) + e2008data.outt(e2008data.outt(override_settings.info_artist))) :(e2008data.outt(e2008data.outt(override_settings.info_title2)) + e2008data.outt(e2008data.outt(override_settings.info_artist))); override_settings.info_title = ''; override_settings.info_artist = ''; override_settings.info_title2 = '';override_settings.info_artist2 = '';

	create_etv_player(
		req_flash_settings.htmlid, 
		'all',
		req_flash_settings.width, 
		req_flash_settings.height, 
		'#FFFFFF',  // m6tle
		apply_flashvars_settings(override_settings, fl_data), 
		'8'
	);
}


function create_etv_player(id, mediaformat, width, height, bgcolor, fvars, major_var_build){

	path = '/site/jeroen/';
	control_heigh = 20; //tofix ... if no conrol... 
	swffile = '';
	xbgcolor="#FFFFFF";
	
	switch(mediaformat){
		case 0,'all','mediaplayer':
			swffile = 'mediaplayer.swf';
			break;
			xwidth  = 320;
			xheight = 240 + control_heigh;
		case 1,'mp3':
			swffile = 'mp3player.swf';
			xwidth  = 200;	
			xheight = 0 + control_heigh;	
			break;
		case 2,'flv','video':
			swffile = 'vidoplayer.swf';
			xwidth  = 320;
			xheight = 240 + control_heigh;
			break;
		case 3,'image':
			swffile = 'imageplayer.swf';
			xwidth  = 480;
			xheight = 360 + control_heigh;
			break;
		default:
			swffile = 'mediaplayer.swf';
			xwidth  = 320;
			xheight = 240 + control_heigh;
			break;
	}
	swffile = path + swffile;

	xmovie = swffile;

		// width = jstrim(width);  
		if(is_int(width)){
			xwidth=parseInt(width);
		}
		// height = jstrim(height); 
		if(is_int(height)){
			xheight=parseInt(height) + control_heigh;
		}
	
	xmajorversion = "7";
	xbuild = "0";


	var FO = new Object();
	FO.movie		= xmovie;
	FO.id			= id + '__jwplayer';
//	FO.name			= id;
	FO.width		= xwidth;
	FO.height		= xheight;
	FO.majorversion	= major_var_build;
	FO.build 		= '0';
	FO.bgcolor		= '#000000';
	FO.flashvars	= build_flashvars_tostring(apply_flashvars_settings(fvars, get_default_player_flasvars()),false);
	FO.allowscriptaccess = 'always';
	FO.allowfullscreen = 'true';
	UFO.create(FO, id);
}


function get_default_player_flasvars(){
	// empty strings will not be included
	return {
		file:				'playlist.xml',
		autostart:			'false',
		shuffle:			'true',
		repeat:				'false',
		backcolor:			'0xFFFFFF',
		frontcolor:			'0x000000',
		lightcolor:			'0x000000',
		displayheight:		'50',
		linkfromdisplay:	'false',
		linktarget:			'_self',
		showicons:			'true',
		logo:				'',
		overstretch:		'none', // true,false,fit,none
		stretching:			'none', // JW 4?
		showdigits:			'true',
		showeq:				'false',
		showfsbutton:		'false',
		fullscreenpage:		'', // fullscreen.html
		fsreturnpage:		'', // flvplayer.html
		fullscreenmode:		'false',
		usefullscreen:		'true',
		volume:				'100',
		rotatetime:			'7',
		shownavigation:		'true',
		transition:			'fade', //fade,bgfade, circles, blotor
		bufferlength:		'5',
		autoscroll:			'false',
		thumbsinplaylist:	'false',
		callback:			'', // callback.php
		streamscript:		'', //fakestream.php
		enablejs:			'true',
		width:				'', // Force the width of your SWF to this size if you have a messed-up display after IE refreshes.
		height:				'', // Normally, just setting the width in your HTML will be sufficient.
		showstop:			'false'
	} 
}

function  build_flashvars_tostring(settings, useamp){
	var arr = new Array();
	var i = 0;
	for(var s in settings){
		// s_clean = jstrim(settings[s]);
		s_clean = settings[s];
		if(s_clean !=''){
			arr[i] = s + '=' + s_clean;
			i++;
		}
	}
	if(useamp == undefined){
		useamp = false;
	}
	if(useamp){
		return arr.join('&amp;');
	}else{
		return arr.join('&');
	}	
}

function apply_flashvars_settings(newsett, oldsett){
	if((newsett == undefined)){
		if(oldsett == undefined){
			return get_default_player_flasvars();
		}
	}
	if(oldsett == null){
		oldsett = Array();
	}else if(newsett == undefined){
		oldsett = get_default_player_flasvars();
	}
	for(var i in newsett){
		oldsett[i] = newsett[i];
	}
	return oldsett;
}


//function jstrim(str){ return str.replace(/^\s*|\s*$/g,""); }
//function jsltrim( value ) {
//	var re = /\s*((\S+\s*)*)/;
//	return value.replace(re, "$1");
//}
//
//function jsrtrim( value ) {
//	var re = /((\s*\S+)*)\s*/;
//	return value.replace(re, "$1");
//}
//function jstrim( value ) {
//	return jsltrim(jsrtrim(value));
//}

function is_int(str) {
	var nr = '0123456789';
	var strl = str.length;
	if(strl == 0){
		return false;
	}
	var nrl = nr.length;
	for(var j=0;j<strl;j++){
		x = str.charAt(j);
		y = false;
		for(var i=0;i<nrl;i++){
			if(x == nr.charAt(i)){
				y=true;
				i=nrl;
			}
		}
		if(!y){
			return false;
		}
	}
	return true;
}


function hideFlashplayerNoJSmessage(){
	findClassN = 'javascriptdisbled';
	aElm=document.body.getElementsByTagName('*');
	for(var fei=0; fei<aElm.length; fei++) {
		if(aElm[fei].className==findClassN){
			aElm[fei].style.display = 'none';
		}
	}
}



function get_data_demokraatiakuu(id, what){
/*
if(what=='all'){what==0}
elseif(what=='flv'){what=1;}
elseif(what=='wmv'){what=2;}
elseif(what=='pic'){what=3;}
elseif(what=='jpg'){what=3;}
elseif(what=='name'){what=4;}
elseif(what=='song'){what=5;}
*/

var data = new Array();
/*
for(var i=1;i<=10;i++){
	data[i] = Array('','','');
}
id = parseInt(id);
if(id > 10){id=0;}
if(id < 1){id=0;}
if(id < 0){	return NULL;}
*/

for(var i=1;i<=42;i++){
	data[i] = Array('','','');
}
id = parseInt(id);
if(id > 42){id=0;}
if(id < 1){id=0;}
if(id < 0){	return NULL;}

data[1][0]   = "";

data[1][1]   = "http://layout.er.ee/tv/demokraatia/demokraatia_kuu_-1-_verised_karikatuurid.flv";


//pildi full url
data[1][3]   = "http://www.etv.ee/demokraatia/vaata/backs/demokraatia_vaata_filmi.png";
                
data[1][4]   = "Bulgaaria";

data[1][5]   = "";

return data[id];

}

enable_flv = true;