

function formvaildate(theValue,theTextWarning,theType){

///--------------------------------------------------

			if(theType == "NotEmpty"){
						if (theValue == "" ) {
							return theTextWarning
						}else{
							return ""
						}			
			}
			
///--------------------------------------------------			
if(theType == "httpTest"){	

	if(theValue.indexOf("http://")){
		return ""
	}else{
		return theTextWarning
	}

}		
///--------------------------------------------------
	
			if (theType == "Email") {
				
				if (theValue == "") {
					return theTextWarning 
				}else{
				
							emailTxt = theValue
							if (emailTxt.indexOf("@") < 0 || emailTxt.indexOf(".") < 0){
								return theTextWarning 
							}else{
								return ""
							}
							
				}
			}

///--------------------------------------------------
			
			if (theType == "Checked") {
				if (theValue == false ){
					return theTextWarning  
				}else{
					return ""
				}
			}
			
///--------------------------------------------------


if (theType == "Date") {
    re = /^\d{1,2}\/\d{1,2}\/\d{4}$/;

    if(theValue != '' && !theValue.match(re)) {
		return theTextWarning  
	}else{
		return ""
    }
}

///--------------------------------------------------


if (theType == "None") {
					
		if (theValue == "None" ) {
			return theTextWarning
		}else{
			return ""
		}	

}

///--------------------------------------------------


if (theType == "LengthNewEvents") {
		if (parseFloat(theValue) > 50) {
			return theTextWarning
		}else{
			return ""
		}	

}

if (theType == "LengthNewEvents2") {
		if (parseFloat(theValue) > 100) {
			return theTextWarning
		}else{
			return ""
		}	

}

if (theType == "LengthNewItems") {
		if (parseFloat(theValue) > 45) {
			return theTextWarning
		}else{
			return ""
		}	

}


if (theType == "LengthNewItems") {
		if (parseFloat(theValue) > 45) {
			return theTextWarning
		}else{
			return ""
		}	

}


if (theType == "LengthFAQS1") {
		if (parseFloat(theValue) > 299) {
			return theTextWarning
		}else{
			return ""
		}	

}

if (theType == "LengthFAQS2") {
		if (parseFloat(theValue) > 949) {
			return theTextWarning
		}else{
			return ""
		}	

}

if (theType == "LengthSearch1") {
		if (parseFloat(theValue) > 800) {
			return theTextWarning
		}else{
			return ""
		}	

}

if (theType == "LengthSearch2") {
		if (parseFloat(theValue) > 5000) {
			return theTextWarning
		}else{
			return ""
		}	

}

///--------------------------------------------------


if (theType == "PostCode") {

PostCodeError = ""
 test = theValue
 test = test.toUpperCase(); 
 size = test.length

 
 while (test.slice(0,1) == " ") 
  {
  test = test.substr(1,size-1);
  size = test.length
  }
 
while(test.slice(size-1,size)== " ") 
 {
  test = test.substr(0,size-1);
  size = test.length
  }
  
if (size < 6 || size > 8){ //Code length rule
  PostCodeError = "error"
  }
 if (!(isNaN(test.charAt(0)))){ //leftmost character must be alpha character rule
   PostCodeError = "error"
  }
 if (isNaN(test.charAt(size-3))){ //first character of inward code must be numeric rule

   PostCodeError = "error"
  }
 if (!(isNaN(test.charAt(size-2)))){ //second character of inward code must be alpha rule
   PostCodeError = "error"
  }
 if (!(isNaN(test.charAt(size-1)))){ //third character of inward code must be alpha rule
   PostCodeError = "error"
  }
 if (!(test.charAt(size-4) == " ")){//space in position length-3 rule
   PostCodeError = "error"
   }
 count1 = test.indexOf(" ");count2 = test.lastIndexOf(" ");
 if (count1 != count2){//only one space rule
   PostCodeError = "error"
  }

		if (PostCodeError != "") {
			return theTextWarning
		}else{
			return ""
		}	

}


///--------------------------------------------------

if (theType == "Number") {

		var checkOK = "01234 56789.";
		var checkStr = theValue;
		var allValid = true;
		for (i = 0;  i < checkStr.length;  i++)
		{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
		break;
		if (j == checkOK.length)
		{
		allValid = false;
		break;
		}
		}
		
		
	if(!allValid) {
		return theTextWarning  
	}else{
		return ""
    }
		
		
}

}
//---------------------------------------------------------------------------




function vaildateResult(theValue){

		if (theValue == ""){
				return true
		}else{
				CompleteErrorMsg = "Please enter all the required fields \n" + theValue
				alert(CompleteErrorMsg)
				return false
		}
}




