function loadContent(id,querystr){

    if (querystr != undefined)
        querystr = querystr
    else
        querystr = null;

	$('#wrapper').load(id + '?c=' + (new Date() * 1),{fundo: querystr}, function(data){
		switch(id){
			case "empresa":
			case "investir":
				// Collapse
				$('.flit-link').click(function(){
					$(this).next().slideToggle();
					_src = $('img', this).attr('src');
					_src = (/_on/.test(_src)) ? _src.replace('_on', '_off') : _src.replace('_off', '_on');
					$('img', this).attr('src', _src);

					$('.flit-link').not(this).each(function(){
						$(this).next().slideUp();
						$('img', this).attr('src', $('img', this).attr('src').replace('_on', '_off'));
					});
				});
				// FancyBox
				$(document).ready(function() {
					$("a#single_image").fancybox({
						'zoomSpeedIn': 300, 'zoomSpeedOut': 300,
						'overlayShow': true,
						'frameWidth': 560,
						'frameHeight': 255,
						'hideOnContentClick': false,
						'overlayOpacity': 0.60
					});
				});
				break;

			case "fundos":
                        case "main":

				// Collapse
                                if (querystr == undefined) {
                                    animatedcollapse.addDiv('radar', 'fade=0,speed=250,group=pets,hide=1')
                                    animatedcollapse.addDiv('podium', 'fade=0,speed=250,group=pets,persist=1,hide=1');
                                    animatedcollapse.addDiv('bravo', 'fade=0,speed=250,group=pets,hide=1');
                                    animatedcollapse.addDiv('exc', 'fade=0,speed=250,group=pets,hide=1');
                                    animatedcollapse.addDiv('fip', 'fade=0,speed=250,group=pets,hide=1');
                                    animatedcollapse.ontoggle=function($, divobj, state){ }
                                    animatedcollapse.init();

                                    $('.togglediv').each(function(){
                                      $(this).css('display','none');
                                      src = $(this).prev().find('img').attr('src');
                                      $(this).prev().find('img').attr('src', src.replace('_on', '_off'));
                                    });
                                  } else {
                                    switch(querystr){
                                        case 'Podium FIA':$('div#podium').css('display','block');
                                            $('a.podium img').attr('src','/images/sub_tit_personale_podium_on.gif');
                                        break;
                                        case 'Radar FIA':$('div#radar').css('display','block');
                                            $('a.radar img').attr('src','/images/sub_tit_personale_radar_on.gif');
                                        break;
                                        case 'Bravo FIM':$('div#bravo').css('display','block');
                                            $('a.bravo img').attr('src','/images/sub_tit_personale_bravo_on.gif');
                                        break;
                                    }
                                    $('a.radar').click(function(){
                                        $('a.radar img').attr('src','/images/sub_tit_personale_radar_off.gif');
                                        $('a.podium img').attr('src','/images/sub_tit_personale_podium_off.gif');
                                        $('a.bravo img').attr('src','/images/sub_tit_personale_bravo_off.gif');
                                        $('a.exc img').attr('src','/images/sub_tit_personale_exc_off.gif');
                                        $('a.fip img').attr('src','/images/sub_tit_personale_tech_off.gif');
                                        $('.togglediv').slideUp('250');
                                        if ($('div#radar').css('display') == 'none') {
                                            $('a.radar img').attr('src','/images/sub_tit_personale_radar_on.gif');
                                            $('div#radar').slideDown('250');
                                        } else {
                                            $('a.radar img').attr('src','/images/sub_tit_personale_radar_off.gif');
                                            $('div#radar').slideUp('250');
                                        }
                                    });
                                    $('a.podium').click(function(){
                                        $('a.radar img').attr('src','/images/sub_tit_personale_radar_off.gif');
                                        $('a.podium img').attr('src','/images/sub_tit_personale_podium_off.gif');
                                        $('a.bravo img').attr('src','/images/sub_tit_personale_bravo_off.gif');
                                        $('a.exc img').attr('src','/images/sub_tit_personale_exc_off.gif');
                                        $('a.fip img').attr('src','/images/sub_tit_personale_tech_off.gif');
                                        $('.togglediv').slideUp('250');
                                        if ($('div#podium').css('display') == 'none') {
                                            $('a.podium img').attr('src','/images/sub_tit_personale_podium_on.gif');
                                            $('div#podium').slideDown('250');
                                        } else {
                                            $('a.podium img').attr('src','/images/sub_tit_personale_podium_off.gif');
                                            $('div#podium').slideUp('250');
                                        }
                                    });
                                    $('a.bravo').click(function(){
                                        $('a.radar img').attr('src','/images/sub_tit_personale_radar_off.gif');
                                        $('a.podium img').attr('src','/images/sub_tit_personale_podium_off.gif');
                                        $('a.bravo img').attr('src','/images/sub_tit_personale_bravo_off.gif');
                                        $('a.exc img').attr('src','/images/sub_tit_personale_exc_off.gif');
                                        $('a.fip img').attr('src','/images/sub_tit_personale_tech_off.gif');
                                        $('.togglediv').slideUp('250');
                                        if ($('div#bravo').css('display') == 'none') {
                                            $('a.bravo img').attr('src','/images/sub_tit_personale_bravo_on.gif');
                                            $('div#bravo').slideDown('250');
                                        } else {
                                            $('a.bravo img').attr('src','/images/sub_tit_personale_bravo_off.gif');
                                            $('div#bravo').slideUp('250');
                                        }
                                    });
                                    $('a.exc').click(function(){
                                        $('a.radar img').attr('src','/images/sub_tit_personale_radar_off.gif');
                                        $('a.podium img').attr('src','/images/sub_tit_personale_podium_off.gif');
                                        $('a.bravo img').attr('src','/images/sub_tit_personale_bravo_off.gif');
                                        $('a.exc img').attr('src','/images/sub_tit_personale_exc_off.gif');
                                        $('a.fip img').attr('src','/images/sub_tit_personale_tech_off.gif');
                                        $('.togglediv').slideUp('250');
                                        if ($('div#exc').css('display') == 'none') {
                                            $('a.exc img').attr('src','/images/sub_tit_personale_exc_on.gif');
                                            $('div#exc').slideDown('250');
                                        } else {
                                            $('a.exc img').attr('src','/images/sub_tit_personale_exc_off.gif');
                                            $('div#exc').slideUp('250');
                                        }
                                    });
                                    $('a.fip').click(function(){
                                        $('a.radar img').attr('src','/images/sub_tit_personale_radar_off.gif');
                                        $('a.podium img').attr('src','/images/sub_tit_personale_podium_off.gif');
                                        $('a.bravo img').attr('src','/images/sub_tit_personale_bravo_off.gif');
                                        $('a.exc img').attr('src','/images/sub_tit_personale_exc_off.gif');
                                        $('a.fip img').attr('src','/images/sub_tit_personale_tech_off.gif');
                                        $('.togglediv').slideUp('250');
                                        if ($('div#fip').css('display') == 'none') {
                                            $('a.fip img').attr('src','/images/sub_tit_personale_tech_on.gif');
                                            $('div#fip').slideDown('250');
                                        } else {
                                            $('a.fip img').attr('src','/images/sub_tit_personale_tech_off.gif');
                                            $('div#fip').slideUp('250');
                                        }
                                    });
                                 }

				// FancyBox
				$("a.box").fancybox({
					'zoomSpeedIn': 300, 'zoomSpeedOut': 300,
					'overlayShow': true,
					'frameWidth': 822,
					'frameHeight': 500,
					'hideOnContentClick': false,
					'overlayOpacity': 0.60
				});


				break;

			case "contato":
				// Form validate
				var validate = $("#commentForm").validate();


                                //ajax
                                $forms = $('form');
                                $forms.bind('submit', function(){
                                    var $button = $('button',this).attr('disabled',true);
                                    var params = $(this.elements).serialize();
                                    var self = this;

                                    erro = validate.errorList.length > 0 ? true : false;


                                    $.ajax({
                                        type: 'POST',
                                        url: this.action,
                                        data: params,
                                        beforeSend: function(){
                                            $('#loading').show();
                                           $('#loading').html("<img src='/images/loading.gif'>");
                                        },
                                        success: function(txt){
                                            $button.attr('disabled',false);
                                            $('#loading').html(txt);
                                            self.reset();
                                        },
                                        error: function(txt){
                                            $('#loading').html(txt);
                                        }
                                    });
                                    return false;




                                });


                                break;
                                default:
                                    $('div img.especial').hide();
                                    $('div#popup').show('slow', function(){
                                        $('div img.especial').show();
                                    });

                                    $('div#popup img').click(function(){
                                        $('div img.especial').hide();
                                        $('div#popup').hide('slow');
                                     setTimeout(function(){$('div#popup').hide('slow'); }, 16000);
                                    });

                                    $('.fancyCadastro').fancybox({
						'zoomSpeedIn': 300, 'zoomSpeedOut': 300,
						'overlayShow': true,
						'frameWidth': 475,
						'frameHeight': 380,
						'hideOnContentClick': false,
						'overlayOpacity': 0.60
					});
                                        

                                        
                                break;

		}
	});
}
