function loadsongs(id, sitepath){
  ceWin =  window.open(sitepath+"playaudio.php?songid="+id,'PLAYER','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no,width=755,height=350');
}

function playselected(spaths){
    slist=document.getElementsByName("songsid[]");
    var ssid="";
    for(i=0;i<slist.length;i++)
    {	
    	e=slist[i];
    	if ((e.checked==true))
    	{
    		ssid=ssid+e.value+',';
    	}
    }
    ssid=ssid.substring(0,ssid.lastIndexOf(','));
    if(ssid=='')
    {
    alert('To Play Please Select Check Box');
    }
    else {

    ceWin =  window.open(spaths+"playallaudio.php?songid="+ssid,'PLAYER','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no,width=755,height=350');
    }
}


function downloadsongs(id, sitepath){
  if(id==0) {
    alert("You need to login ...");
  }else{
      var url=sitepath+"download.php?id="+id;
      window.location.href=url;
  }
    
}

function add2playlist(id, sitepath){
    if(id==0) {
    alert("You need to login");
  }else{
    var url=sitepath+"callback.php?do=add2list&id="+id;
    $.get(url, function(data){
        alert(data);
    });
  }
}

function removefromlist(id, sitepath){
    if(id==0) {
    alert("You need to login");
  }else{
    var url=sitepath+"callback.php?do=rem2list&id="+id;
    $.get(url, function(data){
        alert(data);
        window.location.href=sitepath+"myplaylist.html";
    });
  }
}

function register(){
    var sitepath=document.getElementById('sitepath').value;
    var un=document.getElementById('username').value;
    var pw=document.getElementById('password').value;
    var em=document.getElementById('email').value;
    
    var url=sitepath+"login.php?type=register&username="+un+"&password="+pw+"&email="+em;
    //alert(url);
    $.get(url, function(data){
    
      if(data!="2"){
        $("#loginform").html("Successfully Registered");
         $("#regstatus").html("");
        }
      else
        $("#regstatus").html("Username Already exist");
  });
}

function login(){
    var sitepath=document.getElementById('sitepath').value;
    var un=document.getElementById('username').value;
    var pw=document.getElementById('password').value;
    
    var url=sitepath+"login.php?type=login&username="+un+"&password="+pw;
    //alert(url);
    $.get(url, function(data){
      if(data=="0"){
         $("#loginstatus").html("Invalid Username/Password");
        }else{
          window.location.href=sitepath;
        }
  });

}

function logout(sitepath)
{
  window.location.href=sitepath+"logout.php";
}
