/*	Javascript	*/

function send_contact_function(){
	var form=$('#form_submission').val();
	var name=$('#name').val();
	var phone=$('#phone').val();
	var email=$('#email').val();
	var message=$('#message').val();
	var captcha=$('#captcha').val();
	
	var cache=new Date();
	
	var data_string='form_submission='+form+'&name='+name+'&phone='+phone+'&email='+email+'&message='+message+'&captcha='+captcha+'&cache='+cache;
	
	//DEBUGGING
	//alert(data_string); return false;
	
	$.ajax({
	    type: "POST",
	    url: "php/form_handler.php",
	    data: data_string,
	    success: function(data) {			
			//DEBUGGING
			//alert(data); return false;
			if(data=='true'){
				$('#ez_contact_box').html('<h2>Message sent!</h2>Message Sent! We will be following up as soon as possible.<br><br>Thanks a ton!');
			}else{
				$('#ez_contact_box').html('<h2>Uh oh!</h2>Looks like you missed some information in the form.<br><br>Make sure you enter the security code properly as well - this way we know you are human and not a spam bot.<br><br><a onclick="contact_form_try_again()">Click here to try again!</a>');
			}
    	}
  	});
}

function contact_form_try_again(){
	$.ajax({
	    type: "POST",
	    url: "contact_include.php",
	    cache: false,
	    success: function(data) {			
			//DEBUGGING
			//alert(data); return false;
			$('#ez_contact_box').html(data);
    	}
  	});
}



function initial_load(){
	$('#load_logo').click(function(){
		$('#load_logo').ImageSwitch({Type:"FadeIn", NewImage:"images/logo_finished_load.png", EffectOriginal: false, Speed: 20000});
	});
}

function change_cap(action){
	switch(action){
		case 'left-in': $('.left_cap').css('background-image', 'url(images/nav_hover_left)'); break;
		case 'left-out': $('.left_cap').css('background-image', 'url(images/nav_left.png)'); break;
		
		case 'right-in': $('.right_cap').css('background-image', 'url(images/nav_hover_right)'); break;
		case 'right-out': $('.right_cap').css('background-image', 'url(images/nav_right.png)'); break;
	}
}


$(function(){
	$('a#logo_link').mouseover(
		function(){
			$('img#logo_img').attr('src', 'images/logo_alt.png');
		}
	);

	$('a#logo_link').mouseout(
		function(){
			$('img#logo_img').attr('src', 'images/logo.png');
		}
	);
});

function change_content(source){
	var html=$('#AJAX_'+source).html();
	$('#page_content_mixer').html(html);
	
	//PREVENT HTML PROGRESSION
	return false;
}

function change_page(location){	
	$.ajax({
	    type: "GET",
	    url: "pages/"+location+".php",
		data: '&bust='+Date(),
	    cache: false,
	    success: function(data) {			
			//DEBUGGING
			//alert(data); return false;
			
			//LOAD DATA
			$('#main_content .wrapper').html(data);
			
			//JUMP TO MAIN CONTENT
			$.scrollTo( "a[title='Main Content']", 1000 );
    	}
  	});
	
	//PREVENT HTML PROGRESSION
	return false;
}



/*
	START SLIDER
*/
$(window).load(function() {
	$('#slider_wrapper').orbit({
		animation: 'horizontal-slide', 		//fade, horizontal-slide, vertical-slide
     	animationSpeed: 300, 				//how fast animations are
     	advanceSpeed: 5000, 				//if timer advance is enabled, time between transitions 
     	startClockOnMouseOut: true, 		//if timer should restart on MouseOut
     	startClockOnMouseOutAfter: 3000, 	//how long after mouseout timer should start again
     	directionalNav: true, 				//manual advancing directional navs
     	captions: true, 					//if has a title, will be placed at bottom
     	captionAnimationSpeed: 800, 		//how quickly to animate in caption on load and between captioned and uncaptioned photos
     	timer: true, 						//if the circular timer is wanted
     	bullets: true 						//true or false to activate the bullet navigation
	});
});


//START AT HOME PAGE BY DEFAULT
$(function(){
	$.ajax({
	    type: "GET",
	    url: "pages/home.php",
		data: '&bust='+Date(),
	    cache: false,
	    success: function(data) {			
			//DEBUGGING
			//alert(data); return false;
			
			//LOAD DATA
			$('#main_content .wrapper').html(data);
    	}
  	});
});
