function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function dropNav(id, obj, x, y) {
	
	if(navigator.userAgent.indexOf("Firefox")!=-1) {
		var versionindex=navigator.userAgent.indexOf("Firefox")+8
		if (parseInt(navigator.userAgent.charAt(versionindex))>=1) {
			y = y + 24;
			if (x == 177) // sub menu x's.. bad way of doing it
				y = y - 23;
		}
	}
	if(navigator.userAgent.indexOf("MSIE 6.0")!=-1) {
		y = y + 1;
	}
	
	var coors = findPos(obj);
	
	navBox = document.getElementById(id);
	navBox.style.left = (coors[0]-x) + 'px';
	navBox.style.top = (coors[1]-y) + 'px';
	navBox.style.display = 'inline';
}
function hideNav(id) {
	document.getElementById(id).style.display = 'none';
}
var dostop = 0;
function TOClose(seconds) {
	
	if (dostop == 0) {
		if (seconds > 0) {
			setTimeout( "TOClose("+(seconds - 1)+");" , 1000 );
		} else {
			var inc=0; 
			var alltags=document.all? document.all : document.getElementsByTagName("*"); 
			for (i=0; i<alltags.length; i++){ 
				if (alltags[i].className=='navDdMain' || alltags[i].className=='navDdSub') 
					alltags[i].style.display = 'none';
			}
			TOStop()
		}
	}

}
function CloseSub() {
	var inc=0; 
	var alltags=document.all? document.all : document.getElementsByTagName("*"); 
	for (i=0; i<alltags.length; i++){ 
		if (alltags[i].className=='navDdSub') 
			alltags[i].style.display = 'none';
	}
	TOStop()
}
function TOStop() {
	dostop = 1;
}
function TOGo(seconds) {
	dostop = 0;
	TOClose(3);
}

function bubble(obj, id, x, y) {
        var coors = findPos(obj);


        if(navigator.userAgent.indexOf("Firefox")!=-1) {
                var versionindex=navigator.userAgent.indexOf("Firefox")+8
                if (parseInt(navigator.userAgent.charAt(versionindex))>=1) {
                        y = y + 5;
		}
        }


        popupBox = document.getElementById(id);
	
	

        popupBox.style.left = (coors[0]-x) + 'px';
        popupBox.style.top = (coors[1]-y) + 'px';
        popupBox.style.display = 'inline';
}





function closeClass(name) {
	var alltags=document.all? document.all : document.getElementsByTagName("*"); 
	for (i=0; i<alltags.length; i++){ 
		if (alltags[i].className==name) 
			alltags[i].style.display = 'none';
	}
}

function closeId(name) {
	document.getElementById(name).style.display = 'none';
}

function displayFeatured(id) {
	hideFeatured();
	document.getElementById(id).style.display = 'inline';
		
	document.getElementById(id + "_tab").className = "tab selected";
	
}

function hideFeatured() {
	/*
	var alltags=document.all? document.all : document.getElementsByTagName("*"); 
	for (i=0; i<alltags.length; i++){ 
		if (alltags[i].className=='details') 
			alltags[i].style.display = 'none';
	} */
	// do it simpler / faster way
	var tabs = new Array("featured_shared", "featured_vps", "featured_colocation", "featured_dedicated");
	for (i = 0; i < tabs.length; i++) {
		document.getElementById(tabs[i]).style.display = 'none';
		document.getElementById(tabs[i]).className = 'details';
		document.getElementById(tabs[i] + "_tab").className = 'tab';
	}
}




function tab_select(select, total, srvtype, init) {
	var i = 1;
	for (i = 1; i <= total; i++) {
		document.getElementById("serv_tab_" + i + "s").className = 'serverTab';
		document.getElementById("serv_tab_" + i + "e").className = 'serverTabEnd';
	}
	document.getElementById("serv_tab_" + select + "s").className = 'serverTab tabOn';
	document.getElementById("serv_tab_" + select + "e").className = 'serverTabEnd tabEndOn';
	
	serverlist = getElementsByClassName(document, "div", "serverBox");
	for (i = 0; i < serverlist.length; i++) {
		serverlist[i].style.display = 'none';
	}
	
	servercycles = getElementsByClassName(document, "div", "srvCycle");
	for (i = 0; i < servercycles.length; i++) {
		//if (init == 0)
		//	hideCycles(servercycles[i].id)
	}
	
	serverlist = getElementsByClassName(document, "div", srvtype);
	for (i = 0; i < serverlist.length; i++) {
		serverlist[i].style.display = 'inline';
	}
}


/*
	Written by Jonathan Snook, http://www.snook.ca/jonathan
	Add-ons by Robert Nyman, http://www.robertnyman.com
*/
function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}


function getStockServer(page) {
	if (page == -1)
		return false;
	
	http_request = false;
	if (window.XMLHttpRequest) {
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Cannot create XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = function() {
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				stockServer = document.getElementById("serverStock");
				stockServer.innerHTML = http_request.responseText;
			} else {
				alert('There was a problem with the request.');
			}
		}
	};
	http_request.open('GET', 'server-stock.php?ajax=true&p=' + page, true);
	http_request.send(null);
	
	return false;
}


function displayInfo(id) {
	if (navigator.userAgent.toLowerCase().indexOf('msie') > -1) {
		document.getElementById(id + 'img').setAttribute('alt', '');
	}
	document.getElementById(id).style.display = 'block';
}
function hideInfo(id) {
	document.getElementById(id).style.display = 'none';
}

function map_select(location_id, obj) {
	document.getElementById("point_" + location_id).src = "/images/netmap/point.selected.png";
	
	var coors = findPos(obj);
	box = document.getElementById("info_" + location_id);
	box.style.left =  (coors[0]+30) + 'px';
	box.style.top = (coors[1]-15) + 'px';
	box.style.display = "inline";
}
function map_clear(location_id) {
	document.getElementById("point_" + location_id).src = "/images/netmap/point.png";
	document.getElementById("info_" + location_id).style.display = "none";
}

function mapm_select(location_id, obj) {
	document.getElementById("point_" + location_id).src = "/images/netmap/point-mini.selected.png";
	
	var coors = findPos(obj);
	box = document.getElementById("info_" + location_id);
	box.style.left =  (coors[0]+30) + 'px';
	box.style.top = (coors[1]-15) + 'px';
	box.style.display = "inline";
}
function mapm_clear(location_id) {
	document.getElementById("point_" + location_id).src = "/images/netmap/point-mini.png";
	document.getElementById("info_" + location_id).style.display = "none";
}



var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}
