	

function Active(what){
	what.style.backgroundColor='#f0f0f0';
}
	
function NotActive(what){
	what.style.backgroundColor='';
}


function change_ico_imprezy(sel){
	var value=sel.options[sel.selectedIndex].value;
	var img=value.split("*")	
	if(img[0]==''){
		document.getElementById('view_ico').src='files/imprezy/baza/ico/00000000000000.jpg';
	}else{
		document.getElementById('view_ico').src='files/imprezy/baza/ico/'+img[1];
	}
}
function change_img_imprezy(sel){
	var value=sel.options[sel.selectedIndex].value;
	var img=value.split("*")	
	if(img[0]==''){
		document.getElementById('view_img').src='files/imprezy/baza/org/00000000000000.jpg';
	}else{
		document.getElementById('view_img').src='files/imprezy/baza/org/'+img[1];
	}
}



function InitCalendar(rr,mm,dd){

	cld_BlaTek.D=new Date(rr,mm-1,dd);
	cld_BlaTek.M=mm-1;
	cld_BlaTek.R=rr;

}



function Calendar(E,T){

if(!document.getElementById||!document.body.appendChild)return;
	var offset=0;
	if (window.pageYOffset){
		offset=window.pageYOffset;
	}else{
		offset=(document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	}
	var posX=findPosX(T)+100;
	var posY=findPosY(T)+10;
	document.getElementById(E).style.top=posY+'px';
	document.getElementById(E).style.left=posX+'px';


	
	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';
		}
		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){
				T.value=R+'-'+((t=M+1)<10?'0'+t:t)+'-'+(x<10?'0'+x:x);
			}
		}
		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';
			NotActive(T);
		}
	cld_BlaTek.B=1;
	E.style.display='block';


}


cld_BlaTek={
		day:['pn','wt','śr','cz','pt','so','n'],
		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()

		
}



function findPosX(obj){
	var posLeft = 0;
	if(obj.offsetParent){
		while( true ){
			posLeft += obj.offsetLeft;
			if(!obj.offsetParent){
				break;
			}
			obj = obj.offsetParent;
		}
	}else if(obj.x){
		posLeft += obj.x;
	}
return posLeft;
}

function findPosY(obj){
	var posTop = 0;
	if(obj.offsetParent){
		while(true){
			posTop += obj.offsetTop;
			if(!obj.offsetParent){
				break;
			}
			obj = obj.offsetParent;
		}
	}else if(obj.y)
		posTop += obj.y;
 return posTop;
}
