document.i=1;

function testie(div)
{

if (navigator.appName=="Microsoft Internet Explorer")
{

document.x=1;
document.inc = 44;
document.inc2=15;
if (!document.i || document.i==1)
document.i=27;
}
else
{
document.inc = 15;
document.inc2=5;
document.x=5;
}

if (!document.box  )
{
        document.box= document.getElementById(div);

}
  box= document.box;
if (!document.thing)
{
   document.thing = parseInt(box.style.width,10)+document.i + 'px';
    document.thing2 = parseInt(box.style.height,10)+document.i + 'px';

 }
 else {
 document.thing = parseInt(box.style.width,10)+document.inc+'px';
 document.thing2 = parseInt(box.style.height,10)+document.inc2+'px';
 }  
 if (document.i<=40)
 {
 
    setTimeout("box.style.width=document.thing;box.style.height=document.thing2",document.x);

    document.i++;
 setTimeout("testie();",document.x+1);
  }
 
    }

window.onload=function()
{

setTimeout(function() { document.initialhtml=document.getElementById("register").innerHTML},100);
//setTimeout(function () { document.getElementById("registerlink").href="javascript:void(0)"; },200);
//setTimeout(function() { document.getElementById("loginlink").href="javascript:void(0)";},210);
}



    
function grayOut(vis,div, options) {
document.box= null;
document.i=null;
document.thing=null;
document.test=null;
  // Pass true to gray out screen, false to ungray
  // options are optional.  This is a JSON object with the following (optional) properties
  // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
  // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
  // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
  // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
  // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
  // in any order.  Pass only the properties you need to set.
  var options = options || {}; 
  var zindex = options.zindex || 50;
  var opacity = options.opacity || 70;
  var opaque = (opacity / 100);
  var bgcolor = options.bgcolor || '#000000';
  var dark=document.getElementById('darkenScreenObject');
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
    var tbody = document.getElementsByTagName("body")[0];
    var tnode = document.createElement('div');           // Create the layer.
        tnode.style.position='absolute';                 // Position absolutely
        tnode.style.top='0px';                           // In the top
        tnode.style.left='0px';                          // Left corner of the page
        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
        tnode.style.display='none';                      // Start out Hidden
        tnode.id='darkenScreenObject';                   // Name it so we can find it later
    tbody.appendChild(tnode);                            // Add it to the web page
    dark=document.getElementById('darkenScreenObject');  // Get the object.
   
  }
  if (vis) {
    // Calculate the page width and height 
    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
        var pageWidth = document.body.scrollWidth+'px';
        var pageHeight = document.body.scrollHeight+'px';
    } else if( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = document.body.offsetHeight+'px';
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
    }   
    //set the shader to cover the entire page and make it visible.
    dark.style.opacity=opaque;                      
    dark.style.MozOpacity=opaque;                   
    dark.style.filter='alpha(opacity='+opacity+')'; 
    dark.style.zIndex=zindex;        
    dark.style.backgroundColor=bgcolor;  
    dark.style.width= screen.width + "px";
    dark.style.height= screen.height + "px";
    dark.style.display='block';    

    document.getElementById(div).style.display="block";
    document.getElementById(div).style.zIndex="999";
   testie(div);
      if (navigator.appName=="Microsoft Internet Explorer")
      timez=2000;
      else timez=1000;
       // setTimeout("document.getElementById('" + div + "').innerHTML+=\"<span style='position:absolute;left:0px;top:192px;width:603px;font-size:25pt;height:40px;background-color:black;color:white'>" + div + " Box</span>\";",timez);
  } else {
     dark.style.display='none';
  }
}
var xmlHttp;

function continueZ()
{
document.getElementById("register").style.height='550px';
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="check.php"

url=url+"?name="+document.getElementById("name").value;
url=url+"&password="+document.getElementById("password").value;
url=url+"&email="+document.getElementById("email").value;
url=url+"&age="+document.getElementById("age").value;
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("register").innerHTML=xmlHttp.responseText 
 } 
  else
 {
document.getElementById('register').innerHTML="<img class='x' src='images/loading.gif' />";
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}


/*function continue2()
{

for (i=0;i<document.forms[0].player.length;i++) {
	if (document.forms[0].player[i].checked) {
		playerimg = document.forms[0].player[i].value;
	
	}
}
for (i=0;i<document.forms[0].pokemon.length;i++) {
	if (document.forms[0].pokemon[i].checked) {
		pokemon = document.forms[0].pokemon[i].value;
	
	}
}


xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }


url="name="+encodeURI(document.getElementById("name").value);
url=url +"&password="+encodeURI (document.getElementById("password").value);
url=url +"&email="+encodeURI(document.getElementById("email").value);
url=url +"&age="+encodeURI(1);
url=url +"&pokemon="+encodeURI(pokemon);
url=url +"&player="+encodeURI(playerimg);
alert(url);
xmlHttp.onreadystatechange=stateChanged;
//xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    // xmlHttp.setRequestHeader("Content-length", url.length);
     // xmlHttp.setRequestHeader("Connection", "close");
 
xmlHttp.open("POST","welcome3.php",true)
xmlHttp.send(url);
}

*/
 var http_request = false;
   function makePOSTRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } 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 = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('register').innerHTML = result;            
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   
   function get(obj) {
   for (i=0;i<document.forms[0].player.length;i++) {
	if (document.forms[0].player[i].checked) {
		playerimg = document.forms[0].player[i].value;
	}
}
	for (i=0;i<document.forms[0].pokemon.length;i++) {
	if (document.forms[0].pokemon[i].checked) {
		pokemon = document.forms[0].pokemon[i].value;
	}
}

      var poststr = "name=" + encodeURI( document.getElementById("name").value ) + 
       "&password=" + encodeURI( document.getElementById("password").value ) + 
       "&email=" + encodeURI(document.getElementById("email").value) +
       "&age=" + encodeURI(document.getElementById("age").value) + 
       "&security_code=" + encodeURI(document.getElementById("code").value) + 
       "&player=" + encodeURI(playerimg) +
       "&pokemon=" + encodeURI(pokemon);

      makePOSTRequest('welcome3.php', poststr);
   
   }


