// JavaScript Document 

var notIndex = true;
document.getElementsByClassName = function(cl) {
	var retnode = [];
	var myclass = new RegExp('\\b'+cl+'\\b');
	var elem = this.getElementsByTagName('*');
		for (var i = 0; i < elem.length; i++) {
			var classes = elem[i].className;
			if (myclass.test(classes)) retnode.push(elem[i]);
		}
	return retnode;
};
startList = function() {
	
	var all_hovers = document.getElementsByClassName ("infstarsroot");
		for (var i = 0; i < all_hovers.length; i++ )		{
			all_hovers[i].onmouseover = function ()	{
				this.className = "infstarsrootover";
			}
			all_hovers[i].onmouseout = function ()	{
				this.className = "infstarsroot";
			}
		}
	if (document.all&&document.getElementById) {
		try {
			navRoot = document.getElementById("nav");
		
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" over";
					}
					node.onmouseout=function() {
						this.className=this.className.replace("over", "");
					}
				}
			}
		}catch (e) {}

	}

	
// TOOLTIP - Added at: 10-07-2008 by despark 
// sample 
//  <a href="" class="singlehop_tooltip_action" lang="<b>Included</b><p>Overview gives point-in-time<br/>snapshots of the delegate race.<br/>Click on dates for different views</p>"
	
	var singlehop_tooltip_elements = document.getElementsByClassName("singlehop_tooltip_action");
	
	for (var i = 0; i < singlehop_tooltip_elements.length; i++)	{
		singlehop_tooltip_elements[i].onmouseover = function (e)	{

		//var posx = 0;if (!e) var e = window.event;if (e.pageX) {posx = e.pageX;} else if (e.clientX) {posx = e.clientX + document.body.scrollLeft+document.documentElement.scrollLeft;}
		
		 if (!e) e = window.event;
		
		 if (e)
		 {
		   if (e.pageX || e.pageY)
		   {
		     mousex = e.pageX;
		     mousey = e.pageY;
		     algor = '[e.pageX]';
		     if (e.clientX || e.clientY) algor += ' [e.clientX] '
		   }
		   else if (e.clientX || e.clientY)
		   {
		     mousex = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		     mousey = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
		     algor = '[e.clientX]';
		     if (e.pageX || e.pageY) algor += ' [e.pageX] '
		   }
		 }		
			
			this.windowChild = document.createElement("div");
			this.windowChild.innerHTML = '<div class="singlehop_tooltip_right"><div class="singlehop_tooltip_realcontent">' + this.lang + '</div></div>';
			this.windowChild.className = "singlehop_tooltip_content";
			this.windowChild.style.display = "block";
			window.document.body.appendChild(this.windowChild);
			this.windowChild.style.left = (mousex - 33) + "px";
			this.style.cursor = "pointer";
			this.windowChild.style.top = (mousey - 115) + "px";
			
		}
		singlehop_tooltip_elements[i].onmouseout = function ()	{
			if (this.windowChild)	{
				try {
					this.style.cursor = "default";
					window.document.body.removeChild(this.windowChild);
				} catch (e) {}
			}
		}
	}	
	// End of tooltip code
	
	
	if (document.all&&document.getElementById) {
		
		navRoot = document.getElementById("generalnavigation");
		
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace("over", "");
				}
			}
		}
		
	}
	
	if (document.getElementById("beforeAndAfter") && document.getElementById("beforeAndAfternav"))	{
		var ind = 0;
		
		var beforeAndAfterDiv = document.getElementById ("beforeAndAfter").childNodes;
		var beforeAndAfternavs = document.getElementById("beforeAndAfternav").childNodes;
		
		
		for (var i =0; i < beforeAndAfternavs.length; i++)	{
			if (beforeAndAfternavs[i].tagName == "LI")	{
				beforeAndAfternavs[i].tmp = ind++;
				beforeAndAfternavs[i].onclick = function ()	{
					for ( var j =0; j < beforeAndAfternavs.length; j++)	{
						if (beforeAndAfternavs[j].tagName == "LI")	{
							beforeAndAfternavs[j].firstChild.className = "";						
						}
					}
					this.firstChild.className ="open";
					changeTabToThis(this.tmp);
				}
			}
		}
		function changeTabToThis(num)	{
			$tmp = new Array();
			for (var i =0 ; i < beforeAndAfterDiv.length; i++ )	{
				if (beforeAndAfterDiv[i].tagName == "UL" && beforeAndAfterDiv[i].id != 'beforeAndAfternav')	{
					$tmp.push(beforeAndAfterDiv[i]);
					beforeAndAfterDiv[i].style.display = "none";
				}
			}
			if ($tmp[num])	{
				$tmp[num].style.display = "block";
			}
			
		}
	}
	
	
		//console.info($$('div.auto_align_tooltips'),'test');
		
		captureHover();
		
		
//		if ($('auto_align_tooltips'))	{
//			//var lis = $('auto_align_tooltips').getElementsByTagName("li");
//			$('#auto_align_tooltips li a').each(function(){
//				console.info(this);
//			})
//
//		}	
	
}

	var getWindowDimensions = function ()	{
		var dimensions = {width: 0, height: 0};
		if (document.documentElement)	{
			dimensions.width = document.documentElement.clientWidth;
			dimensions.height = document.documentElement.clientHeight;
		}
	   return dimensions;
	}
	
function captureHover()	{

	
	if (document.getElementById('auto_align_tooltips'))	{
		
		////console.info(getWindowDimensions());
		var dim = getWindowDimensions();

		var lis = document.getElementById('auto_align_tooltips').getElementsByTagName('li');
		
			var a = {};
		
			for( var i = 0 ; i < lis.length; i++)	{

				a[i] = {};
				a[i] = lis[i].getElementsByTagName("a")[0];
				if (typeof(a[i]) == 'undefined') continue;
				a[i].onmouseover = function (e)	{
					if (document.all)	{
						if ((event.clientX + 269 ) > dim.width)	{
						this.parentNode.className = 'rotated_tip';
						}	else	{
						this.parentNode.className = '';	
						}
					} else if (e.clientX || e.clientY)	{
						if ( ( e.pageX  + 269 ) > dim.width )	{
						this.parentNode.className = 'rotated_tip';
						}	else	{
						this.parentNode.className = '';	
						}						
					}
					this.parentNode.style.zIndex = '100';
					this.className = 'show_tip_over';
				}
				a[i].onmouseout = function (e)	{
					this.className = 'show_tip';
					this.parentNode.style.zIndex = '5';
				}

			}
	}
}

var v = new Array ('currentServerDetails','managedServerstab','managedOptionstab','whySinglehoptab','aboutSinglehoptab','supportCentertab');
changeView = function(o) {
	var ul = document.getElementById("generalnavigation").getElementsByTagName("a");
	var navFlag = document.getElementById('navigation').className == 'darkheader';
	for(var i = 0; i < ul.length; i++) {
		(function (i) {
			ul[i].onmouseover = function (  ) {
			 
				clearInfo();
				this.className = "open";
				document.getElementById(v[this.tabId]).style.display="block";
				if(navFlag)
				document.getElementById('navigation').className = (i==0) ? "darkheader":"";
			};
			ul[i].tabId = i;
		})(i);
	}
}
clearInfo = function() {
	var ul = document.getElementById("generalnavigation").getElementsByTagName("a");
	for(var i=0;i<ul.length;i++) {
		ul[i].className = "";
		document.getElementById(v[i]).style.display="none";
	}
}

		var onl = window;
		if( onl.addEventListener ) {
  			onl.addEventListener('load',startList,false);
		} else if ( onl.attachEvent ) {
  			onl.attachEvent('onload',startList);
		} else {onl.onload = startList;}

//window.onload = startList;

