window.addEvent("load", fixedload);

function fixedload(){
    window.onscroll = document.documentElement.onscroll = setMenuOffset;
    window.onresize = document.documentElement.onresize = moveX;
    moveX();
}

function setMenuOffset() { 
    var currentOffset = document.documentElement.scrollTop || document.body.scrollTop; // body for Safari
    moveX();
}


function moveX(){
    var currentXOffset = document.documentElement.scrollLeft || document.body.scrollLeft; // body for Safari
    var winSizes = $(window).getSize();
    var left;
    var scroll;

    if (winSizes.x < 1080) {      
        if (winSizes.x < 1020){
            $$('.frm .inp').set('styles', {
			    'width': '30px'
    		});
            $$('.frm a.plus').set('styles', {
			    'display': 'none'
    		});
            $$('.frm a.minus').set('styles', {
			    'display': 'none'
    		});
        } 
        
        $$('.frm span.kol-vo').set('styles', {
			'display': 'none'
    	});
	} else {
        $$('.frm .inp').set('styles', {
		    'width': '48px'
  		});

	    $$('.frm span.kol-vo').set('styles', {
			'display': ''
		});
        $$('.frm a.plus').set('styles', {
	        'display': ''
    	});
        $$('.frm a.minus').set('styles', {
		    'display': ''
    	});		
	}


    if (winSizes.x <= 1280 && winSizes.x >= 1004) {
        left = winSizes.x - 380;
        if (!Browser.Engine.presto && !Browser.Engine.webkit) left += 20;
        if (Browser.Engine.webkit) left += 5;

        if (left != parseInt($('fixed-box').style.left)) {
            $('fixed-box').style.right = "";
            $('fixed-box').style.left = left + 'px';
        }
    } else {
        if (winSizes.x < 1004) {        
            scroll = $(window).getScrollSize();
            if (Browser.Engine.trident4) {
                left = 1004 - 360;
            } else {
                left = 1004 - 360 - currentXOffset;
            }
            if (left != parseInt($('fixed-box').style.left)) {
                $('fixed-box').style.right = "";
                $('fixed-box').style.left = left + 'px';
            }
        } else {       
            right = (winSizes.x - 1280)/2;
            if (Browser.Engine.presto) right -= 10;
            if (Browser.Engine.webkit) right -= 10;
            if (right != parseInt($('fixed-box').style.right)) {
                $('fixed-box').style.left = "";
                $('fixed-box').style.right = right + 'px';
            }
        }
    }
}