//******************************* XML request **********************************

   var isMozilla=document.all ? false : true;

   function XML_Load(url, method, req_params, ret_method, uparams) {
    this.XMLo=null;
    this.url = url;
    this.method = method;
    this.ret_method=ret_method; //XML or TEXT
    this.uparams = uparams;
    this.req_params=req_params;

     if (window.XMLHttpRequest) {  
         try { this.XMLo = new XMLHttpRequest(); }
         catch (e) { this.XMLo=null; }
     } else if (window.ActiveXObject) {    
                try { this.XMLo = new ActiveXObject("Microsoft.XMLHTTP"); }
                catch (e) { this.XMLo=null; }
            } else this.XMLo=null;

    if (this.XMLo!=null) { 
       //Wait while XML object initialized
       while (this.XMLo.readyState != 4 && this.XMLo.readyState != 0) {}
    }
   }

   XML_Load.prototype.IsReady=function() {   
    if (this.XMLo==null) return false;
    return true;
   }

   XML_Load.prototype.Load=function() {   

    if (this.method == "POST") {
        this.XMLo.open("POST", this.url, true);
        this.XMLo.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=utf-8');
    } else if (this.method == "GET") {
               this.XMLo.open("GET", this.url+'?'+this.req_params, true);
           }

    var eobj=this;

    this.XMLo.onreadystatechange = function () {
     var eclass=eobj;
     var eXMLo=eclass.XMLo;

     if (eXMLo.readyState == 4) {
         if (eXMLo.status == 200) {
//             alert(eXMLo.responseText); //For Debugging only
             eclass.OnReady("",eclass.uparams,((eclass.ret_method=="XML") ? eXMLo.responseXML.documentElement : eXMLo.responseText));
             delete eXMLo;
             delete eclass;
         } else {
//                 alert(eXMLo.responseText); //For Debugging only
                 eclass.OnReady("There was a problem retrieving the XML data:\n" + eXMLo.statusText,eclass.uparams,((eclass.ret_method=="XML") ? eXMLo.responseXML.documentElement : eXMLo.responseText));
                 delete eXMLo;
                 delete eclass;
         }
     }
    }

    if (this.method == 'POST') this.XMLo.send(this.req_params);
        else if (this.method == 'GET') this.XMLo.send(null);

   }

   //User defined function
   XML_Load.prototype.OnReady=function(uparams,ldata) {   
   }

function getAbsPos(el,nobreak) {
 var r={ x: el.offsetLeft, y: el.offsetTop };
 if(typeof(el.style)!='undefined') {
  if(typeof(el.style.overflow)!='undefined') {
   if((el.style.overflow=='auto')&&(!nobreak)) {
    r.x-=el.offsetLeft;
    r.y-=el.offsetTop;
    return r;
    }
   }
  }
 if(el.offsetParent) {
  var tmp=getAbsPos(el.offsetParent,nobreak);
  r.x+=tmp.x;
  r.y+=tmp.y;
  }
 return r;
 }

function getAbsScroll(el,nobreak) {
 var r={ x: 0, y: 0 };
 if(el.tagName=='BODY') return r;
 if(el.scrollLeft) r.x+=el.scrollLeft;
 if(el.scrollTop) r.y+=el.scrollTop;
 if(typeof(el.style)!='undefined') {
  if(typeof(el.style.overflow)!='undefined') {
   if((el.style.overflow=='auto')&&(!nobreak))
    return r;
   }
  }
 if(el.parentNode) {
  var tmp=getAbsScroll(el.parentNode,nobreak);
  r.x+=tmp.x;
  r.y+=tmp.y;
  }
 return r;
 }

function getAbsolutePos(el,nobreak) {
 var r=getAbsPos(el,nobreak);
 var s=getAbsScroll(el,nobreak);
 r.x+=s.x; r.y+=s.y;
 return r;
 }

function FCrEl(parent,tagName,param,style,text) {
 //parent - parent of element, can be NULL
 //param  - "border=1; cellspacing=3; class=my"
 //style  - "border: solid 1px #000000; backgroundColor: #FF0000;"
 tagName=tagName.toLowerCase();
 var el;
 if (tagName=="text") el=document.createTextNode(param);
     else {
           el=document.createElement(tagName);
           var result;
           //Add Attributes
           FCrEl.rep.lastIndex=0;
           while ((result=FCrEl.rep.exec(param))!=null) {
                  var attr=document.createAttribute(result[1]);
                  attr.value=result[2];
                  el.setAttributeNode(attr);
           }

           //Add Style
           FCrEl.res.lastIndex=0;
           while ((result=FCrEl.res.exec(style))!=null) el.style[result[1]]=result[2];
          }

 if (text) el.appendChild(document.createTextNode(text));
 if (parent!=null) parent.appendChild(el);
 return el;
}

FCrEl.rep=new RegExp();
FCrEl.rep.compile(" *(.*?) *= *(.*?) *(;|$)","g");

FCrEl.res=new RegExp();
FCrEl.res.compile(" *(.*?) *: *(.*?) *(;|$)","g");

  function cords() {
   }

  cords.get=function(o) {
   var crdX=o.offsetLeft;
   var crdY=o.offsetTop;
   while ((o=o.offsetParent)!=null) {
    crdX+=o.offsetLeft;
    crdY+=o.offsetTop;
    }
   return [crdX,crdY];
   }

  cords.getX=function(o) {
   var crdX=o.offsetLeft;
   while ((o=o.offsetParent)!=null) crdX+=o.offsetLeft+o.clientLeft;
   return crdX;
   }

  cords.getY=function(o) {
   var crdY=o.offsetTop;
   while ((o=o.offsetParent)!=null) crdY+=o.offsetTop+o.clientTop;
   return crdY;
   }

  function getParentDiv(el) {
   if(typeof(el.style)!='undefined') {
    if(typeof(el.style.overflow)!='undefined') {
     if(el.style.overflow=='auto')
      return el;
     }
    }
   if(el.parentNode)
    return getParentDiv(el.parentNode);
   return null;
   }

  function cSelect(container,name,width,height,bWidth,lWidth,lHeight,noDefVal) {
   if (!cSelect.onclick) { cSelect.onclick=null; cSelect.opened=false; }
   this.container=container;
   this.options=new Array();
   this.name=name;
   this.selected=null;
   this.value=null;
   this.vObj=name ? document.getElementById(name) : null;
   this.noDefVal=noDefVal ? noDefVal : "";
   this.disabled=false;
   this.onChange=null;

   this.selectCN=cSelect.selectCN;
   this.selectAreaCN=cSelect.selectAreaCN;
   this.selectButtonAreaCN=cSelect.selectButtonAreaCN;
   this.selectButtonCN=cSelect.selectButtonCN;

   this.dselectCN=cSelect.dselectCN;
   this.dselectAreaCN=cSelect.dselectAreaCN;
   this.dselectButtonAreaCN=cSelect.dselectButtonAreaCN;
   this.dselectButtonCN=cSelect.dselectButtonCN;

   this.dropDownCN=cSelect.dropDownCN;
   this.dropDownListCN=cSelect.dropDownListCN;
   this.dropDownListItemCN=cSelect.dropDownListItemCN;
   this.dropDownListItemSelectedCN=cSelect.dropDownListItemSelectedCN;

   this.height=height;
   this.width=width; //-(isMozilla ? 2 : 0);
   this.bWidth=bWidth;
   if (!lHeight) lHeight=16*5;
   this.lWidth=lWidth;
   this.lHeight=lHeight;
   var eclass=this;

   var tb=document.createElement("table");
   var a=document.createAttribute("cellspacing"); a.value=0; tb.setAttributeNode(a);
   a=document.createAttribute("cellpadding"); a.value=0; tb.setAttributeNode(a);
   a=document.createAttribute("border"); a.value=0; tb.setAttributeNode(a);
   tb.style.height=this.height+"px";
   tb.style.width=this.width+"px";
   tb.className=this.selectCN;
   tb.style.tableLayout="fixed";
   this.container.appendChild(tb);

   this.HTMLo=tb;
   tb=tb.appendChild(document.createElement("tbody"));

   var tr=document.createElement("tr");
   var a=document.createAttribute("valign"); a.value="top"; tr.setAttributeNode(a);
   tr.style.cursor="pointer";
   tb.appendChild(tr);

   tr.onclick=function(e) {
    if (eclass.disabled) return;

    var o=eclass.dropDownHTMLo;

    if (!e) e=window.event;
    e.cancelBubble=true;

    if (o.style.display=="none") {
        if (cSelect.opened) document.onclick(null);
        cSelect.onclick=document.onclick;
        cSelect.opened=true;

        var vh,vw,sh,sw;
        o.style.height="auto";
        o.style.left=(-(parseInt(eclass.dropDownHTMLo.offsetWidth)+10))+"px";
        o.style.width=eclass.HTMLo.offsetWidth - (isMozilla ? 2 : 0)+"px";
        o.style.display="";
        vh=parseInt(o.offsetHeight);
        if (isNaN(vh) || vh>eclass.lHeight) vh=eclass.lHeight;
        o.style.height=vh;
	var crd=getAbsPos(eclass.HTMLo);
	var crds=new Array();
	crds[0]=crd.x;
	crds[1]=crd.y;

        vh=parseInt(o.offsetHeight);
        vw=parseInt(o.offsetWidth);
        sh=parseInt(eclass.HTMLo.offsetHeight);
        sw=parseInt(eclass.HTMLo.offsetWidth);

	if(eclass.div) {
	 scrollLeft=eclass.div.scrollLeft;
	 scrollTop=eclass.div.scrollTop;
	 clientWidth=eclass.div.clientWidth;
	 clientHeight=eclass.div.clientHeight;
	 }
	else {
         var doc=document;
         if(window.parent.document)
          doc=window.parent.document;
	 scrollLeft=doc.body.scrollLeft;
	 scrollTop=doc.body.scrollTop;
	 clientWidth=doc.body.clientWidth;
	 clientHeight=doc.body.clientHeight;
	 }
        var t=crds[0]-scrollLeft;
        o.style.left=(scrollLeft + (((t+vw)>clientWidth) ? crds[0]+sw-vw : (vw<sw) ? t+sw-vw : t))+"px";

        t=crds[1]-scrollTop;
        var t2=t-vh;
        var t3=clientHeight-t-sh-vh;

        o.style.top=(scrollTop + (t3<0 && (t2>=0 || (t2<0 && t2>t3)) ? t-vh : t+sh))+"px";
        o.style.position="absolute";
        document.body.appendChild(o);

        if (eclass.dropDownListHTMLo.offsetHeight<vh)
            o.firstChild.firstChild.style.height=eclass.dropDownListHTMLo.offsetHeight+(isMozilla ? 0 : 2);
            else o.firstChild.firstChild.style.height=vh;

        document.onclick=function(e) {
         if (!e) e=window.event;
         if(e) e.cancelBubble=true;
         eclass.dropDownHTMLo.style.display="none";
         document.onclick=cSelect.onclick;
         cSelect.onclick=null;
         cSelect.opened=false;
        }

     } else {
      document.onclick(null);
      e.cancelBubble=true;
     }
   return false;
   }
   
   tr.ondblclick=function(e) { if (!e) this.onclick(e); return false; }

   var td=document.createElement("td");
   a=document.createAttribute("nowrap"); a.value=1; td.setAttributeNode(a);
   td.className=this.selectAreaCN;
   td.style.width=(this.width-this.bWidth-4)+"px";
   td.style.height="12px";
   tr.appendChild(td);

   var dv=document.createElement("div");
   a=document.createAttribute("nowrap"); a.value=1; dv.setAttributeNode(a);
   td.appendChild(dv);
   dv.style.width=(this.width-this.bWidth-4)+"px";
   dv.style.height=td.style.height;
   dv.style.overflow="hidden";
   dv.appendChild(document.createTextNode(""));
   this.selectedHTMLo=dv;
   
   if (!this.bWidth) this.bWidth=Math.floor( (100*parseInt(td.offsetHeight))/parseInt(this.HTMLo.offsetWidth) )+"%";
   //for no proportion transformation of button:
   //if (!this.bWidth) this.bWidth=parseInt(td.offsetHeight);

   td=document.createElement("td");
   a=document.createAttribute("align"); a.value="center"; td.setAttributeNode(a);
   td.style.width=this.bWidth;
   td.className=this.selectButtonAreaCN;
   tr.appendChild(td);
   var bt=document.createElement("button");
   bt.style.width="100%";
   bt.className=this.selectButtonCN;
//   bt.value="\u25BC";
   td.appendChild(bt);

   dv=document.createElement("div");
   a=document.createAttribute("nowrap"); a.value=1; dv.setAttributeNode(a);
   dv.className=this.dropDownCN;
   dv.style.position="absolute";
   dv.style.zIndex=100;
   dv.style.left="0px";
   dv.style.top="0px";
   dv.style.overflowX="hidden";
   dv.style.overflowY="auto";
   dv.style.display="none";
   this.HTMLo.appendChild(dv);
   this.dropDownHTMLo=dv;

   tb=document.createElement("table");
   a=document.createAttribute("cellspacing"); a.value=0; tb.setAttributeNode(a);
   a=document.createAttribute("cellpadding"); a.value=0; tb.setAttributeNode(a);
   a=document.createAttribute("border"); a.value=0; tb.setAttributeNode(a);
   tb.style.width="100%";
   tb.className=this.dropDownListCN;
   dv.appendChild(tb);
   tb=tb.appendChild(document.createElement("tbody"));
   this.dropDownListHTMLo=tb;

   this.setUnselected();
  }



  cSelect.prototype.addHiddenStore=function(vObjName) {
   this.vObj=FCrEl(this.container,"INPUT","type=hidden; name="+vObjName+"; id="+vObjName);
  }



  cSelect.prototype.insertBefore=function(before,option,selected) {
   var i,num;
   var eclass=this;                             
   if (!option.className) option.className=this.dropDownListItemCN;
/*
   var tr=FCrEl(null,"TR","height=1;","cursor: pointer");
/**/

   var tr=document.createElement("tr");
   tr.style.height=1;
   tr.style.cursor="pointer";
/**/
   option.HTMLo=tr;

   num=this.options.length;
   if (before) for (i=0;i<this.options.length;i++) if (this.options[i]==before) {num=i; break;}
   this.options.splice(num,0,option); 

   tr.onmouseover=function() {this.className=eclass.dropDownListItemSelectedCN;}
   tr.onmouseout=function() {this.className="";}
   tr.onclick=function() {eclass.setSelectedByObj(option); if((typeof('changed')!='undefined')&&(eclass.vObjName)&&(eclass.vObjName.substring(0,6)=='field_')) changed=true; if (eclass.onChange) eclass.onChange(eclass.selected,option,eclass);}

/*
   var td=FCrEl(tr,"TD","nowrap=1; title="+option.data+"; class="+option.className,"",option.data);
/**/

   var td=document.createElement("td");
   var a=document.createAttribute("nowrap"); a.value=1; td.setAttributeNode(a);
   a=document.createAttribute("title"); a.value=option.data; td.setAttributeNode(a);
   td.className=option.className;
   td.appendChild(document.createTextNode(option.data));
   tr.appendChild(td);
/**/

   if (before) this.dropDownListHTMLo.insertBefore(tr,before.HTMLo);
       else this.dropDownListHTMLo.appendChild(tr);

   if (selected) this.setSelectedByObj(option);
   return option;
  }



  cSelect.prototype.insertBeforeOption=function(before,data,val,selected,className) {
   return this.insertBefore(before,new cSelect.option(data,val,className),selected);
  }



  cSelect.prototype.add=function(option,selected) {
   return this.insertBefore(null,option,selected);
  }



  cSelect.prototype.addOption=function(data,val,selected,className) {
   return this.insertBeforeOption(null,data,val,selected,className);
  }



  cSelect.prototype.remove=function(option) {
   var i;

   for (i=0;i<this.options.length;i++)
        if (this.options[i]==option) {
            this.options.splice(i,1);
            this.dropDownListHTMLo.removeChild(option.HTMLo);
            return option;            
        }

   return null;
  }



  cSelect.prototype.clear=function(option) {
   var i;

   for (i=0;i<this.options.length;i++)
        this.dropDownListHTMLo.removeChild(this.options[i].HTMLo);
   this.options=[];
   this.setUnselected();
  }



  cSelect.prototype.setUnselected=function() {
   this.selectedHTMLo.className=this.selectedAreaCN;
   this.selectedHTMLo.firstChild.nodeValue="...";
   this.selectedHTMLo.title="";
   this.selected=null;
   this.value=null;
   if (this.vObj) this.vObj.value=this.noDefVal;
  }



  cSelect.prototype.setSelectedByObj=function(o) {
   if (o==null) {this.setUnselected(); return;}

   this.selectedHTMLo.firstChild.nodeValue=o.data;
   this.selectedHTMLo.className=o.className;
   this.selectedHTMLo.title=o.data;
   this.selected=o;
   this.value=this.selected.value;
   if (this.vObj) this.vObj.value=o.value;
  }



  cSelect.prototype.setSelectedByOption=function(data) {
   for (var i=0;i<this.options.length;i++) {
        if (this.options[i].data==data) {this.setSelectedByObj(this.options[i]); return true;}
   }
   return false;
  }



  cSelect.prototype.setSelectedByValue=function(val) {
   for (var i=0;i<this.options.length;i++) {
        if (this.options[i].value==val) {this.setSelectedByObj(this.options[i]); return true;}
   }
   return false;
  }



  cSelect.prototype.setOnChangeFunc=function(func) {
   this.onChange=func;
  }



  cSelect.prototype.enable=function(state) {
   this.disabled=!state;
   if (this.disabled) {
       if (this.vObj) {this.vObjName=this.vObj.name; this.vObj.name="";}
       this.HTMLo.className=this.dselectCN;
       this.HTMLo.firstChild.firstChild.firstChild.className=this.dselectAreaCN;
       this.HTMLo.firstChild.firstChild.firstChild.nextSibling.className=this.dselectButtonAreaCN;
       this.HTMLo.firstChild.firstChild.firstChild.nextSibling.className.firstChild=this.dselectButtonCN;
   } else {
           if (this.vObj && this.vObjName) {delete(this.vObjName); this.vObj.name=this.vObjName;}
           this.HTMLo.className=this.selectCN;
           this.HTMLo.firstChild.firstChild.firstChild.className=this.selectAreaCN;
           this.HTMLo.firstChild.firstChild.firstChild.nextSibling.className=this.selectButtonAreaCN;
           this.HTMLo.firstChild.firstChild.firstChild.nextSibling.className.firstChild=this.selectButtonCN;
          }

  }



  cSelect.option=function(data,value,className,HTMLo) {
                            this.data=data;
                            this.value=value;
                            this.HTMLo=HTMLo;
                            this.className=className ? className : null;
                            return this;
                 }



  cSelect.clearDefaultStyles=function() {
   cSelect.selectCN="s_select";
   cSelect.selectAreaCN="s_selectArea";  
   cSelect.selectButtonAreaCN="s_selectButtonArea";  
   cSelect.selectButtonCN="s_selectButton";  

   cSelect.dselectCN="s_dselect";
   cSelect.dselectAreaCN="s_dselectArea";  
   cSelect.dselectButtonAreaCN="s_dselectButtonArea";  
   cSelect.dselectButtonCN="s_dselectButton";  

   cSelect.dropDownCN="s_dropDown";
   cSelect.dropDownListCN="s_dropDownList";
   cSelect.dropDownListItemCN="s_dropDownListItem";
   cSelect.dropDownListItemSelectedCN="s_dropDownListItemSelected";
  }

  cSelect.setDefaultStyles=function(selectCN,selectAreaCN,selectButtonAreaCN,selectButtonCN,dselectCN,dselectAreaCN,dselectButtonAreaCN,dselectButtonCN,dropDownCN,dropDownListCN,dropDownListItemCN,dropDownListItemSelectedCN) {
   if (selectCN!=null)                   cSelect.selectCN=selectCN;
   if (selectAreaCN!=null)               cSelect.selectAreaCN=selectAreaCN;
   if (selectButtonAreaCN!=null)         cSelect.selectButtonAreaCN=selectButtonAreaCN;
   if (selectButtonCN!=null)             cSelect.selectButtonCN=selectButtonCN;
   if (dselectCN!=null)                  cSelect.dselectCN=dselectCN;
   if (dselectAreaCN!=null)              cSelect.dselectAreaCN=dselectAreaCN;
   if (dselectButtonAreaCN!=null)        cSelect.dselectButtonAreaCN=dselectButtonAreaCN;
   if (dselectButtonCN!=null)            cSelect.dselectButtonCN=dselectButtonCN;
   if (dropDownCN!=null)                 cSelect.dropDownCN=dropDownCN;
   if (dropDownListCN!=null)             cSelect.dropDownListCN=dropDownListCN;
   if (dropDownListItemCN!=null)         cSelect.dropDownListItemCN=dropDownListItemCN;
   if (dropDownListItemSelectedCN!=null) cSelect.dropDownListItemSelectedCN=dropDownListItemSelectedCN;
  }

 cSelect.clearDefaultStyles();

function Calendar(CalContainer,WeekFromMonday,Lang,mnYear,mxYear,closeMark) {
 this.MondayStart=WeekFromMonday;

 if (Lang=="RUS") {
     this.day_in_week   = new Array('Пон','Втр','Срд','Чтв','Птн','Суб','Вос');
     this.month_in_year = new Array('Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь');
     this.messages = new Array();
     this.messages["set_cur"]="...";
     this.messages["cur_day"]="сегодняшний день";
     this.messages["cur_month"]="начало месяца";
     this.messages["cur_quar"]="начало квартала";
     this.messages["cur_year"]="начало года";
 } else {
         this.day_in_week   = new Array('Mon','Tue','Wed','Thu','Fri','Sat','Sun');
         this.month_in_year = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
         this.messages = new Array();
         this.messages["set_cur"]="...";
         this.messages["cur_day"]="today";
         this.messages["cur_month"]="beg. mon.";
         this.messages["cur_quar"]="beg. quar.";
         this.messages["cur_year"]="beg. year";
        }

 this.max_days_in_month = 31; // максимальное количество дней в месяце
 this.CalContainer=CalContainer;
 this.SetCurrentDate();
 this.year=0;
 this.month=0;
 this.day=0;
 this.minYear=mnYear;
 this.maxYear=mxYear;
 this.selectedDayObj=null;
 this.OnClkFunc=null; //User onclick function(calo,prevcell,cell,year,month,day), prevcell can be null
 this.OnChgFunc=null; //User onchange function(calo,year,month,status), where status = true - before rebuild and flase - after rebuild
 this.markedDays=null;

 this.dayCellHeight=18;
 this.dayCellWidth=28;

 this.closeMark=closeMark ? true : false;

 this.cellPt=new Array();

 this.workdayCN                 =Calendar.workdayCN;
 this.workday_selectedCN        =Calendar.workday_selectedCN;
 this.workday_markedCN          =Calendar.workday_markedCN;
 this.workday_curCN             =Calendar.workday_curCN;
                                
 this.holidayCN                 =Calendar.holidayCN;
 this.holiday_selectedCN        =Calendar.holiday_selectedCN;
 this.holiday_markedCN          =Calendar.holiday_markedCN;
 this.holiday_curCN             =Calendar.holiday_curCN;
                                
 this.calendarCN                =Calendar.calendarCN;
                                
 this.selectCN                  =Calendar.selectCN;
 this.selectAreaCN              =Calendar.selectAreaCN;
 this.selectButtonAreaCN        =Calendar.selectButtonAreaCN;
 this.selectButtonCN            =Calendar.selectButtonCN;
 this.DselectCN                 =Calendar.DselectCN;
 this.DselectAreaCN             =Calendar.DselectAreaCN;
 this.DselectButtonAreaCN       =Calendar.DselectButtonAreaCN;
 this.DselectButtonCN           =Calendar.DselectButtonCN;
 this.DropDownCN                =Calendar.DropDownCN;
 this.DropDownListCN            =Calendar.DropDownListCN;
 this.DropDownListItemCN        =Calendar.DropDownListItemCN;
 this.DropDownListItemMarkedCN  =Calendar.DropDownListItemMarkedCN;
 this.DropDownListItemSelectedCN=Calendar.DropDownListItemSelectedCN;

 this.inputCN                   =Calendar.inputCN;
                                
 this.hdrRowCN                  =Calendar.hdrRowCN;
 this.yearRowCN                 =Calendar.yearRowCN;
 this.monthRowCN                =Calendar.monthRowCN;
 this.weekRowCN                 =Calendar.weekRowCN;
 this.aCN                       =Calendar.aCN;
}

Calendar.prototype.GetWeekDay = function (num) {
 //num 0-6
 if (!this.MondayStart) if (num==0) return this.day_in_week[6]; else num--;
 return this.day_in_week[num];
}

Calendar.prototype.IsHoliday = function (num) {
 //num 0-6
 if (!this.MondayStart) if (num==0 || num==6) return true; else return false;
 if (num==5 || num==6) return true;
 return false;
}

Calendar.prototype.SetCurrentDate = function () {
 var CurDate  = new Date();
 this.curYear  = (CurDate.getYear());
 if (this.curYear<1000) this.curYear+=1900;
 this.curMonth = (1+CurDate.getMonth());
 this.curMonthDay=CurDate.getDate();
}

Calendar.prototype.GetDaysInMonth = function (year,month) {
 var days=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
 if (month==2 && (year%4)==0) return (days[month-1]+1);
 return days[month-1];
}

Calendar.prototype.GetDayOfWeek = function (year,month,day) {
 var a=Math.floor((14-month)/12);
 var y=year-a;
 var m=month+12*a-2;
 var d=(day+y+Math.floor(y/4)-Math.floor(y/100)+Math.floor(y/400)+Math.floor((31*m)/12))%7;
    //d=0-6 Su,Mo...
 if (d==0) d=6; else d--; //Mo,Tu
 return d;
}

Calendar.prototype.Rebuild = function (year,month,day,markedDays,internal_call) {
 return this.RebuildCalendar (year,month,day,markedDays,internal_call);
 }

Calendar.prototype.RebuildCalendar = function (year,month,day,markedDays,internal_call) {
 var dweek=0;
 var cells;
 var cday=1;
 var i,j;
 var CalHTML;
 var days_in_month;
 var el1,el2,el3,el4,el5,el6,el7,el8,el9;
 var holiday;
 var eclass=this;

// if (this.OnChgFunc!=null) if (!this.OnChgFunc(this,year,month,day,true,internal_call)) return;

 while (this.CalContainer.hasChildNodes()) this.CalContainer.removeChild(this.CalContainer.lastChild);

 if (markedDays) this.markedDays=markedDays;

 if((year=="1990")&&(month=="1")&&(day=="1")) { year=""; month=""; day=""; }
 if (typeof(year)!="number") {year=this.curYear;month=this.curMonth;}
 if (typeof(month)!="number") month=1;
 if (typeof(day)!="number") day=this.curMonthDay;

 days_in_month=this.GetDaysInMonth(year,month);

 el1=FCrEl(this.CalContainer,"TABLE","cellspacing=0; cellpadding=0; border=0; class="+this.calendarCN);
 el1.style.borderCollapse="separate";

 el2=FCrEl(el1,"TBODY");

 //=============== HEADER ROW =================
if(!this.closeMark) {
 el3=FCrEl(el2,"TR","height=20px; valign=middle; class="+this.hdrRowCN);
 el4=FCrEl(el3,"TD","colspan=6;");
 el5=FCrEl(el4,"A","href=#; class="+this.aCN+" ID=YearDec;");
 el4=FCrEl(el3,"TD","align=center;");
 el5=FCrEl(el4,"A","href=#; class="+this.aCN,"","X");
 el5.onclick=function () {eclass.Clear(); return false;};
 }

 //=============== YEAR ROW ===================
 el3=FCrEl(el2,"TR","align=center; class="+this.yearRowCN);

 el4=FCrEl(el3,"TD");
 el5=FCrEl(el4,"A","href=#; class="+this.aCN+" id=MonthDec;");
 el5.onclick=function () {if (month==1) {month=12; year--;} else month--; eclass.Rebuild(year,month,0,null,true); return false;}
 FCrEl(el5,"IMG","src=/resources/cal2_bl.gif; width=11; height=10; border=0");
 //CENTER
 el4=FCrEl(el3,"TD","colspan=2; height=20");
 var s2=new cSelect(el4,"temp2",90,18,18,60,190);
 cSelect.clearDefaultStyles();

 s2.setOnChangeFunc(
  function(user,prv,now,calo) {
   eclass.Rebuild(eclass.year,parseInt(now.value,10),eclass.day,null,true);
  }
 );

 var cn=null;
 for (i=0;i<this.month_in_year.length;i++) {
      if (year==this.curYear && i==(this.curMonth-1)) cn=this.DropDownListItemMarkedCN;
          else cn=this.DropDownListItemCN;
      s2.addOption(this.month_in_year[i],(i+1),false,cn);
 }
 s2.setSelectedByValue(month);

 //RIGHT
 el4=FCrEl(el3,"TD");
 el5=FCrEl(el4,"A","href=#; class="+this.aCN+"; id=MonthInc;");
 el5.onclick=function () {if (month==12) {month=1; year++;} else month++; eclass.Rebuild(year,month,0,null,true); return false;}
 FCrEl(el5,"IMG","src=/resources/cal2_br.gif; width=11; height=10; border=0");

 //LEFT
 el4=FCrEl(el3,"TD");
 el5=FCrEl(el4,"A","href=#; class="+this.aCN+" ID=YearDec;");
 el5.onclick=function () {if (year>eclass.minYear) eclass.Rebuild(year-1,month,0,null,true); return false;}
 FCrEl(el5,"IMG","src=/resources/cal_bl.gif; width=11; height=10; border=0");
 //CENTER
 el4=FCrEl(el3,"TD");
 el8=FCrEl(el4,"FORM","name=SetYear;","display: inline;");
 el8.onsubmit=function () {var yr=NumberToNumber(this.elements[0].value); if (yr==false) yr=eclass.year; else { if (yr<99) yr+=2000; if (yr<eclass.minYear || yr>eclass.maxYear) yr=eclass.year; } eclass.Rebuild(yr,eclass.month,eclass.day,null,true); return false;}
 el9=FCrEl(el8,"INPUT","name=YEAR; type=text; maxlength=4; value="+year+"; class="+this.inputCN,"padding: 2px; width: 30px; height: 16px;");
 var focusEl=el9;
 if (year==this.curYear) el9.style.color="#A00000";
 el9.onchange=function() {this.parentNode.onsubmit();}

 el4=FCrEl(el3,"TD");
 el5=FCrEl(el4,"A","href=#; class="+this.aCN+"; id=YearInc;");
 el5.onclick=function () {if (year<eclass.maxYear) eclass.Rebuild(year+1,month,0,null,true); return false;}
 FCrEl(el5,"IMG","src=/resources/cal_br.gif; width=11; height=10; border=0");

 //=============== MONTH ROW ===================
 el3=FCrEl(el2,"TR","align=center; class="+this.monthRowCN);

 el4=FCrEl(el3,"TD");
 el4=FCrEl(el3,"TD","colspan=5");
 cSelect.setDefaultStyles(this.selectCN,this.selectAreaCN,this.selectButtonAreaCN,this.selectButtonCN,this.DselectCN,this.DselectAreaCN,this.DselectButtonAreaCN,this.DselectButtonCN,this.DropDownCN,this.DropDownListCN,this.DropDownListItemCN,this.DropDownListItemSelectedCN);
 var s1=new cSelect(el4,"temp",200,18,18,160);

 s1.addOption(this.messages["set_cur"],"not",true);
 s1.addOption(this.messages["cur_day"],"day");
 s1.addOption(this.messages["cur_month"],"mon");
 s1.addOption(this.messages["cur_quar"],"quar");
 s1.addOption(this.messages["cur_year"],"year");

 s1.setOnChangeFunc(
  function(user,prv,now,calo) {
           if (now.value=="not") return false;
               else if (now.value=="day") {eclass.Rebuild(eclass.curYear,eclass.curMonth,eclass.curMonthDay,null,true); eclass.DTclick(eclass.cellPt[eclass.curMonthDay-1]);}
                            else if (now.value=="mon") {eclass.Rebuild(eclass.curYear,eclass.curMonth,1,null,true); eclass.DTclick(eclass.cellPt[0]);}
                                     else if (now.value=="quar") {eclass.Rebuild(eclass.curYear,Math.floor((eclass.curMonth-1)/3)*3+1,null,null,true);}
                                              else if (now.value=="year") eclass.Rebuild(eclass.curYear,1,null,null,true);
  }
 );

 //=============== WEEK ROW ===================
 cday=-this.GetDayOfWeek(year,month,1)+1;
 if (!this.MondayStart) cday-=1;

 el3=FCrEl(el2,"TR","align=center; class="+this.weekRowCN+"; height=16;");
 for (i=0;i<=6;i++) FCrEl(FCrEl(el3,"TD","width=25;",i>=5 ? "color: #DB0000" : ""),"TEXT",this.GetWeekDay(i));

 //=============== DAYS SQUARE ===================
 this.cellPt=new Array();
 i=0;
 for (cell=0;cell<42;cell++) {
  if (i==0) {
      FCrEl(FCrEl(el2,"TR","height=2"),"TD","colspan=7","backgroundColor: #EAEAEA");
      el3=FCrEl(el2,"TR","height="+this.dayCellHeight+"; align=center; valign=middle;");
  }
  holiday=this.IsHoliday(i);
  el4=FCrEl(el3,"TD","width="+this.dayCellWidth);
  el4.className=(holiday? this.holidayCN : this.workdayCN);
  if (cday<=0 || cday>days_in_month) {
          FCrEl(el4,"text"," ");
  } else {
          this.cellPt.push(el4);
          el4.id="DT";
          el4.holiday=holiday;
          el4.day=cday;
          el4.style.cursor="pointer";
          el4.onclick=function () {eclass.DTclick(this);}
          if (year==this.curYear && month==this.curMonth && cday==this.curMonthDay) el4.className=(holiday? this.holiday_curCN : this.workday_curCN);
          for (j=0;this.markedDays!=null && j<this.markedDays.length;j++) if (this.markedDays[j]==cday) {el4.className=(holiday? this.holiday_markedCN : this.workday_markedCN); break;}
          el4.defCN=el4.className;
          if (cday==day) {this.selectedDayObj=el4; this.selectedDayObj.className=(holiday ? this.holiday_selectedCN : this.workday_selectedCN);}
          FCrEl(el4,"text",cday);             
         }
  cday++;
  i++;
  if (i>6) i=0;
 }

 focusEl.focus();

 this.year=year;
 this.month=month;
 this.day=day;

 if (this.OnChgFunc!=null) this.OnChgFunc(this,year,month,day,false,internal_call);
}

Calendar.prototype.SetMarkedDays = function (markedDays) {
 this.markedDays=markedDays;
}

Calendar.prototype.SetOnEventsFunction = function (onclickfunc,onchangefunc) {
 this.OnClkFunc=onclickfunc;
 this.OnChgFunc=onchangefunc;
}

Calendar.prototype.Clear = function () {
 while (this.CalContainer.hasChildNodes()) this.CalContainer.removeChild(this.CalContainer.lastChild);
}

Calendar.prototype.GetSelected = function () {
 return {"year" : this.year, "month" : this.month, "day" : this.day};
}


Calendar.prototype.DTclick = function (cell) {
 var t,prev=null;
 if (this.selectedDayObj!=null) {       
     prev=this.selectedDayObj;
     this.selectedDayObj.className=this.selectedDayObj.defCN;
     this.selectedDayObj=null;
 }  

 this.selectedDayObj=cell;
 this.selectedDayObj.className=(this.selectedDayObj.holiday ? this.holiday_selectedCN : this.workday_selectedCN);
 this.day=this.selectedDayObj.day;
 if (this.OnClkFunc!=null) this.OnClkFunc(this,prev,this.selectedDayObj,this.year, this.month,this.selectedDayObj.day);
}


Calendar.clearDefaultStyles=function() {
 Calendar.workdayCN="workday";           //Normal day class name
 Calendar.workday_selectedCN="workday_s"; //Normal day selected class name
 Calendar.workday_markedCN="workday_m";   //Normal day marked class name
 Calendar.workday_curCN="workday_c";
 
 Calendar.holidayCN="holiday";           //Holiday class name
 Calendar.holiday_selectedCN="holiday_s"; //Holiday selected class name
 Calendar.holiday_markedCN="holiday_m";   //Holiday marked class name
 Calendar.holiday_curCN="holiday_c";

 Calendar.calendarCN="calendar";  //Calendar class name

 Calendar.selectCN="cSelect";
 Calendar.selectAreaCN="cSelectArea";
 Calendar.selectButtonAreaCN="cSelectButtonArea";
 Calendar.selectButtonCN="cSelectButton";
 Calendar.DselectCN="cDselect";
 Calendar.DselectAreaCN="cDselectArea";
 Calendar.DselectButtonAreaCN="cDselectButtonArea";
 Calendar.DselectButtonCN="cDselectButton";
 Calendar.DropDownCN="cDropDown";
 Calendar.DropDownListCN="cDropDownList";
 Calendar.DropDownListItemCN="cDropDownListItem";
 Calendar.DropDownListItemMarkedCN="cDropDownListItemMarked";
 Calendar.DropDownListItemSelectedCN="cDropDownListItemSelected";

 Calendar.inputCN="cinput";

 Calendar.hdrRowCN="headerRow";
 Calendar.yearRowCN="yearRow";
 Calendar.monthRowCN="monthRow";
 Calendar.weekRowCN="weekRow";
 Calendar.aCN="hlink";
}

Calendar.setDefaultStyles=function(workdayCN,workday_selectedCN,workday_markedCN,workday_curCN,holidayCN,holiday_selectedCN,holiday_markedCN,holiday_curCN,calendarCN,selectCN,selectAreaCN,selectButtonAreaCN,selectButtonCN,DselectCN,DselectAreaCN,DselectButtonAreaCN,DselectButtonCN,DropDownCN,DropDownListCN,DropDownListItemCN,DropDownListItemMarkedCN,DropDownListItemSelectedCN,inputCN,hdrRowCN,yearRowCN,monthRowCN,weekRowCN,aCN) {
 if (workdayCN!=null)                  Calendar.workdayCN=workdayCN;
 if (workday_selectedCN!=null)         Calendar.workday_selectedCN=workday_selectedCN;
 if (workday_markedCN!=null)           Calendar.workday_markedCN=workday_markedCN;
 if (workday_curCN!=null)              Calendar.workday_curCN=workday_curCN;
 if (holidayCN!=null)                  Calendar.holidayCN=holidayCN;
 if (holiday_selectedCN!=null)         Calendar.holiday_selectedCN=holiday_selectedCN;
 if (holiday_markedCN!=null)           Calendar.holiday_markedCN=holiday_markedCN;
 if (holiday_curCN!=null)              Calendar.holiday_curCN=holiday_curCN;
 if (calendarCN!=null)                 Calendar.calendarCN=calendarCN;
 if (selectCN!=null)                   Calendar.selectCN=selectCN;
 if (selectAreaCN!=null)               Calendar.selectAreaCN=selectAreaCN;
 if (selectButtonAreaCN!=null)         Calendar.selectButtonAreaCN=selectButtonAreaCN;
 if (selectButtonCN!=null)             Calendar.selectButtonCN=selectButtonCN;
 if (DselectCN!=null)                  Calendar.DselectCN=DselectCN;
 if (DselectAreaCN!=null)              Calendar.DselectAreaCN=DselectAreaCN;
 if (DselectButtonAreaCN!=null)        Calendar.DselectButtonAreaCN=DselectButtonAreaCN;
 if (DselectButtonCN!=null)            Calendar.DselectButtonCN=DselectButtonCN;
 if (DropDownCN!=null)                 Calendar.DropDownCN=DropDownCN;
 if (DropDownListCN!=null)             Calendar.DropDownListCN=DropDownListCN;
 if (DropDownListItemCN!=null)         Calendar.DropDownListItemCN=DropDownListItemCN;
 if (DropDownListItemMarkedCN!=null)   Calendar.DropDownListItemMarkedCN=DropDownListItemMarkedCN;
 if (DropDownListItemSelectedCN!=null) Calendar.DropDownListItemSelectedCN=DropDownListItemSelectedCN;
 if (inputCN!=null)                    Calendar.inputCN=inputCN;
 if (hdrRowCN!=null)                   Calendar.hdrRowCN=hdrRowCN;
 if (yearRowCN!=null)                  Calendar.yearRowCN=yearRowCN;
 if (monthRowCN!=null)                 Calendar.monthRowCN=monthRowCN;
 if (weekRowCN!=null)                  Calendar.weekRowCN=weekRowCN;
 if (aCN!=null)                        Calendar.aCN=aCN;
}

Calendar.clearDefaultStyles();

function modalWin() {
}

modalWin.count = 0;
modalWin.stack = [];
modalWin.oldOnResize = null;
modalWin.oldOnScroll = null;
modalWin.oldOnContext= null;
modalWin.oldOnClick= null;
modalWin.oldOnDblClick= null;
modalWin.scrollTop = 0;
modalWin.scrollLeft = 0;

modalWin.createCoverLayer = function() {
	var coverLayer;
	coverLayer = document.createElement( "div" );
	var body_height=document.body.clientHeight;
	with( coverLayer ) {
		onclick = modalWin.cancelEvent;
		onmouseover = modalWin.cancelEvent;
		onmouseout = modalWin.cancelEvent;
		with( style ) {
			display = "none";
			position = "absolute";
			left = 0;
			top = 0;
			width = "100%";
			height = body_height+"px";
			zIndex = modalWin.count*2 + 5000;
			opacity = 0.45;
	  		filter = "alpha(opacity=0.45)";
			backgroundColor = "#000000";
		}
	}

	return coverLayer;
}

modalWin.show = function(height) {
	if ( modalWin.count <= 0 ) return;
	var md, val;
	for ( i = modalWin.count - 1; i >= 0; i-- ) {
		md = modalWin.stack[i]["dialog"];
		val = ( Math.round( ( document.body.clientWidth - md.offsetWidth ) / 2 ) + document.body.scrollLeft );
		md.style.left  =  ( val < modalWin.scrollLeft ? modalWin.scrollLeft : val ) + "px";
		var scroll=self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
		var winHeight=document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
		md.style.top=(parseInt(scroll)+(parseInt(winHeight)-parseInt(height))/2)+'px';
//		val = ( Math.round( ( document.body.clientHeight - md.offsetHeight) / 2 ) + document.body.scrollTop )-200;
//		md.style.top  = ( val < modalWin.scrollTop ? modalWin.scrollTop : val ) + "px";
	}
}

modalWin.cancelEvent = function( e ) {
	if ( !e ) e = event;
	e.cancelBubble = true;
	return false;
}

modalWin.open = function( dialog, width, height, useAjax, onCloseFunc, varObj, removeDialogOnClose ) {
	if ( !dialog ) return false;

	modalWin.count++;
        var data = [];
	modalWin.stack.push( data );

	if ( modalWin.count == 1 ) {
		modalWin.oldOnContext = window.oncontextmenu;
		modalWin.oldOnClick = window.onclick;
		modalWin.oldOnDblClick = window.ondblclick;
		modalWin.oldOnResize = window.onresize;
		modalWin.oldOnScroll = window.onscroll;
	}
	var cl = modalWin.createCoverLayer();
	if ( modalWin.count == 1 ) {
		modalWin.scrollTop = document.body.scrollTop;
		modalWin.scrollLeft = document.body.scrollLeft;
	}
        cl = document.body.appendChild( cl );
	data["coverLayer"] = cl;
	data["dialog"] = dialog;
	data["onClose"] = onCloseFunc ? onCloseFunc : null;
	data["varObj"] = varObj ? varObj : null;
	data["remove"] = removeDialogOnClose ? true : false;

	if ( typeof( dialog ) == "string" ) {
		var pos=dialog.indexOf('?');
		var parts=new Array(2);
		parts[0]=dialog.substr(0,pos);
		parts[1]=dialog.substr(pos+1);

		if ( useAjax ) {
			dialog = document.createElement( "table" );
	 		var attr = document.createAttribute( "cellspacing" );
			attr.value = 0;
			dialog.setAttributeNode( attr );
	 		attr = document.createAttribute( "cellpadding" );
			attr.value = 0;
			dialog.setAttributeNode( attr );
			dialog.appendChild( document.createElement( "tbody" ) ).appendChild( document.createElement( "tr" ) ).appendChild( document.createElement( "td" ) );

			dialog.style.position = "absolute";
			dialog.style.left = 0;
			dialog.style.top = 0;
			dialog = document.body.appendChild( dialog );
		        data["dialog"] = dialog;
		        data["remove"] = true;

		        var xln=new XML_Load(parts[0],"POST",parts[1],"TEXT",null);
		        	if(xln.IsReady()) {
		        		xln.OnReady=function(status,list,ldata) {
						if ( modalWin.count <= 0 ) return;

						if ( ldata ) {
							var o = modalWin.stack[modalWin.count - 1]["dialog"].getElementsByTagName( "td" )[0];
							o.innerHTML = ldata;

							var reg = /<script.*?>((?:.|[\r\n])*?)<\/script>/ig;
							reg.lastIndex=0;
							var result;
							if ( window.execScript ) while ( ( result = reg.exec( ldata ) ) != null ) window.execScript( result[1], "javascript" );
							else while ( ( result = reg.exec( ldata ) ) != null ) window.eval( result[1] );

							modalWin.show(height);
						}
						else {
							alert( "Ошибка при запросе диалога!" );
							modalWin.close(); // error - close win
						}
		        		}
		        	xln.Load();
		        }
		}
		else {
			dialog = document.createElement( "iframe" );
	 		var attr = document.createAttribute( "frameborder" );
			attr.value = "no";
			dialog.setAttributeNode( attr );
	 		var attr = document.createAttribute( "scrolling" );
			attr.value = "auto";
			dialog.setAttributeNode( attr );

			dialog.style.width = width;
			dialog.style.height = height;
			dialog.style.position = "absolute";
			dialog.style.left = 0;
			dialog.style.top = 0;
			dialog.src = parts[0]+"?"+parts[1];

			dialog = document.body.appendChild( dialog );

		        data["dialog"] = dialog;
		        data["remove"] = true;
		}
	}

	with( dialog.style ) {
		position = "absolute";
		zIndex = modalWin.count*2 + 1 + 25000;
		top = "-1000px";
		left = "-1000px";
		display = "";
	}

	with( cl.style ) {
		left = document.body.scrollLeft;
		top = document.body.scrollTop;
		display = "block";
	}

	modalWin.show(height);
	dialog.focus();

	window.onresize = function() {
		modalWin.show(height);
	}

	return true;
}

modalWin.close = function( state ) {
	if ( modalWin.count <= 0 ) return false;
	var data = modalWin.stack[modalWin.count - 1];

        if ( data["onClose"] )
		if ( !data["onClose"]( data["varObj"], state ) ) return;

	data["dialog"].style.display = "none";
	if ( data["remove"] ) data["dialog"].parentNode.removeChild( data["dialog"] );

	data["coverLayer"].style.display = "none";
	data["coverLayer"].parentNode.removeChild( data["coverLayer"] );
	modalWin.stack.splice( modalWin.count - 1, 1 );

	if ( modalWin.count == 1 ) {
		window.onresize = modalWin.oldOnResize;
		window.onscroll = modalWin.oldOnScroll;
		window.oncontextmenu = modalWin.oldOnContext;
		window.onclick = modalWin.oldOnClick;
		window.ondblclick = modalWin.oldOnDblClick;
		modalWin.oldOnResize = modalWin.oldOnScroll = null;
		modalWin.scrollTop = 0;
		modalWin.scrollLeft = 0;
	}
	modalWin.count--;

	return true;
}

modalWin.getCur = function() {
	return 	modalWin.count <= 0 ? null : modalWin.stack[modalWin.count - 1];
}

modalWin.getCurDialog = function() {
	return 	modalWin.count <= 0 ? null : modalWin.stack[modalWin.count - 1]["dialog"];
}

modalWin.getCurVO = function() {
	return 	modalWin.count <= 0 ? null : modalWin.stack[modalWin.count - 1]["varObj"];
}

modalWin.openByDialog = function( dialog, onCloseFunc, varObj, removeDialogOnClose ) {
	return modalWin.open( dialog, null, null, null, onCloseFunc, varObj, removeDialogOnClose );
}

modalWin.openByAjax = function( url, onCloseFunc, varObj, removeDialogOnClose ) {
	return modalWin.open( url, null, null, true, onCloseFunc, varObj, removeDialogOnClose );
}

modalWin.openByIFrame = function( url, width, height, onCloseFunc, varObj, removeDialogOnClose ) {
	return modalWin.open( url, width, height, false, onCloseFunc, varObj, removeDialogOnClose );
}

function validateInt(name,field) {
 var f=document.getElementById(field);
 f.style.backgroundColor="#FFFFFF";
 if(!f.value) return;
 if(parseInt(f.value)!=f.value) f.style.backgroundColor="#FF0000";
 }

function validateDouble(name,field) {
 var f=document.getElementById(field);
 f.style.backgroundColor="#FFFFFF";
 if(!f.value) return;
 if(parseFloat(f.value)!=f.value) f.style.backgroundColor="#FFDDDD";
 }

function validateDay(name,field,month) {
 var f=document.getElementById(field);
 f.style.backgroundColor="#FFFFFF";
 if(!f.value) return;
 if(parseInt(f.value)!=f.value) f.style.backgroundColor="#FFDDDD";
 if((f.value<0)||(f.value>31)) f.style.backgroundColor="#FFDDDD";
 var m=document.getElementById(month).value;
 if(((m==4)||(m==6)||(m==9)||(m==1))&&(f.value>30)) f.style.backgroundColor="#FFDDDD";
 if((m==2)&&(f.value>29)) f.style.backgroundColor="#FFDDDD";
 }

function validateHour(name,field) {
 var f=document.getElementById(field);
 f.style.backgroundColor="#FFFFFF";
 if(!f.value) return;
 if(parseInt(f.value)!=f.value) f.style.backgroundColor="#FFDDDD";
 if((f.value<0)||(f.value>23)) f.style.backgroundColor="#FFDDDD";
 }

function validateMinute(name,field) {
 var f=document.getElementById(field);
 f.style.backgroundColor="#FFFFFF";
 if(!f.value) return;
 if(parseInt(f.value)!=f.value) f.style.backgroundColor="#FFDDDD";
 if((f.value<0)||(f.value>59)) f.style.backgroundColor="#FFDDDD";
 }

