//
//  DymDom - dom based crossbrowser calendar
//  version 1.0.1
//
// -you can't use this code or it's any part without author agreement
// -вы не имеете право использовать данный скрипт или его любую часть 
//	в коммерческих разработках и проектах(с целью получения прибыли) без согласия автора.
// -для использования в свободных проектах и разработках для личного пользования
//  условий и ограничений на использование скрипта нет.
//
//  author: ethan hunt email: ethanhunt@newmail.ru
//  date: 21.09.2004
//
//	когда нибудь наверное наступят времена, что позволят писать web проекты без оглядки на совместимость с браузерами.
//	я хотел написать что-то без постоянных оглядок типа - "Ето кто, а Вы Мозилыч, ну тогда сделаем так".
//	но не все получилось(подключение событий, некоторые глюки с собственным мнением браузеров на то как что-то надо делать(css) и т.д.).
//
//	I like w3c[http://www.w3.org/](интересно то, сколько там документов с соавторством сотрудников из Microsoft).
//
/////////////////////////////////////////////////////////////////////////////
//    global variables
if(!bw)	var bw = new bwl();
var aLangs="rus,eng,ukr";
var bUseCapture=false;
var arrMnmRes = {rus:"Январь,Февраль,Март,Апрель,Май,Июнь,Июль,Август,Сентябрь,Октябрь,Ноябрь,Декабрь",
								 eng:"January,February,March,April,May,June,July,August,September,October,November,December",
								ukr:"Січень,Лютий,Березень,Квітень,Травень,Червень,Липень,Серпень,Вересень,Жовтень,Листопад,Грудень"};
var arrMnmDec = {rus:"Января,Февраля,Марта,Апреля,Майя,Июня,Июля,Августа,Сентября,Октября,Ноября,Декабря".split(","),
								 eng:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),
								 ukr:"Січня,Лютого,Березня,Квітня,Травня,Червня,Липня,Серпня,Вересня,Жовтня,Листопада,Грудня".split(",")};
var arrDnmRes = {rus:"Пн,Вт,Ср,Чт,Пт,Сб,Вс",
								 eng:"Mn,Tu,Wd,Th,Fr,St,Su",
								ukr:"Пн,Вт,Ср,Чт,Пт,Сб,Нд"};
var arrEwords = {rus:{cur:"выбрано"},
								 eng:{cur:"selected"},
								ukr:{cur:"вибрано"}};
/////////////////////////////////////////////////////////////////////////////
//    service function
function zAttachEvent(eo,ef,et){
	if(typeof(ep)!="object" || typeof(ef)!="function" || typeof(et)!="string") return;
	try{
		if(bw.ie6){
			eo.attachEvent(et,ef);
		}else if(bw.ns6){
			eo.addEventListener(et,ef,false);
		}else if(bw.op7){
			eo.attachEvent(et,ef);
		}
	}catch(e){var st="exception ";for(var i in e)st+=(i+"="+e[i]+"<br>");alert(st);}	
}
function zGetObjByID(hObj){
	if(zIsObject(hObj))	return hObj;
	if(!zIsString(hObj))	return null;
	return ((bw.ie||bw.op)?document.all[hObj]:document.getElementById(hObj));
}
function zGetEventSrcObj(e){
	var obj;
	try{
		if(bw.ie){
			if(!e) e=event;
			obj=e.srcElement;
		}else if(bw.ns6){
			obj=e.target;
		}else if(bw.op7){
			obj=e.target;
		}
	}catch(e){var st="exception ";for(var i in e)st+=(i+"="+e[i]+"<br>");alert(st);}
	return obj;
}
//////////////////////////////////////////////////////////////////////////////
//
//	oParent may be:
//		object - for static link created calendar
//		string - for absolute positioning, string format - "top:100px;left:100px;"
//	lang - what language to use
//
function zDymDom(oParent,slang,sdf,sdv,fwd){
	this.oElement=null;
	this.szDateFormat=(!sdf || sdf==undefined)?"d/m/y":sdf;
	this.lang=(!slang || slang==undefined || (aLangs.indexOf(slang)==-1))?"rus":slang;
	//
	this.szDateVal=sdv;
	this.m_nmYear;	this.m_nmDay;	this.m_nmMonth; // cash current calendar values
	//
	this.fwd=(!fwd || fwd==undefined || fwd<1 || fwd>7)?0:fwd-1;
	this.postID=0;
	this.doc=null;;
	var __this=this;
	// cash objects for speed
	this.oParent=oParent;
	this.oElementStyle={position:"static"};
	this.oSelMonth=null;this.oSelYear=null;
	this.oTdHeader=null;this.oTdFooter=null;this.oTdBody=null;
	this.oTable=null;
	// jewels :-)
	this.szID = null;
	this.arrMnm = null;
	this.arrDnm = null;
	//
	this.tmplTblMain = {
		TABLE:{
			attr:{id:"ctable",cellSpacing:"0",border:"0"},
			tags:{
				TBODY:{
					tags:{
						TR_1:{attr:{id:""},
							tags:{
								TD_1:{attr:{id:"cheader",align:"center",valign:"middle",className:"clsheader"}}
							}
						},
						TR_2:{attr:{id:""},
							tags:{
								TD_2:{attr:{id:"cbody",align:"center",valign:"middle",className:"clsbody"}}
							}
						},
						TR_3:{attr:{id:""},
							tags:{
								TD_3:{attr:{id:"cfooter",align:"center",valign:"middle",className:"clsfooter"}}
							}
						}						
					}
				}
			}
		}
	};
	this.tmplHeader = {
		TABLE:{
			attr:{id:"ctable",cellPadding:"0",cellSpacing:"0",className:"",border:"0"},
			tags:{
				TBODY:{
					tags:{
						TR_1:{
							attr:{id:""},
							tags:{
								TD_1:{
									attr:{align:"center",valign:"middle",id:"decMonth",className:"clsbtn",cstext:"\u003C"}
								},
								TD_2:{
									attr:{align:"center",valign:"middle",colspan:"5"},
									tags:{
										SELECT_1:{attr:{id:"selMonth"}},
										SELECT_2:{attr:{id:"selYear"}}
									}
								},
								TD_3:{
									attr:{align:"center",valign:"middle",id:"incMonth",className:"clsbtn",cstext:"\u003E"}
								}
							}
						}
					}
				}
			}
		}
	};
	////////////////////////////////////////////////////////////////////////////////////////////////////
	this.onChange=function(e){
		var oe=zGetEventSrcObj(e);
		var szID=oe.id;szID=(!szID || szID==""?"":szID.substr(0,szID.length-__this.postID.toString().length));			
		switch (oe.tagName.toLowerCase()){
			case "select":
				switch (szID){
					case "selYear":
						__this.m_nmYear=parseInt(oe.value,10);__this.createCalendar();
						break;
					case "selMonth":
						__this.m_nmMonth=parseInt(oe.value,10);__this.createCalendar();
						break;
				}
				break;
		}
		if(!bw.op)return false;
	}
	this.onMouseOver = function(e){
		var oe = zGetEventSrcObj(e);
		switch (oe.tagName.toLowerCase()){
			case "td":
				if (oe.className.indexOf("datecel")!=-1){
					if(!(/ cur\s?/.test(oe.className)))	oe.className+=" cur ";
				}else if(oe.className.indexOf("clsbtn")!=-1){
					oe.className="clsbtnup";
				}
				break;
		}
		if(!bw.op)return false;		
	}
	this.onMouseOut=function(e){
		var oe = zGetEventSrcObj(e);
		switch (oe.tagName.toLowerCase()){
			case "td":
				if (oe.className.indexOf("datecel")!=-1){
					if((/ cur\s?/.test(oe.className)))	oe.className=oe.className.replace(/ cur\s?/,"");
				}else if(oe.className.indexOf("clsbtn")!=-1){
					oe.className="clsbtn";
				}
			break;
		}
		if(!bw.op)return false;
	}
	this.onMouseDown=function(e){
		var oe = zGetEventSrcObj(e);
		switch (oe.tagName.toLowerCase()){
			case "td":
				if(oe.className.indexOf("clsbtn")!=-1){
					oe.className="clsbtndown";
				}
			break;
		}
		if(!bw.op)return false;
	}
	this.onMouseUp=function(e){
		var oe = zGetEventSrcObj(e);
		switch (oe.tagName.toLowerCase()){
			case "td":
				if(oe.className.indexOf("clsbtn")!=-1){
					oe.className="clsbtnup";
				}
			break;
		}
		if(!bw.op)return false;
	}
	this.onClick=function(e){
		var oe = zGetEventSrcObj(e);
		var szID=oe.id;szID=(!szID || szID==""?"":szID.substr(0,szID.length-__this.postID.toString().length));			
		switch (oe.tagName.toUpperCase()){
			case "TD":
				if (oe.className.indexOf("datecel")!=-1){
					var sday=bw.ns6?oe.dateval:oe.getAttribute("dateval");
					__this.m_nmDay=parseInt(sday,10);;__this.setSelectedDate();__this.createCalendar();
				}else{
					switch (szID){
						case "decMonth":
							__this.changeMonth(-1);__this.createCalendar();__this.syncHeader();
							break;
						case "incMonth":
							__this.changeMonth(1);__this.createCalendar();__this.syncHeader();						
							break;					
					}
				}
				break;
		}
		if(!bw.op)return false;
	}
	this.crtElementDom=function(tmpl,obj){
		if(!tmpl) return;
		var ort=null;var sz="";
		var mar=new Array();for(var i in tmpl){mar[mar.length]=i;};mar.sort();
		//for(var i in tmpl){ // fucked Opera not work propertly with this fuck,fuck,fuck...
		for(var ii=0;ii<mar.length;ii++){
			var i=mar[ii];
			sz=(i.indexOf("_")!=-1?i.substr(0,i.indexOf("_")):i);
			ort=document.createElement(sz);if(obj)obj.appendChild(ort);
			for(var j in tmpl[i]){
				switch(j){
					case "attr":
						for(var z in tmpl[i][j]){
							if(typeof(ort[z])=="object"){
								switch(z){
									case "style":
										var s=tmpl[i][j][z];var re = new RegExp("(.)(-)(.)","");
										while(re.test(s)){s=s.replace(re,RegExp.$1+RegExp.$3.toUpperCase());}
										var sar=s.split(";");
										for(var ci=0;ci<sar.length;ci++){
											if(sar[ci]!=""){
												var ssar=sar[ci].split(":");
													ort[z][ssar[0]]=ssar[1];
											};
										}
										break;
									default:;
								}
							}else{
								switch(z){
									case "cstext":ort.appendChild(document.createTextNode(tmpl[i][j][z]));break;
									case "id":/*ort[z]=(tmpl[i][j][z]+this.postID);*/ort.setAttribute(z,tmpl[i][j][z]+this.postID);break;
									default:if(!bw.ns6){ort.setAttribute(z,tmpl[i][j][z]);}else{ort[z]=tmpl[i][j][z];}
								}
							}
						}
						break;
					case "tags":
						this.crtElementDom(tmpl[i][j],ort);
						break;
				}
			}
		}
		if(!obj)return ort;
	}
	this.createMno=function(){
		var os=this.oSelMonth;if(!os)return;
		for(var i=1;i<=this.arrMnm.length;i++)os.options[os.options.length] = new Option(this.arrMnm[i-1],i);
		return;
	}
	this.createYro=function(){
		var os=this.oSelYear;if(!os)return;
		for (var i=1900;i<2100;i++)os.options[os.options.length] = new Option(i,i);
		return;
	}	
	this.getWeekDay = function(fdow,dateVal){
		return (6 + dateVal.getDay() - fdow)%(7);
	}
	this.isDate = function(dateValue){
		var dateSequence = this.szDateFormat.toLowerCase().replace(/[^ymd]/g,'')
		var objRegExp = /^\d{1,4}( |-|\/|\.)\d{1,4}\1\d{1,4}$/
		if(!objRegExp.test(dateValue))
			return false
		var arrayDate = dateValue.split(RegExp.$1); //split date into month, day, year
		var intDay = parseInt(arrayDate[dateSequence.indexOf('d')],10); 
		var intMonth = parseInt(arrayDate[dateSequence.indexOf('m')],10);
		var intYear = parseInt(arrayDate[dateSequence.indexOf('y')],10);
		if (intYear < 30)	intYear+=2000
		if (intYear < 100)	intYear+=1900	
		var d = new Date( intYear, intMonth-1, intDay )
		if ( (d.getFullYear() != intYear) ||  (d.getMonth() != intMonth-1)  || (d.getDate() != intDay) || (intYear < 1000) ) 
			return false
		return true
	}
	this.getDatePart=function(part, dateValue){
		var ds = this.szDateFormat.toLowerCase().replace(/[^ymd]/g,'');
		var re = /^\d{1,4}( |-|\/|\.)\d{1,4}\1\d{1,4}$/;
		re.test(dateValue);
		var ad = dateValue.split(RegExp.$1); //split date into month, day, year
		return parseInt(ad[ds.indexOf(part)],10);
	}
	this.setDatePart=function(part, dateValue, partValue){
		var ds = this.szDateFormat.toLowerCase().replace(/[^ymd]/g,'')
		var re = /^\d{1,4}( |-|\/|\.)\d{1,4}\1\d{1,4}$/
		re.test(dateValue)
		var ad = dateValue.split(RegExp.$1); //split date into month, day, year
		ad[ds.indexOf(part)]=partValue;
		this.szDateVal=ad.join(RegExp.$1);
	}
	this.cashDate=function(){
		this.m_nmMonth=parseInt(this.getDatePart('m',this.szDateVal),10);
		this.m_nmYear=parseInt(this.getDatePart('y',this.szDateVal),10);
		this.m_nmDay=parseInt(this.getDatePart('d',this.szDateVal),10);
	}
	this.setSelectedDate=function(){
		this.setDatePart("d",this.szDateVal,this.m_nmDay);
		this.setDatePart("m",this.szDateVal,this.m_nmMonth);
		this.setDatePart("y",this.szDateVal,this.m_nmYear);
	}
	this.syncHeader=function(){
		while(this.oSelMonth.value!=this.m_nmMonth)	this.oSelMonth.value = this.m_nmMonth;
		while(this.oSelYear.value!=this.m_nmYear)	this.oSelYear.value = this.m_nmYear;
	}
	this.changeMonth=function(adj){
		this.m_nmMonth += adj;
		if(this.m_nmMonth == 13){this.m_nmMonth = 1;this.m_nmYear += 1;}
		if(this.m_nmMonth == 0){this.m_nmMonth = 12;this.m_nmYear -= 1;}
	}
	this.createCalendar = function(){
		var d = new Date(); 					// get current date
		var tDay=d.getDate(),tMonth=d.getMonth()+1,tYear=d.getFullYear();
		var sDay=parseInt(this.getDatePart('d',this.szDateVal),10),sMonth=parseInt(this.getDatePart('m',this.szDateVal),10),sYear=parseInt(this.getDatePart('y',this.szDateVal),10);
		d.setDate(1);									// set day to first day of month
		d.setMonth(this.m_nmMonth-1);	// set current month 
		d.setFullYear(this.m_nmYear); 		// set current year
		var firstDay,lastDay;
		var mArr=new Array(6);
		for(var i=0;i<mArr.length;i++) mArr[i]=new Array(7);
		for(var day=1;day<32;day++){
			d.setDate(day);
			if(day == 1)	firstDay=this.getWeekDay(this.fwd,d);
			if((d.getMonth()+1) == this.m_nmMonth){
				var weekNo = parseInt(((( firstDay + day - 1 ) /7 )*1));
				mArr[weekNo][this.getWeekDay(this.fwd,d)] = d.getDate();
				lastDay = day;
			}
		}
		if(parseInt(this.m_nmDay,10)>lastDay){this.m_nmDay=lastDay};
		////////
		var sid="",scls="";
		var tnb={TABLE:{attr:{id:"tst2",cellPadding:"0",cellSpacing:"1",style:"width:100%;heght=100%;",border:"0"}}};
		tnb["TABLE"]["tags"]={TBODY:""};
		tnb["TABLE"]["tags"]["TBODY"]={tags:{TR_H:""}};
		tnb["TABLE"]["tags"]["TBODY"]["tags"]["TR_H"]={tags:""};
		tnb["TABLE"]["tags"]["TBODY"]["tags"]["TR_H"]["tags"]=new Object();
		for(var i=0;i<this.arrDnm.length;i++)
			tnb["TABLE"]["tags"]["TBODY"]["tags"]["TR_H"]["tags"]["TH_"+i]={attr:{style:"width:14%",	cstext:this.arrDnm[(i+this.fwd)%(7)]}};
		for(var i=0;i<mArr.length;i++){
			if(typeof(mArr[i][0])=="undefined" && i!=0) break;
			tnb["TABLE"]["tags"]["TBODY"]["tags"]["TR_H_"+i]={tags:""};
			tnb["TABLE"]["tags"]["TBODY"]["tags"]["TR_H_"+i]["tags"]=new Object();
			for(var j=0;j<mArr[i].length;j++){
				if(typeof(mArr[i][j])=="undefined")
					tnb["TABLE"]["tags"]["TBODY"]["tags"]["TR_H_"+i]["tags"]["TD_"+i+j]={attr:{className:"dataempty",cstext:"\u0020"}}
				else{
					if(this.m_nmYear==sYear && this.m_nmMonth==sMonth && mArr[i][j]==sDay){
						scls="datecell sel";sid="cselday"+this.postID;
					}else	if(this.m_nmYear==tYear && this.m_nmMonth==tMonth && mArr[i][j]==tDay){
						scls="datecell today";sid="ctoday"+this.postID;
					}else{
						scls=(((j+this.fwd)%(7)==5 || (j+this.fwd)%(7)==6)?"datecell we":"datecell");sid="";
					}
					tnb["TABLE"]["tags"]["TBODY"]["tags"]["TR_H_"+i]["tags"]["TD_"+i+j]={attr:{id:sid,className:scls,dateval:mArr[i][j],cstext:mArr[i][j]}};
				}
			}
		}
		var cn,ot;
		cn=this.oTdBody.childNodes[0];if(cn) this.oTdBody.removeChild(cn);
		this.crtElementDom(tnb,this.oTdBody);
		tn = document.createTextNode(innerText = " "+arrEwords[this.lang]["cur"]+" - " + sDay + " " + arrMnmDec[this.lang][sMonth-1] + " " +sYear);
		cn=this.oTdFooter.childNodes[0];if(cn) this.oTdFooter.removeChild(cn);
		this.oTdFooter.appendChild(tn);
		//this.oElement.style.width=(parseInt(this.oTable.offsetWidth,10)+(bw.op?0:0))+"px";
	}
	this.initialise = function(){
		//
		this.doc=window.document;
		if(!this.doc.body || !bw.dom)	return;
		if(!this.oParent) this.oParent=this.doc.body;
		if(typeof(this.oParent)=="string"){
			this.oElementStyle["position"]="absolute";
			var at=this.oParent.split(";");
			for(var i=0;i<at.length;i++){
				if(at[i]!=""){
					var att=at[i].split(":");
					this.oElementStyle[att[0]]=att[1];
				}
			}
			this.oParent=this.doc.body;
		}
		for(this.postID=0;this.postID<100;this.postID++){if(!this.doc.getElementById("cdiv"+this.postID))break;};
		this.arrMnm = arrMnmRes[this.lang].split(',');
		this.arrDnm = arrDnmRes[this.lang].split(',');
		//
		this.oElement = this.doc.createElement("DIV");this.oElement.className="caliv";this.oElement.id="cdiv"+this.postID;
		for(var i in this.oElementStyle){
			//alert(i+"="+this.oElementStyle[i]);alert(this.oElement.style[i]);
			this.oElement.style[i]=this.oElementStyle[i];
		}
		if(!this.oElement) return;
		this.oParent.appendChild(this.oElement);
		this.crtElementDom(this.tmplTblMain,this.oElement);
		this.oTable=this.doc.getElementById("ctable"+this.postID);
		this.oTdHeader=this.doc.getElementById("cheader"+this.postID);this.oTdBody=this.doc.getElementById("cbody"+this.postID);this.oTdFooter=this.doc.getElementById("cfooter"+this.postID);
		this.crtElementDom(this.tmplHeader,this.doc.getElementById("cheader"+this.postID));
		this.oSelMonth=this.doc.getElementById("selMonth"+this.postID);this.oSelYear=this.doc.getElementById("selYear"+this.postID);
		this.createMno();this.createYro();
		if(bw.ns6 && this.oElementStyle["position"]!="absolute"){this.oTdHeader.style.width=(parseInt(this.oTdHeader.clientWidth,10)-2)+"px";}
		if(!this.isDate(this.szDateVal)){
			var d = new Date();var s=d.toUTCString();
			this.m_nmDay=d.getDate();this.m_nmMonth=d.getMonth()+1;this.m_nmYear=d.getFullYear();
			this.szDateVal = "01/01/1990";
			this.setSelectedDate();
		}
		this.cashDate();
		this.createCalendar();
		this.syncHeader();//this.syncHeader();
		//if(bw.ie6)window.clipboardData.setData("Text",this.oElement.outerHTML);
		// attach events
		if(bw.ns6){this.oElement.addEventListener("mousemove",this.onMouseOver,bUseCapture)}
		else{this.oElement.attachEvent("onmouseover",this.onMouseOver);}
		if(bw.ns6){this.oElement.addEventListener("mouseout",this.onMouseOut,bUseCapture)}
		else{this.oElement.attachEvent("onmouseout",this.onMouseOut);}
		if(bw.ns6){this.oElement.addEventListener("mousedown",this.onMouseDown,bUseCapture)}
		else{this.oElement.attachEvent("onmousedown",this.onMouseDown);}
		if(bw.ns6){this.oElement.addEventListener("mouseup",this.onMouseUp,bUseCapture)}
		else{this.oElement.attachEvent("onmouseup",this.onMouseUp);}
		if(bw.ns6){this.oElement.addEventListener("click",this.onClick,bUseCapture)}
		else{this.oElement.attachEvent("onclick",this.onClick);}
		if(bw.ns6){this.oSelMonth.addEventListener("change",this.onChange,bUseCapture)}
		else{this.oSelMonth.attachEvent("onchange",this.onChange);}
		if(bw.ns6){this.oSelYear.addEventListener("change",this.onChange,bUseCapture)}
		else{this.oSelYear.attachEvent("onchange",this.onChange);}
	}
	this.initialise();	
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// CheckBrowser object    original idea Thomas Brattli (www.bratta.com)
function bwl(){
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent.toLowerCase()
	this.dom=document.getElementById?1:0
	this.ns4=(!this.dom && document.layers)?1:0;
	this.op=window.opera 
	this.moz=(this.agent.indexOf("gecko")>-1 || window.sidebar)
	this.ie=this.agent.indexOf("msie")>-1 && !this.op
	if(this.op){
		this.op5=(this.agent.indexOf("opera 5")>-1 || this.agent.indexOf("opera/5")>-1)
		this.op6=(this.agent.indexOf("opera 6")>-1 || this.agent.indexOf("opera/6")>-1)
		this.op7=this.dom&&!this.op5&&!this.op6 //So all higher opera versions will use it
	}else if(this.moz) this.ns6 = 1;
	else if(this.ie){
		this.ie4 = !this.dom && document.all
  	this.ie5 = (this.agent.indexOf("msie 5")>-1)
  	this.ie55 = (this.ie5 && this.agent.indexOf("msie 5.5")>-1)
  	this.ie6 = this.dom && !this.ie4 && !this.ie5 && ! this.ie55
	}
	//this.mac=(this.agent.indexOf("mac")>-1)
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.op5 || this.op6 || this.op7)
  //this.usedom= this.ns6||this.op7//Use dom creation
  //this.reuse = this.ie||this.op7||this.usedom //Reuse layers
  this.px=this.dom&&!this.op5?"px":""
	return this
}
// apend style rules
var szStyle1="<style>"+
"div.caliv{border: 1px ridge #0099CC;}"+
"div.caliv td {font-family:Tahoma;color:black;font-size:8pt;text-align:center;}"+
"div.caliv th{font-family:arial;background-color:steelblue;color:white; font-size:8pt}"+
"div.caliv td.clsfooter{background-color: #BBD6BC;}"+
"div.caliv td.clsheader{background-color:#6699CC;color:white;padding-top: 3px;padding-bottom: 3px;padding-right: 2px;padding-left: 2px;}"+
"div.caliv button{width:15px;}"+
"div.caliv select{font-family:arial;font-size:8pt;}"+
"div.caliv td.clsbody td{border: 1px none solid;}"+
"div.caliv td.clsbody td.datecell{color: Black;border: 1px solid gainsboro;cursor: pointer;}"+
"div.caliv td.clsbody td.today{background-color: #CCFFFF;border: 1px solid #FFCC99;}"+
"div.caliv td.clsbody td.sel{background-color: #B0C4DE;border: 1px solid Red;}"+
"div.caliv td.clsbody td.we {color: Red;border: 1px solid gainsboro;font-weight: normal;}"+
"div.caliv td.clsbody td.cur{border: 1px solid #336699;background-color: #99FF99;}"+
"</style>";
var szStyle2="<style>"+
"div.caliv{border: 1px ridge #0099CC;background-color:#F7F7F7;}"+
"div.caliv table{background-color:#F0F0F0;}"+
"div.caliv td{font-family:Tahoma;color:black;font-size:8pt;text-align:center;background-color:#F0F0F0;}"+
"div.caliv th{font-family:arial;background-color:steelblue;color:white; font-size:8pt}"+
/* ----------------- footer -----------------*/
"div.caliv td.clsfooter{background-color: #BBD6BC;}"+
/* ----------------- header -----------------*/
"div.caliv td.clsheader{background-color:#6699CC;color:white;padding-top: 3px;padding-bottom: 3px;padding-right: 2px;padding-left: 2px;}"+
"div.caliv td.clsheader table{background-color:#6699CC;}"+
"div.caliv td.clsheader table td{text-align: center;vertical-align: middle;padding-bottom:1px;}"+
"div.caliv td.clsheader table td.clsbtn{background-color: #6699CC;border: 2px solid #E0E0E0;cursor: pointer;cursor: hand;padding-left:3px;padding-right:3px;}"+
"div.caliv td.clsheader table td.clsbtnup{background-color: #E0E0E0;border-top: 2px outset #F0F0F0;border-left: 2px outset #F0F0F0;border-right: 2px outset #E0E0E0;"+
"	border-bottom: 2px outset #E0E0E0;cursor: pointer;cursor: hand;padding-left:3px;padding-right:3px;}"+
"div.caliv td.clsheader table td.clsbtndown{background-color: #E0E0E0;border-top: 2px inset #E0E0E0;border-right: 2px inset #E0E0E0;border-bottom: 2px inset #E0E0E0;"+
"	border-left: 2px inset #E0E0E0;cursor: pointer;cursor: hand;padding-left:3px;padding-right:3px;}"+
"div.caliv td.clsheader select{font-family:Verdana, Arial, Helvetica, sans-serif;"+
"	font-size:10px;cursor:pointer;background-color:#F7F7F7;}"+
/* ----------------- body -----------------*/
"div.caliv td.clsbody table{background-color:gainsboro;}"+
"div.caliv td.clsbody td{}"+
"div.caliv td.clsbody td.dataempty{background-color:#FFFFFF;}"+
"div.caliv td.clsbody td.datecell{color: Black;cursor: pointer;cursor: hand;background-color:#FFFFFF;}"+
"div.caliv td.clsbody td.today{background-color: #CCFFFF;}"+
"div.caliv td.clsbody td.sel{background-color: #B0C4DE;}"+
"div.caliv td.clsbody td.we {color: Red;font-weight: normal;}"+
"div.caliv td.clsbody td.cur{background-color: #99FF99;}"+
"</style>"
document.writeln(szStyle2);
