/* tiskanje dokumenta */

var strQueryString;
strQueryString = '';
 
function printpreview()
{
	var scrnwdth = 0;
	var scrnhght = 0;
	var wdth = 640;
	var hght = 450;
	var lft;
	var tp;
	if((window.screen) && (screen.width) && (screen.height)) {scrnwdth = screen.width; scrnhght = screen.height;}
	if(scrnwdth != 0) lft = (scrnwdth - wdth)/2;
	if(scrnhght != 0) tp = (scrnhght - hght)/2;
	var prn = null;
	prn = window.open(location.pathname + '?blnPrint=true' + strQueryString, 'prnwnd', 'width=' + wdth + ',height=' + hght + ',left=' + lft + ',top=' + tp + ',screenX=' + lft + ',screenY=' + tp + ',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes');
	//alert ('/frameset_print.asp?' + location.protocol + '//' + location.host + location.pathname + '?blnPrint=true' + strQueryString, 'prnwnd', 'width=' + wdth + ',height=' + hght + ',left=' + lft + ',top=' + tp + ',screenX=' + lft + ',screenY=' + tp + ',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes');
	if (prn.blur) prn.focus();
}

function printpreviewen()
{
	var scrnwdth = 0;
	var scrnhght = 0;
	var wdth = 640;
	var hght = 450;
	var lft;
	var tp;
	if((window.screen) && (screen.width) && (screen.height)) {scrnwdth = screen.width; scrnhght = screen.height;}
	if(scrnwdth != 0) lft = (scrnwdth - wdth)/2;
	if(scrnhght != 0) tp = (scrnhght - hght)/2;
	var prn = null;
	prn = window.open('/en/frameset_print.asp?' + location.protocol + '//' + location.host + location.pathname + '?blnPrint=true' + strQueryString, 'prnwnd', 'width=' + wdth + ',height=' + hght + ',left=' + lft + ',top=' + tp + ',screenX=' + lft + ',screenY=' + tp + ',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes');
	if (prn.blur) prn.focus();
}

function printframe()
{
	parent.frame_print_bottom.focus();
	parent.frame_print_bottom.print();
}
function printMe()
{
	window.focus();
	window.print();
}

/* tiskanje dokumenta */

/* preverjanje vnosnih polj */

function isEmpty(besedilo, msg)
{
	if (besedilo.value.length == 0)
	{
		alert(msg)
		besedilo.focus()
		return false
	} 
	return true
}

function isEmail(besedilo, msg)
{
	if (besedilo.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		return true;
	else
	{
		alert(msg);
		besedilo.focus();
		return false;
	}
}

function isSelected(radio, msg)
{
  blnOK = false
  for (var intIndex = 0; intIndex < radio.length; intIndex++)
  {
    if (radio[intIndex].checked)
    {
      blnOK = true
    }
  }
  if (blnOK)
  {
    return true
  }
  else
  {
    alert(msg)
    return false
  }
}

function isEqual(prvobesedilo, drugobesedilo, msg)
{
	if (prvobesedilo.value == drugobesedilo.value)
	{
		alert(msg)
		prvobesedilo.focus()
		return false
	} 
	return true
}

function isTwoInputsEmpty(prvobesedilo, drugobesedilo, msg)
{
	if (prvobesedilo.value.length == 0 && drugobesedilo.value.length == 0)
	{
		alert(msg)
		prvobesedilo.focus()
		return false
	} 
	return true
}

function isTwoInputsFull(prvobesedilo, drugobesedilo, msg)
{
	if (prvobesedilo.value.length != 0 && drugobesedilo.value.length != 0)
	{
		alert(msg)
		prvobesedilo.focus()
		return false
	} 
	return true
}

function isLessThanMin(besedilo, minval, msg)
{
	if (MoneyToInteger(besedilo.value) < minval)
	{
		alert(msg)
		besedilo.select()
		return false
	}
	return true
}

function isChecked(checkbox, msg)
{
	if (checkbox.checked)
	{
		return true
	} 
	alert(msg);
	return false
}

/* preverjanje vnosnih polj */

/* formatiranje številk v znesek */

function FormatCurrency(input)
{
	if (input.value != '')
	{
		var obj = input
		var num = new NumberFormat();
		num.setInputDecimal(',');
		num.setNumber(obj.value);
		num.setPlaces('2', false);
		num.setCurrencyValue('$');
		num.setCurrency(false);
		num.setCurrencyPosition(num.LEFT_OUTSIDE);
		num.setNegativeFormat(num.LEFT_DASH);
		num.setNegativeRed(false);
		num.setSeparators(true, '.', ',');
		obj.value = num.toFormatted();
	}
}

function FormatMoney(input)
{
  var strMoney, strMoneyPare, strFormattedMoney, strMoneyDiv, strMoneyMod;

  strMoney = MoneyToInteger(input.value);
  if (strMoney == 0)
  {
    input.value = "";
    return;
  }

  strMoneyPare = 1001;
  strFormattedMoney = "00";
  strMoneyDiv = Math.floor(strMoney / 1000);
  strMoneyMod = Math.floor(strMoney - (1000 * strMoneyDiv));
  while (strMoneyDiv > 0 || strMoneyMod > 0)
  {
    if (strMoneyPare == 1001 )
	{
	  strFormattedMoney = "," + strFormattedMoney;
	}
    else
	{
      if (strMoneyPare < 100) {strFormattedMoney = "0" + strFormattedMoney};
      if (strMoneyPare < 10) {strFormattedMoney = "0" + strFormattedMoney};
      strFormattedMoney = "." + strFormattedMoney;
    }
    strFormattedMoney = strMoneyMod + strFormattedMoney;
    strMoney = strMoneyDiv;
    strMoneyPare = strMoneyMod;
    strMoneyDiv = Math.floor(strMoney / 1000);
    strMoneyMod = Math.floor(strMoney - (1000 * strMoneyDiv));
  }
  input.value = strFormattedMoney;
  return;
}

function MoneyToInteger(input)
{
  var strMoney, intMoneyLength, intIndex, strInteger;

  strMoney = new String(input);
  intIndex = 0;
  while (strMoney.substring(intIndex, intIndex+1) == '0') {intIndex++};

  intMoneyLength = strMoney.length;
  strMoney = strMoney.substring(intIndex, intMoneyLength);

  strInteger = new String("");
  for (intIndex=0; intIndex<intMoneyLength; intIndex++)
  {
    if (strMoney.substring(intIndex,intIndex+1) == ".") {continue};
    if (strMoney.substring(intIndex,intIndex+1) == ",") {break};
    strInteger += strMoney.substring(intIndex,intIndex+1);
  }

  if (strInteger.length == 0) {return 0};
  if (isNaN(strInteger))
  {
    return 0;
  }
  else
  {
    return parseInt(strInteger);
  }	
}

/* formatiranje številk v znesek */

/* iskanje v toolbaru */

function SearchSubmitSi()
{
	if (isEmpty(document.Query.strQuery, 'Vnesite poizvedbo!'))
	{
		document.Query.action = '/isci.asp';
		document.Query.submit();
	}
}

function SearchSubmitEn()
{
	if (isEmpty(document.Query.strQuery, 'Enter your search!'))
	{
		document.Query.action = '/en/search.asp';
		document.Query.submit();
	}
}

/* iskanje v toolbaru */

function ShowMap(id)
{
  var scrnwdth = 0;
  var scrnhght = 0;
  var wdth = 400;
  var hght = 425;
  var lft;
  var tp;
  if((window.screen) && (screen.width) && (screen.height)) {scrnwdth = screen.width; scrnhght = screen.height;}
  if(scrnwdth != 0) lft = (scrnwdth - wdth)/2;
  if(scrnhght != 0) tp = (scrnhght - hght)/2;
  var abanet = null;
  showmap = window.open('/frameset_print.asp?/orodja/poslovnamreza/map.asp?BranchId=' + id, 'playmap', 'width=' + wdth + ',height=' + hght + ',left=' + lft + ',top=' + tp + ',screenX=' + lft + ',screenY=' + tp + ',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no');
  if (showmap.blur) showmap.focus();
}

function ShowPhoto(id)
{
  var scrnwdth = 0;
  var scrnhght = 0;
  var wdth = 400;
  var hght = 340;
  var lft;
  var tp;
  if((window.screen) && (screen.width) && (screen.height)) {scrnwdth = screen.width; scrnhght = screen.height;}
  if(scrnwdth != 0) lft = (scrnwdth - wdth)/2;
  if(scrnhght != 0) tp = (scrnhght - hght)/2;
  var abanet = null;
  showphoto = window.open('/frameset_print.asp?/orodja/poslovnamreza/photo.asp?FacilityId=' + id, 'playphoto', 'width=' + wdth + ',height=' + hght + ',left=' + lft + ',top=' + tp + ',screenX=' + lft + ',screenY=' + tp + ',menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no');
  if (showphoto.blur) showphoto.focus();
}

function about(url)
{
  var scrnwdth = 0;
  var scrnhght = 0;
  var wdth = 470;
  var hght = 390;
  var lft;
  var tp;
  if((window.screen) && (screen.width) && (screen.height)) {scrnwdth = screen.width; scrnhght = screen.height;}
  if(scrnwdth != 0) lft = (scrnwdth - wdth)/2;
  if(scrnhght != 0) tp = (scrnhght - hght)/2;
  var popupimage = null;
  popupimage = window.open(url, 'popupimagewnd', 'width=' + wdth + ',height=' + hght + ',left=' + lft + ',top=' + tp + ',screenX=' + lft + ',screenY=' + tp + ',menubar=no,toolbar=no,location=no,directories=no,status=yes,scrollbars=yes');  
  if (popupimage.blur) popupimage.focus();
}

function showTabela(input)
{

	if (input == 1)
		{
			document.getElementById('tblSlovenija').style.display = 'block';	
			document.getElementById('tblBalkan').style.display = 'none';
			document.getElementById('tblDrugi').style.display = 'none';
			document.getElementById('tblDrzave').style.display = 'none';
			
		}
	else if (input == 2)
		{
			document.getElementById('tblBalkan').style.display = 'block';
			document.getElementById('tblSlovenija').style.display = 'none';	
			document.getElementById('tblDrugi').style.display = 'none';
			document.getElementById('tblDrzave').style.display = 'none';
			
		}
	
	else if (input == 3)
		{
			
			document.getElementById('tblDrugi').style.display = 'block';
			document.getElementById('tblSlovenija').style.display = 'none';	
			
			document.getElementById('tblBalkan').style.display = 'none';
			document.getElementById('tblDrzave').style.display = 'none';
				
		}
	else
		{
			document.getElementById('tblDrzave').style.display = 'block';
			
			document.getElementById('tblBalkan').style.display = 'none';
			document.getElementById('tblDrugi').style.display = 'none';	
			document.getElementById('tblSlovenija').style.display = 'none';		
		}
	
}


function showArhivTabela(input)
{

	if (input == 1)
		{
			document.getElementById('tblSlovenija').style.display = 'block';	
			document.getElementById('tblBalkan').style.display = 'none';
			document.getElementById('tblDrugi').style.display = 'none';
			document.getElementById('tblDrzave').style.display = 'none';
			
		}
	else if (input == 2)
		{
			document.getElementById('tblBalkan').style.display = 'block';
			document.getElementById('tblSlovenija').style.display = 'none';	
			document.getElementById('tblDrugi').style.display = 'none';
			document.getElementById('tblDrzave').style.display = 'none';
			
		}
	
	else if (input == 3)
		{
			
			document.getElementById('tblDrugi').style.display = 'block';
			document.getElementById('tblSlovenija').style.display = 'none';	
			document.getElementById('tblBalkan').style.display = 'none';
			document.getElementById('tblDrzave').style.display = 'none';
				
		}
	else
		{
			document.getElementById('tblDrzave').style.display = 'block';
			document.getElementById('tblBalkan').style.display = 'none';
			document.getElementById('tblDrugi').style.display = 'none';	
			document.getElementById('tblSlovenija').style.display = 'none';		
		}
	
}




/* ------------------- font size ---------------------- */

/*var prefsLoaded = false;
var defaultFontSize = 76;
var currentFontSize = defaultFontSize;

function revertStyles(){

	currentFontSize = defaultFontSize;
	changeFontSize(0);

}

function changeFontSize(sizeDifference){
	currentFontSize = parseInt(currentFontSize) + parseInt(sizeDifference * 10);

	if(currentFontSize > 130){
		currentFontSize = 130;
	}else if(currentFontSize < 60){
		currentFontSize = 60;
	}

	setFontSize(currentFontSize);
};

function setFontSize(fontSize){

	//alert ("sdf");
	
	var stObj = (document.getElementById) ? document.getElementById('title') : document.all('title');
	stObj.style.fontSize = fontSize + '%';
	stObj = (document.getElementById) ? document.getElementById('content') : document.all('content');
	stObj.style.fontSize = fontSize + '%';
	stObj = (document.getElementById) ? document.getElementById('print_content') : document.all('print_content');
	stObj.style.fontSize = fontSize + '%';
	document.body.style.fontSize = fontSize + '%';
	
};


function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
};

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
};

window.onload = setUserOptions;

function setUserOptions(){
cookie = readCookie("fontSize");
//alert(cookie);
	if(!prefsLoaded){

		cookie = readCookie("fontSize");
		currentFontSize = cookie ? cookie : defaultFontSize;
		setFontSize(currentFontSize);
		
		prefsLoaded = true;
	}

}

window.onunload = saveSettings;

function saveSettings()
{
  createCookie("fontSize", currentFontSize, 365);
}*/