$(document).ready(function(){

   
   var cant = $("#topmenu ul.menu-level-0 > li").length;
   var totalwidth = $("#topmenu").width();
   var usedwidth = 0;
   $("#topmenu ul.menu-level-0 > li > a").each(function(){
      usedwidth+=$(this).width()+2;
   });
   var padding = (totalwidth - usedwidth) / cant / 2;
   $("#topmenu ul.menu-level-0 > li > a").css('padding','0px '+padding+'px');
   $("#topmenu ul.menu-level-0 > li").css('display','inline');
   

   var cant = $("#links a").length;
   var totalwidth = $("#links").width();
   var usedwidth = 0;
   $("#links a").each(function(){
      usedwidth+=$(this).width()+4;
   });
   var padding = (totalwidth - usedwidth) / cant / 2;
   $("#links a").css('padding','0px '+padding+'px');


   $("#topmenu ul.menu-level-0 > li").bind("mouseenter", function(){
   	$(this).addClass("selected");
   	$(this).children("ul").show();
   });
   $("#topmenu ul.menu-level-0 > li").bind("mouseleave", function(){
   	$(this).removeClass("selected");
   	$(this).children("ul").hide();
   });
   $("#topmenu ul.menu-level-1 > li").bind("mouseenter", function(){
        $(this).addClass("selected");
        $(this).children("ul").show();
   });
   $("#topmenu ul.menu-level-1 > li").bind("mouseleave", function(){
        $(this).removeClass("selected");
        $(this).children("ul").hide();
   });

   $("div.class-novedades div.content-view-children").cycle({
      fx: 'scrollUp',
      timeout: 6000,
      pause: 1
   });

   $(".scrollable").each(function(){
      if($(this).get(0).scrollHeight > $(this).get(0).clientHeight){
         $(this).after("<div class='scrollbar'></div>");
         $(this).attr('scrollTop',0);
         $(".scrollable").mousewheel(function(e, value){
            var scrollbar = $(this).next();
            $(scrollbar).slider('value', $(scrollbar).slider('value') + value*8)
//            if($(scrollbar).slider('value') <= 0 || $(scrollbar).slider('value') >= 100) return true;
            return false;
         });
      } else {
         $(this).removeClass("scrollable");
      }
   });
   $(".scrollbar").slider({
      axis: 'vertical',
      orientation: 'vertical',
      value: 100,
      change: handleSliderChange,
      slide: handleSliderSlide});

   $("div.language select").sSelect();

   $("div.content-view-line div.class-faq div.attribute-description").each(function(){
      $(this).css('height', $(this).css('height'));
      $(this).hide();
   });
   $("div.content-view-line div.class-faq h2").click(function(){
      $(this).next().slideToggle();
   });

   $("div.content-view-line div.class-termotanque div.attribute-image a, div.content-view-line div.class-calefon div.attribute-image a, div.content-view-line div.class-caldera div.attribute-image a").fancybox();
});

function selectCountry(country){
    location.href=country;
}

function sumate(){
   document.getElementById("sumate").submit();
}

   function handleSliderChange(e, ui){
      var elem = $(ui.handle).parent().prev();
      var maxScroll = elem.attr("scrollHeight") - elem.height();
      elem.attr({scrollTop: (100-ui.value) * (maxScroll / 100) });
   }

   function handleSliderSlide(e, ui){
      var elem = $(ui.handle).parent().prev();
      var maxScroll = elem.attr("scrollHeight") - elem.height();
      elem.attr({scrollTop: (100-ui.value) * (maxScroll / 100) });
   }

/*$(document).ready(function(){
	if(!$.cookie('felicidades')){
		$.fancybox({
			'padding'       : 0,
			'autoScale'     : false,
			'transitionIn'  : 'none',
			'transitionOut' : 'none',
			'width'         : 640,
			'height'        : 480,
			'href'          : "/design/rheem_com_ar/images/felicidades.swf",
			'type'          : 'swf',
			'swf'           : {
				'wmode'             : 'transparent',
				'allowfullscreen'   : 'true'
			}
		});
	}
	$.cookie('felicidades', 'true', { expires: 3});
});
*/

