// JavaScript Document
function HideContent(){
	$('#right-pane').removeClass('border');
	$('#left-pane').removeClass('inner');
	$('#left-pane').addClass('home');			
}
function HideAnimation(){
	$('#right-pane').addClass('border');
	$('#left-pane').removeClass('home');
	$('#left-pane').addClass('inner');
	$('#animation').hide();
}

function showMenu(){
	$(this).children('ul').show('slide', {'direction':'up'}, 500);
};
function hideMenu(){
	$(this).children('ul').hide('slide', {'direction':'up'}, 200);
};

$(document).ready(function() {
$("#content").hide();
    $('#animation').cycle({
		fx: 'scrollRight,growX,scrollLeft', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		speed: 1000,
		timeout:  5000,
		easing:  'easeOutCirc',
		delay : -5000
	});
	
	var count = 0;
	var effects = new Array('slide','fold','drop', 'blind');

	//Inner Pages Animation	
	$('#navigation a, #footer a, ul.sitemap a').live('click',function(){
		page_url = $(this).attr('href');
		if(count >= effects.length){
			count = 0;
		}
		if(page_url == '/'){
			HideContent(); // hides unwanted content and styles from home page
			$('#global-movers-members').hide();
			$("#content").html("").hide();
			$('#form-wrapper.index').hide(); //need to hide contact form
			$('#animation').show(); // show animation on home page
		} else if(page_url == 'contact'){
			HideAnimation(); // hides animation	and unwanted styles from inner pages
			$('#global-movers-members').hide();
			$("#content").html("").hide();
			$('#form-wrapper.index').show(effects[count],800); //need to show content form
		} else if(page_url == 'global-movers-members'){
			HideAnimation(); // hides animation	and unwanted styles from inner pages
			$('#form-wrapper.index').hide(); //need to hide contact form
			$("#content").html("").hide();
			$('#global-movers-members').hide().show(effects[count],800);
		} else {
			$.ajax({
				type: "POST",
				url: "ajax/page-content.php",
				data: "url="+page_url+"&timestamp="+Math.random(),
				dataType:"html",
				success: function(response){
						HideAnimation(); // hides animation	and unwanted styles from inner pages
						$('#global-movers-members').hide();
						$('#form-wrapper.index').hide(); //need to hide contact form
						$("#content").hide().html(response).show(effects[count],800);				
				}
			});
		}
	count++;
	return false;
	});
$("#navigation ul li.submenu").removeClass('submenu');

$("#navigation ul li").hoverIntent({
	over: showMenu, // function = onMouseOver callback (REQUIRED)    
    interval:200,
	out: hideMenu // function = onMouseOut callback (REQUIRED)	
});
	
	
	
	
	$('.required').focus(function(){
		$(this).addClass('valid');
		if($(this).val() == '(Required)'){
			$(this).val('');
			}
		});
	$('.required').blur(function(){
		if( $.trim($(this).val()).length == 0){
			$(this).removeClass('valid');
			$(this).addClass('error');
			$(this).val('(Required)');
		} else{
			$(this).removeClass('error');
		}
		});
		
	$('#ContactForm').submit(function(){
		valid = true;
		$('.required').each(function(){
			if($(this).val() == '(Required)'){
				$(this).addClass('error');
				valid = false;
			} else{
				$(this).removeClass('error');
			}
		});
		var reg = /^[0-9a-z]+(([\.\-_])[0-9a-z]+)*@[0-9a-z]+(([\.\-])[0-9a-z-]+)*\.[a-z]{2,4}$/;
		if(reg.test($('#EmailAddress').val()) == false) {
			valid = false;
			$('#EmailAddress').addClass('error');
		}
		if(valid){
			  var options = {
				  url: "ajax/ajax-contact.php",
				  beforeSubmit:function() {jQuery("#result").html('<p class="ajax-loader">Submitting&hellip;<p>'); jQuery("#result").slideDown();},
				  success: function(responseText) {
					jQuery("#result").html(responseText);
					$("#result").effect('highlight',{},500, function(){setTimeout(function(){$('#result').hide('slide', {'direction':'up'})}, 3000)});
					//jQuery("#result").slideUp();
				  },
				  clearForm: true
			  };
		 	jQuery(this).ajaxSubmit(options);
			

		}
		return false;		
	});
	
		
		$('#global-movers img').next('div').hide();
		var id = '';
		function showToolTip(){
			id =  $(this).children('div');
			$(id).show('slide', {'direction':'left'}, 1000);
		};
		function hideToolTip(){
			$(id).hide('slide', {'direction':'right'}, 200);
		};

		$('div.tooltip-container').hoverIntent({
			over: showToolTip, 
			interval: 400, 
			out: hideToolTip
		});
		
});

