$(function(){
		
	// Insert icon for the specific widget
	$('#widget-cp-adv-campaigns .cnt h2').before('<img class="widget-icon" src="assets/img/icons/icn-campanii-m.png" alt="Campaniile tale" width="35" height="35" />');
	$('#widget-cp-adv-stats .cnt h2').before('<img class="widget-icon" src="assets/img/icons/icn-statistici-m.png" alt="Statisticile tale" width="35" height="35" />');
	$('#widget-cp-adv-profile .cnt h2').before('<img class="widget-icon" src="assets/img/icons/icn-setari-m.png" alt="Contul tau" width="35" height="35" />');
	
	// IE6 PNG fix
	$('img[src$=.png],.alpha b,.png').ifixpng();
	
	/*
	*	Ferestrele modale pentru Termeni ºi condiþii etc.
	*/
	$('a.bla').click(function(e){
		e.preventDefault();
		e.stopImmediatePropagation();
		var care = $(this).attr('href');
		var idul = care.substr(0,care.length-5);
		
		$.get(care, function(response) {
			$('body').append('<div class="ascuns termeni" id="' + idul + '"><div class="in">' + response + '</div></div>');
			
			$('#' + idul).modal({
				closeHTML: ('<a class="modal_inchide" title="ï¿½nchide (ESC)"></a>'), 
				opacity: 87, 
				overlayCss: {
					opacity		:	.87,
					overflow	:	'hidden', 
					background	:	'url(http://www.statuspimp.ro/assets/img/overlay-mov.png)'
				},
				containerCss: {
					width			:	'950px',
					height			:	'80%', 
					margin			:	'0 auto',
					padding			:	'20px', 
					bakcgroundColor	:	'#ffffff', 
					textAlign		:	'left',
					padding			:	'0', 
					backgroundColor	:	'transparent'
				},
				onClose:function(){
					$.modal.close();
					$('.termeni').remove();
				}
				
			});
			
		});
	});
	
	$(document).keydown(function (e) {
		if( ( e.keyCode == 27 || e.which == 27) ) {
			$.modal.close();
		}
	});
	
	$('#simplemodal-overlay').live('click', function(){
		$('.termeni').remove();
		$.modal.close();
	});/*	gata ferestrele modale */
	
	$('a[rel~=external]').live('click', function(){
		window.open(this.href, '_blank');
		return false;
	});
	
	// Close alert panels
	$('.close-alert-panel').live("click", function(){
		$(this).parent().fadeOut();
		var content = $(this).parent().html();
		if (content.search(/huh@statuspimp.ro/i) != -1)
		{
			createCookie('huh','true','1');
		}
	});
	
	/*
	 *
	 *	The Tooltip
	 *
	 */
	$('.microtip').each(function(){
		xOffset = -25;
		yOffset = -20;		

		this.t = $(this).attr('title');
		
		$(this).hover(function(e){
			
			// afiseaza tooltip numai daca title difera de text
			if ( $(this).text() == $(this).attr('title') ) {
				this.title= '';
				return;
			}// 
			
			this.title = '';
			$('body').append(
				'<p id="tip">'
					+ '<span class="tip_c">'
						+ '<b class="tip_s"></b>'
						+ '<b class="tip_m">' + this.t + '</b>'
						+ '<b class="tip_j"></b>'
					+ '</span>'
				+ '</p>'
			);
			$('#tip')
				.css("top",(e.pageY - yOffset) + "px")
				.css("left",(e.pageX + xOffset) + "px")
				.fadeIn("fast");		
		},
		function(){
			this.title = this.t;		
			$("#tip").remove();
		});	
		$(this).mousemove(function(e){
			$("#tip")
				.css("top",(e.pageY - yOffset) + "px")
				.css("left",(e.pageX + xOffset) + "px");
		});
	});
	

});