// JavaScript Document
$(document).ready(function(){
	$('.slider_item').cycle({
		fx: 'fade', 
		speed:    2000, 
		timeout:  10000
	});
	
	$('.services_slider').cycle({
		fx: 'scrollUp', 
		speed:    2000, 
		timeout:  10000
	});
	
	if(jQuery.isFunction(jQuery.fn.prettyPhoto)){
		$("a[rel^='prettyPhoto']").prettyPhoto({
			'theme':'light_rounded',
			'animationSpeed':'slow'
		});
	}
	
	if(jQuery.isFunction(jQuery.fn.jcarousel)){
		$('#web_carousel, #design_carousel, #photo_carousel, #video_carousel').jcarousel({
			'scroll' : 1,
			'animation' : 'slow',
			'wrap' : 'circular'
		});
	}
	
	if($.browser.msie){
		$('body').css('margin-left', '1px');
		$('#floating_footer_contact_wrap').css('width', '951px');
	}else if(navigator.userAgent.toLowerCase().indexOf('chrome') > -1){
		$('body').css('margin-left', '1px');
		$('#floating_footer_contact_wrap').css('width', '951px');
	}
});

function validate_contact_form(){
	var error_count = 0;

	if(jQuery.trim($('#name').val()) == '' || $('#email').val()===null){
		alert('"Name" and "Email" are required fields');
		error_count++;
	}else{
		if(!isValidEmailAddress($('#email').val())){
			alert('The email address provided is not a valid email address');
			error_count++;
		}else{
			if( jQuery.trim($('#email').val()) != jQuery.trim($('#email_confirm').val()) ){
				alert('Your emails don\'t match');
				error_count++;
			}
		}
	}
	if(error_count>0){
		return false;
	}else{
		return true;
	}
}

function isValidEmailAddress(emailAddress){
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	return pattern.test(emailAddress);
}
