window.onload = function(){
	// from script.js
	block=document.getElementById("korz");	
	popup=document.getElementById("korzina-popup");
	block.onmouseover=function() {
		popup.style.display="block";	
	}
	
	popup.onmouseover=function() {
		popup.style.display="block";	
	}
	
	popup.onmouseout=function() {
		popup.style.display="none";	
	}
	
	var speed = 150;
	
	$(".lvl1").click( function() {
		level = $(this).attr('class').replace('leftmenu ', '');
		curr_ul = $(this).parent().children('ul.'+level);
		display = $(curr_ul).css('display');
		$("ul."+level).slideUp(speed);
		if (display=='none') {
			$(this).parent().children('ul.'+level).slideDown(speed);
		}
		else {
			$(this).parent().children('ul.'+level).slideUp(speed);
		}
	});
}

window.onscroll = function() { }

function numUp(inpId){
 	$(inpId).val(Number($(inpId).val())+1);
}
  
function numDown(inpId){
if($(inpId).val()!=0){
  	$(inpId).val(Number($(inpId).val())-1);
  }
}

function bnumUp(inpId){
 	$(inpId).html(Number($(inpId).html())+1);
 	$.ajax({ url: "/orders/reCountA/"+inpId.replace(/#bnum/,'')+"/"+Number($(inpId).html()),  cache: false,  success: function(html){ $("#cart_top").html(html); }});
}
  
function bnumDown(inpId){
if($(inpId).html()!=1){
  	$(inpId).html(Number($(inpId).html())-1);
  	$.ajax({ url: "/orders/reCountA/"+inpId.replace(/#bnum/,'')+"/"+Number($(inpId).html()),  cache: false,  success: function(html){ $("#cart_top").html(html); }});
  }
}

function switchPrd(prdId){
$("#tovar").html("<img style=\"padding-top:200px;padding-left:200px\" src=\"/images/35-0.gif\">");$.ajax({ url: "/categories/switchprd/"+prdId,  cache: false,  success: function(html){ $("#tovar").html(html); }});
}

function positionit() {
    var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;
    var dsoctop=document.all? iebody.scrollTop : pageYOffset;
    if (document.all||document.getElementById) {
        var docHeight=0;
	if (typeof(window.innerWidth) == 'number') { docHeight = window.innerHeight; }
	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { docHeight = document.documentElement.clientHeight; }
	else if (document.body && (document.body.clientWidth || document.body.clientHeight)) { docHeight = document.body.clientHeight; }
        
        if (docHeight>theobject.height()) {
            dsoctop = dsoctop - theobjectPosition;
        }
        else {
            objectTop = lastPosition + theobjectPosition;
            objectBottom = objectTop + theobject.height();
            if((objectTop < dsoctop) && (dsoctop + docHeight < objectBottom)) {
                dsoctop = lastPosition;
            }
            else {
                dsoctop = dsoctop - theobjectPosition;
                if (lastPosition < dsoctop) {
                    dsoctop = dsoctop - (objectBottom - objectTop - docHeight)
                }
            }
        }
        if ((dsoctop + theobject.height()) > bottomPosition) {
            dsoctop = bottomPosition - theobject.height();
        }

        if (dsoctop < 0) dsoctop = 0;
        if (lastPosition != dsoctop) {
            lastPosition = dsoctop;
            theobject.animate({paddingTop: dsoctop}, 1000);
        }
    }
}
