var msg="Welcome to www.mswo.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=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;
			}
		}

//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.menu_r.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;
}

/*
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> '}
}

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> '}
}



//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;
	} 
}


