$(function() {
	// external links
	$("a[rel=external]").attr("target", "_blank");
	
	// links to other sites
	var host = document.location.protocol + "//" + document.location.host;
	$("a[href^=http]").each(function() {
		if (this.href.indexOf(host) !== 0) {
			$(this).attr("target", "_blank");
		};
	});
	// PDFs 
	$("a[href$=\".pdf\"]").attr("target", "_blank");
	
	$('a.lightbox').colorbox({
		opacity: 0.3
	});
	$('.more_info_top a').each(function() {
		if (this.host.indexOf('youtube.com') !== -1) {
			var youtubeId = this.href.substring(this.href.lastIndexOf('/') + 1);
			$(this).attr('href', 'http://www.youtube.com/embed/' + youtubeId).colorbox({
				iframe: true,
				opacity: 0.3,
				innerWidth: 640,
				innerHeight: 390
			});
		}
	});
	
	
	$("input[type=text][title]").each(function() {
		$(this).data("placeholder", this.title).bind("focus", function() {
			if (this.value == $(this).data("placeholder")) {
				this.value = "";
			}
			$(this).removeClass("default");
		}).bind("blur", function() {
			if (this.value == "" || this.value == $(this).data("placeholder")) {
				this.value = $(this).data("placeholder");
				$(this).addClass("default");
			};
		}).attr("title", "").trigger("blur");
	});
	$("input").each(function() {
		$(this).addClass('input_' + $(this).attr("type"));
	});
	
});


