function browserCheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=(navigator.userAgent.indexOf("Opera")>-1 && document.getElementById)?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie7=(this.ver.indexOf("MSIE 7")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6||this.ie7
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie7 || this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}
var browser=browserCheck()
var jsDOM0 = (document.all);
var jsDOM1 = (document.getElementById);
var jsDOM = jsDOM0 || jsDOM1;
var jsDebug = 0;

var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body


function getObj (name)
{
    if (typeof name == "object") return name;
    if (jsDOM1) return document.getElementById(name);
    if (jsDOM0) return eval('document.all.'+name);
    else return null;
}
	
function hideSelects(a) {
	if (document.getElementById) {
		var tags = ['select', 'iframe', 'object'];
		for (var t in tags) {
			var elms = document.getElementsByTagName(tags[t]);
			for (var e = 0; e < elms.length; e++) {
				elms[e].style.visibility = a ? 'visible' : 'hidden';
			}
		}
	}
}

function show(id)
{
	oLayer = getObj (id);
	oLayer.style.display = 'block';
}

function hide(id)
{
	oLayer = getObj (id);
	oLayer.style.display = 'none';
}

// pouziva sa pre elementy zobrazene s relativnou poziciou, nie absolutne. teda pre tie objekty, ktore nic neprekryvaju.
function toggleDiv(obj) {
	temp = getObj (obj);
	if (temp.style.display == 'none') {
		temp.style.display = 'block';
	} else {
		temp.style.display = 'none';
	}
}

// background change of the object. ID passed
function toggleBgr(id) {
	color1="#f8df55";
	color2="#dddddd";
	temp = getObj (id);
	temp.style.backgroundColor = temp.style.backgroundColor==color1?color2:color1;
}

// background change of the object. Object reference passed
function toggleBgrThis(obj) {
	color1="#f8df55";
	color2="#dddddd";
	obj.style.backgroundColor = obj.style.backgroundColor==color1?color2:color1;
}

function changePhoto(id)
{
	temp = getObj ('bigger');
	temp.src = 'userfiles/properties/___medium_'+images[id];
	temp = getObj ('biggerCaption');
	temp.innerHTML = captions[id];
}

function divShow(a) {
	hideSelects(0);
	document.getElementById(a).style.display='block'
}

function divHide(a) {
	document.getElementById(a).style.display='none'
	hideSelects(1);
}

// * * * photoShow * * *
function photoShow(a) {
	hideSelects(0);
	
	wTop=document.all? (document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop) : pageYOffset;	

	document.getElementById('photoShowImg').style.display='none'
	document.getElementById('photoShowLoading').style.display='block'
	document.getElementById('photoShowImg').src="userfiles/"+a
	document.getElementById('photoShow').style.top=(wTop+100)+"px"
	document.getElementById('photoShow').style.display='block'
}

function photoHide() {
	document.getElementById('photoShow').style.display='none'
	hideSelects(1);
}


// * * * slideshow * * *
var slideShowTimer;
var slideShowCurrent=0;
		
function slideShowRun(a) {
	wTop=document.all? (document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop) : pageYOffset;	

	document.getElementById('slideShow').style.top=(wTop+100)+"px"
	document.getElementById('slideShow').style.display='block'
	clearInterval(slideShowTimer);
	if (!a) a=slideShowPhotos[0][0]
	slideShowMove(a);
	slideShowTimer = setInterval(slideShowMove, 3000);
	temp = getObj ('slideShowPlay');
	temp.src = 'images/slide_show_play_i.gif';
	temp = getObj ('slideShowStop');
	temp.src = 'images/slide_show_stop.gif';
}

function slideShowStop() {
	clearInterval(slideShowTimer);
	temp = getObj ('slideShowPlay');
	temp.src = 'images/slide_show_play.gif';
	temp = getObj ('slideShowStop');
	temp.src = 'images/slide_show_stop_i.gif';
}

function slideShowMove(aa) {
	if (aa!=1 && aa!=-1) aa=1;
	if (aa==1 || aa==-1) {
		slideShowCurrent=slideShowCurrent-(-aa)
		if (slideShowPhotos.length<=slideShowCurrent) {
			slideShowCurrent=0;
		}
		if (slideShowCurrent<0) {
			slideShowCurrent=slideShowPhotos.length-1;
		}
	} else {
		for (var t in slideShowPhotos) {
			if (slideShowPhotos[t][0]==aa) {
				slideShowCurrent=t
			}
		}
	}
	document.getElementById('slideShowPhoto').style.display='none'
	document.getElementById('slideShowLoading').style.display='block'
	document.getElementById('slideShowPhoto').src="userfiles/"+slideShowPhotos[slideShowCurrent][0]
	document.getElementById('slideShow').style.display='block'
	document.getElementById('slideShowCaption').innerHTML=slideShowPhotos[slideShowCurrent][1]
}

function slideShowHide() {
	clearInterval(slideShowTimer);
	document.getElementById('slideShow').style.display='none'
	hideSelects(1);
}

// * * * /slideshow * * *


// * * * titleDiv * * *

fromX = -5 //How much from the actual mouse X should the description box appear?
fromY = 20 //How much from the actual mouse Y should the description box appear?

var px = browser.ns4||window.opera?"":"px";

//Capturing mousemove
var descx = 0
var descy = 0
function titleMouseMove(e) {
	descx=browser.ns4||browser.ns6?e.pageX:event.x;
	descy=browser.ns4||browser.ns6?e.pageY:event.y
}

function titleShow(text, o){
	oTitleDiv = getObj ('titleDiv');
	 if(oTitleDiv){
		if (browser.ns4) {
			oTitleDiv.write(text);oTitleDiv.close()
		} else {
			oTitleDiv.innerHTML = text
		}

		if(browser.ie5||browser.ie6||browser.ie7) descy = descy+document.body.scrollTop
		oTitleDiv.style.left = (descx+fromX)+px
		oTitleDiv.style.top = (descy+fromY)+px
		oTitleDiv.style.display = "block"
    }
	o.onmouseout = function anonymous() {
		oTitleDiv = getObj ('titleDiv');
		if (oTitleDiv) oTitleDiv.style.display = "none"
	}
}

function titleHide(){
	oTitleDiv = getObj ('titleDiv');
	if (oTitleDiv) oTitleDiv.style.display = "none"
}

function titleSetPopup(){
	if(bw.ns4)document.captureEvents(Event.MOUSEMOVE)
	document.onmousemove = titleMouseMove;
}	

titleSetPopup()

/*
function supplyCount(listFilterArea, listFilterMinPrice, listFilterMaxPrice, listFilterAdd, listFilterPerson, listFilterPredaj) {
	document.getElementById('frm_base').src='common/supply_count.php?listFilterArea='+listFilterArea+'&listFilterMinPrice='+listFilterMinPrice+'&listFilterMaxPrice='+listFilterMaxPrice+'&listFilterAdd='+listFilterAdd+'&listFilterPerson='+listFilterPerson+'&listFilterPredaj='+listFilterPredaj;
*/

function supplyCount(listFilterArea, listFilterMinPrice, listFilterMaxPrice, listFilterAdd, listFilterPredaj, listFilterSupplyType) {
	document.getElementById('frm_base').src='common/supply_count.php?listFilterArea='+listFilterArea+'&listFilterMinPrice='+listFilterMinPrice+'&listFilterMaxPrice='+listFilterMaxPrice+'&listFilterAdd='+listFilterAdd+'&listFilterPredaj='+listFilterPredaj+'&listFilterSupplyType='+listFilterSupplyType;
}



function BookmarkThis(page_url) {
	var ver = navigator.appName;
	var num = parseInt(navigator.appVersion);
	if( (ver == "Microsoft Internet Explorer")&&(num >= 4)) {
		window.external.AddFavorite(location.href,document.title);
	} else {
		alert("Sorry. Netscape users must bookmark the pages manually by hitting <Ctrl-D>");
	}
	return false;
}

function show(id)
{
	oLayer = getObj (id);
	oLayer.style.display = 'block';
}

function hide(id)
{
	oLayer = getObj (id);
	oLayer.style.display = 'none';
}

function Another(obj)
{
	oAnother = getObj (obj);
	if (oAnother.style.display == 'none') 
	{
		oAnother.style.display = 'block';
	}
	else 
	{
		oAnother.style.display = 'none';
	}
}

function ChangePic(pic)
{
	oPic = getObj ('bigger');
	oPic.src = 'userfiles/'+pic;
}

function ShowPic(){
	oDivPhoto = getObj ('photoWin');
	oDivPhoto.style.display = 'block';
	Run();
}

function HidePic(){
	oDivPhoto = getObj ('photoWin');
	oDivPhoto.style.display = 'none';
}

// * * * slideshow * * *
var oTimer;
		
function Run()
{
	clearInterval(oTimer);
	oTimer = setInterval(StepCount, 3000);
	oButtonPlay = getObj ('play');
	oButtonPlay.src = 'images/d__play.gif';
	oButtonStop = getObj ('stop');
	oButtonStop.src = 'images/stop.gif';
}

function Stop()
{
	clearInterval(oTimer);
	oButtonPlay = getObj ('play');
	oButtonPlay.src = 'images/play.gif';
	oButtonStop = getObj ('stop');
	oButtonStop.src = 'images/d__stop.gif';
}

function StepCount()
{
	oImg = getObj ('photo');
	if (counter < (images.length-1)) 
	{
		counter++;
	}
	else 
	{
		counter = 0;
	}	
	oImg.src = 'userfiles/'+images[counter];
}

function Previous()
{
	oImg = getObj ('photo');
	if (counter == 0) 
	{
		counter = (images.length-1);
	}
	else 
	{
		counter--;
	}	
	oImg.src = 'userfiles/'+images[counter];
}

function Next()
{
	oImg = getObj ('photo');
	if (counter < (images.length-1)) 
	{
		counter++;
	}
	else 
	{
		counter = 0;
	}	
	oImg.src = 'userfiles/'+images[counter];
}
// * * * /slideshow * * *

function Switcher()
{
	oBox = getObj ('lease_hold');
	oField = getObj ('lease_remaining');
	if (oBox.checked)
	{
		oField.disabled = false;
		oField.style.backgroundColor = '#f3f8cf';
	}
	else
	{
		oField.disabled = true;
		oField.style.backgroundColor = '#ffffff';
	}
}

function userfileToggle(field) {
	if (document.getElementById(field+'_delete').value==0) {
		document.getElementById(field+'_delete').value=1;
		document.getElementById(field+'_linkRemove').style.display='none';
		document.getElementById(field+'_linkUndo').style.display='';
	} else {
		document.getElementById(field+'_delete').value=0;
		document.getElementById(field+'_linkRemove').style.display='';
		document.getElementById(field+'_linkUndo').style.display='none';
	}
	return false;
}

function cookieWrite(name, value, hours) {
  var expire = "";
  if(hours != null) {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}

function cookieRead(name) {
  var cookieValue = "";
  var searchString = name + "=";
  if(document.cookie.length > 0) {
    offset = document.cookie.indexOf(searchString);
    if (offset != -1) { 
      offset += searchString.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end));
    }
  }
  return cookieValue;
}