/* Site specific JS */


$(document).ready(function()
{	
	
	// Open external links in a new window
	$("a[href^='http:']").not("[href*='spruceland.ab.ca']").attr('target','_blank');

	
	// Lightbox
	
	$('a.jQueryLightbox').lightBox(); // Select all links in object with gallery ID
	
	
	// Scroll anchors
	$(".scroll").click(function(event){
		//prevent the default action for the click event
		event.preventDefault();
		
		//get the full url - like mysitecom/index.htm#home
		var full_url = this.href;
		
		//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
		var parts = full_url.split("#");
		var trgt = parts[1];
		
		//get the top offset of the target anchor
		var target_offset = $("#"+trgt).offset();
		var target_top = target_offset.top;
		
		//goto that anchor by setting the body scroll top to anchor top
		$('html, body').animate({scrollTop:target_top}, 600);
	});
	
	
	
}); // End document.ready




$(window).load(function() {
	
	// Fire up the slider
	if ($('#slider').length != 0) 
	{
		$('#slider').nivoSlider({
			effect:'random',
			slices:10,
			animSpeed:500,
			pauseTime:5000,
			directionNav:false, //Next & Prev
			directionNavHide:true, //Only show on hover
			controlNav:false, //1,2,3...
			pauseOnHover:false, //Stop animation while hovering
			beforeChange: function(){},
			afterChange: function(){}
		});
	}
	
});


// Check Newsletter Subscribe Form


infoRequestCheck = function() 
{		

	if ($('#fullName').val() ==""){
		alert("Please provide your name.");
		$('#fullName').focus();
		return false;
	}
	
	if ($('#company').val() ==""){
		alert("Please provide the name of your company.");
		$('#company').focus();
		return false;
	}
	
	if ($('#phoneNumber').val() ==""){
		alert("Please provide your phone number.");
		$('#phoneNumber').focus();
		return false;
	}
	
	if ($('#email').val() ==""){
		alert("Please provide your email address.");
		$('#email').focus();
		return false;
	}
	

	if ($('#email').val() !=""){
		var x = $('#email').val();
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			if (!filter.test(x)) {
				alert("Oops, looks like there's a problem with your email address.");
				$('#email').focus();
				return false;
			}
	}
	
	if ($('#wsp_code').val() ==""){
		alert("Please enter the spam prevention code. 5 lowercase letters, no spaces.");
		$('#wsp_code').focus();
		return false;
	}

	return (true);
	
} //end checkForm function





