// JavaScript Document
function CheckSongsSelected(selname) {
	
	songid = new Array;
	count = 0;
	for (var i=0;i<document.Form_MyPlayList.elements.length;i++) {
			if (document.Form_MyPlayList.elements[i].name == 'sel_songs') {
					
					if (document.Form_MyPlayList.elements[i].checked) {
							var some_chk="yes";
							songid[count] =document.Form_MyPlayList.elements[i].value;
							count ++;
					}
			}
	}
	if(some_chk=="yes"){
		paramaters = "count="+count+"&SGID0="+songid[0];
		for (var j=1;j<count;j++) {
				paramaters += "&"+"SGID"+j+"="+songid[j];
		}
		if(selname=="PlaySelSongs"){
		
			url="http://music.owncustom.com/files/music_playlist_selected.php?"+paramaters;
			pop_owncustwindow=window.open(url,'PlayList','toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=728,height=500');
		
		}else if(selname=="AddToPlaylist"){
		
			url="http://music.owncustom.com/files/music_myplaylist_add.php?"+paramaters;
			pop_owncustwindow=window.open(url,'AddNewPlayList','toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=728,height=500');
		}
		if (window.focus) {pop_owncustwindow.focus()}
	
	}else{
		alert("Please Select Songs To Add To Playlist!");
	
	}
}


function AddToMyPlaylist(formObj){

	return CheckSongsSelected(formObj);
	
	
}

	
function SetAllCheckBoxes(FormName, FieldName, CheckName)
{
	var CheckValue = document.forms[FormName].elements[CheckName].checked;
	if(!document.forms[FormName])
		return;
		var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
		var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
		objCheckBoxes[i].checked = CheckValue;
		
	

	
}

function EditPlayList(dm){
	fval=dm.NewPlayListName.value;
	if(fval==""){
			alert("Please enter the new playlist name to rename.");
			return false;
			
	}
	return true; 
}


function removeAll(selectedList){
	dest = document.getElementById(selectedList);
	for(j = dest.options.length-1;j>=0;j--){
		dest.remove(j);
	}
}

function removeSelected(selectedList){
	dest = document.getElementById(selectedList);
	for(j = dest.options.length-1;j>=0;j--){
		if(dest[j].selected){
			dest.remove(j);
		}
	}
	
}
function selectAll(selectedList){
	dest = document.getElementById(selectedList);
	for(j = dest.options.length-1;j>=0;j--){
		dest[j].selected = true;		
	}
}

function DelPlayList(){

	if(confirm('Are You Sure To Delete PlayList and Its Songs?')==true){
		document.location.href='music_myplaylist_edit_submit.php?act=del&ID=<?php echo $selectmy_list;?>';
		
	
	}else{
	
	return false;
	}
	
}	