/************************************************
*           *
* splosnovizija         *
*           *
************************************************/
var isNN, isIE, isMac, isMoz;
var agent = navigator.userAgent;


isMac = (agent.lastIndexOf('Mac') < 0);

if (document.all) {
  isIE = true;
} else if (document.layers) {
  isNN = true;
  document.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP | Event.RESIZE);
  window.onresize=um_resize;
} else if (navigator.userAgent.indexOf('Gecko') != -1) {
  isMoz = true;
}

// netscapove neumnosti...
if (isNN) {
   var ws = window.innerWidth;
   var hs = window.innerHeight;
}

function um_resize() {
  if (isNN) {
    if ((window.innerWidth != ws) || (window.innerHeight != hs)){
      window.location.href = window.location.href;
    }
  }
}

// čisto nič
function donull () {}

function um_okno(url, n, w, h, opt) {
var win = null;
var i = 0;

  w = w || 640;
  h = h || 433;
  n = n || "okno";
  opt = opt || "toolbar=0,resizable=0";

  if ( screen ) {
    if ( screen.width < 900 ) opt += ",screenX=2,screenY=2,left=2,top=2";
  }

  opt = "width=" + w + ",height=" + h + "," + opt;

  win = window.open(url, "AlpinaOkno" , opt);

  if (win) {
    if (!win.opener) win.opener = self;
    if (win.focus) win.focus()
  }

}

function um_print(w) {
  if (w.print) {
    w.print();
  } else {
    alert('Za tiskanje te strani izberite ustrezen ukaz v meniju ali gumb v orodjarni brskalnika!');
  }
  return true;
}


// stvaritev layerja - crossbrowser
function ustvari(ime,w,h,x,y,z,vidno,vsebina,dodatnoNN,dodatnoIE) {
  if (isNN) {
    vidno ? vidno = 'show' : vidno = 'hide';
    document.write('<layer width='+w+' height='+h+' left='+x+' top='+y+' name="'+ime+'" z-index='+z+' visibility="'+vidno+'" '+dodatnoNN+'>'+vsebina+'</layer>');
  } else if (isIE || isMoz) {
    vidno ? vidno = 'visible' : vidno = 'hidden';
    document.write('<div id="'+ime+'" style="position:absolute;width:'+w+';height:'+h+';left:'+x+';top:'+y+';z-index:'+z+';visibility:'+vidno+';'+dodatnoIE+'" >'+vsebina+'</div>');
  }
}

// premikanje layerja - crossbrowser
function premakni(id,x,y){
  if (isNN){
    if (x != null) document.layers[id].left = x;
    if (y != null) document.layers[id].top = y;
  } else if(isIE){
    if (x != null) document.all[id].style.posLeft = x;
    if (y != null) document.all[id].style.posTop = y;
  } else if (isMoz) {
    if (x != null) document.getElementById(id).style.left = x;
    if (y != null) document.getElementById(id).style.top = y;
  }
}


// vidnost layerja - crossbrowser
function vidnost(id, vidno) {
  if (isNN) {
    vidno ? vidno = 'show' : vidno = 'hide';
    if ( document.layers[id] ) document.layers[id].visibility = vidno;
  } else if (isIE) {
    vidno ? vidno = 'visible' : vidno = 'hidden';
    if ( document.all[id] ) document.all[id].style.visibility = vidno;
  } else if (isMoz) {
    vidno ? vidno = 'visible' : vidno = 'hidden';
    if ( document.getElementById(id) ) document.getElementById(id).style.visibility = vidno
  }
}

// premik & prikaz layerja - crossbrowser
function prikazxy(id, x, y, offsetx) {
  if (isNN) {
    if (x != null) document.layers[id].left = x + offsetx;
    if (y != null) document.layers[id].top = y;
    document.layers[id].visibility = 'show';
  } else if (isIE) {
    if (x != null) document.all[id].style.posLeft = x + offsetx;
    if (y != null) document.all[id].style.posTop = y;
    document.all[id].style.visibility = 'visible';
  } else if (isMoz) {
    if (x != null) document.getElementById(id).style.left = x + offsetx;
    if (y != null) document.getElementById(id).style.top = y;
    document.getElementById(id).style.visibility = 'visible';
  }
}

// menjava slike na layerju - crossbrowser
function menjajImg(kaj,novSrc,nnLayer){
  var layerInfo = "";
  if (isNN){
    layerInfo = nnLayer;
  }
  eval(layerInfo + "document.images['" + kaj + "'].src = '" + novSrc.src + "'");
}


// blinkovizija
function um_blink() {
  // Blink, Blink, Blink...
  var blink = document.all.tags("BLINK")
  for (var i=0; i < blink.length; i++)
    blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : ""
}
function um_startblink() {
  // Make sure it is IE4, what about moz?
  if (document.all)
    setInterval("um_blink()",1000)
}

// blinkovizija za element z id...
function um_blinkID(id, c, s) {
  if ( document.getElementById(id) ) {
    var oldc = '';
    with (document.getElementById(id).style) {
      oldc = backgroundColor;
      backgroundColor=c;
    }
    setTimeout("um_unblinkID('" + id + "', '" + oldc + "')", 750);
  } else {
    if ( s != '' ) alert(s);
  }
}
function um_unblinkID(id, c) {
  document.getElementById(id).style.backgroundColor=c;
}


function um_preloadimages()
{
  var d = document;
  if(d.images)
  {
    if(!d.um_pics) d.um_pics=new Array();
    var i, j = d.um_pics.length, a = um_preloadimages.arguments;
    for(i=0; i<a.length; i++)
    {
      d.um_pics[j] = new Image;
      d.um_pics[j++].src = a[i];
    }
  }
}

function um_changeimg(i)
{
  if ( i.src.indexOf('_a.gif') > 0 )
    {
      i.src = i.src.replace(/_a\.gif/i, '.gif');
    }
  else
    {
      i.src = i.src.replace(/\.gif/i, "_a.gif");
    }
}

function um_changethis(i)
{
  if ( i.src.indexOf('_a.gif') > 0 )
    {
      i.src = i.src.replace(/_a\.gif/i, '.gif');
    }
  else
    {
      i.src = i.src.replace(/\.gif/i, "_a.gif");
    }
}

function um_changeanc(anc)
{

  if ( anc.getElementsByTagName )
  {
    var i = anc.getElementsByTagName("IMG").item(0);
    if ( i ) um_changeimg(i);
  }
}


function colorme(e,c) {
  e.style.backgroundColor=c;
}

function classme(e,c) {
  e.className=c;
}

// SHOW-HIDE
var divShown = null;
var mnuShown = null;

function Alpina(n) {

	if ( !isNaN(n) ) {

		// Menu
		if ( divShown != null )	document.getElementById("div" + divShown).style.display = 'none';
		if ( n > 0 ) {
			document.getElementById("div" + n).style.display = 'block';
			divShown = n;
		} else
			divShown = null;
	}
	
}
