// HBC College Ministry Javascript Document
$ = jQuery.noConflict();

$(document).ready(function(){
	$("#nav > li").hover(
		function(){ $("ul:first", this).slideDown("fast"); },
		function(){ $("ul:first", this).slideUp("fast"); },
		function(){ $("ul:first", this).css({display: 'block'}); },
		function(){ $("ul:first", this).css({display: 'none'}); }
	);
	
	$("#nav > li ul li").hover(
		function(){ $("ul:first", this).slideDown("fast"); },
		function(){ $("ul:first", this).slideUp("fast"); },
		function(){ $("ul:first", this).css({display: 'block'}); }, 
		function(){ $("ul:first", this).css({display: 'none'}); } 
	);
	
	$("#nav > li ul li ul li").hover(
		function(){ $("ul:first", this).slideDown("fast"); },
		function(){ $("ul:first", this).slideUp("fast"); },
		function(){ $("ul:first", this).css({display: 'block'}); }, 
		function(){ $("ul:first", this).css({display: 'none'}); } 
	);
	
	$("#nav > li ul li ul li ul li").hover(
		function(){ $("ul:first", this).slideDown("fast"); },
		function(){ $("ul:first", this).slideUp("fast"); },
		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 : 'fade',
			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>';
                }

			}

		});
	}
	
	if($('#block-rotator-one').length > 0){ //If element exists
		$('#block-rotator-one').cycle({
			fx : 'scrollHorz',
			speed :  250, 
    		timeout : 0,
			pause : 1,
			random : false,
			cleartype :  1, // enable cleartype corrections
			cleartypeNoBg: true,
			next : '#block_rotator_one_next',
			prev : '#block_rotator_one_previous',
			pager : '#block-rotator-one-nav-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>';
                }

			}

		});
	}
	
	if($('#block-rotator-two').length > 0){ //If element exists
		$('#block-rotator-two').cycle({
			fx : 'scrollHorz',
			speed :  250, 
    		timeout : 0,
			pause : 1,
			random : false,
			cleartype :  1, // enable cleartype corrections
			cleartypeNoBg: true,
			next : '#block_rotator_two_next',
			prev : '#block_rotator_two_previous',
			pager : '#block-rotator-two-nav-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>';
                }

			}

		});
	}
	
	if($('#block-rotator-three').length > 0){ //If element exists
		$('#block-rotator-three').cycle({
			fx : 'scrollHorz',
			speed :  250, 
    		timeout : 0,
			pause : 1,
			random : false,
			cleartype :  1, // enable cleartype corrections
			cleartypeNoBg: true,
			next : '#block_rotator_three_next',
			prev : '#block_rotator_three_previous',
			pager : '#block-rotator-three-nav-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>';
                }

			}

		});
	}
	
	if($('#block-rotator-four').length > 0){ //If element exists
		$('#block-rotator-four').cycle({
			fx : 'scrollHorz',
			speed :  250, 
    		timeout : 0,
			pause : 1,
			random : false,
			cleartype :  1, // enable cleartype corrections
			cleartypeNoBg: true,
			next : '#block_rotator_four_next',
			prev : '#block_rotator_four_previous',
			pager : '#block-rotator-four-nav-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>';
                }

			}

		});
	}
	
	if($('#block-rotator-five').length > 0){ //If element exists
		$('#block-rotator-five').cycle({
			fx : 'scrollHorz',
			speed :  250, 
    		timeout : 0,
			pause : 1,
			random : false,
			cleartype :  1, // enable cleartype corrections
			cleartypeNoBg: true,
			next : '#block_rotator_five_next',
			prev : '#block_rotator_five_previous',
			pager : '#block-rotator-five-nav-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>';
                }

			}

		});
	}
	
	if($('#block-rotator-six').length > 0){ //If element exists
		$('#block-rotator-six').cycle({
			fx : 'scrollHorz',
			speed :  250, 
    		timeout : 0,
			pause : 1,
			random : false,
			cleartype :  1, // enable cleartype corrections
			cleartypeNoBg: true,
			next : '#block_rotator_six_next',
			prev : '#block_rotator_six_previous',
			pager : '#block-rotator-six-nav-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>';
                }

			}

		});
	}
	
	if($('#block-rotator-seven').length > 0){ //If element exists
		$('#block-rotator-seven').cycle({
			fx : 'scrollHorz',
			speed :  250, 
    		timeout : 0,
			pause : 1,
			random : false,
			cleartype :  1, // enable cleartype corrections
			cleartypeNoBg: true,
			next : '#block_rotator_seven_next',
			prev : '#block_rotator_seven_previous',
			pager : '#block-rotator-seven-nav-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 showonlyone(thechosenone) {
	 $('div[name|="faqbox"]').each(function(index) {
		  if ($(this).attr("id") == thechosenone) {
			   $(this).slideDown(200);
		  }
		  else {
			   $(this).slideUp(600);
		  }
	 });
}
	
$(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();
});
