var isMac = 0;
var isWin = 0;
var isOtherOS = 0;
var SecondTurn = "X";
var counter = 0;

var x = new Array();
x[0]=false;
x[1]=false;
x[2]=false;
x[3]=false;
x[4]=false;
x[5]=false;
x[6]=false;
x[7]=false;
x[8]=false;


function SetOS(){
  if (navigator.appVersion.indexOf('Mac') != -1){
    isMac = 1;
  }
  else if (navigator.appVersion.indexOf('Win') != -1){
    isWin = 1;
  }
  else {
    isOtherOS = 1;
  }
}

function GetBrowserVersion(){
  return (parseInt(navigator.appVersion));
}

function MoveObject(ObjectID, x, y){
  var object = findDOM(ObjectID, true);
  if (document.getElementByID){
    moveTop = x + 'px';
    moveLeft = y + 'px';
  }
  else
  {
    moveTop = x;
    moveLeft = y;
  }
  object.Top = moveTop;
  object.Left = moveLeft;
}

function ImageSupport(){
  if (document.images) {
    return (true);
  }
  else
  {
    return (false);
  }
}

function findDOM(ObjectID, withStyle){
  if (withStyle){
    if (document.getElementById) {
      return (document.getElementById(ObjectID).style);
    }
    else if (document.all){
      return (document.all[ObjectID].style);
    }
    else if ((navigator.appName.indexOf('Netscape') != -1) && parseInt(navigator.appVersion) == 4){
      return (document.layers[ObjectID]);
    }
  }
  else {
    if (document.getElementById) {
      return (document.getElementById(ObjectID));
    }
    else if (document.all){
      return (document.all[ObjectID]);
    }
    else if ((navigator.appName.indexOf('Netscape') != -1) && parseInt(navigator.appVersion) == 4){
      return (document.layers[ObjectID]);
    }
  }
}

function GetURL(){
  return (self.location);
}

function GetTitle(){
  return (document.title);
}

function GetScreenHeight(Avail){
  if (Avail == 1){
    return (screen.availHeight);
  }
  else
  {
    return (screen.height);
  }
}

function GetScreenWidth(Avail){
  if (Avail == 1){
    return (screen.availWidth);
  }
  else
  {
    return (screen.width);
  }
}

function GetColorDepth(){
  return (screen.colorDepth);
}

function FindLivePageHeight(){
  if (window.innerHeight){
    return (window.innerHeight);
  }
  else if (document.body.clientHeight){
    return (document.body.clientHeight);
  }
  else {
    return (null);
  }
}

function FindLivePageWidth(){
  if (window.innerWidth){
    return (window.innerWidth);
  }
  else if (document.body.clientWidth){
    return (document.body.clientWidth);
  }
  else {
    return (null);
  }
}

function FindScrollLeft(){
  if (document.body.scrollLeft){
    return (document.body.scrollLeft);
  }
  else {
    return (null);
  }
}

function FindScrollTop(){
  if (document.body.scrollTop){
    return (document.body.scrollTop);
  }
  else {
    return (null);
  }
}

function FindWidth(ObjectID){
  var object = document.getElementById(ObjectID);
  if (object.offsetWidth){
    return(object.offsetWidth);
  }
  else {
    return (null);
  }
}

function FindHeight(ObjectID){
  var object = document.getElementById(ObjectID);
  if (object.offsetHeight){
    return(object.offsetHeight);
  }
  else {
    return (null);
  }
}

function FindTop(ObjectID){
  var object = document.getElementById(ObjectID);
  if (object.offsetTop){
    return(object.offsetTop);
  }
  else {
    return (null);
  }
}

function FindLeft(ObjectID){
  var object = document.getElementById(ObjectID);
  if (object.offsetLeft){
    return(object.offsetLeft);
  }
  else {
    return (null);
  }
}

function FindBottom(ObjectID){
  var object = document.getElementById(ObjectID);
  if (object.offsetTop){
    return(object.offsetTop + object.offsetHeight);
  }
  else {
    return (null);
  }
}

function FindRight(ObjectID){
  var object = document.getElementById(ObjectID);
  if (object.offsetLeft){
    return(object.offsetLeft + object.offsetWidth);
  }
  else {
    return (null);
  }
}

function SetText(ObjectID, theText, theIndex){
  if (x[theIndex] == false){
  var object = findDOM(ObjectID, false);
  var theStatus = findDOM("Status", false);
  object.innerHTML = theText;
  if (SecondTurn == "O"){
    SecondTurn = "X";
    theStatus.innerHTML = "Player X";  
  }
  else {
    SecondTurn = "O";  
    theStatus.innerHTML = "Player O";
    }
  x[theIndex] = true;
  counter = counter + 1;
  if (counter == 9){
    ClearGrid();
  }  
}
}

function ShowFAQ(QNum){
  if (QNum == 1){
  var object = findDOM("FAQ1", true);
  object.top = 375;
  }
  if (QNum == 2){
  var object = findDOM("FAQ2", true);
  object.top = 400;
  }
  if (QNum == 3){
  var object = findDOM("FAQ3", true);
  object.top = 425;
  }
  if (QNum == 4){
  var object = findDOM("FAQ4", true);
  object.top = 450;
  }
  if (QNum == 5){
  var object = findDOM("FAQ5", true);
  object.top = 475;
  }
  object.left = 25;
  object.visibility = "visible";
}
function HideFAQ(QNum){
  if (QNum == 1){
  var object = findDOM("FAQ1", true);
  }
  if (QNum == 2){
  var object = findDOM("FAQ2", true);
  }
  if (QNum == 3){
  var object = findDOM("FAQ3", true);
  }
  if (QNum == 4){
  var object = findDOM("FAQ4", true);
  }
  if (QNum == 5){
  var object = findDOM("FAQ5", true);
  }
  object.top = -100;
  object.left = -100;
  object.visibility = "hidden";
  
}

function getCookieVal (offset) { 
var endstr = document.cookie.indexOf (";", offset); 
if (endstr == -1) endstr = document.cookie.length; 
return unescape(document.cookie.substring(offset, endstr));
 } 

function GetCookie (name) { 
var arg = name + "="; 
var alen = arg.length; 
var clen = document.cookie.length; 
var i = 0; 
while (i < clen) { 
var j = i + alen; 
if (document.cookie.substring(i, j) == arg) 
return getCookieVal (j); 
i = document.cookie.indexOf(" ", i) + 1; 
if (i == 0) break; 
} 
return null; 
} 

function login(){
document.cookie = "MTree=YES; domain=mikestree.com";
document.refresh
window.parent.navigate("http://www.mikestree.com/mtree.htm")
}

