function move_box(an,box,pos_x,pos_y,width,height,zamik_x)
{
  var cleft = 0;
  var ctop = 0;
  var obj = an;
  var premik_x = zamik_x||0;
  var premik_y = 0;
  var scrX = window.screen.width;
  var scrY = window.screen.height;
  if (pos_y > 11*scrY/24 && pos_y < 2*scrY/3) 
  {
    premik_y = -height/2 -16;
  }
  else if (pos_y > 2*scrY/3) 
  {
    premik_y = -height - 16;
  }
  while (obj.offsetParent)
  {
      cleft += obj.offsetLeft;
      ctop += obj.offsetTop;
      obj = obj.offsetParent;
  }
  if (pos_x > scrX/2)
  {
    box.style.left = cleft - width - 16 + premik_x + 'px';
  }
  else
  {
    box.style.left = cleft + 50 + premik_x +'px';
  };
  ctop += an.offsetHeight + 8 + premik_y;

  // Handle Internet Explorer body margins,
  // which affect normal document, but not
  // absolute-positioned stuff.
  if (document.body.currentStyle &&
      document.body.currentStyle['marginTop'])
  {
      ctop += parseInt(
          document.body.currentStyle['marginTop']);
  }
  box.style.top = ctop + 'px';
};
function hide_other_alone(obj)
{
  if (!document.getElementsByTagName)
      return;

  var all_divs = document.body.getElementsByTagName("DIV");

  for (i = 0; i < all_divs.length; i++)
  {
      if (all_divs.item(i).style.position != 'absolute' ||
          all_divs.item(i) == obj ||
          !all_divs.item(i).alonePopupBox)
      {
          continue;
      }

      all_divs.item(i).style.display = 'none';
  }
  return;
};
function show_hide_box(an,width,height,pos_x,pos_y,borderStyle,zamik_x)
{
  var href = an.href+ '&amp;p_iframe=1';
  var boxdiv = document.getElementById(href);
  if (boxdiv != null)
  {
      if (boxdiv.style.display=='none')
      {
          hide_other_alone(boxdiv);
          // Show existing box, move it
          // if document changed layout
          move_box(an, boxdiv,pos_x,pos_y,width,height,zamik_x);
          boxdiv.style.display='block';
          frames["ifr"+href].location = frames["ifr"+href].location;
          // Workaround for Konqueror/Safari
          if (!boxdiv.contents.contentWindow)
              boxdiv.contents.src = href;
      }
      else
          // Hide currently shown box.
          boxdiv.style.display='none';
      return false;
  }

  hide_other_alone(null);

  // Create box object through DOM
  boxdiv = document.createElement('div');
  

  // Assign id equalling to the document it will show
  boxdiv.setAttribute('id', href);

  // Add object identification variable
  boxdiv.alonePopupBox = 1;

  boxdiv.style.display = 'block';
  boxdiv.style.position = 'absolute';
  boxdiv.style.width = width + 'px';
  boxdiv.style.height = height + 'px';
  boxdiv.style.border = borderStyle;
  boxdiv.style.textAlign = 'right';
  boxdiv.style.padding = '4px';
  boxdiv.style.background = '#FFFFFF';
  boxdiv.style.scrolling = 'no';
//  boxdiv.style.overflow = 'hidden';
  document.body.appendChild(boxdiv);
  var offset = 0;

  // Remove the following code if ''Close'' hyperlink
  // is not needed.
  var close_href = document.createElement('a');
  close_href.href = '#';
  close_href.onclick = function()
  { 
    show_hide_box(an, width, height,pos_x,pos_y,borderStyle,zamik_x);
  }
  var close_img = document.createElement('img');
  close_img.src = '/gumbi/close.jpg';
  close_img.alt = 'Zapri';
  close_href.appendChild(close_img);
//  close_href.appendChild(document.createTextNode('Zapri'));
  boxdiv.appendChild(close_href);
  offset = close_href.offsetHeight;
  // End of ''Close'' hyperlink code.

  var contents = document.createElement('iframe');
  //contents.scrolling = 'no';
  contents.overflowX = 'hidden';
  contents.overflowY = 'scroll';
  contents.frameBorder = '0';
  contents.style.width = width + 'px';
  contents.style.height = (height - offset) + 'px';
  contents.name="ifr"+href;
  contents.id="ifr"+href

  boxdiv.contents = contents;
  boxdiv.appendChild(contents);
  move_box(an, boxdiv,pos_x,pos_y,width,height,zamik_x);
  if (contents.contentWindow)
      contents.contentWindow.document.location.replace(
          href);
  else
      contents.src = href;
  
  // The script has successfully shown the box,
  // prevent hyperlink navigation.
  return false;
};
function CloseKosaricaKupljeno()
{
  if (document.getElementById("kosaricaKratkoKupljeno") != null)
  {
    document.getElementById("kosaricaKratkoKupljeno").style.display = "none";
  };  
};
function CloseRegNoviceSucess()
{
  if (document.getElementById("noviceRegsucess") != null)
  {
    document.getElementById("noviceRegsucess").style.display = "none";
  };  
};
function povecajSlikoArtikla(artikel)
{
  if (window.document.getElementById('slika_art_'+artikel).height>260)
  {
    window.document.getElementById('slika_art_'+artikel).src='images/slika.php?page=3&iid='+artikel+'&width=&height=250';
    window.document.getElementById('povecaj').innerHTML='Povečaj sliko';
    window.document.getElementById('tabelaArtikelSlika').style.cssFloat = "left";
  }
  else 
  {
    window.document.getElementById('slika_art_'+artikel).src='images/slika.php?page=3&iid='+artikel+'&width=520&height=';
    window.document.getElementById('povecaj').innerHTML='Pomanjšaj sliko';
    window.document.getElementById('tabelaArtikelSlika').style.cssFloat = "none";
  };
};
function check_all(field1
                  ,field2)
{
  if (field1.checked)
  {
    if(field2.length==undefined)
    {
      field2.checked = true;
    }
    else
    {
      for (i = 0; i < field2.length; i++)
	      field2[i].checked = true;
	  };    
  }
  else
  {
    if(field2.length==undefined)
    {
      field2.checked = false;
    }
    else
    {  
      for (i = 0; i < field2.length; i++)
	      field2[i].checked = false;
	  };
  };
};  
function is_any_checked(field)
{ 
  if(field.length==undefined && field.checked)
  {
    return true;
  }  
  else
  {
    for (i = 0; i < field.length; i++)
    {
      if(field[i].checked == true)
        return true; 
    };
  };  
  return false;
};
function arrayToString(arr,str)
{
  var count = 1;
  document.getElementById(str).innerHTML = '';
  if(arr.length==undefined)
  {
    if (arr.checked==true)
      document.getElementById(str).innerHTML=arr.value;
  }
  else
  {
    for (i = 0; i < arr.length; i++)
    {
      if (arr[i].checked==true) {
        if (count == 1){
          document.getElementById(str).innerHTML=arr[i].value + '; ';
        }
        else {
          document.getElementById(str).innerHTML=document.getElementById(str).innerHTML + arr[i].value + '; ';
        };  
        count = count + 1;
      };
    };    
  };
};
