$(document).ready(function(){
	$(".decrease").click(function(){ fontSize("minus") }).blur();
    $(".increase").click(function(){ fontSize("plus") }).blur();


    if ($("body.news").length) {
        $("div.news-images a:not(:first)").hide();
        if ($("div.news-images a").length > 1) {
            $("div.news-images").append("<a href='' class='see-more'>veja mais fotos</a>").find(".see-more").attr("href", "javascript:void(0)").click(function() {
                $("div.news-images a:first").next().click();
            });
        }
        $("div.news-images a:not(.see-more)").lightBox({
            txtImage: "Foto",
            txtOf: "de"
        });
    }
	
	
	if($("#box-enquete").length){
		$("#form-enquete").submit(function(){
			if(!$("input[name='answerId']:checked").length){
				return false;
			}
		})
    }
	if($("body.poll").length){
		
		$("div.poll form").submit(function(){
			if (!$("input[name='answerId']:checked", $(this)).length) {
				return false;
			}
		})
		
    }
	if($("table.result").length)
	{
		$('table.result tr:odd').addClass('odd');
	}
	
	if($("body.simulator.first-step").length){
		$("input[name='valor']:not(:checked)").parent().siblings("input.text-field").attr("disabled", true);
		$("input[name='valor']").click(function(){
			$("input[name='valor']:not(:checked)").parent().siblings("input.text-field").attr("disabled", true).attr("value", "0");
			$(this).parent().siblings("input.text-field").attr("disabled", false);
		});
	}
	
	if($(".all-news  #primary .highlight").length){
		$(".all-news  #primary .highlight:last-child").addClass("last");
	}


	if($("body#john-deere.contact-us")){
		if($("#ouvidoria").length){
			$("#ouvidoria").click(function(){
				$("#contact-options").slideDown("slow");
				$("#this").unbind("click");
			})
		}else{
			$("#contact-options").show();
		}
	}
	
	$("a[rel='external']").attr('target','_blank');
	
});
function fontSize(action, container){
    container = typeof(container) != 'undefined' ? container : "#content" //se não for especificado um container será "div.texto"
	baseSize = parseInt($(container+" p").css("font-size")) //extraímos o font-size padrão, tomando como base o p do nosso container
	
	
 
    $els = $(container+" p");
 
    $els.each(function(){
        $fs = parseInt($(this).css("font-size"));
        if(action=="plus" && baseSize < 16){ 
            $fs+=1;
        }
        else if(
            action == "minus" && baseSize > 11) {
        $fs -= 1;
               }
        $(this).css("font-size", $fs)
    })
}
