//////////////////////////////////////////////////////
//shortcut functions reused throughout the site
//////////////////////////////////////////////////////
var d = document;

//shortcut for dom createElement
function dce(obj) {
 return d.createElement(obj);
}

//shortcut for dom getElementById
function ge(objID) {
 return d.getElementById(objID);
}

//shortcut for dom getElementById
function gt(ele, objID) {
 return ele.getElementsByTagName(objID);
}

//shortcut to delete stuff in area
function delete_stuff(objID) {
if (objID.hasChildNodes())
	{
		while( objID.firstChild ) {
    	//delete all the stat info 
    	objID.removeChild( objID.firstChild );
		}
	}
}

//shortcut for adding slashes
function addslashes(str) {
str=str.replace(/\'/g,'\\\'');
str=str.replace(/\"/g,'\\"');
str=str.replace(/\\/g,'\\\\');
str=str.replace(/\0/g,'\\0');
return str;
}

//shortcut for getting the text of an element
function so_getText(obj) {
 if(obj.textContent) return obj.textContent;
 if (obj.nodeType == 3) return obj.data;
 var txt = new Array(), i=0;
 while(obj.childNodes[i]) {
  txt[txt.length] = so_getText(obj.childNodes[i]);
  i++;
 }
    return txt.join("");
}

//shortcut for XMLHttpRequest calls
function ajax_call() {
//server update code
http_request = false;

        // Mozilla/Safari
        if (window.XMLHttpRequest) {
                http_request = new XMLHttpRequest();
                http_request.overrideMimeType('text/xml');
        }
        // IE
        else if (window.ActiveXObject) {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
        }


        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
}

//shortcut function for multiple window onloads
function addLoadEvent(func) {
var oldonload = window.onload;
if(typeof window.onload != 'function') {
	window.onload = func;
} else {
window.onload = function() {
	oldonload();
	func();
}
}
}


//menu operating function
function menu_replace(){
var mu_area = ge('menu_area')
var atags = gt(mu_area, 'a')
var LItags = gt(mu_area, 'li')
var li_text = d.createTextNode('Games')
atags[1].onclick = function() {
	LItags[1].replaceChild(li_text, LItags[1].firstChild);
	//need line for IE
	ge('menu_area2').style.visibility = 'visible';
	ge('menu_area2').setAttribute('id', 'menu_area2v');
	
	return false;
	}
}
addLoadEvent(menu_replace)




function stat_detail(ip, id) {
tsub = ge('tsub_'+id);
topt = tsub.className;

if(topt == 's_hide') {
ge('o'+id).style.backgroundColor = "#036";
ge('o'+id).style.color = "#ffffff";
tsub.className = 's_show';
stat_load(ip, id)
} else {
ge('o'+id).style.backgroundColor = "";
ge('o'+id).style.color = "#000000";
tsub.className = 's_hide';
}


}

function stat_load(ip, id) {
csub = ge('csub_'+id);
ajax_call()

var url = 'http://www.gamerzlink.com/templates/php/stats_code.php';
http_request.onreadystatechange = alertContents;
http_request.open('POST', url, true);
http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
http_request.send('ip=' + ip + '&sld=' + id + '&act=detail');

function alertContents() {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
			csub.innerHTML = http_request.responseText;
   
            } else {
                alert('There was a problem with the request.');
            }
        }
		
}

}