/* Web Elements by TrueThemes */

	    
(function($) {

/* ------------------------------------------------------------------------
Fire up Functions on Page Load
* ------------------------------------------------------------------------- */
jQuery(document).ready(function () {
	//scrollTop();
	slider();
	buttonHover();
	//openWindow();
	supersized();
	//doTabsType1();
	//doTabsType2();
	//doAccordion();
	jQuery('#kaloto-carousel').jcarousel();
	

});

/* ------------------------------------------------------------------------
Slider
* ------------------------------------------------------------------------- */
function slider(){
	jQuery('.slider').cycle({
	           fx: 'fade',
	           speed: 1000,
	           timeout: 4000,
	           next: '#next',
	           prev: '#prev',
	           pager:  '#circle',
	           after: onAfter
	        });
}
function onAfter(curr, next, opts) {
    var index = opts.currSlide;
    $('#prev')[index == 0 ? 'hide': 'show']();
    $('#next')[index == opts.slideCount - 1 ? 'hide': 'show']();
}

/* ------------------------------------------------------------------------
Open window
* ------------------------------------------------------------------------- */
function openWindow(){
	w=600;
	h=400;
	var left = (screen.width/2)-(w/2);
	var top = (screen.height/2)-(h/2);
	
	jQuery('.social ul li').not('.comments').click(function(){ 
	var pageURL=$(this).find('a').attr('href');
	console.log(pageURL);
	var title=$('title').html();
	window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
	});
	
	jQuery('.comments').click(function(){ 
		var pageURL=$(this).find('a').attr('href');
		window.location.href=pageURL;
	});
}


/* ------------------------------------------------------------------------
Scroll to Top
* ------------------------------------------------------------------------- */
function scrollTop(){
	jQuery('a.scrollToTop').click(function(){ 
	jQuery('html, body').animate({scrollTop:0}, 'slow');
	return false; 
	});
}





/* ------------------------------------------------------------------------
Button Hover
* ------------------------------------------------------------------------- */
function buttonHover(){

jQuery("#menu li").hover(function () {
	jQuery(this).stop().animate({
		opacity: 0.8, 
	}, 200,'linear',function () {
		jQuery(this).stop().animate({
			opacity: 1.0
		}, 200)
	})
}, function () {
	jQuery(this).stop().animate({
		opacity: 1.0
	}, 250)
})

}





/* ------------------------------------------------------------------------
Tabs - Type 1
* ------------------------------------------------------------------------- */
function doTabsType1(){
	var tabs = jQuery('.tabs_type_1');
	if(tabs.length < 1){
		return;
	}
	
	tabs.append("<span class='tabs_type_1_arrow'></span>");
	tabs.each(function(){
		var self = jQuery(this);
		var handlers = self.children('dt');
		var tabContentBlocks = self.children('dd');
		var currentTab = tabContentBlocks.eq(0);
		var arrow = self.children('span').eq(0);
		var handlersWidth = handlers.eq(0).outerWidth();
		var firstHandlerY = handlers.eq(0).position().top + handlers.eq(0).outerHeight() - 17;
		arrow.css({'left': handlersWidth-17 + 'px', 'top': firstHandlerY + 'px'});
		handlers.click(function(){
			var self = jQuery(this);
			currentTab.prev().removeClass('current');
			currentTab.fadeOut('fast');
			currentTab = self.next();
			var minus = self.index() == 0 ? 17 : self.outerHeight()/2 + 17;
			arrowY = self.position().top + self.outerHeight() - minus;
			arrow.animate({'top':arrowY + 'px'});
			currentTab.fadeIn('slow');
			self.addClass('current');
		});
	});
}





/* ------------------------------------------------------------------------
Tabs - Type 2
* ------------------------------------------------------------------------- */
function doTabsType2(){
	var tabs = jQuery('.tabs_type_2');
	if(tabs.length <  1){
		return;
	}
	tabs.append("<span class='tabs_type_2_arrow'></span>");
	tabs.each(function(){
		var self = jQuery(this);
		var handlers = self.children('dt');
		var tabContentBlocks = self.children('dd');
		var currentTab = tabContentBlocks.eq(0);
		var arrow = self.children('span').eq(0);
		var handlersWidth = handlers.eq(0).outerWidth();
		var firstHandlerY = handlers.eq(0).position().top + handlers.eq(0).outerHeight() - 18;
		arrow.css({'left': handlersWidth/2 - 7 + 'px'});
		handlers.click(function(){
			var self = jQuery(this);
			currentTab.prev().removeClass('current');
			currentTab.fadeOut('fast');
			currentTab = self.next();
			//var minus = self.index() == 0 ? 18 : self.outerHeight()/2 + 18;
			arrowY = self.position().left + (self.outerWidth() /2) - 2;
			arrow.animate({'left':arrowY + 'px'});
			currentTab.fadeIn('slow');
			self.addClass('current');
		});
	});
}





/* ------------------------------------------------------------------------
Accordions
* ------------------------------------------------------------------------- */
function doAccordion(){
	var accordions = jQuery('.accordion');
	if(accordions.length < 1){
		return;
	}
	accordions.each(function(){
		var self = jQuery(this);
		var handlers = self.children('dt');
		handlers.click(function(){
			var self = jQuery(this);
			self.children('dt.current').removeClass('current').next().slideUp();
			self.toggleClass('current');
			self.next('dd').slideToggle();
		});
	});
}

/* ------------------------------------------------------------------------
Supersized for background slideshow
* ------------------------------------------------------------------------- */
function supersized(){
	
	$.supersized({
					
		//Functionality
		slideshow               :   1,		//Slideshow on/off
		autoplay				:	1,		//Slideshow starts playing automatically
		start_slide             :   1,		//Start slide (0 is random)
		random					: 	0,		//Randomize slide order (Ignores start slide)
		slide_interval          :   8000,	//Length between transitions
		transition              :   1, 		//0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
		transition_speed		:	1000,	//Speed of transition
		new_window				:	1,		//Image links open in new window/tab
		pause_hover             :   0,		//Pause slideshow on hover
		keyboard_nav            :   1,		//Keyboard navigation on/off
		performance				:	2,		//0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit)
		image_protect			:	1,		//Disables image dragging and right click with Javascript
		image_path				:	'http://www.kalotoflora.com/wp-content/themes/kalotoflora/images/', //Default image path

		//Size & Position
		min_width		        :   1024,		//Min width allowed (in pixels)
		min_height		        :   768,		//Min height allowed (in pixels)
		vertical_center         :   1,		//Vertically center background
		horizontal_center       :   1,		//Horizontally center background
		fit_portrait         	:   1,		//Portrait images will not exceed browser height
		fit_landscape			:   0,		//Landscape images will not exceed browser width
		
		//Components
		navigation              :   0,		//Slideshow controls on/off
		thumbnail_navigation    :   0,		//Thumbnail navigation
		slide_counter           :   0,		//Display slide numbers
		slide_captions          :   0,		//Slide caption (Pull from "title" in slides array)
		slides 					:  	[		//Slideshow Images
						{image : 'http://www.kalotoflora.com/wp-content/themes/kalotoflora/images/background/shop.jpg'} 
				]
									
	}); 
	
}




}(jQuery));




