// Set of scripts to make everything work right on IE<7

// This script makes sure IE displays <hr> stylings properly
function styleHR(){
	var aDivs = document.getElementsByTagName('hr');
	for (var i=0; i<aDivs.length; i++) {
			var hrDiv = document.createElement("div");
			hrDiv.className = "hrDiv";
			hrDiv.innerHTML = "&nbsp;";
			//bottomDiv.appendChild(bottomSpan);
						
			aDivs[i].parentNode.insertBefore(hrDiv,aDivs[i]);
			aDivs[i].style.display = "none";
	}
}

function enableAlphaImagesByClass(objClass){
	$("." + objClass).each(function(){enableAlphaImagesOnObject(this)});
}


function enableAlphaImages(objid){
	
	 if(document.getElementById(objid)){
		 var obj = document.getElementById(objid);
		 enableAlphaImagesOnObject(obj);
	 }

}


// Universal transparent-PNG enabler for MSIE/Win 5.5+
// http://dsandler.org
// From original code: http://www.youngpup.net/?request=/snippets/sleight.xml
// and background-image code: http://www.allinthehead.com/retro/69
// Very slightly modified by Ryan Huber, VMC Communications Web Team
// also:
//  * use sizingMethod=crop to avoid scaling PNGs (who would do such a thing?)
//  * only do this once, to make it compatible with CSS rollovers

function enableAlphaImagesOnObject(obj){
	if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
		var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
		var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5 && Number(rslt[1]) < 7.0);
		if (itsAllGood) {
		
			// Modify this if you need to place your border image in a different directory
			if(window.location.toString().toLowerCase().indexOf("https:") == 0){
				serverprotocol = "https";
			} else {
				serverprotocol = "http";
			}
		
		
			var bg = obj.currentStyle.backgroundImage;
	 
			if (bg && bg.match(/\.png/i) != null) {
				var img = bg.substring(5,bg.length-2);
				var offset = obj.style.backgroundPosition;
				obj.style.filter =
				"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+img+"', sizingMethod='crop')";
				obj.style.backgroundImage = "url("+serverprotocol+"://www.vanderbilthealth.com/images/spacer.gif)";
				obj.style["background-position"] = offset; // reapply
			}
			if (obj.src && obj.src.match(/\.png$/i) != null) {
				var src = obj.src;
				obj.style.width = obj.width + "px";
				obj.style.height = obj.height + "px";
				obj.style.filter =
				"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='crop')"
				obj.src = serverprotocol + "://www.vanderbilthealth.com/images/spacer.gif";
			 }
			
	     }
	 }
}





/* 	Here we have some functions necessary to make IE behave properly with
	focus, active, and hover pseudoclasses.  Courtesy htmldog.com, "Suckerfish Shoals".
*/
function fixIEPseudoClasses() {
	
		if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
		var buttontags = document.getElementsByTagName("button");
		for (var k=0; k<buttontags.length; k++) {
			buttontags[k].onmouseover=function(){
				this.className += ' iehover';
				/*this.hideFocus=true;*/
			}
			buttontags[k].onmouseout=function(){
				/*this.blur();*/
				this.className = this.className.replace(/\biehover\b/,'');
			}
			buttontags[k].onmousedown=function(){
				this.className += "ieactive";
				/*this.hideFocus=true;*/
			}
			buttontags[k].onmouseup=function(){
				/*this.blur();*/
				this.className = this.className.replace(/\bieactive\b/,'');
			}
			
		}
	}
}


function selectFirstMenu(){
	
	if(event.srcElement.selectedIndex<0){
		event.srcElement.options[0].selected=true;
	}	
	
}