User:Denmax/Page.js

/*From WindPower*/

var Tabs = { switchDuration: 400, selectorDuration: 200, inactiveOpacity: 0.25, hoverOpacity: 0.6, tab1: null, tab2: null, tab3: null, tab1Selector: null, tab2Selector: null, tab3Selector: null, selected: 1, hoverTab:function(tab) { if(tab == Tabs.selected) return; if(tab == 1) Tabs.tab1Selector.animate({opacity: Tabs.hoverOpacity}, Tabs.selectorDuration); if(tab == 2) Tabs.tab2Selector.animate({opacity: Tabs.hoverOpacity}, Tabs.selectorDuration); if(tab == 3) Tabs.tab3Selector.animate({opacity: Tabs.hoverOpacity}, Tabs.selectorDuration); },	unhoverTab:function(tab) { if(tab == Tabs.selected) return; if(tab == 1) Tabs.tab1Selector.animate({opacity: Tabs.inactiveOpacity}, Tabs.selectorDuration); if(tab == 2) Tabs.tab2Selector.animate({opacity: Tabs.inactiveOpacity}, Tabs.selectorDuration); if(tab == 3) Tabs.tab3Selector.animate({opacity: Tabs.inactiveOpacity}, Tabs.selectorDuration); },	changeTab:function(tab) { if(tab == Tabs.selected) return; if(Tabs.selected == 1) { Tabs.tab1.hide(Tabs.switchDuration); Tabs.tab1Selector.animate({opacity: Tabs.inactiveOpacity}, Tabs.selectorDuration); }		if(Tabs.selected == 2) { Tabs.tab2.hide(Tabs.switchDuration); Tabs.tab2Selector.animate({opacity: Tabs.inactiveOpacity}, Tabs.selectorDuration); }		if(Tabs.selected == 3) { Tabs.tab3.hide(Tabs.switchDuration); Tabs.tab3Selector.animate({opacity: Tabs.inactiveOpacity}, Tabs.selectorDuration); }		Tabs.selected = tab; if(tab == 1) { Tabs.tab1.show(Tabs.switchDuration); Tabs.tab1Selector.animate({opacity: 1}, Tabs.selectorDuration); }		if(tab == 2) { Tabs.tab2.show(Tabs.switchDuration); Tabs.tab2Selector.animate({opacity: 1}, Tabs.selectorDuration); }		if(tab == 3) { Tabs.tab3.show(Tabs.switchDuration); Tabs.tab3Selector.animate({opacity: 1}, Tabs.selectorDuration); }	},	init: function { Tabs.tab1 = $('#windpower-content-1'); Tabs.tab1Selector = $('#windpower-selector-1').click(function{Tabs.changeTab(1); return false;}).css('opacity', 1); Tabs.tab1Selector.hover(function{Tabs.hoverTab(1);}, function{windTabs.unhoverTab(1);}); Tabs.tab2 = $('#windpower-content-2'); Tabs.tab2Selector = $('#windpower-selector-2').click(function{Tabs.changeTab(2); return false;}).css('opacity', Tabs.inactiveOpacity); Tabs.tab2Selector.hover(function{Tabs.hoverTab(2);}, function{Tabs.unhoverTab(2);}); Tabs.tab3 = $('#windpower-content-3'); Tabs.tab3Selector = $('#windpower-selector-3').click(function{Tabs.changeTab(3); return false;}).css('opacity', Tabs.inactiveOpacity); Tabs.tab3Selector.hover(function{Tabs.hoverTab(3);}, function{Tabs.unhoverTab(3);}); } }; Tabs.init;