jQuery(document).ready(function() {
	/*
    if (jQuery('#xo-page #xo-page-topleftblocks .xo-blockcontentborder')){
        jQuery('#xo-page #xo-page-topleftblocks .xo-blockcontentborder').corner("round 8px");
    }
    if (jQuery('#xo-page #xo-page-toprightblocks .xo-blockcontentborder')){
        jQuery('#xo-page #xo-page-toprightblocks .xo-blockcontentborder').corner("round 8px");
    }
    if (jQuery('#cmanager_randonblocks .xo-blockcontentborder')){
        jQuery('#cmanager_randonblocks .xo-blockcontentborder').corner("round 8px");
    }
	*/
	jQuery('.cpicon a').click(function(){
	    printSelection(jQuery(this));
	});
	
	jQuery('a[rel*=lightbox]').lightBox({
	    imageLoading: ICMS_LIBRARIES_URL+'/jquerylightbox/images/lightbox-ico-loading.gif',
		imageBtnClose: ICMS_LIBRARIES_URL+'/jquerylightbox/images/close.gif',
		imageBtnPrev: ICMS_LIBRARIES_URL+'/jquerylightbox/images/prev.gif',
		imageBtnNext: ICMS_LIBRARIES_URL+'/jquerylightbox/images/next.gif',
		imageBlank: ICMS_LIBRARIES_URL+'/jquerylightbox/images/lightbox-blank.gif',
		containerResizeSpeed: 350,
		txtImage: 'Imagem',
		txtOf: 'de'
	});
	
	jQuery('.dica .title a').click(function(){
		var i = jQuery(this).attr('id');
		jQuery('.dica #t'+i).toggle();
		jQuery('.dica #b'+i).toggle();
	    return false;
	});
	
    jQuery(':input').each(function(){
        jQuery(this).val(jQuery.trim(jQuery(this).val()));
    });
    
    if (jQuery('.event')){
        tooltip();
    }

});

function printSelection(node){

  var content=node.html();
  var pwin=window.open('','print_content','width=100,height=100');

  pwin.document.open();
  pwin.document.write('<html><body onload="window.print()">'+content+'</body></html>');
  pwin.document.close();
 
  setTimeout(function(){pwin.close();},1000);
}

this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 5;
		yOffset = 10;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	jQuery('.event').hover(function(e){
		this.t = jQuery(this).find('.descricao').html();
		jQuery(this).find('td').css('background','#E28301'); 
		if (this.t != null){ 
		    jQuery("body").append("<div id='tooltip'>"+ this.t +"</div>");
		    jQuery("#tooltip")
			    .css("top",(e.pageY - xOffset) + "px")
			    .css("left",(e.pageX + yOffset) + "px")
			    .show("fast");
        }
    },
	function(){	
		jQuery("#tooltip").remove();
		jQuery(this).find('td').css('background','transparent');
    });	
	jQuery('.event').mousemove(function(e){
		jQuery("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};
