/*
 * @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(e){var g,d,b=75;var f={activeOptionClass:"active",dropdownClass:"dropdown",selectedClass:"selected",controlClass:"toggleControl",controls:{persistent:false,next:null,previous:null}};var a={updateCtrl:function(){var k=e(this),j=k.data("options");if(!j.controls.persistent){var i=e(j.dropdown).find("a");var h=0;e.each(i,function(l,m){if(null!=e(m).attr("class")&&e(m).attr("class")==="active"){h=l;return false}});if(null!=j.controls.next){if(h>=(i.length-1)){e(j.controls.next).parent().css("display","none")}else{e(j.controls.next).parent().css("display","block")}}if(null!=j.controls.previous){if(h<=0){e(j.controls.previous).parent().css("display","none")}else{e(j.controls.previous).parent().css("display","block")}}}},poll:function(){var i=e(this),h=i.data("options");d=setInterval(function(){if(location.hash!==g){g=(null==g)?location.hash:g;var l=location.hash;var k=l.substring(6,l.length);var j=e(i).find("."+h.dropdownClass+' a[href="'+k+'"]').get(0);if(null!=j){var n=g.substring(6,g.length);g=l;c.active.apply(i,[j,true]);top.frames[e(h.iframe).attr("name")].location.replace(k);a.updateCtrl.apply(i);if(n!=k){e(h.iframe).trigger("change.switcher",[n,k,j])}}else{if((!e.browser.webkit&&!e.browser.opera)||typeof location.replace!=="function"){try{var o=e(i).find("."+h.dropdownClass+" a."+h.activeOptionClass).get(0)||i.find(".dropdown a").get(0);c.fragment.apply(i,[o,false]);throw new Error("The specified URL could not be loaded because it is not in the switcher dropdown option list!")}catch(m){alert(m.message)}}else{if(k==="undefined"){var o=e(i).find("."+h.dropdownClass+" a."+h.activeOptionClass).get(0)||i.find(".dropdown a").get(0);c.fragment.apply(i,[o,false])}throw new Error("The specified URL could not be loaded because it is not in the switcher dropdown option list!")}}}},b)}};var c={init:function(h){return this.each(function(){var k=e(this),j=k.data("options");if(null==h){h={}}if(null==e(h.iframe)||null==e(h.iframe).attr("name")||e(h.iframe).attr("name")==""){throw new Error('You must specify an iframe element with a "name" attribute!')}h=e.extend({},f,h);h=e.extend({},h,{selected:e(k).find("."+h.selectedClass).get(0),dropdown:e(k).find("."+h.dropdownClass).get(0),control:e(k).find("."+h.controlClass).get(0)});if(null==h.dropdown){throw new Error('No dropdown element with the specified class name "'+h.dropdownClass+'" could be found inside the specified switcher element!')}if(null==h.selected){throw new Error('No element for the selected switcher option, with the specified class name "'+h.selectedClass+'", could be found inside the specified switcher element!')}if(null==h.control){throw new Error('No element for the switcher toggle control, with the specified class name "'+h.controlClass+'", could be found inside the specified switcher element!')}if(!j){e(k).data("options",h)}a.poll.apply(k);if(location.hash==""){var i=e(k).find("."+h.dropdownClass+" a."+h.activeOptionClass).get(0)||k.find(".dropdown a").get(0);if(null==i){throw new Error("Could not find any list of links/options to make active!")}else{c.fragment.apply(k,[i])}}else{resource=location.hash;linkToLoad=resource.substring(6,resource.length);var l=k.find('.dropdown a[href="'+linkToLoad+'"]').get(0);c.fragment.apply(k,[l,false])}e(h.dropdown).find("a").click(function(m){m.preventDefault();c.show.apply(k,[false]);c.fragment.apply(k,[e(this)])});e(h.iframe).load(function(){clearInterval(d);j=k.data("options");c.active.apply(k,[e(k).find("."+j.dropdownClass+" a."+j.activeOptionClass).get(0),false]);a.poll.apply(k)})})},active:function(i,h){return this.each(function(){var k=e(this),j=k.data("options");var l=e(k).find("."+j.dropdownClass+" a."+j.activeOptionClass).get(0);if(null!=l){e(l).removeClass("active")}if(!h){e(j.selected).html(e(i).clone(false))}else{e(j.selected).html('<img src="img/loader.gif" style="margin-left: 100px; margin-top: 12px;" />')}e(i).addClass("active")})},fragment:function(h,i){return this.each(function(){var k=e(this),j=k.data("options");var l=location.hash;i=(null==i)?true:i;if(l==""||!i){location.replace("#load="+e(h).attr("href"))}else{if(l!=e(h).attr("href")){location.hash="load="+e(h).attr("href")}}})},show:function(h){return this.each(function(){var j=e(this),i=j.data("options");e(i.dropdown).css("display",(h)?"block":"none");e(i.dropdown).trigger("toggle.switcher",[h])})},control:function(){var i=e(this),h=i.data("options");c.show.apply(i,[(e(h.dropdown).css("display")==="none")?true:false]);e(document).bind("click",function(){if(e(h.dropdown).css("display")!="none"){c.show.apply(i,[false])}})},previous:function(){var i=e(this),h=i.data("options");e.each(e(h.dropdown).find("li a"),function(k,l){if(e(l).attr("class")=="active"){var j=e(h.dropdown).find("li a")[k-1];if(null!=j){c.fragment.apply(i,[j])}return false}})},next:function(){var i=e(this),h=i.data("options");e.each(e(h.dropdown).find("li a"),function(k,l){if(e(l).attr("class")=="active"){var j=e(h.dropdown).find("li a")[k+1];if(null!=j){c.fragment.apply(i,[j])}return false}})}};e.fn.switcher=function(h){if(top!==self){top.location.replace(self.location.href)}if(c[h]){return c[h].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof h==="object"||!h){return c.init.apply(this,arguments)}else{throw new Error("Method "+h+" does not exist on jQuery.switcher")}}}})(jQuery);
