function checkword(word) {
	strlength = word.value.length;
	if (strlength > 1200 )
	{
		word.value = word.value.substring(0,1200);
		remchar = 0;
	
		
	}
	else {
		remchar = 1200 - strlength;
	}
	
	eval("document.frm.remainingchars.value = remchar;");
	
	
}

function commentfunc(frm)
{

	var a = 0;


		var commradio = false;
	    for (i = 0;  i < document.frm.comment_type.length;  i++)
	    {
	      if (document.frm.comment_type[i].checked)
	          commradio = true;
	    }
	    if (!commradio)
	    {
			alert("Please select either Compliment or Complaint.\n");
			return (false);
	    }


	    if(document.frm.subscriber.value==0 && document.frm.company_dont.value==0 && document.frm.others.value=="")
		{
		alert("Please Enter Company name.");
		return (false);
		}		
			

  // Work Phone field
  var checknum = "0123456789+()- ";
  var checkfield = document.frm.telno.value;
  var checkvalid = true;
  var everynum = "";
  for (i = 0;  i < checkfield.length;  i++)
  {
    ch = checkfield.charAt(i);
    for (j = 0;  j < checknum.length;  j++)
      if (ch == checknum.charAt(j))
        break;
    if (j == checknum.length)
    {
      checkvalid = false;
      break;
    }
    if (ch != ",")
      everynum += ch;
  }
  if (!checkvalid)
  {
    alert("Please enter only digit characters in the \"telephone number\" field.\n");
	return (false);	
  }

	    if(document.frm.telno.value.length < 1)
		{
		alert("Please enter a valid telephone number.\n");
		return (false);
		}
		
		
		if (document.frm.strsubject.value == "") {

		alert("Please enter a subject!\n");
		return (false);
		}
		
		if (document.frm.strsubject.value.length > 1199) {

		alert("Please limit your Subject to 1200 characters!\n");
		return (false);
			}
		
		//if (document.frm.incident.value == "")
		/*if (document.frm.incident.value.length==0)
		{
		alert("Please enter the details of the incident!\n");
		return (false);
		}*/
		
			
		
		if (document.frm.area.value == "") {

		alert("Please enter a area!\n");
		return (false);
		}

		

//City validation//////////
if(document.frm.city.value!="")
{
		var checknum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ ";
			  var checkfield = document.frm.city.value;
			  var checkvalid = true;
			  for (i = 0;  i < checkfield.length;  i++)
			  {
			    ch = checkfield.charAt(i);
			    for (j = 0;  j < checknum.length;  j++)
			      if (ch == checknum.charAt(j))
			        break;
			    if (j == checknum.length)
			    {
			      checkvalid = false;
			      break;
			    }
			  }
			  if (!checkvalid)
			  {
				alert("Please re-enter the City name, you have used invalid characters.\n");
				return (false);
			  }
}
			  
//Area validation/////////////////////////////////////////
		var checknum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ_- ";
			  var checkfield = document.frm.area.value;
			  var checkvalid = true;
			  for (i = 0;  i < checkfield.length;  i++)
			  {
			    ch = checkfield.charAt(i);
			    for (j = 0;  j < checknum.length;  j++)
			      if (ch == checknum.charAt(j))
			        break;
			    if (j == checknum.length)
			    {
			      checkvalid = false;
			      break;
			    }
			  }
			  if (!checkvalid)
			  {
					alert("Please re-enter the Area name, you have used invalid characters.\n");
					return (false);
			  }
			
//Person validation/////////////////////////////////////////
if(document.frm.person2.value!="")
{
		//alert('hi');
		var checknum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ ";
			  var checkfield = document.frm.person2.value;
			  var checkvalid = true;
			  for (i = 0;  i < checkfield.length;  i++)
			  {
			    ch = checkfield.charAt(i);
			    for (j = 0;  j < checknum.length;  j++)
			      if (ch == checknum.charAt(j))
			        break;
			    if (j == checknum.length)
			    {
			      checkvalid = false;
			      break;
			    }
			  }
			  if (!checkvalid)
			  {
				alert("Please re-enter the name of the person responsible, you have used invalid characters.\n");
		
			  }

}
	
}
