  	
	var d = document;

  	function getElement(id) { 
    	  if(d.all) {
      	    return d.all[id];
    	  } else if(d.getElementById) {
            return d.getElementById(id);
    	  } 
	}
	function toggle(id) {
	  getElement(id).style.display = (getElement(id).style.display!="block")? "block" : "none";
	}
	function hide(id) {
	  getElement(id).style.display = "none";
	}

	function getSkin( options_SelectedIndex ) {
	  var l = window.location.href, q_m = l.indexOf('?');
	  l = l.substring(0,q_m);
	  var v = "?skin=" + options_SelectedIndex;
	   // save skin in a cookie 
          setCookie("skin", options_SelectedIndex, 365);
	  //setAlert(options_SelectedIndex);
          //getElement('alerts').innerHTML = "&nbsp;Saved your new skin: <b>" + getCookie('skin') + "</b>";
	  location.replace(l+v);	  
	}

	function setAlert(text)
	{
  	  getElement('alerts').style.display = "block";
 	  getElement('alerts').className = "alertLoader";
 	  getElement('alerts').innerHTML = "Loading skin...";
 	  //getElement('alerts').innerHTML = "Loading skin: <b>" + text + "</b>";
	}

	function goPage(index) {
  	  if(!index) location.href="/index.php";
  	  else location.href="/index" + index + ".php";
	} 

	function getGame(folderPath) {
          location.href='/'+folderPath;
        }

      function show_menu()
      {	 
	if( !getElement('live').checked || getElement('q').value=="") return;
	getElement('targetDiv').style.display = "block";
      }

      function close_menu()
      {
	getElement('targetDiv').style.display = "none";
      }

      function load_box(term) 
      {	
  	getElement('q').value = term;
      }

      function fullscreen() { 
        var tags = d.getElementsByTagName('param');
	  for( var i = 0, tag; tag = tags[i]; i++ ) {
	    //if( tag && (tag.name=="movie"||tag.name=="src") && tag.value.match('.')) { 
	    if(tag.value.indexOf('swf')!=-1||tag.value.indexOf('dcr')!=-1) { 
	      var go = tag.value;
	      break;
	    }
	  }
	if(go) location.href = go; 
	else alert( 'This game can\'t play in full screen.' );
       }

if(window.attachEvent)
    window.attachEvent("onload",setListeners);

  function setListeners(){
    inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++){
      inputList[i].attachEvent("onpropertychange",restoreStyles);
      inputList[i].style.backgroundColor = "";
    }
    selectList = document.getElementsByTagName("SELECT");
    for(i=0;i<selectList.length;i++){
      selectList[i].attachEvent("onpropertychange",restoreStyles);
      selectList[i].style.backgroundColor = "";
    }
  }
  function restoreStyles(){
    if(event.srcElement.style.backgroundColor != "")
      event.srcElement.style.backgroundColor = "";
  }

      function handleKeyUpEvent(keyEvent) 
      { 
	if( !getElement('live').checked ) return;

	var e = encodeURIComponent? encodeURIComponent:escape;
        keyEvent = (keyEvent) ? keyEvent: window.event;
        input = (keyEvent.target) ? keyEvent.target : 
          keyEvent.srcElement;
        if (keyEvent.type == "keyup") {
          if (input.value) {
	    if(input.value.match(/[^a-zA-Z0-9 ]/gi)) return;
	      var datasource = "/data.php?qu="+e(input.value);
              getData(datasource);
          } 
          else {
            var targetDiv = getElement("targetDiv");
            targetDiv.innerHTML = "<div></div>";
          }
        }
      }

	var xobj = false; 
        if (window.XMLHttpRequest) {	
          xobj = new XMLHttpRequest();
        } else if (window.ActiveXObject) {
          xobj = new ActiveXObject("Microsoft.XMLHTTP");
        }

      function getData(dataSource)  {

        // var xobj = getXMLHttp();
        if(xobj) {
          xobj.open("GET", dataSource); 
          xobj.onreadystatechange = function() 
          { 
            if (xobj.readyState == 4 && 
              xobj.status == 200) { 		
		var xreq=xobj.responseText;
		xreq = xreq.substring(xreq.indexOf('('),xreq.lastIndexOf(')')+1);
		xreq = "getList"+xreq;
		eval(xreq);
            } 
          } 
          xobj.send(null); 
        }
      }

      function submitSearchForm(term) {
	var q = unescape(term);
	d.forms.f.q.value=q;
	d.forms.f.submit(); 
	return false;	
      }

      //function getList(someVar,listWord,listResult,someArray) 
      function getList(a) 
      {
	//alert(a);

	var words = new Array();
        var data = "<table width=433>";

        //var i = 1, item=1, results=2;
 	var i = 1; //, item = 1, results = 2;

	// gets the number of results returned from google api
  	var w_count = a? a[1].length : 0;

	//alert(w_count);

 	// targetDiv display
	getElement('targetDiv').style.display="inline";

        //if (listResult.length != 0 ) {

	if( w_count > 0 ) { 


 	words=arguments;

	for(var n = 0; n < arguments.length; n++) {

    	  for(var j = 0; j < w_count; j++)   { 

            //if( "undefined" == typeof(listResult[item])) { 
	      //close_menu();
	      //return;
            //}

            data += "<tr><td class=\"searchTerms\" nowrap>" +
            "<a class=\"searchTerms\" onclick=\"return submitSearchForm('"+ escape(words[n][1][j][0]) +"')\" href='http://www.google.com/custom?q=" + escape(words[n][1][j][0]) + "'>" + words[n][1][j][0] + "</a></td><td class=\"searchResults\" nowrap>" + words[n][1][j][1] + "</td></tr>";
	    i++;

	    //item++; item++;

	    //results++; results++;
          }

	}         

      }
	  show_menu();

	//else {
	 // close_menu();
	//}


        data += "</table>";
        var targetDiv = getElement("targetDiv");
        targetDiv.innerHTML = data;

}

      function getCookie(NameOfCookie){
        if (d.cookie.length > 0) {              
          begin = d.cookie.indexOf(NameOfCookie+"=");       
          if (begin != -1) {           
            begin += NameOfCookie.length+1;       
            end = d.cookie.indexOf(";", begin);
          if (end == -1) end = d.cookie.length;
            return unescape(d.cookie.substring(begin, end));
          } 
        }
      return null;
     }

     function setCookie(NameOfCookie, value, expiredays) {
       var ExpireDate = new Date(), domain = location.host; 
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
 	d.cookie = NameOfCookie + "=" + escape(value) + 
  	((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString() +"; path=/; domain=" + domain );
     }

var xmlhttp;

function showRSS(str,inp)
  {

  xmlhttp=GetXmlHttpObject();
  if (xmlhttp==null)
    {
    alert ("Your browser does not support XML HTTP Request");
    return;
    }
  var url="/getrss.php";

  url=url+"?q="+str+"&inp="+inp;
  //url=url+"?q="+str;

  url=url+"&sid="+Math.random();
  xmlhttp.onreadystatechange=stateChanged;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  }

function stateChanged()
  {
  if (xmlhttp.readyState==4)
    {
    document.getElementById("rssOutput").innerHTML=xmlhttp.responseText;
    }
  }

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

     window.onload = function() { 
	if( (!document.URL.match('/games/')) && document.referrer.indexOf('game-scape.com')==-1 ){ 
	  location.href='/games/monkeylander/';//random-game.php
	}
	 showRSS('GamingNews','console gaming');//source: Google,MSNBC, search query
     }
