 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].type == "textarea")
			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 == "")
	{
		return false;
	}
else
	return true;
}/*---- Checks the text box for empty string -----*/

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;
}/*---- Checks the cofirm password and password are same -----*/



function telephoneCheck(telephoneNum)
 {
 	var validCharRegExp = /^\+?[\d\- ]+$/;
	var isValid = (validCharRegExp.test(telephoneNum));
	
	return isValid;
 }

function emailCheck(email)
  {
	 var validCharRegExp = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,20})$/i;
	
	var isValid = (validCharRegExp.test(email));
	
	return isValid;
}/*----- Email-----*/

   
function alphaOnly(e) {
	 
	var k;
	document.all ? k = e.keyCode : k = e.which;
	return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 9 || k == 32 || k == 0 || k == 95);
}
function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);
//alert(key);
// control keys
 if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27)  || (key==43) || (key==44) || (key==45) || (key==46) || (key==32))
   return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
   return true;

// decimal point jump
else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
else
   return false;
}


