

var xmlHttp;
function GetxmlHttp()
{
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	}
	catch( e )
	{
		// Internet Explorer
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch( e )
		{
			try
			{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch( e )
			{
				/*
				alert("Your browser does not support AJAX!");*/
				
			}
		}
	}
	
	xmlHttp.onreadystatechange = function()
	{
		if( xmlHttp.readyState == 4 )
		{
			//document.myForm.time.value = xmlHttp.responseText;
			//alert( xmlHttp.responseText );
			//alert( document.getElementById( "NewComments" ).innerHTML );
			if( xmlHttp.responseText.length > 0 )
			{
				document.getElementById( "NewComments" ).innerHTML = "<hr noshade width='50%' SIZE=1 COLOR=#d0d0d0>" + xmlHttp.responseText + document.getElementById( "NewComments" ).innerHTML;
			}
		}
		else
		{
			//alert( "State: " + xmlHttp.readyState + " Text:" + xmlHttp.responseText );
		}
	}
	return xmlHttp;
}
	


function AddComment(form,strID)
{
	//alert( document.form1.email.value );
	//alert( form[0].email );
	//alert( form[0]["email"] );
	var strEmail =  document.form1.email.value;
	var strMessage =  document.form1.comment.value;
	var strName =  document.form1.username.value;
	var strURL =  document.form1.url.value;
	
	if( strEmail.search( "your email") != -1 ) strEmail = "domedude@somewhere.com";
	
	if( strMessage.length <= 0 ) return;
	
	strEmail = TrimString( strEmail );
	if( strEmail.length == 0 ) strEmail = "dude@someplace.com";
	
	if( strMessage.length > 255 ) strMessage = strMessage.substring(0,255);
	
	var strURL = "../addcomment.php?id=" + strID + "&email=" + strEmail + "&text=" + strMessage + "&name=" + strName + "&url=" + strURL;
	
	//alert( strURL );/**/

	xmlHttp = GetxmlHttp();
	xmlHttp.open( "GET", strURL, true );
	xmlHttp.send( null );

	document.form1.email.value = "";
	document.form1.comment.value = "";
}

function TrimString(sInString)
{
  sInString = sInString.replace( /^\s+/g, "" );
  return sInString.replace( /\s+$/g, "" );
}