function centerFirstElement(){
	
	$("#logo_slider>div:nth-child(4) img").css('top', (70-$("#logo_slider>div:nth-child(4) img").height())/2)
				
				$("#logo_slider>div:nth-child(4) img").css('left', (200-$("#logo_slider>div:nth-child(4) img").width())/2)	
	
}



function sendContactMessage(){
	
	if( $('#contact_name').attr('defaultValue') != $('#contact_name').val() ){
		var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
		if( emailPattern.test($('#contact_email').val()) ){
			
			if( $('#contact_message').val() != "" ){
				$.ajax({
				  type: 'POST',
				  url: '/functions/contact_us.php',
				  data: $("#contact_us").serialize(),
				  success: function(msg){
					  
				  }
				});
				
				$('#contact_form_disp').hide();
				$('#contact_thanks').fadeIn();
				
				
			}else{
				alert("Please enter a message.");
			}
			
		}else{
			alert("Please enter a valid email address.");
		}
		
	}else{
		alert("Please enter your name.");
	}
	
}

$(document).ready(function(){
		setTimeout('doHashAction();', 10);
		
	$("#logo_slider>div:nth-child(4)").show();
					
						timer = setInterval("centerFirstElement()", 3);
		
						timer = setInterval("slideshowAnimate()", 5000);
						
						
					
						
						
						
						
		setDefaultTextInputValues();
		$(".tabs td").click(function(){
						  	$(".tab_content_container div").hide();
						   	$(".tab_content_container div:nth-child("+($(this).index()*1+1)+")").show();
						   
						   	$(".tabs td").removeClass('active');
						  	$(this).addClass('active');
						   });
		
						   
});

function slideshowAnimate( index ){

	if( index != null ){
		index = index;
	}else{
		 index = $("#logo_slider>div:visible").index()*1 + 1;
	}
	
	
	 
	
	$("#logo_slider>div:nth-child("+(index*1)+")").fadeOut('slow', function(){

		if( $("#logo_slider>div:nth-child("+(index*1+1)+")").length != 0 ){
			
		
			
			$("#logo_slider>div:nth-child("+(index*1+1)+")").fadeIn('slow');	
				
		}else{
			$("#logo_slider>div:nth-child(3)").fadeIn('slow');
		}
		
		$("#logo_slider>div:nth-child("+(index*1+1)+") img").css('top', (70-$("#logo_slider>div:nth-child("+(index*1+1)+") img").height())/2)
				
				$("#logo_slider>div:nth-child("+(index*1+1)+") img").css('left', (200-$("#logo_slider>div:nth-child("+(index*1+1)+") img").width())/2)
														  
														  });	
}



function doHashAction(){

  var hash = window.location.hash;
  if(hash.substring(1) == 'career_tools'){
	  $(".tabs td:nth-child(2)").click();
  }
}


function setDefaultTextInputValues(){
	var allInputs = $("input[value='']");
	for(i=0; i<allInputs.length; i++){

		if($(allInputs[i]).attr("defaultvalue")){
		
			if( $(allInputs[i]).attr('type') == 'number' ){
				$(allInputs[i]).attr('type', 'text');
			}
			
			$(allInputs[i]).val($(allInputs[i]).attr("defaultvalue"));
			$(allInputs[i]).css("color", "#CCC");
			
			$(allInputs[i]).blur(function(){
										  if($(this).val() == "" && $(this).attr("defaultvalue")){
												$(this).val($(this).attr("defaultvalue"));
												$(this).css('color', '#CCC');
											}
										  
										  });
			
			$(allInputs[i]).focus(function(){
										 if($(this).val() ==  $(this).attr("defaultvalue")){
												$(this).val('');
											}
											$(this).css('color', 'black');
										  
										  });
			
		}
	}
}
