﻿

////////////////////////////////////////////////////////////////////////////
//show hide dropdown list for older browsers.
function startlist() {

navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+="dd";
  }
  node.onmouseout=function() {
  this.className=this.className.replace("dd", "");
   }
   }
  }
 }
 
function show(classname) {
var li = document.getElementsByTagName("ul")
for (var i=0; i < li.length; i++) {
	var div = li[i];
	// add stuff here //
	if (li[i].className.match(classname)) {
	//div.style.display = "block";
		}
	}
}

//////////////////////////////////////////////////////////////////////////////
//Ajax file loader

//THIS IS NOT BEING USED.

var xmlHttp
function getfile(divid)
{

//var fn = window.location.href;
//var fn = fn.substring(fn.lastIndexOf("\/")+1,fn.lastIndexOf(""));


xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
  
var str = parent.document.URL;
var pid = str.substring(str.indexOf('?')+3, str.length)

//alert(pid);
   
var url=pid;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
//}

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
   { 
   document.getElementById(divid).innerHTML=xmlHttp.responseText;
   }
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
 
return xmlHttp;
}
}

//////////////////////////////////////////////////////////////////////
// THERE IS PROBABLY A MORE ELEGANT SOLUTION FOR THIS 

function highlightlinks() {
    var fn = window.location.href;
    var fn = fn.substring(fn.lastIndexOf("\/")+1,fn.lastIndexOf(""));
    
    //FOR PRODUCTS MENU
    if (fn == 'products.aspx') {
        document.getElementById("ps").style.fontWeight = 'bold';
    }
    if (fn == 'simplifid.aspx') {
        //alert("found the page");
        document.getElementById("green").style.color = '#9fa615';
        document.getElementById("green").style.fontWeight = 'bold';
    }
    if (fn == 'urovysionfish.aspx') {
        //alert("found the page");
        document.getElementById("red").style.color = '#8d0e56';
        document.getElementById("red").style.fontWeight = 'bold';
    }
    if (fn == 'uropathology.aspx') {
        //alert("found the page");
        document.getElementById("blue").style.color = '#22619f';
        document.getElementById("blue").style.fontWeight = 'bold';
    }

    
    // FOR DIAGNOSTIC MENU
    if (fn == 'diagnosticquality.aspx') {
        document.getElementById("dq").style.fontWeight = 'bold';
    }
    if (fn == 'leanlab.aspx') {
        document.getElementById("lld").style.fontWeight = 'bold';
    }
    if (fn == 'tissueprep.aspx') {
        document.getElementById("tps").style.fontWeight = 'bold';
    }
    if (fn == 'altprogram.aspx') {
        document.getElementById("ap").style.fontWeight = 'bold';
    }

    
    // FOR ABOUTUS MENU
    if (fn == 'aboutus.aspx') {
        document.getElementById("au").style.fontWeight = 'bold';
    }
    if (fn == 'medicalstaff.aspx') {
        document.getElementById("ms").style.fontWeight = 'bold';
    }
    if (fn == 'directors.aspx') {
        document.getElementById("md").style.fontWeight = 'bold';
    }
    if (fn == 'pathologists.aspx') {
        document.getElementById("up").style.fontWeight = 'bold';
    }
    if (fn == 'leadership.aspx') {
        document.getElementById("lt").style.fontWeight = 'bold';
    }
    if (fn == 'ourlocations.aspx') {
        document.getElementById("ol").style.fontWeight = 'bold';
    }
    if (fn == 'htcorporate.aspx') {
        document.getElementById("hc").style.fontWeight = 'bold';
    }


    // BUSINESS SOLUTIONS MENU
    if (fn == 'businesssolutions.aspx') {
        document.getElementById("bs").style.fontWeight = 'bold';
    }
    if (fn == 'clientbill.aspx') {
        document.getElementById("cb").style.fontWeight = 'bold';
    }
    if (fn == 'tcpc.aspx') {
        document.getElementById("tcpc").style.fontWeight = 'bold';
    }
    if (fn == 'labbuildout.aspx') {
        document.getElementById("lb").style.fontWeight = 'bold';
    }
    if (fn == 'remoteoffice.aspx') {
        document.getElementById("rp").style.fontWeight = 'bold';
    }



    //CUSTOMER SERVICE MENU
    if (fn == 'customerservice.aspx') {
        document.getElementById("cs").style.fontWeight = 'bold';
    }
    if (fn == 'communication.aspx') {
        document.getElementById("c").style.fontWeight = 'bold';
    }
    if (fn == 'reporting.aspx') {
        document.getElementById("r").style.fontWeight = 'bold';
    }
    if (fn == 'ehrdonationprogram.aspx') {
        document.getElementById("ehr").style.fontWeight = 'bold';
    }

}


//////////////////////////////////////////////////////////////////////

function addsymbol(string, symbol) {
    var replacewith
    
    if (symbol == "R") {
        replacewith = string.replace(" ", "") + "&reg;"
    }
    if (symbol == "TM") {
        replacewith = string + "&trade;"
    }

    var sections = document.getElementsByTagName("p");
    for (var i = 0; i < sections.length; i++) {
        
        var text = sections[i].innerHTML
        var sr = text.search(string);
        if (sr > -1) {

            var r = text.replace(string, replacewith);
            sections[i].innerHTML = r;
            return;
        }

    }

} 
//////////////////////////////////////////////////////////////////////
//Check OS if linux then load different style sheet to handle the font size diffeneces.
function checkos() {
    
    //alert(navigator.platform);
    if (navigator.platform == "Linux i686")  {
        
        var hid = document.getElementsByTagName("head")[0];
        var css = document.createElement('link');
        css.type = 'text/css';
        css.rel = 'stylesheet';
        css.href = 'linux.css';
        css.media = 'screen';
        hid.appendChild(css);
    }

}




//////////////////////////////////////////////////////////////////////
window.onload = function () {
    //This will autostart the code for the dropdown list
    startlist();
    highlightlinks();

    //addsymbol("HealthTronics ", "R");
    addsymbol("Laboratory Solutions", "TM");
    addsymbol("UroVysion", "R");
    addsymbol("SimplifID", "TM");
    checkos();
}
