


Cufon.replace('#nav li');
Cufon.replace('h4');


var scrSpeed = 1000;

$(document).ready( function () {
	
	
	$(window).scroll(function(){
		if ($(window).scrollLeft() > 0) {
			$("#back").fadeIn("slow");
		}
		else {
			$("#back").fadeOut("slow");
		}
	});
    
   
   
	$('#nav1').click(function(){
		$.scrollTo( "#m1", scrSpeed, { axis:'x', offset: { left: -200 } } );
	});
    
	$('#nav2').click(function(){
		$.scrollTo( "#m2", scrSpeed, { axis:'x', offset: { left: -200 } } );
	});
    
	$('#nav3').click(function(){
		$.scrollTo( "#m3", scrSpeed, { axis:'x', offset: { left: -200 } } );
	});
    
	$('#nav4').click(function(){
		$.scrollTo( "#m4", scrSpeed, { axis:'x', offset: { left: -200 } } );
	});
    
	$('#nav5').click(function(){
		$.scrollTo( "#m5", scrSpeed, { axis:'x', offset: { left: -200 } } );
	});
    
	
	
	
	shortcut.add("Home",function() {
		$.scrollTo( 0, scrSpeed, { axis:'x' } );
	});
	shortcut.add("End",function() {
		$.scrollTo( "#container div:last", scrSpeed, { axis:'x' } );
	});
	shortcut.add("Right",function() {
		$.scrollTo( '+=500px', 500, { axis:'x' } );
        },
	 	{ 'disable_in_input':true
	});
	shortcut.add("Left",function() {
		$.scrollTo( '-=500px', 500, { axis:'x' } );
         },
	 	{ 'disable_in_input':true
	});
    shortcut.add("Up",function() {
		$.scrollTo( '-=500px', 500, { axis:'x' } );
         },
	 	{ 'disable_in_input':true
	});
    shortcut.add("Down",function() {
		$.scrollTo( '+=500px', 500, { axis:'x' } );
        },
	 	{ 'disable_in_input':true
	});
    shortcut.add("B",function() {
		$.scrollTo( 0, scrSpeed, { axis:'x' } );
        },
	 	{ 'disable_in_input':true
	});
	
	
	
	$('#back a').click(function(){
		$.scrollTo( 0, scrSpeed, { axis:'x', easing:'easeOutQuint' } );
	});
	
	
	
	
	(function($) {
		$.fn.cfadeIn = function(speed, callback) {
			$(this).fadeIn(speed, function() {
				if(jQuery.browser.msie)
					$(this).get(0).style.removeAttribute('filter');
				if(callback != undefined)
					callback();
			});
		};
		$.fn.cfadeOut = function(speed, callback) {
			$(this).fadeOut(speed, function() {
				if(jQuery.browser.msie)
					$(this).get(0).style.removeAttribute('filter');
				if(callback != undefined)
					callback();
			});
		};
	})(jQuery);
    
    
    
    var excerpt = $("#blog a").next("p");
    var dTop = - excerpt.height();
    excerpt.css('top', dTop-80);
    $("#blog a").hover(function() {
		excerpt.animate({opacity: "show", top: dTop - 60}, "slow");
	}, function() {
		excerpt.animate({opacity: "hide", top:dTop - 70}, "fast", function () {
               // $("#blog a").unbind('mouseover').unbind('mouseout');   
        });
	});
    
    
    
    $('#bzform').validate({
        submitHandler: function() {
            $('#bzform').ajaxSubmit(function() { 
                $('#contactform').fadeOut('slow', function() {
                $('#contactform').html('<p><strong>Thank you!</strong> Your message has been sent and we will respond, if needed, as soon as possible.</p>');
                $('#contactform').cfadeIn('slow');            
                });
            });
        },
        errorPlacement: function(error, element) {
            error.appendTo( element.prev('label') );
        }        
     }); 
     
     
    	$("#helper").effect("pulsate", { times:3 }, 1000);
        $("#helper a").click(function() {
        	var loc = "#" + $(this).attr("rel");
            $.scrollTo(loc, 1000, { axis:'x', offset: { left: -35 }} );
        });
        $(window).scroll(function(){
        	$("#helper").fadeOut("slow");
        });
        
    
    	
    $.fn.setWidth = function() {
    	var totalWidth = 1650
        $('div#container').children(".module").each(function() {
            totalWidth = totalWidth + $(this).width();	
        });
        $("#container").width(totalWidth);
    }
    
    $("div#container").setWidth();    
    
					
});

