var xmlHttp;
function addcomments(str,layid)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
  
  if(str.length > 500) {
	document.getElementById("txtHint").innerHTML="Length must be below 500 chars ";
	document.getElementById("txtHint").style.color="red";
	return false;  
  } else if(str.indexOf("www") > 0 || str.indexOf(".com") > 0 ) {
		document.getElementById("txtHint").innerHTML="URLs not allowed";
		document.getElementById("txtHint").style.color="red";
		return false; 
  } else if(str.indexOf("href")>0) {
		document.getElementById("txtHint").innerHTML="Links not allowed";
		document.getElementById("txtHint").style.color="red";
		return false; 
  }
 document.getElementById("txtHint").style.color="#009900";
var url="http://www.123mycodes.com/flashlayouts/comments.php";
url=url+"?str="+str;
url=url+"&layoutid="+layid;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged() 
{ 

if (xmlHttp.readyState==4)
{ 

document.getElementById("txtHint").innerHTML=xmlHttp.responseText;;
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}