function check_number(e) {
    var ns = (navigator.appName == "Netscape");

    if (ns) var key_index = e.which;
    else var key_index = window.event.keyCode;

    // status = 'key pressed = '+key_index;
    // only allow numbers and backspace
    if ((key_index > 47 && key_index < 58) || key_index == 0 || key_index == 8)
        return true;
    else
        return false;
}	

function popupWindow(url,w,h) {
    windowprops = "height=" + h + ",width=" + w + ",location=no,scrollbars=no,menubar=no,toolbar=no,resizable=no,titlebar=no,status=no";
 	window.open(url, "Picture" + w + h, windowprops);
}

function popupPhotoWindow(url,w,h) {
    windowprops = "height=" + h + ",width=" + w + ",location=no,scrollbars=yes,menubar=no,toolbar=no,resizable=yes,titlebar=no,status=no";
 	window.open(url, "Picture" + w + h, windowprops);
}

function popupScrolerWindow(url,w,h) {
    windowprops = "height=" + h + ",width=" + w + ",location=no,scrollbars=yes,menubar=no,toolbar=no,resizable=yes,titlebar=no,status=no";
 	window.open(url, "Picture" + w + h, windowprops);
}

function autoResize() {
	if (window.document.getElementById("toptable").offsetWidth > 449) {
	    window.resizeTo(window.document.getElementById("toptable").offsetWidth + 10, 500);
	}
	if (window.document.getElementById("toptable").offsetWidth < 450) {
	    window.resizeTo(450, 500);
	}
}
	
function imgDoubleError(jdocid,picid) {
    jdocid.src = 'http://www.svetknjige.si/article_images/empty.gif';
}
		
function imgErrorFunc(jdocid) {
    jdocid.src = 'http://www.svetknjige.si/article_images/empty.gif';
}
function imgArticleErrorFunc(jdocid) {
    jdocid.src = 'http://www.svetknjige.si/article_images/empty.gif';
}
function expandNode(oSubItems) {
	if (oSubItems.style.display == "none")	{
	    oSubItems.style.display = "block";
	} else {
	    oSubItems.style.display = "none";
	}
}

function checkCheckBox(f) {
    if (f.agree.checked == false) {
        alert('Potrdite, da se strinjate s splošnimi pogoji!');
        return false;
    }
    else
        return true;
}

// rolldown banner: start

//variables
var stepx;
var stepy;
var counter;
var timerid;

// reset rolldown banner variables for rolldown banner
function resetRolldownBannerVariables() {

    //variables
    stepx = 0;
    stepy = 0;   
    counter = 0;
    imgwidth = 400;   // banner width, in pixels
    imgheight = 284;   // banner height, in pixels
    innerW = "document.body.offsetWidth";
    innerH = "document.body.offsetHeight";
    offsetX = "document.body.scrollLeft";
    offsetY = "document.body.scrollTop";

}

// move rolldown banner
function moveRolldownBanner() {	
    //rolldown banner object name
    rolldownbannerobjectname = "rolldownbanner";
    
    //variables
    var availableX = eval(innerW);
    var availableY = eval(innerH);
    var currentX = eval(offsetX);
    var currentY = eval(offsetY);

    //increment counter
    counter++;

    // dimension x
    x = availableX - (availableX / 2);

    //borders
    if (counter > 50) { stepy = 1; }
    if (counter > 532) { stepy = 0; }
    if (counter > 900) { stepy = -3; }

    // dimension y
    y = document.getElementById(rolldownbannerobjectname).offsetTop + stepy;
    if (counter < 50) { y = -245; }

	//move
	evalMove(rolldownbannerobjectname);
	
	//set itmer
    timerid = setTimeout("moveRolldownBanner()",3);	
}

//eval move
function evalMove(rolldownbannerobjectname) {
    document.getElementById(rolldownbannerobjectname).style.left = x + 'px';
    document.getElementById(rolldownbannerobjectname).style.top = y + 'px';
}

// rolldown banner: end

function bookmark(bookmarkurl, bookmarktitle) {
    if (document.all) window.external.AddFavorite(bookmarkurl, bookmarktitle);
}
    
// menu jscript file

// menu bar
Menu = {timer : null, current : null};
Menu.getStyle = function(name){
	if(document.getElementById) return document.getElementById(name).style;
	else if(document.all) return document.all[name].style;
	else if(document.layers) return document.layers[name];
}
Menu.show = function(name,menuname){
	if(this.timer) clearTimeout(this.timer);
	this.getStyle(name).visibility = "visible";
	this.current = name;
	setPosition(this, name, menuname, 0, 187); //set position
}
Menu.hide = function(){
	this.timer = setTimeout("Menu.doHide()",300);
}
Menu.doHide = function(){
	if(this.current){
		this.getStyle(this.current).visibility = "hidden";
		this.current = null;
	}
}

// menu bar secondary level
Menui = {timer : null, current : null};
Menui.getStyle = function(name){
	if(document.getElementById) return document.getElementById(name).style;
	else if(document.all) return document.all[name].style;
	else if(document.layers) return document.layers[name];
}
Menui.show = function(name, menuname){
	if(this.timer) clearTimeout(this.timer);
	this.getStyle(name).visibility = "visible";
	this.current = name;
	setPosition(this, name, menuname, 18, -1); //set position
}
Menui.hide = function(){
	this.timer = setTimeout("Menui.doHide()",300);
}
Menui.doHide = function(){
	if(this.current){
		this.getStyle(this.current).visibility = "hidden";
		this.current = null;
	}
}

// first page about menu bar
Menuii = {timer : null, current : null};
Menuii.getStyle = function(name){
	if(document.getElementById) return document.getElementById(name).style;
	else if(document.all) return document.all[name].style;
	else if(document.layers) return document.layers[name];
}
Menuii.show = function(name,menuname){
	if(this.timer) clearTimeout(this.timer);
	this.getStyle(name).visibility = "visible";
	this.current = name;
	setPosition(this, name, menuname, 21, -6); //set position
}
Menuii.hide = function(){
	this.timer = setTimeout("Menuii.doHide()",300);
}
Menuii.doHide = function(){
	if(this.current){
		this.getStyle(this.current).visibility = "hidden";
		this.current = null;
	}
}

//set object position
function setPosition(obj, name, menuname, offsetTop, offsetLeft)
{
    
    //declare
    var top = 0;
    var left = 0;
    var anchor, layer, scroll, height, parenttop, space;
	
	if (document.getElementById)//N6,IE6
	{
		anchor = document.getElementById(menuname);
		layer = document.getElementById(name).offsetHeight;
	}
	else if (document.all)//IE4,IE5
	{
		anchor = document.all(menuname);
		layer = document.all(name).clientHeight;
	}
	while (anchor.offsetParent != null)
	{
		top += anchor.offsetTop;
		left += anchor.offsetLeft;
      	anchor = anchor.offsetParent;
	}
	if (document.all)//IE4+
	{
		scroll = document.body.scrollTop;
		height = document.body.clientHeight;
	}
	else //N6
	{
		scroll = window.pageYOffset;
		height = window.innerHeight;
	}
	parenttop = top - scroll;
	space = height - parenttop;
	if (space > layer){	top = top; } else {	top = top - layer + 21;	}
 
    //set position
    obj.getStyle(name).top = top + offsetTop;
	obj.getStyle(name).left = left+ offsetLeft;  
 
    //return
    return obj
}

//get style by browser
function getStyle(name)
{
	if(document.getElementById) return document.getElementById(name).style;
	else if(document.all) return document.all[name].style;
	else if(document.layers) return document.layers[name];
}

