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'
  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='#ffd9d3'

 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=(x<10?'0'+x:x)+'-'+((x=M+1)<10?'0'+x:x)+'-'+R
    T.value=R+'-'+((y=M+1)<10?'0'+y:y)+'-'+(x<10?'0'+x:x)
  }
  with(cld_BlaTek)
  if(d==D.getDate()&&M==D.getMonth()&&R==D.getFullYear())
   dt.style.backgroundColor='#d0d0d0'
 }
 T.onblur=function(){if(cld_BlaTek.B)E.style.display='none'}
 cld_BlaTek.B=1;E.style.display='block'
}

cld_BlaTek={
 day:['pn','wt','śr','cz','pt','so','ni'],
 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()
}


// JavaScript Document

var monthLength = new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
var monthNames = new Array("dowolny", "styczeń", "luty", "marzec", "kwiecień", "maj", "czerwiec", "lipiec", "sierpień", "wrzesień", "październik", "listopad", "grudzień");

var finderMonth = 100;
var finderMonthTo = 100;
var finderDay = 100;
var finderDayTo = 100;


function newCheck(indexFinderMonth, indexFinderDay, formName, dayName, monthName, any) {
  
  if (any == true) {
    toIndexMonth = indexFinderMonth;
    toIndexDay = indexFinderDay - 1;
  } else {
    toIndexMonth = indexFinderMonth - 1;
    toIndexDay = indexFinderDay - 1;
  }
  eval("document."+formName+"."+monthName+".options.selectedIndex = "+toIndexMonth+";");
  ///************************
  
  if (year/4 == parseInt(year/4)) monthLength[2] = 29;
	
	eval("document."+formName+"."+dayName+".options.length = 0;");
  startPosition = 1;
	if (any == false) var ile = monthLength[(toIndexMonth + 1)];
	else var ile = monthLength[(toIndexMonth)];
	if ((toIndexDay+1) > ile) toIndexDay = ile - 1;

	for (i=startPosition; i<=ile; i++) {
      eval("document."+formName+"."+dayName+".options.add(new Option("+i+","+i+"));");
      	     
     /* if (selectedDay == (i-1)) {
        toIndex = i-1;
        eval("document."+formName+"."+dayName+".options.selectedIndex = "+toIndex+";");
      }*/
  }
  
  ///************************
  eval("document."+formName+"."+dayName+".options.selectedIndex = "+toIndexDay+";");
  
}

function checkDate(formName, dayName, monthName, any) {
	var now = new Date();
	year = now.getYear();
  
 
  eval("var selectedMonth = document."+formName+"."+monthName+".value;");
  eval("var selectedDay = document."+formName+"."+dayName+".options.selectedIndex;");
 

	if (year/4 == parseInt(year/4)) monthLength[2] = 29;
	
	eval("document."+formName+"."+dayName+".options.length = 0;");
  startPosition = 1;
	var ile = monthLength[(selectedMonth)];
	if ((selectedDay+1) > ile) selectedDay = ile - 1;

	for (i=startPosition; i<=ile; i++) {
      eval("document."+formName+"."+dayName+".options.add(new Option("+i+","+i+"));");
      	     
      if (selectedDay == (i-1)) {
        toIndex = i-1;
        eval("document."+formName+"."+dayName+".options.selectedIndex = "+toIndex+";");
      }
  }
  
  if (any == true && (ile == 0 || ile == undefined)) eval("document."+formName+"."+dayName+".options.add(new Option('--',''));");
  monthLength[2] = 28;
}

function defaultMonthFill(formName, dayName, monthName, nextSelect, any) {
  var now = new Date();
	curentMonth = now.getMonth();
  year = now.getFullYear();
  //alert (year);
  var ile = monthNames.length;
  
  if (any == true) startPosition = 0;
  else startPosition = 1;
  if (any == false) {
    if (nextSelect == true) {
      if (curentMonth == 11) toIndex = 0;
      else toIndex = curentMonth + 1;
    } else toIndex = curentMonth;
    
  } else if (any == true) toIndex = 0;
  
  if (nextSelect == false) {
      if (finderMonth != 100) {
          if (any == true) { toIndex = finderMonth; }
          else if (any == false) { toIndex = finderMonth - 1; }
      } 
      
  } else {
      if (finderMonthTo != 100) {
        if (any == true) { toIndex = finderMonthTo; }
        else if (any == false) { toIndex = finderMonthTo - 1; }
      } 
  }
  
  
  var goodYear;
  for (i=startPosition; i<ile; i++) {
    if (any == true && i == 0) {
      p = "''";
      goodYear = "";
    } else {
      p = i;
      if (any == false) {
        if (i < curentMonth + 1) goodYear = year + 1;
        else goodYear = year;
      } else {
        if (i < curentMonth + 1) goodYear = year + 1;
        else goodYear = year;
      }
    }
    eval("document."+formName+"."+monthName+".options.add(new Option('"+goodYear+" "+monthNames[i]+"',"+p+"));");
  }
  //alert("toIndex: " + toIndex);
  eval("document."+formName+"."+monthName+".options.selectedIndex = "+toIndex+";");
  
  
}

function defaultDayFill(formName, dayName, monthName, nextSelect, any) {

    var now = new Date();
	  curentDay = now.getDate();
	  curentMonth = now.getMonth();
	  //alert("! "+ curentMonth);
	  
    if (nextSelect == true && finderDayTo != 100 && finderMonthTo != 100) curentMonth = finderMonthTo - 1;
	  if (nextSelect == false && finderDay != 100 && finderMonth != 100) curentMonth = finderMonth - 1;
	  
	  if (nextSelect == true) {
      if (finderMonthTo == 100) {
        if (curentMonth == 11) var ile = monthLength[1];
        else var ile = monthLength[curentMonth+2];
      } else {
        //alert("!"+ finderMonthTo)
        var ile = monthLength[finderMonthTo];
      }
      
    } else {
      var ile = monthLength[curentMonth+1];
	  }
	  
	  var toIndex = curentDay - 1;
	  
    if (curentDay > ile) curentDay = ile;
    
    if (nextSelect == false && finderDay != 100) {
        toIndex = finderDay - 1;
        
    } else if (nextSelect == true && finderDayTo != 100) {
        toIndex = finderDayTo - 1;
    } 
    //alert("ile: "+ ile +" any:" + any +" finderDay: "+ finderDay +" finderDayTo: "+ finderDayTo +" curentMonth: "+ curentMonth );
    
    if ((any == true && nextSelect == false && finderDay == 100) || (any == true && nextSelect == true && finderDayTo == 100)) {
        
        eval("document."+formName+"."+dayName+".options.add(new Option('--',''));");
    
    } else {
      
      var startPosition=0;
      for (i=startPosition; i<ile; i++) {
        p = i + 1;
        eval("document."+formName+"."+dayName+".options.add(new Option('"+p+"',"+p+"));");
      }
      //alert("toIndex: "+toIndex);
      eval("document."+formName+"."+dayName+".options.selectedIndex = "+toIndex+";");
    }
}

		  var window_chat;
		  
        function open_photo_window (w, h, id, idb)
        {
        	domain = 'http://www.konta.nettur.pl/88827/';
					if (w > screen.availWidth)  
					{
						w = screen.availWidth - 50;
						scrollbars = 'yes';
					}
					else if (h > screen.availHeight)
					{
						h = screen.availHeight - 50;
						scrollbars = 'yes';			
					}
					else
					{
						scrollbars = 'no';
					}
  			  parameters = 'top=' +  eval((screen.availHeight-h)/4) + ',left=' + eval((screen.availWidth-w)/4) + ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scrollbars+',resizable=no, width='+w+', height='+h;
			  window.open (domain+'?Act=photo&id='+id+'&id_b='+idb, '', parameters);
        }
       function open_window (w, h, id)
        {
           domain = 'http://www.konta.nettur.pl/88827/';
           window.open (domain+id, '', 'menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=yes, resizable=no, width='+w+', height='+h+', left=150, top=150');
			
        }

        function main_return()
        {
           window.location.href='index.rst';
        }
        function reserve_trip ()
        {
             if (document.reservation.agree.checked) 
			   {

			     if (document.reservation.reg > '')
				  {
					  if (document.reservation.reg.checked) document.reservation.submit();
					  else alert ('Musisz zapozna� si� z regulaminem wycieczek !');
				  }
				  else document.reservation.submit();
		  		}
			   else alert ('Musisz wyrazi� zgod� na przetwarzanie twoich danych osobowych !');

        }
        function test_form ()
        {
           if (form_reserve.name.value == '')             { alert ('Podaj imi�'); form_reserve.name.focus(); }
           else if (form_reserve.surname.value == '')    { alert ('Podaj nazwisko'); form_reserve.surname.focus(); }
           else if (form_reserve.adress.value == '')    { alert ('Podaj adres'); form_reserve.adress.focus(); }
           else if (form_reserve.city.value == '')        { alert ('Podaj miasto'); form_reserve.city.focus(); }
           else if (form_reserve.zip.value == '')        { alert ('Podaj kod'); form_reserve.zip.focus(); }
           else if (form_reserve.phone.value == '')        { alert ('Podaj numer telefonu'); form_reserve.phone.focus(); }
           else document.form_reserve.submit();
        }
	  var date_type

        function calendar (which,idb,inputname)
        {
	
           var now = new Date();
           var m = now.getMonth() + 1;
           var y = now.getYear();
	   
/*	   if (inputname)   {}
	   else
	   {
	      //if (which)
	    //  inputname =    
	   }
*/	   
           if (idb)
           {
	   
              window.open('http://www.konta.nettur.pl/calendar?year='+y+'&month='+m+'&res='+which+'&date_type='+date_type, '' , 'menubar=no, toolbar=no, width=200, height=200, resizable=no, status=yes, scrollbars=no, left=300, top=300');
           }
	   else
           {		    
               window.open ('calendar?year='+y+'&month='+m+'&res='+which+'&date_type='+date_type, '' , 'menubar=no, toolbar=no, width=200, height=200, resizable=no, status=no, scrollbars=no, left=300, top=300');
           }
        }

// funkcja otwierajaca kalendarz do selectow

function calendarSelect (formName, dayName, monthName, any) {
	
    var now = new Date();
    var m = now.getMonth() + 1;
    var y = now.getFullYear();
    window.open('calendarSelect?year='+y+'&month='+m+'&formName='+ formName + '&dayName='+ dayName + '&monthName='+ monthName + '&any=' + any , '' , 'menubar=no, toolbar=no, width=200, height=200, resizable=no, status=yes, scrollbars=no, left=300, top=300');
           
}
		  
		  
function close_window(inputData) 
{
	var winName = eval(inputData);

	if (navigator.appName == "Netscape" && winName && winName.closed) 
	{
		eval("delete " + inputData);
		eval(inputData + " = null");
		
		return;
	}
	if (winName) 
	{
		winName.close();
		return;
	}
}

function js_confirm(qst,url,target)
{
  if (confirm(qst))
  {

  		if (target=="undefined" || target=='' || target==null)
		{
		  
	     document.location = url;
		}
		else
		{

			self.parent.document.getElementById(target).src = url;
		}
  }
  else
  {
      return false;
  }

}

function showLayer2(layer){
	
}
