$(document).ready(function(){   

    $("img.jqzoom").jqueryzoom();

    customResize();
    
    $(window).resize(customResize);

    $(".navPanel ul li").hover(
        function () {                       
            var tooltip = $(this).find("img").attr("alt");
            $(".navPanel ul li").css("z-index","0");            
            $(this).css("z-index","9999").find("a").stop().animate({"top": "25px","left": "25px"}, 250).append("<div>" + tooltip + "</div>");
            $(this).find("a div").addClass("tooltip");
        }, 
        function () {
            $(this).find("a").stop().animate({"top": "0","left": "0"}, 250);            
            $(this).find("a div").remove();
        }
    );

})

function customResize(){
    //определим число элементов
    var windowWidth = $(window).width();
    if (windowWidth > 1200) windowWidth = 1200;         
    var newsize = windowWidth / 180; newsize = newsize.toFixed(0);
    
    //удалим лишнее
    $(".navPanel ul li").each(remove);
            
    function remove(index){            
        if (index > newsize-1){            
            $(this).css("display","none");                
        }else{
            $(this).css("display","block");
        }    
    }    
                            
}

/* обновляем капчу */
function reloadCaptcha(){
	
	$("#captchaImg").attr("src","/captcha/"+Math.round(Math.random()*1000));
	$(".captchaText").attr("value","");
	
	return true;
}

/* разворачивающиеся блоки */
function toggleBlock(block){
	if ($("#"+block).css("display") == 'block'){	
		//сворачиваем				
		$("#"+block).slideUp("slow");
	}else{										
		$("#"+block).slideDown("slow");
		
	}	
}		
