$(document).ready(function(){
    $(".error").hide();
    $(".logo").css({top:"-10px"});
    $(".colophon").css({paddingTop:"16px"});
    $(".visNav").visualNav();
    $("a.toplink").click(function() {
	$("html, body").animate({scrollTop: "0px"}, 1000);
	}); 
    $(".logo").hover(function() {
	$(this).stop(true, true).animate({top: "0px"}, 200);
	}, function() {
	$(this).stop(true, true).animate({top: "-10px"}, 200);
	}); 
    $(".toplink").hover(function() {
	$(this).stop(true, true).animate({bottom: "28px"}, 400);
	}, function() {
	$(this).stop(true, true).animate({bottom: "24px"}, 200);
	}); 
    $(".colophon").hover(function() {
	$(this).stop(true, true).animate({paddingTop: "10px"}, 200);
	}, function() {
	$(this).stop(true, true).animate({paddingTop: "16px"}, 200);
	});

    $(".bigcopy").cycle( {
	    fx:'fade',
	    speed:300,
	    timeout:7000,
	    sync:0,
	    slideExpr:'.line',
	    width:700,
	    height:170
	});

    $(".images-chit-chat-slp").cycle( {
	    fx:'scrollHorz',
	    speed:800,
	    timeout:0,
	    sync:1,
	    easing:'easeOutExpo',
	    nowrap:true,
	    pager:'.pager-chit-chat-slp',
	    height:430
	}).touchwipe({
	    wipeLeft:function(){
		$(".images-chit-chat-slp").cycle("next");
	    },
	    wipeRight:function() {
		$(".images-chit-chat-slp").cycle("prev");
	    }
	});    
    

    $(".images-jeanne-coleman").cycle( {
	    fx:'scrollHorz',
	    speed:800,
	    timeout:0,
	    sync:1,
	    easing:'easeOutExpo',
	    nowrap:true,
	    pager:'.pager-jeanne-coleman',
	    height:466
	}).touchwipe({
	    wipeLeft:function(){
		$(".images-jeanne-coleman").cycle("next");
	    },
	    wipeRight:function() {
		$(".images-jeanne-coleman").cycle("prev");
	    }
	});    
    

    $(".images-angela-pace-gould").cycle( {
	    fx:'scrollHorz',
	    speed:800,
	    timeout:0,
	    sync:1,
	    easing:'easeOutExpo',
	    nowrap:true,
	    pager:'.pager-angela-pace-gould',
	    height:466
	}).touchwipe({
	    wipeLeft:function(){
                $(".images-angela-pace-gould").cycle("next");
	    },
	    wipeRight:function() {
		$(".images-angela-pace-gould").cycle("prev");
	    }
	});    
    
    $(".images-chadwell-supply").cycle( {
	    fx:'scrollHorz',
	    speed:800,
	    timeout:0,
	    sync:1,
	    easing:'easeOutExpo',
	    nowrap:true,
	    pager:'.pager-chadwell-supply',
	    height:430
	}).touchwipe({
	    wipeLeft:function(){
		$(".images-chadwell-supply").cycle("next");
	    },
	    wipeRight:function() {
		$(".images-chadwell-supply").cycle("prev");
	    }
	});

    $(".submit").click(function() {
	$('.error').hide();
	
	var name = $("input#name").val();
	    if (name == "") {
		$("#name_error").fadeIn('slow');
		$("input#name").focus();
		return false;
	    }
	var email = $("input#email").val();
	    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	    if (!filter.test(email)) {
		$("#email_error").fadeIn('slow');
		$("input#email").focus();
		return false;
	    }
	var message = $("textarea#message").val();
	    if (message == "") {
		$("#message_error").fadeIn('slow');
		$("textarea#message").focus();
		return false;
	    }
		    
	var dataString = 'name='+ name + '&email=' + email + '&message=' + message;
	
	$(".loading").show();
		    
	$.ajax({
	type: "POST",
	url: "sendmail.php",
	data: dataString,
	success: function() {
	    $('#contact-form').fadeOut('fast');
	    $('.message-box').delay(400).fadeIn('slow');
	    }
	 }); // $.ajax
	return false;
    }); // $.submit

    $(".reset").click(function() {
	$('.error').hide();
	$('input#name, input#email, textarea#message').val("");
	$("input#name").focus();
    	return false;
    }); // $.reset
        
}); // document ready
