$(document).ready(

	function(){
		if($('#slideshow').length > 0) {
			$('#slideshow').cycle({ 
				fx:     'scrollRight', 
				speed:  'slow', 
				timeout: 4000, 
				next:   '#next', 
				prev:   '#prev' 
			});
		}
		
		if($('#news-ticker').length > 0) {
			$('#news-ticker').cycle({ 
				fx:     'scrollUp', 
				speed:  'slow', 
				timeout: 8000
			});
		}
		
		if($('#banner').length > 0) {
			$('#banner').cycle({ 
				fx:     'fade', 
				speed:  'slow', 
				timeout: 6000
			});
		}
		
		if($('#tabs').length > 0) {
			$('.fragment').hide();
			$('.gallery').hide();
			$('#fragment-'+activeTab).show();
			$('#fragment-button-'+activeTab).addClass('active');
			$('#gallery-'+activeTab).show();
			
			if (activeSubTab != '0') {
				var target_offset = $("#sub-fragment-"+activeSubTab).offset();
				var target_top = target_offset.top;
				$('html, body').animate({scrollTop:target_top}, 777);
			}
			
			$('.fragment-button').click(function(){
				$('.fragment').hide();
				$('.gallery').hide();
				$(this).parent().parent().find('li').removeClass('active');
				$(this).parent().addClass('active');
				
				activeTab = $(this).attr('href').split('-')[1];
				$('#fragment-'+activeTab).fadeIn();
				$('#gallery-'+activeTab).fadeIn();
				
				return false;
			});
		}
		
		// Pretty Photo
		if($("a[rel^='prettyPhoto']").length > 0) {
			$("a[rel^='prettyPhoto']").prettyPhoto({
				animationSpeed: 'normal',
				padding: 40,
				opacity: 0.6,
				showTitle: true,
				allowresize: true,
				counter_separator_label: ' of ',
				theme: 'dark_rounded',
				callback: function(){}
			});
		}
		
		// Anchor Scroll
		if($(".scroll").length > 0) {
			$(".scroll").click(function(event){
				event.preventDefault();
				var full_url = this.href;
				var parts = full_url.split("#");
				var trgt = parts[1];
				var target_offset = $("#"+trgt).offset();
				var target_top = target_offset.top;
				$('html, body').animate({scrollTop:target_top}, 777);
			});
		}
	}
	
);
