function isValidEmail(input){
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return filter.test(input);
}

function trimForm(form){
	for(var i = 0 ; i  < form.elements.length; i++){
		if(form.elements[i].type == 'text' || form.elements[i].type == 'textarea'){
			form.elements[i].value = trim(form.elements[i].value);
		}
	}
}

// Removes leading whitespaces
function LTrim( value ) {
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

// Removes ending whitespaces
function RTrim( value ) {
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

// Removes leading and ending whitespaces
function trim( value ) {
	return LTrim(RTrim(value));
}

function limitTextArea(input, length){
	input.value = input.value.substring(0, length);
}

function hideObject(obj){
   if (window.ActiveXObject) { // IE
      obj.style.display = "none";
   } else if (window.XMLHttpRequest) { // Mozilla, Safari,...
      obj.style.display = "none";
   }
}

function showObject(obj){
   if (window.ActiveXObject) { // IE
      obj.style.display = "block";
   } else if (window.XMLHttpRequest) { // Mozilla, Safari,...
      obj.style.display = "table-row";
   }
}

function getRadioButtonValue(obj){
	if(obj.length == null)
		return obj.value;
	for(var i = 0; i < obj.length; i++){
		if(obj[i].checked)
			return obj[i].value;
	}
}

function checkleapyear(datea)
{
	datea = parseInt(datea);

	if(datea%4 == 0)
	{
		if(datea%100 != 0)
		{
			return true;
		}
		else
		{
			if(datea%400 == 0)
				return true;
			else
				return false;
		}
	}
	return false;
}

function getDateOfMonth(month, year){
	var month_i = parseInt(month);
	switch(month_i){
		case 1: 
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12: return 31;
		case 4: 
		case 6:
		case 9:
		case 11: return 30;
		case 2: 
			if(checkleapyear(year))
				return 29;
			else
				return 28;
	}
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
	    {
	    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	    }
	  catch (e)
	    {
	    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	    }
	  }
	return xmlHttp;
}