/*
 * @author			Daniyal Hamid
 * 
 * @license			This JavaScript file is a commercial file, available for purchase at 
 *					http://codecanyon.net/user/daniyal/portfolio. Any illegal copying, 
 *					distribution, packaging or re-production of this script for commercial or 
 *					personal use is strictly prohibited and will be considered theft.
 *
 * @copyright		The author is the first owner of copyright and reserves all rights to
 *					all written work contained in this file. Distribution, re-production
 *					or commercial use of the written work in this file, without the author's 
 * 					signed permission, prior consent or a valid license, is strictly prohibited.
 *					The author is protected by the "Copyright, Designs and Patents Act 1988" of 
 *					the United Kingdom. Any infringement of the copyright, in or outside of the
 *					United Kingdom, may result in a lawsuit.
 */


(function(b){var c={activeOptionClass:"active",loaderClass:"loader",loaderSrc:"img/loader.gif",loaderAlt:"Loading...",selectedClass:"selected",dropdownClass:"dropdown"};var a={init:function(d){return this.each(function(){var g=b(this),f=g.data("options");if(null==d){d={}}d=b.extend({},c,d);d=b.extend({},d,{selected:b(g).find("."+d.selectedClass).get(0),dropdown:b(g).find("."+d.dropdownClass).get(0)});if(null==d.selected){throw new Error('No element for the selected switcher option, with the specified class name "'+d.selectedClass+'", could be found inside the specified switcher element!')}if(null==d.dropdown){throw new Error('No dropdown element with the specified class name "'+d.dropdownClass+'" could be found inside the specified switcher element!')}if(null!=d.loaderSrc){var e=new Image();e.src=d.loaderSrc;e.alt=d.loaderAlt;b(e).addClass(d.loaderClass);d.loader=e;delete d.loaderSrc;delete d.loaderAlt;delete d.loaderClass}else{d.loader='<p class="'+d.loaderClass+'">'+d.loaderAlt+"</p>";delete d.loaderAlt}if(!f){b(g).data("options",d)}b(d.dropdown).find("a").bind("click",function(j){j.preventDefault();var i=b(j.target).get(0);if(b(i).get(0).tagName.toLowerCase()!=="a"){i=b(i).children("a").get(0)||b(i).parent("a").get(0)}if((i.tagName.toLowerCase())==="a"){a.show.apply(g,[false]);a.active.apply(g,[i,(b(i).attr("href").indexOf("#")==-1)?true:false]);location.href=b(i).attr("href")}});var h=a.active.apply(g);if(null==h){throw new Error('You must specify the "active" class for the links inside the "dropdown" list!')}a.active.apply(g,[h,false])})},active:function(e,d){var g=b(this),f=g.data("options");var h=b(g).find("."+f.dropdownClass+" a."+f.activeOptionClass).get(0);if(null==e){if(null!=h){return h}else{throw new Error("No active link found in the switcher dropdown list.")}}if(null!=h){b(h).removeClass(f.activeOptionClass)}if(!d){b(f.selected).html(b(e).clone(false))}else{b(f.selected).html(f.loader)}b(e).addClass(f.activeOptionClass)},show:function(d){var f=b(this),e=f.data("options");if(null==d){return((b(e.dropdown).css("display")=="none")?false:true)}b(e.dropdown).css("display",(d)?"block":"none");b(e.dropdown).trigger("toggle.switcher",[d])},toggle:function(){return this.each(function(){var e=b(this),d=e.data("options");var f=a.show.apply(e);a.show.apply(e,[(f)?false:true])})}};b.fn.switcher=function(d){if(a[d]){return a[d].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof d==="object"||!d){return a.init.apply(this,arguments)}else{throw new Error("Method "+d+" does not exist on jQuery.switcher")}}}})(jQuery);
