var xmlHttp

function isAlphaNumericc(Input) 
{
		//var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
		var iChars = "\\\\/";
        for (var i = 0; i < document.frm_comments.txtcomments.value.length; i++)
		 {
                if (iChars.indexOf(document.frm_comments.txtcomments.value.charAt(i)) != -1)
				{
                alert ("Special characters are not allowed for comments");
                return true;
        		}
				
        }
	
}



function show_comments()
{ 
	/*if(isAlphaNumeric(document.frm_comments.txtname.value))
	{
		alert("Special characters (@ # $ % ^ & ~) are not allowed for Name")
		document.frm_comments.txtname.focus()
		return false
	}
	else if (document.frm_comments.txtname.value=="")
	{
		alert("Please enter Name")
		document.frm_comments.txtname.focus()
		return false
	}*/
	if(document.frm_comments.optMovie[1].checked)
	{
		if(document.frm_comments.selsongid.selectedIndex=="")
		{
			alert("Please select Song Name")
			document.frm_comments.selsongid.focus()
			return false
		}
	}	
	if (document.frm_comments.txtcomments.value=="")
	{
		alert("Please enter Comments")
		document.frm_comments.txtcomments.focus()
		return false
	}
	else if(isAlphaNumericc(document.frm_comments.txtcomments.value))
	{
		//alert("Special characters (@ # $ % ^ & ~) are not allowed  for Comments")
		document.frm_comments.txtcomments.focus()
		return false
	}/**/
	else
	{
		if(document.frm_comments.optMovie[0].checked)
		{
		
			//var url="show_comments.php";
			var url="show_comments.php?name="+document.frm_comments.txtname.value+"&comments="+document.frm_comments.txtcomments.value+"&movie=0";
			document.frm_comments.txtcomments.value="";
			xmlHttp=GetXml_HttpObject(state_Changed)
			xmlHttp.open("GET", url , true)
			xmlHttp.send(null)
		}
		else	//if(document.frm_comments.optMovie[1].checked)
			{
				var url="show_comments.php?name="+document.frm_comments.txtname.value+"&comments="+document.frm_comments.txtcomments.value+"&movie=1&songid="+document.frm_comments.selsongid.value;
				//document.frm_comments.txtname.value="";
				document.frm_comments.txtcomments.value="";
				document.frm_comments.selsongid.value="";
				xmlHttp=getxml1_HttpObject(status_Changed)
				xmlHttp.open("GET", url , true)
				xmlHttp.send(null)
		}
	}
} 

function state_Changed() 
{
	alert(document.getElementById("moviecommentdisp").innerHTML);
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("moviecommentdisp").innerHTML=xmlHttp.responseText 
	} 
} 


function status_Changed() 
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("songcommentdisp").innerHTML=xmlHttp.responseText 
	} 
} 


function GetXml_HttpObject(handler)
{ 
	var objXmlHttp=null
	
	if (navigator.userAgent.indexOf("Opera")>=0)
	{
		alert("This example doesn't work in Opera") 
		return 
	}
	
	if (navigator.userAgent.indexOf("MSIE")>=0)
	{ 
		var strName="Msxml2.XMLHTTP"
		
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
		{
			strName="Microsoft.XMLHTTP"
		} 
		try
		{ 
			objXmlHttp=new ActiveXObject(strName)
			objXmlHttp.onreadystatechange=handler 
			return objXmlHttp
		} 
		catch(e)
		{ 
			alert("Error. Scripting for ActiveX might be disabled") 
			return 
		} 
	} 
	if (navigator.userAgent.indexOf("Mozilla")>=0)
	{
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler 
		return objXmlHttp
	}
} 

function getxml1_HttpObject(handler)
{ 
	var objXmlHttp=null
	
	if (navigator.userAgent.indexOf("Opera")>=0)
	{
		alert("This example doesn't work in Opera") 
		return 
	}
	
	if (navigator.userAgent.indexOf("MSIE")>=0)
	{ 
		var strName="Msxml2.XMLHTTP"
		
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
		{
			strName="Microsoft.XMLHTTP"
		} 
		try
		{ 
			objXmlHttp=new ActiveXObject(strName)
			objXmlHttp.onreadystatechange=handler 
			return objXmlHttp
		} 
		catch(e)
		{ 
			alert("Error. Scripting for ActiveX might be disabled") 
			return 
		} 
	} 
	if (navigator.userAgent.indexOf("Mozilla")>=0)
	{
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler 
		return objXmlHttp
	}
} 
