    var adcount = 0;
    var adstart = 1;
    var artimeout = 40000;
    var adtimeout = 10000;

    var adslft = new Array(4);
    adslft[0] = "<a href='http://mashthegas.tv/include/cllkad.php?target=www.tbara.com' target='new'><img border=0 src='http://mashthegas.tv/images/tbaralogo.gif' width=150 height=50></a><br />";
    adslft[1] = "<a href='http://mashthegas.tv/include/cllkad.php?target=www.newsmyrnaspeedway.org' target='new'><img border=0 src='http://mashthegas.tv/images/new_smyrna_link.gif' width=150 height=50></a><br />";
    adslft[2] = "<a href='http://mashthegas.tv/include/cllkad.php?target=www.citruscountyspeedway.com' target='new'><img border=0 src='http://mashthegas.tv/images/citrus.gif' width=150 height=50></a><br />";
    adslft[3] = "<a href='http://mashthegas.tv/include/cllkad.php?target=www.ocalaspeedway.com' target='new'><img border=0 src='http://mashthegas.tv/images/ocala.gif' width=150 height=50></a><br />";
    adslft[4] = "<a href='http://mashthegas.tv/include/cllkad.php?target=www.eastbayracewaypark.com' target='new'><img border=0 src='http://mashthegas.tv/images/eastbay.gif' width=150 height=50></a><br />";
    
    var adsrgt = new Array(4);
    adsrgt[0] = "<a href='http://mashthegas.tv/include/cllkad.php?target=www.getfastwings.com' target='new'><img border=0 src='http://mashthegas.tv/images/fastwings.gif' width=150 height=50></a><br />";
    adsrgt[1] = "<a href='http://mashthegas.tv/include/cllkad.php?target=mashthegas.tv/sun_lover_pools.htm' target='new'><img border=0 src='http://mashthegas.tv/images/sunloverlogo.jpg' width=150 height=50></a><br />";
    adsrgt[2] = "<a href='http://mashthegas.tv/include/cllkad.php?target=www.desotosuperspeedway.com/home/home.htm' target='new'><img border=0 src='http://mashthegas.tv/images/dss_r7_c1.jpg' width=150 height=50></a><br />";
    adsrgt[3] = "<a href='http://mashthegas.tv/include/cllkad.php?target=www.proshocks.com/' target='new'><img border=0 src='http://mashthegas.tv/images/proshock1.gif' width=150 height=50></a><br />";
    adsrgt[4] = "<a href='http://mashthegas.tv/include/cllkad.php?target=www.uscsracing.com/' target='new'><img border=0 src='http://mashthegas.tv/images/uscs.gif' width=150 height=50></a><br />";

/* ================================================================
    Correct way to attach events to the onload function
   ================================================================ */
   function addEvent(obj,evType,fn) {
    if (obj.addEventListener) {
        obj.addEventListener(evType, fn, false);
        return true;
    } else if (obj.attachEvent) {
        var r = obj.attachEvent("on"+evType, fn);
        return r;
    } else {
        return false;
    }
    }




function startme() {
    Rounded("div#top","tr bl", 'transparent', '#98afc7',"border #0000ff"); 
    Rounded("div#present","bot", '#ffffff', '#98afc7',""); 
    Rounded("h3.adtitle","top", '#98afc7', '#4169e1',"");  
    RequestAds();
    RotateAds();

}


/*  ==========================================
    Ajax function Calls
    ========================================== */

    function RequestAds() {
        var http_request = MakeRequest();
        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }

        http_request.onreadystatechange = function() { Contents(http_request,RotateAd,"RequestAds"); };
        var host =  "http://" + window.location.hostname;
        var urladd = host +"/include/getads.php?ad=" + escape(adstart);
        
        //alert(urladd);
        http_request.open('GET', urladd, true);
        http_request.send(null);
    }

    function RotateAd(resp) {
        window.setTimeout('RequestAds()',artimeout);
        //alert("Hit it!");
        if (resp != "Error") { 
            var respads = resp.split("||");
            adstart = respads[2];
            var ads = respads[1].split("|-|");

            //alert("Loading ads starting at " + adstart);

            adslft = ads[0].split("|=|");
            adsrgt = ads[1].split("|=|");
        }
    }


    function RotateAds() {
        window.setTimeout('RotateAds()',adtimeout);

        var ad1 = getRefToDiv('adlc');
        var ad2 = getRefToDiv('adrc');
        
        adcount += 1;
        if (adcount > 4) adcount = 0;
        //alert(ad1.innerHTML);
              
        if (ad1) ad1.innerHTML = ""
        if (ad2) ad2.innerHTML = ""
        
        for (x=adcount;x<=4;x++) {
            if (ad1) ad1.innerHTML += adslft[x] ;
            if (ad2) ad2.innerHTML += adsrgt[x];
        }

        if (adcount > 0) {
            for (x=0;x<adcount;x++) {
                if (ad1) ad1.innerHTML += adslft[x] ;
                if (ad2) ad2.innerHTML += adsrgt[x];
            }
        }
        
    }

    function GetVideo(idx) {
        var http_request = MakeRequest();
        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }

        http_request.onreadystatechange = function() { Contents(http_request,ProcVideo,"GetVideo"); };
        var urladd = GetHome() +"getvid.php?mode=" + escape(idx);
        // alert(urladd);
        http_request.open('GET', urladd, true);
        http_request.send(null);
    }

    function ProcVideo(resp) {
        var VidContent = "";
        var bt = "";
        //alert(resp);
        var rsp = resp.split("||");
        if (rsp[0] == "ok") {
            //alert(resp);
            getRefToDiv('nav').innerHTML = rsp[1];
                VidContent = "";
                VidContent = "<OBJECT ID=\"MediaPlayer\" width=590 height=500 classid=\"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" codebase=\"http://activex.microsoft.com/activex/controls/ mplayer/en/nsmp2inf.cab#Version=5,1,52,701\" standby= \"Loading Media Player\" type=\"application/x-oleobject\">";
                VidContent += "<PARAM NAME=\"FileName\" VALUE=\"" + rsp[2] + "\"></param>";
                VidContent += "<PARAM NAME=\"AutoStart\" Value=\"-1\"></param>";
                VidContent += "<PARAM NAME=\"StretchToFit\" Value=\"1\"></param>";
                VidContent += "<PARAM NAME=\"ShowControls\" VALUE=\"True\"></param>";
                VidContent += "<PARAM NAME=\"controler\" VALUE=\"True\"></param>";
                VidContent += "<PARAM NAME=\"ShowStatusBar\" VALUE=\"True\"></param>";
                VidContent += "<PARAM NAME=\"Rate\" VALUE=\"1\"></param>";
                VidContent += "<PARAM NAME=\"Loop\" VALUE=\"True\"></param>";
                VidContent += "<EMBED type=\"application/x-mplayer2\" pluginspage=\"http://www.microsoft.com/Windows/MediaPlayer/\" SRC=\"" + rsp[2] + "\" width=590 height=500 name=\"MediaPlayer\" autostart=\"True\" ShowStatusBar=\"1\" ShowControls=\"1\" stretchToFit=\"1\" Loop=\"True\">";
                VidContent += "</EMBED>";
                VidContent += "</OBJECT>";
                
                getRefToDiv('vid').innerHTML = VidContent;
                if (rsp[3]) {
                    VidContent = "";
                    bt = rsp[3].split("==");
                    if (bt[0]) {
                        VidContent += bt[0];   
                    }
                    if (bt[1]) {
                        VidContent += bt[1];
                    }
                    getRefToDiv('res').innerHTML = VidContent;
                    
                } else {
                    getRefToDiv('res').innerHTML = "";
                }
                if (rsp[4]) {
                    VidContent = "";
                    bt = rsp[4].split("==");
                    if (bt[0]) {
                        VidContent += bt[0];   
                    }
                    if (bt[1]) {
                        VidContent += bt[1];
                    }
                    getRefToDiv('art').innerHTML = VidContent;
                } else {
                    getRefToDiv('art').innerHTML = "";
                }
                if (rsp[5]) {
                    getRefToDiv('nowplay').innerHTML = rsp[5];
                }                
        }   
    }

    function GetVideos(idx) {
        
        //document.MediaPlayer.FileName = movie[idx];
        document.MediaPlayer.FileName = GetHome() + "videos/" + idx + ".wmv";
    }



/*  ===================================
    make an Ajax request to the server 
    =================================== */
    function MakeRequest() {
             var http_request = false;
        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                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('Giving up :( Cannot create an XMLHTTP instance)');
            return false;
        }
   
        return http_request;        
        
    }

/*  =========================================
    Process an Ajax response from the server
    ========================================= */ 
    
    function Contents(http_request,DoResponse,context) {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                DoResponse(http_request.responseText);
            } else {
                //alert('There was a problem with the request.' + context);
                DoResponse("Error");
            }
        }
    }

    function GetHome() {
        var host =  "http://" + window.location.hostname;
        var path =  window.location.pathname.split("/")
        path.length -= 1;

        for (var i in path) {
            if (path[i].length > 0) host += "/" + path[i];
        }
        
        return host + "/";
    
        
    }


function dumpProps(obj, parent) {
   // Go through all the properties of the passed-in object 
   for (var i in obj) {
      // if a parent (2nd parameter) was passed in, then use that to 
      // build the message. Message includes i (the object's property name) 
      // then the object's property value on a new line 
      if (parent) { var msg = parent + "." + i + "\n" + obj[i]; } else { var msg = i + "\n" + obj[i]; }
      // Display the message. If the user clicks "OK", then continue. If they 
      // click "CANCEL" then quit this level of recursion 
      if (!confirm(msg)) { return; }
      // If this property (i) is an object, then recursively process the object 
      if (typeof obj[i] == "object") { 
         if (parent) { dumpProps(obj[i], parent + "." + i); } else { dumpProps(obj[i], i); }
      }
   }
}

function NiftyCheck(){
if(!document.getElementById || !document.createElement)
    return(false);
isXHTML=/html\:/.test(document.getElementsByTagName('body')[0].nodeName);
if(Array.prototype.push==null){Array.prototype.push=function(){
      this[this.length]=arguments[0]; return(this.length);}}
return(true);
}

function Rounded(selector,wich,bk,color,opt){
var i,prefixt,prefixb,cn="r",ecolor="",edges=false,eclass="",b=false,t=false;

if(color=="transparent"){
    cn=cn+"x";
    ecolor=bk;
    bk="transparent";
    }
else if(opt && opt.indexOf("border")>=0){
    var optar=opt.split(" ");
    for(i=0;i<optar.length;i++)
        if(optar[i].indexOf("#")>=0) ecolor=optar[i];
    if(ecolor=="") ecolor="#666";
    cn+="e";
    edges=true;
    }
else if(opt && opt.indexOf("smooth")>=0){
    cn+="a";
    ecolor=Mix(bk,color);

    }
if(opt && opt.indexOf("small")>=0) cn+="s";
if(opt && opt.indexOf("big")>=0) cn+="l";
prefixt=cn;
prefixb=cn;
if(wich.indexOf("all")>=0){t=true;b=true}
else if(wich.indexOf("top")>=0) t="true";
else if(wich.indexOf("tl")>=0){
    t="true";
    if(wich.indexOf("tr")<0) prefixt+="l";
    }
else if(wich.indexOf("tr")>=0){
    t="true";
    prefixt+="r";
    }
if(wich.indexOf("bottom")>=0) b=true;
else if(wich.indexOf("bl")>=0){
    b="true";
    if(wich.indexOf("br")<0) prefixb+="l";
    }
else if(wich.indexOf("br")>=0){
    b="true";
    prefixb+="r";
    }
var v=getElementsBySelector(selector);
var l=v.length;
for(i=0;i<l;i++){
    if(edges) AddBorder(v[i],ecolor);
    if(t) AddTop(v[i],bk,color,ecolor,prefixt);
    if(b) AddBottom(v[i],bk,color,ecolor,prefixb);
    }
}

function AddBorder(el,bc){
var i;
if(!el.passed){
    if(el.childNodes.length==1 && el.childNodes[0].nodeType==3){
        var t=el.firstChild.nodeValue;
        el.removeChild(el.lastChild);
        var d=CreateEl("span");
        d.style.display="block";
        d.appendChild(document.createTextNode(t));
        el.appendChild(d);
        }
    for(i=0;i<el.childNodes.length;i++){
        if(el.childNodes[i].nodeType==1){ 
            el.childNodes[i].style.borderLeft="1px solid "+bc;
            el.childNodes[i].style.borderRight="1px solid "+bc;
            }
        }
    }
el.passed=true;
}
    
function AddTop(el,bk,color,bc,cn){
var i,lim=4,d=CreateEl("b");

if(cn.indexOf("s")>=0) lim=2;
if(cn.indexOf("l")>=0) lim=8;
if(bc) d.className="artop";
else d.className="rtop";
d.style.backgroundColor=bk;
for(i=1;i<=lim;i++){
    var x=CreateEl("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    if(bc) x.style.borderColor=bc;
    d.appendChild(x);
    }
el.style.paddingTop=0;
el.insertBefore(d,el.firstChild);
}

function AddBottom(el,bk,color,bc,cn){
var i,lim=4,d=CreateEl("b");

if(cn.indexOf("s")>=0) lim=2;
if(cn.indexOf("l")>=0) lim=8;
if(bc) d.className="artop";
else d.className="rtop";
d.style.backgroundColor=bk;
for(i=lim;i>0;i--){
    var x=CreateEl("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    if(bc) x.style.borderColor=bc;
    d.appendChild(x);
    }
el.style.paddingBottom=0;
el.appendChild(d);
}

function CreateEl(x){
try {
if(isXHTML) return(document.createElementNS('http://www.w3.org/1999/xhtml',x));
else return(document.createElement(x));
}
catch(e) {
}
return(document.createElement(x));
}


function getElementsBySelector(selector){
var i,selid="",selclass="",tag=selector,f,s=[],objlist=[];
if(selector.indexOf(" ")>0){  //descendant selector like "tag#id tag"
    s=selector.split(" ");
    var fs=s[0].split("#");
    if(fs.length==1) return(objlist);
    f=document.getElementById(fs[1]);
    if(f) return(f.getElementsByTagName(s[1]));
    return(objlist);
    }
if(selector.indexOf("#")>0){ //id selector like "tag#id"
    s=selector.split("#");
    tag=s[0];
    selid=s[1];
    }
if(selid!=""){
    f=document.getElementById(selid);
    if(f) objlist.push(f);
    return(objlist);
    }
if(selector.indexOf(".")>0){  //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass=="")
    return(v);
for(i=0;i<v.length;i++){
    if(v[i].className.indexOf(selclass)>=0){
        objlist.push(v[i]);
        }
    }
return(objlist);
}

function Mix(c1,c2){
var i,step1,step2,x,y,r=new Array(3);
if(c1.length==4)step1=1;
else step1=2;
if(c2.length==4) step2=1;
else step2=2;
for(i=0;i<3;i++){
    x=parseInt(c1.substr(1+step1*i,step1),16);
    if(step1==1) x=16*x+x;
    y=parseInt(c2.substr(1+step2*i,step2),16);
    if(step2==1) y=16*y+y;
    r[i]=Math.floor((x*50+y*50)/100);
    }
return("#"+r[0].toString(16)+r[1].toString(16)+r[2].toString(16));
}
function getRefToDiv(divID,oDoc) {
  if( document.getElementById ) {    return document.getElementById(divID); }
  if( document.all ) {    return document.all[divID]; }
  if( !oDoc ) { oDoc = document; }
  if( document.layers ) {
    if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
      //repeatedly run through all child layers
      for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
        //on success, return that layer, else return nothing
        y = getRefToDiv(divID,oDoc.layers[x].document); }
    return y; } }
  return false;
}

