 //--- onload functions ----------------------------------
    
function siteSpecificOnload(){
  pageSpecificOnload();

  //add additional functions here
  }

// do nothing on pages where pageSpecificOnload does not appear:
function pageSpecificOnload(){
  var hereforpagespecific;
  }
  
    
//--- search functions ----------------------------------  
function replaceQuotes(keyword){
  keyword = keyword.replace('\"','\\\"');
  if(keyword.indexOf('\"') != -1){
      keyword = replaceQuotes(keyword)
  }
  return keyword;
}

/*Expand/Collapse Divs */
function expandCollapse() {
for (var i=0; i<expandCollapse.arguments.length; i++) {
var element = document.getElementById(expandCollapse.arguments[i]);
element.style.display = (element.style.display == "none") ? "block" : "none"; }
}

/* **********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
********************************************** */

function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}

function stringUpper(title) {
    var pattern = /(\w)(\w*)/; // a letter, and then one, none or more letters 

    var a = title.split(/\s+/g); // split the sentence into an array of words

    for (i = 0 ; i < a.length ; i ++ ) {
        var parts = a[i].match(pattern); // just a temp variable to store the fragments in.

        var firstLetter = parts[1].toUpperCase();
        var restOfWord = parts[2].toLowerCase();

        a[i] = firstLetter + restOfWord; // re-assign it back to the array and move on
    }
    
    title = a.join(' '); // join it back together
    return title;
}

//--- Expandable menu ----------------------------------  
/*
    Expandable Listmenu Script (modified)
    Author : Daniel Nolan
    http://www.bleedingego.co.uk/webdev.php
*/

function initMenus() {
    if (!document.getElementsByTagName) return;
    
    var aMenus = document.getElementsByTagName("LI");
    for (var i = 0; i < aMenus.length; i++) {
        var mclass = aMenus[i].className;
        if (mclass.indexOf("treenode") > -1) {
            var submenu = aMenus[i].childNodes;
            for (var j = 0; j < submenu.length; j++) {
                if (submenu[j].tagName == "A") {
          
                    submenu[j].onclick = function() {  
                        var node = this.nextSibling;
              var hasLanding = (this.href.substring(this.href.length-1) != "#");
              var alreadyOnPage = (this.href == document.location.href);
              
              while (1) {
                if (node != null) {
                  if (node.tagName == "UL") {
                    var d = (node.style.display == "none")
                    if ((!hasLanding || alreadyOnPage) && d) node.style.display = "block";
                    if (!d) node.style.display = "none";
                    this.className = (d) ? "treeopen" : "treeclosed";
                    if (hasLanding && d && !alreadyOnPage) document.location.href=this.href;
                    return false;
                  }

                  node = node.nextSibling;
                } else {
                  return false;
                }

              }
                          
                        return false;
                    }
                    
                    submenu[j].className = (mclass.indexOf("open") > -1) ? "treeopen" : "treeclosed";
                }
                
                if (submenu[j].tagName == "UL")
                    submenu[j].style.display = (mclass.indexOf("open") > -1) ? "block" : "none";
            }
        }
    }
}



function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("&") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("&")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if ( 
aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return strReturn;
} 

function collapseAllNav() {
var items = document.getElementById("treemenu").getElementsByTagName("ul");
    for (var t=0; t<items.length; t++){
        items[t].style.display="none";
    }
}


// Function to highlight selected link in the left nav

function highlightCurrentLink() {
  
    var currentLocation = document.location.href;
    var targetNode;
    
    targetNode = document.getElementById("treemenu");
    
    if (targetNode != null)
    {
        var links = targetNode.getElementsByTagName("a");
        
        // Search thorugh all links
        for (var i = 0; i < links.length; i++) {
            
            var linkHref = links[i].href;
            //highlight transforms under the main nav
            if (currentLocation.indexOf("transform=") > -1) {
                if (getURLParam("transform") == "faqs" || getURLParam("transform") == "toptips" || getURLParam("transform") == "brands" ){
                currentLocation = currentLocation.substring(0, currentLocation.indexOf("transform=")-1);
                }
                document.write("<!-- nav test: "+currentLocation+"-->");    
            }
        
            if (linkHref == currentLocation) {
                links[i].setAttribute("className", "selected");
                links[i].setAttribute("class", "selected"); 
                
                // add the class to the top level menu item 
                links[i].parentNode.parentNode.setAttribute("className",  "treenodeopen parentSelected");
                links[i].parentNode.parentNode.setAttribute("class",  "treenodeopen parentSelected");   
                // traverse the DOM to stick the submenu's open
                var stree =links[i].parentNode.parentNode.parentNode.getElementsByTagName("ul");
                stree[0].style.display = "block";
                links[i].parentNode.parentNode.parentNode.setAttribute("className","treeopen");
                links[i].parentNode.parentNode.parentNode.setAttribute("class","treeopen");             
                links[i].parentNode.parentNode.setAttribute("class","subtree");             
                links[i].parentNode.parentNode.setAttribute("className","subtree");                             

            } //end if
        } // end for
    }  // end if
    
    //try to get the pet food 3rd level subnav to stay open... WILL NEED TO ADJUST FUN. ID.
    if (getURLParam("header") == "pet"  || getURLParam("header") == "dog" || getURLParam("header") == "greyhound"){
        // check if subnav2 exists first
        if(document.getElementById("subnav2")) {
          var subnav = document.getElementById("subnav2");
          subnav.style.display = "block";
        }
    }
} //end function


function collapseAll() {
    ans = document.getElementById("maincol").getElementsByTagName("div");
        for (t=0; t<ans.length; t++){
                ans[t].style.display="none";
    }
}

function externalLinks(target) { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
       if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {anchor.target = "_blank"; 
       } else if(anchor.getAttribute("href") && anchor.getAttribute("rel") == "thiswindow")anchor.target = "_top";
       
 } 
}

