function addEvent(elm, evType, fn, useCapture) {
  // cross-browser event handling for IE5+, NS6 and Mozilla
  // By Scott Andrew
  if (elm.addEventListener) {
    elm.addEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.attachEvent) {
    var r = elm.attachEvent('on' + evType, fn);
    EventCache.add(elm, evType, fn);
    return r;
  } else {
    elm['on' + evType] = fn;
  }
}

addEvent(window, 'unload', EventCache.flush, false);

function load() {
	if (to = document.getElementById('status').getElementsByTagName('select')) {
		status();
		addEvent(to[0], 'change', status, false);
	}	
}

function status() {
	if (to = document.getElementById('status').getElementsByTagName('select')) {
		//alert('to: '+to[0].value);
		var do_zmiany = document.getElementById('reservation');
		if(to[0].value==1) {
			//alert('Rezerwacja');
			do_zmiany.className = do_zmiany.className.replace(/^.*$/,"div_show");
		} else {
			do_zmiany.className = do_zmiany.className.replace(/^.*$/,"display_no");
		}
		
	}
}


function displayPage(url, name, width, height, scrollvalue) {
	w = window.open(url, name, 'width='+width+', height='+height+', scrollbars='+scrollvalue+', menubar=no, resizable=0');
	w.moveTo(screen.width/2-width/2, screen.height/2-height/2);
}

function showImg( img_src, img_w, img_h, img_name, scroll ) {
	img_w_n = img_w+20;
	img_h_n = img_h+20;
	img_w_o = img_w;
	if(scroll==''){
		scroll = 'no';
	} else {
		scroll = scroll;
	}
   var popup = window.open('','','width=' + img_w_n + ',height=' + img_h_n + ',resizable=0,scrollbars='+scroll+',menubar=no');
   popup.document.open();
   popup.document.write('<html><head><title>'+img_name+'<\/title><\/head>');
   popup.document.write('<body style="margin: 0;padding: 0; position: relative;">');
   popup.document.write('<a href="javascript:window.close();" style="margin: 0 ;border: none; padding: 0;"><img style="margin: 0;border: 10px solid #eeeeee;padding: 0;" src=' + img_src + ' /></a>');
   if(scroll=='yes'){
		popup.document.write('<br /><div style="position: absolute; top:10; left: 10; background-color: #ffffff; padding: 5px 0; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold;"><p style="margin: 0 5px; padding: 0;">'+img_name+'<\/p><\/div>');
		}
	 popup.document.write('<\/body><\/html>');
//<input type="button" value="Print / Drukuj" onclick="javascript:window.print()" \/>
//   popup.document.focus();
   popup.document.close();
}

function makeOk() {
	if (img = document.getElementById('middle_site').getElementsByTagName('img')) {
		if (img.length>0) {
			//alert(img[1].parentNode.tagName);
			//alert('Ilosc obrazkow: '+$img.length);
			for (i=0; i<img.length; i++) {
				if ( (img[i].parentNode.parentNode.tagName.toLowerCase() == 'p') && (img[i].parentNode.parentNode.parentNode.tagName.toLowerCase() != 'td') ) {
					if (i%2 == 0) {
						img[i].className = img[i].className.replace(/^.*$/,"img_prawy");
					} else {
						img[i].className = img[i].className.replace(/^.*$/,"img_lewy");
					}
					img[i].style.position = 'relative';
	
				}
			}
		}
	}
}
