/* The tab navigation script. Always use in conjunction with docobj.js! */

// Set up array of tab element style property strings

var weblink = new Array (10);

weblink[0] = null;
weblink[1] = '/index.php';
weblink[2] = '/products.php';
weblink[3] = '/specials.php';
weblink[4] = '/shipping.php';
weblink[5] = '/links.php';
weblink[6] = '/contactus.php';

var tabArray = new Array(9);
tabArray[0] = null;
tabArray[1] = getStyleObj('tab1');
tabArray[2] = getStyleObj('tab2');
tabArray[3] = getStyleObj('tab3');
tabArray[4] = getStyleObj('tab4');
tabArray[5] = getStyleObj('tab5');
tabArray[6] = getStyleObj('tab6');

// Set up array of tabmiddle td element style property strings

var tabTextArray = new Array(9);
tabTextArray[0] = null;
tabTextArray[1] = getStyleObj('tabmiddle1');
tabTextArray[2] = getStyleObj('tabmiddle2');
tabTextArray[3] = getStyleObj('tabmiddle3');
tabTextArray[4] = getStyleObj('tabmiddle4');
tabTextArray[5] = getStyleObj('tabmiddle5');
tabTextArray[6] = getStyleObj('tabmiddle6');

// Set up array of text box element style property strings

var boxArray = new Array(9);
boxArray[0] = null;
boxArray[1] = getStyleObj('box1');
boxArray[2] = getStyleObj('box2');
boxArray[3] = getStyleObj('box3');
boxArray[4] = getStyleObj('box4');
boxArray[5] = getStyleObj('box5');
boxArray[6] = getStyleObj('box6');

var contentbox=getStyleObj('contentbox');

// the global variables for the tab functions
var active = null;

var activebgcolor = "#FF9999";
var activetextcolor = "black";


var inactivebgcolor = "#FFCCCC";
var inactivetextcolor = "#000000";

var overbgcolor = "#FFCCCC";
var overtextcolor = "red";


// the tab appearance changing function

function tabcolor(tabnum,color1,color2) {
tab = eval(tabArray[tabnum]);
tabtext = eval(tabTextArray[tabnum]);
tab.backgroundColor = color1;
tabtext.color = color2;

if (document.all) {
 tabtext.cursor = 'hand';
 }
else {
 tabtext.cursor = 'pointer';
 }
}

// the link change tab function

function choosemenu(num)
{
    if (window.location.href != weblink[num])
    {
        window.location.href=weblink[num];
    }
}
// the central tab navigation function

function choosebox(num) {

if (document.all || document.getElementById) {

if (active) {
activetablayer = eval(tabArray[active]);
activetabtext = eval(tabTextArray[active]);
activeboxlayer = eval(contentbox);
//activeboxlayer = eval(boxArray[active]);
activetablayer.zIndex = 0;
activeboxlayer.zIndex = 0;
tabcolor(active,inactivebgcolor, inactivetextcolor);

       }

tablayer = eval(tabArray[num]);
tabtext = eval(tabTextArray[num]);
//boxlayer = eval(boxArray[num]);

boxlayer=eval(contentbox);
tablayer.zIndex = 11;
boxlayer.zIndex = 10;

tabcolor(num,activebgcolor, activetextcolor);


active = num;
  }
}




// invoked onmouseover the tab

function tabover(tabnum) {

if (tabnum != active) {
 tabcolor(tabnum,overbgcolor,overtextcolor);
  }
}


//invoked onmouseout of the tab

function tabout(tabnum) {

if (tabnum != active) {
tabcolor(tabnum,inactivebgcolor,inactivetextcolor);
 }
}


// initialize the page

function initialize() {

// initialize the z-index for all the elements and re-arrange them

 for (i=1; i < tabArray.length; i++) {
  tablayer = eval (tabArray[i]);
  boxlayer = eval (boxArray[i]);
  tablayer.zIndex = tabArray.length-i;
  boxlayer.zIndex = tabArray.length-i;
  }

// then, make  the first tab active.

choosebox(1);

}


function NewWindow(mypage,myname,w,h,scroll){
    var win = null;
    settings ='height='+h+',width='+w+',top=170,resizable=0,scrollbars='+scroll;
    win = window.open(mypage,myname,settings);
    win.focus();
}

function getStyleObj(elem,parent) {
    if (document.layers) {
        if (parent) {
         return "document."+parent+".document."+elem;
          }
        else {
        return "document."+elem + ".style";
             }

      }
        else if (document.all) {
        return "document.all."+elem + ".style";
      }
        else if (document.getElementById) {
        return "document.getElementById('"+elem+"').style";

    }
}

var xmlhttp
try {
    xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
} catch (e) {
    try {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
    } catch (E) {
        xmlhttp=false
    }
}

if (!xmlhttp) {
    try {
        xmlhttp = new XMLHttpRequest();
    } catch (e) {
        xmlhttp=false
    }
}

function track(url) {
        xmlhttp.open("HEAD", "tracker.php?" + url, true);
//        xmlhttp.onreadystatechange=function() {
//                 if (xmlhttp.readyState==4) {
//                         xmlhttp.getAllResponseHeaders()
//                 }
//        }
        xmlhttp.send(null)
        return false
}
