/* 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('/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');
	prn = window.open('./print.aspx?' + 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();
}

/* 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
}

/* preverjanje vnosnih polj */

/* formatiranje številk v znesek */

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 = 320;
  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?BranchId=' + 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();
}

