var msg="Welcome to EDYTA ";
var mywin = null;

function okno_wyb2(link,nazwa,szer,wys)
{
	var SupAg="edyta";
	var FIRMA="70";

	var centerWidth=(window.screen.width-szer)/2;
	var centerHeight=(window.screen.height-wys)/4;
	var lng=link.substring(0,2);

	if(link.substring(3,14)=="wyb_lok.php"){
		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(20,23)=="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;
			}
		}

	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=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width='+szer+
		',height='+wys+',left=' + centerWidth +',top=' + centerHeight);

	mywin.focus();
//	return mywin.name;
}

// wybiera z linku numer biura nieruch. 
function ofertaZ(str)
{  return(str.substr(str.indexOf("Fid=")+4,2)); }

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 */

//string na wyjściu: tylko liczby i '.'
function check(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(isNaN(parseInt(znak)))zmiana=true;
	else zwr+=znak;
	}
if(!zmiana) return;
form.elements[el].value=zwr;
}

//string 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;
}

/*checkLimit
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 check_tmp(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 expand2(id) // odkrywa/ukrywa text
{
	ids=document.getElementById(id).style;
	if (ids.overflow!='visible'){
		ids.overflow='visible';
		ids.height='auto';
		document.getElementById('r'+id.substring(1)).innerHTML='<b>[ &#171; zwiń&nbsp; &nbsp;]</b> '}
	else{ids.overflow='hidden';
		ids.height='72px';
		document.getElementById('r'+id.substring(1)).innerHTML='<b>[rozwiń &#187;]</b> '}
}
