$(document).ready(function(){

	//font replacement
	Cufon.replace("h1,h2,h3:not(.nocufon),h4", {hover: true});
	
	//banner scoller
	$("div.scrollable").scrollable({
		size: 1, 
		loop: true,
		speed: 750
	}).circular().navigator().autoscroll({interval: 4500});

	//pricing details
	$("div.pricing-more-info").hide();
    
	$("a.pricing-more").click(function () {
		//show details
		$(this.href.substring(this.href.indexOf("#"), this.href.length)).fadeToggle();
		return false;
	}); 
	
    $("div.pricing-more-info .close").click(function () {
		//hide details
		$(this).parent().fadeToggle();
		return false;
	});
    
    //lightboxsetup
    $(".screenshots a, .imagecaption-gallery a").lightBox(); 
    

    //control loing form toggle
    $("a#helper-login, a#control-login-toggle").click(function () {
		//hide details
		$("form#control-login").fadeToggle();
		return false;
	});

    //username input watermark
	$("#control-login-domain").Watermark("domain.com");

	// when the form is submitted
	$('#colo-quote').submit( function(){
	
		var reg_email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/; 
	
		var inputcheck = $('#contact_name');
		// if field has something in it, do submit actions, otherwise write out error
		if( inputcheck.val() == '' ){
			// add class to change colour
			inputcheck.addClass("required").get(0).focus();
			return false;
		}else{ inputcheck.removeClass("required"); }

		var inputcheck = $('#business_name');
		if( inputcheck.val() == '' ){
			inputcheck.addClass("required").get(0).focus();
			return false;
		}else{ inputcheck.removeClass("required"); }
		
		var inputcheck = $('#email_address');
		if( inputcheck.val() == '' || !reg_email.test( inputcheck.val() ) ){
			inputcheck.addClass("required").get(0).focus();
			return false;
		}else{ inputcheck.removeClass("required"); }
		
	});	

	jQuery.fn.fadeToggle = function(speed, easing, callback) {
		return this.animate({opacity: 'toggle'}, speed, easing, callback);
	};     
    
});