$(function(){
		
		// hide interactive items by default
		$(".slide").hide();
	
		// these tabs are extended for cross-fading with jQuery Tools Tabs
		$(".tabs-nav").tabs(".slide", { 
				effect: 'fade', 
				fadeInSpeed: 1600,
				fadeOutSpeed: 1600,
				rotate: true
		}).slideshow({ 
				autoplay:true,
				interval:8000,
				clickable: false
		});
		
		$(".tabs-nav a").click(function() { 
				$(".tabs-nav").tabs().pause();																																																			
		});
		
		// pseudeo shadows
		$(".h-title").each(function() {
				var div = $(document.createElement('div')).attr({ 'class' : "h-shadow" }).html( $(this).html() );
				$(div).insertBefore(this);
		});
	
		// disable form submit for Ajax
		$("#corpLogin .go").bind("click", function() {
				if( $("#companyCode").val() == "" ) {
					alert('Please enter a company code');
					return false;
				}
				$("#corpLogin").submit();
				return false;
			});
		
		// Ajax routine for corp login
		$("#corpLogin").submit(function() {
				var xhrURL = $("#corpLogin").attr("action");
				var urlValue = $('#companyCode').val();
				var validURL = 1; // Ajax returns 1 if bad URL
				
				$.get(xhrURL, { url:urlValue }, function(data) {
								validURL = data;
								if (validURL == 0) { 
										window.location = 'https://' + urlValue + '.reardencommerce.com';
								} else {
										alert('The company code you entered appears to be invalid.');
								}
						});
				
						return false;
			});
		
		$("#companyCode").bind("focus", function() {
				$(this).val("");																																							
		});
});
