function dateselect(vname)
{
//alert("in to script");
today = new Date();
thismonth = today.getMonth()+1;
thisyear = today.getYear();
if (thisyear < 999 )
    thisyear = today.getYear()+1900;
thisday = today.getDate();
days=vname + "days"
months=vname + "months"
years=vname + "years"

//Display days

document.write(" <select name=");
document.write(days);
document.write("size=1>");
for (var theday = 1; theday <= 31; theday++) {
var theday = "" + theday;
if (theday.length == 1) {
theday = "0" + theday;
}
document.write("<option");
if (theday == thisday) document.write(" selected");
document.write(">");
document.write(theday);
}
document.write("</select>");

//display month

document.write(" <select name=");
document.write(months);
document.write(" size=1>");
for (var themn = 1; themn <= 12; themn++) {
var themn = "" + themn;
if (themn.length == 1) {
themn = "0" + themn;
}
document.write("<option");
if (themn == thismonth) document.write(" selected");
document.write(">");
document.write(themn);
}
document.write("</select>");


//display last five year

document.write(" <select name=");
document.write(years);
document.write(" size=1>");
for (var theyr = 0; theyr <= 5; theyr++) {
var theyr = "" + theyr;
if (theyr.length == 1) {
theyr = "0" + theyr;
}
document.write("<option");
if (theyr == thisyear) document.write(" selected");
document.write(">");
//alert(thisyear-theyr);
document.write(thisyear-theyr);
}
document.write("</select>");
}


//same as above but display future year also
function dateselect2(vname,addyear,lessyear)
{
    today = new Date();
    thismonth = today.getMonth()+1;
    thisyear = today.getYear();
    if (thisyear < 999 )
        thisyear = today.getYear()+1900;
    thisday = today.getDate();
    maxyear=thisyear + addyear;
    minyear=thisyear - lessyear;
    days=vname + "days";
    months=vname + "months";
    years=vname + "years";

    //Display days

    document.write(" <select name=");
    document.write(days);
    document.write(" size=1>");
    for (var theday = 1; theday <= 31; theday++) {
        var theday = "" + theday;
        if (theday.length == 1) {
            theday = "0" + theday;
        }
        document.write("<option value='" + theday + "' ");
        if (theday == thisday) document.write(" selected");
        document.write(">");
        document.write(theday);
    }
    document.write("</select>");

    //display month

    document.write(" <select name=");
    document.write(months);
    document.write(" size=1>");
    for (var themn = 1; themn <= 12; themn++) {
        var themn = "" + themn;
        if (themn.length == 1) {
            themn = "0" + themn;
        }
        document.write("<option value='" + themn + "' ");
        if (themn == thismonth) document.write(" selected");
        document.write(">");
        document.write(themn);
    }
    document.write("</select>");


    //display last five year

    document.write(" <select name=");
    document.write(years);
    document.write(" size=1>");
    for (var theyr = minyear; theyr <= maxyear; theyr++) {
        document.write("<option value='" + theyr + "' ");
        if (theyr == thisyear) document.write(" selected");
        document.write(">");
        document.write(theyr);
    }
    document.write("</select>");

}    //end of function

//SAME AS ABOVE BUT WITH SPECIFIC DATE SELECTED
function dateselect(vname,fdays,fmonths,fyears)
{
today = new Date();
/*thismonth = today.getMonth()+1;
thisyear = today.getYear();
thisday = today.getDate();
*/
if(fmonths)
    thismonth = fmonths;
else
    thismonth = today.getMonth()+1;
if(fyears)
    thisyear = fyears;
else{
    thisyear = today.getYear();
    if (thisyear < 999 )
        thisyear = today.getYear()+1900;
}
if(fdays)
    thisday = fdays;
else
    thisday = today.getDate();

days=vname + "days"
months=vname + "months"
years=vname + "years"

//Display days

document.write(" <select name=");
document.write(days);
document.write(" size=1>");
for (var theday = 1; theday <= 31; theday++) {
var theday = "" + theday;
if (theday.length == 1) {
theday = "0" + theday;
}
document.write("<option value="+theday);
if (theday == thisday) document.write(" selected");
document.write(">");
document.write(theday);
}
document.write("</select>");

//display month

document.write(" <select name=");
document.write(months);
document.write(" size=1>");
for (var themn = 1; themn <= 12; themn++) {
var themn = "" + themn;
if (themn.length == 1) {
themn = "0" + themn;
}
document.write("<option value="+themn);
if (themn == thismonth) document.write(" selected");
document.write(">");
document.write(themn);
}
document.write("</select>");


//display last five year

document.write(" <select name=");
document.write(years);
document.write(" size=1>");
var countyear=Number(thisyear)+20;
for (var theyr = 40; theyr >= 0; theyr--){
document.write("<option value="+(countyear-theyr));
if ((countyear-theyr) == thisyear) document.write(" selected");
document.write(">");
document.write(countyear-theyr);
}
document.write("</select>");
}
/*
THIS CHECKS TWO DATE TO AND RETURN TRUE IF FIRST DATE IS SMALL THEN SECOND DATE
ACCEPT THREE PARAMETERS
frm= FORM OBJECT
FIRST CHARECTOR OF FIRST  DATE
FIRST CHARECTOR OF SECONDATE 
*/
function date_compare(frm,startdt,enddt)
{
    var firstdt = new Date(frm.elements[startdt+"years"].value,frm.elements[startdt+"months"].value,frm.elements[startdt+"days"].value);
    var seconddt = new Date(frm.elements[enddt+"years"].value,frm.elements[enddt+"months"].value,frm.elements[enddt+"days"].value);
       
	   return (firstdt<=seconddt);
       
}
function date_compare_new(frm,startdt,enddt)
{
    
    var firstdt = new Date(frm.elements[startdt+"years"].value,frm.elements[startdt+"months"].value,frm.elements[startdt+"days"].value);
    var seconddt = new Date(frm.elements[enddt+"years"].value,frm.elements[enddt+"months"].value,frm.elements[enddt+"days"].value);
    return (seconddt<firstdt);
       
}
function date_compare_new1(frm,startdt,enddt)
{
    
    var firstdt = new Date(frm.elements[startdt+"years"].value,frm.elements[startdt+"months"].value,frm.elements[startdt+"days"].value);
    var seconddt = new Date(frm.elements[enddt+"years"].value,frm.elements[enddt+"months"].value,frm.elements[enddt+"days"].value);
	   
	return (seconddt<=firstdt);
       
}



function isLeapYear(yy)
{
    if( (( yy%100 != 0) && (yy % 4 ==0)) || (yy%400 == 0) )
        return 29;
    else
        return 28;    
}

function sipdateselect(vname)
{

today = new Date();
thismonth = today.getMonth()+1;
thisyear = today.getYear();
if (thisyear < 999 )
    thisyear = today.getYear()+1900;
thisday = today.getDate();
//days=vname + "days"
months=vname + "months"
years=vname + "years"

//display month

document.write(" <select name=");
document.write(months);
document.write(" size=1>");
for (var themn = 1; themn <= 12; themn++) {
var themn = "" + themn;
if (themn.length == 1) {
themn = "0" + themn;
}
document.write("<option");
if (themn == thismonth) document.write(" selected");
document.write(">");
document.write(themn);
}
document.write("</select>");


//display last five year

document.write(" <select name=");
document.write(years);
document.write(" size=1>");
for (var theyr = 0; theyr <= 18; theyr++) {
var theyr = "" + theyr;
if (theyr.length == 1) {
theyr = "0" + theyr;
}
document.write("<option");
if (theyr == thisyear) document.write(" selected");
document.write(">");
document.write(thisyear-theyr);
}
document.write("</select>");
}


