/*******************************************************************
- Funkcija koja otvrara novi prozor u IE5+, Gecko 0.94+ ( kao i prijasnje verzije)
*********************************************************************/

function imgPop(imageURL)
{
	if (document.getElementById && navigator.userAgent.toLowerCase().indexOf('opera') == -1)
	{
		var imgWin = window.open('about:blank','imgWin','width=200, height=200, left=100, top=100');

		with (imgWin.document)
		{
imgWin.document.writeln('<html><head><title>Ucitavam sliku...</title>');
imgWin.document.writeln('<style type="text/css"><!-- body { margin: 0px; } --></style></head>');
imgWin.document.writeln('<body onload="self.focus();"><a href="javascript:window.close()"><img id="pic" style="display:none" border=0/><a/></body></html>');


			close();		
		}

		var img = new Image();
		img.onload = function() { sizeImgWin(imgWin, img); };
                 
		img.src = imageURL;
               // img.onclick=imgPop(this.href);
               //izvrsavanje
	}
	else window.open(imageURL);
}
	
function sizeImgWin(win, img)
{
   	var new_w = img.width;
	var new_h = img.height;
	var old_w = win.innerWidth || win.document.body.offsetWidth;
	var old_h = win.innerHeight || win.document.body.offsetHeight;

	if (!new_w) { new_w = old_w; }
	if (!new_h) { new_h = old_h; }

	new_w -= old_w; new_h -= old_h;
	win.resizeBy(new_w,new_h);
	win.document.title = img.src.substring(img.src.lastIndexOf("/")+1);
	var pic = win.document.getElementById('pic');
	pic.src = img.src;
	pic.style.display = 'block';

	sw=screen.width;
	sh=screen.height;

	var leftPos=((sw-new_w)/2)-100; // Centriraj.
	var topPos=((sh-new_h)/2)-(100+(((sh-new_h)/2)*0.1)); // Centriraj, pa pomjeri za 10% gore%
	win.moveTo(leftPos, topPos);
}



/********************************************************************
- Funkcija koja otvrara novi prozor HTML, za rezultate
********************************************************************/

function OpenPopup (c) {
window.open(c,'window','width=450,height=140,scrollbars=no,status=no');
}





/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/ 

var w=1
var h=1

if (document.getElementById || document.all)
document.write('<div id="trailimageid" style="position:absolute;visibility:hidden;left:0px;top:0px; z-index: 1000;width:1px;height:1px;border:1px solid #001241;background:#F0ECE5;"><img id="ttimg" src="images/container.gif" /></div>')

function gettrailobj()
{
	if (document.getElementById) return document.getElementById("trailimageid").style
	else if (document.all) return document.all.trailimagid.style
}

function truebody()
{
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function hidetrail()
{
	document.onmousemove=""
	document.getElementById('ttimg').src='images/container.gif'
	gettrailobj().visibility="hidden"
	gettrailobj().left=-1000
	gettrailobj().top=0
}


function showtrail(width,height,file)
{
	if(navigator.userAgent.toLowerCase().indexOf('opera') == -1 && navigator.userAgent.toLowerCase().indexOf('safari') == -1)
	{
		w=width
		h=height
		
		// followmouse()
	
		gettrailobj().visibility="visible"
		gettrailobj().width=w+"px"
		gettrailobj().height=h+"px"
		document.getElementById('ttimg').src=file
		document.onmousemove=followmouse
	}
}


function followmouse(e)
{

	if(navigator.userAgent.toLowerCase().indexOf('opera') == -1 && navigator.userAgent.toLowerCase().indexOf('safari') == -1)
	{

		var xcoord=20
		var ycoord=20

		if (typeof e != "undefined")
		{
			xcoord+=e.pageX
			ycoord+=e.pageY
		}
		else if (typeof window.event !="undefined")
		{
			xcoord+=truebody().scrollLeft+event.clientX
			ycoord+=truebody().scrollTop+event.clientY
		}

		var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
		var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)

		if (xcoord+w+3>docwidth)
		xcoord=xcoord-w-(20*2)

		if (ycoord-truebody().scrollTop+h>truebody().clientHeight)
		ycoord=ycoord-h-20;

		gettrailobj().left=xcoord+"px"
		gettrailobj().top=ycoord+"px"

	}

}

