If you think the Code involves infringement, please let me know and I will delete it immediately:
There are two files: calendar.htm and calendar. js.
This is the code for calendar. JS:
Document. write ('<IFRAME id = calframe name = calframe frameborder = 0 src = script/calendar/calendar.htm style = display: none; position: absolute; Z-index: 100> </iframe> ');
Document. onclick = hidecalendar;
Function showcalendar (simg, bopenbound, sfld1, snextp, snextd, sstartd, sendd, SVD, Soe, svde, sot, s3f, sfld2, scallback, snextvde)
{
// 1. Name of the control in the pop-up position of the simg calendar,
// 2. bopenbound,
// 3. sfld1 get the control name of the date,
// 4. snextp specifies the name of the control in the pop-up position of the new calendar after the date is selected. Do not enter the name,
// 5. After snextd selects a date, the control name of the value is displayed in the new calendar. Do not enter the name,
// 6. Start Time of sstartd,
// 7. sendd as of the effective time,
// 8. The week of SVD is valid, for example, '1, 3, 5'. enter '0' on Sunday'
// 9.soe, valid for a single pair of days, '0' indicates a pair of days, And '1' indicates a single day
// 10. svde special date, for example, '1970-10-11,2004-11-20, '. You must enter ','
// 11. If the Sot is directly in the text box, click 'text ',
// 12. The next calendar pops up in s3f. After selecting it, click "get date" and locate the new control.
// Sfld2. The default calendar date is displayed.
// Scallback
// The effective time of the next snextvde focus.
VaR fld1, fld2;
VaR cf = Document. getelementbyid ("calframe ");
VaR WCF = Window. frames. calframe;
VaR oimg = Document. getelementbyid (simg );
If (! Oimg) {alert ("the control object does not exist! "); Return ;}
If (! Sfld1) {alert ("the input control is not specified! "); Return ;}
Fld1 = Document. getelementbyid (sfld1 );
If (! Fld1) {alert ("the input control does not exist! "); Return ;}
If (fld1.tagname! = "Input" | fld1.type! = "Text") {alert ("the input control type is incorrect! "); Return ;}
If (sfld2)
{
Fld2 = Document. getelementbyid (sfld2 );
If (! Fld2) {alert ("the reference control does not exist! "); Return ;}
If (fld2.tagname! = "Input" | (fld2.type! = "Text" & fld2.type! = "Hidden") {alert ("reference control type error! "); Return ;}
}
If (! WCF. bcalloaded) {alert ("calendar is not loaded successfully! Please refresh the page! "); Return ;}
WCF. n_position = snextp;
WCF. n_textdate = snextd;
WCF. startdate = sstartd;
WCF. enddate = sendd;
WCF. vailidday = SVD;
WCF. oddeven = SOE;
WCF. vailiddate = svde;
WCF. nextvailiddate = snextvde;
WCF. objecttype = sot;
WCF. thirdfocus = s3f;
If (Cf. style. Display = "Block") {Cf. style. Display = "NONE"; return ;}
VaR ET = 0, El = 0, P = oimg;
VaR ST = Document. Body. scrolltop, SL = Document. Body. scrollleft;
VaR Eh = oimg. Height, ew = oimg. width;
While (P & P. tagname! = "Body") {et + = P. offsettop; El + = P. offsetleft; P = P. offsetparent ;}
If (SOT = "text ")
{
Cf. style. Top = + (document. Body. clientheight-(ET-St)-Eh> = Cf. Height )? ET + EH + 20: eT-cf.height;
}
Else
{
Cf. style. Top = (document. Body. clientheight-(ET-St)-Eh> = Cf. Height )? ET + eh: eT-cf.height;
}
Cf. style. Left = (document. Body. clientwidth-(El-SL)> = Cf. width )? El: El + eW-cf.width;
Cf. style. Display = "Block ";
WCF. openbound = bopenbound;
WCF. fld1 = fld1;
WCF. fld2 = fld2;
WCF. Callback = scallback;
WCF. initcalendar ();
}
Function hidecalendar ()
{
VaR cf = Document. getelementbyid ("calframe ");
Cf. style. Display = "NONE ";
}
This is the source code of calendar.htm:
<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en">
<! -- Saved from url = (0056) http://www.elong.com/hotels/Script/calendar/calendar.htm -->
<HTML> <Meta http-equiv = Content-Type content = "text/html; charset = gb2312">
<Style type = text/CSS> TD {
Font-size: 12px; font-family: Arial; text-align: Center
}
TD. dt {
Font-size: 11px; font-family: Arial; text-align: Center
}
A {
Color: Blue
}
A: hover {
Color: red
}
A. BT {
Color: #888888.
}
</Style>
<Script language = JavaScript>
<! --//
VaR STR = '', I, j, YY, mm, openbound, callback;
VaR fld1, fld2;
VaR Wp = Window. parent;
VaR cf1_wp.doc ument. getelementbyid ("calframe ");
VaR week, curday, SD, Ed, today = new date ();
VaR n_position, n_textdate, startdate, enddate, vailidday, oddeven, vailiddate, nextvailiddate, objecttype, mmm, DDD, thirdfocus;
Mmm = "";
Today. sethours (0); today. setminutes (0); today. setseconds (0); today. setmilliseconds (0 );
// Var lastyear = today. getyear (), lastmonth = today. getmonth ();
Function parsedate (s) // resolution date
{
VaR Reg = new Regexp ("[^ 0-9-]", "")
If (S. Search (REG)> = 0) return today;
VaR Ss = S. Split ("-");
If (ss. length! = 3) return today;
If (isnan (ss [0]) | isnan (ss [1]) | isnan (ss [2]) return today;
Return new date (parsefloat (ss [0]), parsefloat (ss [1])-1, parsefloat (ss [2]);
}
Function resizecalendar () {Cf. width = 144; Cf. Height = 192;} // set the calendar width and height.
Function initcalendar () // Initialization
{
Curday = today;
If (fld1 & fld1.value. length> 0) {curday = parsedate (fld1.value );}
If (fld2 & fld2.value. length> 0) {curday = parsedate (fld2.value );}
If (! Startdate = "") {SD = parsedate (startdate )}
If (! Enddate = "") {ed = parsedate (enddate )}
// Window. Alert (startdate );
// Window. Alert (enddate );
Drawcalendar (curday. getfullyear (), curday. getmonth ());
}
Function drawcalendar (Y, m) // draws a calendar
{
VaR x = new date (Y, M, 1), MV = x. getday (), D = x. getdate (), de;
YY = x. getfullyear (); Mm = x. getmonth ();
Document. getelementbyid ("yyyymm"). innerhtml = YY + "." + (mm + 1> 9? Mm + 1: "0" + (mm + 1 ));
// Clear the calendar
For (VAR I = 1; I <= mV; I ++)
{
De = Document. getelementbyid ("D" + I );
De. innerhtml = "";
De. bgcolor = "";
}
// Draw a calendar
While (X. getmonth () = mm)
{
De = Document. getelementbyid ("D" + (D + mV ));
If (X. gettime () = curday. gettime ())
De. bgcolor = "# dddddd ";
Else
De. bgcolor = "# def1f8 ";
If (X. gettime () = today. gettime ())
{
// Window. Alert (1 );
If (ifdraw (x ))
{
De. innerhtml = "<a href = javascript: setdate (" + D + ");> <font color = Red>" + D + "</font> </a> ";
}
Else
{
De. innerhtml = "<a href = javascript: setdate (" + D + ");> </a> ";
// De. innerhtml = " ";
// De. innerhtml = "<a href = javascript: setdate (" + D + ");> <font color = # ff0000> x </font> </a> ";
}
}
Else if (X. gettime () <today. gettime ())
{
// Window. Alert (2 );
If (ifdraw (x ))
{
If (openbound) {de. innerhtml = "<a href = javascript: setdate (" + D + "); Class = BT>" + D + "</a> ";}
Else {de. innerhtml = "<font color = #888888>" + D + "</font> ";}
}
Else
{
De. innerhtml = "<a href = javascript: setdate (" + D + ");> </a> ";
// De. innerhtml = " ";
// De. innerhtml = "<a href = javascript: setdate (" + D + ");> <font color = # ff0000> x </font> </a> ";
}
}
Else
{
// Window. Alert (3 );
If (ifdraw (x ))
{
De. innerhtml = "<a href = javascript: setdate (" + D + ");>" + D + "</a> ";
}
Else
{
De. innerhtml = "<a href = javascript: setdate (" + D + ");> </a> ";
// De. innerhtml = " ";
// De. innerhtml = "<a href = javascript: setdate (" + D + ");> <font color = # ff0000> x </font> </a> ";
}
}
X. setdate (++ D );
}
While (D + MV <= 42)
{
De = Document. getelementbyid ("D" + (D + mV ));
De. innerhtml = "";
De. bgcolor = "";
D ++;
}
}
Function ifdraw (xd)
{
If (! Startdate = ""&&! Enddate = "")
{
If (XD. gettime ()> = SD. gettime () & XD. gettime () <= ed. gettime ())
{
If (returnoe (xd) & returnvd (xd) & returnvde (xd ))
{
Return true
}
Else
{
Return false
}
}
Else
{
Return false;
}
}
Else
{
If (returnoe (xd) & returnvd (xd) & returnvde (xd ))
{
Return true
}
Else
{
Return false
}
}
}
Function returnoe (xd)
{
If (! Oddeven = "")
{
If (oddeven = "0 ")
{
If (XD. getdate () % 2 = 0)
{
Return true;
}
Else
{
Return false;
}
}
Else
{
If (! (XD. getdate () % 2 = 0 ))
{
Return true;
}
Else
{
Return false;
}
}
}
Else
{
Return true;
}
}
Function returnvd (xd)
{
If (! Vailidday = "")
{
If (vailidday. indexof (XD. getday (). tostring ()> = 0)
{
Return true;
}
Else
{
Return false;
}
}
Else
{
Return true;
}
}
Function returnvde (xd)
{
If (! Vailiddate = "")
{
If (vailiddate. indexof (XD. getyear (). tostring () + "-" + (XD. getmonth () + 1 ). tostring () + "-" + XD. getdate (). tostring () + ",")> = 0)
{
Return true;
}
Else
{
Return false;
}
}
Else
{
Return true;
}
}
Function setdate (d) // set the date
{
WP. hidecalendar ();
/*
If (Mm. tostring (). Length = 1)
{
Mmm = "0" + (mm + 1). tostring ();
}
Else
{
Mmm = mm + 1;
}
If (D. tostring (). Length = 1)
{
Ddd = "0" + D. tostring ();
}
Else
{
Ddd = D;
}
VaR dstr = YY + "-" + (MMM) + "-" + DDD;
*/
Mmm = mm + 1;
VaR dstr = YY + "-" + (MMM) + "-" + D;
If (callback & callback. length> 0) {eval ("WP." + callback + "(/" "+ dstr + "/")");}
Else {fld1.value = dstr ;}
If (! N_position = ""&&! N_textdate = "")
{
// Wp.doc ument. getelementbyid (n_textdate). value = "";
WP. showcalendar (n_position, false, n_textdate, '','', startdate, enddate, vailidday, oddeven, nextvailiddate, objecttype, thirdfocus, fld1.id, true );
}
Else
{
If (! Thirdfocus = "")
{
Otd1_wp.doc ument. getelementbyid (thirdfocus );
OTD. Focus ();
}
}
// Hidecalendar ();
}
// -->
</SCRIPT>
<Meta content = "mshtml 6.00.2900.2668" name = generator> <Body bgcolor = white leftmargin = 0 topmargin = 0 onload = resizecalendar ();
Marginheight = "0" marginwidth = "0">
<Table id = tbl0 cellspacing = 0 cellpadding = 1 bgcolor = #7db6c7 border = 0>
<Tbody>
<Tr>
<TD>
<Table cellspacing = 1 cellpadding = 2 width = "100%" bgcolor = white border = 0>
<Tbody>
<Tr bgcolor = #7db6c7>
<TD id = Prev width = 16> <
Href = "javascript: drawcalendar (YY, mm-1);"> Src = "./icon/prev.gif" width = 16 border = 0> </a> </TD>
<TD id = yyyymm style = "font-size: 12px; color: White" width = "99%"> </TD>
<TD id = next width = 16> <
Href = "javascript: drawcalendar (YY, mm + 1);"> Src = "./icon/next.gif" width = 16
Border = 0> </a> </TD> </tr> </tbody> </table>
<Table cellspacing = 0 cellpadding = 0 width = 142 bgcolor = # def1f8 border = 0>
<Tbody>
<Tr bgcolor = # ffffff Height = 18>
<TD width = 18 bgcolor = # ffffff> day </TD>
<TD width = 18 bgcolor = # ffffff> 1 </TD>
<TD width = 18 bgcolor = # ffffff> 2 </TD>
<TD width = 18 bgcolor = # ffffff> 3 </TD>
<TD width = 18 bgcolor = # ffffff> 4 </TD>
<TD width = 18 bgcolor = # ffffff> 5 </TD>
<TD width = 18 bgcolor = # ffffff> 6 </TD> </tr>
<Tr Height = 1>
<TD bgcolor = # def1f8 colspan = 7> </TD> </tr>
<Script language = JavaScript>
<! --//
For (I = 0; I <6; I ++)
{
STR + = "<tr Height = 18> ";
For (j = 1; j <= 7; j ++) STR + = "<TD id = D" + (I * 7 + J) + "bgcolor = '# def1f8'> </TD> ";
STR + = "</tr> ";
}
Document. Write (STR );
// -->
</SCRIPT>
<Tr Height = 18>
<TD bgcolor = # def1f8 colspan = 7> & nbsp; </TD> </tr>
<Tr bgcolor = #7db6c7 Height = 20>
<TD colspan = 7> <
Style = "font-size: 12px; color: White; text-Decoration: none"
Href = "javascript: WP. hidecalendar (); "> close the window </a> </TD> </tr> </tbody> </table>
<Script language = JavaScript>
<! --//
VaR bcalloaded = true;
// -->
</SCRIPT>
</Body>