// JavaScript Document
 $(document).ready(function() {
	$('.slider-list').cycle({
		prev: '#slider-prev-button',
		next: '#slider-next-button',
		speed:   1200,
		timeout: 7000,
		after:   onAfter,
		before:   onBefore
	});
	
	Cufon.replace('h3.product-title', { 
	  color: '#F9BB16', 
	 fontFamily: 'Helvetica', 
	 textShadow: '1px 2px rgba(0,0,0,.6)' 
	});
	
	$("#footer li.footer-menu").hoverIntent(function(){
		$("#product-links").fadeIn();
	}, function() {
		$("#product-links").hide();
	});

	$('.menu').sooperfish({
                dualColumn  : 6, //if a submenu has at least this many items it will be divided in 2 columns
                tripleColumn  : 8, //if a submenu has at least this many items it will be divided in 3 columns
        });

	$("#testimonial-form").validate({
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				success: function(){ $("#testimonial-form").fadeOut(function(){ $(".success").fadeIn(); }); }
			});
		}
	});

	$("#contact-form").validate({
		submitHandler: function(form) {
			jQuery(form).ajaxSubmit({
				success: function(){ $("#contact-form").fadeOut(function(){ $(".success").fadeIn(); }); }
			});
		}
	});

	$("#map1").gMap({ zoom: 12, markers: [{ address: "210 High Street, Palo Alto, CA 94301", html: "CMSolutions, LLC" }]});

	$(document).keydown(function(e){
		 switch(e.keyCode) {
			case 37:
			        $('.slider-list').cycle('prev');
				break;
			case 39:
			        $('.slider-list').cycle('next');
				break;
    		}
	});
});

function onAfter() {
	$(this).find('*:not(:first)').delay(1000).showdelay();
}


function onBefore() {
	$(this).find('*:not(:first)').hide();
}

function mycarousel_initCallback(carousel) {
	$("#slider-prev-button").click(function(){
		carousel.prev();
		return false;
	});

	$("#slider-next-button").click(function(){
		carousel.next();
		return false;
	});
}




(function($){
	$.fn.showdelay = function(){
		var delay = 0;
		return this.each(function(){
			$(this).hide().delay(delay).fadeIn(1500);
			delay += 1500;
		});
	};
})(jQuery);


