function formsubmit(formname){
	if(document.form[formname].onsubmit()){
		document.form[formname].submit();
	}
}

function window_open()
{
var newWindow;
var urlstring = '/js/calendar.htm'
newWindow = window.open(urlstring,'','height=200,width=280,toolbar=no,minimize=no,status=no,memubar=no,location=no,scrollbars=no')
}

var itvp_klip_window;
function na_open_window(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
  toolbar_str = toolbar ? 'yes' : 'no';
  menubar_str = menubar ? 'yes' : 'no';
  statusbar_str = statusbar ? 'yes' : 'no';
  scrollbar_str = scrollbar ? 'yes' : 'no';
  resizable_str = resizable ? 'yes' : 'no';

  cookie_str = document.cookie;
  cookie_str.toString();

  pos_start  = cookie_str.indexOf(name);
  pos_end    = cookie_str.indexOf('=', pos_start);

  cookie_name = cookie_str.substring(pos_start, pos_end);

  pos_start  = cookie_str.indexOf(name);
  pos_start  = cookie_str.indexOf('=', pos_start);
  pos_end    = cookie_str.indexOf(';', pos_start);

  if (pos_end <= 0) pos_end = cookie_str.length;
  cookie_val = cookie_str.substring(pos_start + 1, pos_end);
  if (cookie_name == name && cookie_val  == "done")
    return;

	if (itvp_klip_window){
		itvp_klip_window.close();
	}
		      
	msg = window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
	itvp_klip_window=msg;
  msg.focus();
  return false;
}

function open_window_print(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
  	toolbar_str = toolbar ? 'yes' : 'no';
  	menubar_str = menubar ? 'yes' : 'no';
  	statusbar_str = statusbar ? 'yes' : 'no';
  	scrollbar_str = scrollbar ? 'yes' : 'no';
	resizable_str = resizable ? 'yes' : 'no';
  	msg = window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
	msg.print();
	return false;
}

function open_clip_popup(idm, width, height, quality, scroll) {
    toolbar_str = 'no';
    menubar_str = 'no';
    statusbar_str = 'no';
    scrollbar_str = 'no';
    resizable_str = 'no';
    quality = quality ? quality : '11';
    width = width ? width : '700';
    height = height ? height : '570';
    url = 'http://v1.itvp.pl/sys/media/i.tvp/idm/'+idm+'/rodzaj/'+(quality-10)+'/width/700/height/570';
	if (itvp_klip_window){
		itvp_klip_window.close();
	}
		      
    msg = window.open(url, 'popup', 'width=700,height=570,toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
	itvp_klip_window=msg;
    msg.focus();
    return false;
}

function open_clip_popup_ns(idm, width, height, quality) {
    toolbar_str = 'no';
    menubar_str = 'no';
    statusbar_str = 'no';
    scrollbar_str = 'no';
    resizable_str = 'no';
    quality = quality ? quality : '11';
    width = width ? width : '384';
    height = height ? height : '374';
    url = 'http://v1.itvp.pl/sys/media/noscroll/i.tvp/idm/'+idm+'/rodzaj/'+(quality-10)+'/width/700/height/570';
	if (itvp_klip_window){
		itvp_klip_window.close();
	}
    msg = window.open(url, 'popup', 'width=700,height=570,toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
	itvp_klip_window=msg;
    msg.focus();
    return false;
}



function img_popup_window(img_path, width, height,scrollbar, win_width, win_height )
{
	scrollbar_str = scrollbar ? 'yes' : 'no';
  	win_width = win_width ? win_width : width;
  	win_height = win_height ? win_height : height;
  
  	msg = window.open('', 'popup', 'left=20,top=20,width='+(win_width + 10) +',height='+(win_height+10)+',toolbar=no,status=no,menubar=no,scrollbars=' + scrollbar_str + ',resizable=no');
  	msg.document.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Obrazek</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style>body, html {margin: 0; padding: 0;}</style></head><body><a href="#" onclick="window.close()"><img border="0" align="center" src="' + img_path + '" width="' + width+ '"  height="' + height +'" ></a></body></html>');
  	msg.focus();
    return false;
}

/* Ukrywanie, odkrywanie elementu menu lub czegos innego */
function hideshow(which, me, rozwin_txt, zwin_txt){
	if (!document.getElementById){
		return;
	}	
	h_div =	document.getElementById(which);
	if (h_div.style.display=="none"){
		h_div.style.display="";
		me.value = zwin_txt;
	} else {
		h_div.style.display="none";
		me.value = rozwin_txt;
	}	

}
function polec(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
  toolbar_str = toolbar ? 'yes' : 'no';
  menubar_str = menubar ? 'yes' : 'no';
  statusbar_str = statusbar ? 'yes' : 'no';
  scrollbar_str = scrollbar ? 'yes' : 'no';
  resizable_str = resizable ? 'yes' : 'no';

  cookie_str = document.cookie;
  cookie_str.toString();

  pos_start  = cookie_str.indexOf(name);
  pos_end    = cookie_str.indexOf('=', pos_start);

  cookie_name = cookie_str.substring(pos_start, pos_end);

  pos_start  = cookie_str.indexOf(name);
  pos_start  = cookie_str.indexOf('=', pos_start);
  pos_end    = cookie_str.indexOf(';', pos_start);

	var URL = unescape(location.href);
	var link = escape(encodeURIComponent(URL)); 
	var url = url+link;

  if (pos_end <= 0) pos_end = cookie_str.length;
  cookie_val = cookie_str.substring(pos_start + 1, pos_end);
  if (cookie_name == name && cookie_val  == "done")
    return;
 
  msg = window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
  msg.focus();

}

function zwin( _levelId) {
	var thisLevel = document.getElementById( _levelId );
	thisLevel.style.display = "none";
}

var otwarte = new Array();	
var param = 1;

function rozwin( _levelId, param) {
	var thisLevel = document.getElementById( _levelId );
	if ( thisLevel.style.display == "none") {

		if(otwarte[param]){
			zwin(otwarte[param]);
			level = otwarte[param];
			otwarte[param] = false;
			rozwin(level+'_link', param);
		}
		thisLevel.style.display = "block";
		otwarte[param] = _levelId;

		}
	else {
		zwin( _levelId);
		}
}

function zwin2( _levelId) {
	var thisLevel = document.getElementById( _levelId );
	thisLevel.style.display = "none";
}
var otwarte = new Array('');	
function rozwin2( _levelId) {
	var thisLevel = document.getElementById( _levelId );
	if ( thisLevel.style.display == "none") {
		thisLevel.style.display = "block";
	} else {
		zwin2( _levelId);
	}
}

function zobacz_wynik(divek){
	wynik=divek.getElementsByTagName('div')[1];
	if(wynik.style.visibility=="visible"){
		wynik.style.visibility="hidden";
	}else{
		wynik.style.visibility="visible";
	}
}

function set_hidden(hidden_field, checkbox_field) {
	hf = document.getElementById(hidden_field);
	cf = checkbox_field;	
	if(checkbox_field.checked == false) {
		hf.value = 0 ;
	}else {
		hf.value = 1 ;
	}
//	alert(hf.value + ' checkbox '+ cf.value); 
}
// wysyła komunikat do konsoli javascript firefoxa
function debug_ff(aMsg) {
   setTimeout(function() { throw new Error("[debug] " + aMsg); }, 0);
}

var okno;
function nowe_okno(url,tytul,opcje){
    if (okno){
        okno.close();
    }
    okno = window.open(url,tytul,opcje);
    okno.focus();
}
