$(document).ready(function(){
	
	$('#nojs').remove();
	$("#p-btn-1").click(function(event){
		event.preventDefault();						  
		$('#p-nav-1').slideDown(100);
	});
	
	$('#p-nav-1').mouseleave(function(){ $(this).fadeOut(300);});
	$('#p-nav-1').click(function(){ $(this).fadeOut(300);});	

	$('#categories li a, #proj-r-list li a').hover(
		function(){$(this).find('img').stop().fadeTo(50, .5);}, 
		function(){$(this).find('img').stop().fadeTo(500, 1);}
	);
	$('#top-nav a').hover(
		function(){$(this).stop().animate({'color' : '#cc0000'}, 50);},
		function(){$(this).stop().animate({'color' : '#666'}, 300);	
	});	
	$('#htxt li a').hover(
		function(){$(this).stop().animate({'color' : '#333'}, 50);},
		function(){$(this).stop().animate({'color' : '#666'}, 300);	
	});		
	$('#nav li').hover(
		function(){$(this).find('a').stop().animate({'color' : '#333'}, 50);},
		function(){$(this).find('a').stop().animate({'color' : '#888'}, 300);	
	});		
	$('#sub-nav a').hover(
		function(){$(this).stop().animate({'color' : '#fff'}, 50);},
		function(){$(this).stop().animate({'color' : '#999'}, 300);	
	});			
	$('#f-nav a').hover(
		function(){$(this).stop().animate({'color' : '#252525'}, 50);},
		function(){$(this).stop().animate({'color' : '#999'}, 300);	
	});			
	$('#quote a').hover(
		function(){$(this).stop().animate({ backgroundColor: '#252525' }, 200);},
		function(){$(this).stop().animate({ backgroundColor: '#cc0000' }, 400);
	});	
	$('.ftplink').hover(
		function(){$(this).stop().animate({ backgroundColor: '#cc0000' }, 200);},
		function(){$(this).stop().animate({ backgroundColor: '#252525' }, 400);
	});
	$('#ogk').hover(
		function(){$(this).stop().animate({'color': '#cc0000' }, 200);},
		function(){$(this).stop().animate({'color': '#252525' }, 400);
	});	
	$('#btn-back').hover(
		function(){$(this).stop().animate({'color': '#cc0000' }, 200);},
		function(){$(this).stop().animate({'color': '#252525' }, 400);
	});				
	$('#btn-view').hover(
		function(){
			$(this).stop().animate({ backgroundColor: '#fff' }, 200);
		
		},
		function(){
			$(this).stop().animate({ backgroundColor: '#cc0000' }, 400);
	});	
	$('#btn-testm').hover(
		function(){$(this).stop().animate({ backgroundColor: '#fff' }, 200);},
		function(){$(this).stop().animate({ backgroundColor: '#252525' }, 400);
	});					

	$('#nav li ul li a').prepend('<em></em>');
	$('#nav li ul li a').hover(
		function(){$(this).find('em').stop().fadeTo(25, 1);}, 
		function(){$(this).find('em').stop().fadeTo(500, 0);}
	);				

	if($("#project").length)
	{
		$('.slideshow').fadeIn(1200);
		$('.slideshow').cycle({
			fx: 'fade',
			timeout: 6000,
			speed: 1000,
			next: '.slideshow'
		});
		
		$('#btn-testm').toggle(
			function(event){$(
				'#proj-testimonial').stop().animate({"bottom": "0px"}, {duration:600, easing:"easeOutCubic"}); event.preventDefault();
				$(this).text('Hide Testimonial');			
			},
			function(event){
				$('#proj-testimonial').stop().animate({"bottom": "-326px"}, {duration:600, easing:"easeInCubic"}); event.preventDefault();
				$(this).text('View Testimonial');			
			}			
		);	
	
		$('#btn-close').click(function(event){$('#btn-testm').click();});		
			
				
		$("a[rel=lbx]").fancybox({
					'transitionIn'		: 'fade',
					'transitionOut'		: 'none',
					'titlePosition' 	: 'over',
					'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
						return '<span id="fancybox-title-over">' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' <strong>&nbsp; '  : '') + '</strong></span>';
			}
		});	
		tooltip();
		// screenshotPreview();		
		
	}
	
	tt2();	
	
	$('.blank').click(function(){ window.open(this.href);return false });

	$('.fix').fadeOut(900);
	
    $('.fw').cycle({
			fx: 'fade',
            random: 1,
			speed: 1000,
            delay: 0,
			timeout: 6000,
	        prev:    '#prev',
	        next:    '#next',
      		pagerAnchorBuilder: pagerFactory
    });
    function pagerFactory(idx, slide) {
        var s = idx > 2 ? ' style="display:none"' : '';
        return '<li'+s+'><a href="#">'+(idx+1)+'</a></li>';
    };
		
    $('#dock2').cycle({
			fx: 'fade',
			speed: 1000,
            delay: 0,
			timeout: 6000
    });	
		
    $('#home-ss ul').cycle({
			fx: 'fade',
			speed: 1000,
			random: 1,
            delay: 2000,
			timeout: 6000,
			next: '#hfix'
    });	


/*
    setTimeout(function() {
        $('.sustain').cycle({
            random: 1,
            delay:  -2000
        });

    }, 1000);
*/

 $('noscript').remove();
 
 	if($('.home').length)
	{
		$('#home-ss ul').fadeIn(2400);			
	}
 	if($('#newsletterform').length)
	{
		$("#newsletterform").validate();	
	}		

});

