
//-------------------------Copyright cckerala.com-----
function dirOpen(x) {
   f3=document.newForm; 
f3.dfile.value=x;savePlaylist();
 f3.submit();
}
//--------------------------
//Move fields to playlist
//--------------------------
   function mf(x) {
    f1 = document.songsForm;
    if (!browser) {
      alert (alert1);
       return;
    }
   if (f1.songId.length == 15) {
       alert ("Maximum 15 songs allowed in the Playlist....");
       return;
                                }
   if (f1.songId.options[0].value != "") {
      document.songsForm.songId.length++;
   }
   i = f1.songId.length - 1;
    f1.songId.options[i].text = songs[x];
   f1.songId.options[i].value = titles[x];
}
//--------------------------
//Remove a song from list
//--------------------------
function removeFields() {
  f1 = document.songsForm;
  if (!browser) {
      alert (alert1);
     return;
   }  
  if (f1.songId.options[0].value == "") {
      return;
   }  
  selected = f1.songId.selectedIndex;
   j = f1.songId.length - 1;
   for (i=selected; i<j; i++) {
    f1.songId.options[i].text  = f1.songId.options[i+1].text;
    f1.songId.options[i].value = f1.songId.options[i+1].value;
   }
   f1.songId.options[j].text = "";
   f1.songId.options[j].value = "";
  if (f1.songId.length == 1) {
      f1.songId.options[0].text = "No songs selected";
      f1.songId.options[0].value = "";
   }
  else {
      f1.songId.length--;
  } 
}
//--------------------------
//Clear the Playlist
//--------------------------
function clearPlaylist() {
   f1 = document.songsForm;
   if (!browser) {
      alert (alert1);
      return false;
   } 
   j = f1.songId.length;
   for (i=0; i<j; i++) {

     f1.songId.options[i].text = "";
     f1.songId.options[i].value = "";
     f1.songId.options[i].selected = false;
   }
  f1.songId.length = 1; 
   f1.songId.options[0].text = "No songs selected";
 f1.songId.options[0].value = "";
}
//--------------------------
//Save list as cookie
//--------------------------
function savePlaylist() {
  f1 = document.songsForm;
   j = f1.songId.length;
  
   var playListIds    = new Array(j);
   var playListTitles = new Array(j);
   for (i=0; i<j; i++) {
      playListIds[i]    = f1.songId.options[i].value;
      playListTitles[i] = f1.songId.options[i].text;
   }
   if (f1.songId.options[0].value == "") {
      playListIds = "";
      playListTitles = "";
  }
   newCookie("PLAYLISTIDS",playListIds);
   newCookie("PLAYLISTTITLES",playListTitles);
}
//-------------------------
//Load Saved list from cookie
//--------------------------

function loadPlaylist() {
   f1 = document.songsForm;
  var songTitles = getCookie("PLAYLISTTITLES");
   var songIds    = getCookie("PLAYLISTIDS");
  if ((songTitles != "") &&  (songIds != "")) {
     var titles = songTitles.split(",");
    var ids    = songIds.split(",");
   f1.songId.length = titles.length;
    for (i=0; i<titles.length; i++) {
        f1.songId.options[i].text  = titles[i];
         f1.songId.options[i].value = ids[i];
      }
   }
}
//-------------------------------------------------------
//Clear the Playlist and add previous playlist from cookie
//-------------------------------------------------------
function onLoadHandler() {
   clearPlaylist();
   loadPlaylist();
}

function addClip(){

 	  // RealOneActiveXObject.ClearNowPlaying();

	f1 = document.songsForm;
	if (!browser) {
      		alert (alert1);
      		return false;
   		} 		
	if (f1.songId.options[0].value == "") {
		alert ("Select atleast ONE song...");
      		return false;
   		}
 
     j = f1.songId.length;
 	var playListIds= new Array();;
	
 	for (i=0; i<j; i++) {
		
     	playListIds[i] =f1.songId.options[i].value;

}
         
	
f1.playlist.value=playListIds;

f1.submit();
   	
	 }




function addClipe(){

 	   RealOneActiveXObject.ClearNowPlaying();

	f1 = document.songsForm;
	if (!browser) {
      		alert (alert1);
      		return false;
   		} 		
	if (f1.songId.options[0].value == "") {
		alert ("Select atleast ONE song...");
      		return false;
   		}
 
     j = f1.songId.length;
 	var playListIds    = new Array(j);
	RealOneActiveXObject.PlayClip(f1.location.value+f1.songId.options[0].value,"Title="+f1.songId.options[0].text+"|Comments=Bought to you by cckerala.com|Language=Malayalam","http://www.cckerala.com/Music/keralasongs.htm",300,300);
 	for (i=1; i<j; i++) {
		
     	 playListIds = f1.songId.options[i].value;
	Title = f1.songId.options[i].text;
	RealOneActiveXObject.AddToNowPlaying(f1.location.value+f1.songId.options[i].value,"Title="+Title+"|Comments=Bought to you by cckerala.com|Language=Malayalam","_keep");
 	  
	}
   	
	 }

 	


function playClipe(x) {
   f1 = document.songsForm;
//titles[x].value=titles[x].value;

    if (!browser) {
      alert (alert1);
       return;
    }
 RealOneActiveXObject.ClearNowPlaying(); 
 RealOneActiveXObject.PlayClip(f1.location.value+titles[x],"Title="+songs[x]+"|Language=Malayalam");

   }



function playClip(x) {
   f1 = document.songsForm;
//titles[x].value=titles[x].value;

    if (!browser) {
      alert (alert1);
       return;
    }
 //RealOneActiveXObject.ClearNowPlaying(); 
 //RealOneActiveXObject.PlayClip(f1.location.value+titles[x],"Title="+songs[x]+"|Language=Malayalam");

  f1.playlist.value=titles[x];

f1.submit(); 

}


