$(document).ready(function() {

        //$('.elipsis .lnk-leia-mais')


    	//add class ao p
	$('.km-post-all p').each(function(){
		var css = $(this).attr('class');
		if(css == '' || css == null){
			$(this).addClass('txt-post');
		}
	});
        //apaga classe do p
	$('.ct-avatar li p').removeClass('txt-post');
                     
	//adiciona target
	$('.txt-post a').each(function(){
		$(this).attr('target', '_blank');
	});

        $('.gallery .gallery-item a').each(function(){
		$(this).attr('target', '_blank');
	});

	$('#alt-login-methods .txt-post a').removeAttr('target');

        $('.km-post-slide-resumo .lnk-leia-mais').remove();
        $('.km-post-slide-resumo .lnk-leia-mais').remove();
        $('.elipsis').ellipsis();

         /* serve somente para o I.E.  que nao aceita :only-child */
        if ($.browser.msie) {
            $('.km-post-all .km-post-conteudo p:first-child img').each(function(idx, e) {
                 if ($(e).is('img:first-child')) {
                     $(e).addClass('acertaPrimeiraImagemPost');
                 }
            });
        }
        
        
        /* acerta primeira imagem do paparazzi qdo ela tem 600px de largura!! */
        $('.km-posts.paparazzi .km-post-all .km-post-conteudo p:first-child img').each(function(idx, e) {
             if ($(e).is('img:first-child')) {
            	 
            	 $(e).removeClass('acertaPrimeiraImagemPost');
            	 
            	 var img = new Image();
            	 $(img).load( function() {
            			 		if (this.width == 600)
            			 			$(e).addClass('acertaPrimeiraImagemPostPaparazzi');
            	 		   }
            	 ).attr('src', $(e).attr('src'));
            	 
             }
        });
        
        
        function getXbackgroundPosition(obj) {
            if ($(obj).css('background-position-x')) {
            	return parseInt($(obj).css('background-position-x').split(' ')[0]);
            } else {
            	return parseInt($(obj).css('background-position').split(' ')[0]);
            };        	
        }

        $('#ct-mn ul li a')
                /*.css( {backgroundPosition: "0 0"} )*/
                .mouseover(function(){
                       if ($(this).hasClass('ativo'))
                           return;
                       if ($(this).hasClass('en') || $(this).hasClass('es') || $(this).hasClass('mn-idioma-sep'))
                           return;
                       
                       horizontalPosition = getXbackgroundPosition(this);
                                                
                        $(this).stop().animate(
                                {backgroundPosition:"("  + horizontalPosition + " -22px)"},
                                {duration:500})
                        })
                        
                .mouseout(function(){
                        if ($(this).hasClass('ativo'))
                           return;
                       if ($(this).hasClass('en') || $(this).hasClass('es'))
                           return;
                        //horizontalPosition = $(this).css('backgroundPosition').split(' ')[0];
                       horizontalPosition = getXbackgroundPosition(this);
                        $(this).stop().animate(
                                {backgroundPosition:"("  + horizontalPosition + " 0)"},
                                {duration:500})
                        });

	//translate
	$('.mn-idioma a').click(function(){
		var css = $(this).attr('class');
		$('body').translate(css);
	});

whenReizeWindows();

$(window).resize(function() {
   whenReizeWindows();
});

        /************ abaixo, herdado do kyliebr ********/


	//identifica a página atual
	if(pag == "index"){
		e = $('#ct-mn ul li .home');
	}else if(pag == "noticias"){
		e = $('#ct-mn ul li .noticias');
	}else if(pag == "seacrch"){
		e = $('#ct-mn ul li .noticias');
        }else if(pag == "galeria"){
		e = $('#ct-mn ul li .galeria');        
	}
        $(e).addClass('ativo');
        if ($(e).css('backgroundPosition') != null) {
            horizontalPosition = $(e).css('backgroundPosition').split(' ')[0];
            $(e).css('backgroundPosition', horizontalPosition + ' -22px');
        }

        //remove tag
	$('.ct-sb-foto #ttc-coppermine-badge h3').remove();
	$('.ct-sb-foto #ttc-coppermine-badge br').remove();

        //deleta html
	$('body').each(function(){
		$('#stc_comm_send').remove();
	});

        $('.ct-avatar li h6 .url').attr('target', '_blank');

    }
);

function whenReizeWindows() {
   if ($("body").height() < $(window).height()) 
      $('#ct-ft').attr("style","position: absolute; bottom: 0px");
   else
      $('#ct-ft').attr("style","");
}
