$(document).ready(function(){
try{

	$("ul.css-tabs li:first").addClass("current");
	$("ul.css-tabs li a").click(function(){
		$("ul.css-tabs li").removeClass("current");
		$(this).parent().parent().addClass("current");
	});
	
	//Tira as bordas do topo dos dois primeiros ítens dos resultados de busca de receita
	$(".resultbuscareceita .detalheslist li:lt(2)").css("border-top","none");
	$(".resultbuscareceita .detalheslist li:nth-child(2)").css("border-top","none");

	// ATALHOS ACESSKEY
	$("#lfp1").attr("accesskey",0);
	$("#logo").attr("accesskey",1);
	$("#lnkacessibilidade").attr("accesskey",2);
	$(".lnkparent").attr("accesskey",3);
	$(".pagina_inicial").attr("accesskey",4);
	$("#ebFooter .lnkseta").attr("accesskey",9);
} catch(e){}

});

$(document).ready(function () {
    $('.doubledetailblock .btmais').addClass('mmais');
    $('<a class="btmais mmais">Quero saber</a>').replaceAll('.mmais');	
    $(".mmais").click(function () {
		$('#splitinstalacao').addClass('ligado').height($(document).height())
		var tp=($(document).height()-$('#splitinstalacao .box').height())/2
		$('#splitinstalacao .box').css('margin-top',tp)
		window.scrollTo(0,tp-20)
		return false
    });
    $(".close").click(function () {
		$('#splitinstalacao').removeClass('ligado')
		return false
   });
});


$(document).ready(function(){

	try{
	
		// MENU 
		$('#nav li').hover(function(){
			$(this).find('ul.dropdown').addClass('displayblock');
			$(this).find('ul.dropdown').removeClass('displaynone');
		}, function(){
			$(this).find('ul.dropdown').removeClass('displayblock');
			$(this).find('ul.dropdown').addClass('displaynone');
		});
		// MENU SELECTED

		/*$('#nav .listparent a').click(function(){
			_class=$(this).parents('.listparent').attr('class').replace(/listparent /,'')
			createCookie('selected',_class,365)
		});

		if (_class=readCookie('selected')) {
			$('.listparent .lnkparent').removeClass('selected')
			$('#nav .'+_class+' span,#nav .'+_class+'>a').addClass('selected')
		}*/		

	}catch(e){}

	try{

	// setup ul.tabs to work as tabs for each div directly under div.panes 
	$("ul.tabs").tabs("div.panes > div"); 
	$("ul.css-tabs:first").tabs("div.css-panes:first > div");

	}catch(e){}

	try{
	
	$("ul.tabs li:first").addClass("current first-child");
	$("ul.tabs li:last-child, .detalheslist li:last-child, .acessibilidade li:last-child").addClass("last-child");
	

	$("div fieldset:last-child, ul li:last-child").addClass("lastchild");
	$("li:last-child").addClass("lastchild");
	$("div fieldset:last").addClass("lastchild");

	$("ul.tabs li a").click(function(){
		$("ul.tabs li").removeClass("current")
		$(this).parent().addClass("current")
	})
	
	}catch(e){}
	
	// setup ul.tabs to work as tabs for each div directly under div.panes

	$("ul.tectabs").tabs("div.panes > div");

	try{
		$("ul.tectabs li:first").addClass("current first-child");
		$("ul.tectabs li:last").addClass("last-child");
		$("ul.tectabs li a").click(function () {
			$("ul.tectabs li").removeClass("current");
			$(this).parent().addClass("current");
		});
	
	var qtdnumber = $(".produtolist ul li").length;
	if (qtdnumber <= 2) {
		$(".produtolist ul").addClass("listcenter"); 
	} else {
		$(".produtolist ul").removeClass("listcenter");
	}

	$('.produtolist li:nth-child(4n)').css({"margin-right":"0"})

	}catch(e){}
});

// Fim dos JS de Funcoes

 $(document).ready(function(){

			$("#nav-one li").hover(
				function(){ $("ul", this).fadeIn("fast"); }, 
				function() { } 
			);
	  	if (document.all) {
				$("#nav-one li").hoverClass ("sfHover");
			}
	  });
	  
		$.fn.hoverClass = function(c) {
			return this.each(function(){
				$(this).hover( 
					function() { $(this).addClass(c);  },
					function() { $(this).removeClass(c); }
				);
			});
		};	  
		
	/**
	* Funções da troca das cores do site
	**/
	(function($){
			try{
				// Call stylesheet init so that all stylesheet changing functions 
				// will work.
				$.stylesheetInit();
				
				// This code loops through the stylesheets when you click the link with 
				// an ID of "toggler" below.
				$('#toggler').bind(
					'click',
					function(e)
					{
						$.stylesheetToggle();
						return false;
					}
				);
				
				// When one of the styleswitch links is clicked then switch the stylesheet to
				// the one matching the value of that links rel attribute.
				$('.styleswitch').bind(
					'click',
					function(e)
					{
						$.stylesheetSwitch(this.getAttribute('rel'));
						return false;
					}
				);
			}catch(e){}
	})(jQuery);

// cookie functions
function createCookie(name,value,days){
	if (days)	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name){
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name){
	createCookie(name,"",-1);
}
// /cookie functions		


// execute your scripts when the DOM is ready. this is a good habit
$(function() {

    // initialize scrollable
	try{
		$("div.scrollable").scrollable();
	}catch(e){}

});

$(function() {

$(".items img").click(function() {

    // calclulate large image's URL based on the thumbnail URL (flickr specific)
    var url = $(this).attr("src").replace("_t", "");

    // get handle to element that wraps the image and make it semitransparent
    var wrap = $("#image_wrap").fadeTo("medium", 0.5);

    // the large image from flickr
    var img = new Image();

    // call this function after it's loaded
    img.onload = function() {

        // make wrapper fully visible
        wrap.fadeTo("fast", 1);

        // change the image
        wrap.find("img").attr("src", url);

    };

    // begin loading the image from flickr
    img.src = url;

// when page loads simulate a "click" on the first image
}).filter(":first").click();
});


$(function() {
	$('.typemonosplit').addClass('typeseparador')

});

/*$(function(){
	//try{
	  if($.browser.msie){
	  $('.bt').each(function(){
		var span=$('<span><span></span></span>')
		$(this).after(span)
		$(this).remove()
		$(span).find('span:eq(0)').append(this)
		span.attr('class',$(this).attr('class').replace(/bt/g,'button')+' '+$(this).attr('class'))
		if ($(this).attr('class').indexOf('sh')!=-1) {
			$(this).attr('class',$(this).attr('class').substr($(this).attr('class').indexOf('sh')))
		}else {	$(this).attr('class','')}
	  })
	  }
	//}catch(e){}
});*/

$(function () {
	try {
		var sb=$("a[rel=shadowbox]")
		if(sb.length){
			$("a[rel=shadowbox]").each(function(){
				//dim=sb.attr('class').split('sh')[1].split('x')
				dim=$(this).attr('class').split('sh')[1].split('x')
				$(this).fancybox({
					transitionIn: 'none',
					transitionOut: 'none',
					titlePosition: 'none',
					width: parseInt(dim[0]),
					height: parseInt(dim[1]),
					autoScale: false,
					autoDimensions: false,
					showNavArrows: false,
					onComplete: function () {
						$('#fancybox-left,#fancybox-right').hide()
						$('#fancybox-outer').addClass('flash')
					}
				});
			});
		}
	} catch(e){ }
});

//Borda Arredondada IE
$(function() {
	$('.box').wrapInner('<div class="roundInner">').append('<div style="clear:both;font-size:1px;">&nbsp;</div>');
});

$(function() {
    try
	{
		var galleries = $('.ad-gallery').adGallery({
				width:380,
				height:380,
				effect:'fade',
				callbacks:{beforeImageVisible:addLupa}
			});
   	    if (galleries == undefined)
        return;
    }
	catch(e)
	{
	
	}
    $('#switch-effect').change
	(
      function() 
	  {
        galleries[0].settings.effect = $(this).val();
        return false;
      }
    );
	
    $('#toggle-slideshow').click(
      function() {
        galleries[0].slideshow.toggle();
        return false;
      }
    );
  });

/* COMPARTILHE BEGIN */
function reconfig_menu(){
  $('div[id$=_head]')
    .before('<div class="shareboxheader minbox">Compartilhe Consul: Parte de sua casa</div>')
    .remove()
  if(!$(".shareboxheader.maxbox").length)
    $('span[id$=_brand]').parent()
      .before('<div class="shareboxheader maxbox">Compartilhe Consul: Parte de sua casa</div>')
      .hide()
  $('.shareboxheader.minbox')
    .parent().parent().addClass('shareboxcontainer').end().css('margin','-4px')
  $('.shareboxcontainer>div>div:last').addClass('shareboxfooter')
  $('.shareboxheader.maxbox').parent().find('div:last').addClass('shareboxfooter')
  $('.shareboxheader.maxbox').parent().parent().parent().parent().css({width:290,padding:'0 1px'})
  if($('.shareboxcontainer .at_item').length%2){
    $('.at_item:last').before('<div class="at_item" style="width:102px;float:left;"></div>').removeClass('at_col0').addClass('at_col1')
  }
}
$(function(){
  $('.addthis_button').mouseover(function(){setTimeout('reconfig_menu()',100)})
})
/* COMPARTILHE END */

/* Excluir caracteres especiais em textbox ou textarea */

function numeros() {
    if (document.all) { // Internet Explorer 
        nTecla = event.keyCode;
    }
    else if (document.layers && navigator.appName.indexOf("Mozilla") == -1) { // Nestcape 
        nTecla = event.which;
    }
    else { // Mozilla / FireFox / Opera 
        nTecla = event.which;
    }

    if ((nTecla < 44) || (nTecla > 57)) {
        if ((nTecla < 96) || (nTecla > 106)) {
            //alert("Somente números são permitidos");
            event.returnValue = false;
        }
    }
}
/* End Excluir caracteres especiais em textbox ou textarea */

$(function() {
    $('#comparador table tbody tr:even').css('background', '#f3f5e8');
    $('#comparador table tbody tr > td:first-child').addClass('itens');
    $('#comparador table tbody tr > td:last-child').css('border-right', 'none');
    $('#comparador table tbody > tr:last-child').css('border-bottom', 'none');
}); 

//SLIDER HOME CONSUL
$(document).ready(function(){
	try {
		$("#slider").easySlider({
			auto: true,
			continuous: true
		});
	} catch(e){};
});

/* CODIGO USADO NA PAGINA DE ENTRE EM CONTATO */
$(document).ready(function() {
	$(".contato ul.tabs li.aba4").removeClass("lastchild");
}); 

/* Codigo Utilizado no módulo de Mais Receitas  */
$(document).ready(function() {
	$(".receitas-destaques").removeClass("lastchild");
	$(".receitas-destaques").removeClass("last-child");
	$(".receitas-destaques:last").addClass("receitas-destaques last");
});

$(document).ready(function() {
	$("ul.detalheslist span span li.teste").removeClass("lastchild");
	$("ul.detalheslist span span li.teste").removeClass("last-child");
	$("ul.detalheslist span span li.teste:last-child").addClass("last-child");
});

/*** Muda tamanho de fonte ***/
$(document).ready(function(){
	var psize = $('p');
	var tamanhoatual = 0;
	var tamanhoatual = tamanhoatual + 1;
	$(".letramaior").click(function(){
		var size = $(psize).css("font-size");
		var newSize = parseInt(size.replace(/px/, "")) + 1;

		if (tamanhoatual<=2){
			$(psize).css("font-size", newSize + "px");
			tamanhoatual++;
		}

	});
	$(".letramenor").click(function(){
		var size = $(psize).css("font-size");
		var newSize = parseInt(size.replace(/px/, "")) - 1;

		if (tamanhoatual>=0){
			$(psize).css("font-size", newSize + "px");
			tamanhoatual--;
		}

	});
});	

function addLupa(){
	$(".ad-image-description").after('<img src="/images/icolupa.png" class="icolupa" onclick="$(\'.img_media\').click()">')
}

//Acrescenta o link para a lupa do carroucel
$(document).ready(function(){
	setTimeout(addLupa,500)
});	
