function createXmlHttpRequestObject()
{
        var xmlHttp;
        try
        {
                xmlHttp = new XMLHttpRequest();
        }
        catch(e)
        {
                var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
                "MSXML2.XMLHTTP.5.0",
                "MSXML2.XMLHTTP.4.0",
                "MSXML2.XMLHTTP.3.0",
                "MSXML2.XMLHTTP",
                "Microsoft.XMLHTTP");
                for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
                {
                        try
                        {
                                xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
                        }
                        catch (e) {}
                }
        }
        if (!xmlHttp) alert("Error creating the XMLHttpRequest object.");
        else return xmlHttp;
}
var myRequest = createXmlHttpRequestObject();
function rate(r, gameid, baseurl) {
		var url = baseurl+"includes/insertrating.php?rank="+r+"&gameid="+gameid;
		var myRandom=parseInt(Math.random()*99999999);
		myRequest.open("GET", url + "&rand=" + myRandom, true);
		myRequest.onreadystatechange = vmTest;
		myRequest.send(null);
		return true;
	}
	
	function vmTest() {
    if(myRequest.readyState == 4) {
        if(myRequest.status == 200) {
        	var data = myRequest.responseText;
        	document.getElementById('ratings').innerHTML = data;
        	//alert (data);
        } else {
            alert("An error has occurred: " + myRequest.statusText);
        }
    } 
}


function popUp(URL){
winpops=window.open(URL,"","width=320,height=240,left=100,top=100,status=0,scrollbars=0,resizable=1,menubar=0,location=0,toolbar=0")
}
function popUp2(URL){
winpops=window.open(URL,"","width=400,height =250,left=100,top=100,status=0,scrollbars=0,resizable=1,menubar=0,location=0,toolbar=0")
}

function popUp3(URL){
winpops=window.open(URL,"","width=640,height =480,left=100,top=100,status=0,scrollbars=1,resizable=0,menubar=0,location=0,toolbar=0")
}

function popUpFavorite(URL){
winpops=window.open(URL,"","width=200,height=100,left=100,top=100,status=0,scrollbars=0,resizable=1,menubar=0,location=0,toolbar=0")
}

function popUpHelp(URL){
winpops=window.open(URL,"","width=640,height=480,left=100,top=100,status=1,scrollbars=1,resizable=1,menubar=0,location=0,toolbar=0")
}
function popUpTerms(URL){
winpops=window.open(URL,"","width=640,height=480,left=100,top=100,status=0,scrollbars=1,resizable=0,menubar=0,location=0,toolbar=0");
}

function popComments(URL){
winpops=window.open(URL,"","width=440,height=400,left=100,top=100,status=0,scrollbars=1,resizable=1,menubar=0,location=0,toolbar=0");
}

function popReportGame(URL){
winpops=window.open(URL,"","width=250,height=225,left=100,top=100,status=0,scrollbars=0,resizable=1,menubar=0,location=0,toolbar=0")
}

function confirmAction(url,msg)
{
 var where_to= confirm(msg);
 if (where_to== true)
 {
   window.location=url;
 }
}

function textCounter (field, countfield, maxlimit)
{
	if (field.value.length > maxlimit)
	field.value = field.value.substring(0, maxlimit);
	else
	countfield.value = maxlimit - field.value.length;
}

function fullScreen(theURL) {
window.open(theURL, '', 'fullscreen=yes, scrollbars=auto, status=1,scrollbars=1,resizable=1,menubar=0,location=0,toolbar=0');
}

function switchMenu(obj) {
var el = document.getElementById(obj);
if ( el.style.display != 'none' ) {
el.style.display = 'none';
}
else {
el.style.display = '';
}
}



// Nannette Thacker http://www.shiningstar.net
function confirmDeleteMessage()
{
var agree=confirm("Are you sure you wish to delete this message?");
if (agree)
	return true ;
else
	return false ;
}


function FullScreen(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
  var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
  var int_windowTop = (screen.height - a_int_windowHeight) / 2;
  var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
  var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
    if (parseInt(navigator.appVersion) >= 4) {
      obj_window.window.focus();
    }
}

//===========================================================================
// YouTube Functions
//===========================================================================
function showInline (elName) {
	var theElemenet = document.getElementById(elName);
	if (theElemenet) {
		theElemenet.style.display = "inline";
	}
}
function hideInline (elName) {
	var theElemenet = document.getElementById(elName);
	if (theElemenet) {
		theElemenet.style.display = "none";
	}
}
