 var errors=0;
function validation(){
errors=0;
chkfname();
chkfcompany();
chkfdesignation();
chkfemail();
chkfoffice_tel();
chkfcity();
chkfcountry();
chkfmsg();
chkCaptcha();
	
	if(errors==0){
	return true;
	}
	else{
		return false;
	}

}


function validation1(){
errors=0;
chkffname();
chkfffname();
chkffemail();
chkCaptcha1();
	
	if(errors==0){
	return true;
	}
	else{
		return false;
	}

}

function chkffname(){
if(Trim(document.getElementById("ffname").value)==""){
		document.getElementById('ffname').className="err";
		
		errors=1;
	}
	else{

		document.getElementById('ffname').className="fields";
			
		}

}
function chkfffname(){
if(Trim(document.getElementById("fffname").value)==""){
		document.getElementById('fffname').className="err";
		
		errors=1;
	}
	else{

		document.getElementById('fffname').className="fields";
			
		}

}

function chkffemail(){
	if(Trim(document.getElementById('ffemail').value) != ""){
	if(!checkmail(Trim(document.getElementById('ffemail').value))){
		document.getElementById('ffemail').className="err";
		
		errors=1;
}
else{
		document.getElementById('ffemail').className="fields";
	
	errors=0
	}
}
else{
		document.getElementById('ffemail').className="err";
	
	errors=1;
}
}



function chkfname(){
if(Trim(document.getElementById("fname").value)==""){
		document.getElementById('fname').className="err";
		
		errors=1;
	}
	else{

		document.getElementById('fname').className="fields";
			
		}

}

function chkfcompany(){
if(Trim(document.getElementById("fcompany").value)==""){
		document.getElementById('fcompany').className="err";
		
		errors=1;
	}
	else{

		document.getElementById('fcompany').className="fields";
			
		}

}




function chkfemail(){
	if(Trim(document.getElementById('femail').value) != ""){
	if(!checkmail(Trim(document.getElementById('femail').value))){
		document.getElementById('femail').className="err";
		
		errors=1;
}
else{
		document.getElementById('femail').className="fields";
	
	errors=0
	}
}
else{
		document.getElementById('femail').className="err";
	
	errors=1;
}
}



function chkfmsg(){
if(Trim(document.getElementById("fmsg").value)==""){
		document.getElementById('fmsg').className="errmore";
		
		errors=1;
	}
	else{

		document.getElementById('fmsg').className="fields";
			
		}

}

function chkfcity(){
if(Trim(document.getElementById("fcity").value)==""){
		document.getElementById('fcity').className="err";
		
		errors=1;
	}
	else{

		document.getElementById('fcity').className="fields";
			
		}

}


function chkfcountry(){
if(Trim(document.getElementById("fcountry").value)==""){
		document.getElementById('fcountry').className="err";
		
		errors=1;
	}
	else{

		document.getElementById('fcountry').className="fields";
			
		}

}

function chkfdesignation(){
if(Trim(document.getElementById("fdesignation").value)==""){
		document.getElementById('fdesignation').className="err";
		
		errors=1;
	}
	else{

		document.getElementById('fdesignation').className="fields";
			
		}

}
function chkfoffice_tel(){
	var regexp=/^[ \-+0-9]+$/
	var amtValue=Trim(document.getElementById("foffice_tel").value);
if(Trim(document.getElementById("foffice_tel").value)==""){
		document.getElementById('foffice_tel').className="err";
		errors=1;
	}
		else{
			if(!amtValue.match(regexp)){
		document.getElementById('foffice_tel').className="err";
		errors=1;
			}
			else{
		document.getElementById('foffice_tel').className="fields";
			}
		}

}

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('rqCode').className="err";


		errors=1;
	}
	else{

			document.getElementById('rqCode1').innerHTML="";
					document.getElementById('rqCode').className="fields";

         //   document.getElementById('imgecap').innerHTML="";
		}

}

function chkCaptcha1(){
if(Trim(document.getElementById("frqCode").value)==""){
		document.getElementById('frqCode1').innerHTML="Word Verification Incorrect: Please type the characters you see in the picture";
				document.getElementById('frqCode').className="err";


		errors=1;
	}
	else{

			document.getElementById('frqCode1').innerHTML="";
					document.getElementById('frqCode').className="fields";

         //   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';
			}
}

function showRequest(reqValue){
if(reqValue != ""){
	document.getElementById('fform').submit();
}	
}

function showRequest1(reqValue){
if(reqValue != ""){
	document.getElementById('fform1').submit();
}	
}
