// ładowanie głównego okienka
function Laduj(bClose)
{
	var w = 800, h = 600;
	var popW = 800, popH = 600;

	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}

	var leftPos = (w-popW)/2;
	if (leftPos < 0) {
		leftPos = 0;
	}
	
	var topPos = (h-popH)/2
	if (topPos < 0) {
		topPos = 0;
	}

	window.open('Login.aspx', 'KOLKaP_WEB', 'scrollbar=yes, resizable=yes, width=800, height=600, left='+leftPos+', top='+topPos, true);
    if (bClose == true) {
    	// aby nie było tego głupawego komunikatu o tym, że zamyka się okienko
		// trzeba trochę oszukać IE ;-)
		window.opener = 'x';
		// i teraz można zamknąć okienko bez komunikatu :-D
		window.close();
	}
}

function printpr()
		{	
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>'; 
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser); 
		WebBrowser1.ExecWB(7, 1);
		WebBrowser1.outerHTML = "";
		}
		
function pageSetup()
		{	
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>'; 
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser); 
		WebBrowser1.ExecWB(8, 1);
		WebBrowser1.outerHTML = "";
		}
		
/*function enableZapisz()
		{
			document.getElementById("btnZapisz").disable=true;
			window.execScript("__doPostBack('tbNumer', '')","JavaScript");
			return true;
		}*/
		

//blokuje przyciki drukowania dla reporttoolbar
function zablokuj(rtPDrukRap, rtPDrukStr ,cb_doEdycji) {
  cb = document.getElementById(cb_doEdycji);
  if ( cb.checked == true ){
    rtPrzyciskDrukRap = document.getElementById(rtPDrukRap);
    rtPrzyciskDrukRap.disabled = true;
  
    rtPrzyciskDrukStr = document.getElementById(rtPDrukStr);
    rtPrzyciskDrukStr.disabled = true;
  }
}

function ZmianaChecka(form, formWFrame, reportToolBar, cbName) {
  cb = window.parent.document.getElementById(cbName);
  if (cb.name == "cbEdycja")
  {
    if (cb.checked == false) { 
      select = window.parent.document.getElementById(reportToolBar+"_PageNumber");
      numer_strony = select.selectedIndex;
    
      //fram = window.frames[0];
      fram = parent.frames[0];
      form2 = fram.document.getElementById(formWFrame)
      form2.action = "?nr="+numer_strony+"&ZMIANA=true";
      form2.submit();
    }
    else {
      select = parent.document.getElementById(reportToolBar+"_PageNumber");
      numer_strony = select.selectedIndex;
    
      if ( numer_strony == null || numer_strony == "" ){ 
        numer_strony=0; 
      }
    
      form1 = parent.document.getElementById(form);
      form1.action = "?nr="+numer_strony;
      form1.submit();
    }
  }
  else
  {
    ce = window.parent.document.getElementById("cbEdycja");
    if (ce.checked == false )
    {
      select = window.parent.document.getElementById(reportToolBar+"_PageNumber");
      numer_strony = select.selectedIndex;
    
      if ( numer_strony == null || numer_strony == "" ){ 
        numer_strony=0; 
      }
    
      form1 = parent.document.getElementById(form);
      form1.action = "?nr="+numer_strony+"&ZMIANA="+cbName;
      form1.submit();
    }
    else
    {
      select = window.parent.document.getElementById(reportToolBar+"_PageNumber");
      numer_strony = select.selectedIndex;
      //fram = window.frames[0];
      fram = parent.frames[0];
      form2 = fram.document.getElementById(formWFrame)
      form2.action = "?nr="+numer_strony+"&ZMIANA="+cbName;
      form2.submit();
    }
  }
}

function PoleShow(tytulOkna, idRodzic, idPoleDocelowe, idbtnAkceptujacy)
    {
      var opis = document.getElementById(idPoleDocelowe).value;
      //if (opis == "")
      //{
        var tresc = "";
        
        tresc = tresc + '<div>';
        tresc = tresc + '<iframe id="iframeTlo" scrolling="no" frameborder="0"></iframe>';
        tresc = tresc + '<div id="pagedimmer">&nbsp;</div>';
        tresc = tresc + '<div id="divTextArea" >';
	      tresc = tresc + '<div style="margin:5px;" height="100%">';
	      tresc = tresc + '<table width="100%" height="100%" style="background-color:#FFFFFF; border:1px solid #999999;">';
	      tresc = tresc + '<tr>';
	      tresc = tresc + '<td style="font-family:tahoma; font-size:11px; font-weight:bold; border-bottom:1px solid #CCCCCC; padding-left:5px; color:#000000; height:22px;">' + tytulOkna + '</td>';
		    tresc = tresc + '</tr>';
		    tresc = tresc + '<tr>';
		    tresc = tresc + '<td style="font-family:tahoma; font-size:11px;padding-left:5px;">';
		    tresc = tresc + '<div id="formsblue" style="overflow:auto; height:120px;">';
		    tresc = tresc + '<textarea id="tbOpiniaPopUp" style="height:98%; width:100%;">';
		    tresc = tresc + opis;
		    tresc = tresc + '</textarea>';
		    tresc = tresc + '</div>';
		    tresc = tresc + '</td>';
		    tresc = tresc + '</tr>';
		    tresc = tresc + '<tr>';
		    tresc = tresc + '<td style="border-top:1px solid #CCCCCC; padding-top:5px;text-align:right;">';
		      
		    tresc = tresc + '<input id="btnAkceptujOp" type="button" value="Ok" class="msg_button_class" onClick="Odrzuc(\'' + idRodzic + '\', \'' + idPoleDocelowe + '\', \'' + idbtnAkceptujacy + '\');">';
		    tresc = tresc + '<input id="btnAnuluj" type="button" value="Anuluj" class="msg_button_class" onClick="PoleHide(\'' + idRodzic + '\')">';
		      
		    tresc = tresc + '</td>';
		    tresc = tresc + '</tr>';
		    tresc = tresc + '</table>';
	      tresc = tresc + '</div>';
        tresc = tresc + '</div>';
        tresc = tresc + '</div>';
        
        HideAllDropDownLists();
        document.getElementById(idRodzic).innerHTML = tresc;
      //}
      //else
      //{
      //  OdrzucBezPopUpu(idbtnAkceptujacy);
      //}
    }
    
    function PoleHide(idRodzic)
    {
      ShowAllDropDownLists();
      document.getElementById(idRodzic.toString()).innerHTML = "";
    }
    
    function OdrzucBezPopUpu(idbtnAkceptujacy)
    {
      ShowAllDropDownLists();
      document.getElementById(idbtnAkceptujacy).click();
    }
    
    function Odrzuc(idRodzic, idPoleDocelowe, idbtnAkceptujacy)
    {
      //var tresc = document.getElementById("tbOpiniaPopUp").innerText;
      var tresc = document.getElementById("tbOpiniaPopUp").value;
      document.getElementById(idPoleDocelowe).value = tresc;
      document.getElementById(idRodzic).innerHTML = "";
      ShowAllDropDownLists();
      document.getElementById(idbtnAkceptujacy).click();
      
    }

function HideAllDropDownLists()
{
  var elements = document.forms[0].elements;
  for (var i=0; i < elements.length; i++)
  {
    if (elements[i].type == "select-one")
    {
      elements[i].style.display = "none";
    }
  }
}

function ShowAllDropDownLists()
{
  var elements = document.forms[0].elements;
  for (var i=0; i < elements.length; i++)
  {
    if (elements[i].type == "select-one")
    {
      elements[i].style.display = "block";
    }
  }
}
