
$(document).ready(function() {
		
		
		$('#tabs').tabs();
		
		//Clear Input
		$('input.blog_search').clearType();
		$('input.industry').clearType();
		$('input.location').clearType();
		$('input.salary').clearType();
		$('input.type').clearType();
		$('input.email').clearType();
		$('input.password').clearType();
		
		$('#content .contentLeft ul li').css('color','#EF3E42');
		$('#content .contentLeft ul li').wrapInner('<span />');
				
		//Slider
		var numberOfSlides = $('ul.slides li').length;
		var slidewidth = 950;
		var slideContWidth = numberOfSlides*slidewidth;
		var lessThanViewPort = slideContWidth-slidewidth;
		
		$('#hero .slider ul.slides').css('width',slideContWidth);
		
		setInterval(function() { moveSlider(slidewidth, slideContWidth, lessThanViewPort) } ,12000);
		
		$('div.nav a.left').click(function(){
				
				var leftVal = $('ul.slides').css('margin-left');
				leftVal = parseInt(leftVal);
				leftVal = (leftVal*-1); 
				if (!$("#hero .slider ul.slides").is(':animated')) {
					if (leftVal>0){
						$("#hero .slider ul.slides").animate({
								'margin-left': '+=950'								  
						},1000)	
					}
				}
				return false;
		});
		
		$('div.nav a.right').click(function(){
				
				var leftVal = $('ul.slides').css('margin-left');
				leftVal = parseInt(leftVal);
				leftVal = (leftVal*-1); 
				
				if (!$("#hero .slider ul.slides").is(':animated')) {
					if (leftVal<lessThanViewPort){
						$("#hero .slider ul.slides").animate({
								'margin-left': '-=950'								  
						},1000)	
					}
				}
				return false;
		});
		
});

$(window).load(function() {
      
	  //Column height upgrades
	//	var colLeft = $('.contentLeft').height();
	//	var colRight = $('.contentRight').height();
	//	if(colLeft < colRight){ $('.contentLeft').height(colRight - 49); }
	  
	  $('ul.subnav').each(function() {
			var thiswidth = 0;
			thiswidth = $(this).width();
			//alert(thiswidth);
			var parentwidth = 0;
			parentwidth = $(this).parent('li').width();
			//alert(parentwidth);
			var left = thiswidth-parentwidth;
			//alert(left);
			left = left/2;
			left = left*-1;
			
			$(this).css({'left': left+'px'})
		});
});

function moveSlider(slidewidth, slideContWidth, lessThanViewPort){
			
	var leftVal = $('ul.slides').css('margin-left');
		leftVal = parseInt(leftVal);
		leftVal = (leftVal*-1); 
	
	if (!$("#hero .slider ul.slides").is(':animated')) {
		if (leftVal<lessThanViewPort){
			$("#hero .slider ul.slides").animate({
					'margin-left': '-=950'								  
			},1000)
		}else{
			$("#hero .slider ul.slides").animate({
					'margin-left': '0'								  
			},500)
		}
  }
}


$.fn.clearType = function () {
	var thisVal = $(this).val();
	$(this).focus(function() {
		if($(this).val()==thisVal){
			$(this).val('');
		}
	});
	$(this).blur(function() {
		if($(this).val()==''){
			$(this).val(thisVal);
		}					  
	});
	
};

$.fn.tabs = function () {
			
			
	
			this.contents().find(".textArea").hide(); 
			this.contents().find(".textArea.active").show(); 
			
			this.children("ul.nav").children("li").children("a").click(function() {
				var clicked = $(this);
				var activeTab = clicked.attr("href"); 
				activeTab = activeTab.replace('#', ".")
				
				clicked.parent('li').siblings().children('a').removeClass("active");
				clicked.addClass("active"); 
				
				clicked.parent('li').parent('ul').siblings('.content').find(".textArea").removeClass('active').hide();
				clicked.parent('li').parent('ul').siblings('.content').find(activeTab).addClass('active').show();
				
				return false;
				
			});
		
};
