// DIGITAL MOBILES S.L (Digitalak): playlist-a.
// www.digitalak.com
<!--
var hasieraketa = 0; //Hasieraketa == 1,fill egin da, hasieraketa eman da!!
var my_playlist = new Array;//nire playlist-a
var my_playlist_first=0;
var id_my_playlist_cell;//kolorez aldatu behar den taula
var id_my_playlist_td_cell;//kolorez aldatu behar den taularen td-a
var id_my_playlist_ida;
var id_playlist_photo;
var playlist_momentukoa = -1;//hasieran playlist -1 izango da. Berrienak kasuan ere parametro gisa -1 pasatuko da.
// some variables to save
var currentPosition;
var endPosition;
var currentState;

function show_playlist(){

	document.getElementById('my_playlist').innerHTML=write_my_playlist();
}

function write_my_playlist(){

	var tmp = "<table width=\"266\" height=\"86\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"; 
	for (i=0;i<my_playlist.length;i++)
	{
		if (i > 0){
		tmp = tmp + "<tr>";
			tmp = tmp + "<td height=\"1\" width=\"266\">";
				tmp = tmp + "<table height=\"1\" width=\"266\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#869195\">";
				  tmp = tmp + "<tr>";
					tmp = tmp + "<td width=\"10\"></td>";
					tmp = tmp + "<td width=\"256\" bgcolor=\"#33474e\"></td>";
					tmp = tmp + "<td width=\"5\"></td>";
				  tmp = tmp + "</tr>";
				tmp = tmp + "</table>";
			tmp = tmp + "</td>";
		tmp = tmp + "</tr>";
		}
		tmp = tmp + "<tr>";
        tmp = tmp + "<td id=\"my_playlist_td_" + i +"\" bgcolor=\"#869195\" width=\"266\" align=\"left\" valign=\"top\">";
		tmp = tmp + "<table width=\"266\"  height=\"86\" onMouseOver=\"my_playlist_change_colour_over(this,'"+ my_playlist[i][5] +"','" + i +"')\" onMouseOut=\"my_playlist_change_colour_out(this,'"+ my_playlist[i][5] +"','" + i +"')\" id=\"my_playlist_" + i +"\" class=\"testubeltza\">";
			tmp = tmp + "<tr height=\"24\" onClick=\"javascript:my_playlist_play(" + i +")\">"; 
			tmp = tmp + "<td width=\"110\"><div align=\"center\"><img id=\"my_playlist_argazkia_" + i +"\" src="+ my_playlist[i][5] +"_0.jpg width=\"96\" height=\"73\" /></div></td>";
         	tmp = tmp + "<td id=\"my_playlist_td_" + i +"\" width=\"156\">"+ my_playlist[i][1] +"</td>";
		tmp = tmp + "</tr>";
		tmp = tmp + "</table>";	
		tmp = tmp + "</td>";
		tmp = tmp + "</tr>";
	}
	tmp = tmp + "</table>";
	return tmp;
}

function add_my_playlist(id,name,desc,longtext,url,photo,duration,date){
	var my_playlist_length = my_playlist.length;
	my_playlist[my_playlist_length]= new Array(7); // nire_playlist array-ko 2. dimentsioa sortu 6 aldagaikoa.
	my_playlist[my_playlist_length][0] = id;
	my_playlist[my_playlist_length][1] = name;
	my_playlist[my_playlist_length][2] = desc;
	my_playlist[my_playlist_length][3] = longtext;
	my_playlist[my_playlist_length][4] = url;
	my_playlist[my_playlist_length][5] = photo;
	my_playlist[my_playlist_length][6] = duration;
	my_playlist[my_playlist_length][7] = date;
	show_playlist();
	
	if (hasieraketa == 1 ){
		my_playlist_change_colour(document.getElementById("my_playlist_" + playlist_momentukoa),document.getElementById("my_playlist_td_" + playlist_momentukoa));
	}
	
}

function remove_my_playlist(id){
	
	if (id == my_playlist.length-1 && id == playlist_momentukoa){
		my_playlist.splice(id,1);
		show_playlist();	
		my_playlist_play (0);
	}
	else if (id < my_playlist.length && id == playlist_momentukoa ){
		my_playlist.splice(id,1);
		show_playlist();
		my_playlist_play (id);
	}
	else if (id < playlist_momentukoa ){
		my_playlist.splice(id,1);
		show_playlist();
		playlist_momentukoa = parseInt(playlist_momentukoa) - 1;
		my_playlist_change_colour(document.getElementById("my_playlist_" + playlist_momentukoa),document.getElementById("my_playlist_td_" + playlist_momentukoa));
	}
	else {
		my_playlist.splice(id,1);
		show_playlist();
		my_playlist_change_colour(document.getElementById("my_playlist_" + playlist_momentukoa),document.getElementById("my_playlist_td_" + playlist_momentukoa));
	}
}

function swap_my_playlist(id){
	if (id > 0 && id == playlist_momentukoa){
		var my_playlist_lag = new Array;//nire playlist-a
		my_playlist_lag[0]= new Array(7);
		my_playlist_lag[0] = my_playlist[id - 1];
		my_playlist[id - 1] = my_playlist[id];
		my_playlist[id] = my_playlist_lag[0];
		show_playlist();
		playlist_momentukoa = parseInt(playlist_momentukoa) - 1;
		my_playlist_change_colour(document.getElementById("my_playlist_" + playlist_momentukoa),document.getElementById("my_playlist_td_" + playlist_momentukoa));
	}
	else if (id > 0 && id == playlist_momentukoa +1){
		var my_playlist_lag = new Array;//nire playlist-a
		my_playlist_lag[0]= new Array(7);
		my_playlist_lag[0] = my_playlist[id - 1];
		my_playlist[id - 1] = my_playlist[id];
		my_playlist[id] = my_playlist_lag[0];
		show_playlist();
		playlist_momentukoa = parseInt(playlist_momentukoa) + 1;
		my_playlist_change_colour(document.getElementById("my_playlist_" + playlist_momentukoa),document.getElementById("my_playlist_td_" + playlist_momentukoa));
	}
	else if ( id > 0 ) {
		var my_playlist_lag = new Array;//nire playlist-a
		my_playlist_lag[0]= new Array(7);
		my_playlist_lag[0] = my_playlist[id - 1];
		my_playlist[id - 1] = my_playlist[id];
		my_playlist[id] = my_playlist_lag[0];
		show_playlist();
		my_playlist_change_colour(document.getElementById("my_playlist_" + playlist_momentukoa),document.getElementById("my_playlist_td_" + playlist_momentukoa));
	}
}


////////////////////////////////www.jeroenwijering.com//////////////////////////////
	// some variables to save
	
	function getUpdate(typ,pr1,pr2,pid) {
		if(typ == "time") { 
			currentPosition = pr1;
			endPosition = pr2;
		}
		
		else if(typ == "state") { currentState = pr1; }
	};
	
	// These functions are caught by the feeder object of the player.
	function loadFile(obj) { thisMovie("mpl").loadFile(obj); };

	// This is a javascript handler for the player and is always needed.
	function thisMovie(movieName) {
	    if(navigator.appName.indexOf("Microsoft") != -1) {
			return window[movieName];
		} else {
			return document[movieName];
		}
	};

////////////////////////////////www.jeroenwijering.com//////////////////////////////

function my_playlist_play (id){
	
	my_playlist_change_colour(document.getElementById("my_playlist_" + id),document.getElementById("my_playlist_td_" + id),id,my_playlist[parseInt(id)][5]);
	if (hasieraketa == 0){
		var s1 = new SWFObject("mediaplayer.swf","mpl","590","390","7");
		s1.addParam("allowfullscreen","true");
		s1.addVariable("file",my_playlist[parseInt(id)][4]);
		s1.addVariable("enablejs","true");
		s1.addVariable("javascriptid","mpl");
		s1.addVariable('overstretch','true');
		s1.addVariable("backcolor","0x000000");
		s1.addVariable("frontcolor","0xFFFFFF");
		s1.addVariable("lightcolor","0x869195");
		s1.addVariable("width","590");
		s1.addVariable("height","390");
		s1.addVariable('autostart','true');  
		s1.write("player");
	}
	else if (hasieraketa == 1){
		bideo_egorea=3;
		loadFile({file:my_playlist[parseInt(id)][4]});
	}
	document.getElementById('my_bideoa_name').innerHTML=my_playlist[parseInt(id)][1];
	document.getElementById('my_bideoa_desc').innerHTML=my_playlist[parseInt(id)][3];
	document.getElementById('enbed').value="<embed src=\"http://www.eaj-pnv.tv/player.swf\" width=\"400\" height=\"300\" allowscriptaccess=\"always\" allowfullscreen=\"true\" flashvars=\"file=" + my_playlist[parseInt(id)][4] + "&autostart=false\" />";
	playlist_momentukoa = id;
}

// taularen kolorea aldatu, play egoeran dagoen taula.
function my_playlist_change_colour(cell,cell1,id,photo){
	if (my_playlist_first == 0){
		my_playlist_first = 1;
	}else if (my_playlist_first == 1){
		id_my_playlist_cell.className = "testubeltza";
		id_my_playlist_td_cell.style.backgroundColor="#869195" ;
		var image0 = document.getElementById("my_playlist_argazkia_"+id_my_playlist_ida);
   		image0.src = id_playlist_photo+"_0.jpg";
	}
	cell.className = "testutxuria";
	cell1.style.backgroundColor="#33474e" ;
	var image1 = document.getElementById("my_playlist_argazkia_"+id);
    image1.src = photo+"_1.jpg";
	id_my_playlist_ida=id;
	id_playlist_photo=photo;
	id_my_playlist_cell=cell;
	id_my_playlist_td_cell=cell1;
}

// sagua taula gainetik pasatzean kolorea aldatu
function my_playlist_change_colour_over(cell,photo,id){
	cell.className = "testutxuria";
	var taula_td = document.getElementById("my_playlist_td_"+id);
	taula_td.style.backgroundColor="#33474e" ;
	var image = document.getElementById("my_playlist_argazkia_"+id);
    image.src = photo+"_1.jpg";
}

// sagua taulatik ateratzean kolorea aldatu 
function my_playlist_change_colour_out(cell,photo,id){
	if (id_my_playlist_cell!=cell){
		cell.className = "testubeltza";
		var taula_td = document.getElementById("my_playlist_td_"+id);
		taula_td.style.backgroundColor="#869195" ;
		var image = document.getElementById("my_playlist_argazkia_"+id);
   		image.src = photo+"_0.jpg";
	}
}

// -->