// JavaScript Document
var imageCount = 0;
var sliderCount = 0;
var sliderFirstLoad = true;
var control=0;

if(jQuery.browser.mozilla){
    jQuery(window).load(function(){
        jQuery('.news_content .home_news div').hide();
        jQuery('.rightcolumn h3').css('cursor', 'pointer').click(module_toogle);
        jQuery('.news_content .home_news h3').css('cursor', 'pointer').click(news_toogle);
        //jQuery('#primary_content').load('blog div.blocks', blog);
        jQuery('#slider-wrapper div#slider_inner img').each(function () {
            if($(this)[0].complete){
                sliderCount++;
                if(sliderCount == 3 && sliderFirstLoad == true){
                    sliderFirstLoad = false;
                    jQuery('#slider_inner').nivoSlider({
                        effect:'fold'
                    });
                }
            }
        });
    
    });
}else{
    jQuery(document).ready(function(){
        jQuery('.news_content .home_news div').hide();
        jQuery('.rightcolumn h3').css('cursor', 'pointer').click(module_toogle);
        jQuery('.news_content .home_news h3').css('cursor', 'pointer').click(news_toogle);
        jQuery('#primary_content').load('blog div.blocks', blog);
        jQuery('#slider-wrapper div#slider_inner img').load(function () {
            sliderCount++;
            if(sliderCount == 3 && sliderFirstLoad == true){
                sliderFirstLoad = false;
                jQuery('#slider_inner').nivoSlider({
                    effect:'fold'
                });
            }
            return false;
        });
			
        
    });
}

function blog(){

    jQuery('#primary_content div.blocks div').hide();
    jQuery('div.blocks').css('width', (jQuery('#news_content').width() - 20));

    jQuery('#primary_content div.blocks div:nth-child(1)').show();
    jQuery('#primary_content div.blocks div:nth-child(2)').show();
    jQuery('#primary_content div.blocks div:nth-child(3)').show();
    jQuery('#primary_content div.blocks div:nth-child(4)').show();
    jQuery('#primary_content div.blocks div:nth-child(5)').show();

    jQuery('.blocks div.post-info').hide();
    jQuery('.blocks div.post-content').hide();
    jQuery('.blocks div.post-tags').hide();
	
    var alargado = false;
    var obj;
    jQuery('#primary_content h2.title a').css('cursor', 'pointer').click(function(){
        if(alargado && obj.parent().attr("id") != jQuery(this).parent().parent().children('div.post-content').parent().attr("id")){
            obj.slideUp();
            alargado = false;
        }
        jQuery(this).parent().parent().children('div.post-content').slideToggle();
        obj = jQuery(this).parent().parent().children('div.post-content');
        alargado = !alargado;
        jQuery(this).parent().parent().parent().parent().parent().animate({
            scrollTop:'0px'
        });
        return false;
    });
    return false;
}
function news_toogle(){
    //jQuery(this).closest('div.home_news').find('div:first').slideToggle();
    jQuery(this).parent().children('div').slideToggle();
}
function module_toogle(){
    //jQuery(this).closest('div.module').find('div:first').slideToggle();
    jQuery(this).parent().children('div').slideToggle();
}
function inf_hidde(){
    jQuery(this).find('div:first').hide();
}

function inf_show(){
    jQuery(this).find('div:first').show();
}



