
var errMsg_emp="Please provide "
var errMsg_inv="Please provide valid "

var VALIDATE_EMAIL= "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"
var VALIDATE_NAME= "abcdefghijklmnopqrstuvwxyz' "
var VALIDATE_CNAME= "abcdefghijklmnopqrstuvwxyz1234567890#&()./,'- "
var VALIDATE_SALUTN= "abcdefghijklmnopqrstuvwxyz. "
var VALIDATE_ADDR= "abcdefghijklmnopqrstuvwxyz1234567890,./-'() "
var VALIDATE_INTPIN="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234568790 "

/*
function chkBlank(ele,elenm,frm,defval)
{
	if(frm.ele.type.toLowerCase()=='text' || frm.ele.type.toLowerCase()=='textarea')
	{
		if(trim(frm.ele.value)=='' || trim(frm.ele.value)==defval)
			{
				alert(errMsg_emp+elenm);
				frm.ele.focus();
				return false;
			}		
	}
	if(frm.ele.type.toLowerCase()=='select-one')
	{
		if(frm.ele.selectedIndex==0)
			{
				alert(errMsg_emp+elenm);
				frm.ele.focus();
				return false;
			}		
	}
}*/
function V(arg)
{
	return(document.getElementById(arg).value)	
}

function chkchar(obj,chklst)
{
	 var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	var checkOK =chklst ;
	var checkStr = obj.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)
		{
			ch = checkStr.charAt(i);
			for (j = 0;  j < checkOK.length;  j++)
			  if (ch == checkOK.charAt(j))
			  break;
			  if (j == checkOK.length)
				{
				  allValid = false;
				  break;
				}
		  }

	if (!allValid)
	  {	
		obj.value=obj.value.substring(0,(checkStr.length)-1);
	  }
}

///////////get rid of all spaces////////////
function trimSpace(x)
{
	var emptySpace = / /g;
	var trimAfter = x.replace(emptySpace,"");
	return(trimAfter);
}	
//////get rid of leading & lagging spaces//////
function trim(strText) { 
    // get rid of leading spaces 
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);

    // get rid of trailing spaces 
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);

   return strText;
} 
////allow only characters///////
function charonly(e)
{
	var unicode=e.charCode? e.charCode : e.keyCode
	//alert(unicode)
	if (unicode!=8)
		{
			if ((unicode!=32 && (unicode<65 || (unicode>90 && (unicode<97 || unicode>122)))) && unicode!=39 && unicode!=45 && unicode!=13 && unicode!=15 && unicode!=37 &&  unicode!=39 && unicode!=14 && unicode!=9  )
			return false
		}
}
function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}
/////
function txtlim(obj,limit){
	var mlength=parseInt(limit);
	if (obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}
/////////////address field validation//////////
function chkaddr(e)
{
	var unicode=e.charCode? e.charCode : e.keyCode
	if (unicode!=8)
		{
		if ((unicode!=32 && (unicode<65 || (unicode>90 && (unicode<97 || unicode>122)))) && unicode!=39 && unicode!=44 && unicode!=9 && unicode!=45 && unicode!=46 && unicode!=13 && unicode!=15 && unicode!=14 && unicode!=47 && unicode!=38 && unicode!=40 && unicode!=41 && ((unicode<48||unicode>57)&& unicode!=9))
				return false
		}
}
//////////////
function numbersonly(e)
{
	
	//alert("Test")

	var unicode=e.charCode? e.charCode : e.keyCode
	//alert(unicode)
	if (unicode!=8)
		{
			if ((unicode<48||unicode>57)&& unicode!=9 && unicode!=13 && unicode!=15 && unicode!=14 && unicode != 46  || unicode==127 )
			return false
		}
}
////////////allow only these characters-> abcdefghijklmnopqrstuvwxyz1234567890#&()./,'-
function alphanumeric(e)
	{
		var unicode=e.charCode? e.charCode : e.keyCode
		if (unicode!=8 && unicode!=13)
		{		
			if ((unicode>64 && unicode<91) || (unicode>96 && unicode<123) || (unicode>47 && unicode<58) || (unicode==9) || (unicode==32) || (unicode>43 && unicode<48)|| (unicode>38 && unicode<42) || (unicode==35) || (unicode==38) && unicode!=13 && unicode!=15 && unicode!=14 ) 
			return true;
			else
			return false;
		}
	}
///////////check for valid email format//////////////
function emailValidate(incomingString, defaultValue)
{
	if(trimSpace(incomingString).length == 0 || incomingString.search(/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/g) == -1 || incomingString==defaultValue)
	{
		return false;
	}
	else
		return true;	
}	
////////////////////
function resetfrm(frm)
 {
 var oForm=frm;
	var iCounter=0	
	var sFldname,sFldType
	var iLength
	iLength=oForm.elements.length	
	while(iCounter<iLength)
	{		
		sFldType=oForm.elements[iCounter].type;
		sFldname=oForm.elements[iCounter].name;
		if (sFldType.toLowerCase() == "text")
			{
				oForm.elements[iCounter].value='';
			}
		if (sFldType.toLowerCase() == "select-one")
			{			
				oForm.elements[iCounter].options[0].selected=true
			}
		if (sFldType.toLowerCase() == "textarea")
			{			
				oForm.elements[iCounter].value='';
			}
		if (sFldType.toLowerCase() == "textarea")
			{			
				oForm.elements[iCounter].value='';
			}	
		if (sFldType.toLowerCase() == "checkbox")
			{			
				oForm.elements[iCounter].checked=false;
			}	
			
		iCounter = iCounter + 1		
	}
 }
/////calender script////////
	var ControlToSet;
	var CalWidth=180;
	var StartYear = "";
	var EndYear = "";
	var FormatAs;
	var NN4 = (navigator.appName.indexOf("Netscape")>=0 && !document.getElementById)? true : false;
	var NN6 = (document.getElementById && navigator.appName.indexOf("Netscape")>=0 )? true: false;
	var TOP;
	var LEFT;

	if(NN4)document.captureEvents(Event.MOUSEMOVE);

	document.onmousemove = LogPosition;

	function LogPosition(evt){

	    if (NN4||NN6){
	    LEFT=evt.screenX;
	    TOP=evt.screenY-10;
	    }
	    else{
	    LEFT=event.screenX;
	    TOP=event.screenY-10;
	    }

	}

	function ShowCalendar(CONTROL,START_YEAR,END_YEAR,FORMAT){	
	ControlToSet = eval(CONTROL);
	StartYear = START_YEAR;
	EndYear = END_YEAR;
	FormatAs = FORMAT;
	var strFeatures = "width=" + CalWidth + ",height=150" + ",left=" + LEFT + ",top=" + TOP;
	var CalWindow = window.open("/applications/common/HTMLCalendar.htm","Calendar", strFeatures)
	CalWindow.focus();
	} //End Function

	function SetDate(DATE){
	if(ControlToSet){
	ControlToSet.value = DATE; 
	}
	ControlToSet = null;
	StartYear = null;
	EndYear = null;
	FormatAs = null;
	}
 ///////////////////////
