$(document).ready(function(){
	function getCursorX(e){
		return e.pageX || e.layerX || e.clientX + document.documentElement.scrollLeft;
	};
	var scroller;
	$(document).mousemove(function(e){
		var percentage = -(getCursorX(e) * 2 / $(window).width()) + 1;
		if (!(scroller = document.getElementById('cloud_1'))) return;
		scroller.style.marginLeft = ~~(percentage*13) + "px";
		if (!(scroller = document.getElementById('cloud_2'))) return;
		scroller.style.marginLeft = ~~(percentage*10) + "px";
		if (!(scroller = document.getElementById('cloud_3'))) return;
		scroller.style.marginLeft = ~~(percentage*12) + "px";
		if (!(scroller = document.getElementById('cloud_4'))) return;
		scroller.style.marginLeft = ~~(percentage*8) + "px";
		if (!(scroller = document.getElementById('cloud_5'))) return;
		scroller.style.marginLeft = ~~(percentage*20) + "px";
	});
    $("#sort").tablesorter();
    
    
    var IE=!!top.execScript;
     
    if (!IE)
    {
     var admin = $("#admin");
     if ($.cookie("top") < 0)
     {
        $.cookie("top", 0);
     }
     admin.animate({"left" : $.cookie("left") + "px", "top" : $.cookie("top") + "px"}, 1000);
    
    $("#admin").draggable({ scroll: true,
            stop: function(e,ui) {
    			$.cookie("top", ui.position.top);
                $.cookie("left", ui.position.left);
    		}
      });
    }
    else
    {
    $("#admin").draggable({ scroll: true});
    }
     
    $("#disable, #enable").click(function(){
    $("#loading").css("display", "inherit");
    jQuery.post("/ajax/disable_page.php", {"co_id": $(this).attr("co_id"), "set" : $(this).attr("id")},
    function(data){
        window.location.reload();
    }, "json");
    });
    
    $(".compressor_philter p").toggle(function(){
        $(this).find("span").css("background-position","13px 13px");
        $("div#" + $(this).attr("id")).stop(true,true).hide(500);
    },function(){
        $(this).find("span").css("background-position","0px 0px");
        $("div#" + $(this).attr("id")).stop(true,true).show(500);
    });
    
    $("input[type=submit]").button();
    
    $(".tbl tr:even td, .catalogue_tech tr:even td").css("background", "#e5edff");
    
    $(function() {
        var d=300;
        $('#navigation a').each(function(){
            $(this).stop().animate({
                'marginTop':'-80px'
            },d+=150);
        });

        $('#navigation > li').hover(
        function () {
            $('a',$(this)).stop().animate({
                'marginTop':'-2px'
            },200);
        },
        function () {
            $('a',$(this)).stop().animate({
                'marginTop':'-80px'
            },200);
        }
    );
    });
    
    
    
});


/*
var $path = "http://www.compressor-rnd.ru/templates/site/images/";

container='test';
snow_intensive=400; 
snow_speed=20000; 
snow_src=new Array($path + 'sneg1.gif', $path + 'sneg2.gif', $path + 'sneg3.gif', $path + 'sneg4.png'); 

$(document).ready(snow_start); 

function snow_start() { 
	snow_id=1; 
	snow_y=$("#" + container).height()-30; 
	setInterval(function() { 
		snow_x=Math.random()*document.body.offsetWidth-100; 
		snow_img=(snow_src instanceof Array ? snow_src[Math.floor(Math.random()*snow_src.length)] : snow_src); 
		snow_elem='<img class="png" id="snow'+snow_id+'" style="position:absolute; left:'+snow_x+'px; top:0;z-index:10000" src="'+snow_img+'">'; 
		$("#" + container).append(snow_elem); 
		snow_move(snow_id); 
		snow_id++; 
	},snow_intensive);
} 

function snow_move(id) { 
	$('#snow'+id).animate({top:snow_y,left:"+="+Math.random()*100},snow_speed,function() { 
	$(this).empty().remove(); 
});}*/
