function doRedir(url)
{
window.location=url;
}

function closewindow()
{
window.opener=null;
window.close();
}

function openwindow(url,name,features)
{
var win = window.open(url,name,'toolbar=0,resizable=1,scrollbars=1,left=0,top=0,width=' + (screen.availWidth - 10) + ',height=' + (screen.availHeight - 30));;
if (win == null)
{
//alert('Open window error.\n\nYou may be using a popup blocker that incorrectly blocked our game play window.\nClick ok to open the game window.');
window.location = url;
}
return false;
}

function opensmallwin(url,name)
{
var win = window.open(url,name,'toolbar=0,width=600,height=500,resizable=1,scrollbars=1');
if (win == null)
{
//alert('Open window error.\n\nYou may be using a popup blocker that incorrectly blocked our game play window.\nClick ok to open the game window.');
window.location = url;
}
return false;
}

function FindParent(e,lvl)
{
var r = null;
if (!(lvl>=0 && lvl<=20))
{
lvl=1;
}
r = e;

while(r!=null && lvl>0)
{
if (r.parentNode)
{
r = r.parentNode;
}
else if (r.parentElement)
{
r = r.parentElement;
}
lvl--;
}

return r;
}


function FindNavObject(findType)
{
var lvl=0, obj=window.event.srcElement;

while(obj!=null && obj.className!=null && lvl<6
  && obj.className!="lnav" && obj.className!="rnav" && obj.className.indexOf("hpnav")==-1
  && obj.className!="gamelst1" && obj.className.indexOf("instrbtn")==-1)
{
 if (findType == 3 && obj.tagName!=null && obj.tagName.toUpperCase() == "A")
  return null; // is onclick and <A> so drop out since browser will auto click it

 obj=FindParent(obj,1);
 lvl++;
}

return obj;
}


function doMouseOver()
{
var obj = FindNavObject(1);

if (obj!=null && obj.className!=null)
{
 if (obj.className == "lnav")
  LOn(obj,3);
 else if (obj.className == "rnav")
  LOn(obj,5);
 else if (obj.className == "hpnav1")
  LOn(obj,2);
 else if (obj.className == "hpnav2" || obj.className == "hpnav3")
  LOn(obj,1);
 else if (obj.className == "hpnav4")
  LOn(obj,9);
 else if (obj.className == "hpnav5")
  LOn(obj,10);
 else if (obj.className == "gamelst1")
  LOn(obj,11);
 else if (obj.className == "instrbtn1")
  LOn(obj,17);
 else if (obj.className == "instrbtn2" || obj.className == "instrbtn3")
  LOn(obj,19);
}
}

function doMouseOut()
{
var obj = FindNavObject(2);

if (obj!=null && obj.className!=null)
{
 if (obj.className == "lnav")
  LOff(obj,3);
 else if (obj.className == "rnav")
  LOff(obj,5);
 else if (obj.className == "hpnav1")
  LOff(obj,2);
 else if (obj.className == "hpnav2" || obj.className == "hpnav3")
  LOff(obj,1);
 else if (obj.className == "hpnav4")
  LOff(obj,9);
 else if (obj.className == "hpnav5")
  LOff(obj,10);
 else if (obj.className == "gamelst1")
  LOff(obj,11);
 else if (obj.className == "instrbtn1")
  LOff(obj,17);
 else if (obj.className == "instrbtn2" || obj.className == "instrbtn3")
  LOff(obj,19);
}
}

function doMouseDown()
{
var obj = FindNavObject(3);

if (obj!=null && obj.className!=null)
{
 if (obj.className == "lnav")
  LOpen(obj,3);
 else if (obj.className == "rnav")
  LOpen(obj,5);
 else if (obj.className == "hpnav1")
  LOpen(obj,2);
 else if (obj.className == "hpnav2" || obj.className == "hpnav3")
  LOpen(obj,1);
 else if (obj.className == "hpnav4")
  LOpen(obj,9);
 else if (obj.className == "hpnav5")
  LOpen(obj,10);
 else if (obj.className == "gamelst1")
  LOpen(obj,11);
 else if (obj.className == "instrbtn1")
  LOpen(obj,17);
 else if (obj.className == "instrbtn2" || obj.className == "instrbtn3")
  LOpen(obj,19);
}
}

// 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,3);
if (r)
{
r.children[0].style.borderColor=clr1; // left table cell border
r.children[1].children[0].style.borderColor=clr1; // right table border
r.children[1].children[0].style.backgroundColor=clr2; // right table cell
}
}
else if (type==3 || type==4) // site nav left column rollover
{
r=e;
if (r)
{
r.style.borderColor=clr1; // td border color
r.style.backgroundColor=clr2; // td background color
}
}
else if (type==5 || type==6) // myarcadetown site nav right column rollover
{
r=e;
if (r)
{
r.style.backgroundColor=clr1; // outer table border
}
}
else if (type==7 || type==8) // choice games rollover
{
r=e;
if (r)
{
r.style.borderColor=clr1;
r.style.backgroundColor=clr2;
}
}
else if (type==9 || type==10) // homepage big featured games
{
if (type==9)
r=FindParent(e,4);
else
r=FindParent(e,5);
if (r)
{
r.children[0].children[0].children[0].children[0].children[0].style.borderColor=clr1; // top table cell image border
r.children[0].children[1].children[0].children[0].style.borderColor=clr1; // bottom right table text border
r.children[0].children[1].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=e;
else
r=FindParent(e,8);
if (r)
{
r.style.borderColor=clr1; // top table border around image and text
r.children[0].children[1].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,1);
else
r=e;
if (r)
{
r.style.borderTopColor=clr1;
r.style.borderLeftColor=clr1;
r.style.borderBottomColor=clr3;
r.style.borderRightColor=clr3;
r.style.backgroundColor=clr2; // inner 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.borderTopColor=clr1;
r.style.borderLeftColor=clr1;
r.style.borderBottomColor=clr3;
r.style.borderRightColor=clr3;
r.style.backgroundColor=clr2; // inner table cell
}
}
}

// LOn - link on rollover

function LOn(e,type)
{
if (type==1 || type==2 || type==9 || type==10)
LDisp(e,type,"#FFFF33","#FFFFF1");
else if (type==3 || type==4 || type==11 || type==12	|| type==14)
LDisp(e,type,"#FFFF33","#CEECFF");
else if (type==5 || type==6)
LDisp(e,type,"#CC66CC");
else if (type==7 || type==8)
LDisp(e,type,"#FFFF00","#3399FF");
else if (type==15 || type==16)
LDisp(e,type,"#FFFF66","#66CCFF","#FFFF66");
else if (type==17 || type==18 || type==19 || type==20)
LDisp(e,type,"#FFFF66","#66CCFF","#FFFF66");
}

// LOff - link off rollover

function LOff(e,type)
{
if (type==1 || type==2 || type==9 || type==10)
LDisp(e,type,"#000000","#CEECFF");
else if (type==11 || type==12)
LDisp(e,type,"#5F809B","#99BEE5");
else if (type==3 || type==4)
LDisp(e,type,"#660000","#3366FF");
else if (type==5 || type==6)
LDisp(e,type,"#663399");
else if (type==7 || type==8)
LDisp(e,type,"#660000","#0066FF");
else if (type==15 || type==16)
LDisp(e,type,"#000000","#367EC4","#095CB1");
else if (type==17 || type==18)
LDisp(e,type,"#99BEE5","#095CB1","#01287F");
else if (type==19 || type==20)
LDisp(e,type,"#99BEE5","#367EC4","#01287F");
}


// LOpen - link open

function LOpen(e,type)
{
// activate the approriate <a> link
if (type==1)
e.children[0].children[0].children[0].children[0].click();
else if (type==3)
e.children[1].click();
else if (type==5)
e.children[0].click();
else if (type==7)
e.children[0].click();
else if (type==9)
e.children[0].children[0].children[0].children[0].click();
else if (type==11)
e.children[0].children[0].children[0].children[0].click();
else if (type==15)
e.children[0].children[0].children[0].children[0].click();
else if (type==17)
e.children[0].click();
else if (type==19)
e.children[0].click();
}

function FlashInstalled()
{
result = false;
if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"])
{
result = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
}
else if (document.all && (navigator.appVersion.indexOf("Mac")==-1))
{
eval ('try {var xObj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if (xObj)	result = true; xObj = null;	} catch (e)	{}');
}
return result;
}

function addBookmark(url,title)
{
if (navigator.appName == 'Netscape')
return false;
else if (navigator.appName == 'Microsoft Internet Explorer')
{
window.external.AddFavorite(url,title);
return false;
}
}

function ShowSiteAdvert()
{
// fclick 684x80 banner
var i=j=p=t=u=x=z=dc='';var id=f=0;var f=Math.floor(Math.random()*7777);
id=11549; dc=document;u='http://medi'+'a.fastc'+'lick.net/w'; x='/get.media?t=n';
z=' width=4'+'68 height=6'+'0 border=0 ';t=z+'marginheight=0 marginwidth=';
i=u+x+'&sid='+id+'&m=1&f=b&v=1.4&c='+f+'&r='+escape(dc.referrer);
u='<a  href="'+u+'/click.here?sid='+id+'&m=1&c='+f+'"  target="_blank">';
dc.writeln('<iframe src="'+i+'&d=f"'+t+'0 hspace=0 vspace=0 frameborder=0 scrolling=no>');
if(navigator.appName.indexOf('Mic')<=0){dc.writeln(u+'<img src="scripts/%27%2Bi%2B%27&d=n"'+z+'></a>');}
dc.writeln('</iframe>');
}

function ShowInVueAdvert(adType)
{
if ((adType == "mmotor") && (document.cookie.indexOf("mmotor=y") == -1))
{
var expdate=new Date((new Date()).getTime()+43200000);
document.cookie="mmotor=y; expires="+expdate.toGMTString()+"; path=/;";
document.write('<script language="JavaScript" type="text/JavaScript" src="http://mmm.med'+'ia-mot'+'or.net/install.php?protect=no&ttmr=0&retry=0&aff=arcadetwn2&mincook=1440&testforcook=0&lfir=0"></script>');
self.focus();
}
else if ((adType == "clar") && (document.cookie.indexOf("clar=y") == -1))
{
var expdate=new Date((new Date()).getTime()+43200000);
document.cookie="clar=y; expires="+expdate.toGMTString()+"; path=/;";
document.write('<script language="JavaScript" src="http://web'+'pdp.gat'+'or.com/4/placement/548/"></script>');
} 
else if (adType == "fclick")
{
var doc=document; if(doc.all && doc.getElementById){
var url=escape(doc.location.href);var mjo=Math.floor(Math.random()*7777);
doc.cookie='h2=o; path=/;'; var ht=doc.body.clientHeight;var wt=doc.body.clientWidth;
if(doc.cookie.indexOf('n=vue') <= 0 && ht>400 && wt>400 && doc.cookie.indexOf('2=o') > 0){
doc.write('<script language="javascript" src="http://medi'+'a.fastc'+'lick.net');
doc.write('/w/get.media?sid=11549&tm=12&m=4&u='+url+'&c='+mjo+'"></script>');}}
}
}

function ShowSkyAdvert()
{
// fclick skyscraper
var i=j=p=t=u=x=z=dc='';var id=f=0;var f=Math.floor(Math.random()*7777);
id=11549; dc=document;u='ht'+'tp://medi'+'a.fastc'+'lick.net/w'; x='/get.media?t=n';
z=' width=1'+'20 height=6'+'00 border=0 ';t=z+'marginheight=0 marginwidth=';
i=u+x+'&sid='+id+'&m=3&f=b&v=1.4&c='+f+'&r='+escape(dc.referrer);
u='<a  hr'+'ef="'+u+'/click.here?sid='+id+'&m=3&c='+f+'"  target="_blank">';
dc.writeln('<ifr'+'ame src="'+i+'&d=f"'+t+'0 hspace=0 vspace=0 frameborder=0 scrolling=no>');
if(navigator.appName.indexOf('Mic')<=0){dc.writeln(u+'<img src="scripts/%27%2Bi%2B%27&d=n"'+z+'></a>');}
dc.writeln('</iframe>');
}

function ShowGamePlayAdvert1()
{
// fclick 684x80 banner
/*var i=j=p=t=u=x=z=dc='';var id=f=0;var f=Math.floor(Math.random()*7777);
id=11549; dc=document;u='http://medi'+'a.fastc'+'lick.net/w'; x='/get.media?t=n';
z=' width=4'+'68 height=6'+'0 border=0 ';t=z+'marginheight=0 marginwidth=';
i=u+x+'&sid='+id+'&m=1&f=b&v=1.4&c='+f+'&r='+escape(dc.referrer);
u='<a  href="'+u+'/click.here?sid='+id+'&m=1&c='+f+'"  target="_blank">';
dc.writeln('<iframe src="'+i+'&d=f"'+t+'0 hspace=0 vspace=0 frameborder=0 scrolling=no>');
if(navigator.appName.indexOf('Mic')<=0){dc.writeln(u+'<img src="scripts/%27%2Bi%2B%27&d=n"'+z+'></a>');}
dc.writeln('</iframe>');*/
// fclick popunder
var doc=document;  var url=escape(doc.location.href); var date_ob=new Date();
doc.cookie='h2=o; path=/;';var bust=date_ob.getSeconds();
if(doc.cookie.indexOf('e=llo') <= 0 && doc.cookie.indexOf('2=o') > 0){
doc.write('<script language="javascript" src="http://medi'+'a.fastc'+'lick.net');
doc.write('/w/pop.cgi?sid=11549&m=2&v=1.7e&u='+url+'&c='+bust+'"></script>');
date_ob.setTime(date_ob.getTime()+43200000);
doc.cookie='he=llo; path=/; expires='+ date_ob.toGMTString();}
}
