//To Set the focus to the TabStrip

function viewPage(TabStriptId,pageNum,ControlFocusId) 
{		
	
    TabStrip.selectedIndex = pageNum;
    document.getElementById(ControlFocusId).focus();
	
	/*(if(pageNum == "1")
	{
	TabStrip.selectedIndex = pageNum;
	document.getElementById("txtYear").focus();				
	} 
	if(pageNum == "2")
	{
	TabStrip.selectedIndex = pageNum;
	document.getElementById("txtInsValue").focus();				
	}
	if(pageNum == "3")
	{
	TabStrip.selectedIndex = pageNum;
	document.getElementById("txtRegistrationIssueDate").focus();				
	}*/
}	

// TO VALIDATE THE MM/YYYY FORMAT DATE
function fnValidateDateMY(vDateFieldId)
{
	vDateReq = vDateFieldId.value;

	a = vDateReq.length;
	count=0;
	for(i=0;i<a;i++)
	if (vDateReq.charAt(i)=="")	count++;
	if (count == a)
	{
	//	window.alert("Please enter the  Date.\n");
	//	vDateFieldId.focus();
	//	return false;
	}
	else
	{
		month1 = 0;
		if(vDateReq.indexOf(".")!=-1)
		{
		alert("Please remove the dots");
		vDateFieldId.focus();
		vDateFieldId.select();
		return false;
		}

		if(vDateReq.indexOf(" ")!=-1)
		{
		alert("Please remove the spaces");
		vDateFieldId.focus();
		vDateFieldId.select();
		return false;
		}
		
		if ((vDateReq.charAt(2)== "-" && vDateReq.length == 7) || (vDateReq.charAt(2)== "/" && vDateReq.length == 7))
		{
			mm = vDateReq.substring(0,2);
//			dd = vDateReq.substring(3,5);
			yyyy = vDateReq.substring(6,10);
			var arr31 =new Array (1,3,5,7,8,10,12);
			var arr30 = new Array(4,6,9,11);
			if (isNaN(yyyy))
			{
			alert("Month should be Numerics");
				vDateFieldId.focus();
				vDateFieldId.select();
				return false;
			} 
			
			if((yyyy==0000)||(mm==0))
			{
				window.alert("Month/Year/ should not be zero");
				vDateFieldId.focus();
				vDateFieldId.select();
				return false;
			}		

			if ((mm <=12 ) && (mm > 0))
			{
				for (i=0 ; i<arr31.length ; i++)
				if (mm == arr31[i])
				{
					month1 = 31;
					break; 
				}

				if (month1 == 0)
				for (i=0 ; i<arr30.length ; i++)
				if (mm == arr30[i])
				{
					month1 = 30;
					break; 
				}
				
			}	
			else
			{
				alert("Month should be in between 1 and 12");
				vDateFieldId.focus();
				vDateFieldId.select();
				return false;
			}	

		}
		else
			if (vDateReq != "")
			{
				alert("Date should in the format : MM/YYYY") ;
				vDateFieldId.focus();
				vDateFieldId.select();
				return false;
			}    
	}  
	 
	return true;
} 


			
// TO FIND THE DIFFERENCE BETWEEN FROM AND TO DATE
function fnTimeDiff(vFrom,vTo)
{
	if ((vFrom != "")  && (vTo != ""))
	{
		var vFromArr=vFrom.split(":");
		var hh1=vFromArr[0];
		var mm1=vFromArr[1];
		var ss1=vFromArr[2];
						
		var vToArr=vTo.split(":");
		var hh2=vToArr[0];
		var mm2=vToArr[1];
		var ss2=vToArr[2];
		
		if(hh1>hh2)
		{
			return -1;
		}					
		if((hh1==hh2)&&(mm1>mm2))
		{
			//alert("mm1>mm2");			
			return -1;
		}			

		if((hh1==hh2)&&(mm1==mm2))//&&(ss1>ss2))  
		{
			//alert("dd1>dd2");			
			return -1;
		}
//		if((hh1==hh2)&&(mm1==mm2))//&&(ss1==ss2))  
//		{
//			//alert("Equall");			
//			return 0;
//		}
		else
		{
			//alert("Date1<Date2");
			return 1;
		}
	
	}
	
}
// TO FIND THE DIFFERENCE BETWEEN TWO DATES.

function date_diff(vStDate,vEndDate)
{
	
	//This function assumes that Date Format is in MM/DD/YYYY
	
	var vStDate=vStDate;
	var vEndDate=vEndDate;
	var vStDateArr;
	var vEndDateArr;
	var vStDD;
	var vStMM;
	var vStYYYY;
	var vEndDD;
	var vEndMM;
	var vEndYYYY;
	
	vStDateArr=vStDate.split("/");	
	vStMM = vStDateArr[0];
	vStDD = vStDateArr[1];	
	vStYYYY = vStDateArr[2];
	
	vEndDateArr = vEndDate.split("/");
	vEndMM = vEndDateArr[0];
	vEndDD = vEndDateArr[1];	
	vEndYYYY = vEndDateArr[2];
	
	if( (vStYYYY>vEndYYYY) || (vStYYYY==vEndYYYY && vStMM>vEndMM) || (vStYYYY==vEndYYYY && vStMM==vEndMM && vStDD>vEndDD) )
	{
		return -1;		
	}
	
	return 0;

}

function date_diff_NS(vStDate,vEndDate)
{
	
	var vStDate=vStDate;
	var vEndDate=vEndDate;
	var vStDateArr;
	var vEndDateArr;
	var vStDD;
	var vStMM;
	var vStYYYY;
	var vEndDD;
	var vEndMM;
	var vEndYYYY;
	
	vStDateArr=vStDate.split("/");	
	vStMM=parseInt(vStDateArr[0],10);	
	vStDD=parseInt(vStDateArr[1],10);	
	vStYYYY=parseInt(vStDateArr[2],10);
	
	vEndDateArr=vEndDate.split("/");
	vEndMM=parseInt(vEndDateArr[0],10);	
	vEndDD=parseInt(vEndDateArr[1],10);	
	vEndYYYY=parseInt(vEndDateArr[2],10);
	
	if( (vStYYYY>vEndYYYY) || (vStYYYY==vEndYYYY && vStMM>vEndMM) || (vStYYYY==vEndYYYY && vStMM==vEndMM && vStDD>vEndDD) )
	{
	    vStDate = null;
	    vEndDate = null;
	    vStDateArr = null;
	    vEndDateArr = null;
	    vStDD = null;
	    vStMM = null;
	    vStYYYY = null;
	    vEndDD = null;
	    vEndMM= null;
	    vEndYYYY= null;
		return -1;		
	}	
		vStDate = null;
	    vEndDate = null;
	    vStDateArr = null;
	    vEndDateArr = null;
	    vStDD = null;
	    vStMM = null;
	    vStYYYY = null;
	    vEndDD = null;
	    vEndMM= null;
	    vEndYYYY= null;
	return 0;
}



// TO VALIDATE THE DATE.

function date_valid(vDateVal)
{
		v_enddate=vDateVal

		a=v_enddate.length
		count=0	   
			
		for(i=0;i<a;i++)
		if (v_enddate.charAt(i)==" ")
			count++
		if (count==a)
		{			
			return -1;
		}
		else        
		{
			month1 = 0			      
			if ((v_enddate.charAt(2)== "-" && v_enddate.charAt(5)=="-" && v_enddate.length == 10) || (v_enddate.charAt(2)== "/" && v_enddate.charAt(5)=="/" && v_enddate.length == 10))
			{
				mm = v_enddate.substring(0,2)
				dd = v_enddate.substring(3,5)
				yyyy = v_enddate.substring(6,10)
				
				var arr31 =new Array (1,3,5,7,8,10,12)
				var arr30 = new Array(4,6,9,11)
				
				if (isNaN(dd) || isNaN(yyyy))
				{					
					return -1;
				} 		    
		         if((dd==0)||(yyyy==0000)||(mm==0))
		        {		             
		             return -1;
		        }		
				if ((mm <=12 ) && (mm > 0))
				{
					for (i=0 ; i<arr31.length ; i++)
					if (mm == arr31[i])
					{
						month1 = 31
						break; 
					}
			  
					if (month1 == 0)
						for (i=0 ; i<arr30.length ; i++)
							if (mm == arr30[i])
							{
								month1 = 30
								break; 
							}
			  
					if (month1 == 30)
						if (dd > 30 )
						{							
					        return -1;
						} 
						      
					if (month1 == 31)
						if (dd > 31 )
						{							
							return -1;					
						}
										
					if (parseInt(mm) == 2)    
						if ( (yyyy % 4 == 0) || (yyyy%400 == 0) )//Leap Year
						{									
								if(dd > 29)
									return -1;					
						}	
						else //Non Leap Year
							if (dd > 28)
							{								
								return -1;
							}			
			}	
			else
			{				
			    return -1;
			}		
	}
	else
		if (v_enddate != "")
		{		   
		   return -1;
		}    
   }

	return 0
}


// E-MAIL VALIDATION

function funmail(vFrm,vObj)
{
mail=eval("document."+vFrm+"."+vObj+".value");
mail = Trim(mail);
if (mail!="")
{
   chat=mail.indexOf("@");   
   if(chat==-1)
   {alert("Please enter the valid E-mail(@ missed)");return -1;}
   else
   {
   chatlast=mail.lastIndexOf("@");
   chatmore=mail.lastIndexOf("@",chatlast-1);
   
   if(chatmore!=-1){alert("Please enter the valid E-mail(more than one @)");return -1;}
     
   chdot=mail.indexOf(".");
   if(chdot==-1){alert("Please enter the valid E-mail(. missed)");return -1;}
   else{
     if(chdot==0){alert("Please enter the valid E-mail(. as first character)");return -1;}
     if(chat==0){alert("Please enter the valid E-mail(@ as frist character)");return -1;}
     
     if(chdot<chat){alert("Please enter the valid E-mail(. after @)");return -1;} 
     else{
      if(chdot==chat+1){alert("Please enter the valid E-mail(@ and . are consecutive)");return -1;}
         }
     if(mail.charAt(chdot+1)=="."){alert("Please enter the valid E-mail(two .s are consecutive)");return -1;}         
     dotlast=mail.lastIndexOf(".")     
     if(dotlast+1==mail.length){alert("Please enter the vallid E-mail(last character is .)");return -1;}
   }
   }
   var splchar = " ,/<>?!`';:#$%^&*()=-|[]{}~" + '"' + "+\\\n\t";
   for(i=0;i<=mail.length;i++)
    {
      for (var j = 0; j < splchar.length; j++)
      {
        if(mail.charAt(i)==splchar.charAt(j)){alert(splchar.charAt(j)+" not allowed");return -1;}      
      }      
    }
}
//else
//	{alert("Please enter the E-mail");return -1;}
return 0;
}

//For Validating the Email with Label Messages

function fnValidateEmail(vEmailValue)
{
    //mail=eval("document."+vFrm+"."+vObj+".value");
    var strMessage = "";
    mail = Trim(vEmailValue);
    if (mail!="")
    {
       chat=mail.indexOf("@");   
       if(chat==-1)
       {
            strMessage = "Please enter the valid E-mail(@ missed)";
            return strMessage;
       }
       else
       {
           chatlast=mail.lastIndexOf("@");
           chatmore=mail.lastIndexOf("@",chatlast-1);       
            if(chatmore!=-1)
            {
                strMessage = "Please enter the valid E-mail(more than one @)";
                return strMessage;
            }             
            chdot=mail.indexOf(".");
            if(chdot==-1)
            {
                strMessage="Please enter the valid E-mail(. missed)";
                return strMessage;
            }
            else
            {
                 if(chdot==0)
                 {
                    strMessage="Please enter the valid E-mail(. as first character)";
                    return strMessage;
                 }
                 if(chat==0)
                 {
                    strMessage="Please enter the valid E-mail(@ as frist character)";
                    return strMessage;
                 }
                 
                 if(chdot<chat)
                 {
                    strMessage="Please enter the valid E-mail(. after @)";
                    return strMessage;
                 } 
                 else
                 {
                    if(chdot==chat+1)
                    {
                        strMessage="Please enter the valid E-mail(@ and . are consecutive)";
                        return strMessage;
                    }
                 }
                 if(mail.charAt(chdot+1)==".")
                 {
                    strMessage="Please enter the valid E-mail(two .s are consecutive)";
                    return strMessage;
                 }         
                 dotlast=mail.lastIndexOf(".")     
                 if(dotlast+1==mail.length)
                 {
                    strMessage="Please enter the vallid E-mail(last character is .)";
                    return strMessage;
                 }       
            }
        }
    
        var splchar = " ,/<>?!`';:#$%^&*()=-|[]{}~" + '"' + "+\\\n\t";
        for(i=0;i<=mail.length;i++)
        {
          for (var j = 0; j < splchar.length; j++)
          {
            if(mail.charAt(i)==splchar.charAt(j))
            {
                strMessage= splchar.charAt(j)+" not allowed";
                return strMessage;
            }      
          }      
        }
    }
    
    return strMessage;
}

//FOR VALIDATING THE LOGIN PAGE

function LoginCheck(vFrm,vObj,vObj1)
{ 
  
uIdObj=eval("document."+vFrm+"."+vObj);
uPwdObj=eval("document."+vFrm+"."+vObj1);
uId=uIdObj.value;
uPwd=uPwdObj.value;

 ec=0;
 not_char=new String("~!@#$%^&*()-=+[{]\\|;:'',<.>/?\"")

  
 if(uId=="")
  {alert("enter the Userid");ec=1;}
  else
      {
     for(i=0;i<uId.length;i++)
		 for(j=0;j<not_char.length;j++)
		 {
			  if(uId.charAt(i) == not_char.charAt(j)) { alert("enter proper User Id...you can use '_'");ec=1;}
		 }    
                      
       }
 
	if (ec==0)
	{
	  if(uPwd=="")
	  {alert("enter the Password");ec=1;}
		else
	   {
		 for(i=0;i<uPwd.length;i++)
			 for(j=0;j<not_char.length;j++)
			 {
			   
			   if(uPwd.charAt(i) == not_char.charAt(j)) { alert("enter proper Password...you can use '_'");ec=1;}
											  
			 }   
		}	     

	 } 

return 0;
}

 //
//FOR VALIDATING THE TEXT BOX

function fnRestrictDecData(TextName)
{
	if(document.getElementById(TextName.id).value.indexOf(".") == -1)
	{
		return;
	}				
	var strTextDot=document.getElementById(TextName.id).value.indexOf(".")+1								
	var strDecLen =TextName.value.substring(strTextDot,TextName.value.length)
	if (strDecLen.length >2)
	{
		TextName.value=TextName.value.substring(0,TextName.value.length-(strDecLen.length -2));
		return false;
	}
	else
	{
		return true;
	}

}

function fnAppendDecimal()
{
	if(event.keyCode == 46)
	{
		if(event.srcElement.value == "")
		{
			event.srcElement.value = "0.";
			positionCursorAtEnd(event.srcElement);
			return false;
		}
		else
		{
			if (document.selection.createRange().text == event.srcElement.value)
			{
				event.srcElement.value = "0.";
				positionCursorAtEnd(event.srcElement);
				return false;
			}
		}
	}
	
	// space,single dot
	if ((event.keyCode==46) && (event.srcElement.value.indexOf(".")==-1))
	{
		return true;
	}
	
	//0-9
	if ((event.keyCode>47) && (event.keyCode<58))
	{
		return true;
	}
	
	//a-z
	if ((event.keyCode > 96) && (event.keyCode < 123))
	{
		return true;
	}
	
	//A-Z
	if ((event.keyCode > 64) && (event.keyCode < 91))
	{
		return true;
	}
	return false;

}

function validText(vFrm,vObj,vLabel)
{
	uIdObj=eval("document."+vFrm+"."+vObj);
	uId=uIdObj.value;
	count = 0
    a = uId;
    for (i=0 ; i < uId.length ; i++)
    if (a.charAt(i) == " ")
    count++
    if (count == a.length)    
    {  
		window.alert("Please enter valid " + vLabel)
		return -1;   
	}
	return 0;  

}

function validTextNum(vFrm,vObj,vLabel)
{	
	uIdObj=eval("document."+vFrm+"."+vObj);
	uId=uIdObj.value;
	
	vVal=validText(vFrm,vObj,vLabel);

	if(vVal==-1)
	{
		uIdObj.focus();
		return -1;
	}
	
	a = uId;
	if (isNaN(a))   
	{  
		alert("Please enter valid " + vLabel)
		return -1;
	}
	
	if (a.indexOf("e") != -1)
	{
		alert("Please enter valid " + vLabel)
		return -1;
	}
	
	if (a.indexOf(".") != -1)
	{
		if (a.split(".")[1].length > 2)
		{
			alert("Please adjust to two decimals")
			return -1;
		}
	}  

}


//FOR VALIDATING TEXT BOX CONTROL ARRAY

function validTextArr(vFrm,vObj,vInd)
{
vObj=eval("document."+vFrm+"."+vObj);
vVal=vObj.value;

 ec=0;
 not_char=new String("~!@#$%^&*()-=+[{]\\|;:'',<.>/?\"")

  
 if(vVal=="")
  {alert("enter the Userid");ec=1;}
  else
      {
     for(i=0;i<vVal.length;i++)
     for(j=0;j<not_char.length;j++)
		 {
          if(vVal.charAt(i) == not_char.charAt(j)) { alert("enter proper User Id...you can use '_'");ec=1;}
          }    
                      
       }

}



//FOR VALIDATIONG THE SELECT BOX

function selectBox(vFrm,vObj,vLabel)
{

vObj=eval("document."+vFrm+"."+vObj);
vVal=vObj.selectedIndex;

	if (vVal==0 )
	{
	alert("Please select " + vLabel);
	return -1;
	}


}

//FOR VALIDATIONG THE SELECT BOX ARRAY

function selectBoxArray(vFrm,vObj,vInd,vLabel)
{

vObj=eval("document."+vFrm+"."+vObj[vInd]);
vVal=vObj.selectedIndex;

	if (vVal==0 )
	{
	alert("Please select" + vLabel);
	return false;
	}
}

//FOR VALIDATING THE CHECK BOX


function fnCheckAll(vFrm,vObj,vObj1)
{

vObj=eval("document."+vFrm+"."+vObj);	
vObj1=eval("document."+vFrm+"."+vObj1);	
var vLen;
vLen=vObj1.length;

if(vObj.checked)
	{
		for(var i=0;i<vLen;i++)		
		vObj1[i].checked=true;
		
	}
else
	{
		for(var i=0;i<vLen;i++)		
		vObj1[i].checked=false;
		
	}
return false;
}




//	FOR REPLACTING STRINGS 


function replace(thestring,searchfor,replacewith)
{

  str=thestring;
  len=str.length
  searchstr=searchfor;
  replacestr=replacewith;
  var str1;    
  for(i=0;i<str.length;i++)
  {       
     if(str.substring(i,i+searchstr.length)==searchstr)
     {       
        str1=str.substring(0,i)+replacestr;               
        str=str1+str.substring(i+searchstr.length,len);                        
     }  
  }

}


//FOR GETTING RADIO BUTTON VALUES


function fnradio(vFrm,vObj)

{
vObj=eval("document."+vFrm+"."+vObj);

for(var i=0 ; i<frm.r.length ; i++)
   if (vObj[i].checked)
    {
        vVal = vObj[i].value
     
    }

return false;
}


//Calendar

function show_calendar2(str_target, str_datetime) {
	var arr_months = ["January", "February", "March", "April", "May", "June",
		"July", "August", "September", "October", "November", "December"];
	var week_days = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
	var n_weekstart = 1; // day week starts from (normally 0 or 1)

	var dt_datetime = (str_datetime == null || str_datetime =="" ?  new Date() : str2dt2(str_datetime));		
	//If invalid format then return.
	if(dt_datetime=="-1")
	{		
		return;
	}
		
	var dt_prev_month = new Date(dt_datetime);
	dt_prev_month.setMonth(dt_datetime.getMonth()-1);
	if (dt_datetime.getMonth()%12 != (dt_prev_month.getMonth()+1)%12) {
		dt_prev_month.setMonth(dt_datetime.getMonth());
		dt_prev_month.setDate(0);
	}
	var dt_next_month = new Date(dt_datetime);
	dt_next_month.setMonth(dt_datetime.getMonth()+1);
	if ((dt_datetime.getMonth() + 1)%12 != dt_next_month.getMonth()%12)
		dt_next_month.setDate(0);
	
	var dt_firstday = new Date(dt_datetime);
	dt_firstday.setDate(1);
	dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);
	var dt_lastday = new Date(dt_next_month);
	dt_lastday.setDate(0);
	
	// html generation (feel free to tune it for your particular application)
	// print calendar header
	var str_buffer = new String (
		"<html>\n"+
		"<head>\n"+
		"	<title>Calendar</title>\n"+
		"</head>\n"+
		"<body bgcolor=\"White\">\n"+
		"<table class=\"clsOTable\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n"+
		"<tr><td bgcolor=\"#4682B4\">\n"+
		"<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\">\n"+
		"<tr>\n	<td bgcolor=\"#4682B4\"><a href=\"javascript:window.opener.show_calendar2('"+
		str_target+"', '"+ dt2dtstr2(dt_prev_month)+"');\">"+
		"<img src=\"..\\..\\..\\images\\prev.gif\" width=\"16\" height=\"16\" border=\"0\""+
		" alt=\"previous month\"></a></td>\n"+
		"	<td bgcolor=\"#4682B4\" colspan=\"5\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"
		+arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"</font></td>\n"+
		"	<td bgcolor=\"#4682B4\" align=\"right\"><a href=\"javascript:window.opener.show_calendar2('"
		+str_target+"', '"+dt2dtstr2(dt_next_month)+"');\">"+
		"<img src=\"..\\..\\..\\images\\next.gif\" width=\"16\" height=\"16\" border=\"0\""+
		" alt=\"next month\"></a></td>\n</tr>\n"
	);

	var dt_current_day = new Date(dt_firstday);
	// print weekdays titles
	str_buffer += "<tr>\n";
	for (var n=0; n<7; n++)
		str_buffer += "	<td bgcolor=\"#87CEFA\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"+
		week_days[(n_weekstart+n)%7]+"</font></td>\n";
	// print calendar table
	str_buffer += "</tr>\n";
	while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
		dt_current_day.getMonth() == dt_firstday.getMonth()) {
		// print row heder
		str_buffer += "<tr>\n";
		for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
				if (dt_current_day.getDate() == dt_datetime.getDate() &&
					dt_current_day.getMonth() == dt_datetime.getMonth())
					// print current date
					str_buffer += "	<td bgcolor=\"#FFB6C1\" align=\"right\">";
				else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 7)
					// weekend days
					str_buffer += "	<td bgcolor=\"#DBEAF5\" align=\"right\">";
				else
					// print working days of current month
					str_buffer += "	<td bgcolor=\"white\" align=\"right\">";

				if (dt_current_day.getMonth() == dt_datetime.getMonth())
					// print days of current month
					str_buffer += "<a href=\"javascript:window.opener."+str_target+
					".value='"+dt2dtstr2(dt_current_day)+"'; window.close();\">"+
					"<font color=\"black\" face=\"tahoma, verdana\" size=\"2\">";
				else 
					// print days of other months
					str_buffer += "<a href=\"javascript:window.opener."+str_target+
					".value='"+dt2dtstr2(dt_current_day)+"'; window.close();\">"+
					"<font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";
				str_buffer += dt_current_day.getDate()+"</font></a></td>\n";
				dt_current_day.setDate(dt_current_day.getDate()+1);
		}
		// print row footer
		str_buffer += "</tr>\n";
	}
	// print calendar footer
	str_buffer +=
		"</table>\n" +
		"</tr>\n</td>\n</table>\n" +
		"</body>\n" +
		"</html>\n";

	var vWinCal = window.open("", "Calendar", 
		"width=200,height=250,status=no,resizable=yes,top=200,left=200");
	vWinCal.opener = self;
	vWinCal.focus();
	var calc_doc = vWinCal.document;
	calc_doc.write (str_buffer);
	calc_doc.close();
}

// datetime parsing and formatting routimes. modify them if you wish other datetime format
function str2dt2 (str_datetime) {	
	var re_date = /^(\d+)\/(\d+)\/(\d+)$/;
	if (!re_date.exec(str_datetime))
	{
		alert("Invalid Datetime format: "+ str_datetime);
		return -1;
	}
	return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1));
	
}
function dt2dtstr2 (dt_datetime) {
	vMon=dt_datetime.getMonth()+1;	
	if(vMon<10)
		vMon="0"+vMon;
	vDat=dt_datetime.getDate()
	if(vDat<10)
		vDat="0"+vDat
	return (new String (
			vDat+"/"+vMon+"/"+dt_datetime.getFullYear()));
}

function fnSplChar(vFrm,vObj,vVal,vMsg)
{
	var splChArr=new Array('!','-','_',',',' ','#','$','%','^','&','*','(',')','<','>','.','@','|','{','}','[',']','\\','/');
		
	for (i=0;i<vVal.length;i++)	  
		for(j=0;j<splChArr.length;j++)
			if(vVal.charAt(i)==splChArr[j])
			{
				alert("Please enter valid " + vMsg);				
				vFocusObj=eval("document."+vFrm+"."+vObj);
				vFocusObj.focus();
				return false;
			}	
	return true;
}

function fnCheckDelete()
{
	return confirm('Are you sure you want to delete ? ');
}


//-------------------------------------------------------------
    // Select all the checkboxes (Hotmail style)
    //-------------------------------------------------------------
    function SelectAllCheckboxes(spanChk){
    
    // Added as ASPX uses SPAN for checkbox 
    var oItem = spanChk.children;
    var theBox=oItem.item(0)
    xState=theBox.checked;    

        elm=theBox.form.elements;
        for(i=0;i<elm.length;i++)
        if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
            {
            //elm[i].click();
            if(elm[i].checked!=xState)
            elm[i].click();
            //elm[i].checked=xState;
            }
    }
    
    function HighlightRow(chkB)    {
    var oItem = chkB.children;
    xState=oItem.item(0).checked;    
    if(xState)
        {
        //chkB.parentElement.parentElement.style.backgroundColor='#FFCC66';
        chkB.parentElement.parentElement.parentElement.style.backgroundColor='#DBEAF5';
        //#DBEAF5#4791C5
        // grdEmployees.SelectedItemStyle.BackColor
        //chkB.parentElement.parentElement.style.color='white';
        chkB.parentElement.parentElement.parentElement.style.color='white';
        // grdEmployees.SelectedItemStyle.ForeColor
        }
        else 
        {
        chkB.parentElement.parentElement.parentElement.style.backgroundColor='white';
        //grdEmployees.ItemStyle.BackColor
        chkB.parentElement.parentElement.parentElement.style.color='#DBEAF5';
        //grdEmployees.ItemStyle.ForeColor
        }
    }
    
//this has been added to ensure the user selects site and comp before he starts doing any transaction
     /*    
    function setStatus(vSiteOrComp)
	{ 
	    //Whenever the user selectes either company or site this cookie will be created.	    
	   setCookie('eBizSiteOrComp',vSiteOrComp,'');
	}
	*/
    function ShowCompSiteError()
	{
	    //Before going to this function get the value of the cookie
	    //and then check whether it has any value. if it has any value then proceed
	    //other wise generate error and stop submitting...
	    var vSiteOrComp = getCookie('eBizSiteOrComp');
	   
		 if(vSiteOrComp != "" && vSiteOrComp != null)
		 {
		    setCookie('eBizSiteOrComp','','');
		    return true;
		 }
		 else
		 {		    
		    document.getElementById("lblMessage").innerText = "Please Select Company and Site";
		    document.getElementById("lblMessage").className = "messageFail";
		    document.getElementById("lblMessage").focus();
		    return false;
		 }		
	}
	/*
	function setCookie(c_name,value,expiredays)
    {         
        document.cookie=c_name+ "=" +escape(value) ;//+((expiredays==null) ? "" : ";expires="+exdate);
    }
	*/
	function getCookie(c_name)
    {
        if (document.cookie.length>0)
          {            
              c_start=document.cookie.indexOf(c_name + "=");
              
              if (c_start!=-1)
                { 
                    c_start=c_start + c_name.length+1 ;                    
                    var substr = unescape(document.cookie.substring(c_start,document.cookie.length));                    
                    c_end = substr.indexOf(";");                    
                    if(c_end != -1)
                        return substr.substring(0,c_end);
                    else
                        return substr;   
                    
                } 
          }
        return null;
    }


//Function to Show the ViewLog Link in the page
   function ShowErrorBtn()
   {
		lnkViewLog = document.getElementById("ErrorLog_lnkViewLog");
		lnkViewLog.style.display="block";
	}
	
	//Function to Show the ViewLog Link in the page
	function ShowErrorLog(tt)
	{
		var strURL,strScreen;
		var winFeatures,width,height,left,top;
		
		width=800;
		height=400;
		
		top = (screen.height-height)/2-20;
		left = (screen.width-width)/2;
		
		strURL = "../../../common/aspx/ShowErrorLog.aspx?tt=" + tt;
		
		winFeatures = "toolbars=no,scrollbars=yes,resizable=yes";
		winFeatures = winFeatures + ",width=" + width + ",height=" + height ;
		winFeatures = winFeatures + ",top=" + top + ",left=" + left;
		
		window.open(strURL,"ShowErrorLog",winFeatures);
	}
	
	function ShowErrorLog(tt,seqNo)
	{
		var strURL,strScreen;
		var winFeatures,width,height,left,top;
		
		width=800;
		height=400;
		
		top = (screen.height-height)/2-20;
		left = (screen.width-width)/2;
		
		strURL = "../../../common/aspx/ShowErrorLog.aspx?tt=" + tt;
		if(!isNaN(seqNo))
		{
		   strURL = strURL + "&seq=" + seqNo;
		}
		
		winFeatures = "toolbars=no,scrollbars=yes,resizable=yes";
		winFeatures = winFeatures + ",width=" + width + ",height=" + height ;
		winFeatures = winFeatures + ",top=" + top + ",left=" + left;
		
		window.open(strURL,"ShowErrorLog",winFeatures);
	}
	
	function Trim(s) 
	{
		  
		while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
		{
			s = s.substring(1,s.length);
		}

		while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
		{
			s = s.substring(0,s.length-1);
		}
		return s;
	}

    function fnHide(vPanelQry,vPanelButton,hdnStatusQB)
	{		
		if(vPanelQry.style.display == 'none' )
		{
			event.srcElement.src = "../../../Images/redpin.gif";
			vPanelQry.style.display = "block";		
			if(vPanelButton!=null)			
			vPanelButton.style.display = "block";					
			hdnStatusQB.value = "block";
			event.srcElement.alt = "Hide Query Block";
		}
		else 
		{
			event.srcElement.src = "../../../Images/greenpin.gif";
			vPanelQry.style.display = "none";					
			if(vPanelButton!=null)
			vPanelButton.style.display = "none";					
			hdnStatusQB.value = "none";
			event.srcElement.alt = "Show Query Block";
		}						
	}
	
    function SelectAllCheckboxes(spanChk,dgGrid,intRow)
	{
		 
		var strRows = document.getElementById(dgGrid).rows;																
		try
		{
			for(i=1;i<strRows.length;i++)
			{						
				strRows[i].cells[intRow].childNodes.item(0).checked = document.getElementById(spanChk.id).checked;
				HighlightRow(strRows[i].cells[intRow].childNodes.item(0));
			}
		}
		catch(e)
		{
			var r = '';
			for (var p in e)
				r += p + ': ' + e[p] + '\n';
			alert(r);
			return false;
		}
	}
		
	function HighlightRow(chkB)  
	{
		if(chkB.checked == true)
		{
			chkB.parentElement.parentElement.style.backgroundColor='#DBEAF5';        
			chkB.parentElement.parentElement.style.color='white';        
		}
		else
		{
			chkB.parentElement.parentElement.style.backgroundColor='white';        
			chkB.parentElement.parentElement.style.color='#DBEAF5';        
		}
    }
    

    //start of - FUNCTIONS TO VALIDATE PRE-FORMATTED DATES IN MM/DD/YYYY FORMAT
function fnFormatDate(vDateName)
{	
	if((event.keyCode > 7 &&  event.keyCode < 47) )
		return true;
		
	if(vDateName.value.length == 2 || vDateName.value.length == 5)
		vDateName.value += "/";
	
	return true;
}

function fnFormatTime(vDateName)
{	
				
		if((event.keyCode > 47 &&  event.keyCode < 58) || (event.keyCode > 95 &&  event.keyCode < 106) )
		{				
			if(vDateName.value.length == 2)
			{
			    if(parseInt(vDateName.value) >23)
			    {
			        //alert("Hours should not be greater than 23");
			        document.getElementById("lblMessage").className = "messageFail";
					document.getElementById("lblMessage").innerText = "Hours should not be greater than 23";	
			        vDateName.value = "";			        
			        return false;
			    }
			    vDateName.value += ":";
			}
			else
			{
			    if(vDateName.value.length == 5)
			    {
			        var TempVal = validateTime(vDateName);
			        if(TempVal != true)
			        {
			           vDateName.value = "";
			            return false; 
			        }		        
			    }
			}
		}
		else
		{
			return false;		
		}			
		return true;
}

function validateTime(vTimeClientId)
{	
	vStTime = vTimeClientId.value;
	
	vTimeFieldId = vTimeClientId;			
	a = vStTime.length;
	count=0;
	for(i=0;i<a;i++)
	if (vStTime.charAt(i)=="")
		count++;			
				
				
		if ((vStTime.charAt(2)== ":") && (vStTime.length == 5) )
		{		
				
				hh = vStTime.substring(0,2)
				mm = vStTime.substring(3,5)
			//	ss = vStTime.substring(6,8)
												
		
			/*	if(hh<=0)
				{
					//window.alert("Hours should be greater than zero")
					document.getElementById("lblMessage").className = "messageFail";
					document.getElementById("lblMessage").innerText = "Hours should be greater than zero";	
					//vTimeFieldId.focus();
					//vTimeFieldId.select();
					return 1;
				}
				
				if(mm<0)
				{
					//window.alert("Minutes should be greater than or equall to zero")
					document.getElementById("lblMessage").className = "messageFail";
					document.getElementById("lblMessage").innerText = "Minutes should be greater than or equall to zero";	
					//vTimeFieldId.focus();
					//vTimeFieldId.select();
					return 2;
				} */
					
	
				if(hh>23)
				{
					//window.alert("Hours should not be greater than 23")
					document.getElementById("lblMessage").className = "messageFail";
					document.getElementById("lblMessage").innerText = "Hours should not be greater than 23";						
					vTimeFieldId.focus();
					vTimeFieldId.select();
					return 3;
				}
			
				if(mm>59)
				{
					
					document.getElementById("lblMessage").className = "messageFail";
					document.getElementById("lblMessage").innerText = "Minutes should not be greater than 59";	
					//vTimeFieldId.value = "";
					//vTimeFieldId.focus();
					//vTimeFieldId.select();
					return 4;
				}
			
		}		

		else
		{
		if (vStTime != "")
		{		
			//alert("Time should be in the format : HH:MM:SS"); 
			document.getElementById("lblMessage").className = "messageFail";
			document.getElementById("lblMessage").innerText = "Time should be in the format : HH:MM";	
			//vTimeFieldId.focus();
			//vTimeFieldId.select();
		return false;
		} 
	}			
//}   
document.getElementById("lblMessage").innerText = "";	
return true;
}

function fnValidate(vDateName)
{
	if((event.keyCode > 7 &&  event.keyCode < 47) )
			return true;
	
							
	if ((event.keyCode > 47 && event.keyCode < 58)||(event.keyCode > 95 &&  event.keyCode < 107)) 
	{
		if (vDateName.value.length >= 10)
			return false;
			
		return true;
	}
	return false;
}

function fnValidateDate(vDateFieldId)
{
	vDateReq = vDateFieldId.value;

	a = vDateReq.length;
	count=0;
	for(i=0;i<a;i++)
	if (vDateReq.charAt(i)=="")	count++;
	if (count == a)
	{
	//	window.alert("Please enter the  Date.\n");
	//	vDateFieldId.focus();
	//	return false;
	}
	else
	{
		month1 = 0;
		if(vDateReq.indexOf(".")!=-1)
		{
		alert("Please remove the dots");
		vDateFieldId.focus();
		vDateFieldId.select();
		return false;
		}

		if(vDateReq.indexOf(" ")!=-1)
		{
		alert("Please remove the spaces");
		vDateFieldId.focus();
		vDateFieldId.select();
		return false;
		}
		
		if ((vDateReq.charAt(2)== "-" && vDateReq.charAt(5)=="-" && vDateReq.length == 10) || (vDateReq.charAt(2)== "/" && vDateReq.charAt(5)=="/" && vDateReq.length == 10))
		{
			mm = vDateReq.substring(0,2);
			dd = vDateReq.substring(3,5);
			yyyy = vDateReq.substring(6,10);
			var arr31 =new Array (1,3,5,7,8,10,12);
			var arr30 = new Array(4,6,9,11);
			if (isNaN(dd) || isNaN(yyyy))
			{
			alert("Day should be Numerics");
				vDateFieldId.focus();
				vDateFieldId.select();
				return false;
			} 
			
			if((dd==0)||(yyyy==0000)||(mm==0))
			{
				window.alert("Month/Day/Year/ should not be zero");
				vDateFieldId.focus();
				vDateFieldId.select();
				return false;
			}		

			if ((mm <=12 ) && (mm > 0))
			{
				for (i=0 ; i<arr31.length ; i++)
				if (mm == arr31[i])
				{
					month1 = 31;
					break; 
				}

				if (month1 == 0)
				for (i=0 ; i<arr30.length ; i++)
				if (mm == arr30[i])
				{
					month1 = 30;
					break; 
				}

				if (month1 == 30)
				if (dd > 30 )
				{
					alert("Date should be less than or equal to 30");
					vDateFieldId.focus();
					vDateFieldId.select();
					return false;

				}	

				if (month1 == 31)
				if (dd > 31 )
				{
					alert("Date should be less than or equal to 31");
					vDateFieldId.focus();
					vDateFieldId.select();
					return false;
				}	


				if (mm == 2)    
				if ((((yyyy % 4 == 0) && (yyyy%100 != 0)) || (yyyy%400 ==0)) && dd > 29) 
				{
					alert("Day should be less than 29");
					vDateFieldId.focus();
					vDateFieldId.select();
					return false;

				}	
				else
				if (dd > 28)
				{
					alert("Day should be less than 28");
					vDateFieldId.focus();
					vDateFieldId.select();
					return false;
				}
			}	
			else
			{
				alert("Month should be in between 1 and 12");
				vDateFieldId.focus();
				vDateFieldId.select();
				return false;
			}	

		}
		else
			if (vDateReq != "")
			{
				alert("Date should in the format : MM/DD/YYYY") ;
				vDateFieldId.focus();
				vDateFieldId.select();
				return false;
			}    
	}  
	 
	return true;
}   		
//end of - FUNCTIONS TO VALIDATE PRE-FORMATTED DATES IN MM/DD/YYYY FORMAT

function fnAlphaNumeric()
{
	// space,single quote, comma
	//(event.srcElement.value.length>0)
	
	if ((event.keyCode==32) || (event.keyCode==39) || (event.keyCode==44))
	{
		return true;
	}
	//0-9
	if ((event.keyCode>47) && (event.keyCode<58))
	{
		return true;
	}
	//for -
	if (event.keyCode==45)
	{
		return true;
	}

	//a-z
	if ((event.keyCode>96) && (event.keyCode<123))
	{
		return true;
	}
	
	//A-Z
	if ((event.keyCode>64) && (event.keyCode<91))
	{
		return true;
	}
	return false;
}
	
// fnalphanumeric with percentage sign
function fnAlphaNumericwp()
{
	// space,single quote, comma
	if ((event.keyCode==32) || (event.keyCode==39) || (event.keyCode==44))
	{
		return true;
	}
	//%
	if (event.keyCode==37)
	{
		return true;
	}
	//0-9
	if ((event.keyCode>47) && (event.keyCode<58))
	{
		return true;
	}

	//a-z
	if ((event.keyCode>96) && (event.keyCode<123))
	{
		return true;
	}
	
	//A-Z
	if ((event.keyCode>64) && (event.keyCode<91))
	{
		return true;
	}
	return false;
}

		
function fnNumeric()
{
	//0-9
	if ((event.keyCode>47) && (event.keyCode<58))
	{
		return true;
	}			
	return false;
}

function getScrollBottom(p_oElem)
{
	return p_oElem.scrollHeight - p_oElem.scrollTop - p_oElem.clientHeight;
}

function fnLoad(vdocument)
{					
		if(document.getElementById("hdnStatus").value != "")
		{
			vdocument.getElementById("pnlQuery").style.display = vdocument.getElementById("hdnStatus").value;
			if(vdocument.getElementById("pnlButton")!=null)
			vdocument.getElementById("pnlButton").style.display = vdocument.getElementById("hdnStatus").value;
			if(vdocument.getElementById("hdnStatus").value == "block")
			{
				vdocument.getElementById("btnHide").src = "../../../Images/redpin.gif";
				vdocument.getElementById("btnHide").alt = "Hide Query Block";
			}
			else
			{
				vdocument.getElementById("btnHide").src = "../../../Images/greenpin.gif";
				vdocument.getElementById("btnHide").alt = "Show Query Block";
			}
		}				
		
}		

function fnFixHeader(dgDataGrid)
{					
	if(document.getElementById(dgDataGrid) != null)
	{
		try
		{													
			var intTableLength = document.getElementById(dgDataGrid).rows.length;
			var HeaderRow = document.getElementById(dgDataGrid).rows[0];
			var FooterRow = document.getElementById(dgDataGrid).rows[intTableLength -1];
			if(document.getElementById(dgDataGrid).rows.length > 8)
			{
				HeaderRow.className = "ScrollGridHeader";
				FooterRow.className = "ScrollGridFooter";							
			}
			else
			{
				HeaderRow.className = "gridHeadercolor";
				FooterRow.className = "gridFootercolor";	
			}
		}
		catch(e)
		{
			var r = '';
			for (var p in e)
				r += p + ': ' + e[p] + '\n';
			alert(r);
		}
	}
}

function fnTimeNumeric()
{
		// single quote
	if (event.keyCode==39)
	{
		return true;
	}
	//0-9
	if ((event.keyCode>47) && (event.keyCode<58))
	{
		return true;
	}			
	return false;
}

			function fnTimeValidate(vTimeFieldId)
{

    var vStTime = vTimeFieldId.value;
    var a = vStTime.length;

		if(vStTime.indexOf(".")!=-1)
		{
			alert("Please remove the dots");
			vTimeFieldId.focus();
			vTimeFieldId.select();
			return false;
		}

		if(vStTime.indexOf(" ")!=-1)
		{
			alert("Please remove the spaces");
			vTimeFieldId.focus();
			vTimeFieldId.select();
			return false;
		}

		if ((vStTime.charAt(2)== ":") && (vStTime.charAt(5)== ":") && (vStTime.length == 8) )
		{
				hh = vStTime.substring(0,2)
				mm = vStTime.substring(3,5)
				ss = vStTime.substring(6,8)

				if (isNaN(hh) || isNaN(mm) || isNaN(ss))
				{
					alert("Time should be Numerics");
					vTimeFieldId.focus();
					vTimeFieldId.select();
					return false;
				}

				if(hh<0)
				{
					window.alert("Hours should be greater than or equal to zero")
					vTimeFieldId.focus();
					vTimeFieldId.select();
					return false;
				}

				if(mm<0)
				{
					window.alert("Minutes should be greater than or equal to zero")
					vTimeFieldId.focus();
					vTimeFieldId.select();
					return false;
				}
				
				if(ss<0)
				{
					window.alert("Seconds should be greater than or equal to zero")
					vTimeFieldId.focus();
					vTimeFieldId.select();
					return false;
				}


				if(hh>23)
				{
					window.alert("Hours should not be greater than 23")
					vTimeFieldId.focus();
					vTimeFieldId.select();
					return false;
				}

				if(mm>59)
				{
					window.alert("Minutes should not be greater than 59")
					vTimeFieldId.focus();
					vTimeFieldId.select();
					return false;
				}
				
				if(ss>59)
				{
					window.alert("Seconds should not be greater than 59")
					vTimeFieldId.focus();
					vTimeFieldId.select();
					return false;
				}
		}

		else
		{
			if (vStTime != "")
			{
				alert("Time should be in the format : HH:MM:SS");
				vTimeFieldId.focus();
				vTimeFieldId.select();
				return false;
			}
		}
}

//Generate popup window with parent page details

function getPrint_Old(print_area,SubTitle)
{				 
	var pp = window.open();			 
	pp.document.writeln('<HTML><HEAD><title>Print Preview</title><LINK href="../../../inc/style.css"  type="text/css" rel="stylesheet">')
	pp.document.writeln('<LINK href="PrintStyle.css"  type="text/css" rel="stylesheet" media="print">')
	pp.document.writeln('<base target="_self"></HEAD>')				 
	pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0" onload="window.print();">');
	pp.document.writeln('<form  method="post">');			 
	pp.document.writeln('<TABLE width=100%><TR><TD></TD></TR><TR><TD align=right><INPUT ID="PRINT" type="button" Class="btn" value="Print" onclick="javascript:location.reload(true);window.print();">&nbsp;<INPUT ID="CLOSE" type="button" value="Close" Class="btn"  onclick="window.close();"></TD></TR><TR><TD></TD></TR></TABLE>');
	pp.document.writeln('<table cellSpacing="0" cellPadding="0" width="100%" border="0"><tr height=25><td><table cellSpacing="0" cellPadding="0" width="100%" border="0"><tr><TD align="center" valign="middle"><FONT style="color:black;font-family:Verdana,Arial,sans-serif;font-size:15pt;font-weight:bold;">'+ SubTitle +'</FONT><br><br></TD></TR></TABLE></td></tr></table>');
	
	pp.document.writeln(document.getElementById(print_area).innerHTML);
	
	pp.document.writeln('</form></body></HTML>');
	return false;			
	
}
 function getPrint(print_area,SubTitle)
{			

    var winFeatures,width,height,left,top;

    width=900;
    height=500;

    top = (screen.height-height)/2-20;
    left = (screen.width-width)/2;

    winFeatures = "toolbars=yes,scrollbars=yes,resizable=yes,status=yes";
    winFeatures = winFeatures + ",width=" + width + ",height=" + height ;
    winFeatures = winFeatures + ",top=" + top + ",left=" + left;


 
    var pp = window.open('','',winFeatures);

    pp.document.writeln('<HTML><HEAD><title>Print Preview</title><LINK href="../../../inc/style.css"  type="text/css" rel="stylesheet">')
    pp.document.writeln('<LINK href="PrintStyle.css"  type="text/css" rel="stylesheet" media="print">')
    pp.document.writeln('<base target="_self"></HEAD>')				 
    pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0" onafterprint="fnAfterPrint()" onbeforeprint="fnBeforePrint()">');
    pp.document.writeln('<form  method="post">');			 
    pp.document.writeln('<TABLE width=100%><TR><TD></TD></TR><TR><TD align=right><INPUT ID="btnPrint" type="button" Class="btn" value="Print" onclick="javascript:location.reload(true);window.print();">&nbsp;<INPUT ID="btnClose" type="button" value="Close" Class="btn"  onclick="window.close();"></TD></TR><TR><TD></TD></TR></TABLE>');
    pp.document.writeln('<table cellSpacing="0" cellPadding="0" width="100%" border="0"><tr height=25><td><table cellSpacing="0" cellPadding="0" width="100%" border="0"><tr><TD align="center" valign="middle"><FONT style="color:black;font-family:Verdana,Arial,sans-serif;font-size:15pt;font-weight:bold;">'+ SubTitle +'</FONT><br><br></TD></TR></TABLE></td></tr></table>');
	
    pp.document.writeln(document.getElementById(print_area).innerHTML);
	
    pp.document.writeln('</form></body></HTML>');
    return false;			

}

function fnPhoneNumbers()
{	
	//0-9
	if ((event.keyCode>47) && (event.keyCode<58))
	{
		return true;
	}
	//for -
	if (event.keyCode==45)
	{
		return true;
	}
	
	//for +
	if (event.keyCode==43)
	{
		return true;
	}	
	return false;
}

function fnNumericWithDecimal()
{
	//0-9
	if ((event.keyCode>47) && (event.keyCode<58))
	{
		return true;
	}	
	
	if ((event.keyCode==46) && (event.srcElement.value.indexOf(".")==-1))
	{
		return true;
	}
			
	return false;
}


function fnGetCurrentDate()
{
    var temp = "";

    var currDate = new Date();

    var mn = currDate.getMonth();

    //month 0 - 11 then we add one to get the actual month value

    mn=mn+1;

    if(mn < 10)
    {
        mn="0"+mn;
    }

    temp += mn + "/";

    var mnDay = currDate.getDate();

    if(mnDay < 10)
    {
        mnDay="0"+mnDay;
    }

    //day of month 1-31

    temp += mnDay + "/";

    var yr = currDate.getYear();

    //year number since 2000

    temp += yr;
    
    return temp;
}
function fnDecimalNumeric()
			{
				//0-9
				if (((event.keyCode > 47) && (event.keyCode < 58)) || (event.keyCode == 39))
				{
					return true;
				}
				
				if((event.keyCode == 44))
				{
					return true;
				}
				
				//** For Decimal Values 
				//** 46 keyCode for "." 
				if(event.srcElement.value.indexOf(".") != -1)
				{
					if((event.keyCode == 46))
					{
						return false;
					}
				}
				else
				{
					if((event.keyCode == 46))
					{
						return true;
					}
				}
				
				return false;
			}
			
			
		function checkkey(order)
        {
            vOrder = order.value; 
            vRegex=/^[a-zA-Z0-9]{2}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{3}$/
                    
            if(!vOrder.match(vRegex)) 
            {
                alert('Please enter a valid Order #');
                order.focus();
                return false;
             }
             
            return true;
        }
        
        
