function printIt(getSlug){
$('.txt *').removeClass().attr('style','');
    $.post("print.php",{
        title: $('h1').html(),
        content: $('.txt').html(),
        siteName: $('title').text(),
        siteURL: $('base').attr('href').substring(0,$('base').attr('href').length-1),
        slug: getSlug
    },function(html){
        $('body *').css('display','none');
        $('body').css('background','transparent none');
        $('body').append('<div id="print"><!-- --></div>');
        $('#print').css('display','block');
        $('#print').html(html);
    });
}
function bookmarksite(object){
  if(document.all){
    window.external.AddFavorite(object.href , object.title);
    return false;
  }
   return true;
}

var intervalo;

function clicar()
{
	//$('.mod-slideshow-container').cycle('pause');
	//clearinterval(intervalo);
	//intervalo = setTimeout($('.mod-slideshow-container').cycle('resume'), 10000);
}


$(document).ready(function(){
		
							   
    //ie6 png fix
    if(typeof(DD_belatedPNG)!='undefined'){
        try{
            DD_belatedPNG.fixPng($('#cabecalho').get(0));
            DD_belatedPNG.fixPng($('#corpo_aux').get(0));
            DD_belatedPNG.fixPng($('#cabecalho .logo_starsoft img').get(0));
            DD_belatedPNG.fixPng($('#rodape_aux').get(0));
            DD_belatedPNG.fixPng($('#cabecalho .bar_navegacao').get(0));
        }catch(e){
            alert(e);
        }
    }

    $('a[rel=external]').attr('target','_blank');
    if(!jQuery.support.htmlSerialize)
        $('a[rel=sidebar]').click(function(){bookmarksite(this);});
    $('a[rel=suggest]').click(function(){$.showAkModal(this.href,this.title,650,450);return false;});
    $('a[rel=print]').click(function(){printIt(location.pathname);return false;});
    $('.bot_diminuir_texto').click(function(){$.FontSizer.DecreaseSize();return false;});
    $('.bot_aumentar_texto').click(function(){$.FontSizer.IncreaseSize();return false;});
    $('#cabecalho .bar_navegacao > ul.menu > li > ul').parent()
    .hover(
        function(){
            var $this = $(this);
            var $submenu = $this.children('ul');
            var $submenu_selected = $submenu.parent().parent().children('.selected').children('ul');
            var $bar_navegacao_aux = $('#cabecalho .bar_navegacao_aux');
            $this.addClass('hover').css('z-index',10);
            $bar_navegacao_aux.css('display','block');
            if(!$this.is('.selected'))
                if(typeof(DD_belatedPNG)!='undefined'){
                    $submenu.css('display','block');
                    $submenu_selected.css('display','none');
                }
                else{
                    $submenu.stop(true, true).fadeIn('slow');
                    $submenu_selected.stop(true, true).fadeOut('slow');
                }
        },
        function(){
            var $this = $(this);
            $this.removeClass('hover').css('z-index',0);
            var $submenu = $this.children('ul');
            var $submenu_selected = $submenu.parent().parent().children('.selected').children('ul');
            var $bar_navegacao_aux = $('#cabecalho .bar_navegacao_aux');
            if(!$this.is('.selected')){
                if(!$submenu_selected.size())
                    $bar_navegacao_aux.css('display','none');
                if(typeof(DD_belatedPNG)!='undefined'){
                    $submenu.css('display','none');
                    $submenu_selected.css('display','block');

                }
                else{
                    $submenu.stop(true, true).fadeOut('slow');
                    $submenu_selected.stop(true, true).fadeIn('slow');
                }
            }
        }
    ).filter('[class*=selected]').each(function(){
            var $this = $(this);
            var $submenu = $this.children('ul');
            var $bar_navegacao_aux = $('#cabecalho .bar_navegacao_aux');
            $this.css('z-index',9);
            $bar_navegacao_aux.css('display','block');
            $submenu.css('display','block');
    });
    if($('.mod-rondedbox').size())
        $('.mod-rondedbox')
        .prepend('<div class="mod-rondedbox-t"><div class="mod-rondedbox-tl"><!-- --><\/div><div class="mod-rondedbox-tr"><!-- --><\/div></div>')
        .append('<div class="mod-rondedbox-b"><div class="mod-rondedbox-bl"><!-- --><\/div><div class="mod-rondedbox-br"><!-- --><\/div></div>');

    if($('.scroll').size())
        $('.scroll').jScrollPane({showArrows: true, scrollbarWidth: 10, arrowSize: 4});

    if($('.mod-dropdown-anchor').size())
        $('.mod-dropdown-anchor').click(function(){
          var $anchor = $(this);
          var $master =   $anchor.parent().parent();
          var $targets = $master.find('.mod-dropdown-target');
          var $target = $(this).next();
          if($target.size()){
              if($target.is(':visible')){
                $targets.hide('fast');
              }
              else{
                  $targets.hide('fast');
                  $target.show('fast');
              }
          }
        });

    if($('.mod-slideshow-container').size())
        $('.mod-slideshow-container').each(function(){
            var $container = $(this);
            var $slideshow = $container.parent();
            var $pager;
            if($container.children().size()>1){
                $slideshow.append('<div class="mod-slideshow-pager"></div>');
                $pager = $slideshow.children('.mod-slideshow-pager');
            }
            else{
                $pager = null;
            }
            
			if($pager){
            	 $container.cycle({
                    container: $container,
                    fx: 'fade',
                    pager: $pager,
                    activePagerClass: 'active',
                    pagerAnchorBuilder: function(idx, slide) {
                        return '<a href="javascript:;">'+slide.title+'</a>';
                    },
                    timeoutFn: function calculateTimeout(currElement, nextElement, opts, isForward) {
                        var $currentElement = $($container.children('div').get(opts.currSlide));
                        var delay = eval($currentElement.attr('delay'));
                        if(typeof(delay)=='number'){
                            return delay;
                        }
                        return 5000;                        
                    }
                });  
            }
        });
		
		if($('form').size())
        $('form').each(function(){
            var $form= $(this);

            if(!$form.hasClass('.edit')){

                $form.find('input[type=text], textarea')
                .focus(function(){
                   var $entTxt = $(this);
                   if($.trim($entTxt.val()) == this.defaultValue)
                        $entTxt.val('');
                })
                .blur(function(){
                    var $entTxt = $(this);
                    if($.trim($entTxt.val())=='')
                        $entTxt.val(this.defaultValue);
                });
          }
        });

       var searchDecode = decodeURI(window.location.search);
       var cidade;
       if(searchDecode.search(/unidade=(\w|\s)+/)!=-1){
           cidade = searchDecode.split('=')[1];
           $('h1').text($('h1').text()+' - '+cidade);
       }
	   
	           
});