function trim(sStr)
{
   var s;
   sStr = sStr.toString();
   sStr = sStr.replace(/(^\s*)|(\s*$)/g,"");
   sStr = sStr.replace(/\s{2,}/g," "); /*----- Removes the unwanted spaces(more than one)-----*/
   return(sStr);
}/*---- Regular expression functions for clearing the spaces ----*/

function clear_spaces(formName)
{
	var element_all =  formName.elements;
	var i;
	for(i=0;i<element_all.length;++i)
	{
			if (element_all[i].type == "text")
				element_all[i].value = trim(element_all[i].value);
	}
}/*----- Trim all the text boxes Only-----*/

function checkText(obj)
{
/*-----The trim function has to be called before calling this function -----*/
/*---- Later , type will be passed as a parameter so that the type will be like email, phone no , numeric, character ---*/
if(obj.value == "")
	{
		//alert("Please enter the "+name);
		//obj.focus();
		return false;
	}
else
	return true;

}/*---- Checks the text box for empty string -----*/

function checkEqual(string1,string2)
{
	var retVal =(trim(string1) === trim(string2)) ? true : false;
	return retVal;
}/*-----checkEqual()----*/



function checkConfPassword(obj1,obj2)
{
	
/*-----The trim function has to be called before calling this function -----*/

if(obj1.value != "" && obj2.value != "")
	{
		if(trim(obj1.value) != trim(obj2.value))
		return false;
		else
		return true;
	}
else
	return false;
	
}
function checkSelected(obj)
{
	/*if(obj.options[obj.selectedIndex].value == 0 )
		return false;
	else
	return true;*/
return (obj.options[obj.selectedIndex].value == 0 ) ? false : true;
}/*----checkSelected()-----*/


function emailCheck(email)
  {
//	  alert(email);
  	var validCharRegExp = /^\w(\.?\w)*@\w(\.?[-\w])*\.([a-z]{3}(\.[a-z]{2})?|[a-z]{2}(\.[a-z]{2})?)$/i;
	var isValid = (validCharRegExp.test(email));
	
	return isValid;
  }/*----- Email-----*/

 function isUrl(s) {
	var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
	return regexp.test(s);
}

function imposeMaxLength(Object, MaxLen)
{
  return (Object.value.length <= MaxLen);
}


function back()
{
    history.go(-1);
}
