function dogodek(elm, tip, fn, ecapture) {
	if (elm.addEventListener) {
		elm.addEventListener(tip, fn, ecapture);
	// "this" ne deluje pri uporabi attachEvent-a
    /*} else if (elm.attachEvent) {
		var d = elm.attachEvent('on' + tip, fn);
		return d;*/
	} else {
		elm['on' + tip] = fn;
	}
}

function init() {
    var menu = document.getElementById('menu');
    var menuImages = menu.getElementsByTagName('img');
    /* nalozimo mouseover slikce in dogodke, pri cemer
       spustimo logo in vzorec na dnu menija */
    for (var i = 1; i < (menuImages.length - 1); i++) {
        if (!menuImages[i].getAttribute('id')) {
            dogodek(menuImages[i], 'mouseover', slikeover, false);
            dogodek(menuImages[i], 'mouseout', slikeout, false);
            slikaon = menuImages[i].getAttribute('name');
            slikaon = new Image();
            slikaon.src = menuImages[i].src.substr(0,menuImages[i].src.length - 7) + 'on.jpg';
            slikaoff = new Image();
            slikaoff = menuImages[i].src;
        }
    }
}

function slikeover() {
    var pot = this.src.split('/');
    if (this.src.substr(this.src.length - 6,this.src.length) != 'on.jpg' || this.src.substr(this.src.length - 6,this.src.length) != 'in.jpg') {
        this.src = 'http://www.hotel-planinka.si/images/' + pot[4] + '/' + this.getAttribute('name') + '_on.jpg';
    }
}

function slikeout() {
    var pot = this.src.split('/');
    if (this.src.substr(this.src.length - 7,this.src.length) != 'off.jpg' || this.src.substr(this.src.length - 6,this.src.length) != 'in.jpg') {
        this.src = 'http://www.hotel-planinka.si/images/' + pot[4] + '/' + this.getAttribute('name') + '_off.jpg';
    }
}

dogodek(window, 'load', init, false);
