
$(window).load(function(){

	var now = new Date();
	now.setDate(now.getDate()-1)
	$('input#search_date').DatePicker({
		/*flat: true,*/
		date: ['05-09-2010', '05-09-2010'],
		current: '05-09-2010',
		format: 'd-m-Y',
		calendars: 1,
		mode: 'range',
		onRender: function(date) {
			return {
				disabled: (date.valueOf() < now.valueOf())
			}
		},
		onChange: function(formated, dates) {
			$('input#search_date').val(formated.join(' a '));
		},
		starts: 1
	});
    
    $('input#search_date_mediareport').DatePicker({
		/*flat: true,*/
		date: ['05-09-2010', '05-09-2010'],
		current: '05-09-2010',
		format: 'd-m-Y',
		calendars: 1,
		mode: 'range',
		onRender: function(date) {
			return {
				disabled: (date.valueOf() > now.valueOf())
			}
		},
		onChange: function(formated, dates) {
			$('input#search_date_mediareport').val(formated.join(' a '));
		},
		starts: 1
	});
    
    $("a[rel^='gallery']").prettyPhoto({
		animationSpeed: 'normal', /* fast/slow/normal */
		padding: 40, /* padding for each side of the picture */
		opacity: 0.8, /* Value betwee 0 and 1 */
		showTitle: true, /* true/false */
		allowresize: true, /* true/false */
		counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
		theme: 'dark_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
		callback: function(){}
	});
    
    var is_agenda_favorites = false;
		//div.astar_ 
		$('div.starAgenda a.favorites').live('click',function() {
			if(!is_agenda_favorites)
			{
				is_agenda_favorites = true;
				var clubid = $(this).find("span.star").attr("id").substr(1);
                var $_this = $(this);
				$.ajax({
					type: "POST",
					dataType: "html",
					url: "/ajax/action/gallery-widget",
					data: 'action=favorites&club_id='+clubid,
					success: function(data)
					{
						$_this.parent().next('div.favorites-temp').html(data);
						var star = $_this.parent().next('div.favorites-temp').find("a.favorites");
						$_this.parent().next('div.favorites-temp').find("a.favorites").remove();
						var msg = $_this.parent().next('div.favorites-temp').html();
						$('div.astar_'+clubid).html(star);
						$.pnotify(msg);
						$_this.parent().next('div.favorites-temp').html("");
						is_agenda_favorites = false;
                        initTooltips();
					}
				});
				return false;
			}
        });
    
    
//$.prettyPhoto.open('/popup.html?iframe=true&width=800&height=600','','Publicidade');
//$.prettyPhoto.open('http://www.youtube.com/watch?v=FJku5nxMOuY','','Publicidade');
//$.prettyPhoto.open('/uploads/flyers/VIANA-sounds-good-338x500.jpg','','Publicidade');

	
});