function submitenter(myfield,e,callback)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   if (callback) {
      eval(callback); 
   }
   myfield.form.submit();

   return false;
   }
else
   return true;
}
function checkemail(strEmail)
{
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(strEmail))
		return true;
	else
		return false;
}
function trimAll( strValue ) 
{

 var objRegExp = /^(\s*)$/;

    //check for all spaces
    if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
    }

   //check for leading & trailing spaces
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       //remove leading and trailing whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}

function getCheckBoxCount(objForm,filter)
{
	var reg = new RegExp(filter);
	var cnt = 0;
	for (i = 0; i < objForm.length; i++)
	{
		if (objForm[i].type == "checkbox")
		{
			if (reg.test(objForm[i].name))
			{
				if (objForm[i].checked == true)
				{
					cnt++;
				}
			}
		}
	}
	return (cnt > 0) ? true : false;
}


function getposOffset(overlay, offsettype)
{
	/* To get the total offset depending on the offset type */
	var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
	/* To get the parent offset of the overlay passed as the parameter */
	var parentEl=overlay.offsetParent;
	/* To check if the parent offset is not NULL */
	while (parentEl!=null)
	{
	 /* To get total offset depending on the offset type */
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		/* To assign offset parent to the parent offset */
		parentEl=parentEl.offsetParent;
	}
	/* To return the total offset */
	return totaloffset;
}

/* To display the position of the div and open it as a popup */
function overlay(curEle, subobjstr, opt_position)
{
	/* If check the get element by id property */
	if (document.getElementById)
	{
		curobj = document.getElementById(curEle);
		/* To get the object of the div to be soon */
		var subobj=document.getElementById(subobjstr)
		/* To show/display the div */
		subobj.style.display=(subobj.style.display!="block") ? "block" : "none"
		/* To get the X co-ordinate */
		var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0)
		/* To get the Y co-ordinate */
		var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)

		/* To assign X-Y co-ordinate values to the div style positioning */
		subobj.style.left=xpos+"px";
		subobj.style.top=ypos+"px";
		//alert(subobj.style.left +'=' +subobj.style.top)
	 }

 }

 function is_real(val)
 {
	objRegExp = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/;
	return objRegExp.test(val);
 }
 function hideObj(obj)
 {
	$(obj).style.display = 'none';	
 }
 function showObj(obj)
 {
	 $(obj).style.display = '';	
 }

function clearSelection ( obj )
{
	obj.options.length = 0;
}

