
function CheckDate2(Od,Do) {
	var d1 = Od.split("-");
	var d2 = Do.split("-");
	var dat1 = (d1[0]+d1[1]+d1[2])*1;
	var dat2 = (d2[0]+d2[1]+d2[2])*1;
	if(dat1>dat2) return false;
	else return true;
}

function ShowMessage(txt,pid) {
	var pole = document.getElementById("MessagePlace");
	if(txt.length>0) pole.innerHTML = "<div>"+txt+"</div>";
	else pole.innerHTML = "";
	return false;
}

function CheckDate(date)
{
var monthLength = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
d = date.split("-");
if(d.length==3) {
	
	year = d[0]*1;
	month = d[1]*1;
	day = d[2]*1;
	
	if (isNaN(day)||isNaN(month)||isNaN(year)) return false;

	if (year/4 == parseInt(year/4))
		monthLength[1] = 29;

	if (day > monthLength[month-1]) return false;

	monthLength[1] = 28;
	
	return true;
	
}else return false;

}

/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */

//Written by Bogdan Blaszczak/BlaTek
//blatek@25.pl
function Calendar(E,T){
 if(!document.getElementById||!document.body.appendChild)return
 var i,j,tBody,Row,od,Do,d,dt
 function cEl(t,p,h,w){
  p.appendChild(t=document.createElement(t))
  if(h)t.innerHTML=h;if(w)t.style.width='27px'
  t.style.color='black'	
  return t}
 function cB(x){with(cld_BlaTek){
  B=0;x==0?R--:x==1?R++:x==2?(!M?(M=11,R--):M--):(M==11?(M=0,R++):M++)}
 }
 with(cld_BlaTek){
  od=Date.UTC(R,M,1);Do=Date.UTC(R,M+1,1)}
 E=document.getElementById(E)
 while(E.childNodes.length)E.removeChild(E.firstChild)
 tBody=cEl('tbody',cEl('table',E))
 tBody.onmouseup=function(){T.focus()}
 tBody.onmousemove=function(){
  if(window.getSelection)window.getSelection().removeAllRanges()}
 Row=cEl('tr',tBody)
 cEl('td',Row,'&#171;',1).onmousedown=function(){cB(0)}
 cEl('th',Row,cld_BlaTek.R)
 cEl('td',Row,'&#187;',1).onmousedown=function(){cB(1)}
 Row=cEl('tr',tBody)
 cEl('td',Row,'&#171;',1).onmousedown=function(){cB(2)}
 cEl('th',Row,cld_BlaTek.month[cld_BlaTek.M])
 cEl('td',Row,'&#187;',1).onmousedown=function(){cB(3)}

 tBody=cEl('tbody',cEl('table',E))
 Row=cEl('tr',tBody)
 for(i=0;i<7;i++)
  with(cEl('th',Row,cld_BlaTek.day[i]))
   if(i==6)style.backgroundColor='#f88'

 for(i=od;i<Do;i+=86400000){
  with(new Date(i)){d=getUTCDate();dt=getUTCDay()}
  if(dt==1||i==od)Row=cEl('tr',tBody)
  if(dt!=1&&d==1)for(j=1;j<(dt?dt:7);j++)cEl('th',Row)
  dt=cEl('td',Row,d);dt.onmousedown=function(x){
   x=+this.innerHTML
   with(cld_BlaTek) {
	Mon = ((y=M+1)<10?'0'+y:y)
	Day = (x<10?'0'+x:x)
	//T.value=Day+'-'+Mon+'-'+R
	T.value=R+'-'+Mon+'-'+Day
	}
  }
  with(cld_BlaTek)
  if(d==D.getDate()&&M==D.getMonth()&&R==D.getFullYear())
   dt.style.backgroundColor='#fff'
 }
 T.onblur=function(){if(cld_BlaTek.B)E.style.display='none'}
 cld_BlaTek.B=1;E.style.display='block'
}


//global object (You can translate month&day names)
cld_BlaTek={
 day:['pn','wt','śr','cz','pt','so','nd'],
 month:['styczeń','luty','marzec','kwiecień','maj','czerwiec', 'lipiec','sierpień','wrzesień','październik','listopad','grudzień'],
 D:new Date(),M:new Date().getMonth(),R:new Date().getFullYear()
}
