/*@cc_on @*/
/*@if (@_win32)
document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
var script = document.getElementById("__ie_onload");
script.onreadystatechange = function() {
	if (this.readyState == "complete") {
		init(); // call the onload handler
	}
};
/*@end @*/

if (document.addEventListener) {
	document.addEventListener("DOMContentLoaded", init, false);
}

if (/WebKit/i.test(navigator.userAgent)) { // sniff
	var _timer = setInterval(function() {
		if (/loaded|complete/.test(document.readyState)) {
			clearInterval(_timer);
			init(); // call the onload handler
		}
	}, 10);
}
window.onload = init;
var FeatureTabs = Class.create()
FeatureTabs.prototype = {
	me:null,
	sections:null,
	tabs:null,
	elementId:"",
	initialize:function(el){
		me = this
		el = $(el)
		me.elementId = el.id
		me.sections = $$("#"+el.id+" .section");
		
		me.sections[0].className = "section-selected";
		selecetedSection = me.sections[0]
		me.tabs = $$("#"+el.id+" .tab-navigation a");
		
		me.tabs.each(function(tab){
			Event.observe(tab,"click",me.swapTabs);
			if(tab.href+"-section" == window.location+"#"+selecetedSection.id){
				tab.up().className = "selected";
				
			}
			Event.observe(tab,"mouseover",function(event){
				tab = Event.element(event).parentNode;	
				tab.originalCssClass = tab.className;
				tab.className = "selected";
			});
			Event.observe(tab,"mouseout",function(event){
				tab = Event.element(event).parentNode;
				tab.className = tab.originalCssClass;
				tab.originalCssClass = null;
			});
			tab.onclick = function(){return false;}
		});
	},
	swapTabs:function(event){
		tab = Event.element(event);
		while(tab.tagName != "A" && tab != document.body){
			tab = tab.parentNode;
		}
		selectedId = tab.href.slice(tab.href.lastIndexOf("#")+1);
		$(selectedId+"-section").className = "section-selected";
		tab.up().className = tab.up().originalCssClass = "selected";
		 
		me.sections.each(function(sec){
			if(sec.id != selectedId+"-section"){
				sec.className = "section";
			}
		});
		me.tabs.each(function(t){
			if(t != tab){
				t.up().className = "";
			}
		});
		/* wierd ie6 tech specs fix */
		if(document.all){
			specs = $$("#"+me.elementId+" .tech-section")
			specs.each(function(s){
				s.style.display = "block";
			});
			$(me.elementId).style.display = "none";
			$(me.elementId).style.display = "block";
		}
		Event.stop(event);
	}
	
}
function init() {
	// quit if this function has already been called
	if (arguments.callee.done) return;
	// flag this function so we don't do the same thing twice
	arguments.callee.done = true;
	document.body.className = "hasjs";
	if($("notes-product-features")){
		ft = new FeatureTabs("notes-product-features");
	}
};
