CSSIE6fix = function() {
// This function navigates through the DOM to make IE(6 and/or 7) behave more like it actually supports any decent CSS	
	fullBrowserDetails = navigator.userAgent;
	if (fullBrowserDetails.indexOf("MSIE 6") != -1) {
		theBrowser = "ie6";
	}
	else if (fullBrowserDetails.indexOf("MSIE 7") != -1) {
		theBrowser = "ie7";
	}
	else {
		theBrowser = "unidentified";
	}
	// IE6 + IE7 fixes (IE7 doesn't like the attribute selector for the scope attribute)
	if ( (theBrowser == "ie6") || (theBrowser == "ie7") ) {
		// style the <th> tag according to [scope] attribute
		var thArray = document.getElementsByTagName("th");
		// now mimic what it does in the CSS
		var thlen = thArray.length;
		if (thlen > 0) {
			for ( var i=0; i < thlen; i++ ) {
				if (thArray[i].getAttribute("scope") == "row") {
					thArray[i].style.backgroundColor = "#eeeeee";
					thArray[i].style.verticalAlign = "top";
				}
				else if (thArray[i].getAttribute("scope") == "col") {
					thArray[i].style.backgroundColor = "#dddddd";
					thArray[i].style.verticalAlign = "bottom";
				}
			}
		}		
	}
	// IE6 fixes (IE6 doesn't support the attribute selector)
	if ( (theBrowser == "ie6")  ) {
		// style <a> tag for documents (that is, anything that contains '.pdf' or '.doc')
		var aArray = document.getElementsByTagName("a");
		var alen = aArray.length;
		
		if (alen > 0) {
			for ( var i=0; i < alen; i++ ) {
				if (aArray[i].getAttribute("href")) {
					var ahref = aArray[i].getAttribute("href").toLowerCase();
					//document.write(ahref.length);
					if ( ahref.length > 4 ) {
						ahrefEnd = ahref.substr(ahref.length - 4, 4);
						ahrefEnd2 = ahref.substr(ahref.length - 5, 5);
						ahrefStart = ahref.substr(0,7);
						ahrefURLresult = ahref.substr(0,33);
						ahrefURLresultServer = ahref.substr(0,2);
						if ( (ahrefEnd == ".doc" ) || (ahrefEnd == ".pdf" ) || (ahrefEnd2 == ".doc/" ) || (ahrefEnd2 == ".pdf/" ) ) {
							var isDoc = true;
						}
						else {
							var isDoc = false;
						}
						if (ahrefStart == "mailto:") {
							var isMailTo = true;
						}
						else {
							var isMailTo = false;
						}
						if (ahrefEnd == ".mp3")  {
							var isAudio = true;
						}
						else {
							var isAudio = false;
						}
						if ( (ahrefURLresult != "http://www.mcknightbuilders.co.uk") && (ahrefURLresultServer != "fi") ) {
							isExternalLink = true;
						}
						else {
							isExternalLink = false;
						}
						if ( (isExternalLink) && (!isDoc) && (!isMailTo) ) {
							aArray[i].style.background = "transparent url(../images/design/externalLink.gif) center right no-repeat";
							aArray[i].style.paddingRight = "14px";
						}
						else if ( (isExternalLink) && (isMailTo) ) {
							aArray[i].style.background = "url(../images/design/email.gif) center right no-repeat";
							aArray[i].style.paddingRight = "16px";
							aArray[i].style.paddingBottom = "0px";
						}
						else if ( (isExternalLink) && (isDoc) ) {
							aArray[i].style.background = "url(../images/design/externalLinkandDoc.gif) center right no-repeat";
							aArray[i].style.paddingRight = "25px";
						}
						else if ( (!isExternalLink) && (isDoc) ) {
							aArray[i].style.background = "url(../images/design/doc.gif) center left no-repeat";
							aArray[i].style.paddingLeft = "12px";
						} 
						else if ( (!isExternalLink) && (isAudio) ) {
							aArray[i].style.background = "url(../images/design/audio.gif) center right no-repeat";
							aArray[i].style.paddingRight = "16px";
							aArray[i].style.paddingBottom = "0px";
						} 
						else if ( (isExternalLink) && (isAudio) ) {
							aArray[i].style.background = "url(../images/design/externalLinkandAudio.gif) center right no-repeat";
							aArray[i].style.paddingRight = "16px";
							aArray[i].style.paddingBottom = "0px";							
						} 
					}
				}
			}
		}
	}
}
// run the function onload
window.onload = CSSIE6fix;