//-----------------------------------------------
//delo s cookiji
function setCookie(name, value, days, path, domain, secure) {
	days = (isNaN(days)? 1: days)
	var date = new Date();
	date.setTime(date.getTime()+(escape(days)*24*60*60*1000));

	var curCookie = name + "=" + escape(value) +
	((date) ? "; expires=" + date.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
	document.cookie = curCookie;
}

function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else {
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}

function delCookie(name){
	setCookie(name, "", -1);
}
//-----------------------------------------------

function OpenWindow(URL, Name, Width, Height) {
	var PositionX = 0;
	var PositionY = 0;
	var DefaultWidth  = 600;
	var DefaultHeight = 400;
	var WinObject, Params = 'scrollbars=1, resizable=1, left=' + PositionX + ', top=' + PositionY;
	Params += ', width=' + ((isNaN(parseInt(Width))) ? DefaultWidth : Width);
	Params += ', height=' + ((isNaN(parseInt(Height))) ? DefaultHeight : Height);
	WinObject = window.open(URL, Name, Params)
	if (!WinObject) return true;
	if (WinObject.focus) WinObject.focus();
	return false;
}


function InsertFlash(Target, ID, Version, File, Width, Height, Parameters) {
	var ParametersObjectStr = ''
	var ParametersEmbedStr = ''
	var s, v
	for (s in Parameters) {
		v = Parameters[s]
		ParametersObjectStr += '<param name="'+s+'" value="'+v+'" />'
		ParametersEmbedStr += ' '+s+'="'+v+'" '
	}
	var FlashHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ' +
			'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+Version+',0,0,0" ' +
			'width="'+Width+'" height="'+Height+'" id="'+ID+'">' +
			'<param name="movie" value="'+File+'" />' +
			ParametersObjectStr +
			'<embed src="'+File+'" menu="true" ' +
				'pluginspage="http://www.macromedia.com/go/getflashplayer"  ' +
				'type="application/x-shockwave-flash" width="'+Width+'" height="'+Height+'" name="'+ID+'" '+ParametersEmbedStr+' />' +
		'</object>'
	document.getElementById(Target).innerHTML = FlashHTML
}

function VerifyBrowserFlashSupport(FlashVersion) {
	var flashinstalled = 0;
	var flashversion = 0;
	if (navigator.plugins && navigator.plugins.length) {
		var x = navigator.plugins["Shockwave Flash"];
		if (x) {
			flashinstalled = 2;
			if (x.description) {
				var y = x.description;
				if (y.charAt(y.indexOf('.')-1)+'' == FlashVersion+'') return true;
			}
		}
		if ((FlashVersion == 2) && (navigator.plugins["Shockwave Flash 2.0"])) {
			return true;
		}
	} else if (navigator.mimeTypes && navigator.mimeTypes.length) {
	} else {
		try{
			var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + FlashVersion);
			return true;
		}
		catch(e){
		}
	}
	return false;
}

function InsertFlashOrHTML(Target, ID, Version, File, Width, Height, Parameters, NoFlashHTML) {
	if (VerifyBrowserFlashSupport(Version)) {
		InsertFlash(Target, ID, Version, File, Width, Height, Parameters)
	} else {
		document.getElementById(Target).innerHTML = NoFlashHTML
	}
}

function enlargeImage(content, title, close) {
	top.consoleRef=window.open('','enlargeImage', 'menubar=0,toolbar=0,status=0,scrollbars=0,resizable=0');
	top.consoleRef.document.writeln('<html><head><title>' + title + '</title>');
	top.consoleRef.document.writeln('<sc' + 'ript language="javascript" type="text/javascript">');
	top.consoleRef.document.writeln('<!--');
	top.consoleRef.document.writeln('	var NS = (navigator.appName==\'Netscape\')?true:false;');
	top.consoleRef.document.writeln('	function fitPic(){');
	top.consoleRef.document.writeln('		iWidth = document.images[1].width;');
	top.consoleRef.document.writeln('		iHeight = document.images[1].height;');
	top.consoleRef.document.writeln('		window.resizeTo(iWidth + 30, iHeight + 90);');
	top.consoleRef.document.writeln('	}');
	top.consoleRef.document.writeln('	function printIt(){');
	top.consoleRef.document.writeln('		//document.getElementById("header").style.display = \'none\';');
	top.consoleRef.document.writeln('		document.getElementById("header").style.visibility = \'hidden\';');
	top.consoleRef.document.writeln('		if(window.print){');
	top.consoleRef.document.writeln('			window.print();');
	top.consoleRef.document.writeln('		}else{');
	top.consoleRef.document.writeln('			var WebBrowser = \'<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>\';');
	top.consoleRef.document.writeln('			document.body.insertAdjacentHTML(\'beforeEnd\', WebBrowser);');
	top.consoleRef.document.writeln('			WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box WebBrowser1.outerHTML = "";');
	top.consoleRef.document.writeln('		}');
	top.consoleRef.document.writeln('		//document.getElementById("header").style.display = \'block\';');
	top.consoleRef.document.writeln('		document.getElementById("header").style.visibility = \'visible\';');
	top.consoleRef.document.writeln('	}');
	top.consoleRef.document.writeln('//-->');
	top.consoleRef.document.writeln('</sc' + 'ript>');
	top.consoleRef.document.writeln('</head>');
	top.consoleRef.document.writeln('<body marginwidth=\'0\' marginheight=\'0\' leftmargin=\'0\' rightmargin=\'0\' topmargin=\'0\' bottommargin=\'0\' onLoad=\'fitPic();self.focus();\'>');
	top.consoleRef.document.writeln('<table width="100%" height="100%" border="0"><tr id="header"><td align="left"><a href="javascript:void(0);" onclick="printIt();"><img src="design/printer.gif" border="" align="absmiddle" /></a></td><td align="right"><a href="javascript:void(0);" onclick="self.close();" style="font-family:Tahoma;font-size:11px;">' + close + '</a></td></tr><tr><td align="center" valign="middle" colspan="2"><img id="theImage" src="imagelib/source/' + content + '" border="0" alt="' + title + '" /></td></tr></table>');
	top.consoleRef.document.writeln('</body></html>');
	top.consoleRef.document.close()
}

function OdpriPopup(url, sirina, visina, dodatno){
	params = 'width='+sirina+',height='+visina+',location=no,menubar=yes,status=no,toolbar=no,scrollbars=yes'+dodatno;
	/*window.open(url, 'PrintPreview'+Math.round(Math.random(1000)*100), params);*/ //ce hoces, da se odpre vsak v novem oknu
	window.open(url, 'PrintPreview', params);
	return false;
}

function ChangeCss(theClass,element,value){
	var cssRules;
	var s,r;
	if(document.all){
		cssRules = 'rules';
	}else if (document.getElementById){
			cssRules = 'cssRules';
	}
	for(var S = 0; S < document.styleSheets.length; S++){
		for(var R = 0; R < document.styleSheets[S][cssRules].length; R++){
			if(document.styleSheets[S][cssRules][R].selectorText == theClass){
				//alert(document.styleSheets[S][cssRules][R].selectorText + ':' + value);
				document.styleSheets[S][cssRules][R].style[element] = value;
			}
		}
	}
}

function GetCss(theClass,element){
	var cssRules;
	var s,r;
	if (document.all){
		cssRules = 'rules';
	}else if(document.getElementById){
			cssRules = 'cssRules';
		}
	for(var S = 0; S < document.styleSheets.length; S++){
		for(var R = 0; R < document.styleSheets[S][cssRules].length; R++){
			if(document.styleSheets[S][cssRules][R].selectorText == theClass){
				//alert(document.styleSheets[S][cssRules][R].selectorText + ':' + value);
				return document.styleSheets[S][cssRules][R].style[element];
			}
		}
	}
	return 0;
}

var xsize;
xsize = parseInt(getCookie("FontSizeInc"));
if(isNaN(xsize)){
	xsize = 0;
}

SetFontSize(".bdy");
SetFontSize(".text_blue_title");

function SetFontSize(theClass){
	FontSizeCookie = parseInt(getCookie(theClass));
	if(!isNaN(FontSizeCookie)){
		ChangeCss(theClass, "fontSize", FontSizeCookie+"px");
	}
}

function IncreaseFontSize(theClass){
	var px_str, px;
	px_str = GetCss(theClass, "fontSize"); px_str = px_str.replace("px", ""); px = parseInt(px_str);
	ChangeCss(theClass, "fontSize", (px+1)+"px");
	setCookie(theClass, px+1)
}

function DecreaseFontSize(theClass){
	var px_str, px;
	px_str = GetCss(theClass, "fontSize"); px_str = px_str.replace("px", ""); px = parseInt(px_str);
	ChangeCss(theClass, "fontSize", (px-1)+"px");
	setCookie(theClass, px-1)
}

var tgs = new Array('div','td','tr','a');
//Specify spectrum of different font sizes:
var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var startSz = 2;
function ts( trgt,inc ) {
      if (!document.getElementById) return
      var d = document,cEl = null,sz = startSz,i,j,cTags;
     sz += inc;
      if ( sz < 0 ) sz = 0;
      if ( sz > 6 ) sz = 6;
      startSz = sz;
      if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];
      cEl.style.fontSize = szs[ sz ];
      for ( i = 0 ; i < tgs.length ; i++ ) {
            cTags = cEl.getElementsByTagName( tgs[ i ] );
            for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
      }
}

/*
function zoomText(size){
  var obj=document.getElementsByTagName("*");
  for(var i=0;i<obj.length;i++){
    obj[i].style.fontSize=size;
  }
}
*/

var mapisvisible;
function showHideContent(id, show){
	var elem = document.getElementById(id);
	if(elem){
		if(show){
			elem.style.display = 'block';
			elem.style.visibility = 'visible';
		}else{
			elem.style.display = 'none';
			elem.style.visibility = 'hidden';
		}
		mapisvisible != mapisvisible;
	}
}
/*
<div id="someRegion">
...
</div>
<input type="button" value = "Hide Content" onclick="showHideContent('someRegion', false);">
<input type="button" value = "Show Content" onclick="showHideContent('someRegion', true);">
*/


function rtrim(argvalue) {
  while (1) {
    if (argvalue.substring(argvalue.length - 1, argvalue.length) != " ")
      break;
    argvalue = argvalue.substring(0, argvalue.length - 1);
  }
  return argvalue;
}

function ltrim(argvalue) {
  while (1) {
    if (argvalue.substring(0, 1) != " ")
      break;
    argvalue = argvalue.substring(1, argvalue.length);
  }
  return argvalue;
}

function trim(argvalue) {
  var tmpstr = ltrim(argvalue);
  return rtrim(tmpstr);
}