function ltrim(str)
{	
	var temp = str;	
	try
	{	
		for(i=0;i<temp.length;i++)
		{
			if(temp.charAt(0) == ' ')
				temp = temp.substring(1);
			else
				break;
		}	
	}
	catch(e){}	
	return temp;	
}

function rtrim(str)
{
	var temp = str;
	try
	{	
		for(i=temp.length-1;i>=0;i--)
		{
			if(temp.charAt(i) == ' ')
				temp = temp.substring(0,i);
			else
				break;
		}	
	}
	catch(e){}	
	return temp;
}

function trim(str)
{
	try
	{
		str = ltrim(str);
		str = rtrim(str);
	}
	catch(e){}
	return str;
}


function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

/*function validateform(str)
{	
	var sstr = str.split(',')
	var i,j,tstr,errorStr
	errorStr=""
	for (i=0;i<sstr.length;i=i+3)
	{
		var s = eval("document.forms(0)." + sstr[i] + ".value")		
		if ((sstr[i+2]=="R" || sstr[i+2]=="RE") && s=="")
			errorStr = errorStr + "\n" + sstr[i + 1] + " is Required."		
		else if((sstr[i+2]=="E" || sstr[i+2]=="RE") && s!='')
			if (!checkEmail(s))
					errorStr = errorStr + "\n" + sstr[i + 1] + " is not a valid Email Address."				
	}
	if (errorStr!="")
	{
		alert("Please check the following errors :" + errorStr)
		return false
	}
	else
		return true;
}*/
function validateform(str,frmName)
{
	
	var sstr = str.split(',')
	var i,j,tstr,errorStr
	errorStr=""
	for (i=0;i<sstr.length;i=i+3)
	{
		var s = trim(eval("document."+frmName+"."+ sstr[i] + ".value"))
		if ((sstr[i+2]=="R" || sstr[i+2]=="RE") && s=="")
			errorStr = errorStr + " " + sstr[i + 1] + vRequired + "\n"
		else if(sstr[i+2]=="RN"  && (parseInt(s)==0 || s==""))	
			errorStr = errorStr + " " + sstr[i + 1] + vRequired +" \n"		
		else if((sstr[i+2]=="E" || sstr[i+2]=="RE") && s!='')
			if (!checkEmail(s))
					errorStr = errorStr + " " + sstr[i + 1] + vEmail				
	}
	if (errorStr!="")
	{
		alert(vRequiredHeading+errorStr);
		//alert(errorStr)
		//displayerror(errorStr,true)
		return false;
	}
	else
		return true;
}
function displayerror(str,showbox)
{	
	document.getElementById("message").innerHTML=str		
	var twidth=document.getElementById("errorbox").style.width.substring(0,document.getElementById("errorbox").style.width.length-2)
	document.getElementById("errorbox").style.left=(screen.width-twidth)/4
	document.getElementById("errorbox").style.top=document.body.scrollTop + 20
	document.getElementById("errorbox").style.display=""
}

function checkEmail(strng)
{
	var emailFilter=/^.+@.+\..{2,3}$/;
	if (!(emailFilter.test(strng))) 
		return false;
	var illegalChars= /[\(\)\<\>\?\,\;\:\\\/\"\[\]\*\+\-\&\%\!\#\$\^\=]/		
	if (strng.match(illegalChars)) 
		return false;
	else
		return true;
}

function NumbersOnly(e)
{              
                if (window.event)
                {
                    //alert("if");
                    //alert(event.keyCode)
                                if (event.keyCode<48 || event.keyCode>57)
                                {
                                                event.keyCode=0;
                                                return false;
                    }
                }
                else 
                {
                    //alert("else");
                                if (e.which==8 || e.which==0)
                                                return true;
                                else if (e.which<48 || e.which>57)
                                                return false; 
                }              
}

function NoComma()
{	
	if (event.keyCode==44)
		event.keyCode=0;
}
function convertdate(vDate)
{
	var vDate1,vDate2;
	vDate1 = vDate.split("-");
	vDate2 =  vDate1[0] + "-" +  mnum(vDate1[1]) + "-" +  vDate1[2];
	return vDate2;
}

function showcal(s)
{
	var str;
	
	str=document.all(s).value.split("-")	
	document.all("frmcal").src='calendar.asp?frmnm=top&obj=' + s + '&month=' + mnum(str[1]) + '&year=' + str[2];				
	
	document.all('divcal').style.display='';
	document.all('divcal').style.left=event.x-20;
	
	document.all('divcal').style.top=event.y+10;				
}

function getFrames()
{	
	var frmnm,currfrm;
	frmnm="['"  + frameElement.name + "']";	
	currfrm="parent"	
	while ( eval(currfrm) != top)
	{
		frmnm= "['" + eval(currfrm + '.name') + "']" + frmnm
		currfrm = "parent." + currfrm		
	}
	return	"top.frames" + frmnm	
}

function hidecal()
{
	document.all("divcal").style.display='none';
}

function mnum(a)
{
	switch(a)
	{
		case "JAN": 
			return 1
		case  "FEB":
			return 2
		case "MAR": 
			return 3
		case "APR": 
			return 4
		case  "MAY":
			return 5
		case  "JUN":
			return 6
		case "JUL" :
			return 7
		case "AUG" :
			return 8
		case "SEP" :
			return 9
		case "OCT" :
			return 10
		case "NOV" :
			return 11
		case "DEC" :
			return 12;				
		}			
}

function mnumfull(a)
{
	switch(a)
	{
		case 1: 
			return "January"
		case  2:
			return "February"
		case 3: 
			return "March"
		case 4: 
			return "April"
		case  5:
			return "May"
		case  6:
			return "June"
		case 7:
			return "July"
		case 8:
			return "August"
		case 9:
			return "September"
		case 10 :
			return "October"
		case 11 :
			return "November"
		case 12 :
			return "December";				
		}			
}

function mnumweekday(a)
{
	switch(a)
	{
		case 0: 
			return "Sunday"
		case 1:
			return "Monday"
		case 2: 
			return "Tuesday"
		case 3: 
			return "Wednesday"
		case 4:
			return "Thursday"
		case 5:
			return "Friday"
		case 6:
			return "Saturday"
	}			
}

function gotoFirstPage(whichForm)
{
document[whichForm].submit();
}
function telnoOnly()
{
	
	if ((event.keyCode<47 || event.keyCode>57 )&&( event.keyCode!=44)&&(event.keyCode!=92)&&(event.keyCode!=45)&&(event.keyCode!=41)&&(event.keyCode!=40)&&(event.keyCode!=43))
		event.keyCode=0;
}
function gotoPage(pageno,whichForm)
{
document[whichForm]["page"].value = pageno;
document[whichForm].submit();
}

function gotoScorecardPage(pageno,whichForm,vCurrentId)
{
	document[whichForm]["page"].value = pageno;
	document[whichForm]["memberId"].value = vCurrentId;
	document[whichForm].submit();
}

function validateform1(str)
			{
				
				
				var sstr = str.split(',')
				var i,j,tstr,errorStr
				errorStr=""
				for (i=0;i<sstr.length;i=i+3)
				{
					var s = eval("document.forms[0]." + sstr[i] + ".value")
					if ((sstr[i+2]=="R" || sstr[i+2]=="RE") && s=="")
						errorStr = errorStr + "\n" + sstr[i + 1] + " is Required."		
					else if((sstr[i+2]=="E" || sstr[i+2]=="RE") && s!='')
						if (!checkEmail(s))
								errorStr = errorStr + "\n" + sstr[i + 1] + " is not a valid Email Address."				
				}
				if (errorStr!="")
				{
					alert("Please check the following errors :" + errorStr)
					return false
				}
				else
					return true;
			}
			
			function sd(e)
			{	
				if (window.event)
				{
					if (event.keyCode>0 || event.keyCode<200)
						return false; 
				}
				else 
				{
					if (e.which==8 || e.which==0)
						return true;
					else if (e.which>0 || e.which<200)
						return false; 
				}	
			}
