// JavaScript Document
function validateEmail(e) {
	var reg1 = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
	var reg2 = /^[a-zA-Z0-9\_\-\.]+\@(\[?)[a-zA-Z0-9\_\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;

	if (e.match(reg1) || !e.match(reg2)) {
		return false;
	}
	
	return true;
}

function numbersonly(e){
var unicode=e.charCode? e.charCode : e.keyCode
if (unicode!=8){ //if the key isn't the backspace key (which we should allow)
if (unicode<48||unicode>57) //if not a number
return false //disable key press
}
}


function charsonly(e){
	var unicode=e.charCode? e.charCode : e.keyCode
	if (unicode!=8)
	{ //if the key isn't the backspace key (which we should allow)
		if ((unicode>=48)&&(unicode<=57)) return(true); // 0-9
		if ((unicode>=65)&&(unicode<=90)) return(true); // A-Z
		if ((unicode>=97)&&(unicode<=122)) return(true); //
		return false //disable key press
	}
}

function fnumbersonly(e){
var unicode=e.charCode? e.charCode : e.keyCode;
if ((unicode!=8)&&(unicode!=46&&unicode!=44)){ //if the key isn't the backspace key (which we should allow)
if (unicode<48||unicode>57) //if not a number
return false //disable key press
}
}


function IsNumeric(sText) {
	
  var ValidChars = "0123456789";
  var IsNumber=true;
  var Char;
 
  if (sText.length > 0) {
    for (i = 0; i < sText.length && IsNumber == true; i++) { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) {
        IsNumber = false;
      }
    }
  } else {
	IsNumber = false;  
  }
  
  return IsNumber;
   
}


function validateUrl(u)
{
	var url = String(u);
 //   var pattern = "^((ht|f)tp(s?)\:\/\/|~/|/)?([\w]+:\w+@)?([a-zA-Z]{1}([\w\-]+\.)+([\w]{2,5}))(:[\d]{1,5})?((/?\w+/)+|/?)(\w+\.[\w]{3,4})?((\?\w+=\w+)?(&\w+=\w+)*)?";
	var pattern = /http(s?)\:\/\/.+/;

    if(url.match(pattern))
    {
        return true;
    }
    else
    {
        return false;
    }
}
