google.setOnLoadCallback(function(){
	
    var cache = [];

    $("a[rel='rollover'] img, input[type='image']").each(function(){

        var cacheImage = document.createElement('img');
        var img = this.src;
        img = img.replace("_off","_on");
        cacheImage.src = img;
        cache.push(cacheImage);
    })

    .hover(function(){
        this.src = this.src.replace("_off","_on");
    },function(){
        this.src = this.src.replace("_on","_off");
    });

    $(".menu_nivel1").click(function(){
        $(".menuitens2:not(."+$(this).attr('id')+")").slideUp();
        $("."+$(this).attr('id')).slideToggle();
    });

    $(".input_login").focusin(function(){
        if($(this).val()=='e-mail')
           $(this).val('');
    });

    $(".input_login").focusout(function(){
        if($(this).val()=='')
            $(this).val('e-mail');
    });

	idCepea = 'cepea';
    vmFuturo = 'bmf';
    vcGraos = 'cgsoja';
    vmfNewYork = 'ny';
  

    $(".mFuturo").click(function(){

        pag = $(this).attr('id');
		//ajax('ajaxmfuturo.php?do='+pag,'mFuturo'); 
        $("#mFuturo").load('/ajaxMFuturo.php?do='+pag, function(){

            if(pag='bmf'){

                $("#mFuturo a").click(function(){

                    window.open('https://quotes.enfoque.com.br/noticiasagricolas/login.aspx?cod='+$(this).attr('id'),$(this).attr('id'),'width=760,height=440,scrollbars=yes,toolbar=no,location=no,status=yes,menubar=no,resizable=yes,left=0,top=0')

                });

            }

        });

        $(".mFuturo").attr('href','javascript:void(0)');

        $(this).removeAttr('href');

        vmFuturo = pag;

    });

    $(".cGraos").click(function(){

        pag = $(this).attr('id');

        $("#cGraos").load('/ajaxMFuturo.php?do='+pag);

        $(".cGraos").attr('href','javascript:void(0)');

        $(this).removeAttr('href');

        vcGraos = pag;

    });

     $(".cepea").click(function(){

        pag = $(this).attr('id');
		//ajax('ajaxMFuturo.php?do='+pag,'Cepea');
        $("#cepea").load('/ajaxMFuturo.php?do='+pag);

        $(".cepea").attr('href','javascript:void(0)');

        $(this).removeAttr('href');

        idCepea = pag;

        //alert(idCepea); 

      });

    $(".mfNewYork").click(function(){

        pag = $(this).attr('id');
		//ajax('ajaxMFuturo.php?do='+pag,'mfNewYork');
        $("#mfNewYork").load('/ajaxMFuturo.php?do='+pag);

        $(".mfNewYork").attr('href','javascript:void(0)');

        $(this).removeAttr('href');

        vmfNewYork = pag;

    });

    setInterval(function(){

        $("#"+vmFuturo).trigger('click');

        $("#"+vcGraos).trigger('click');

        $("#"+vmfNewYork).trigger('click');
	
        $("#"+idCepea).trigger('click');

    }, 120000);

    $("#mFuturo").click(function(){

        window.open('https://quotes.enfoque.com.br/noticiasagricolas/login.aspx?cod='+$(this).attr('id'),$(this).attr('id'),'width=760,height=440,scrollbars=yes,toolbar=no,location=no,status=yes,menubar=no,resizable=yes,left=0,top=0')

    });

    $.getScript('http://s7.addthis.com/js/250/addthis_widget.js?pub=noticiasagricolas', function(){

        $('.partilhar').mouseover(

            function(){

                return addthis_open(this, '', '[URL]', '[TITLE]');

            }).mouseout(

            function(){

                addthis_close();

            }).click(

            function(){

                return addthis_sendto();

            });

        $('.enviarAmigo').click(function(){

            return addthis_open(this, 'email', '[URL]', '[TITLE]');

        });

        $('.feeds').click(function(){

            return addthis_open(this, 'feed', 'http://www.noticiasagricolas.com.br/parceiros/rss.php');

        });

    });
	
});

  function btesquerdo(){
	        $("#rotativoe").animate({
            "scrollLeft": "-=84px"
		    }, 'slow');
		
	   }// });

   // $("#btdir0").click(function(){
		 function btdireito(){
		   $("#rotativoe").animate({
           "scrollLeft": "+=84px" 
        }, 'slow'); 
		}
function changePicture(pic, idi, idf){
		  //document.getElementById(idi).src=pic; 
		  ajax('classificados/fotoplay.php?pic='+pic+'&idi='+idi+'&idf='+idf+'&lixo=true','foto');
}

  carregarProximoa = function(){

        if ($(".mvid_player_holder .ativo").next().length){

            $(".mvid_player_holder .ativo").next().trigger('click');

            $(".nextMaisVideos").trigger('click');

        }else{

            $(".mvid_player_holder a").first().trigger('click');

            $(".mvid_player_holder").animate({

                "scrollLeft": "0"

            }, 'slow');



        }

    }



    $(".mvid_player_holderc a").click(function(){

        $(".ativo").attr('class', 'inativo');

        $(this).attr('class', 'ativo');

        $.ajax({

            url: 'classificados/anuhome.php?id='+$(this).attr('id').substring(7),

            cache: 'true',

            beforeSend: function() {

                clearTimeout()

                $(".loaderMaisVideosc").fadeIn();

                clearTimeout(timeProximoa);

            },

            success: function(data) {

                $('#maisVideosc').html(data);

                $(".loaderMaisVideosc").fadeOut();

                timeProximoa = setTimeout(carregarProximoa, 20000);

            }

        });

    });



    timeProximo = setTimeout(carregarProximoa, 20000);



    $(".prevMaisVideosc").click(function(){

        $(".mvid_player_holderc").animate({

            "scrollLeft": "-=84px"

        }, 'slow');

    });

    $(".nextMaisVideosc").click(function(){

        $(".mvid_player_holderc").animate({

            "scrollLeft": "+=84px"

        }, 'slow');

    });
 function listAnuncio(id){
	 
	ajax('../classificados/listAnuncio.php?id='+id+'&lixo=true','na_wr_cont1');
}

function opere(){
	document.location.reload.href ="xmlcotacoes/operebanco.php";	
}
//setInterval(opere(), 900000);
