
function setNav(){
var pagehref = window.location;
var pageurl = pagehref.toString();
var url = pageurl.toLowerCase();
var objNav = document.getElementById("nav");
var navAnchor = objNav.getElementsByTagName("a");


for(i=0; i<navAnchor.length; i++)
        {
         var link = navAnchor[i].getAttribute("href").toString();
         var llink = link.toLowerCase()
         if (url.indexOf(llink) != -1){
			 var ulClass = navAnchor[i].parentNode.parentNode.className;
			  switch(ulClass){
				 case "level1":
					navAnchor[i].parentNode.className = "active";
				 break;
				 
				 case "level2":
				 	navAnchor[i].parentNode.parentNode.parentNode.className = "active";
					navAnchor[i].parentNode.className += " active";
				 break;
				 
				 case "level3":
				 	navAnchor[i].parentNode.parentNode.parentNode.parentNode.parentNode.className = "active";
					navAnchor[i].parentNode.parentNode.parentNode.className = "active";
					navAnchor[i].parentNode.className = "active";
				 break;
			  }
            }
        }
    }


function randomImage(){
	var imgArray = new Array();
		imgArray[0] = "random_1.jpg";
		imgArray[1] = "random_2.jpg";
		imgArray[2] = "random_3.jpg";
		imgArray[3] = "random_4.jpg";
		
	var imgAlign = new Array();
		imgAlign[0] = "right";
		imgAlign[1] = "right";
		imgAlign[2] = "right";
		imgAlign[3] = "left";
		
	var imgBlock = document.getElementById("image_rotator");
	var randomNum  = Math.random();
	var num = Math.floor(randomNum * 4);
		
	imgBlock.innerHTML = "<img src=\"/images/patient/" + imgArray[num] + "\" />";
	imgBlock.style.textAlign = imgAlign[num];
}

function popUp(link){
	var newWin = window.open("", "popWin", "toolbar=no, location=no, status=no, scrollbar=no, resizable=no, width=450, height=200");
			
	var htmlText = "<html><head><title>Kuvan</title><style type=\"text/css\">body{font-family:arial, helvetica, sans-serif; font-size:12px;}</style><script type=\"text/javascript\"></script></head><body><p>The link you have selected will take you away from this site to one that is not controlled by or affiliated with KUVAN.com or BioMarin. We have not contributed to, nor do we have control over, the content of the site you have selected and accordingly, the content you are about to view cannot and should not be attributed to BioMarin.</p><p>" + "<a href=\"" + link + "\" target=\"_blank\">" +link + "</a></p><p style=\"text-align:center;\"><input type=\"button\" value=\"Continue\" onclick=\"window.open(\'"+ link +"\'); self.close();\" />&nbsp;<input type=\"button\" value=\"Cancel\" onclick=\"javascript:self.close();\" /></p></body></html>";
			
	newWin.document.write(htmlText);
}

function ref(num){
	var ref = new Array();
	var refUrl = "/Common/References.htm#r" + num;
	var newWin = window.open(refUrl, "refWin", "toolbar=no, location=no, status=no, scrollbar=no, resizable=no, width=450, height=200");
}


function eventHandler(){
	setNav();
	randomImage();
}

window.onload = eventHandler;