$(document).ready(function(){

	/* Dots Slider 1 */
	jQuery(function(){
		$('#dotsSlider')
		.after('<div id="dotsSliderNav">')
		.cycle({
			fx:		'fade',
			speed:	400,
			timeout: 3000,
			pager:	'#dotsSliderNav',
			after:	onAfter
		});

		function onAfter() {
			//get the height of the current slide
			var $ht = $(this).height();
			//set the container's height to that of the current slide
			$(this).parent().animate({height: $ht});
		}
	});
	/* End Dots Slider 1 */

	/* Rondabout Slider */
	jQuery(function(){
		$('#roundaboutSlider').roundabout({
			minScale: 0.9,
			minOpacity: 0.9,
			easing: 'easeOutBounce',
			duration: 1200,
			clickToFocus: false,
			btnNext: '.nextSlide',
			btnPrev: '.previousSlide'
		});
	});
	/* End Rondabout Slider */

	/* Dots Slider 2 */
	jQuery(function(){
		$('#dotsSlider2')
		.after('<div id="dotsSlider2Nav">')
		.cycle({
			fx:		'fade',
			speed:	400,
			timeout: 3000,
			pager:	'#dotsSlider2Nav',
			height: '401px',
			prev:   '.prevDotsSlide',
			next:   '.nextDotsSlide'
		});
	});
	/* End Dots Slider 2 */

	/* Single Portfolio Slider */
	jQuery(function(){
		$('#portfolioSlider')
		.after('<div id="portfolioSliderNav">')
		.cycle({
			fx:		'fade',
			speed:	400,
			timeout: 3000,
			pager:	'#portfolioSliderNav',
			height: '490px'
		});
	});
	/* End Single Portfolio Slider */

	/* Tabs Slider */
	jQuery(function(){
		$slideshow = {
			context: false,
			tabs: false,
			timeout: 3000,      // time before next slide appears (in ms)
			slideSpeed: 1000,   // time it takes to slide in each slide (in ms)
			tabSpeed: 500,      // time it takes to slide in each slide (in ms) when clicking through tabs
			fx: 'fade',   // the slide effect to use - http://malsup.com/jquery/cycle/options.html
	
			init: function() {
				this.context = $('#tabsSlider');
				this.tabs = $('#tabsNav li', this.context);
				this.tabs.remove();
				this.prepareSlideshow();
				this.fillEmptyGap();
			},
	
			prepareSlideshow: function() {
				$('#tabsSlides > ul', $slideshow.context).cycle({
					fx: $slideshow.fx,
					timeout: $slideshow.timeout,
					speed: $slideshow.slideSpeed,
					fastOnEvent: $slideshow.tabSpeed,
					pager: $('#tabsNav', $slideshow.context),
					pagerAnchorBuilder: $slideshow.prepareTabs,
					before: $slideshow.activateTab,
					pauseOnPagerHover: true,
					pause: true
				});
			},
	
			prepareTabs: function(i, slide) {
				return $slideshow.tabs.eq(i);
			},

			fillEmptyGap: function() {
				// fill possibly empty gap in the end
				var tabsLiWidths = 0,
					tabsUl = $('#tabsNav').outerWidth(true);
	
				$('#tabsNav li').each(function() {
					tabsLiWidths += $(this).outerWidth(true);
				});
	
				var fillWidth = tabsUl - tabsLiWidths;
	
				$('#tabsNav').append('<span class="fill">&nbsp;</span>');
				$('#tabsNav span.fill').css('width',fillWidth);
			}
			
		};
		
		$('body').addClass('js');
		
		$slideshow.init();
		
	});
	/* End Tabs Slider */
	
	/* Piecemaker 3D Slider */
	jQuery(function(){
		var flashvars = {};
		var params = {};
		params.wmode = "transparent";
		var attributes = {};
		swfobject.embedSWF("piecemaker/piecemaker.swf", "piecemakerSlider", "1200", "500", "10", false, flashvars, params, attributes);
	});
	/* End Piecemaker 3D Slider */
	
	/* Fancybox Images */
	jQuery(function(){
		$("a.single_image").fancybox({
			'transitionIn'	: 'fades',
			'transitionOut'	: 'fade',
			'titlePosition'	: 'over'
		});
		$("a.multi_images").fancybox({
			'transitionIn'	: 'fade',
			'transitionOut'	: 'fade',
			'titlePosition'	: 'over'
		});
	});
	/* End Fancybox Images */

	/* Fancybox Iframe */
	jQuery(function(){
		$("a.iframe").fancybox({
			'width'				: '75%',
			'height'			: '75%',
			'autoScale'     	: false,
			'transitionIn'		: 'fade',
			'transitionOut'		: 'fade',
			'type'				: 'iframe',
			'titleShow'		    : false
		});
	});
	/* End Fancybox Iframe */

	/* Fancybox Youtube Video */
	jQuery(function(){
		$(".youtube_video").click(function() {
			$.fancybox({
					'padding'		: 0,
					'autoScale'		: false,
					'transitionIn'	: 'fade',
					'transitionOut'	: 'fade',
					'title'			: this.title,
					'width'		    : 680,
					'height'		: 495,
					'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
					'type'			: 'swf',
					'swf'			: {
						'wmode'		: 'transparent',
						'allowfullscreen'	: 'true'
					}
				});

			return false;
		});
	});
	/* End Fancybox Youtube Video */

	/* Zoom Icon */
	jQuery(function(){
		$(".zoom a").append("<span></span>");
		$(".zoom a").hover(function(){
			$(this).children("img").stop(true, true).animate({opacity:0.7},300);
			$(this).children("span").stop(true, true).fadeIn(300);
		},function(){
			$(this).children("img").stop(true, true).animate({opacity:1},250);
			$(this).children("span").stop(true, true).fadeOut(250);
		});
		
		$(".photos a").hover(function(){
			$(this).children("img").stop(true, true).animate({opacity:0.6},300);
		},function(){
			$(this).children("img").stop(true, true).animate({opacity:1},250);
		});
	});
	/* End Zoom Icon */
	

	/* Sidebar Widget Slider */
	jQuery(function(){
		$(".trigger").click(function(){
			$(this).toggleClass("active").next().slideToggle(400);
			return false;
		});
	});
	/* End Sidebar Widget Slider */

	/* clearField */
	jQuery(function(){
		$('.clearField').clearField();
	});
	/* End clearField */
	
});
