 var errors=0;
function validation(){
chkfname();
chkcompany();
chkcountry();
chktelephone();
//chkfax();
chkemail();
chkcity();
chkmsg();
chkattach();
chkCaptcha();
	
	if(errors==0){
	return true;
	}
	else{
		return false;
	}

}

function chkattach(){

}



function chkfname(){
if(Trim(document.getElementById("fname").value)==""){
		document.getElementById('errfname').innerHTML="Please enter Name";
		errors=1;
	}
	else{

			document.getElementById('errfname').innerHTML="";
		}

}



function chkcompany(){
if(Trim(document.getElementById("fcompany").value)==""){
		document.getElementById('errcompany').innerHTML="Please enter Company";
		
		errors=1;
	}
	else{

			document.getElementById('errcompany').innerHTML="";
			
		}

}

function chkcity(){
if(Trim(document.getElementById("fcity").value)==""){
		document.getElementById('errcity').innerHTML="Please enter City";
		
		errors=1;
	}
	else{

			document.getElementById('errcity').innerHTML="";
			
		}

}

function chkcountry(){
if(Trim(document.getElementById("fcountry").value)==""){
		document.getElementById('errcountry').innerHTML="Please enter Country";
		
		errors=1;
	}
	else{

			document.getElementById('errcountry').innerHTML="";
		
		}

}

function chkmsg(){
if(Trim(document.getElementById("fmsg").value)==""){
		document.getElementById('errmsg').innerHTML="Please enter the Message";
		
		errors=1;
	}
	else{

			document.getElementById('errmsg').innerHTML="";
			
		}

}

function chkemail(){
	if(Trim(document.getElementById('femail').value) != ""){
	if(!checkmail(Trim(document.getElementById('femail').value))){
		document.getElementById('erremail').innerHTML="Please enter a valid email address";

		errors=1;
}
else{
	document.getElementById('erremail').innerHTML="";

	errors=0
	}
}
else{
	document.getElementById('erremail').innerHTML="Please enter a valid email address";

	errors=1;
}
}


function chktelephone(){
	var regexp=/^[ \-+0-9]+$/
	var amtValue=Trim(document.getElementById("ftelephone").value);
	if(Trim(document.getElementById("ftelephone").value)==""){
		document.getElementById('errtelephone').innerHTML="Please enter Telephone No.";

		errors=1;
	}
	else{
		if(!amtValue.match(regexp)){
		document.getElementById('errtelephone').innerHTML="Please enter valid Telephone No.";	
		errors=1;
		}
		else{
			document.getElementById('errtelephone').innerHTML="";

		}
	}

}


function chkCaptcha(){
if(Trim(document.getElementById("rqCode").value)==""){
		document.getElementById('rqCode1').innerHTML="Word Verification Incorrect: Please type the characters you see in the picture";	
//	        document.getElementById('imgecap').innerHTML='<img src="images/bg.gif" class="err" />';

		errors=1;
	}
	else{

	document.getElementById('rqCode1').innerHTML="";
    //        document.getElementById('imgecap').innerHTML="";
		}

}

function reKeyPress(event, keyRE) {
        var strr = "";
        for(var i in event) {
            strr += "\n" + i + " - " + event[i];
        }

        if (    ( typeof(event.keyCode) != 'undefined' && event.keyCode > 0 && String.fromCharCode(event.keyCode).search(keyRE) != (-1) ) ||
            ( typeof(event.charCode) != 'undefined' && event.charCode > 0 && String.fromCharCode(event.charCode).search(keyRE) != (-1) ) ||
            ( typeof(event.charCode) != 'undefined' && event.charCode != event.keyCode && typeof(event.keyCode) != 'undefined' && event.keyCode.toString().search(/^(8|9|13|45|46|35|36|37|39)$/) != (-1) ) ||
            ( typeof(event.charCode) != 'undefined' && event.charCode == event.keyCode && typeof(event.keyCode) != 'undefined' && event.keyCode.toString().search(/^(8|9|13)$/) != (-1) ) ) {

		    return true;
        } else {
            return false;
        }
    }

function checkmail(no)
{
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
    if (!no.match(re))
    {

       return(false);
    }
    else{

     return(true);
     }
}

/*
==================================================================
LTrim(string) : Returns a copy of a string without leading spaces.
==================================================================
*/
function LTrim(str)
/*
   PURPOSE: Remove leading blanks from our string.
   IN: str - the string we want to LTrim
*/
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) {
      // We have a string with leading blank(s)...

      var j=0, i = s.length;

      // Iterate from the far left of string until we
      // don't have any more whitespace...
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;

      // Get the substring from the first non-whitespace
      // character to the end of the string...
      s = s.substring(j, i);
   }
   return s;
}

/*
==================================================================
RTrim(string) : Returns a copy of a string without trailing spaces.
==================================================================
*/
function RTrim(str)
/*
   PURPOSE: Remove trailing blanks from our string.
   IN: str - the string we want to RTrim

*/
{
   // We don't want to trip JUST spaces, but also tabs,
   // line feeds, etc.  Add anything else you want to
   // "trim" here in Whitespace
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      // We have a string with trailing blank(s)...

      var i = s.length - 1;       // Get length of string

      // Iterate from the far right of string until we
      // don't have any more whitespace...
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;


      // Get the substring from the front of the string to
      // where the last non-whitespace character is...
      s = s.substring(0, i+1);
   }

   return s;
}

/*
=============================================================
Trim(string) : Returns a copy of a string without leading or trailing spaces
=============================================================
*/
function Trim(str)
/*
   PURPOSE: Remove trailing and leading blanks from our string.
   IN: str - the string we want to Trim

   RETVAL: A Trimmed string!
*/
{
   return RTrim(LTrim(str));
}

function showOthers()
{
	
	if (document.getElementById('checkothers').checked==true){
		document.getElementById('others').style.display='';
		}
		else{
			document.getElementById('others').style.display='none';
			}
	}

