var targetDiv = "";

function printURL()
{
	var header = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Printable version</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>';
	header += '<link rel="stylesheet" href="/css/default.css" type="text/css"/></head>';
	header += '<body onload="window.print();" style="margin: 0px auto; text-align: center;">';
	header += '<div id="print" style="width: 625px; margin: 0px auto; text-align: left;">';
	var footer = '</div></body></html>';

	var strInner = document.body.innerHTML;
	var startPos = strInner.lastIndexOf("<!-- print_start -->");	
	var endPos = strInner.lastIndexOf("<!-- print_end -->");
	strInner = strInner.substring(startPos+20, endPos);
		
	if (strInner.lastIndexOf("<!-- print_pause_on -->") > -1)
	{
		var str1 = "<!-- print_pause_on -->";
		var str2 = "<!-- print_pause_off -->";

		startPos = strInner.lastIndexOf(str1);	
		endPos = strInner.lastIndexOf(str2);

		if (endPos > startPos)
		{
			leftStr = strInner.substr(0, startPos);
			rightStr = strInner.subst(endPos + str2.length, strInner.length);
			strInner = leftStr + rightStr;
		}
	}

	var xwin = window.open("", "PrintVersion", "width=665, menubar=yes, toolbar=yes, statubar=no, scrollbars=yes, resizable=yes");

	xwin.document.open();
	xwin.document.write(header+strInner+footer);
	xwin.document.close();
}

function isPPC() {
	if (navigator.appVersion.indexOf("PPC") != -1) return true;
	else return false;
}

function sendPage(mailHeadline){
	if(!isPPC()) {
		window.location="mailto:\?subject\=" + mailHeadline + "&body=" + mailHeadline + ": " + window.location;
	}else { 
		window.location="mailto:\?body=" + mailHeadline + ": " + window.location;
	}
}

function switchDisplay(obj)
{
	basicclass = "mala_najava";
	additionalclass= " hidden";

	if(obj.parentNode.className == basicclass)
	{
		obj.parentNode.className = basicclass+additionalclass;
	}
	else
	{
		obj.parentNode.className = basicclass;
	}
	
}

function ajax(value, curr1, curr2, resultDiv)
{
	if (isNaN(value) || value == "")
	{
		alert("Morate uneti numeričku vrednost.");

		return false;
	}
	else
	{
		targetDiv = resultDiv;
		
		xmlHttpCustom = GetXmlHttpObjectCustom();

		if (xmlHttpCustom == null)
		{
			alert ("Browser does not support HTTP Request");
			return;
		}

		url = "/asp/exchange_rate/ajax.asp?exchangeValue="+value+"&curr1="+curr1+"&curr2="+curr2;

		xmlHttpCustom.onreadystatechange = stateChangedCustom;
		xmlHttpCustom.open("GET",url,true);
		xmlHttpCustom.send(null);
	}
}

function stateChangedCustom() 
{
	if (xmlHttpCustom.readyState == 4 || xmlHttpCustom.readyState == "complete")
	{
		document.getElementById(targetDiv).innerHTML = xmlHttpCustom.responseText;
	}
}

function GetXmlHttpObjectCustom()
{
	var xmlHttp = null;

	try
	{
		xmlHttp = new XMLHttpRequest();
	}
		catch (e)
	{
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}

	return xmlHttp;
}

function noEnterKey()
{
	if (window.event && window.event.keyCode == 13)
	{
		return false;
	}
}

function levelUpHeights()
{
	h1 = document.getElementById("home_content").offsetHeight;
	h2 = document.getElementById("home_news").offsetHeight;
	h3 = document.getElementById("contentRight").offsetHeight;

	var h = Math.max(h1, h2, h3);

	document.getElementById("home_content").style.height = h + "px";
	document.getElementById("home_news").style.height = h + "px";
	document.getElementById("contentRight").style.height = h + 5 + "px";
}