ie = (document.all)? 1 : 0
document.write ('<style type="text/css">.lnk,.over,.out { cursor: ',((ie)?'hand':'pointer'),' }</style>')

function getElm(id) {
	return document.getElementById(id)
}
function getStyle(id) {
	return getElm(id).style
}
function show() {
	for (i=0; i<arguments.length; i++)
		getStyle(arguments[i]).visibility = 'visible'
}
function hide() {
	for (i=0; i<arguments.length; i++)
		getStyle(arguments[i]).visibility = 'hidden'
}
function bodyW(){
	return (ie)? document.body.clientWidth : window.innerWidth
}
function bodyH(){
	return (ie)? document.body.clientHeight : window.innerHeight
}
function resizer(page) {
	if ((bodyW() != W) || (bodyH() != H)) center_all(page)
}
function chStatus(s) {
	window.status = (s)? s : ' '
	return true
}
function center_all(page) {
	W = bodyW()
	H = bodyH()

	midX = W>>1
	midY = H>>1

	if ((midY / 2) == (midY >> 1)) midY--

	var obj
	var height
	if (page == 'home') {
		obj = getElm('sve')
		var x = ((obj.style.width)? parseInt(obj.style.width) : obj.offsetWidth) >> 1
		obj.style.left = ((midX - x) > 0)? (midX - x) + 'px' : '3px'

		obj = getElm('cvijet')
		var y = (obj.style.height)? parseInt(obj.style.height) : obj.offsetHeight
		var top = ((H - y - 139) > 0)? (H - y) : 139
		obj.style.top = top + 'px'
	
		obj = getElm('logo')
		obj.style.top = ((top - 125) >> 1) + 'px'
		
		height = top+y

	} else {
		var h1 = (getElm('submenu').offsetHeight+250)
		var h2 = (getElm('content').offsetHeight+160)
		if ((h2 - h1) > 110) {
			getStyle('logo').top = (h2 - 103) + 'px'
			height = h2
		} else {
			getStyle('logo').top = h1 + 'px'
			height = h1 + 90
		}
	}
	
	var bg = getElm('pcela_bg')
	bg.style.width = W + 'px'
	bg.style.height = ((height > H)? height : H) + 'px'
}
function loadActiveImages(imgObj,imgPath) {
	if (!imgPath) imgPath = ''
	eval ('addImage("' + imgObj + '_on", "_img/' + (imgPath + imgObj) + '_on.gif")' )
	eval ('addImage("' + imgObj + '_off", "_img/' + (imgPath + imgObj) + '_off.gif")' )
}
function addImage(imgObj,imgSrc) {
	eval ( imgObj + ' = new Image()' )
	eval ( imgObj + '.src = "' + imgSrc + '"' )
	eval ( 'document.getElementById("images_loader").appendChild(' + imgObj + ')' )
}

loading_idle = 0
restarts = 0
function load_content(frameName,fn,oldCompleted) {
	var crtice = ''

	var completed = 0
	var slike = getElm(frameName).getElementsByTagName('IMG')
	var max = slike.length
	for (i=0; i<max; i++) {
		if (slike[i].complete) completed++
	}

	if (oldCompleted == completed) {
		if (!loading_idle) {
			loading_idle = new Date()
		} else {
			var now_time = new Date()
			if ((now_time.getTime() - loading_idle.getTime()) > (10000+(restarts*5000))) {
				loading_idle = 0
				restarts++
				for (i=0; i<max; i++) {
					if (!slike[i].complete) slike[i].src = slike[i].src
				}
			}
		}
	} else {
		loading_idle = 0
		var postotak = completed/slike.length
		if (postotak > 1) postotak = 0.99
		var crtice_broj = Math.floor(postotak * 20)
		for (i=0; i<20; i++) {
			crtice += (i<crtice_broj)? '.' : ' '
		}
		getElm('load_bar').innerHTML = '<pre>  [ ' + crtice + ' ]</pre>'
	}
	
	if (completed == max) {
		hide('loader')
		if (fn) eval(fn)
		restarts = 0
	} else {
		window.setTimeout('load_content("'+frameName+'","'+fn+'",'+ completed +')',1)
	}
}
function open_slika(n) {
	window.open("big_img.php?s="+n,"Galerija","width=420,height=360,scrollbars=no,resizable=no,screenX=30,screenY=30")
}

