	function SetStartPage(){ 
		dom.setHomePage("http://www.unikat.pl"); 
	} 

	function Favourite(){ 
		window.external.AddFavorite('http://www.unikat.pl/','Najlepsze nieruchomości w najlepszym biurze UNIKAT')
	} 

	function winOpen(url, name, args, str) 
	{
		if (typeof(popupWin) != "object")
		{
			popupWin = window.open(url,name,args);
			popupWin.document.write(str);
		} else 
		{
			if (!popupWin.closed)
			{			
				popupWin.window.close();
				popupWin = window.open(url,name,args);
				popupWin.document.write(str);			
			} else {
				popupWin = window.open(url, name,args);
				popupWin.document.write(str);
			}
		}
		popupWin.focus();
	}
	

// Znajduje elastycznie element DOM.
// Jeśli elem jest obiektem, to go zwraca i już.
// Jeśli elem jest nazwą, to szuka wg id i name. Dla przycisku typu "radio"
// zwraca listę wszystkich o tej samej nazwie z jednego formularza.
function FindElement(elem)
{
  if(typeof(elem) == 'string'){
    var found = document.getElementById(elem);  // chyba IE po nazwie też znajduje 
    if(found == null){
      found = document.getElementsByName(elem)[0];
    }
    // odszukanie całej grupy przycisków o tej samej nazwie
    elem = found;
    //ShowObjectProperties(elem);
//    if(elem.type == 'radio'){
//      elem = elem.form.elements[elem.name];
//    }
  }
  return elem;
}

	function Switch( ShowID ) {
		div1 = FindElement('Div1');
		div2 = FindElement('Div2');
		div3 = FindElement('Div3');		
		table1 = FindElement('Table1');
		table2 = FindElement('Table2');		
		table3 = FindElement('Table3');				
		
		if (ShowID == '1') {
			div1.className = 'DivVisible';
			div2.className = 'DivHidden';	
			div3.className = 'DivHidden';				
			table1.className = 'TabOver';								
			table2.className = 'TabNormal';					
			table3.className = 'TabNormal';								
		} 
		if (ShowID == '2')  {
			div1.className = 'DivHidden';
			div2.className = 'DivVisible';						
			div3.className = 'DivHidden';
			table1.className = 'TabNormal';											
			table2.className = 'TabOver';								
			table3.className = 'TabNormal';												
		} 
		if (ShowID == '3')  {
			div1.className = 'DivHidden';
			div2.className = 'DivHidden';			
			div3.className = 'DivVisible';						
			table1.className = 'TabNormal';								
			table2.className = 'TabNormal';											
			table3.className = 'TabOver';								
		}		
	}
	
	function Validate (form) {
		typn = FindElement('typn');
		kat = FindElement('kat');
		miejsc = FindElement('miejsc');
		listingID = FindElement('ListingID');
		
		
		if ( Trim(listingID.value)!='') return true;
		
		if (typn.value==0) {
			alert('Proszę wybrać typ nieruchomości lub wpisać numer oferty');	
			return false;
		}
		
		if (kat.value==0) {
			alert('Proszę wybrać kategorię lub wpisać numer oferty');	
			return false;
		}		
	
		if (miejsc.value==0) {
//			alert('Wybierz miejscowość');	
//			return false;
		}		
	
		return true;
	}	
	
	
	function Trim( tekst ) {
	    return tekst.replace( /^\s+|\s+$/g, "" );
	}
	
	
	
// ***************************************	
	



function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
	
//	return	window.innerHeight ? window.innerHeight : document.body.clientHeight ;
}


function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}


function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}


function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}



var timer;
var ms=0;
var newy = 0;

var counter = 0;

function AlignBottomBanner() {
		
	var banner = document.getElementById('PaperNote');
	if (!banner) return false;
	
	
	newy = f_scrollTop() + 30;
	var str = (Math.abs(newy) + Math.abs(banner.offsetTop) )/ 2;
//	alert(str);
//	banner.style.display = 'block';	
	banner.style.top = str + 'px';
}



function scrolltop()
{
	AlignBottomBanner();
	timer = setTimeout("scrolltop()",100);
}

function stoptimer()
{
	clearTimeout(timer);
}


scrolltop();



function HidePaperNote() {

	var banner = document.getElementById('PaperNote');
	if (!banner) return false;
	
	banner.style.display = 'none';		
	
	stoptimer();
}


function DoTask( stask, sid, typ ) {

	//sid = -2 znaczy z listy ofert 
	//sid = -1 znaczy z koszyka		
	if (sid==-2 && NotSelected()) {
		NotSelected_Msg();
		return false;
	}	
	
	form = FindElement('ListingsForm');
	task = FindElement('ListingsTask');
	if (task!=null) task.value = '';
	
	var url = '';
	var target = '_blank';
	
	if (stask=='ask') {
		url = 'ign_Email.php?id='+sid+'&type=ask'
		if (typ!=undefined) url = url + '&typ='+typ
		target = "_top";				
	} else
	if (stask=='save') {
		url = 'pdf.php?id='+sid+'&type=1'
		if (typ!=undefined) url = url + '&typ='+typ		
	} else	
	if (stask=='email') {
		url = 'ign_Email.php?id='+sid+'&type=email'
		if (typ!=undefined) url = url + '&typ='+typ		
		target = "_top";				
	} else	
	if (stask=='print') {
		url = 'pdf.php?id='+sid+'&type=0'
		if (typ!=undefined) url = url + '&typ='+typ		
		target = "_blank";		
	} else	
	if (stask=='add') {
		target = "_top";		
		if (task!=null) task.value = 'a';		
	} else	
	if (stask=='rem') {
		target = "_top";		
		if (task!=null) task.value = 'r';		
	}		
	

	
	if (form!=null) {
//		alert('ok');
		form.action = url;
		form.target = target;
		form.submit();
	} else {
//		alert('nook');		
	}
}


function GetCheckboxValue(controlName) {
	d = document.getElementById(controlName);
	if (d!=null) return d.checked;	
			else return null;	
}




function NotSelected() {
	var ret = 0;
	for (a=1; a<=20; a++) {
		if (GetCheckboxValue('Listings_'+a)) ret++;
	}

	return (ret==0);
}


function NotSelected_Msg() {
	alert('Proszę zaznaczyć przynajmniej jedną ofertę, klikając pole zaznaczenia po lewej stronie wiersza tabeli.');
}


function is_numeric( mixed_var ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: David
    // +   improved by: taith
    // +   bugfixed by: Tim de Koning
    // *     example 1: is_numeric(186.31);
    // *     returns 1: true
    // *     example 2: is_numeric('Kevin van Zonneveld');
    // *     returns 2: false
    // *     example 3: is_numeric('+186.31e2');
    // *     returns 3: true
    // *     example 4: is_numeric('');
    // *     returns 4: false
 
    if (mixed_var === '') {
        return false;
    }
 
    return !isNaN(mixed_var * 1);
}
