jQuery(document).ready(function() {
        jQuery('#wrapper').gradient({from: 'eaf3fb',to: 'ffffff',direction: 'horizontal' });
        jQuery('#footer').gradient({from: 'fcfcfa',to: 'ebe5ce',direction: 'horizontal' });
        jQuery('#primary').gradient({from: 'badcf0',to: 'ffffff',direction: 'horizontal' });

	var img = jQuery('#headimage')[0]

        switch (jQuery('.current_page_item > a')[0].title.toLowerCase()) {
                case 'meet our team':
                        img.src = themeUrl + '/images/headers/meetourteam.png';
                        break;
                case 'happy patients': 
                        img.src = themeUrl + '/images/headers/happypatients.png';
                        break;
                default:
                        img.src = themeUrl + '/images/headers/header.jpg';
        }; 

	setInterval( "slideSwitch()", 5000 );
});

// Form Validator
function validateForm()
{
	var x=document.forms["coupon"]["name"].value

	if (x==null || x=="")
	{
		alert("Your name must be filled out in order to receive this coupon");
		return false;
	}

	var x=document.forms["coupon"]["phone"].value

	if (x==null || x=="")
	{
		alert("Your phone number must be filled out in order to receive this coupon");
		return false;
	}

	var x=document.forms["coupon"]["email"].value
	var atpos=x.indexOf("@");
	var dotpos=x.lastIndexOf(".");

	if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
	{
		alert("Your email address must be valid in order to receive this coupon");
		return false;
	}
}

function slideSwitch() {
    var $active = jQuery('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = jQuery('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : jQuery('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

