//validateField(Form name, Textfield Name, ['number' or 'email' or 'null'] ) 
      
function validateField(formName, textField, restrict){ 

	var tBox       = eval("document."+formName+"." + textField); 
	var textValue 	= LTrim(tBox.value); 
	switch (restrict){ 
		case 'number': 
			if(LTrim(tBox.value) == "" || tBox.value =="XX" || tBox.value ==" "){ 
				tBox.focus(); 
				return false; 
			}
			else if(!isNaN(tBox.value)){ 
				return true; 
			}else{ 
				tBox.focus(); 
				return false; 
			} 
			break; 
		
		case 'page_num':
			if(!isNaN(tBox.value) && tBox.value != "" && tBox.value > 0 ){ 
				return true; 
			}else{ 
				tBox.focus(); 
				return false; 
			} 
			break; 
		
		case 'email': 
			var atIndex = tBox.value.indexOf("@"); 
			var dotIndex = tBox.value.lastIndexOf("."); 
			if((atIndex != -1) && (dotIndex != -1) && (atIndex != 0) && (atIndex < dotIndex)){ 
				return true; 
			}else{ 
				tBox.focus(); 
				return false; 
			} 
			break; 
		
		case 'null': 
			if(LTrim(tBox.value) == "" || tBox.value =="XX" || tBox.value ==" "){ 
				tBox.focus(); 
				return false; 
			}else{ 
				return true; 
			} 
			break; 
		
		case 'url': 
			var re = new RegExp("\\b(http)|(https)|(ftp)://www.\\w*","i");
			if(!tBox.value.match(re)){ 
				tBox.focus(); 
				return false; 
			}else{ 
				return true; 
			} 
			break; 		
		
		default:						
			alert('Please specify key to validate');
			break; 
	} 
}

function LTrim(sString){ 
	while (sString.substring(0,1) == ' '){ 
		sString = sString.substring(1, sString.length); 
	} 
	return sString; 
}

