(function( $ ) {
	$.fn.inlineLabel = function () {		
		$(this).each(function() {
			
			$(this).data("orig_type",$(this).attr("type"))
			if ($(this).attr("type") == 'password') {			
				$(this)[0].type = "text";
			}			
			if ($(this).val() == "") {
				$(this).val($(this).attr("title"));
				$(this).addClass("default-text");
			}
			else {
				$(this).removeClass("default-text");
			}

			$(this).focus(function() {			
				if ($(this).val() == $(this).attr("title")) {
					$(this).removeClass("default-text");
					$(this).val("");
					if ($(this).data("orig_type") == 'password') {
						$(this)[0].type = 'password';
					}
				}
			}).blur(function() {
				if ($(this).val() == "") {
					$(this).addClass("default-text");
					$(this).val($(this).attr("title"));
					if ($(this).data("orig_type") == 'password') {
						$(this)[0].type = 'text';
					}
				}
			}).blur();	
		})
	}
})( jQuery )


// JavaScript Document

showTabList = function(tabId) {
	$('ul.tabs li').removeClass('active');
	$('li#' + tabId + '-tab').addClass('active');
	
	$('ul.active-tablist').removeClass('active-tablist');
	$('ul.' + tabId + '-tablist').addClass('active-tablist');
}

//$(document).ready(function() {
jQuery(function() {
	
	$("ul.sf-menu").superfish({ 
		delay: 800,
		speed: 'fast',
		pathClass: 'active'
	});
	$('a.secondary').each(function(i, el){
		$(el).parent().addClass('secondary');
	});
	
	$(".field-value").inlineLabel();
	
	/*$(".field-value").focus(function() {
		if ($(this).val() == $(this)[0].title) {
			$(this).removeClass("default-text");
			$(this).val("");
		}
	}).blur(function() {
		if ($(this).val() == "") {
			$(this).addClass("default-text");
			$(this).val($(this)[0].title);
		}
	}).blur(); */
	
	//searchAutocomplete();
	
	//make tweets links open in a popup
	$("span.tweetlinks a").click(function() {
		var $this = jQuery(this);
		var left = (jQuery(window).width()/2) - 250;
		var top = (jQuery(window).height()/2) - 165;		
		window.open($this.attr("href"), $this.text(), "status=0,toolbar=0,location=0,menubar=0,height=330,width=500,left="+left+",top="+top);
		return false;
	});
});

// break out of frame
if (top.location!= self.location) {
	if (self.location.href.indexOf('loading') < 0) {
		top.location = self.location.href
	}
}


function searchAutocomplete() {
	//make search form autocomplete
	jQuery("#location").autocomplete({		
		source: BASE_URL+"/jobboard/job/search-autocomplete?format=json",//+"&XDEBUG_PROFILE=1",		
		minLength: 2,
		dataType: "json"		
	});
}
