function open_new(url, width, height) {
var Win = window.open(url,"open_new",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=no,menubar=no' )

with(Win.document) {
   write('<html><head><title>'+url+'</title><script>function onl(){ img = new Image(); img.src = \"'+url+'\";window.resizeTo(img.width+30,img.height+100);}</script></head><body style="margin:10 10 10 10;" onload="onl()" LEFTMARGIN=0 bgcolor="#8BC78C" TOPMARGIN=0 MARGINWIDTH=10 MARGINHEIGHT=10');
   write('"><img src="'+url+'"  onclick="self.close()" /></body></html>');
   close();
  }

}






function submitForm(forma)
{

document.s1.submit();


}

function showMaxHeight()
{

			heightC = document.getElementById('contentoH');
			heightL = document.getElementById('lselect');
			heightR = document.getElementById('contentoR');

			maxValue = Math.max(heightL.offsetHeight,heightC.offsetHeight,heightR.offsetHeight);

			//alert(maxValue);

			document.getElementById('stopka').style.top=(maxValue +300) + "px";
			document.getElementById('container').style.height=(maxValue + 300) + "px";
			/*
			alert(document.getElementById('contento0').offsetHeight);
			*/

}

function resizeOnAjax()
{
heightP = document.getElementById('response');
heightC = document.getElementById('contentoH');
heightL = document.getElementById('lselect');
heightR = document.getElementById('contentoR');
maxValue = Math.max(heightP.offsetHeight,heightL.offsetHeight,heightC.offsetHeight,heightR.offsetHeight);


document.getElementById('stopka').style.top=(maxValue +400) + "px";
document.getElementById('container').style.height=(maxValue + 400) + "px";
}

function onMouseShowSecondNode(elemntId){
//alert("oooooo");
	obj = elemntId;
	obj.style.background="url(../templates/newwsbif2/menue.gif) top repeat-x"
  //alert(obj.style.background + 'poszło');

}
function onMouseOutShowSecondNode(elemntId){
//alert("out");
	obj = elemntId;
	obj.style.background="url(../templates/newwsbif2/menuea1.gif) top repeat-x"
 // alert(obj.style.background + 'poszło');

}



function showSecondNode(elemntId, status)
{
	obj = document.getElementById(elemntId);
	if(status==1)
	{
	 obj.style.display = "block";
	}
	else
	{
     obj.style.display = (obj.style.display == "none" ? "block" : "none");
	}
	//alert(elemntId)
	showMaxHeight();


}


function openClickNode()
{
uri = document.location.href;
//alert(uri);
strona = uri.split("/");
ile = strona.length-1;
nazwa = strona[ile];
element = "show"+nazwa.substring(0, 6) 
el2 = element.substring(0, 6)+"0000";
el3 = element.substring(0, 8)+"00";//cleareTags(document.getElementById("ac"+nazwa.substring(0, 6)).value)
//alert(el2);
//alert("el2:" +el2+"\n\nel3:" +el3+"\n\n"));

//
//alert(tekst);
//alert("el2:" +el2+"\n\nel3:" +el3+"\n\ntext:"+cleareTags(document.getElementById("ac"+nazwa.substring(0, 6)).innerHTML));
if(document.getElementById("ac"+nazwa.substring(0, 6)))
{
tekst = cleareTags(document.getElementById("ac"+nazwa.substring(0, 6)).innerHTML);
document.getElementById("ac"+nazwa.substring(0, 6)).innerHTML = "<span class=\"thisSelected\">"+tekst+"</span>"
}

var obj2=document.getElementById(el2);
var obj3=document.getElementById(el3);

if(obj2!="undefined")
{

//alert("el2:true");
	try{
	 obj2.style.display = "block";
	}
	catch(err0)
	{
	
	}
}
if(obj3!="undefined")
{

	try{
	    obj3.style.display = "block";
	}
	catch(err)
	{
	
	}

}




/*
element = "show"+nazwa.substring(0, 6) 
element = "show010000";
alert(element);
showSecondNode(element);
*/
showMaxHeight();

}
function cleareTags(str)
{
var stringToReplace = String(str);
var re=/(<\/?p)(?:\s[^>]*)?(>)|<[^>]*>/gi;
str = stringToReplace.replace(re,'');
return str
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}


function checkFormNotEmpty()
{
	    objektFormy = document.daneosobowe;
  
			if(trim(objektFormy.imie1.value)=='')	{return "\nWpisz imię pierwsze\n";}
			if(trim(objektFormy.nazwisko.value)==''){return "Wpisz nazwisko\n"}
			if(trim(objektFormy.pesel.value)==''){return "Wpisz PESEL\n"}
			if(trim(objektFormy.dowod_seria.value)==''){return "Wpisz Serię i numer dowodu osobistego\n"}
			if(trim(objektFormy.miejsce_ur.value)==''){return "Wpisz miejsce urodzenia\n"}
		//if(trim(objektFormy.imiona_rodzicow.value)==''){return "Wpisz imiona rodziców\n"}
		//if(trim(objektFormy.ulica.value)==''){return "Wpisz nazwę ulicy\n"}
		//	if(trim(objektFormy.nr_domu.value)==''){return "Wpisz numer domu\n"}
			
	
	return "sprawdzono";
	

}

// This code was written by Tyler Akins and has been placed in the
// public domain.  It would be nice if you left this header intact.
// Base64 code from Tyler Akins -- http://rumkin.com

var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

function encode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   do {
      chr1 = input.charCodeAt(i++);
      chr2 = input.charCodeAt(i++);
      chr3 = input.charCodeAt(i++);

      enc1 = chr1 >> 2;
      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
      enc4 = chr3 & 63;

      if (isNaN(chr2)) {
         enc3 = enc4 = 64;
      } else if (isNaN(chr3)) {
         enc4 = 64;
      }

      output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + 
         keyStr.charAt(enc3) + keyStr.charAt(enc4);
   } while (i < input.length);
   
   return output;
}

function decode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
   input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

   do {
      enc1 = keyStr.indexOf(input.charAt(i++));
      enc2 = keyStr.indexOf(input.charAt(i++));
      enc3 = keyStr.indexOf(input.charAt(i++));
      enc4 = keyStr.indexOf(input.charAt(i++));

      chr1 = (enc1 << 2) | (enc2 >> 4);
      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
      chr3 = ((enc3 & 3) << 6) | enc4;

      output = output + String.fromCharCode(chr1);

      if (enc3 != 64) {
         output = output + String.fromCharCode(chr2);
      }
      if (enc4 != 64) {
         output = output + String.fromCharCode(chr3);
      }
   } while (i < input.length);

   return output;
}































