function mywrite(flash)
{
	document.write(flash)
}


function $(name)
{
	obj =  document.getElementById(name);
	return obj;
}



function Sort(f)
{
//	alert(f);
	var s;
	switch (f)
	{
		case 'nr': s = "kolejnosc";
			break;
		case 'pietro': s = "uwagi_pl";
			break;
		case 'metraz': s = "lead_pl";
			break;
		case 'pokoje': s = "wstep_pl";
			break;
	
		default : s = f;
	}

	$("sort").value = s; 

	if ($("dir").value == "asc" ) $("dir").value = "desc";
	else $("dir").value = "asc";
		
	$("S").submit();
}



var pi=0;
function zmien_pietro(nr)
{
	
	$("pietro_"+pi).style.display = "none";
	
	if ($("pietro_"+nr))
	{
		pi = nr;
		$("pietro_"+nr).style.display = "block";
	}
}

function zmien_pietro2(nr)
{
	var l = document.location.href;
	if (l.indexOf("&pt")>0) l = l.substring(0, l.indexOf("&pt"));
	document.location.href = l+"&pt="+nr;
}



function myMail(f)
{
	if (!CheckEMail(f.email.value))
	{
		alert("Prosze podać poprawnie adres e-mail...");
		f.email.focus();
		return false;
	}

	return true;
}


function checkKontakt(f)
{
	if (!f.nazwisko.value)
	{
		alert("Prosze podać imię i nazwisko...");
		f.nazwisko.focus();
		return false;
	}

	
	if (!f.email.value && !f.telefon.value)
	{
		alert("Prosze podać adres e-mail lub telefon kontaktowy...");
		f.email.focus();
		return false;
	}
	
	if (f.email.value && !CheckEMail(f.email.value))
	{
		alert("Prosze podać poprawnie adres e-mail...");
		f.email.focus();
		return false;
	}
	
/*
	if (!f.temat.value)
	{
		alert("Prosze podać temat wiadomości...");
		f.temat.focus();
		return false;
	}
*/

	if (!f.tresc.value)
	{
		alert("Prosze podać treść wiadomości...");
		f.tresc.focus();
		return false;
	}

	return true;
}



function checkPrzedstawiciel(f)
{
	if (!f.nazwisko.value)
	{
		alert("Prosze podać imię i nazwisko...");
		f.nazwisko.focus();
		return false;
	}

	
	if (!f.email.value && !f.telefon.value)
	{
		alert("Prosze podać adres e-mail lub telefon kontaktowy...");
		f.email.focus();
		return false;
	}
	
	if (f.email.value && !CheckEMail(f.email.value))
	{
		alert("Prosze podać poprawnie adres e-mail...");
		f.email.focus();
		return false;
	}
	
/*
	if (!f.temat.value)
	{
		alert("Prosze podać temat wiadomości...");
		f.temat.focus();
		return false;
	}
*/

	if (!f.tresc.value)
	{
		alert("Prosze podać treść wiadomości...");
		f.tresc.focus();
		return false;
	}

	return true;
}



function checkZapytaj(f)
{
	if (!f.nazwisko.value)
	{
		alert("Prosze podać imię i nazwisko...");
		f.nazwisko.focus();
		return false;
	}

	
	if (!f.email.value && !f.telefon.value)
	{
		alert("Prosze podać adres e-mail lub telefon kontaktowy...");
		f.email.focus();
		return false;
	}
	
	if (f.email.value && !CheckEMail(f.email.value))
	{
		alert("Prosze podać poprawnie adres e-mail...");
		f.email.focus();
		return false;
	}
	
/*
	if (!f.temat.value)
	{
		alert("Prosze podać temat wiadomości...");
		f.temat.focus();
		return false;
	}
*/

	if (!f.tresc.value)
	{
		alert("Prosze podać treść wiadomości...");
		f.tresc.focus();
		return false;
	}

	return true;
}

/*
function powieksz(el, fname, s, w)
{
	wys = w + 5;
	szer = s + 25;

	  if(window.screen){
		aw=screen.availWidth;
		ah=screen.availHeight;
	  }else{
		aw=640;
		ah=450;
	  }

	  if (szer>810) szer = 810;
	  if (wys>610) wys = 610;

	str = "foto.php?dir="+escape(el)+"&ph="+escape(fname);
	var win = window.open(str,"zoom","width="+szer+", height="+wys+", left="+(aw-szer)/2+", top="+ (ah-wys)/2+", titlebar=no, status=no, toolbar=no, menubar=no, location=no, resizable=yes, scrollbars=yes, fullscreen=no");
	win.focus();

}
*/

function powieksz(img)
{
	$("zdjecie").src = galeria+img;
}

var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1
var ns6=document.getElementById&&!document.all
var ns4=document.layers

z = 1000;
function showmenu(e,object)
{
	if (!document.all&&!document.getElementById&&!document.layers) 
		return;

	if (window.menuobj) 
		hidemenu();

	clearhidemenu();
	
	menuobj=document.getElementById(object);
	if (menuobj)
	{
		menuobj.thestyle=(ie4||ns6)? menuobj.style : menuobj
		menuobj.thestyle.visibility="visible"
		menuobj.thestyle.zIndex=z++;
	}
//	alert(z + " " +menuobj.thestyle.zIndex);
//	pozobj=document.getElementById('poz_'+object);
//	if (pozobj)
//		pozobj.className='menu_hover';

return false
}

function hidemenu()
{
	if (window.menuobj)
	{
		menuobj.thestyle.visibility=(ie4||ns6)? "hidden" : "hide"
//		pozobj.className='menu';
	}
}

function dynamichide(e)
{
	if (ie4&&!menuobj.contains(e.toElement))
		delayhidemenu()
	else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
		delayhidemenu()
}

function delayhidemenu()
{
	if (ie4||ns6||ns4)
	delayhide=setTimeout("hidemenu()",500)
}

function clearhidemenu()
{
	if (window.delayhide)
		clearTimeout(delayhide)
}


function sel_change(object)
{
	clearhidemenu();

	if (object.className=='zmien_on')
		object.className='zmien_off';
	else
		object.className='zmien_on';
}

if (ie4||ns6)
	document.onClick=hidemenu();
	

var act_odp;
function odp(id)
{
	if ($("odp_"+act_odp))
	{
		$("odp_"+act_odp).style.display = "none";
	}

	if ($("odp_"+id))
	{
		$("odp_"+id).style.display = "block";
		act_odp = id;
	}
	return;
}

var nr=0;
function Woj(numer)
{
	
	if (nr>-2)
	{
		$("woj"+nr).style.display = "none";
	}
	
	if ($("woj"+numer))
	{
		nr = numer;
	}
	else
	{
		nr = -1;
	}

	$("woj"+nr).style.display = "block"
}




// Powiekszanie czcionek

function setActiveStyleSheet(title, reset) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
  if (reset == 1) {
  createCookie("wstyle", title, 365);
  }
}

function setStyle() {
var style = readCookie("wstyle");
if (style != null) {
setActiveStyleSheet(style, 0);
}
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+escape(value)+expires+"; path=/;";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length,c.length));
  }
  return null;
}