/*
* Slidorion, An Image Slider and Accordion Combined
* Intructions: http://www.slidorion.com
* Created by Ben Holland - http://www.ben-holland.co.uk
* Version: 0.94
* Copyright 2011 Ben Holland <benholland99@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function(a){a.fn.extend({slidorion:function(b){var c={autoPlay:true,easing:"",effect:"fade",first:"section1",interval:7e3,hoverPause:false,speed:1e3};var b=a.extend(c,b);return this.each(function(){function B(b){var c=a("#slider",s).outerHeight();var d=a("#slider",s).outerWidth();var e,f,g,h=0;var i=s.css("backgroundColor");a(".slider-image img",s).each(function(){e=a(this).outerHeight();f=a(this).outerWidth();g=(c-e)*.5;h=(d-f)*.5;a(this).css({"padding-top":g,"padding-bottom":g,"padding-left":h,"padding-right":h,"background-color":i,position:"absolute"});a(this).css({"z-index":l});l++});a('.slider-image[rel="'+b+'"] img',s).css({"z-index":l});l++}function A(){clearInterval(s.data("interval"));t=setInterval(function(){x(d,g,f,h)},i);s.data("interval",t)}function z(){clearInterval(s.data("interval"))}function y(){t=setInterval(function(){x(d,g,f,h)},i);s.data("interval",t)}function x(b,c,d,f){if(o==false){var g=b.substr(b.length-1);var h=s.data("slideCount")+1;g++;if(g==h){a('.slider-link[rel="section1"]',s).trigger("click",w)}else{e="section"+g;a('.slider-link[rel="'+e+'"]',s).trigger("click",w)}}}function w(){$objHeader=a(this,s);e=a(this,s).attr("rel");if(e==d){return false}else{if($objHeader.parent().next().is(":hidden")){a(".slider-link.active",s).removeClass("active").parent().next().slideUp();$objHeader.addClass("active").parent().next().slideDown()}v(d,e,g,f,h)}l++;d=e;return false}function v(b,c,d,e,f){if(!p&&q){A();$current=a('.slider-image[rel="'+b+'"] img',s);$new=a('.slider-image[rel="'+c+'"] img',s);var g=$current.outerWidth();var h=$current.outerHeight();switch(d){case"fade":$new.css({"z-index":l,display:"none"}).fadeIn(e);break;case"slideLeft":$new.css({left:g,opacity:"1"});$current.animate({left:"-="+g,top:"0",opacity:"1"},{queue:true,duration:e,easing:f});$new.animate({left:"-="+g,top:"0",opacity:"1"},{queue:true,duration:e,easing:f});break;case"slideRight":$new.css({left:"-"+g+"px",opacity:"1"});$current.animate({left:"+="+g,top:"0",opacity:"1"},{queue:true,duration:e,easing:f});$new.animate({left:"+="+g,top:"0",opacity:"1"},{queue:true,duration:e,easing:f});break;case"slideUp":$new.css({top:h,opacity:"1"});$current.animate({top:"-="+h,left:"0",opacity:"1"},{queue:true,duration:e,easing:f});$new.animate({top:"-="+h,left:"0",opacity:"1"},{queue:true,duration:e,easing:f});break;case"slideDown":$new.css({top:"-"+h+"px",opacity:"1"});$current.animate({top:"+="+h,left:"0",opacity:"1"},{queue:true,duration:e,easing:f});$new.animate({top:"+="+h,left:"0",opacity:"1"},{queue:true,duration:e,easing:f});break;case"overLeft":$new.css({left:g,top:"0",opacity:"1","z-index":l});$new.animate({left:"-="+g,top:"0",opacity:"1"},{queue:true,duration:e,easing:f});break;case"overRight":$new.css({left:"-"+g+"px",top:"0",opacity:"1","z-index":l});$new.animate({left:"+="+g,top:"0",opacity:"1"},{queue:true,duration:e,easing:f});break;case"overUp":$new.css({top:h,left:"0",opacity:"1","z-index":l});$new.animate({top:"-="+h,left:"0",opacity:"1"},{queue:true,duration:e,easing:f});break;case"overDown":$new.css({top:"-"+h+"px",left:"0",opacity:"1","z-index":l});$new.animate({top:"+="+h,left:"0",opacity:"1"},{queue:true,duration:e,easing:f});break;case"none":$new.css({"z-index":l});break}}}var c=b;var d=c.first;var e="";var f=c.speed;var g=c.effect;var h=c.easing;var i=c.interval;var j=c.hoverPause;var k=c.autoPlay;var l=1;var m=0;var n=0;var o=false;var p=false;var q=false;var r="";var s=a(this);if(m==n){a(".slider-image",s).each(function(){m++;s.data("slideCount",m)});a(".slider-link",s).each(function(){n++;s.data("accordCount",n)});if(k==true){var t=setInterval(function(){x(d,g,f,h)},i);s.data("interval",t)}if(j==true&&k==true){s.hover(function(){o=true;z()},function(){o=false;y()})}var u=a(".slider-link",s);a(".content",s).hide();a('.header a[rel="'+d+'"]',s).addClass("active").parent().next().show();B(d);u.click(w)}else{console.log("The number of slider images does not match the number of accordion sections.")}a(window).load(function(){q=true})})}})})(jQuery)
