function getRandomArbitary(min, max){ return Math.round(Math.random() * (max - min) + min); }
function rosi_rotate(){
   size = $("#rosi_rotate p").size();
   M = $("#rosi_rotate p:visible").next().index();
   if(M<0){M=0;}
   N = M+1;
   if(N>size){N=1;}
   $("#rosi_rotate p").fadeOut(1000);
   $("#rosi_rotate p:nth-child("+N+")").fadeIn(1000);
}

jQuery(document).ready(function() {
    $("#menu_rosi_turin li").css({"background" : "#fff url(http://www.rosi.ru/menu/imgs/arrow1_1.gif) no-repeat 5px center"});
    $("#menu_rosi_turin li:has(ul)").css({"background" : "#fff url(http://www.rosi.ru/menu/imgs/arrow2_1.gif) no-repeat 5px center"});

    $("#menu_rosi_turin li").hover(
	function(){ //over
	 $(this).css({"border-left-color" : "#090", "border-top-color" : "#aab", "border-bottom-color" : "#eef", "border-right-color" : "#eef"});
     $(this).children("ul").css({"display" : "block"});
			  },
    function(){ //out
	 $(this).css({"border-color" : "#fff", "border-left-color" : "#bbb", "border-bottom" : "1px dotted #eee"});
     $(this).children("ul").css({"display" : "none"});
			  });

/**   For Menu-top   **/   

    var wid = 0;
    var wid2 = 0;

    $(".turin_menu-top>li>ul").css({"left" : "0"});
    $(".turin_menu-top li").hover(
	function(){ //over
	 $(this).css({"border-left-color" : "#090", "border-top-color" : "#aab", "border-bottom-color" : "#eef", "border-right-color" : "#eef"});
     wid = $(this).width();
     wid2 = $(this).children("ul").width();

     if(wid2 < wid) {
       $(this).children("ul").css({"min-width" : wid+12+"px"});
     }

     wid = $(this).children("ul").width();
     $(this).children("ul").css({"left" : wid+"px"});
     $(".turin_menu-top>li>ul").css({"left" : "0"});

     $(this).children("ul").css({"display" : "block"});
			  },
    function(){ //out
	 $(this).css({"border-color" : "#fff", "border-left-color" : "#bbb", "border-bottom-color" : "#eee"});
     $(this).children("ul").css({"display" : "none"});
			  });

/**   For Rotate   **/   
   if(b!=1){
      $("#rosi_rotate p:first-child").show();
      var b = 1;
   }

   rotate_interval = setInterval(rosi_rotate,5000);
   $('#rosi_rotate').hover(function() {
     clearInterval(rotate_interval);
   }, function() {
     rotate_interval = setInterval(rosi_rotate,5000);
   });

});
