(function($){
	$.fn.extend({
		center: function () {
			return this.each(function() {
				var top = ($(window).height() - $(this).outerHeight()) / 2;
				var left = ($(window).width() - $(this).outerWidth()) / 2;
				$(this).css({position:'absolute', margin:0, top: (top > 0 ? top : 0)+'px', left: (left > 0 ? left : 0)+'px'});
			});
		}
	}); 
})(jQuery);
jQuery(function(){
	/* Navigation Add Specific Classes */
	$('ul#menu-primary li a').addClass('menu-primary').each(function(index, element){$(element).attr("id", "menu-primary" + (index + 1) );});
	/* Search Form Toggle */  
	swapValue = [];
	$(':text').each(function(i){
		swapValue[i] = $(this).val();
		$(this).focus(function(){
			if ($(this).val() == swapValue[i]) {
				$(this).val("");
			} $(this).addClass("focus");
		}).blur(function(){
			if ($.trim($(this).val()) == "") {
				$(this).val(swapValue[i]);
				$(this).removeClass("focus");
				}
			});
		});
	
	$(".tabContent").hide(); //Hide all content
	$("#tabs a:first").addClass("selected"); //Activate first tab
	$(".tabContent:first").show(); //Show first tab content

	// On Click Event
	$("#tabs a").click(function() {
		$("#tabs a").removeClass("selected"); //Remove any "selected" class
		$(this).addClass("selected"); //Add "selected" class to selected tab
		$(".tabContent").hide(); //Hide all tab content

		var activeTab = $(this).attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});
	/* Category List Add Class to List Items */
	$('li.cat-item a').prepend('<span class="icon"><!-- --></span>');
	$('li.cat-item a').each(function() {$(this).parent().addClass($(this).text());});
	
	/* Carousel */
	$(".carousel").jCarouselLite({
		btnNext: ".next",
		btnPrev: ".prev"
	});
	
	$(":text").each(function (type) {
		$(this).focus(function () {
			$(this).next("label.inlined").addClass("focus");
		});
		$(this).keypress(function () {
			$(this).next("label.inlined").addClass("has-text").removeClass("focus");
		});
		$(this).blur(function () {
			if($(this).val() == "") {
				$(this).next("label.inlined").removeClass("has-text").removeClass("focus");
			}
		});
	});
	
	$('label').addClass('inlined');
	
	$('#slider1').anythingSlider({
				autoPlay            : false,      // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
				startStopped    : false, // If autoPlay is on, this can force it to start stopped
				width           : 617,  // Override the default CSS width
				startPanel          : 1,         // This sets the initial panel
				hashTags            : true,      // Should links change the hashtag in the URL?
				buildNavigation     : false      // If true, builds a list of anchor links 
				
			});
	 $("div.team-pic a").click(function(){
		 var currentId = $(this).attr('rel');
		  $('#slider1').anythingSlider(currentId);
		  return false;
		});

	$("#overlay").css({
		'opacity': 0.5
	});
	$('div.team-pic a').click(function () {
		$("#overlay").fadeIn("fast", function () {
			$("#sliderWrapper").fadeIn("slow");
			return false;
		});
	});
	$("#closeThis").click(function () {
    		$("#sliderWrapper").fadeOut("slow", function () {
    			$("#overlay").fadeOut("fast");
				return false;
  			});
		});
	$('#sliderWrapper').center();
	$('#sliderWrapper').hide();
	$("td.jobs-applynow a").addClass("big-link");
});
