/**
*������ѡ��ؼ���tiannet����ǰ�˾������ƶ��á��ִ�������meizz�������ؼ���
*tiannet�����ʱ��ѡ���ܡ�select,object��ǩ���ع��ܣ���������с���ܡ�
*ʹ�÷�����
* (1)ֻѡ������
* (2)ѡ�����ں�сʱ
* (3)ѡ�����ں�сʱ������
*���ò����ķ���
* (1)�������ڷָ�� setdatesplit(strsplit);ĭ��ϊ"-"
* (2)����������ʱ��֮��ķָ�� setdatetimesplit(strsplit);ĭ��ϊ" "
* (3)����ʱ��ָ�� settimesplit(strsplit);ĭ��ϊ":"
* (4)����(1),(2),(3)�еķָ�� setsplit(strdatesplit,strdatetimesplit,strtimesplit);
* (5)���ÿ�ʼ�ͽ������ setyearperiod(intdatebeg,intdateend)
*˵����
* ĭ�ϸ��ص�����ʱ���ʽ��ͬ��2005-02-02 08:08
*/
//------------------ ��ʽ���� ---------------------------//
//���ܰ�ťͬ����ʽ
var s_tiannet_turn_base = "height:16px;font-size:9pt;color:white;border:0 solid #cccccc;cursor:hand;background-color:#2650a6;";
//���ꡢ�µȵi�ť
var s_tiannet_turn = "width:28px;" + s_tiannet_turn_base;
//�رա���յȱ�ť��ʽ
var s_tiannet_turn2 = "width:22px;" + s_tiannet_turn_base;
//��ѡ��������
var s_tiannet_select = "width:64px;display:none;";
//�¡�ʱ����ѡ��������
var s_tiannet_select2 = "width:46px;display:none;";
//����ѡ��ؼ������ʽ
var s_tiannet_body = "width:150;background-color:#2650a6;display:none;z-index:9998;position:absolute;" +
"border-left:1 solid #cccccc;border-top:1 solid #cccccc;border-right:1 solid #999999;border-bottom:1 solid #999999;";
//��ʾ�յ�td����ʽ
var s_tiannet_day = "width:21px;height:20px;background-color:#d8f0fc;font-size:10pt;";
//������ʽ
var s_tiannet_font = "color:#ffcc00;font-size:9pt;cursor:hand;";
//���ӵ���ʽ
var s_tiannet_link = "text-decoration:none;font-size:9pt;color:#2650a6;";
//����
var s_tiannet_line = "border-bottom:1 solid #6699cc";
//------------------ �������� ---------------------------//
var tiannetyearst = 1950;//��ѡ��ŀ�ʼ���
var tiannetyearend = 2010;//��ѡ��ľ������
var tiannetdatenow = new date();
var tiannetyear = tiannetdatenow.getfullyear(); //������ı����ij�ʼֵ
var tiannetmonth = tiannetdatenow.getmonth()+1; //�����µı����ij�ʼֵ
var tiannetday = tiannetdatenow.getdate();
var tiannethour = tiannetdatenow.gethours();//tiannetdatenow.gethours();
var tiannetminute = tiannetdatenow.getminutes();
var tiannetarrday=new array(42); //����д���ڵ�����
var tiannetdatesplit = "-"; //���ڵķָ����
var tiannetdatetimesplit = " "; //������ʱ��֮��ķָ��
var tiannettimesplit = ":"; //ʱ��ķָ����
var tiannetoutobject; //��������ʱ��ķ���
var arrtiannethide = new array();//��ǿ�����صı�ǩ
var m_bolshowhour = false;//�ƿ���ʾсʱ
var m_bolshowminute = false;//�ƿ���ʾ����
var m_amonhead = new array(12); //����������ÿ���µ��������
m_amonhead[0] = 31; m_amonhead[1] = 28; m_amonhead[2] = 31; m_amonhead[3] = 30; m_amonhead[4] = 31; m_amonhead[5] = 30;
m_amonhead[6] = 31; m_amonhead[7] = 31; m_amonhead[8] = 30; m_amonhead[9] = 31; m_amonhead[10] = 30; m_amonhead[11] = 31;
// ---------------------- �û��ɵ��õĺ��� -----------------------------//
//�û�����������ֻѡ������
function setday(obj){
tiannetoutobject = obj;
//�����ǩ����ֵ�������ڳ�ʼ��ϊ��ǰֵ
var strvalue = tiannettrim(tiannetoutobject.value);
if( strvalue != "" ){
tiannetinitdate(strvalue);
}
tiannetpopcalendar();
}
//�û�����������ѡ�����ں�сʱ
function setdayh(obj){
tiannetoutobject = obj;
m_bolshowhour = true;
//�����ǩ����ֵ�������ں�сʱ��ʼ��ϊ��ǰֵ
var strvalue = tiannettrim(tiannetoutobject.value);
if( strvalue != "" ){
tiannetinitdate(strvalue.substring(0,10));
var hour = strvalue.substring(11,13);
if( hour < 10 ) tiannethour = hour.substring(1,2);
}
tiannetpopcalendar();
}
//�û�����������ѡ�����ں�сʱ������
function setdayhm(obj){
tiannetoutobject = obj;
m_bolshowhour = true;
m_bolshowminute = true;
//�����ǩ����ֵ�������ں�сʱ�����ӳ�ʼ��ϊ��ǰֵ
var strvalue = "";
if( strvalue != "" ){
tiannetinitdate(strvalue.substring(0,10));
var time = strvalue.substring(11,16);
var arr = time.split(tiannettimesplit);
tiannethour = arr[0];
tiannetminute = arr[1];
if( tiannethour < 10 ) tiannethour = tiannethour.substring(1,2);
if( tiannetminute < 10 ) tiannetminute = tiannetminute.substring(1,2);
}
tiannetpopcalendar();
}
//���ÿ�ʼ���ںͽ�������
function setyearperiod(intdatebeg,intdateend){
tiannetyearst = intdatebeg;
tiannetyearend = intdateend;
}
//�������ڷָ����ĭ��ϊ"-"
function setdatesplit(strdatesplit){
tiannetdatesplit = strdatesplit;
}
//����������ʱ��֮��ķָ����ĭ��ϊ" "
function setdatetimesplit(strdatetimesplit){
tiannetdatetimesplit = strdatetimesplit;
}
//����ʱ��ָ����ĭ��ϊ":"
function settimesplit(strtimesplit){
tiannettimesplit = strtimesplit;
}
//���÷ָ��
function setsplit(strdatesplit,strdatetimesplit,strtimesplit){
tiannetdatesplit(strdatesplit);
tiannetdatetimesplit(strdatetimesplit);
tiannettimesplit(strtimesplit);
}
//����ĭ�ϵ����ڡ���ʽϊ��yyyy-mm-dd
function setdefaultdate(strdate){
tiannetyear = strdate.substring(0,4);
tiannetmonth = strdate.substring(5,7);
tiannetday = strdate.substring(8,10);
}
//����ĭ�ϵ�ʱ�䡣��ʽϊ��hh24:mi
function setdefaulttime(strtime){
tiannethour = strtime.substring(0,2);
tiannetminute = strtime.substring(3,5);
}
// ---------------------- end �û��ɵ��õĺ��� -----------------------------//
//------------------ begin ҳ����ʾ���� ---------------------------//
var weekname = new array("��","һ","��","��","��","��","��");
document.write('
');
document.write('
');
document.write(' ��');
document.write('');
document.write(' ��');
document.write('');
//document.write('
');
//document.write('
');
document.write(' ʱ');
document.write('');
document.write(' ��');
document.write('');
document.write('
');
//���һ������
document.write('
');
document.write('
');
document.write('');
document.write(' ');
document.write('');
document.write('');
document.write('
');
//���һ������
document.write('
');
document.write('
');
document.write(' ');
for(var i =0;i < weekname.length;i ++){
//�������
document.write('' + weekname[i] + ' | ');
}
document.write('
');
document.write('
');
//������ѡ��
document.write('
');
var n = 0;
for (var i=0;i<5;i++) {
document.write (' ');
for (var j=0;j<7;j++){
document.write(' | ');
n ++;
}
document.write ('
');
}
document.write (' ');
document.write(' | ');
document.write(' | ');
document.write('���'+
' �ر�' +
' ȷ�� ' +
' | ');
document.write ('
');
document.write('
');
document.write('
');
//------------------ end ҳ����ʾ���� ---------------------------//
//------------------ ��ʾ����ʱ���span��ǩ��ӧ�¼� ---------------------------//
//�������span��ǩ��ӧ
function spanyearcevent(){
hideelementsbyid(new array("seltianyear","tiannetmonthhead"),false);
if(m_bolshowhour) hideelementsbyid(new array("tiannethourhead"),false);
if(m_bolshowminute) hideelementsbyid(new array("tiannetminutehead"),false);
hideelementsbyid(new array("tiannetyearhead","seltianmonth","seltianhour","seltianminute"),true);
}
//�����·�span��ǩ��ӧ
function spanmonthcevent(){
hideelementsbyid(new array("seltianmonth","tiannetyearhead"),false);
if(m_bolshowhour) hideelementsbyid(new array("tiannethourhead"),false);
if(m_bolshowminute) hideelementsbyid(new array("tiannetminutehead"),false);
hideelementsbyid(new array("tiannetmonthhead","seltianyear","seltianhour","seltianminute"),true);
}
//����сʱspan��ǩ��ӧ
function spanhourcevent(){
hideelementsbyid(new array("tiannetyearhead","tiannetmonthhead"),false);
if(m_bolshowhour) hideelementsbyid(new array("seltianhour"),false);
if(m_bolshowminute) hideelementsbyid(new array("tiannetminutehead"),false);
hideelementsbyid(new array("tiannethourhead","seltianyear","seltianmonth","seltianminute"),true);
}
//��������span��ǩ��ӧ
function spanminutecevent(){
hideelementsbyid(new array("tiannetyearhead","tiannetmonthhead"),false);
if(m_bolshowhour) hideelementsbyid(new array("tiannethourhead"),false);
if(m_bolshowminute) hideelementsbyid(new array("seltianminute"),false);
hideelementsbyid(new array("tiannetminutehead","seltianyear","seltianmonth","seltianhour"),true);
}
//���ݱ�ǩid���ػ���ʾ��ǩ
function hideelementsbyid(arrid,bolhide){
var strdisplay = "";
if(bolhide) strdisplay = "none";
for(var i = 0;i < arrid.length;i ++){
var obj = document.getelementbyid(arrid[i]);
obj.style.display = strdisplay;
}
}
//------------------ end ��ʾ����ʱ���span��ǩ��ӧ�¼� ---------------------------//
//�ж�ij���ƿ�ϊ����
function ispinyear(year){
var bolret = false;
if (0==year%4&&((year%100!=0)||(year%400==0))) {
bolret = true;
}
return bolret;
}
//�õ�һ���µ�����������ϊ29��
function getmonthcount(year,month){
var c=m_amonhead[month-1];
if((month==2)&&ispinyear(year)) c++;
return c;
}
//�������õ�ǰ���ա���ҫ�ƿ�ֹ�ڷ��ꡢ����ʱ����ǰ�մ��ڵ��µ������
function setrealdaycount() {
if( tiannetday > getmonthcount(tiannetyear,tiannetmonth) ) {
//�����ǰ���մ��ڵ��µ�����գ���ȡ���������
tiannetday = getmonthcount(tiannetyear,tiannetmonth);
}
}
//�ڸ�λ��ǰ����
function addzero(value){
if(value < 10 ){
value = "0" + value;
}
return value;
}
//ȡ���ո�
function tiannettrim(str) {
return str.replace(/(^\s*)|(\s*$)/g,"");
}
//ϊselect����һ��option
function createoption(objselect,value,text){
var option = document.createelement("option");
option.value = value;
option.text = text;
objselect.options.add(option);
}
//��ǰ�� year
function tiannetprevyear() {
if(tiannetyear > 999 && tiannetyear <10000){tiannetyear--;}
else{alert("��ݳ�����χ��1000-9999����");}
tiannetsetday(tiannetyear,tiannetmonth);
//������с���������с��ݣ�����ӧ��option
if( tiannetyear < tiannetyearst ) {
tiannetyearst = tiannetyear;
createoption(document.all.seltianyear,tiannetyear,tiannetyear + "��");
}
checkselect(document.all.seltianyear,tiannetyear);
tiannetwritehead();
}
//���� year
function tiannetnextyear() {
if(tiannetyear > 999 && tiannetyear <10000){tiannetyear++;}
else{alert("��ݳ�����χ��1000-9999����");return;}
tiannetsetday(tiannetyear,tiannetmonth);
//�����ݳ�������������ݣ�����ӧ��option
if( tiannetyear > tiannetyearend ) {
tiannetyearend = tiannetyear;
createoption(document.all.seltianyear,tiannetyear,tiannetyear + "��");
}
checkselect(document.all.seltianyear,tiannetyear);
tiannetwritehead();
}
//ѡ�����
function tiannettoday() {
tiannetyear = tiannetdatenow.getfullyear();
tiannetmonth = tiannetdatenow.getmonth()+1;
tiannetday = tiannetdatenow.getdate();
tiannetsetvalue(true);
//tiannetsetday(tiannetyear,tiannetmonth);
//selectobject();
}
//��ǰ���·�
function tiannetprevmonth() {
if(tiannetmonth>1){tiannetmonth--}else{tiannetyear--;tiannetmonth=12;}
tiannetsetday(tiannetyear,tiannetmonth);
checkselect(document.all.seltianmonth,tiannetmonth);
tiannetwritehead();
}
//�����·�
function tiannetnextmonth() {
if(tiannetmonth==12){tiannetyear++;tiannetmonth=1}else{tiannetmonth++}
tiannetsetday(tiannetyear,tiannetmonth);
checkselect(document.all.seltianmonth,tiannetmonth);
tiannetwritehead();
}
//��span��ǩ��д���ꡢ�¡�ʱ���ֵ�����
function tiannetwritehead(){
document.all.tiannetyearhead.innertext = tiannetyear + "��";
document.all.tiannetmonthhead.innertext = tiannetmonth + "��";
if( m_bolshowhour ) document.all.tiannethourhead.innertext = " "+tiannethour + "ʱ";
if( m_bolshowminute ) document.all.tiannetminutehead.innertext = tiannetminute + "��";
tiannetsetvalue(false);//���ı���ֵ���������ر��ؼ�
}
//������ʾ��
function tiannetsetday(yy,mm) {
setrealdaycount();//���õ�����ʵ����
tiannetwritehead();
var strdatefont1 = "", strdatefont2 = "" //����������ʾ�ķ��
for (var i = 0; i < 37; i++){tiannetarrday[i]=""}; //����ʾ�������ȫ�����
var day1 = 1;
var firstday = new date(yy,mm-1,1).getday(); //ij�µ�һ������ڼ�
for (var i = firstday; day1 < getmonthcount(yy,mm)+1; i++){
tiannetarrday[i]=day1;day1++;
}
//���������ʾ�յ����һ�еĵ�һ����Ԫ���ֵϊ�գ����������с�
//if(tiannetarrday[35] == ""){
// document.all.trtiannetday5.style.display = "none";
//} else {
// document.all.trtiannetday5.style.display = "";
//}
for (var i = 0; i < 37; i++){
var da = eval("document.all.tdtiannetday"+i) //��д�µ�һ���µ�������������
if (tiannetarrday[i]!="") {
//�ж��ƿ�ϊ��ĩ���������ĩ�����ϊ��ɫ����
if(i % 7 == 0 || (i+1) % 7 == 0){
strdatefont1 = ""
strdatefont2 = ""
} else {
strdatefont1 = "";
strdatefont2 = ""
}
da.innerhtml = strdatefont1 + tiannetarrday[i] + strdatefont2;
//����ǵ�ǰѡ����죬��ı���ɫ
if(tiannetarrday[i] == tiannetday ) {
da.style.backgroundcolor = "#cccccc";
} else {
da.style.backgroundcolor = "#efefef";
}
da.style.cursor="hand"
} else {
da.innerhtml="";da.style.backgroundcolor="";da.style.cursor="default"
}
}//end for
tiannetsetvalue(false);//���ı���ֵ���������ر��ؼ�
}//end function tiannetsetday
//����option��ֵѡ��option
function checkselect(objselect,selectvalue) {
var count = parseint(objselect.length);
if( selectvalue < 10 && selectvalue.tostring().length == 2) {
selectvalue = selectvalue.substring(1,2);
}
for(var i = 0;i < count;i ++){
if(objselect.options[i].value == selectvalue){
objselect.selectedindex = i;
break;
}
}//for
}
//ѡ���ꡢ�¡�ʱ���ֵ�������
function selectobject(){
//������с���������с��ݣ�����ӧ��option
if( tiannetyear < tiannetyearst ) {
for( var i = tiannetyear;i < tiannetyearst;i ++ ){
createoption(document.all.seltianyear,i,i + "��");
}
tiannetyearst = tiannetyear;
}
//�����ݳ�������������ݣ�����ӧ��option
if( tiannetyear > tiannetyearend ) {
for( var i = tiannetyearend+1;i <= tiannetyear;i ++ ){
createoption(document.all.seltianyear,i,i + "��");
}
tiannetyearend = tiannetyear;
}
checkselect(document.all.seltianyear,tiannetyear);
checkselect(document.all.seltianmonth,tiannetmonth);
if( m_bolshowhour ) checkselect(document.all.seltianhour,tiannethour);
if( m_bolshowminute ) checkselect(document.all.seltianminute,tiannetminute);
}
//����������ʱ��ŀؼ���ֵ
//����bolhidecontrol - �ƿ����ؿؼ�
function tiannetsetvalue(bolhidecontrol){
var value = "";
if( !tiannetday || tiannetday == "" ){
tiannetoutobject.value = value;
return;
}
var mm = tiannetmonth;
var day = tiannetday;
if( mm < 10 && mm.tostring().length == 1) mm = "0" + mm;
if( day < 10 && day.tostring().length == 1) day = "0" + day;
value = tiannetyear + tiannetdatesplit + mm + tiannetdatesplit + day;
if( m_bolshowhour ){
var hour = tiannethour;
if( hour < 10 && hour.tostring().length == 1 ) hour = "0" + hour;
value += tiannetdatetimesplit + hour;
}
if( m_bolshowminute ){
var minute = tiannetminute;
if( minute < 10 && minute.tostring().length == 1 ) minute = "0" + minute;
value += tiannettimesplit + minute;
}
tiannetoutobject.value = value;
//document.all.divtiannetdate.style.display = "none";
if( bolhidecontrol ) {
tiannethidecontrol();
}
}
//�ƿ���ʾʱ��
function showtime(){
if( !m_bolshowhour && m_bolshowminute){
alert("���ҫѡ����ӣ���������ѡ��сʱ��");
return;
}
hideelementsbyid(new array("tiannethourhead","seltianhour","tiannetminutehead","seltianminute"),true);
if( m_bolshowhour ){
//��ʾсʱ
hideelementsbyid(new array("tiannethourhead"),false);
}
if( m_bolshowminute ){
//��ʾ����
hideelementsbyid(new array("tiannetminutehead"),false);
}
}
//������ʾ����ѡ��ؼ��������û�ѡ��
function tiannetpopcalendar(){
//������������ʾ���ӧ��head
hideelementsbyid(new array("seltianyear","seltianmonth","seltianhour","seltianminute"),true);
hideelementsbyid(new array("tiannetyearhead","tiannetmonthhead","tiannethourhead","tiannetminutehead"),false);
tiannetsetday(tiannetyear,tiannetmonth);
tiannetwritehead();
showtime();
var dads = document.all.divtiannetdate.style;
var ix, iy;
var h = document.all.divtiannetdate.offsetheight;
var w = document.all.divtiannetdate.offsetwidth;
//����left
if (window.event.x + h > document.body.offsetwidth - 10 )
ix = window.event.x - h - 5 ;
else
ix = window.event.x + 5;
if (ix <0)
ix=0;
//����top
iy = window.event.y;
if (window.event.y + w > document.body.offsetheight - 10 )
iy = document.body.scrolltop + document.body.offsetheight - w - 5 ;
else
iy = document.body.scrolltop +window.event.y + 5;
if (iy <0)
iy=0;
dads.left = ix;
dads.top = iy;
tiannetshowcontrol();
selectobject();
}
//���������ؼ�(ͬʱ��ʾ��ǿ�����صı�ǩ)
function tiannethidecontrol(){
document.all.divtiannetdate.style.display = "none";
tiannetshowobject();
arrtiannethide = new array();//�������صı�ǩ�������
}
//��ʾ�����ؼ�(ͬʱ���ػ��ڵ��ı�ǩ)
function tiannetshowcontrol(){
document.all.divtiannetdate.style.display = "";
tiannethideobject("select");
tiannethideobject("object");
}
//���ݱ�ǩ�������ر�ǩ�������ס�ؼ���select��object
function tiannethideobject(strtagname) {
x = document.all.divtiannetdate.offsetleft;
y = document.all.divtiannetdate.offsettop;
h = document.all.divtiannetdate.offsetheight;
w = document.all.divtiannetdate.offsetwidth;
for (var i = 0; i < document.all.tags(strtagname).length; i++)
{
var obj = document.all.tags(strtagname)[i];
if (! obj || ! obj.offsetparent)
continue;
// ��ȡԪ�ض���body��ǵ��������
var objleft = obj.offsetleft;
var objtop = obj.offsettop;
var objheight = obj.offsetheight;
var objwidth = obj.offsetwidth;
var objparent = obj.offsetparent;
while (objparent.tagname.touppercase() != "body"){
objleft += objparent.offsetleft;
objtop += objparent.offsettop;
objparent = objparent.offsetparent;
}
//alert("�ؼ����:" + x + "select���" + (objleft + objwidth) + "�ؼ��ײ�:" + (y+h) + "select��:" + objtop);
var bolhide = true;
if( obj.style.display == "none" || obj.style.visibility == "hidden" || obj.getattribute("author") == "tiannet" ){
//�����ǩ����������صģ�����ҫ�����ء�����ǿؼ��е�������ҳ�������ء�
bolhide = false;
}
if( ( (objleft + objwidth) > x && (y + h + 20) > objtop && (objtop+objheight) > y && objleft < (x+w) ) && bolhide ){
//arrtiannethide.push(obj);//��¼�����صı�ǩ����
arrtiannethide[arrtiannethide.length] = obj;
obj.style.visibility = "hidden";
}
}
}
//��ʾ�����صı�ǩ
function tiannetshowobject(){
for(var i = 0;i < arrtiannethide.length;i ++){
//alert(arrtiannethide[i]);
arrtiannethide[i].style.visibility = "";
}
}
//��ʼ�����ڡ�
function tiannetinitdate(strdate){
var arr = strdate.split(tiannetdatesplit);
tiannetyear = arr[0];
tiannetmonth = arr[1];
tiannetday = arr[2];
}
//���
function tiannetclear(){
tiannetoutobject.value = "";
tiannethidecontrol();
}
//������ʱ�رոÿؼ�
document.onclick=function(){
//function document.onclick(){
with(window.event.srcelement){
if (tagname != "input" && getattribute("author") != "tiannet")
tiannethidecontrol();
}
}
//��esc���رոÿؼ�
document.onkeypress=function (){
if( event.keycode == 27 ){
tiannethidecontrol();
}
}