function rand( min, max ) {
 
    if( max ) {
        return Math.floor(Math.random() * (max - min + 1)) + min;
    } else {
        return Math.floor(Math.random() * (min + 1));
    }
}
function reloadImage(image)
{
   img = document.getElementById(image);
   img.src = '/captcha/generate/'+rand(1, 1000);
}

$(document).ready(function(){
    $("#search_form").submit(function(){
        if ($.trim($("#search_text").val()) != '') {
            str = $.trim($("#search_text").val());
            if (str.length < 4) {
                alert('Текст запроса слишком маленький, попробуйте ещё.');
                $("#search_text").click().val(str);
                return false;
            }
            newstr = str.replace(/[^а-яА-Яa-zA-Z0-9 ]/gi, "");
            //newstr = escape(newstr);
            newstr = newstr.replace(/\s/gi, "_")
            $('#search_form').attr('action', $('#search_form').attr('action') + newstr + '/1');
            //alert($('#search_form').attr('action') + '\n' + newstr);
            return true;
        } else {
            alert('введите текст для поиска');
            return false;
        }
    });
});
if ($.browser.msie) {
	$(document).ready(function(){
	 $("ul.dropdown li").hover(function(){
	   $(this).addClass("hover");
	   $('> .dir',this).addClass("open");
	   $('ul:first',this).css('visibility', 'visible');
	 },function(){
	   $(this).removeClass("hover");
	   $('.open',this).removeClass("open");
	   $('ul:first',this).css('visibility', 'hidden');
	 });

	});
}


