
// for image rollovers

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function swapOn(imgName) {
  if (document.images) {
    document[imgName].src = eval(imgName + "_on.src");
  }
}

function swapOff(imgName) {
  if (document.images) {
    document[imgName].src = eval(imgName + ".src");
  }
}

function getElementsByClassName(classname, node)  {
    if(!node) node = document.getElementsByTagName("body")[0];
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}

function getBigSwatch(file,swatch) {
    
    var targ = document.getElementById("large_swatch");
    targ.src = file;
    var swatches = getElementsByClassName("smallSwatch");
    
    // update appearances based on which swatch is active
    for(i=0; i<swatches.length; i++){
        var indicator = document.getElementById("indicator" + i);
        if(swatches[i].id == swatch){
            
            swatches[i].className += " activeSwatch";
            swatches[i].setAttribute('onmouseover', '');
            swatches[i].setAttribute('onmouseout', '');
            indicator.src = "images/arrow_active.gif";
        }else{
            swatches[i].className = "smallSwatch";
            swatches[i].setAttribute('onmouseover', 'swapIndicatorOn(' + i + ')');
            swatches[i].setAttribute('onmouseout', 'swapIndicatorOff(' + i + ')');
            indicator.src = "images/spacer.gif";
        }    
    }

}

function swapIndicatorOn(i) {
    var indicator = document.getElementById("indicator" + i);
    indicator.src = "images/arrow_hover.gif";
}

function swapIndicatorOff(i) {
    var indicator = document.getElementById("indicator" + i);
    indicator.src = "images/spacer.gif";
}


// for AJAX

function GetXmlHttpObject() { 
    var objXMLHttp = null;
    if (window.XMLHttpRequest){
        objXMLHttp = new XMLHttpRequest();
    }else if (window.ActiveXObject){
        objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return objXMLHttp;
}

var xmlDoc;

function loadXML()
{
//load xml file
// code for IE
if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("tabs.xml");
//getmessage()
}
// code for Mozilla, etc.
else if (document.implementation &&
document.implementation.createDocument)
{
xmlDoc= document.implementation.createDocument("","",null);
xmlDoc.load("tabs.xml");
//xmlDoc.onload=getmessage
}
else
{
alert('Your browser cannot handle this script');
}

}

function showSlideLink(){
    var slidelink = document.getElementById("slide_link");
    slidelink.style.visibility = "visible";
}
function hideSlideLink(){
    var slidelink = document.getElementById("slide_link");
    slidelink.style.visibility = "hidden";
}



function getTab(name) {
    // first turn the current tab span back into a live link
    var subnav = document.getElementById("subnav");
    var activeTab = document.getElementById("subnav_active");
    var activeName = activeTab.firstChild.nodeValue;
    var newLink = document.createElement("a");
    var newLinkText = document.createTextNode(activeName);
    newLink.appendChild(newLinkText);
    newLink.setAttribute("href","#");
    newLink.setAttribute("onclick","getTab('" + activeName + "')");   
    var oldTab = subnav.replaceChild(newLink,activeTab);
    
    // now make the link for the new tab into a span 
    var navtabs = subnav.getElementsByTagName('a');
    for(i=0; i<navtabs.length; i++){
        var n = navtabs[i].firstChild.nodeValue;
        if(n == name) {
            // this is the active tab, so no link needed
            var newSpan = document.createElement("span");
            var newText = document.createTextNode(n);
            newSpan.appendChild(newText);
            newSpan.setAttribute("id","subnav_active");
            var spawn = subnav.replaceChild(newSpan,navtabs[i]);
        }
    }
        
}


