
$(document).ready( function() {
	$(".close").click( function() { $("#facebox").fadeOut('slow'); } );
	var inter = setTimeout(function() { $("#facebox").fadeOut('slow'); clearInterval(inter); } , 5000);

	
	$.fn.qtip.styles.futbolowo = { // Last part is the name of the style
			      width: 200,
			      padding: 10,
			      background: '#e6ffb0',
			      color: '#3c5800',
			      textAlign: 'left',
			      border: {
			         width: 1,
			         radius: 2,
			         color: '#3c5800'
			      },
			      
			      name: 'dark' // Inherit the rest of the attributes from the preset dark style
			};
			
	$.fn.qtip.styles.error = { // Last part is the name of the style
				  width: 200,
				  padding: 10,
				  background: '#facdcd',
				  color: 'red',
				  textAlign: 'left',
				  border: {
					 width: 1,
					 radius: 2,
					 color: 'red'
				  },

				  name: 'dark' // Inherit the rest of the attributes from the preset dark style
			};
	
	$('.target').each(function() {
		$(this).qtip({
			content: {
			text: '<img class="throbber" src="/projects/qtip/images/throbber.gif" alt="Loading..." />',
			url: '/campaigns/show-target/id/'+$(this).attr('rel') // Use the rel attribute of each element for the url to load
			/*
			title: {
				text: $(this).attr('title') // Give the tooltip a title using each elements text
			}
			*/
		}, 
		style: 'futbolowo',
		position: {
		      corner: {
		         target: 'rightBottom',
		         tooltip: 'bottomLeft'
		      }
		   }
		});
	});
	
	
		$('.targetType').qtip({
			content: {
			text: 'ładuje...',
			url: '/campaigns/show-session-target',
			data: '',
			method: 'get'
		}, 
		style: 'futbolowo',
		position: {
		      corner: {
		         target: 'leftTop',
		         tooltip: 'bottomLeft'
		      }
		   },
		   api: {
			   beforeShow: function (event)
			   {
			   url = this.options.content.url;
			   data = this.options.content.data;
			   method = this.options.content.method || 'get';
			   this.loadContent(url, data, method);
			   }
			   }
		   
		});
	
	
	$('.help').each(function() {
		$(this).qtip({
			style: 'futbolowo',
			position: {
		      corner: {
		         target: 'rightTop',
		         tooltip: 'leftTop'
		      }
		   }
		});
	});
	
	$('.error').each(function() {
		$(this).qtip({
			style: 'error',
			position: {
			  corner: {
				 target: 'rightTop',
				 tooltip: 'leftTop'
			  }
		   }
		});
	});
	
}) ;









// Create your tooltips 
//$('.help').simpletip({ content: 'ładuję..'}); 

/*
$('.help').each(function(i,e){
	var api = $('.help').eq(i).simpletip(); 
	text  = api.getParent().attr("title");
	api.update(text);
});
$('.help').removeAttr("title");
*/
//$('.target').simpletip({ content: 'ładuję..'});
/*
$('.target').each(function(i,e){
	$(this).simpletip({
		onShow: function() {
			content : $(this).attr('title');
		}
          
    });
	/*
	
	var api = $('.target').eq(i).simpletip(); 
	tid = api.getParent().attr("title");
	api.load("/campaigns/show-target/id/"+tid);
	*/
/*
});
$('.target').removeAttr("title");

$('.help').each(function() {
    $(this).simpletip({
        content : $(this).attr('title')
    });
});
*/

/*
$(".target").each()simpletip().simpletip({
	onShow: function() {
		text = this.attr('title');
		alert(text);
	//	this.update(text+"edrgthy");
	},
	content: '<strong>ładuję...</strong><br/><br/>a to jakiś super tekst ;)'

});
*/
