var DtKUpError=false
/****************************List of Sundays and Holidays, needs regular update - hence commented
var arrHolDate=new Array();
arrHolDate[0]='01/01/1900';
arrHolDate[1]='01/06/2002';
arrHolDate[2]='01/13/2002';
arrHolDate[3]='01/20/2002';
arrHolDate[4]='01/27/2002';
arrHolDate[5]='02/03/2002';
arrHolDate[6]='02/10/2002';
arrHolDate[7]='02/17/2002';
arrHolDate[8]='02/24/2002';
arrHolDate[9]='03/03/2002';
arrHolDate[10]='03/10/2002';
arrHolDate[11]='03/17/2002';
arrHolDate[12]='03/24/2002';
arrHolDate[13]='03/31/2002';
arrHolDate[14]='04/07/2002';
arrHolDate[15]='04/14/2002';
arrHolDate[16]='04/21/2002';
arrHolDate[17]='04/28/2002';
arrHolDate[18]='05/05/2002';
arrHolDate[19]='05/12/2002';
arrHolDate[20]='05/19/2002';
arrHolDate[21]='05/26/2002';
arrHolDate[22]='06/02/2002';
arrHolDate[23]='06/09/2002';
arrHolDate[24]='06/16/2002';
arrHolDate[25]='06/23/2002';
arrHolDate[26]='06/30/2002';
arrHolDate[27]='07/07/2002';
arrHolDate[28]='07/14/2002';
arrHolDate[29]='07/21/2002';
arrHolDate[30]='07/28/2002';
arrHolDate[31]='08/04/2002';
arrHolDate[32]='08/11/2002';
arrHolDate[33]='08/18/2002';
arrHolDate[34]='08/25/2002';
arrHolDate[35]='09/01/2002';
arrHolDate[36]='09/08/2002';
arrHolDate[37]='09/15/2002';
arrHolDate[38]='09/22/2002';
arrHolDate[39]='09/29/2002';
arrHolDate[40]='10/06/2002';
arrHolDate[41]='10/13/2002';
arrHolDate[42]='10/20/2002';
arrHolDate[43]='10/27/2002';
arrHolDate[44]='11/03/2002';
arrHolDate[45]='11/10/2002';
arrHolDate[46]='11/17/2002';
arrHolDate[47]='11/24/2002';
arrHolDate[48]='12/01/2002';
arrHolDate[49]='12/08/2002';
arrHolDate[50]='12/15/2002';
arrHolDate[51]='12/22/2002';
arrHolDate[52]='12/29/2002';
arrHolDate[53]='01/02/2002';
arrHolDate[54]='01/01/2002';
arrHolDate[55]='01/04/2004';
arrHolDate[56]='01/11/2004';
arrHolDate[57]='01/18/2004';
arrHolDate[58]='01/25/2004';
arrHolDate[59]='02/01/2004';
arrHolDate[60]='02/08/2004';
arrHolDate[61]='02/15/2004';
arrHolDate[62]='02/22/2004';
arrHolDate[63]='02/29/2004';
arrHolDate[64]='03/07/2004';
arrHolDate[65]='03/14/2004';
arrHolDate[66]='03/21/2004';
arrHolDate[67]='03/28/2004';
arrHolDate[68]='04/04/2004';
arrHolDate[69]='04/11/2004';
arrHolDate[70]='04/18/2004';
arrHolDate[71]='04/25/2004';
arrHolDate[72]='05/02/2004';
arrHolDate[73]='05/09/2004';
arrHolDate[74]='05/16/2004';
arrHolDate[75]='05/23/2004';
arrHolDate[76]='05/30/2004';
arrHolDate[77]='06/06/2004';
arrHolDate[78]='06/13/2004';
arrHolDate[79]='06/20/2004';
arrHolDate[80]='06/27/2004';
arrHolDate[81]='07/04/2004';
arrHolDate[82]='07/11/2004';
arrHolDate[83]='07/18/2004';
arrHolDate[84]='07/25/2004';
arrHolDate[85]='08/01/2004';
arrHolDate[86]='08/08/2004';
arrHolDate[87]='08/15/2004';
arrHolDate[88]='08/22/2004';
arrHolDate[89]='08/29/2004';
arrHolDate[90]='09/05/2004';
arrHolDate[91]='09/12/2004';
arrHolDate[92]='09/19/2004';
arrHolDate[93]='09/26/2004';
arrHolDate[94]='10/03/2004';
arrHolDate[95]='10/10/2004';
arrHolDate[96]='10/17/2004';
arrHolDate[97]='10/24/2004';
arrHolDate[98]='10/31/2004';
arrHolDate[99]='11/07/2004';
arrHolDate[100]='11/14/2004';
arrHolDate[101]='11/21/2004';
arrHolDate[102]='11/28/2004';
arrHolDate[103]='12/05/2004';
arrHolDate[104]='12/12/2004';
arrHolDate[105]='12/19/2004';
arrHolDate[106]='12/26/2004';
*************************************/
var weekend = [0,6];
var weekendColor = "#D1D1D1";
var fontface = "Verdana";
var fontsize = 2;

var gNow = new Date();
var ggWinCal;

isNav = (navigator.appName.indexOf("Netscape") != -1) ? true : false;
isIE  = (navigator.appName.indexOf("Microsoft")!= -1) ? true : false;

Calendar.Months = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"];

Calendar.DOMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

Calendar.lDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

function Calendar(p_item, p_WinCal, p_month, p_year, p_format) {

        if ((p_month == null) && (p_year == null))        return;

        if (p_WinCal == null)
                this.gWinCal = ggWinCal;
        else
                this.gWinCal = p_WinCal;

        if (p_month == null) {
                this.gMonthName = null;
                this.gMonth = null;
                this.gYearly = true;
        } else {
                this.gMonthName = Calendar.get_month(p_month);
                this.gMonth = new Number(p_month);
                this.gYearly = false;
        }



        this.gYear = p_year;
        p_format = p_fmt;
        this.gFormat = p_format;
        this.gBGColor = "#D1D1D1";
        this.gFGColor = "black";
        this.gTextColor = "black";
        this.gHeaderColor = "black";
        this.gReturnItem = p_item;
}

Calendar.get_month = Calendar_get_month;
Calendar.get_daysofmonth = Calendar_get_daysofmonth;
Calendar.calc_month_year = Calendar_calc_month_year;
Calendar.print = Calendar_print;

function Calendar_get_month(monthNo) {
        return Calendar.Months[monthNo];
}

function Calendar_get_daysofmonth(monthNo, p_year) {

        if ((p_year % 4) == 0) {
                if ((p_year % 100) == 0 && (p_year % 400) != 0)
                        return Calendar.DOMonth[monthNo];

                return Calendar.lDOMonth[monthNo];
        } else
                return Calendar.DOMonth[monthNo];
}

function Calendar_calc_month_year(p_Month, p_Year, incr) {

        var ret_arr = new Array();

        if (incr == -1) {

                if (p_Month == 0) {
                        ret_arr[0] = 11;
                        ret_arr[1] = parseInt(p_Year) - 1;
                }
                else {
                        ret_arr[0] = parseInt(p_Month) - 1;
                        ret_arr[1] = parseInt(p_Year);
                }
        } else if (incr == 1) {

                if (p_Month == 11) {
                        ret_arr[0] = 0;
                        ret_arr[1] = parseInt(p_Year) + 1;
                }
                else {
                        ret_arr[0] = parseInt(p_Month) + 1;
                        ret_arr[1] = parseInt(p_Year);
                }
        }

        return ret_arr;
}

function Calendar_print()
{
 gWinCal.print();
}

function Calendar_calc_month_year(p_Month, p_Year, incr) {

        var ret_arr = new Array();

        if (incr == -1) {

                if (p_Month == 0) {
                        ret_arr[0] = 11;
                        ret_arr[1] = parseInt(p_Year) - 1;
                }
                else {
                        ret_arr[0] = parseInt(p_Month) - 1;
                        ret_arr[1] = parseInt(p_Year);
                }
        } else if (incr == 1) {

                if (p_Month == 11) {
                        ret_arr[0] = 0;
                        ret_arr[1] = parseInt(p_Year) + 1;
                }
                else {
                        ret_arr[0] = parseInt(p_Month) + 1;
                        ret_arr[1] = parseInt(p_Year);
                }
        }

        return ret_arr;
}


new Calendar();

Calendar.prototype.getMonthlyCalendarCode = function() {
        var vCode = "";
        var vHeader_Code = "";
        var vData_Code = "";


        vCode = vCode + "<TABLE BORDER=1 BGCOLOR=\"" + this.gBGColor + "\">";

        vHeader_Code = this.cal_header();
        vData_Code = this.cal_data();
        vCode = vCode + vHeader_Code + vData_Code;

        vCode = vCode + "</TABLE>";

        return vCode;
}

Calendar.prototype.show = function() {
        var vCode = "";

        this.gWinCal.document.open();


        this.wwrite("<html>");
        this.wwrite("<head><title>Calendar</title>");
        this.wwrite("</head>");

        this.wwrite("<body bgcolor=\"#EBEAEA\"" +
                "link=\"" + this.gLinkColor + "\" " +
                "vlink=\"" + this.gLinkColor + "\" " +
                "alink=\"" + this.gLinkColor + "\" " +
                "text=\"" + this.gTextColor + "\"><form>");
        this.wwriteA("<FONT FACE='" + fontface + "' SIZE=2><B>");
        this.wwriteA(this.gMonthName + " " + this.gYear);
        this.wwriteA("</B><BR>");

        var prevMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, -1);
        var prevMM = prevMMYYYY[0];
        var prevYYYY = prevMMYYYY[1];

        var nextMMYYYY = Calendar.calc_month_year(this.gMonth, this.gYear, 1);
        var nextMM = nextMMYYYY[0];
        var nextYYYY = nextMMYYYY[1];

        this.wwrite("<TABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#D1D1D1'><TR><TD ALIGN=center>");
        this.wwrite("<FONT FACE='" + fontface + "' SIZE=1><A HREF=\"" +
                "javascript:window.opener.Build(" +
                "'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)-10) + "', '" + this.gFormat + "'" +
                ");" +
                "\" title=\"Click to move back 10 years\" >Year(-10)<\/A></FONT></TD><TD ALIGN=center>");
        this.wwrite("<FONT FACE='" + fontface + "' SIZE=1><A HREF=\"" +
                "javascript:window.opener.Build(" +
                "'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)-1) + "', '" + this.gFormat + "'" +
                ");" +
                "\" title=\"Click to move back 1 year\" >Year(-1)<\/A></FONT></TD><TD ALIGN=center>");
        this.wwrite("<FONT FACE='" + fontface + "' SIZE=1><A HREF=\"" +
                "javascript:window.opener.Build(" +
                "'" + this.gReturnItem + "', '" + prevMM + "', '" + prevYYYY + "', '" + this.gFormat + "'" +
                ");" +
                "\" title=\"Click to move back 1 month\" >Month(-1)<\/A></FONT></TD><TD ALIGN=center>");
        this.wwrite("<FONT FACE='" + fontface + "' SIZE=1><A HREF=\"" +
                "javascript:window.opener.Build(" +
                "'" + this.gReturnItem + "', '" + nextMM + "', '" + nextYYYY + "', '" + this.gFormat + "'" +
                ");" +
                "\" title=\"Click to move forward 1 month\" >Month(+1)<\/A></FONT></TD><TD ALIGN=center>");
        this.wwrite("<FONT FACE='" + fontface + "' SIZE=1><A HREF=\"" +
                "javascript:window.opener.Build(" +
                "'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)+1) + "', '" + this.gFormat + "'" +
                ");" +
                "\" title=\"Click to move forward 1 year\" >Year(+1)<\/A></FONT></TD><TD ALIGN=center>");
        this.wwrite("<FONT FACE='" + fontface + "' SIZE=1><A HREF=\"" +
                "javascript:window.opener.Build(" +
                "'" + this.gReturnItem + "', '" + this.gMonth + "', '" + (parseInt(this.gYear)+10) + "', '" + this.gFormat + "'" +
                ");" +
                "\" title=\"Click to move forward 10 years\" >Year(+10)<\/A></FONT></TD></TR></TABLE><BR>");
        this.wwrite("<center>");
        vCode = this.getMonthlyCalendarCode();
        this.wwrite(vCode);

	this.wwrite("<br>");
        this.wwrite("<TABLE WIDTH='100%' BORDER='0' CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN=center>");
        this.wwrite("<input type ='button' name='close' value='Close' style=\"font-size: 8pt\" onClick='self.close()' title='Click to close Calendar only \nif you do not want to select Date'><input type ='button' name='reset' value='Reset' style=\"font-size: 8pt\" onClick='opener.show_cal();' title='Click for current month and year'>");
        this.wwrite("</td></tr></table>");
        this.wwrite("</font></form></body></html>");
        this.gWinCal.document.close();
}

Calendar.prototype.showY = function() {
        var vCode = "";
        var i;
        var vr, vc, vx, vy;
        var vxf = 285;
        var vyf = 200;
        var vxm = 10;
        var vym;
        if (isIE)        vym = 75;
        else if (isNav)        vym = 25;

        this.gWinCal.document.open();

        this.wwrite("<html>");
        this.wwrite("<head><title>Calendar</title>");
        this.wwrite("<style type='text/css'>\n<!--");
        for (i=0; i<12; i++) {
                vc = i % 3;
                if (i>=0 && i<= 2)        vr = 0;
                if (i>=3 && i<= 5)        vr = 1;
                if (i>=6 && i<= 8)        vr = 2;
                if (i>=9 && i<= 11)        vr = 3;

                vx = parseInt(vxf * vc) + vxm;
                vy = parseInt(vyf * vr) + vym;

                this.wwrite(".lclass" + i + " {position:absolute;top:" + vy + ";left:" + vx + ";}");
        }
        this.wwrite("-->\n</style>");
        this.wwrite("</head>");

        this.wwrite("<body " +
                "link=\"" + this.gLinkColor + "\" " +
                "vlink=\"" + this.gLinkColor + "\" " +
                "alink=\"" + this.gLinkColor + "\" " +
                "text=\"" + this.gTextColor + "\">");
        this.wwrite("<FONT FACE='" + fontface + "' SIZE=2><B>");
        this.wwrite("Year : " + this.gYear);
        this.wwrite("</B><BR>");


        var prevYYYY = parseInt(this.gYear) - 1;
        var nextYYYY = parseInt(this.gYear) + 1;

        this.wwrite("<TABLE WIDTH='100%' BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#D1D1D1'><TR><TD ALIGN=center>");
        this.wwrite("[<A HREF=\"" +
                "javascript:window.opener.Build(" +
                "'" + this.gReturnItem + "', null, '" + prevYYYY + "', '" + this.gFormat + "'"

                +
                ");" +
                "\" alt='Prev Year'><<<\/A>]</TD><TD ALIGN=center>");
        this.wwrite("[<A HREF=\"javascript:window.print();\">Print</A>]</TD><TD ALIGN=center>");
        this.wwrite("[<A HREF=\"" +
                "javascript:window.opener.Build(" +
                "'" + this.gReturnItem + "', null, '" + nextYYYY + "', '" + this.gFormat + "'" +
                ");" +
                "\">>><\/A>]</TD></TR></TABLE><BR>");


        var j;
        for (i=11; i>=0; i--) {
                if (isIE)
                        this.wwrite("<DIV ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");
                else if (isNav)
                        this.wwrite("<LAYER ID=\"layer" + i + "\" CLASS=\"lclass" + i + "\">");

                this.gMonth = i;
                this.gMonthName = Calendar.get_month(this.gMonth);
                vCode = this.getMonthlyCalendarCode();
                this.wwrite(this.gMonthName + "/" + this.gYear + "<BR>");
                this.wwrite(vCode);

                if (isIE)
                        this.wwrite("</DIV>");
                else if (isNav)
                        this.wwrite("</LAYER>");
        }

        this.wwrite("</font><BR></body></html>");
        this.gWinCal.document.close();
}

Calendar.prototype.wwrite = function(wtext) {
        this.gWinCal.document.writeln(wtext);
}

Calendar.prototype.wwriteA = function(wtext) {
        this.gWinCal.document.write(wtext);
}

Calendar.prototype.cal_header = function() {
        var vCode = "";

        vCode = vCode + "<TR>";
        vCode = vCode + "<TD WIDTH='14%' bgcolor='#D1D1D1'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Sun</B></FONT></TD>";
        vCode = vCode + "<TD WIDTH='14%' bgcolor='#D1D1D1'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Mon</B></FONT></TD>";
        vCode = vCode + "<TD WIDTH='14%' bgcolor='#D1D1D1'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Tue</B></FONT></TD>";
        vCode = vCode + "<TD WIDTH='14%' bgcolor='#D1D1D1'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Wed</B></FONT></TD>";
        vCode = vCode + "<TD WIDTH='14%' bgcolor='#D1D1D1'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Thu</B></FONT></TD>";
        vCode = vCode + "<TD WIDTH='14%' bgcolor='#D1D1D1'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Fri</B></FONT></TD>";
        vCode = vCode + "<TD WIDTH='16%' bgcolor='#D1D1D1'><FONT SIZE='2' FACE='" + fontface + "' COLOR='" + this.gHeaderColor + "'><B>Sat</B></FONT></TD>";
        vCode = vCode + "</TR>";

        return vCode;
}

Calendar.prototype.cal_data = function() {
        var vDate = new Date();
        vDate.setDate(1);
        vDate.setMonth(this.gMonth);
        vDate.setFullYear(this.gYear);

        var vFirstDay=vDate.getDay();
        var vDay=1;
        var vLastDay=Calendar.get_daysofmonth(this.gMonth, this.gYear);
        var vOnLastDay=0;
        var vCode = "";


        vCode = vCode + "<TR>";
        for (i=0; i<vFirstDay; i++) {
                vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(i) + "><FONT SIZE='2' FACE='" + fontface + "'> </FONT></TD>";
        }

        for (j=vFirstDay; j<7; j++) {
        vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j) + "><FONT SIZE='2' FACE='" + fontface + "'>" +
                        "<A HREF='#' " +
                                "onClick=\"self.opener.document." + this.gReturnItem + ".value='" +
                                this.format_data(vDay) +
                                "';" + "\self.opener.document." + this.gReturnItem + ".focus();window.close();\">" +
                                this.format_day(vDay) +
                        "</A>" +
                        "</FONT></TD>";
                vDay=vDay + 1;
        }
        vCode = vCode + "</TR>";

        for (k=2; k<7; k++) {
                vCode = vCode + "<TR>";

                for (j=0; j<7; j++) {
                        vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j) + "><FONT SIZE='2' FACE='" + fontface + "'>" +
                                "<A HREF='#' " +
                                        "onClick=\"self.opener.document." + this.gReturnItem + ".value='" +
                                        this.format_data(vDay) +
                                        "';" + "\self.opener.document." + this.gReturnItem + ".focus();window.close();\">" +
                                this.format_day(vDay) +
                                "</A>" +
                                "</FONT></TD>";
                        vDay=vDay + 1;

                        if (vDay > vLastDay) {
                                vOnLastDay = 1;
                                break;
                        }
                }

                if (j == 6)
                        vCode = vCode + "</TR>";
                if (vOnLastDay == 1)
                        break;
        }

        for (m=1; m<(7-j); m++) {
                if (this.gYearly)
                        vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j+m) +
                        "><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'> </FONT></TD>";
                else
                        vCode = vCode + "<TD WIDTH='14%'" + this.write_weekend_string(j+m) +
                        "><FONT SIZE='2' FACE='" + fontface + "' COLOR='gray'>" + m + "</FONT></TD>";
        }

        return vCode;
}

Calendar.prototype.format_day = function(vday) {
        var vNowDay = gNow.getDate();
        var vNowMonth = gNow.getMonth();
        var vNowYear = gNow.getFullYear();

         ////////// New Block Of Code ////////////////
                	
        if(typeof(arrHolDate)=='object')
        {	
        	for(var i=0;i<arrHolDate.length;i++)
        	{
                 var vHoliday= new Date(arrHolDate[i]);
                 var vHolDay=vHoliday.getDate();
                 var vHolMonth=vHoliday.getMonth();
                 var vHolYear=vHoliday.getYear();

         	if(vday==vHolDay && this.gMonth==vHolMonth && this.gYear == vHolYear)
         	return ("<FONT COLOR=\"red\"><B>" + vday + "</B></FONT>");
         	}
         }	
        ////////////////////////////////////////////////////

        if (vday == vNowDay && this.gMonth == vNowMonth && this.gYear == vNowYear)
                return ("<FONT COLOR=\"blue\"><B>" + vday + "</B></FONT>");
		//return ("<FONT COLOR=" + todayColor + "><B>" + vday + "</B></FONT>");
        else
                return (vday);
}

Calendar.prototype.write_weekend_string = function(vday) {
        var i;

        for (i=0; i<weekend.length; i++) {
                if (vday == weekend[i])
                        return (" BGCOLOR=\"" + weekendColor + "\"");
        }

        return "";
}

Calendar.prototype.format_data = function(p_day) {
        var vData;
        var vMonth = 1 + this.gMonth;
        vMonth = (vMonth.toString().length < 2) ? "0" + vMonth : vMonth;
        var vMon = Calendar.get_month(this.gMonth).substr(0,3).toUpperCase();
        var vFMon = Calendar.get_month(this.gMonth).toUpperCase();
        var vY4 = new String(this.gYear);
        var vY2 = new String(this.gYear.substr(2,2));
        var vDD = (p_day.toString().length < 2) ? "0" + p_day : p_day;

        switch (this.gFormat) {
                case "MM\/DD\/YYYY" :
                        vData = vMonth + "\/" + vDD + "\/" + vY4;
                        break;
                case "MM\/DD\/YY" :
                        vData = vMonth + "\/" + vDD + "\/" + vY2;
                        break;
                case "MM-DD-YYYY" :
                        vData = vMonth + "-" + vDD + "-" + vY4;
                        break;
                case "MM-DD-YY" :
                        vData = vMonth + "-" + vDD + "-" + vY2;
                        break;

                case "DD\/MON\/YYYY" :
                        vData = vDD + "\/" + vMon + "\/" + vY4;
                        break;
                case "DD\/MON\/YY" :
                        vData = vDD + "\/" + vMon + "\/" + vY2;
                        break;
                case "DD-MON-YYYY" :
                        vData = vDD + "-" + vMon + "-" + vY4;
                        break;
                case "DD-MON-YY" :
                        vData = vDD + "-" + vMon + "-" + vY2;
                        break;

                case "DD\/MONTH\/YYYY" :
                        vData = vDD + "\/" + vFMon + "\/" + vY4;
                        break;
                case "DD\/MONTH\/YY" :
                        vData = vDD + "\/" + vFMon + "\/" + vY2;
                        break;
                case "DD-MONTH-YYYY" :
                        vData = vDD + "-" + vFMon + "-" + vY4;
                        break;
                case "DD-MONTH-YY" :
                        vData = vDD + "-" + vFMon + "-" + vY2;
                        break;

                case "DD\/MM\/YYYY" :
                        vData = vDD + "\/" + vMonth + "\/" + vY4;
                        break;
                case "DD\/MM\/YY" :
                        vData = vDD + "\/" + vMonth + "\/" + vY2;
                        break;
                case "DD-MM-YYYY" :
                        vData = vDD + "-" + vMonth + "-" + vY4;
                        break;
                case "DD-MM-YY" :
                        vData = vDD + "-" + vMonth + "-" + vY2;
                        break;

                default :
                        vData = vMonth + "\/" + vDD + "\/" + vY4;
        }

        return vData;
}

function Build(p_item, p_month, p_year, p_format) {

	if(p_year < 1753)	return;
        var p_WinCal = ggWinCal;
        gCal = new Calendar(p_item, p_WinCal, p_month, p_year, p_format);


        gCal.gBGColor="#EBEAEA";
        gCal.gLinkColor="black";
        gCal.gTextColor="black";
        gCal.gHeaderColor="darkgreen";


        if (gCal.gYearly)        gCal.showY();
        else        gCal.show();
}

function show_cal()
{
        p_item = arguments[0];

        if (arguments[1] == null)
                p_month = new String(gNow.getMonth());
        else
                p_month = arguments[1];
        if (arguments[2] == "" || arguments[2] == null)
                p_year = new String(gNow.getFullYear().toString());
        else
                p_year = arguments[2];
        if (arguments[3] == null)
                p_format = p_fmt;
        else
                p_format = arguments[3];

        vWinCal = window.open("", "Calendar","width=400,height=275,status=no,resizable=no,top=200,left=200");

        vWinCal.opener = self;

        ggWinCal = vWinCal;
	vWinCal.focus();

        p_item = p_fld;


        
        Build(p_item, p_month, p_year, p_format);
}

function show_yearly_calendar(p_item, p_year, p_format) {

        if (p_year == null || p_year == "")
                p_year = new String(gNow.getFullYear().toString());
        if (p_format == null || p_format == "")
                p_format = "MM/DD/YYYY";

        var vWinCal = window.open("", "Calendar", "scrollbars=no");
        vWinCal.opener = self;
        ggWinCal = vWinCal;

        Build(p_item, null, p_year, p_format);}
        

function show_calendar(fld, p_frm)
{

        if (p_frm == "103"){
        p_fmt="DD/MM/YYYY";}

        if (p_frm == "101"){
        p_fmt="MM/DD/YYYY";}

        p_fld=fld;
        var build_cal=show_cal();        
}


function checkdate(dt1,dt2,dtfrm)
{
var fdt1 = dt1;
var fdt2 = dt2;

var yr1=parseInt(fdt1.substr(6,10),10)
var yr2=parseInt(fdt2.substr(6,10),10)



if (dtfrm == "103"){
var mm1=parseInt(fdt1.substr(3,2),10)
var mm2=parseInt(fdt2.substr(3,2),10)

var dd1=parseInt(fdt1.substr(0,2),10)
var dd2=parseInt(fdt2.substr(0,2),10)
}

if (dtfrm == "101"){
var mm1=parseInt(fdt1.substr(0,2),10)
var mm2=parseInt(fdt2.substr(0,2),10)

var dd1=parseInt(fdt1.substr(3,2),10)
var dd2=parseInt(fdt2.substr(3,2),10)
}

	if (yr1 < yr2)
	{
		//alert("Year Ok");
		return true;
	}
	
	if (yr1 > yr2)
	{
		//alert("Year Not Ok");
		return false;
	}
	
	if (yr1 == yr2)
	{
		//alert("Equal Year");
    	if (mm1 > mm2)
		  {
			//alert("Month not Ok");
			return false;
		}
		if (mm1 < mm2)
		{
			//alert("Month Ok");
			return true;
		}
		if (mm1 == mm2)
		{
			//alert("Equal Month");
			if (dd1 > dd2)
			{
				//alert("Date not Ok");
				return false;
			}
				if (dd1 < dd2)
			{
				//alert("Date Ok");
				return true;
			}
			if (dd1 == dd2)
			{
				//alert("Equal Date");
				return true;
			}
		}
	}   
}




function show_time(fld,frm)
{
	popup = window.open('','timepop','width=460,height=130,top=235,left=170');
	
	popup.document.write("<html><head><title>Time");
	popup.document.write("</title>");
	
	popup.document.write("<script language=\"javascript\">");
		popup.document.write("function timeTrans(){");
		popup.document.write("frmTm ='"+frm+"';");
		popup.document.write("hour = document.time.hour.options[document.time.hour.selectedIndex].value;");
		popup.document.write("min = document.time.min.options[document.time.min.selectedIndex].value;");
		popup.document.write("sec = document.time.sec.options[document.time.sec.selectedIndex].value;");
		popup.document.write("if(frmTm == \"24\" ){opener.document."+fld+".value = hour+':'+min+':'+sec;}");
		popup.document.write("if(frmTm == \"12\" ){");
		popup.document.write("ap = document.time.ap.options[document.time.ap.selectedIndex].value;");
		popup.document.write("opener.document."+fld+".value = hour+':'+min+':'+sec+' '+ap;}");		
		popup.document.write("self.close();}");
	popup.document.write("</script>");
	
	popup.document.write("</head>");
	popup.document.write("<body bgcolor=\"#EBEAEA\" text=\"#000000\">");
	popup.document.write("<form name=\"time\">");
	popup.document.write("<table width=\"25%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\"><tr><td>");
	  popup.document.write("<table border=\"0\" cellspacing=\"10\" cellpadding=\"0\" align=\"center\">");
	    popup.document.write("<tr>");
	      popup.document.write("<td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">Hour");
		  popup.document.write("</font></td>");
	      popup.document.write("<td>");
	        popup.document.write("<select name=\"hour\">");
	          popup.document.write("<option value=\"00\">00");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"01\">01");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"02\">02");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"03\">03");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"04\">04");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"05\">05");
			  popup.document.write("</option>");
		  popup.document.write("<option value=\"06\">06");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"07\">07");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"08\">08");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"09\">09");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"10\">10");
			  popup.document.write("</option>");
			  popup.document.write("<option value=\"11\">11");
			  popup.document.write("</option>");
			  if (frm == "24"){
	          popup.document.write("<option value=\"12\">12");
			  popup.document.write("</option>");
			  popup.document.write("<option value=\"13\">13");
			  popup.document.write("</option>");
			  popup.document.write("<option value=\"14\">14");
			  popup.document.write("</option>");
			  popup.document.write("<option value=\"15\">15");
			  popup.document.write("</option>");
			  popup.document.write("<option value=\"16\">16");
			  popup.document.write("</option>");
			  popup.document.write("<option value=\"17\">17");
			  popup.document.write("</option>");
			  popup.document.write("<option value=\"18\">18");
			  popup.document.write("</option>");
			  popup.document.write("<option value=\"19\">19");
			  popup.document.write("</option>");
			  popup.document.write("<option value=\"20\">20");
			  popup.document.write("</option>");
			  popup.document.write("<option value=\"21\">21");
			  popup.document.write("</option>");
			  popup.document.write("<option value=\"22\">22");
			  popup.document.write("</option>");
			  popup.document.write("<option value=\"23\">23");
			  popup.document.write("</option>");
			  }
	        popup.document.write("</select>");
	      popup.document.write("</td>");
	      popup.document.write("<td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">Minute");
		  popup.document.write("</font></td>");
	      popup.document.write("<td>");
	        popup.document.write("<select name=\"min\">");
	          popup.document.write("<option value=\"00\">00");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"01\">01");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"02\">02");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"03\">03");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"04\">04");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"05\">05");
			  popup.document.write("</option>");
		  popup.document.write("<option value=\"06\">06");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"07\">07");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"08\">08");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"09\">09");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"10\">10");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"11\">11");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"12\">12");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"13\">13");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"14\">14");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"15\">15");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"16\">16");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"17\">17");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"18\">18");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"19\">19");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"20\">20");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"21\">21");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"22\">22");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"23\">23");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"24\">24");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"25\">25");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"26\">26");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"27\">27");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"28\">28");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"29\">29")
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"30\">30");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"31\">31");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"32\">32");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"33\">33");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"34\">34");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"35\">35");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"36\">36");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"37\">37");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"38\">38");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"39\">39");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"40\">40");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"41\">41");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"42\">42");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"43\">43");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"44\">44");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"45\">45");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"46\">46");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"47\">47");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"48\">48");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"49\">49");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"50\">50");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"51\">51");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"52\">52");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"53\">53");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"54\">54");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"55\">55");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"56\">56");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"57\">57");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"58\">58");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"59\">59");
			  popup.document.write("</option>");
	        popup.document.write("</select>");
	      popup.document.write("</td>");
	      popup.document.write("<td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">Second");
		  popup.document.write("</font></td>");
	      popup.document.write("<td>");
	        popup.document.write("<select name=\"sec\">");
	          popup.document.write("<option value=\"00\">00");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"01\">01");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"02\">02");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"03\">03");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"04\">04");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"05\">05");
			  popup.document.write("</option>");
		  popup.document.write("<option value=\"06\">06");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"07\">07");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"08\">08");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"09\">09");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"10\">10");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"11\">11");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"12\">12");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"13\">13");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"14\">14");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"15\">15");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"16\">16");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"17\">17");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"18\">18");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"19\">19");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"20\">20");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"21\">21");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"22\">22");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"23\">23");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"24\">24");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"25\">25");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"26\">26");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"27\">27");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"28\">28");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"29\">29")
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"30\">30");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"31\">31");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"32\">32");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"33\">33");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"34\">34");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"35\">35");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"36\">36");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"37\">37");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"38\">38");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"39\">39");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"40\">40");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"41\">41");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"42\">42");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"43\">43");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"44\">44");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"45\">45");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"46\">46");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"47\">47");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"48\">48");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"49\">49");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"50\">50");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"51\">51");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"52\">52");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"53\">53");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"54\">54");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"55\">55");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"56\">56");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"57\">57");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"58\">58");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"59\">59");
			  popup.document.write("</option>");
	        popup.document.write("</select>");
	      popup.document.write("</td>");
		  if (frm == "12"){
	      popup.document.write("<td><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">AM/PM");
		  popup.document.write("</font></td>");
	      popup.document.write("<td>"); 
	        popup.document.write("<select name=\"ap\">");
	          popup.document.write("<option value=\"AM\">AM");
			  popup.document.write("</option>");
	          popup.document.write("<option value=\"PM\">PM");
			  popup.document.write("</option>");
	        popup.document.write("</select>");
	      popup.document.write("</td>");
		  }
	    popup.document.write("</tr>");
	    popup.document.write("<tr>"); 
	      popup.document.write("<td colspan=\"8\">"); 
	        popup.document.write("<div align=\"center\"><br>");
	       popup.document.write("<input type=\"reset\" name=\"Reset\" value=\"Cancel\" style=\"font-size: 8pt; border-style: outset\" onClick=\"self.close()\">");
	          popup.document.write("<input type=\"button\" name=\"b1\" value=\"  Ok  \" style=\"font-size: 8pt; border-style: outset\" onClick=\"timeTrans()\">");
	        popup.document.write("</div>");
	      popup.document.write("</td>");
	    popup.document.write("</tr>");
	  popup.document.write("</table>");
	  popup.document.write("</table>");
	  popup.document.write("</form>");
	popup.document.write("</body>");
	popup.document.write("</html>");

}	


function dodate(e, obj1,dtformat) {

DOMonth  = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
LDOMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];


    if (document.all) {
        e = window.event;
    }

    var key;



    if (document.layers)
    {
        key = e.which;
    }
    if (document.all)
    {	
        key = e.keyCode;
     }	
 
   if(e.ctrlKey)
  { 	
    if((key==17)||(key==86)||(key==68)) 
     {
       return false	
      }
   }		  
 
    if(key!=9)
   	{
    if(((key<48)&&(key!=8)&&(key!=13)&&(key!=46)&&(key!=37)&&(key!=39&&(key!=16&&(key!=17))))||(key>57)&&(key<96)||(key>105))
     {
      if(obj1.value.length!="")
       {
      //e.cancelBubble = true;
      //e.returnValue = false;
       DtKUpError=true	      
       alert("Invalid entry")
       DtKUpError=false	      
      obj1.value=""  //obj1.value.substring(0,obj1.value.length-1);
      obj1.focus();
      return false;
       } 
     }	
    }

     if(obj1.value.length<10)    
	{
         if(dtformat==103)
    	   {
	      
	      if(obj1.value.substring(0,2)>31||obj1.value.substring(0,2)=='00')
	      {
 	      DtKUpError=true
	      alert("Invalid Day")
 	      DtKUpError=false
	      obj1.value=obj1.value.substring(0,0)
 	      obj1.focus();
	      return false;
	      }

	       if(obj1.value.substring(3,5)>12||obj1.value.substring(3,5)=='00')
	      {
 	      DtKUpError=true	
	      alert("Invalid month")
 	      DtKUpError=false
	      obj1.value=obj1.value.substring(0,3)
 	      obj1.focus();
	      return false;
	      }	
             
	   }	 	

         if(dtformat==101)
           {
	     if(obj1.value.substring(0,2)>12||obj1.value.substring(0,2)=='00')
	     {
 	      DtKUpError=true
    	      alert("Invalid month")
 	      DtKUpError=false
	      obj1.value=obj1.value.substring(0,0)
	  obj1.focus();
	      return false;
	     }

	      if(obj1.value.substring(3,5)>31||obj1.value.substring(3,5)=='00')
	      {
 	      DtKUpError=true
	      alert("Invalid Day")
 	      DtKUpError=false
	      obj1.value=obj1.value.substring(0,3)
	  obj1.focus();
	      return false;
	      }	

           }	 	
 	
	if((obj1.value.length==2)||(obj1.value.length==5))
         {
	  if(obj1.value.substring(obj1.value.length-1,obj1.value.length)!="/")
           {
	   obj1.value=obj1.value.toUpperCase() +"/";
	   obj1.focus();
           }
         }
    }
     else
    {
       if(obj1.value.length>10)
         {	
          DtKUpError=true
          alert("Invalid Input")
          DtKUpError=false
          obj1.value=obj1.value.substring(0,obj1.value.length-1);
	  obj1.focus();
          return false;
         }

       p_year=obj1.value.substring(obj1.value.length-4,obj1.value.length) 
       p_year=parseInt(p_year)
       
       if(p_year==0)
       {
       DtKUpError=true
       alert("Invalid year")
       DtKUpError=false
       obj1.value=obj1.value.substring(0,obj1.value.length-4);
       obj1.focus();
       return false;
       }
       if(p_year<1940)	
       {
       DtKUpError=true
       alert("System does not support year less than '1940' ");
       DtKUpError=false
       /* By Rupankar to make the value to 9 characters */
       obj1.value=obj1.value.substring(0,obj1.value.length-4);
       obj1.focus();
       return false;
       }	
	
	
       if(dtformat==103)
        {
	  dayNo=obj1.value.substring(0,2);      
	  monthNo=obj1.value.substring(3,5);
      	
        }
        else
        {
          monthNo=obj1.value.substring(0,2)
          dayNo=obj1.value.substring(3,5)
        }
 
       if ((p_year % 4) == 0) 
         {
           if ((p_year % 100) == 0 && (p_year % 400) != 0)
             {
              p_day=DOMonth[monthNo-1];
             }
           else
            {
             p_day=LDOMonth[monthNo-1];
            }
         } 
        else
         {
          p_day=DOMonth[monthNo-1];
         }


         dayNo=parseInt(dayNo)
         p_day=parseInt(p_day)


         if(dayNo>p_day&&dayNo!=0)
          {
          DtKUpError=true
          alert("Invalid date");
          DtKUpError=false
          obj1.value='';
	  obj1.focus();
          return false;
          }

     }
}

function CheckValidation1(obj1,obj2,obj3,Ctrl5,Ctrl6,Ctrl7,Ctrl8,Ctrl9,Ctrl10,Ctrl11,Ctrl12,Ctrl13,Ctrl14) 
{
    var date='';var ValMsg='';
    var flag=true;
    var Focus='';
    var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    var d1 = new Date(makedate(BC1(obj1).value));
    var d2 = new Date(makedate(BC1(obj2).value));

    var d3 = new Date();
    var one_day=1000*60*60*24

    BC1(obj3).value =  Math.ceil((d2.getTime()-d1.getTime())/(one_day))+1; 

    if(BC1(Ctrl10).value=='--please select--'){
        ValMsg+='Please Select Leave Type.\n';
        flag = false; Focus+=Ctrl10+',';
        BC1(Ctrl10).style.background = "LemonChiffon";
    }
    if(BC1(Ctrl5).value==''){
        ValMsg+='Please enter a value for Unpaid Leave, or else enter 0 for none.\n';
        flag = false; Focus+=Ctrl5+',';
        BC1(Ctrl5).style.background = "LemonChiffon";
    }

    if(BC1(Ctrl6).value==''){
        ValMsg+='Please enter Place of Travel.\n';
        flag = false; Focus+=Ctrl6+',';
        BC1(Ctrl6).style.background = "LemonChiffon";
    }

    if(BC1(Ctrl7).value==''){
        ValMsg+='Please enter Travel Address.\n';
        flag = false; Focus+=Ctrl7+',';
        BC1(Ctrl7).style.background = "LemonChiffon";
    }

    if(BC1(Ctrl8).value==''){
        ValMsg+='Please enter Contact Number.\n';
        flag = false; Focus+=Ctrl8+',';
        BC1(Ctrl8).style.background = "LemonChiffon";
    }
    if(BC1(Ctrl12).value=='--please select--'){
        ValMsg+='Please Select Passport required or not.\n';
        flag = false; Focus+=Ctrl12+',';
        BC1(Ctrl12).style.background = "LemonChiffon";
    }

    if (chkdate(BC1(obj1).value) == ''){
        ValMsg+='Please Enter Start Date.\n';
        flag = false; Focus+=obj1+',';
    }
    if (chkdate(BC1(obj1).value) == false){
        ValMsg+='Start date is invalid.\n';
        flag = false; Focus+=obj1+',';
    }
    if (chkdate(BC1(obj2).value) == ''){
        ValMsg+='Please Enter End Date.\n';
        flag = false; Focus+=obj2+',';
    }
    if (chkdate(BC1(obj2).value) == false){
        ValMsg+='End date is invalid.\n';
        flag = false; Focus+=obj2+',';
    }

    if ((d1.getFullYear()>d2.getFullYear()) || (d1.getMonth()>d2.getMonth() && d1.getFullYear()>=d2.getFullYear()) || (d1.getDate()>d2.getDate() && d1.getMonth()>=d2.getMonth() && d1.getFullYear()>=d2.getFullYear()))
    {
        ValMsg+='Leave Start Date Cannot be Greater than Leave End Date.\n';
        flag = false; Focus+=obj2+',';
        BC1(obj2).style.background = "LemonChiffon";
    }

    if(BC1(Ctrl11).value=='--please select--'){
        ValMsg+='Please Select Ticket required or not.\n';
        flag = false; Focus+=Ctrl11+',';
        BC1(Ctrl11).style.background = "LemonChiffon";
    }
    
    if(BC1(Ctrl9).value==''){
        ValMsg+='Please enter Travel Sector.\n';
        flag = false; Focus+=Ctrl9+',';
        BC1(Ctrl9).style.background = "LemonChiffon";
    }

    if(BC1(Ctrl13)!=null){
        if(BC1(Ctrl13).value==''){
            ValMsg+='Please enter HR Person Name.\n';
            flag = false; Focus+=Ctrl13+',';
            BC1(Ctrl13).style.background = "LemonChiffon";
        }
        if(BC1(Ctrl14).value==''){
            ValMsg+='Please enter HR person Email.\n';
            flag = false; Focus+=Ctrl14+',';
            BC1(Ctrl14).style.background = "LemonChiffon";
        }
        if(BC1(Ctrl14).value!=''){
            email=BC1(Ctrl14).value;
            AtPos = email.indexOf("@");
            StopPos = email.lastIndexOf(".");
            if ((AtPos == -1 || StopPos == -1) || (StopPos < AtPos) || (StopPos - AtPos == 1)) {
                ValMsg+='Please enter valid Email.';
                flag = false; Focus+=Ctrl14+',';
                BC1(Ctrl14).style.background = "LemonChiffon";
            }
        }
    }
    
    if(ValMsg.length > 0) {alert(ValMsg); BC1(Focus.split(',')[0]).focus(); return false;}        
}


function ValidatPPForm(obj1,obj2,obj3) 
{
    var date='';var ValMsg='';
    var flag=true;
    var Focus='';
    var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    var d1 = new Date(makedate(BC1(obj1).value));
    var d2 = new Date(makedate(BC1(obj2).value));
    var d3 = new Date();
    var one_day=1000*60*60*24

    if (chkdate(BC1(obj1).value) == ''){
        ValMsg+='Please Enter Start Date.\n';
        flag = false; Focus+=obj1+',';
    }
    if (chkdate(BC1(obj1).value) == false){
        ValMsg+='Start date is invalid.\n';
        flag = false; Focus+=obj1+',';
    }

    if (chkdate(BC1(obj2).value) == ''){
        ValMsg+='Please Enter Return Date.\n';
        flag = false; Focus+=obj2+',';
    }
    if (chkdate(BC1(obj2).value) == false){
        ValMsg+='Return date is invalid.\n';
        flag = false; Focus+=obj2+',';
    }

    if ((d1.getFullYear()>d2.getFullYear()) || (d1.getMonth()>d2.getMonth() && d1.getFullYear()>=d2.getFullYear()) || (d1.getDate()>d2.getDate() && d1.getMonth()>=d2.getMonth() && d1.getFullYear()>=d2.getFullYear()))
    {
        ValMsg+='Passport Request Date Cannot be Greater than Passport Return Date.\n';
        flag = false; Focus+=obj2+',';
        BC1(obj2).style.background = "LemonChiffon";
    }

    if((BC1(obj3).value=='')){
        ValMsg+='Please Enter The Reason for withdrawal.\n';
        flag = false; Focus+=obj3+',';
        BC1(obj3).style.background = "LemonChiffon";
    }
    
    if(ValMsg.length > 0) {alert(ValMsg); BC1(Focus.split(',')[0]).focus(); return false;}        
}

function BC1 (id){
 var obj = document.getElementById(id);
 return obj;
}

function datecheck(obj)
{
if(DtKUpError==false)
{ 
 if(obj.value!="")
 {
   if((parseInt(obj.value.length)<10)||(parseInt(obj.value.length)>10))
   {
     alert("Invalid date");	     
     obj.focus();
     obj.value=""
     return false	
   }
   if(obj.value.substring(2,3)!="/")
  {
    alert("Invalid date");	  
    obj.focus();
    obj.value=""
    return false	
  }
  if(obj.value.substring(5,6)!="/")
  {
   alert("Invalid date");
   obj.focus();
   obj.value=""
   return false	
  }

 }
}
}
function makedate(date)
{
    var strDay; var strMonth; var strYear; 
    if (date.length>5) {
        strDay = date.substr(0, 2);
        strMonth = date.substr(3, 2);
        strYear = date.substr(6,4);
    }
    return  strMonth + "/" + strDay + "/" + strYear;
}

function chkdate(date) {
var strDateArray; var strDay; var strMonth; var strYear; var intday; var intMonth; var intYear;
var booFound = false; var strSeparatorArray = new Array("/");
var intElementNr;var err = 0;

for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
        if (date.indexOf(strSeparatorArray[intElementNr]) != -1) {
            strDateArray = date.split(strSeparatorArray[intElementNr]);            
        booFound = true;
       }
    }
if (booFound) {
    if (date.length>5) {
        strDay = date.substr(0, 2);
        strMonth = date.substr(3, 2);
        strYear = date.substr(6,4);
   }
}
intday = parseInt(strDay, 10);
if (isNaN(intday)) {
    err = 2;
    return false;
}
intMonth = parseInt(strMonth, 10);
    if (isNaN(intMonth)) {
        if (isNaN(intMonth)) {
        err = 3;
        return false;
       }
}
intYear = parseInt(strYear, 10);
    if (isNaN(intYear)) {
        err = 4;
        return false;
    }
if (intMonth>12 || intMonth<1) {
    err = 5;
    return false;
}
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
    err = 6;
    return false;
}
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
    err = 7;
    return false;
}
if (intMonth == 2) {
    if (intday < 1) {
    err = 8;
    return false;
}
if (LeapYear(intYear) == true) {
        if (intday > 29) {
        err = 9;
    return false;
    }
}
else {
    if (intday > 28) {
            err = 10;
            return false;
        }
    }
}
return true;
}
function LeapYear(intYear) {
    if (intYear % 100 == 0) {
    if (intYear % 400 == 0) { return true; }
}
else {
    if ((intYear % 4) == 0) { return true; }
    }
return false;
}
