function create_pl(){
	setpanelheader("Create an empty playlist?");
	panelaction="createpl";
	panel_loadbody('');
}
function submit_createpl(){
	panelaction = panelaction.replace("save_","");
	panelaction = "save_createpl";	
	sMsg = Trim(document.frmcreateempl.pldesc.value);
	pname=document.getElementById('pname').value;
	panelparam='&pname='+pname+'&message='+encodeURIComponent(sMsg);
	show_panel_loading('panelstatus');		
	panel_loadbody('result');
}
function show_renamepl(){
 	var pid = get_selected_val('frmlist');
	if(pid!=""){
		setpanelheader("Rename this playlist?");
		panelaction="renamepl";
		panelparam= '&pid='+pid;
		panel_loadbody('');
	}
}
function show_editpl(pid){
	if(pid!=""){
		setpanelheader("Rename this playlist?");
		panelaction="renamepl";
		panelparam= '&pid='+pid;
		panel_loadbody('');
	}
}

function submit_renamepl(pid){
	panelaction = panelaction.replace("save_","");
	panelaction = "save_renamepl";	
	pname=document.getElementById('pname').value;
	sMsg = Trim(document.frmrenamepl.pldesc.value);
	panelparam='&pid='+pid+'&pname='+pname+'&message='+encodeURIComponent(sMsg);
	show_panel_loading('panelstatus');		
	panel_loadbody('result');
}
function delete_pl(){
 	if(confirm("Delete selected playlist ?")){
		var aPid = get_selected_val('frmlist');
		var pid = aPid.join(",");
		if(pid == ""){
			alert('please select a playlist to delete');
			return;
		}
		document.frmplaction.btnsubmit.value='deletepl';
		document.frmplaction.delplid.value = pid;
		document.frmplaction.method="POST";
		document.frmplaction.submit();
	}
}
function removesongfrmpl(id){
	 if(confirm("Are you sure you want to remove?")){
	 		var song_ids=get_selected_val('frmplsongsact'); 
		 	document.frmplsongsact.pid.value = id;
		 	document.frmplsongsact.song_ids.value=song_ids;
		 	document.frmplsongsact.paction.value = "deletesongs";
			document.frmplsongsact.submit();
		}
}
function openshare(pid,tp,cnt){
 	if((pid)!=""){
 	 	if(cnt < 1){
			alert('Minimum 1 Song is required to share');
			return false;
		}
 	 	if(tp=="F"){
			var headertxt = "Share this playlist with friends";
		}else{
			var headertxt = "Make this playlist public";
		}
		setpanelheader(headertxt);
		panelaction = "sharepl";	
		panelparam = '&pid='+pid+'&tp='+tp;
		panel_loadbody('load_auto');
	}	
}
function save_share(){
	panelaction = panelaction.replace("save_","");
	panelaction = "save_share";	
	
	var sFrid = new Array();
	var obj = document.getElementById('seladdr');
	if(obj){
		if(obj.innerHTML == ""){
			alert("Please select a friend or enter a valid email");
			document.getElementById('auto_friendid').focus();
			return false;
		}
	}
	iL = document.frmshare.frid.length;
	if(iL!=undefined){
		for(i=0;i<iL;i++){
			sFrid.push(document.frmshare.frid[i].value);
		}
	}else{
		sFrid.push(YAHOO.util.Dom.get('frid').value);
	}
	sMsg = Trim(document.frmshare.sharemsg.value);
	panelparam = panelparam+'&frid='+(sFrid.join("^A"))+'&message='+encodeURIComponent(sMsg);
	show_panel_loading('panelstatus');		
	panel_loadbody('result');
}
function editshare(pid){
 	if((pid)!=""){
		var headertxt = "Share this playlist with friends";
		setpanelheader(headertxt);
		panelaction = "removeshare";
		panelparam = '&pid='+pid+'&tp=F';
		panel_loadbody('');
	}	
}
function remove_share(){
 	panelaction = panelaction.replace("save_","");
	panelaction = "save_removeshare";	
 	var sFrid = get_selected_val('frmremoveshare');
	panelparam = panelparam+'&frid='+(sFrid.join("^A"));
	show_panel_loading('panelstatus');
	panel_loadbody('result');	
}
function openpublic(pid,cnt){
	if(cnt <5){
		alert('Minimum 5 Songs are required to make it public');
		return false;
	}
	if(pid!=""){
		setpanelheader("Make your playlist public?");
		panelaction="publicpl";
		panelparam= '&pid='+pid;
		panel_loadbody('');
	}
}

function save_public(){
	panelaction = panelaction.replace("save_","");
	panelaction = "save_public";	
	sMsg = Trim(document.frmshare.sharemsg.value);
	panelparam = panelparam+'&message='+encodeURIComponent(sMsg);
	show_panel_loading('panelstatus');
	panel_loadbody('result');
}

function editpublic(pid){
	if(confirm("Confirm removing the playlist from public")){
		document.frmplaction.delplid.value = pid;
		document.frmplaction.btnsubmit.value='removepublic';
		document.frmplaction.method = "post";
		document.frmplaction.submit();
	}
}
function deletepl(pid){
 	if(confirm("Delete this playlist")){
	document.frmplaction.btnsubmit.value='deletepl';
	document.frmplaction.method="post";
	document.frmplaction.delplid.value=pid;
	document.frmplaction.submit();
	}
}
function deletefrpl(pid){
 	if(confirm("Remove from your friends list")){
	document.frmplaction.btnsubmit.value='removeshare';
	document.frmplaction.method="POST";
	document.frmplaction.delplid.value=pid;
	document.frmplaction.submit();
	}	
}
function deletefavpl(pid){
 	if(confirm("Remove from your favourite list")){
	document.frmplaction.btnsubmit.value='removefavpl';
	document.frmplaction.method="post";
	document.frmplaction.delplid.value=pid;
	document.frmplaction.submit();
	}	
}