function UsunWczytywanie()
{
	if (document.getElementById)
		document.getElementById('loading').style.visibility='hidden';
	else
	{
		if(document.layers) //NS4
			document.loading.visibility = 'hidden';
		else //IE4
			document.all.loading.style.visibility = 'hidden';
 	};
};

function pr()
{
	if (!window.print)
	{
		alert("Musisz mieć NS4.x lub IE5,\naby użyć drukowania!")
		return;
	}
	window.print()
}

function openClose(id)
{
   if(document.getElementById) {
      element = document.getElementById(id);
   } else if(document.all) {
      element = document.all[id];
   } else return;

   if(element.style) {
      if(element.style.display == 'block' ){
         element.style.display = 'none';
      } else {
         element.style.display = 'block';
      }
   }
}
function okno(nazwa,width,height)
{
okienko=window.open(nazwa, "Zoom", "width="+width+", height="+height+", top=50, left=50, scroolbar=auto");
};

function okno(nazwa,width,height,tytul)
{
okienko=window.open(nazwa, tytul, "width="+width+", height="+height+", top=50, left=50, scroolbar=auto");
};

function okno_oferta(nazwa)
{
okienko_oferta=window.open(nazwa, "Podgląd", "width=500, height=500, top=0, left=0, scrollbars=yes");
};

function usun(tekst)
{
i = CONFIRM("Czy na pewno chcesz usunąć to zlecenie?");
if (i==true) window.location.replace(tekst);
};

function help()
{
okienko=window.open('help.htm','Help', 'width=600, height=500, top=50, left=50, scrollbars=yes,resizable=no,menubar=no, toolbar=no');
};


function okienko_proba(nazwa,szer,wys)
{
okienko_oferta=window.open(nazwa, "Podgląd", "width="+szer+", height="+wys+", top=300, left=300, scrollbars=yes");
};

function Ustaw_czcionke()
{
	wartosc="";
        if (document.dodaj.czcionka.selectedIndex!=0)
		wartosc+=' face="'+document.dodaj.czcionka.options[document.dodaj.czcionka.selectedIndex].value+'"';
        if (document.dodaj.rozmiary.selectedIndex!=0)
		wartosc+=' size="'+document.dodaj.rozmiary.options[document.dodaj.rozmiary.selectedIndex].value+'"';
        if (document.dodaj.kolory.selectedIndex!=0)
		wartosc+=' color="'+document.dodaj.kolory.options[document.dodaj.kolory.selectedIndex].value+'"';

	if (wartosc!="") bbcode('[font'+wartosc+']','[/font]');
};

function bbcode(tag,tag2,z)
{
if (document.selection)
{
	tekst=document.selection.createRange().text;
	document.getElementById('opis').focus();
	document.selection.createRange().text=tag+tekst+tag2;
}
else
{
	tekst=document.getElementById('opis').value.substring(document.getElementById('opis').selectionEnd||0,document.getElementById('opis').selectionStart||0);
        if ((document.getElementById('opis').selectionStart || document.getElementById('opis').selectionStart=='0')) document.getElementById('opis').value=document.getElementById('opis').value.substring(0,document.getElementById('opis').selectionStart)+tag+tekst+tag2+document.getElementById('opis').value.substring(document.getElementById('opis').selectionEnd,document.getElementById('opis').value.length);
	else document.getElementById('opis').value+=tag+tekst+tag2;
};
};

function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=no,menubar=no' );
}

function high(which2)
{
theobject=which2
highlighting=setInterval("highlightit(theobject)",30)
}
function low(which2)
{
clearInterval(highlighting)
if (which2.style.MozOpacity)
which2.style.MozOpacity=0.3
else if (which2.filters)
which2.filters.alpha.opacity=30
}
function highlightit(cur2){
if (cur2.style.MozOpacity<1)
cur2.style.MozOpacity=parseFloat(cur2.style.MozOpacity)+0.1
else if (cur2.filters&&cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}

PositionX = 50;
PositionY = 50;

defaultWidth  = 50;
defaultHeight = 50;

var AutoClose = true;

if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;

function popImage(imageURL,imageTitle,altText){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="George"  src='+imageURL+' style="display:block"></body></html>');
close();
}}

function FormVerImage(obj, tablica, tekst) {
	var val=FormVer(obj,tablica);
	res=true;
	// usun oznaczenie
  	jQuery('#image').css("border","1px solid #000");

  	// podkresl blednie oznaczone
    wart=eval('obj.image.value');
    wart=wart.toUpperCase();
    if ((wart!=tekst))  {
		jQuery('#image').css("border","1px solid red");
		alert('Proszę przepisać poprawnie tekst z obrazka');
		return false;
    }
    else if (val==true)
    	return true;
	else {
	    alert('Proszę wypełnić wszystkie wymagane pola');
		return false;
	}
};

function FormVer(obj, tablica) {
	var elems = tablica;
	res=true;

	// usun oznaczenie
  	for (a=0; a<elems.length; a++) {
		jQuery('#'+elems[a]).css("border","1px solid silver");
  	}

  	// podkresl blednie oznaczone
  	for (a=0; a<elems.length; a++) {
    	wart=eval('obj.'+elems[a]+'.value');
    	if ((wart==''))  {
			jQuery('#'+elems[a]).css("border","1px solid red");
			res=false;
    	}
  }

  //if (res==false)
  //      alert('Proszę wypełnić wszystkie wymagane pola formularza!');
  return res;
};
