jQuery.noConflict();

//DOCUMENT.READY
jQuery(document).ready(function() { 
	//loop through each post type and setup a jquery tabs object
	jQuery('#tabbed-Restaurant-reviews > ul').tabs({ fx: { opacity: 'toggle', duration: 150 } });		
	jQuery('#tabbed-Music-reviews > ul').tabs({ fx: { opacity: 'toggle', duration: 150 } });		
	jQuery('#tabbed-Movie-reviews > ul').tabs({ fx: { opacity: 'toggle', duration: 150 } });		
	jQuery('#tabbed-Fashion-reviews > ul').tabs({ fx: { opacity: 'toggle', duration: 150 } });		
	jQuery('#tabbed-Product-reviews > ul').tabs({ fx: { opacity: 'toggle', duration: 150 } });	
	
	//colorbox
	jQuery('.review .article-image a').colorbox({transition:'fade', speed:250});
	jQuery('.single-post .content .article-image a').colorbox({transition:'fade', speed:250});
	jQuery('.colorbox').colorbox({transition:'fade', speed:250});
	jQuery('.colorboxiframe').colorbox({transition:'fade', speed:250, iframe:true, innerWidth:640, innerHeight:390});						
	 
	//latest slider	
	jQuery(function() {
		jQuery(".latest-slider").jCarouselLite({		
			auto: 3000,
			easing: "easeInOutExpo",
			speed: 1100,
			visible: 4			
		});	
	});
	jQuery(function() {
		jQuery(".latest-slider-header").jCarouselLite({		
			auto: 3000,
			easing: "easeInOutExpo",
			speed: 1100,
			visible: 4			
		});	
	});	  		
});

//WINDOW.LOAD
jQuery(window).load(function() {
	//spotlight slider	
	jQuery(function() {
		jQuery(".main-content-left #spotlight-slider").jCarouselLite({		
			auto: 2000,
			easing: "easeInOutExpo",
			speed: 1100,
			visible: 2			
		});	
	});
	jQuery(function() {
		jQuery(".main-content #spotlight-slider").jCarouselLite({		
			auto: 2000,
			easing: "easeInOutExpo",
			speed: 1100,
			visible: 3			
		});	
	});					
	jQuery('#featured').nivoSlider({				
		effect: 'random', // Specify sets like: 'fold,fade,sliceDown'
		slices: 10, // For slice animations
		boxCols: 6, // For box animations
		boxRows: 3, // For box animations
		animSpeed: 200, // Slide transition speed
		pauseTime: 6000, // How long each slide will show
		startSlide: 0, // Set starting Slide (0 index)
		directionNav: true, // Next and Prev navigation
		directionNavHide: true, // Only show on hover
		controlNav: true, // 1,2,3... navigation
		controlNavThumbs: true, // Use thumbnails for Control Nav
		controlNavThumbsFromRel: false, // Use image rel for thumbs
		controlNavThumbsSearch: '540x390', // Replace this with...
		controlNavThumbsReplace: '70x70', // ...this in thumb Image src
		keyboardNav: true, // Use left and right arrows
		pauseOnHover: true, // Stop animation while hovering
		manualAdvance: false, // Force manual transitions
		captionOpacity: 0.85, // Universal caption opacity
		prevText: 'Prev', // Prev directionNav text
		nextText: 'Next', // Next directionNav text
		beforeChange: function(){}, // Triggers before a slide transition
		afterChange: function(){}, // Triggers after a slide transition
		slideshowEnd: function(){}, // Triggers after all slides have been shown
		lastSlide: function(){}, // Triggers when last slide is shown
		afterLoad: function(){} // Triggers when slider has loaded							 
	});
});		


//DOCUMENT.READY
jQuery(document).ready(function() { 	
	// SUPERFISH
	jQuery('#top-menu ul').superfish({
		hoverClass:  'over', 						// the class applied to hovered list items 
		delay:       400,                            // one second delay on mouseout 
		animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
		speed:       150,                          // faster animation speed 
		autoArrows:  true,                           // disable generation of arrow mark-up 
		dropShadows: true                            // disable drop shadows 
	}); 	
	jQuery('#cat-menu ul').superfish({
		hoverClass:  'over', 						// the class applied to hovered list items 
		delay:       400,                            // one second delay on mouseout 
		animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
		speed:       150,                          // faster animation speed 
		autoArrows:  true,                           // disable generation of arrow mark-up 
		dropShadows: true                            // disable drop shadows 
	}); 	
	jQuery('#main-menu ul').superfish({
		hoverClass:  'over', 						// the class applied to hovered list items 
		delay:       400,                            // one second delay on mouseout 
		animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
		speed:       150,                          // faster animation speed 
		autoArrows:  true,                           // disable generation of arrow mark-up 
		dropShadows: true                            // disable drop shadows 
	});
	
	//toggle functions
	jQuery('.toggle-content').hide();
		//switch plus with minus image
	jQuery(".toggle").toggle(function(){
		jQuery(this).addClass("active");
		}, function () {
		jQuery(this).removeClass("active");
	});			
	//slide up and down on click
	jQuery(".toggle").click(function(){
		jQuery(this).next(".toggle-content").slideToggle();
	});
				
	jQuery('#post-1').click(function() { 
		jQuery('#slider1').cycle(0); 
		return false; 
	});
	jQuery('#post-2').click(function() { 
		jQuery('#slider1').cycle(1); 
		return false; 
	});
	jQuery('#post-3').click(function() { 
		jQuery('#slider1').cycle(2); 
		return false; 
	});
	jQuery('#post-4').click(function() { 
		jQuery('#slider1').cycle(3); 
		return false; 
	});
	jQuery('#post-5').click(function() { 
		jQuery('#slider1').cycle(4); 
		return false; 
	});
	jQuery('#post-6').click(function() { 
		jQuery('#slider1').cycle(5); 
		return false; 
	});
	
	//jQuery tabs
	jQuery('#tabbed-posts > ul').tabs({ fx: { opacity: 'toggle', duration: 150 } });
	jQuery('#tabbed-archives > ul').tabs({ fx: { opacity: 'toggle', duration: 150 } });
	jQuery('#tabbed-reviews > ul').tabs({ fx: { opacity: 'toggle', duration: 150 } });
	jQuery('.tabs-shortcode > ul').tabs({ fx: { opacity: 'toggle', duration: 150 } });
	//Review Categories tabs are setup in the header.html file
	
	if(!jQuery.browser.msie){button_hover_shortcode();}	
	
	//colorpickers
	//demo background color
	jQuery('#colorSelector').ColorPicker({
		color: '#F9F9FF',
		onShow: function (colpkr) {
			jQuery(colpkr).fadeIn(300);
			return false;
		},
		onHide: function (colpkr) {
			jQuery(colpkr).fadeOut(300);
			return false;
		},
		onChange: function (hsb, hex, rgb) {
			jQuery('body').css('backgroundColor', '#' + hex);
			jQuery('#colorSelector div').css('backgroundColor', '#' + hex);
		}
	});
	
});

//WINDOW.LOAD
jQuery(window).load(function() {
	//article slider	
	jQuery(function() {
		jQuery(".main-content-left #article-slider").jCarouselLite({		
			btnNext: ".article-slider-next",		
			btnPrev: ".article-slider-prev",
			easing: "easeInOutExpo",
			speed: 300,
			visible: 5			
		});	
	});
	jQuery(function() {
		jQuery(".main-content #article-slider").jCarouselLite({		
			btnNext: ".article-slider-next",		
			btnPrev: ".article-slider-prev",
			easing: "easeInOutExpo",
			speed: 300,
			visible: 8			
		});	
	});
	//shortcode slider
	jQuery(function() {
		jQuery("#shortcode-slider").jCarouselLite({		
			btnNext: ".shortcode-slider-next",		
			btnPrev: ".shortcode-slider-prev",
			easing: "easeInOutExpo",
			speed: 300,
			visible: 1			
		});	
	});
	//BRIGHTEN AND DARKEN IMAGE HOVERS (OR ANY OTHER ELEMENT)
	jQuery(function() {
		// BRIGHTEN
		// OPACITY OF BUTTON SET TO 75%
		jQuery(".brighten").css("opacity","0.75");			
		// ON MOUSE OVER
		jQuery(".brighten").hover(function () {											  
			// SET OPACITY TO 100%
			jQuery(this).stop().animate({
			opacity: 1.0
			}, 70);
		},			
		// ON MOUSE OUT
		function () {				
			// SET OPACITY BACK TO 75%
			jQuery(this).stop().animate({
			opacity: 0.75
			}, 700);
		});
		
		// DARKEN
		// ON MOUSE OVER
		jQuery(".darken img").hover(function () {											  
			// SET OPACITY TO 100%
			jQuery(this).stop().animate({
			opacity: .28
			}, 150);
		},			
		// ON MOUSE OUT
		function () {				
			// SET OPACITY BACK TO 75%
			jQuery(this).stop().animate({
			opacity: 1.0
			}, 600);
		});	
	});
	//mosaics
	jQuery(function($){				
		$('.circle').mosaic({
			opacity		:	0.8			//Opacity for overlay (0-1)
		});
		
		$('.fade').mosaic();
		
		$('.bar').mosaic({
			animation	:	'slide'		//fade or slide
		});
		
		$('.bar2').mosaic({
			animation	:	'slide'		//fade or slide
		});
		
		$('.bar3').mosaic({
			animation	:	'slide',	//fade or slide
			anchor_y	:	'top'		//Vertical anchor position
		});
		
		$('.cover').mosaic({
			animation	:	'slide',	//fade or slide
			hover_x		:	'400px'		//Horizontal position on hover
		});
		
		$('.cover2').mosaic({
			animation	:	'slide',	//fade or slide
			anchor_y	:	'bottom',		//Vertical anchor position
			hover_y		:	'65px'		//Vertical position on hover
		});
		
		$('.cover3').mosaic({
			animation	:	'slide',	//fade or slide
			hover_x		:	'400px',	//Horizontal position on hover
			hover_y		:	'300px'		//Vertical position on hover
		});	
	});
});

//toggle the demo settings - you can disregard this, it is only used for the swagger demo
function hidedemo() {
	jQuery('.demo-wrapper').animate({				 
		 "right": "-=128px"				 
		}, 300, "easeInOutExpo" );	
	jQuery('.hide-demo').hide();
	jQuery('.show-demo').show();		
}
function showdemo() {
	jQuery('.demo-wrapper').animate({				 
		 "right": "0px"				 
		}, 300, "easeInOutExpo" );	
	jQuery('.hide-demo').show();
	jQuery('.show-demo').hide();		
}
function changebg(id, repeat, image, logo) {
	jQuery('.bg').css("opacity","1");
	jQuery('.bg').css("border-color","#FFF");
	jQuery('#'+id+'').css("opacity","0.5");
	jQuery('#'+id+'').css("border-color","#000");
	jQuery('body').css("background-image", "url("+image+")");
	jQuery('body').css("background-repeat", ""+repeat+"");
	jQuery('#site-logo').attr("src", ""+logo+"");
}
function changeheaders(id, cssclass) {	
	jQuery('.bg').css("opacity","1");
	jQuery('.bg').css("border-color","#FFF");
	jQuery('#'+id+'').css("opacity","0.5");
	jQuery('#'+id+'').css("border-color","#000");	
	jQuery('.section-wrapper').removeClass("dark");
	jQuery('.section-wrapper').addClass(""+cssclass+"");
}

//button hovers
function button_hover_shortcode(){
	jQuery('.button_link,.more-button a,.comment-reply-link,button[type=submit],button,input[type=submit],input[type=button],input[type=reset],input[type=image]').hover(
		function() {
				jQuery(this).stop().animate({opacity:0.80},300);
			},
			function() {
				jQuery(this).stop().animate({opacity:1},300);
		});
}

//makes background position animations work in firefox
(function($) {
if(!document.defaultView || !document.defaultView.getComputedStyle){
    var oldCurCSS = jQuery.curCSS;
    jQuery.curCSS = function(elem, name, force){
        if(name === 'background-position'){
            name = 'backgroundPosition';
        }
        if(name !== 'backgroundPosition' || !elem.currentStyle || elem.currentStyle[ name ]){
            return oldCurCSS.apply(this, arguments);
        }
        var style = elem.style;
        if ( !force && style && style[ name ] ){
            return style[ name ];
        }
        return oldCurCSS(elem, 'backgroundPositionX', force) +' '+ oldCurCSS(elem, 'backgroundPositionY', force);
    };
}

var oldAnim = $.fn.animate;
$.fn.animate = function(prop){
    if('background-position' in prop){
        prop.backgroundPosition = prop['background-position'];
        delete prop['background-position'];
    }
    if('backgroundPosition' in prop){
        prop.backgroundPosition = '('+ prop.backgroundPosition + ')';
    }
    return oldAnim.apply(this, arguments);
};

function toArray(strg){
    strg = strg.replace(/left|top/g,'0px');
    strg = strg.replace(/right|bottom/g,'100%');
    strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
    var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
    return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
}

$.fx.step.backgroundPosition = function(fx) {
    if (!fx.bgPosReady) {
        var start = $.curCSS(fx.elem,'backgroundPosition');

        if(!start){//FF2 no inline-style fallback
            start = '0px 0px';
        }

        start = toArray(start);

        fx.start = [start[0],start[2]];

        var end = toArray(fx.end);
        fx.end = [end[0],end[2]];

        fx.unit = [end[1],end[3]];
        fx.bgPosReady = true;
    }

    var nowPosX = [];
    nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
    nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
    fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];
};
})(jQuery);