//INI
//*****************************************
$(document).ready(function(){
	//QTIP: Bar
	//*****************************************
	$('#header ul#bar li a,#header input#s').qtip({
		position: {
			corner: {
				target: 'topMiddle',
				tooltip: 'bottomMiddle'
			},
			adjust: {
				x: 0,
				y: -8
			}
		},
		style: {
			fontSize: 14,
			fontWeight: 'bold',
			border: {
				width: 3,
				radius: 5
			},
			tip: {
				corner: 'bottomMiddle',
				size: {
					y: 25
				}
			},
			name: 'cream'
		},
		show: {
			effect: {
				type: 'slide',
				length: 150
			}
		},
		hide: {
			effect: {
				type: 'slide',
				length: 150
			}
		}
	});
	
	//QTIP: Websnapr
	//*****************************************
	var valDomain = document.domain;
	$('#content div.entry a:not([href*='+valDomain+'])').each(function() {
		var content = '<img src="http://images.websnapr.com/?key=q9Df9caGp1ta&url=';
		content += $(this).attr('href');
		content += '" alt="Cargando thumbnail..." height="152" width="202" />';
		$(this).qtip({
			content: content,
			position: {
				adjust: {
					screen: true
				}
			},
			style: {
				width: 222,
				padding: 5,
				fontSize: 11,
				background: '#FFFFFF',
				color: '#333333',
				textAlign: 'center',
				border: {
					width: 3,
					radius: 5,
					color: '#051E33'
				},
				tip: true,
				name: 'dark'
			},
			show: {
				effect: {
					type: 'slide',
					length: 150
				}
			},
			hide: {
				effect: {
					type: 'slide',
					length: 150
				}
			}
		});
	});
	
	//QTIP: Comment!
	//*****************************************
	$('#content div.title a.cm').qtip({
		position: {
			corner: {
				target: 'leftMiddle',
				tooltip: 'rightMiddle'
			}
		},
		style: {
			width: 85,
			fontSize: 10,
			fontFamily: 'Arial',
			fontWeight: 'bold',
			textTransform: 'uppercase',
			background: '#000408',
			color: '#DDF6D0',
			border: {
				width: 3,
				radius: 2,
				color: '#A9DE8F'
			},
			tip: {
				corner: 'rightMiddle',
				size: {
					y: 15
				}
			},
			name: 'dark'
		},
		show: {
			effect: {
				type: 'slide',
				length: 150
			}
		},
		hide: {
			effect: {
				type: 'slide',
				length: 150
			}
		}
	});
	
	//QTIP: Ad spots
	//*****************************************
	$('#sidebar table#ads td a').qtip({
		position: {
			corner: {
				target: 'bottomMiddle',
				tooltip: 'topMiddle'
			}
		},
		style: {
			textAlign: 'center',
			fontSize: 10,
			fontFamily: 'Arial',
			fontWeight: 'bold',
			textTransform: 'uppercase',
			background: '#000408',
			color: '#8FCADE',
			border: {
				width: 3,
				radius: 2,
				color: '#8FCADE'
			},
			tip: {
				corner: 'topMiddle',
				size: {
					y: 3
				}
			},
			name: 'dark'
		},
		show: {
			effect: {
				type: 'slide',
				length: 150
			}
		},
		hide: {
			effect: {
				type: 'slide',
				length: 150
			}
		}
	});
	
	//QTIP: Flickr
	//*****************************************
	$('#flickr_badge_wrapper .flickr_badge_image img').qtip({
		position: {
			corner: {
				target: 'leftMiddle',
				tooltip: 'rightMiddle'
			}
		},
		style: {
			textAlign: 'left',
			fontSize: 12,
			fontFamily: 'Arial',
			textTransform: 'lowercase',
			background: '#000408',
			color: '#8FCADE',
			border: {
				width: 3,
				radius: 2,
				color: '#8FCADE'
			},
			tip: {
				corner: 'rightMiddle',
				size: {
					x: 15
				}
			},
			name: 'dark'
		},
		show: {
			effect: {
				type: 'slide',
				length: 150
			}
		},
		hide: {
			effect: {
				type: 'slide',
				length: 150
			}
		}
	});
	
	//Activate default text on inputs
	//*****************************************
	$(function(){ 
		$('input[title!=""]').hint();
	});
});

//Scroll
//*****************************************
function scroll(id) {
	$('html').animate({scrollTop: $('#' + id).offset().top},1500);
}

//Default text on inputs
//*****************************************
jQuery.fn.hint = function (blurClass) {
	if (!blurClass) { 
		blurClass = 'blur';
	}
	return this.each(function () {
		// get jQuery version of 'this'
		var $input = jQuery(this),
		// capture the rest of the variable to allow for reuse
		title = $input.attr('title'),
		$form = jQuery(this.form),
		$win = jQuery(window);
		function remove() {
			if ($input.val() === title && $input.hasClass(blurClass)) {
				$input.val('').removeClass(blurClass);
			}
		}
		// only apply logic if the element has the attribute
		if (title) {
			// on blur, set value to title attr if text is blank
			$input.blur(function () {
				if (this.value === '') {
					$input.val(title).addClass(blurClass);
				}
			}).focus(remove).blur(); // now change all inputs to title
			// clear the pre-defined text when form is submitted
			$form.submit(remove);
			$win.unload(remove); // handles Firefox's autocomplete
		}
	});
};