// David Hicks Photography Javascript Document
$ = jQuery.noConflict();
$ = jQuery;

$(document).ready(function(){
	$("#nav > li").hover(
		function(){ $("ul:first", this).css({display: 'block'}); }, 
		function(){ $("ul:first", this).css({display: 'none'}); } 
	);
	$("#nav > li ul li").hover(
		function(){ $("ul:first", this).css({display: 'block'}); }, 
		function(){ $("ul:first", this).css({display: 'none'}); } 
	);
	$("#nav li ul").css({display: 'none'});
	
	if($('#banner').length > 0){ //If element exists
		$('#banner').cycle({
			fx : 'scrollLeft',
			easing : 'bounceout',
			speed :  900, 
    		timeout : 8000,
			pause : 1,
			random : 0,
			cleartype :  1, // enable cleartype corrections
			cleartypeNoBg: true,
			next : '#banner_next',
			prev : '#banner_previous',
			pager : '#banner_pager',
			pagerAnchorBuilder: function(idx, slide) {
				if (idx == 0) {
						return '<li class="pagination"><a href="#"></a></li>';
				}
				else {
                        return '<li class="pagination"><a href="#"></a></li>';
                }

			}

		});
	}

});
	
$(function(){$.fn.scrollToTop=function(){$(this).hide().removeAttr("href");if($(window).scrollTop()!="0"){$(this).fadeIn("fast")}var scrollDiv=$(this);$(window).scroll(function(){if($(window).scrollTop()=="0"){$(scrollDiv).fadeOut("fast")}else{$(scrollDiv).fadeIn("fast")}});$(this).click(function(){$("html, body").animate({scrollTop:0},"slow")})}});
$(function() {
	$("#toTop").scrollToTop();
});