function openwindow(url,name,features)
{
window.open(url,name,'toolbar=0,resizable=1,scrollbars=1,left=0,top=0,width=' + (screen.width - 10) + ',height=' + (screen.height - 45));
}

function FindParent(e,lvl)
{
 var r = null;
 if (!(lvl>=0 && lvl<=20))
 {
  lvl=1;
 }
 r = e;

 while(lvl>0)
 {
  if (r.parentNode)
  {
   r = r.parentNode;
  }
  else if (r.parentElement)
  {
   r = r.parentElement;
  }
  lvl--;
 }

 return r;
}

// LDisp - link mouseover display

function LDisp(e,type,clr1,clr2,clr3)
{
 var r=null;
 if (type==1 || type==2) // home page main game selection rollover
 {
  if (type==1)
   r=FindParent(e,2);
  else
   r=FindParent(e,6);
  if (r)
  {
   r.children[0].children[0].style.backgroundColor=clr1; // left table border
   r.children[1].children[0].style.backgroundColor=clr1; // right table border
   r.children[1].children[0].children[0].children[0].style.backgroundColor=clr2; // right table cell
  }
 }
 else if (type==3 || type==4) // site nav left column rollover
 {
  if (type==3)
   r=e;
  else
   r=FindParent(e,8);
  if (r)
  {
   r.style.backgroundColor=clr1; // outer table border
   r.children[0].children[0].children[0].children[0].style.backgroundColor=clr2; // inner table color
  }
 }
 else if (type==5 || type==6) // myarcadetown site nav right column rollover
 {
  if (type==5)
   r=FindParent(e,1);
  else
   r=FindParent(e,5);
  if (r)
  {
   r.style.backgroundColor=clr1; // outer table border
  }
 }
 else if (type==7 || type==8) // myarcadetown site nav right column rollover
 {
  if (type==7)
   r=e;
  else
   r=FindParent(e,1);
  if (r)
  {
   r.style.backgroundColor=clr1; // outer table border
  }
 }
 else if (type==9 || type==10) // homepage big featured games
 {
  if (type==9)
   r=FindParent(e,4);
  else
   r=FindParent(e,8);
  if (r)
  {
   r.children[0].children[0].children[0].children[0].style.backgroundColor=clr1; // top table image border
   r.children[0].children[1].children[1].children[0].style.backgroundColor=clr1; // bottom right table text border
   r.children[0].children[1].children[1].children[0].children[0].children[0].style.backgroundColor=clr2; // bottom right table row text
  }
 }
 else if (type==11 || type==12) // category list game links
 {
  if (type==11)
   r=FindParent(e,4);
  else
   r=FindParent(e,8);
  if (r)
  {
   r.style.backgroundColor=clr1; // top table border around image and text
   r.children[0].children[0].children[0].style.backgroundColor=clr2; // td around table row text
  }
 }
 else if (type==15 || type==16) // popup screen close button
 {
  if (type==16)
   r=FindParent(e,4);
  else
   r=e;
  if (r)
  {
   r.style.backgroundColor=clr1; // outer table border
   r.children[0].children[0].children[0].style.backgroundColor=clr2; // left text button color
   r.children[0].children[0].children[1].style.backgroundColor=clr3; // right X close button color
  }
 }
 else if (type==17 || type==18) // game instructions play now link
 {
  if (type==18)
   r=FindParent(e,4);
  else
   r=e;
  if (r)
  {
   r.style.backgroundColor=clr1; // outer table border
   r.children[0].children[0].children[0].style.backgroundColor=clr2; // inner <td> table cell
  }
 }
 else if (type==19 || type==20) // game instructions play game and other buttons
 {
  if (type==20)
   r=FindParent(e,1);
  else
   r=e;
  if (r)
  {
   r.style.backgroundColor=clr2; // inner table cell
  }
 }
}

// LOn - link on rollover

function LOn(e,type)
{
 if (type==1 || type==2 || type==3 || type==4 || type==9 || type==10 || type==11 || type==12
		  || type==14 || type==17 || type==18 || type==19 || type==20)
  LDisp(e,type,"#FF0000","#66CCFF");
 else if (type==5 || type==6)
  LDisp(e,type,"#CC66CC");
 else if (type==7 || type==8)
  LDisp(e,type,"#3399FF");
 else if (type==15 || type==16)
  LDisp(e,type,"#FFFF00","#3399FF","#3399FF");
}

// LOff - link off rollover

function LOff(e,type)
{
 if (type==1 || type==2 || type==9 || type==10 || type==11 || type==12)
  LDisp(e,type,"#000000","#0066FF");
 else if (type==3 || type==4)
  LDisp(e,type,"#000000","#FFFFFF");
 else if (type==5 || type==6)
  LDisp(e,type,"#663399");
 else if (type==7 || type==8)
  LDisp(e,type,"#0066FF");
 else if (type==15 || type==16)
  LDisp(e,type,"#000000","#0066FF","#3333CC");
 else if (type==17 || type==18)
  LDisp(e,type,"#000000","#3333CC");
 else if (type==19 || type==20)
  LDisp(e,type,"#000000","#0066FF");
}

// LOpen - link open

function LOpen(e,type)
{
 if (type==1)
  e.children[0].children[0].children[0].children[0].click(); // activate the <a> link
 else if (type==3)
  e.children[0].children[0].children[0].children[0].children[0].children[0].children[1].children[0].click(); // activate the <a> link
 else if (type==5)
  e.children[0].children[0].children[1].children[0].click(); // activate the <a> link
 else if (type==7)
  e.children[0].click(); // activate the <a> link
 else if (type==9)
  e.children[0].children[0].children[0].children[0].click(); // activate the <a> link
 else if (type==11)
  e.children[0].children[0].children[0].children[0].click(); // activate the <a> link
 else if (type==15)
  e.children[0].children[0].children[0].children[0].click(); // activate the left <a> link
 else if (type==17)
  e.children[0].children[0].children[0].children[0].click(); // activate the inner <a> link
 else if (type==19)
  e.children[0].click(); // activate the inner <a> link
}
