// global the thingies

var xmlhttp;
var fileurl = "";

var cp_ispopped = 0;
var cp_x1 = 0;
var cp_x2 = 0;
var cp_y1 = 0;
var cp_y2 = 0;

var lb_popped = 0;
var ln_popped = 0;

var bannersTop = new Array();
var bannerTopCount = 0;
var bannerTopTO = 0;
var bannerTopCurPos = 0;
var productDetailOpen = false;


function loadDivFromFile(fileurl, divid)
{
	if (window.XMLHttpRequest) {
		xmlhttp=new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (xmlhttp!=null) {
		xmlhttp.open("GET", fileurl, true);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState==4) {// 4 = "loaded"
				if (xmlhttp.status==200) {// 200 = "OK"
					document.getElementById(divid).innerHTML = xmlhttp.responseText;	
				} else {
					window.status = "Problem retrieving data from "+fileurl+": " + xmlhttp.statusText;
				}
			}
		};
		
		xmlhttp.send(null);
	} else {
		alert("Your browser does not support XMLHTTP!\nPlease contact your administrator.");
	}
}

function containsDOM (container, containee) {
  var isParent = false;
  do {
    if ((isParent = container == containee))
      break;
    containee = containee.parentNode;
  }
  while (containee != null);
  return isParent;
}

function checkMouseEnter (element, evt) {
  if (!evt) var evt = window.event;
  if (element.contains && evt.fromElement) {
    return !element.contains(evt.fromElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}

function checkMouseLeave (element, evt) {
  if (!evt) var evt = window.event;
  if (element.contains && evt.toElement) {
    return !element.contains(evt.toElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}

function getStyle(el, cssprop){
 if (el.currentStyle) //IE
  return el.currentStyle[cssprop]
 else if (document.defaultView && document.defaultView.getComputedStyle) //Firefox
  return document.defaultView.getComputedStyle(el, "")[cssprop]
 else //try and get inline style
  return el.style[cssprop]
}

function getElementHeight(Elem) {
	if(document.getElementById) {
		var elem = document.getElementById(Elem);
	} else if (document.all){
		var elem = document.all[Elem];
	}
	xPos = elem.offsetHeight;
	return xPos;
}

function getElementWidth(Elem) {
	if(document.getElementById) {
		var elem = document.getElementById(Elem);
	} else if (document.all){
		var elem = document.all[Elem];
	}
	xPos = elem.offsetWidth;
	return xPos;
}

function getScreenHeight() {
  var myHeight = 0;
  if( typeof( window.innerHeight ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && document.documentElement.clientHeight ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && document.body.clientHeight ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
	return parseInt(myHeight);
}

function getCurrentScroll() {
  var myHeight = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Non-IE
    myHeight = window.pageYOffset;
  } else if( document.documentElement && document.documentElement.scrollTop ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.scrollTop;
  } else if( document.body && document.body.scrollTop ) {
    //IE 4 compatible
    myHeight = document.body.scrollTop;
  }
	return parseInt(myHeight);
}

function getTotalHeight(){
	var d= document.documentElement;
	var b= document.body;
	var who= d.offsetHeight? d: b ;
	return Math.max(who.scrollHeight,who.offsetHeight);
}


function findPosY(ajdi) {
	var curtop = 0;
	var obj = document.getElementById(ajdi);
	if (obj.offsetParent) {
		do {
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}	
	return curtop;
}

function findPosX(ajdi) {
	var curleft = 0;
	var obj = document.getElementById(ajdi);
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
		} while (obj = obj.offsetParent);
	}
	return curleft;
}

function setOpacity(opacity, id)  { 
  var object = document.getElementById(id).style; 
  object.opacity = (opacity / 100); 
  object.MozOpacity = (opacity / 100); 
  object.KhtmlOpacity = (opacity / 100); 
  object.filter = "alpha(opacity=" + opacity + ")"; 
} 

function showItem(opacity, id) {
  if (document.getElementById) {
    if(opacity < 1) {
			document.getElementById(id).style.display='block';
    }
    if (opacity < 100) {
       setOpacity(opacity,id);
       opacity += 2;
       window.setTimeout("showItem("+opacity+",'"+id+"')", 5);
    }
  }
}

function hideItem(opacity, id) {
  if (document.getElementById) {
    if(opacity < 5) {
			document.getElementById(id).style.display='none';
    }
    if (opacity > 5) {
       setOpacity(opacity,id);
       opacity -= 5;
       window.setTimeout("hideItem("+opacity+",'"+id+"')", 5);
    }
  }
}

function formatNumber(stev) {
	var num = new NumberFormat();
	num.setInputDecimal('.');
	num.setNumber(stev);
	num.setPlaces('2', false);
	num.setCurrencyValue('$');
	num.setCurrency(false);
	num.setCurrencyPosition(num.LEFT_OUTSIDE);
	num.setNegativeFormat(num.LEFT_DASH);
	num.setNegativeRed(false);
	num.setSeparators(true, '.', ',');
	return num.toFormatted();
}

function validateEmail(mejl)
{
	var isok = true;
	if (mejl.length<8) isok = false;
	if (mejl.indexOf('@')<=0) isok = false;
	if (mejl.indexOf('.')<=0) isok = false;
	return isok;
}





// filter description
function showFilterDesc(filterId, filterDesc){
	var top = findPosY("filter_"+filterId);
	//var left = findPosX("filter_"+filterId); 
	var left = 170;
	var filter = document.getElementById("filter_desc");
	filter.style.top = (parseInt(top) - 15)+"px";
	filter.style.left = (parseInt(left))+"px";
	document.getElementById("filter_desc_content").innerHTML = filterDesc;
	filter.style.display = "block";
}

function hideFilterDesc(){
	var filter = document.getElementById("filter_desc");
	filter.style.display = "none";
}


// product detail

function slideLeft(divId,px) {
	if(px=="")	px=164;
	var div = document.getElementById(divId);
	var ml = parseInt(getStyle(div, 'marginLeft'));
	if(ml<0) {
		div.style.marginLeft = (ml+px)+'px';
	}
	if(ml>-165) {
		document.getElementById(divId+'_left').className = 'arrow-blank';
	} else {
		document.getElementById(divId+'_left').className = 'arrow-left';
	}
	var boxW = parseInt(getStyle(div, 'width'));
	var pw = parseInt(getStyle(div.parentNode, 'width'));
	if(parseInt(boxW+ml)>pw-165) {
		document.getElementById(divId+'_right').className = 'arrow-right';
	}
}
function slideRight(divId,px) {
	if(px=="")	px=164;
	var div = document.getElementById(divId);
	var ml = parseInt(getStyle(div, 'marginLeft'));
	var boxW = parseInt(getStyle(div, 'width'));
	var pw = parseInt(getStyle(div.parentNode, 'width'));
	if(parseInt(boxW+ml)>pw) {
		div.style.marginLeft = (ml-px)+'px';
	} 
	if(parseInt(boxW+ml)<pw+165) {
		document.getElementById(divId+'_right').className = 'arrow-blank';
	} else {
		document.getElementById(divId+'_right').className = 'arrow-right';
	}
	if(ml<1) {
		document.getElementById(divId+'_left').className = 'arrow-left';
	}
}

// change product image
function changeProductImage(img, imgbig) {
	var div = document.getElementById('image_big');
	var output = '<img src="/images/spacer.gif" alt="Slika" width="420" height="315"';
	if(imgbig!='') output += ' title="Kliknite za povečavo" onclick="showBigImage()"';
	output += ' />';
	div.innerHTML = output;
	div.style.backgroundImage = 'url('+img+')';
	document.getElementById('tmpImgBig').value=imgbig;
}


// litebox show
function showBigImage() {
	var image_big = document.getElementById('pu_image_big');
  var srcimg = getStyle(document.getElementById('image_big'), 'backgroundImage');
  
  var lb = document.getElementById('linked_content_light_box');
	var lbHeight = findPosY('footer') + 150;
	lb.style.height = lbHeight+'px';
	lb.style.display='block';
	
	var lc = document.getElementById('linked_content_popup');
	srcimg = document.getElementById('tmpImgBig').value;
  if(srcimg != '') {
		lc.innerHTML = '<div id="linked_content_wrapper" align="center" onclick="hideBigImage()" onmouseover="this.style.cursor=\'-moz-zoom-out\'"><img src="'+srcimg+'" alt="Slika" id="popped_image" title="Kliknite, da se slika zapre" /></div>';
		lc.style.display='block';
		lc.style.top = getCurrentScroll()+'px';
		var lcHeight = getElementHeight('linked_content_popup');
		if(lcHeight+getCurrentScroll() > lbHeight) lbHeight = lcHeight+getCurrentScroll();
		lb.style.height = lbHeight+'px';
	}
}
// litebox hide
function hideBigImage() {
	document.getElementById('pu_image_big').style.display='none';
	document.getElementById('linked_content_popup').style.display='none';
  document.getElementById('linked_content_light_box').style.display='none';
  window.scrollTo(0,getCurrentScroll());
}

// show tab
function showProductDetail(kaj) {
	var targetDiv = document.getElementById('product_detail_tab');
	var sourceDiv = document.getElementById('hidden_detail_tab_'+kaj);
	var link = document.getElementById('product_detail_tab_'+kaj);
	var toolbar = '<div id="expand_link" style="padding: 5px 0px 10px 0px;"><a href="javascript:void(0);" onclick="expandProductDetail()" class="view">Povečaj</a></div>';
	if(productDetailOpen) {
		toolbar = '<div id="expand_link" style="padding: 5px 0px 10px 0px; text-align: right;"><a href="javascript:void(0);" onclick="shrinkProductDetail()" class="close">Pomanjšaj</a></div>';
	}
	targetDiv.innerHTML = toolbar + sourceDiv.innerHTML;
	for (i=1;i<=2;i++) {
		document.getElementById('product_detail_tab_'+i).className = '';
	}
	link.className = 'active';
}

function expandProductDetail() {
	var targetDiv = document.getElementById('product_detail_tab');
	targetDiv.className = 'detail_extended';
	productDetailOpen = true;
	if(productDetailOpen) {
		document.getElementById('expand_link').innerHTML = '<a href=\"javascript:void(0);\" onclick=\"shrinkProductDetail()\" class=\"close\">Pomanjšaj</a>'
		document.getElementById('expand_link').style.textAlign = 'right';
		if(document.getElementById('productDetailQuantities')) {
			document.getElementById('productDetailQuantities').style.height='';
		}
	} else {
		document.getElementById('expand_link').innerHTML = '<a href=\"javascript:void(0);\" onclick=\"expandProductDetail()\" class=\"view\">Povečaj</a>'
		document.getElementById('expand_link').style.textAlign = 'left';
		if(document.getElementById('productDetailQuantities')) {
			document.getElementById('productDetailQuantities').style.height='150px';
		}
	}
}
function shrinkProductDetail() {
	var targetDiv = document.getElementById('product_detail_tab');
	targetDiv.className = 'tabs-detail';
	productDetailOpen = false;
	if(document.getElementById('productDetailQuantities')) {
		document.getElementById('productDetailQuantities').style.height='150px';
	}
	document.getElementById('expand_link').innerHTML = '<a href=\"javascript:void(0);\" onclick=\"expandProductDetail()\" class=\"view\">Povečaj</a>'
	document.getElementById('expand_link').style.textAlign = 'left';
}


function getPageSizeWithScroll(){
    if (window.innerHeight && window.scrollMaxY) {// Firefox
        yWithScroll = window.innerHeight + window.scrollMaxY;
        xWithScroll = window.innerWidth + window.scrollMaxX;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        yWithScroll = document.body.scrollHeight;
        xWithScroll = document.body.scrollWidth;
    } else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
        yWithScroll = document.body.offsetHeight;
        xWithScroll = document.body.offsetWidth;
      }
    arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
    return arrayPageSizeWithScroll;
}


// show linked content
function showLinkedContent(i) {
	var lb = document.getElementById('linked_content_light_box');
	var lbHeight = findPosY('footer') + 150;
	lb.style.height = lbHeight+'px';
	lb.style.display='block';
	
	var lc = document.getElementById('linked_content_popup');
	lc.innerHTML = '<div id="linked_content_wrapper" align="center">' + document.getElementById('product_linked_content_'+i).innerHTML + '</div>';
	lc.style.display='block';
	lc.style.top = getCurrentScroll()+'px';
	var lcHeight = getElementHeight('linked_content_popup');
	if(lcHeight+getCurrentScroll() > lbHeight) lbHeight = lcHeight+getCurrentScroll();
	lb.style.height = lbHeight+'px';
	
}
function hideLinkedContent() {
  document.getElementById('linked_content_popup').style.display='none';
  document.getElementById('linked_content_light_box').style.display='none';
  window.scrollTo(0,getCurrentScroll());
}


// toggle prices vat / no vat
function productShowPrices(kaj) {
	var div = document.getElementById('hidden_detail_prices_'+kaj);
	document.getElementById('product_detail_prices').innerHTML = div.innerHTML;
}




// submit basket || povprasevanje
function addProductToBasket() {
	var frm = document.getElementById('frmSizes');
	frm.action = '/kosarica/dodaj' + fileExtension;
	frm.submit();
}


// recalculate sum price for product
function sumProductPrice() {
	var listed = parseInt(document.getElementById('listed').value);
	var isVat = document.getElementById('hidden_detail_prices_type').value;
	var sumPrice = 0;
	var sumPriceVat = 0;
	var tempSum = 0;
	var tempSumVat = 0;
	for(i=0; i<listed; i++) {
		tempSum = (parseFloat(document.getElementById('q_'+i).value) * parseFloat(document.getElementById('p_'+i).value));
		tempSumVat = (parseFloat(document.getElementById('q_'+i).value) * parseFloat(document.getElementById('pv_'+i).value));
		sumPrice += tempSum;
		sumPriceVat += tempSumVat;
		tempSum = "" + "" + tempSum.toFixed(2);
		tempSumVat = "" + "" + tempSumVat.toFixed(2);
		if(isVat == 0) {
			document.getElementById('sum_'+i).innerHTML = formatNumber(tempSum);
		} else {
			document.getElementById('sum_'+i).innerHTML = formatNumber(tempSumVat);
		}
	}
	sumPrice = "" + sumPrice.toFixed(2);
	sumPriceVat = "" + sumPriceVat.toFixed(2);
	if(isVat == 0) {
		document.getElementById('product_price_sum').innerHTML = formatNumber(sumPrice);
		document.getElementById('product_price_sum_text').innerHTML = 'Vrednost skupaj';
	} else {
		document.getElementById('product_price_sum').innerHTML = formatNumber(sumPriceVat);
		document.getElementById('product_price_sum_text').innerHTML = 'Vrednost skupaj z DDV';
	}
	//document.getElementById('product_price_vat_sum').innerHTML = formatNumber(sumPriceVat);
}


function recalculatePrices(productId, rgid) {
	var listed = parseInt(document.getElementById('listed').value);
	var isVat = document.getElementById('hidden_detail_prices_type').value;
	var prodInBasket = parseInt(document.getElementById('products_in_basket').value);
	var tempSum = 0;
	for(i=0; i<listed; i++) {
		if(document.getElementById('q_'+i).value == '') document.getElementById('q_'+i).value = '0';
		if(''+parseInt(document.getElementById('q_'+i).value) != document.getElementById('q_'+i).value)  document.getElementById('q_'+i).value = '0';
		if(parseInt(document.getElementById('q_'+i).value) < 0)	document.getElementById('q_'+i).value = '0';
		tempSum += parseInt(document.getElementById('q_'+i).value);
	}
	window.open('/ProductRecalculatePrices.aspx?prodid='+productId+'&prodsum='+tempSum+'&prodinbasket='+prodInBasket+'&rgid='+rgid+'&isvat='+isVat,'dummy');
}



// user details - prejemna mesta
function fillDeliveryFields(i) {
	if(i.length<1 || i=="NaN" || i=="undefined")	i=0;
	var frm = document.frmRegUser;
	if(i != 0) {
		frm.prej_naziv.value = document.getElementById('tmp_prej_naziv_'+i).value;
		frm.prej_naziv2.value = document.getElementById('tmp_prej_naziv2_'+i).value;
		frm.prej_naslov.value = document.getElementById('tmp_prej_naslov_'+i).value;
		frm.prej_posta.value = document.getElementById('tmp_prej_posta_'+i).value;
		frm.prej_kraj.value = document.getElementById('tmp_prej_kraj_'+i).value;
		document.getElementById('user_delivery_details').innerHTML = 'Spremeni podatke:';
		document.getElementById('kaj').value = 'edit';
	} else {
		frm.prej_naziv.value = document.getElementById('prejNaziv').value;
		frm.prej_naziv2.value = '';
		frm.prej_naslov.value = '';
		frm.prej_posta.value = '';
		frm.prej_kraj.value = '';
		document.getElementById('user_delivery_details').innerHTML = 'Dodaj novo prejemno mesto:';
		document.getElementById('kaj').value = 'add';
	}
	//alert(document.getElementById('kaj').value);
}


// register user
function registerUserCheck() {
	var frm = document.getElementById('frm_register');
	var errmsg = '';
	if(!validateEmail(frm.email.value)) {
		errmsg += '\n- Vnesite pravilen email naslov';
	}
	var status = false;
	for (i=0; i<frm.status.length; i++) {
		if (frm.status[i].checked) {
			status = true; 
		}
	}
	if(!status) {
		errmsg += '\n- Izberite svoj status';
	}
	if(errmsg == '') {
		frm.sbmchk.value='z4v45';
		frm.action = '/uporabniki/registracija' + fileExtension;
		frm.submit();
	} else {
		alert('Pri izpolnjevanju obrazca je prišlo do ene ali več napak:'+errmsg);
	}
}


// dostava - register user

function registerToggleDostava()
{
  if (document.frmRegUser.dostava.checked)
  { 
		document.getElementById("box_dostava").style.display='block';
		document.frmRegUser.addr2.value = "";
		document.frmRegUser.postna2.value = "";
		document.frmRegUser.kraj2.value = "";
	}
	else
	{ 
		document.getElementById("box_dostava").style.display='none';
		document.frmRegUser.addr2.value = document.frmRegUser.addr.value;
		document.frmRegUser.postna2.value = document.frmRegUser.postna1.value;
		document.frmRegUser.kraj2.value = document.frmRegUser.kraj1.value;
	}
}





// error message
function msgboxShow(txt){
	document.getElementById("msgbox_content").innerHTML = txt;
	document.getElementById("msgbox").style.display = "block";
	setTimeout("msgboxClose()", 5000);
}
function msgboxClose(){
	document.getElementById("msgbox").style.display = "none";
}


// facebook
function fbs_click() {
	u=location.href;
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	//alert('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t));
	return false;
}


// category submenu popup

function showCategorySubMenu(parentid, i, isall) {
	var div = document.getElementById('category_submenu');
	var parentX = getStyle(document.getElementById('category_menu_'+i,'left'));
	div.style.margin = '-1px 0px 0px ' + ((i*117) - 480) + 'px';
	var showall = '0';
	if(isall == 1) showall = '1';
	loadDivFromFile('/ProductCategoriesSubMenu.aspx?parentid='+parentid+'&showall='+showall,'category_submenu');
	div.style.display='block';
}

function hideCategorySubMenu(who) {
	var div = document.getElementById('category_submenu');
	if(who == 0) { // parentdiv
		if(cp_ispopped!=1) {
			div.innerHTML='';
			div.style.display='none';
			cp_ispopped = 0;
		}
	} else { // self
		div.innerHTML='';
		div.style.display='none';	
		cp_ispopped = 0;
	}
}


// video player

function youtube(code, width, height) {
	var yt = '<object width="' + width + '" height="' + height + '" wmode="transparent">';
	yt += '<param name="movie" value="http://www.youtube.com/v/' + code + '&hl=en&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999&autoplay=1"></param>';
	yt += '<param name="allowFullScreen" value="true"></param>';
	yt += '<param name="allowscriptaccess" value="always"></param>';
	yt += '<param name="wmode" value="opaque">';
	yt += '<embed src="http://www.youtube.com/v/' + code + '&hl=en&fs=1&rel=0&color1=0x3a3a3a&color2=0x999999&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' + width + '" height="' + height + '" wmode="transparent"></embed>';
	yt += '</object>';
	return yt;
}


function showVideo(divid, video, title, body, video_image, autostart, yt) {
	if(yt) {
		document.getElementById(divid).innerHTML = youtube(video, 420, 315);
	} else {
		var s1 = new SWFObject("/flash/mediaplayer.swf","mediaplayer","420","315","8");
		s1.addParam('allowscriptaccess','always');
		s1.addParam("allowfullscreen","true");
		s1.addParam("wmode", "transparent");
		s1.addVariable("width","420");
		s1.addVariable("height","315");
		s1.addVariable('backcolor','0xdddddd');
		s1.addVariable('frontcolor','0x000000');
		s1.addVariable('lightcolor','0xffff00');
		s1.addVariable('screencolor','0x000000');
		s1.addVariable('searchbar','false');
		s1.addVariable('autostart',autostart);
		s1.addVariable('enablejs','true');
		s1.addVariable("file",video);
		if(video_image!="") {
			s1.addVariable("image",video_image);
		}
		s1.write(divid);
	}
	document.getElementById('videobody').innerHTML = body;
	document.getElementById('videotitle').innerHTML = title;
}


function showProductVideo(video, autostart, yt) {
	if(yt) {
		document.getElementById('image_big').innerHTML = youtube(video, 420, 315);
	} else {
		var s1 = new SWFObject("/flash/mediaplayer.swf","mediaplayer","420","315","8");
		s1.addParam('allowscriptaccess','always');
		s1.addParam("allowfullscreen","true");
		s1.addParam("wmode", "transparent");
		s1.addVariable('width','420');
		s1.addVariable('height','315');
		s1.addVariable('backcolor','0xdddddd');
		s1.addVariable('frontcolor','0x000000');
		s1.addVariable('lightcolor','0xffff00');
		s1.addVariable('screencolor','0x000000');
		s1.addVariable('searchbar','false');
		s1.addVariable('autostart',autostart);
		s1.addVariable('enablejs','true');
		s1.addVariable('file','/src/Video/'+video);
		s1.write('image_big');
	}
}





// banners

function rotateBannerTop(curpos) {
	if(curpos == -1)	curpos = bannerTopCurPos + 1;
	var divImg = document.getElementById("banner_top_image");
	var divTxt = document.getElementById("banner_top_text");
	if(curpos >= bannerTopCount)	curpos = 0;
	bannerTopCurPos = curpos;
	for(i=0; i<bannerTopCount; i++) {
		document.getElementById('pag_'+i).className='pag';
	}
	document.getElementById('pag_'+curpos).className='pag_over';
	divTxt.innerHTML = bannersTop[curpos][2];
	divImg.innerHTML = '<a href="' + bannersTop[curpos][3] + '" class="nounderline"><img src="/src/Banner/' + bannersTop[curpos][0] + '" alt="' + bannersTop[curpos][1] + '" /></a>';
	showItem(0,'banner_top_image');
	bannerTopTO = setTimeout('rotateBannerTop(' + (curpos + 1) + ')', bannerRefreshTime);
}

function showBannerTop(curpos) {
	bannerTopCurPos = curpos;
	clearTimeout(bannerTopTO);
	var divImg = document.getElementById("banner_top_image");
	var divTxt = document.getElementById("banner_top_text");
	
	divTxt.innerHTML = bannersTop[curpos][2];
	divImg.innerHTML = '<a href="' + bannersTop[curpos][3] + '" class="nounderline"><img src="/src/Banner/' + bannersTop[curpos][0] + '" alt="' + bannersTop[curpos][1] + '" /></a>';
	showItem(0,'banner_top_image');
	for(i=0; i<bannerTopCount; i++) {
		document.getElementById('pag_'+i).className='pag';
	}
	document.getElementById('pag_'+curpos).className='pag_over';
}






// SEARCH

function toggleSearchScope() {
	var chkall = document.getElementById('search_all_items');
	var divurl = '/SearchToggleScope.aspx';
	if(chkall.checked) {
		divurl += '?sall=1';
	} else {
		divurl += '?sall=0';
	}
	loadDivFromFile(divurl, 'toggle_search_scope');
}


// PRINT
function productPrint(id) {
	window.open('/natisni/izdelek/'+id+fileExtension, 'printframe');
	if(document.printframe) {
		document.printframe.focus();
		document.printframe.print();
	}
}

// product detail - neighbours:
function neighbourLeft() {
	var div = document.getElementById('neighbour_left');
	var posY = findPosY('stepback') + 5;
	div.style.top = posY+'px';
	div.style.display='block';
}
function hideNeighbourLeft(who) {
	var div = document.getElementById('neighbour_left');
	if(who == 0) { // parentdiv
		if(lb_popped!=1) {
			div.style.display='none';
			lb_popped = 0;
		}
	} else { // self
		div.style.display='none';	
		lb_popped = 0;
	}
}

function neighbourRight() {
	var div = document.getElementById('neighbour_right');
	var posY = findPosY('stepback') + 5;
	div.style.top = posY+'px';
	div.style.display='block';
}
function hideNeighbourRight(who) {
	var div = document.getElementById('neighbour_right');
	if(who == 0) { // parentdiv
		if(ln_popped!=1) {
			div.style.display='none';
			ln_popped = 0;
		}
	} else { // self
		div.style.display='none';	
		ln_popped = 0;
	}
}




// ONLOAD:
//document.observe('dom:loaded', function() { 
//    var rcid = document.getElementById('search_rootcatid').innerHTML;
//    var catid = document.getElementById('search_catid').innerHTML;
//    new Ajax.Autocompleter('search_input', 'search_suggestions','/SearchResults.aspx?rcid='+rcid+'&catid='+catid, {
//			minChars: 3,
//			frequency: 0.8,
//			indicator: "loading",
//			select: "search_go_to_url",
//			//afterUpdateElement: function() {document.getElementById('search_input').style.color='#ffffff'; alert(document.getElementById('search_input').value.replace('Iskanje po izdelkih','')); setTimeout("document.location.href=document.getElementById('search_input').value.replace('Iskanje po izdelkih','')", 1000);}
//			afterUpdateElement: function() {document.getElementById('search_input').style.color='#ffffff'; document.location.href=document.getElementById('search_input').value;}
//    });
//});


