<!-- Paste this code into an external JavaScript file named: scrollWin.js  -->

/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Travis Beckham :: http://www.squidfingers.com | http://www.podlob.com */

// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//
// Coded by Travis Beckham
// http://www.squidfingers.com | http://www.podlob.com
// If want to use this code, feel free to do so, but please leave this message intact.
//
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// --- version date: 02/04/03 ---------------------------------------------------------
/*

If you use a DOCTYPE that puts Explorer 6 in standards compliant mode, some properties
of document.body are reassigned to document.documentElement. In Explorer 5 the
properties still belong to document.body. Checking if the documentElement exists is not
enough, since it exists in all W3C DOM compatible browsers, so we also have to see if
it has the property we are trying to access.
For more info on this topic visit http://www.xs4all.nl/~ppk/js/doctypes.html

*/
var ScrollWin = {
  w3c : document.getElementById,
  iex : document.all,
  scrollLoop : false,
  scrollInterval : null, // setInterval id
  currentBlock : null,   // object reference
  getWindowHeight : function(){
    if(this.iex) return (document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight;
    else return window.innerHeight;
  },
  getScrollLeft : function(){
    if(this.iex) return (document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
    else return window.pageXOffset;
  },
  getScrollTop : function(){
    if(this.iex) return (document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
    else return window.pageYOffset;
  },
  getElementYpos : function(el){
    var y = 0;
    while(el.offsetParent){
      y += el.offsetTop
      el = el.offsetParent;
    }
    return y;
  },
  scroll : function(num){
    if(!this.w3c){
      location.href = "#"+this.anchorName+num;
      return;
    }
    if(this.scrollLoop){
      clearInterval(this.scrollInterval);
      this.scrollLoop = false;
      this.scrollInterval = null;
    }
    if(this.currentBlock != null) this.currentBlock.className = this.offClassName;
    this.currentBlock = document.getElementById(this.blockName+num);
    this.currentBlock.className = this.onClassName;
    var doc = document.getElementById(this.containerName);
    var documentHeight = this.getElementYpos(doc) + doc.offsetHeight;
    var windowHeight = this.getWindowHeight();
    var ypos = this.getElementYpos(this.currentBlock);
    if(ypos > documentHeight - windowHeight) ypos = documentHeight - windowHeight;
    this.scrollTo(0,ypos);
  },
  scrollTo : function(x,y){
    if(this.scrollLoop){
      var left = this.getScrollLeft();
      var top = this.getScrollTop();
      if(Math.abs(left-x) <= 1 && Math.abs(top-y) <= 1){
        window.scrollTo(x,y);
        clearInterval(this.scrollInterval);
        this.scrollLoop = false;
        this.scrollInterval = null;
      }else{
        window.scrollTo(left+(x-left)/2, top+(y-top)/2);
      }
    }else{
      this.scrollInterval = setInterval("ScrollWin.scrollTo("+x+","+y+")",70);
      this.scrollLoop = true;
    }
  }
};

// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/*
using the following line, IE/PC returns an incorrect number when getting the document height.
var document_height = document.all ? document.body.offsetHeight : window.document.height;
To fix this problem, a container div is wrapped around the content so the correct height
can be determined.
*/

// Edit these variables

ScrollWin.containerName = "drzac"; // The id name of the div containing the content
ScrollWin.anchorName    = "anchor";    // The alpha portion of the anchor names
ScrollWin.blockName     = "block";     // The alpha portion of the content blocks
ScrollWin.onClassName   = "active";    // The CSS class name for the 'on' state
ScrollWin.offClassName  = "visited";   // The CSS class name for the 'off' state



random_number= Math.floor(Math.random()* 10+1 );
// Loads the appropriate image and text color based on random number.
if (random_number==1) {
image="slikevrh/1.jpg";
}
if (random_number==2) {
image="slikevrh/2.jpg";
}
if (random_number==3) {
image="slikevrh/3.jpg";
}
if (random_number==4) {
image="slikevrh/4.jpg";
}
if (random_number==5) {
image="slikevrh/5.jpg";
}
if (random_number==6) {
image="slikevrh/6.jpg";
}
if (random_number==7) {
image="slikevrh/7.jpg";
}
if (random_number==8) {
image="slikevrh/8.jpg";
}
if (random_number==9) {
image="slikevrh/9.jpg";
}
if (random_number==10) {
image="slikevrh/10.jpg";
}

function backToTop() {
var x1 = x2 = x3 = 0;var y1 = y2 = y3 = 0;
if (document.documentElement) {
x1 = document.documentElement.scrollLeft || 0;
y1 = document.documentElement.scrollTop || 0;
}
if (document.body) {
x2 = document.body.scrollLeft || 0;
y2 = document.body.scrollTop || 0;
}
x3 = window.scrollX || 0;y3 = window.scrollY || 0;
var x = Math.max(x1, Math.max(x2, x3));
var y = Math.max(y1, Math.max(y2, y3));
window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));
if (x > 0 || y > 0) {
window.setTimeout("backToTop()", 25);
}
}


var ss = {
  fixAllLinks: function() {

    var allLinks = document.getElementsByTagName('a');

    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if ((lnk.href && lnk.href.indexOf('#') != -1) && 
          ( (lnk.pathname == location.pathname) ||
	    ('/'+lnk.pathname == location.pathname) ) && 
          (lnk.search == location.search)) {

        ss.addEvent(lnk,'click',ss.smoothScroll);
      }
    }
  },

  smoothScroll: function(e) {

    if (window.event) {
      target = window.event.srcElement;
    } else if (e) {
      target = e.target;
    } else return;


    if (target.nodeType == 3) {
      target = target.parentNode;
    }


    if (target.nodeName.toLowerCase() != 'a') return;


    anchor = target.hash.substr(1);

    var allLinks = document.getElementsByTagName('a');
    var destinationLink = null;
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if (lnk.name && (lnk.name == anchor)) {
        destinationLink = lnk;
        break;
      }
    }


    if (!destinationLink) return true;


    var destx = destinationLink.offsetLeft; 
    var desty = destinationLink.offsetTop;
    var thisNode = destinationLink;
    while (thisNode.offsetParent && 
          (thisNode.offsetParent != document.body)) {
      thisNode = thisNode.offsetParent;
      destx += thisNode.offsetLeft;
      desty += thisNode.offsetTop;
    }


    clearInterval(ss.INTERVAL);

    cypos = ss.getCurrentYPos();

    ss_stepsize = parseInt((desty-cypos)/ss.STEPS);
    ss.INTERVAL =
setInterval('ss.scrollWindow('+ss_stepsize+','+desty+',"'+anchor+'")',10);


    if (window.event) {
      window.event.cancelBubble = true;
      window.event.returnValue = false;
    }
    if (e && e.preventDefault && e.stopPropagation) {
      e.preventDefault();
      e.stopPropagation();
    }
  },

  scrollWindow: function(scramount,dest,anchor) {
    wascypos = ss.getCurrentYPos();
    isAbove = (wascypos < dest);
    window.scrollTo(0,wascypos + scramount);
    iscypos = ss.getCurrentYPos();
    isAboveNow = (iscypos < dest);
    if ((isAbove != isAboveNow) || (wascypos == iscypos)) {

      window.scrollTo(0,dest);

      clearInterval(ss.INTERVAL);

      location.hash = anchor;
    }
  },

  getCurrentYPos: function() {
    if (document.body && document.body.scrollTop)
      return document.body.scrollTop;
    if (document.documentElement && document.documentElement.scrollTop)
      return document.documentElement.scrollTop;
    if (window.pageYOffset)
      return window.pageYOffset;
    return 0;
  },

  addEvent: function(elm, evType, fn, useCapture) {

    if (elm.addEventListener){
      elm.addEventListener(evType, fn, useCapture);
      return true;
    } else if (elm.attachEvent){
      var r = elm.attachEvent("on"+evType, fn);
      return r;
    } else {
      alert("Handler could not be removed");
    }
  } 
}

ss.STEPS = 35;

ss.addEvent(window,"load",ss.fixAllLinks);

function ShowHide(id) {
    obj = document.getElementsByTagName("div");
    if (obj[id].style.display == 'block'){
    obj[id].style.display = 'none';
    }
    else {
    obj[id].style.display = 'block';
    }
}

function ToggleElement(element, dur)
{
    new Effect.toggle(element,'Blind', {duration:dur});
}




var imagenumber = 15 ;
var randomnumber = Math.random() ;
var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1 ;
var rand2 = Math.round( (imagenumber-1) * randomnumber) + 2 ;
var rand3 = Math.round( (imagenumber-1) * randomnumber) + 3 ;
var rand4 = Math.round( (imagenumber-1) * randomnumber) + 4 ;
var rand5 = Math.round( (imagenumber-1) * randomnumber) + 5 ;
var rand6 = Math.round( (imagenumber-1) * randomnumber) + 6 ;
var rand7 = Math.round( (imagenumber-1) * randomnumber) + 7 ;
images = new Array
images[1] = "galerija/1"
images[2] = "galerija/2"
images[3] = "galerija/3"
images[4] = "galerija/4"
images[5] = "galerija/5"
images[6] = "galerija/6"
images[7] = "galerija/7"
images[8] = "galerija/8"
images[9] = "galerija/9"
images[10] = "galerija/10"
images[11] = "galerija/11"
images[12] = "galerija/12"
images[13] = "galerija/13"
images[14] = "galerija/14"
images[15] = "galerija/15"
images[16] = "galerija/16"
images[17] = "galerija/17"
images[18] = "galerija/18"
images[19] = "galerija/19"
images[20] = "galerija/20"
images[21] = "galerija/21"
images[22] = "galerija/22"

var image1 = images[rand1]
var image2 = images[rand2]
var image3 = images[rand3]
var image4 = images[rand4]
var image5 = images[rand5]
var image6 = images[rand6]
var image7 = images[rand7]


