|
<script>
var myC_x, myC_y; var myC_timeset = null, myC_timeset1 = null; var divObj = null; var inputName;
function myCalendar () // Build the object
{
var myDate = new Date (); this.year = myDate.getFullYear (); this.month = myDate.getMonth () + 1; this.date = myDate.getDate (); this.format = "yyyy-mm-dd "; this.style = myStyle (1); this.show = createCalendar; this.input = createInput;
}
function myStyle (num) // Set the style
{
if (! num || isNaN (num)) {alert ('The parameter is incorrect, use the default style!'); num = 1;}
Var style = new Array ();
style [1] = ". week {background-color: #DfDfff; font-size: 12px; width: 140px;}"
+ ". ds {width: 140px; font-size: 12px; cursor: hand}"
+ ". mover {border: 1px solid black; background-color: # f4f4f4;}"
+ ". move1 {border: 1px solid # 5d5d5d; background-color: # f4f4f4; color: # 909eff; font-size: 12px}"
+ ". tit {background-color: # 909EFF; width: 140px; font-size: 12px; color: white; cursor: default}"
+ ". cs {position: absolute; border: 1px solid # 909eff; width: 142px; left: 0px; top: 0px; z-index: 9999;}"
+ ". shadow {position: absolute; left: 0px; top: 0px; font-family: Arial Black; font-size: 50px; color: # d4d4d4; z-index: 1; text-align: center;}";
document.write ("<style type = 'text / css'>");
document.write (style [num]);
document.write ("</ style>");
}
function createCalendar ()
{
var week = new Array ('day', 'one', 'two', 'three', 'four', 'five', 'six');
document.write ("<div class = 'cs' onselectstart =' return false 'oncontextmenu =' return false 'onmousedown =' if (event.button == 2) this.style.display =\" none\"'id =' myC_div '> <div class =' shadow '> </ div> <div style =' position: absolute; left: 0px; top: 0px; z-index: 1 '> ");
// Create the head
document.write ("<table class = 'tit' id = 'myC_Top' onmousedown = 'myC_x = event.x-parentNode.parentNode.style.pixelLeft; myC_y = event.y-parentNode.parentNode.style.pixelTop; setCapture ( ) 'onmouseup =' releaseCapture (); 'onmousemove =' myCMove (this.parentElement.parentElement); '> <tr> <td width = 10 onmouseover =' this.style.color =\"black\" 'onmouseout =' this .style.color =\"\" 'onclick =' cutYear () 'style =' font-family: Webdings; cursor: hand; 'title =' Decrease Year '> 7 </ td> <td title =' Decrease Month 'onmouseover =' this.style.color =\"black\" 'onclick =' cutMonth () 'onmouseout =' this.style.color =\"\" 'width = 10 style =' font-family: Webdings; cursor: hand; '> 3 </ td> <td align = center onmouseover = this.className =' move1 '; onmouseout = this.className =' '; divHidden (myC.parentElement.nextSibling); onclick =' createyear ("+ this .year + ", this); divShow (myC.parentElement.nextSibling); '> </ td> <td align = center onclick =' createmonth (" + this.month + ", this); divShow (myC.parentElement.nextSibling) 'onmouseover = this.className =' move1 '; onm ouseout = this.className = ``; divHidden (myC.parentElement.nextSibling);> </ td> <td width = 10 onmouseover = 'this.style.color =\"black\"' onmouseout = 'this.style.color =\"\" 'onclick =' addMonth () 'style =' font-family: Webdings; cursor: hand; 'title =' Add Month '> 4 </ td> <td width = 10 style =' font-family : Webdings; cursor: hand; 'onmouseover =' this.style.color =\"black\" 'onmouseout =' this.style.color =\"\" 'onclick =' addYear () 'title =' Add Year '> 8 </ td> </ tr> </ table> ");
// Create week entry
document.write ("<table class = 'week'> <tr>");
for (i = 0; i <7; i ++)
document.write ("<td align = center>" + week [i] + "</ td>");
document.write ("</ tr> </ table>");
// create date entry
document.write ("<table class = 'ds' id = 'myC' cellspacing = 2 cellpadding = 0>");
for (i = 0; i <6; i ++)
{
document.write ("<tr>");
for (j = 0; j <7; j ++)
document.write ("<td width = 10% height = 16 align = center onmouseover = 'mOver (this)' onmouseout = 'mOut (this)' onclick = 'if (this.innerText! =\"\") getValue ( inputName, this.innerText); myC_div.style.display =\"none\" '> </ td> ");
document.write ("</ tr>");
}
document.write ("</ table>");
// Build watermark
document.write ("</ div>");
// Create selection layer
document.write ("<div style = 'position: absolute; left: 0px; top: 0px; z-index: 3' onmouseover = divShow (this) onmouseout = divHidden (this)> </ div>");
document.write ("</ div>");
// Display the date
showDate (this.year, this.month);
myC_div.style.display = 'none';
}
function getValue (obj, value)
{
eval (obj) .value = parseInt (myC_Top.cells [2] .innerText) + "-" + parseInt (myC_Top.cells [3] .innerText) + "-" + value;
}
function showDate (year, month)
{
var myDate = new Date (year, month-1,1);
var today = new Date ();
var day = myDate.getDay ();
var length = new Array (31,30,31,30,31,30,31,31,30,31,30,31);
length [1] = ((year% 4 == 0)&&(year% 100! = 0) || (year% 400 == 0))? 29:28;
for (i = 0; i <myC.cells.length; i ++) myC.cells [i] .innerHTML = "";
for (i = 0; i <length [month-1]; i ++)
{
myC.cells [i + day] .innerHTML = (i + 1);
if (new Date (year, month-1, i + 1) .getDay () == 6 | new Date (year, month-1, i + 1) .getDay () == 0) {myC.cells [ i + day] .style.color = 'red';}
}
myC_Top.cells [2] .innerText = year + "year";
myC_Top.cells [3] .innerText = month + "month";
with (myC.parentNode.previousSibling.style)
{
pixelLeft = myC.offsetLeft;
pixelTop = myC.offsetTop;
height = myC.clientHeight;
width = myC.clientWidth;
}
myC.parentElement.parentElement.style.height = myC.parentElement.offsetHeight;
myC.parentElement.previousSibling.innerHTML = year;
} |
|