function validCheck(iGo, eml){
	//alert("e " + eml);
	var n = document.f1.n;
	var t = document.f1.t;
	var sec = document.f1.loadsecurity

	//n.value = n.value.trim();
	s = n.value + "";
	//alert("n " + n + " t " + t  + "\ns" + s);
	sErr = "";
	ln = s.length;
	//if(ln > 17 || ln < 10){
	//	sErr += "Phone length incorrect should be more than 9 and less than 14\n";
	//}
	allowed = "+0123456789- ";
	chr0 = "";
	sDbg = "sDbg ";
	//alert("2");
	sNum = "";
	sArea = "";
	for(i = 0 ; i < ln; i++){

		chr1 = s.substring(i, i + 1);
		if(chr1.charCodeAt(0) >= 48 && chr1.charCodeAt(0) <= 57){
			sNum = sNum + chr1;
			//alert(chr1 + " ln" + chr1.charCodeAt(0));
			if(sNum.length == 3){sArea = sNum;
				//alert( " ln" + sNum.length);
			}
		}
		if(i > 0){
			chr0 = s.substring(i -1 , i );
			if(i == 1){
				allowed = allowed.substring(1); //echo " $ll now allow [{$allowed}] $ll";
			}
			//alert( i + " " + chr1 + " " + chr1.charCodeAt(0));


		}

		sDbg = sDbg + "\nchr1 [" + chr1 + "] 0 [" + chr0 + "]";
		if(allowed.indexOf(chr1) < 0 || (chr1 == chr0 && ( chr1 == " " || chr1 == "-") )){

			sErr += "Invalid character in phone at " + (i+1) + " "  + (chr0 ==chr1) + "\n";
			//alert("sErr " + sErr + "sDbg " + sDbg + " "  + (chr0 ==chr1));
		}else{
			sDbg += " " + i + " " + (chr0 ==chr1) + " " + (chr0 == " " || chr1== " " ) +  " chr1 [" + chr1 + "] N ok \t";
		}
	}
	//alert( " sNum " + sNum + " area " + sArea);
	if(sAllowedAreas.length < 5){
		sErr += "Script not set up no allowed codes, contact support " + "\n";
	}else{
		if(sArea != "" && (sArea.length != 3 || sAllowedAreas.indexOf(sArea + "|") < 0)){
			sErr += "Invalid area code :\'" + sArea +  "\'\n";
		}
	}
	if(iGo==2 && sec.value == "")sErr += "Invalid security code : please enter value" +  "\n";
	//alert("3");
	if(t.value.length > 139){
		sErr += "Message length too long max is 139 yours is " + (t.value.length) + "\n";
	}else if(t.value.length < 1 && iGo==2){
		sErr += "Message length too small, yours is " + (t.value.length) + "\n";
	}

	if(sNum.length != 10){
		sErr += "Number must be entered as  10 digits (excluding dashes and spaces), you entered :" + (sNum) + " length :" + (sNum.length) + "\n";
	}

	if((iGo==1 && eml !=null ) && (eml == "" || !emlCheck(eml))){
		sErr += eml + " Email id is invalid, please provide a valid email id\n";
	}
	sErr = sErr + "";
	if(sErr != ""){
		alert("Errors in form values:\n" + sErr  );//+ sDbg
		return false;
	}

	document.f1.target = "frm1" ;
	document.f1.target = "isel2";
	//alert("4 :[" + sErr + "]");
	//alert("4 :" + escape("aa")  + "psot to " + document.f1.action);
	if(iGo == 2){
		//alert("sbmt");
		document.f1.submit();
	}
	//alert("5 :" + sErr);
	//ajax1(n, t);
	return true;

}


/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function emlCheck(str) {

		str = str + ""
		var at1="@"
		var dot="."
		var lat=str.indexOf(at1)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at1)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at1)==-1 || str.indexOf(at1)==0 || str.indexOf(at1)==lstr){
		   
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    
		    return false
		}

		 if (str.indexOf(at1,(lat+1))!=-1){
		    
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    
		    return false
		 }

 		 return true					
	}


