function checkForm() 
{
missinginfo = "";
if(document.enquiry.name.value == "") {
missinginfo += "\n     -  Name";
}

if ((document.enquiry.email.value == "") || 
(document.enquiry.email.value.indexOf('@') == -1) || 
(document.enquiry.email.value.indexOf('.') == -1)) {
missinginfo += "\n     -  Email";
}

/*if(document.enquiry.company.value == "") {
missinginfo += "\n     -  Company Name";
}

if(document.enquiry.title.value == "") {
missinginfo += "\n     -  Your Title";
}*/


if(document.enquiry.country.value == "xxx") {
missinginfo += "\n     -  Country";
}

/*if (document.enquiry.displaycount.value > 3000)
{
missinginfo += "\n     -  Comments";
}*/

if (missinginfo != "") {

missinginfo ="_____________________________\n" +
"There is some error in fields:\n" +
missinginfo + "\n_____________________________" +
"\nPlease correct and submit again!";
alert(missinginfo);
return false;
}
else return true;
}

function countit(what)
{
formcontent=what.form.comments.value
what.form.displaycount.value=formcontent.length
	if (what.form.displaycount.value > 3000)
	{
	//confirm('Keep it short, please');
		if(!confirm('Keep it short, please'))
		{
		what.form.comments.value = what.form.comments.value.substring(0,3010-10)
		what.form.displaycount.value=3000;
		}
	}
	
}

function checkComm()
{
	if (document.enquiry.displaycount.value > 3000)
	{
		document.enquiry.enqSubmit.disabled=true; 
	}
	else
	{
		document.enquiry.enqSubmit.disabled=false; 
	}
}


function checkTextBox()
{
value=document.searchForm.keyword.value;

	if (value=="Site Search...")
	{
	document.searchForm.keyword.value="";
	}

}

function checkTextBoxBack()
{
value=document.searchForm.keyword.value;

	if (value=="")
	{
	document.searchForm.keyword.value="Site Search...";
	}


}


function cnt(w,x){
var y=w.value;
var r = 0;
a=y.replace(/\s/g,' ');
a=a.split(' ');
for (z=0; z<a.length; z++) {if (a[z].length > 0) r++;}
x.value=r;

if (x.value > 3000)
	{
	//confirm('Keep it short, please');
		if(!confirm('Keep it short, please'))
		{
		w.value = w.value.substring(0,3010-10)
		x.value=3000;
		}
	}
}

function wordCounter(_form, _field, maxlimit)
{
  var _string="";
  var _wordCount=0;
  var _obj=eval("_form."+_field);
  var _IsSpace=true;
  var _WasSpace=false;
  for (var _x=0;_x<_obj.value.length;_x++)
  {
    _WasSpace=_IsSpace;
    _IsSpace=(_obj.value.charAt(_x) == " ");
    
    if(_IsSpace && ! _WasSpace)
    {
      _wordCount++;
      if(_wordCount<maxlimit)
        _string+=" ";
    }
    else if(!_IsSpace)
    {
      if(_wordCount<maxlimit)
        _string+=_obj.value.charAt(_x);
    }
  }
  _obj.value=_string;
  _form.displaycount.value=_wordCount;
}

function openWindow()
{
vleft=screen.width/2-456/2;
vwidth=screen.height/2-409/2;
//alert(vleft + ' x ' + vwidth );
window.open("tellafriend.php","mywindow","status=0,toolbar=0,width=456,height=409,left=" + vleft + ",top=" + vwidth);	
}