var msg="Welcome to www.nga.pl ";
var mywin = null;

function okno_wyb2(link,nazwa,szer,wys)
{
//	var SupAg="ula";
//	var FIRMA="10";

	var centerWidth=(window.screen.width-szer)/2;
	var centerHeight=(window.screen.height-wys)/4;
	var lng;

	if(link.substring(0,9)=="ofe1w.php"){
		lng=link.substring(22,24)
		if(document.ffind.Ewoj.value=="-"){
			switch (lng){
				case 'en':window.alert("Firstly you have select Province !!");break;
				case 'de':window.alert("Vorher muss eine Woiwodschaft ausgewählet werden !!");break;
				default :window.alert("Wcze¶niej Musisz wybrać Województwo !!");
				}
			document.ffind.Ewoj.focus();
			return true;
			}
		else if(link.substring(10,18)=="szuk=lok") if(document.ffind.Egmi.value==""){
			switch (lng){
				case 'en':window.alert("Firstly you have select Commune !!");break;
				case 'de':window.alert("Vorher muss eine Gemeinde ausgewählet werden !!");break;
				default :window.alert("Wcze¶niej Musisz wybrać gminę !!");
				}
			document.ffind.igmi.focus();
			return true;
			}
		}

//alert(typeof mywin=='object');
//if(mywin!=null){mywin.close();}
//if(mywin && typeof mywin=='object' && !mywin.closed)mywin.close()

/*	if(link.substr(0,28)=="http://www.nga.pl/zdjecia/ag")
		{if (ofertaZ(link)!=FIRMA) link="http://www.nga.pl/zdjecia/ag/"+SupAg+".php";}
	else if (link.substr(0,9)=="offer.php")
	{if (ofertaZ(link)!=FIRMA)link=link+"&FIR="+FIRMA+"&SupAgt="+SupAg;
	link="http://www.nga.pl/"+link;
	}
*/
	mywin=window.open(link,nazwa,
		'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width='+szer+
		',height='+wys+',left=' + centerWidth +',top=' + centerHeight);

	mywin.focus();
//	return mywin.name;
}

function wstaw() {
	window.close();
}

function  GO_(link){top.location.href=link;}
function go_l(link){top.location.href=link;}

/* filtr lokalizacji */

function IsEmpty(tx) {
	if(tx.value==null)return true;
	if(tx.value.length==0)return true;
	return false;
}	

function onCha_woj() //fun.php
{
	d=document;
	d["ilok"].src="stale/find-g.gif";

	if(d.ffind.Ewoj.value=="-")d["igmi"].src="stale/find-g.gif";
	else d["igmi"].src="stale/find.gif";
	
	d.ffind.Egmi.value="";
	d.ffind.Elok.value="";
}

function onCha_gmi() //OK
{
	d=window.opener.document;
	d.ffind.Egmi.value=window.document.forma.lokS.options[window.document.forma.lokS.selectedIndex].value;

	if(IsEmpty(d.ffind.Egmi))d["ilok"].src="stale/find-g.gif";
	else d["ilok"].src="stale/find.gif";
	
	d.ffind.Elok.value="";
	window.close();
}

function onCha_lok()
{
	window.opener.document.ffind.Elok.value=
		window.document.forma.lokS.options[window.document.forma.lokS.selectedIndex].value;
	window.close();
}

/* filtr lokalizacji END */

//na wyjściu tylko liczby ewentualnie znaki z t='.,@'
function check(el,fm,t) {

var wart, znak, dw, zwr='', zmiana=false; //local

t = "0123456789"+ (typeof(t) != "undefined" ? t : "");
wart = document.forms[fm].elements[el].value;
dw=wart.length;

for (var w = 0; w < dw; w++)
 {	if (t.indexOf(znak=wart.charAt(w))==-1) zmiana=true;
	else zwr+=znak;
 }
if(!zmiana) return;
document.forms[fm].elements[el].value=zwr;
}


function isFloat(s)

{   var i;
    var seenDecimalPoint = false;

    if (isEmpty(s)) 
       if (isFloat.arguments.length == 1) return false;
       else return (isFloat.arguments[1] == true);

    if (s == '.') return false;

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if ((c == '.') && !seenDecimalPoint) seenDecimalPoint = true;
        else if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}




//na wyjściu TEXT bez liczb i '@'
function checkTx(el,fm) {

form = document.forms[fm];
wart = form.elements[el].value;
zwr='';
dl=wart.length;
zmiana=false;

for (var j = 0; j < dl; j++)
 {znak=wart.charAt(j);
	if((parseInt(znak)<39 || parseInt(znak)>30)|| '@'==znak) zmiana=true;
	else zwr+=znak;
 }
if(!zmiana) return;
form.elements[el].value=zwr;
}

/*
object TheForm
string the name of the form field to check
int the min value
int the max value

return boolean whether a valid number has been submitted or not
*/
function checkLimit(theForm, theFieldName, min, max)
{
var theField	= theForm.elements[theFieldName];
var val			= parseInt(theField.value);

if (val < min || val > max) {
	theField.select();
	alert("Niepoprawna Warto¶ć: " +val);
	theField.focus();
	return false;
}

else{theField.value = val;}
document.ffind.page.value=val;
document.ffind.submit();
return false;
}

function expand(id) // odkrywa/ukrywa text
{
	ids=document.getElementById(id).style;
	if (ids.display=='block'){
		ids.display='none';
		document.getElementById('r'+id.substring(1)).innerHTML='<b>...[&#8211;&raquo;]</b> '}
	else{ids.display='block';
		document.getElementById('r'+id.substring(1)).innerHTML='<b>...[&laquo;&#8211;]</b> '}
}

//INNI

var interval = 100;
var spacelen = 120;
var space10=" ";
var seq=0;

function Scroll() {
	len = msg.length;
	window.status = msg.substring(0, seq+1);
	seq++;
	if ( seq >= len ) {
		seq = spacelen;
		window.setTimeout("Scroll2();", interval );
	}
	else window.setTimeout("Scroll();", interval );
}

function Scroll2() {
	var out="";
	for (i=1; i<=spacelen/space10.length; i++) out += space10;
	out = out + msg;
	len=out.length;
	window.status=out.substring(seq, len);
	seq++;
	if ( seq >= len ) { seq = 0; };
	window.setTimeout("Scroll2();", interval );
}

// Zmien zawartosc bloku ident
function writeTo(ident, tekst){
	if (document.all) {//  IE4+ code
		document.all[ident].innerHTML = tekst;
	} else if (document.layers) {//  NS4+ code 
		document.layers[ident].document.open();
		document.layers[ident].document.write(tekst);
		document.layers[ident].document.close();
	} else if (document.getElementById) {// NS6+, Firefox 
		document.getElementById(ident).innerHTML= tekst;
	} 
}

function printdiv(printpage)
{
var headstr = "<html><head><title></title></head><body>";
var footstr = "</body>";
var newstr = document.getElementById(printpage).innerHTML;

var oldstr = document.body.innerHTML;
document.body.innerHTML = headstr+newstr+footstr;
//window.alert("::"+newstr);
window.print(); 
document.body.innerHTML = oldstr;
return false;
}


function expand2(id) // odkrywa/ukrywa text
{
	switch(ln) {
	case 'de': zw='falten';ro='erweitern';break;
	case 'en': zw='fold';  ro='expand';break;
	  default: zw='zwiń';  ro='rozwiń'
	}

	ids=document.getElementById(id).style;
	if (ids.overflow!='visible'){
		ids.overflow='visible';
		ids.height='auto';
		document.getElementById('r'+id.substring(1)).innerHTML='<b>[ &#171; '+zw+'&nbsp; &nbsp;]</b> '}
	else{ids.overflow='hidden';
		ids.height='72px';
		document.getElementById('r'+id.substring(1)).innerHTML='<b>['+ro+' &#187;]</b> '}
}

function onSprzedane() //ofea.php
{
	row = document.getElementById('isprzed').style;
	if(document.getElementById('Fstan').value!="a") row.display = "";
	else row.display = "none";}

