function GetXmlHttpObject(handler)
{   var objXMLHttp=null
	 if (window.XMLHttpRequest)
	 {
		objXMLHttp=new XMLHttpRequest();
	 }
	 else if (window.ActiveXObject)
	 {
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	 return objXMLHttp;
}

function stateChanged_test()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		/*var str = xmlHttp.responseText;
		temp = str.split('#123#');
		document.getElementById('notposting').innerHTML=temp[0];		
		document.getElementById("show_comment_table").innerHTML=temp[1];
		document.getElementById("txt_comment").value="";*/
		var str = xmlHttp.responseText;
		temp = str.split('#123#');	
		document.getElementById("security_code").value="";		
		document.getElementById('notposting').innerHTML=temp[0];		
		if(temp[1] != undefined)
		{
			document.getElementById("show_comment_table").innerHTML=temp[1];
		}
		document.getElementById("txt_comment").value="";
		var val = document.getElementById("comment_value").innerHTML;
		var vval = Number(val);
		document.getElementById("comment_value").innerHTML = ++vval ;
	}
}


function stateChanged_add()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("show_success_add").innerHTML=xmlHttp.responseText;
	}
}


function add_playlist(path,videoid)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url=path+"music/audio_post_playlist.php"
	var urls="id="+videoid
	urls=urls+"&sid="+Math.random();

	xmlHttp.onreadystatechange=stateChanged_add; 
	xmlHttp.open("POST",url,true) ;
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", urls.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(urls);
}
function remove_playlist(path,videoid,playlist_id)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url=path+"music/remove_playlist.php"
	var urls="id="+videoid;
	urls=urls+"&playlist_id="+playlist_id;
	urls=urls+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged_add; 
	xmlHttp.open("POST",url,true) ;
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", urls.length);
	xmlHttp.setRequestHeader("Connection", "close");

	xmlHttp.send(urls);
}



function post_audio_comment(path)
{
	if(document.post_comment.txt_comment.value.length<=0)
	{
		alert("Please enter Comment !");
		document.post_comment.txt_comment.focus();
		return false;
	}
	
	if(document.post_comment.txt_comment.value.length>= 256)
	{
		alert("Too Big Comment ! Only 255 Characters are allowed");
		document.post_comment.txt_comment.focus();
		return false;
	}
	if(document.getElementById("security_code").value.length<=0)
	{
		alert("Enter the security code!");
		document.getElementById("security_code").focus();
		return false;
	}
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url=path+"music/audio_comment_insert.php"
	
	var urls="id="+document.post_comment.audio_id.value
	urls=urls+"&comment="+document.post_comment.txt_comment.value
	urls=urls+"&captcha="+document.getElementById("security_code").value
	urls=urls+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged_test; 
	
	xmlHttp.open("POST",url,true) ;
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", urls.length);
	xmlHttp.setRequestHeader("Connection", "close");

	xmlHttp.send(urls);
}



function stateChanged_add_playlist()
{
	if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("txtResult").innerHTML=xmlHttp.responseText;
	}
}

function add_new_playlist(path)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url=path+"music/audio_newpost_playlist.php"
	var urls="playlist="+document.frm_forum.playlist.value;

	urls=urls+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged_add_playlist; 
	xmlHttp.open("POST",url,true) ;
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", urls.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(urls);
}


function delete_playlist(path,id)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url=path+"music/audio_newpost_playlist.php"
	var urls="id="+id;
	urls=urls+"&action=delete";
	urls=urls+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged_add_playlist; 
	xmlHttp.open("POST",url,true) ;
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", urls.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(urls);
}
