// JavaScript Document Browser Fixes

/*
	Inspite of all the css options there are still problems with html.
	1) IE6 has a problem with 'img.VerticalLine' in that the vertical lines of the menu
		extend beyond the menu. Most of the time I use "vertical-align = 'middle'" but in IE6 I use
		"verticalAlign = 'top'".
*/

function getCSSRule(ruleName, deleteFlag) {                     // Return requested style obejct
	ruleName=ruleName.toLowerCase();                            // Convert test string to lower case.
	if (document.styleSheets) {                                 // If browser can play with stylesheets
		for (var i=0; i<document.styleSheets.length; i++) {     // For each stylesheet
			var styleSheet=document.styleSheets[i];             // Get the current Stylesheet
			var ii=0;                                           // Initialize subCounter.
			var cssRule=false;                                  // Initialize cssRule.
			do {                                                // For each rule in stylesheet
				if (styleSheet.cssRules) {                      // Browser uses cssRules?
					cssRule = styleSheet.cssRules[ii];          // Yes --Mozilla Style
				} else {                                        // Browser usses rules?
					cssRule = styleSheet.rules[ii];             // Yes IE style.
				}                                               // End IE check.
				if (cssRule)  {                                 // If we found a rule...
					if (cssRule.selectorText.toLowerCase()==ruleName) { //  match ruleName?
						if (deleteFlag=='delete') {             // Yes.  Are we deleteing?
							if (styleSheet.cssRules) {          // Yes, deleting...
								styleSheet.deleteRule(ii);      // Delete rule, Moz Style
							} else {                            // Still deleting.
								styleSheet.removeRule(ii);      // Delete rule IE style.
							}                                   // End IE check.
							return true;                        // return true, class deleted.
						} else {                                // found and not deleting.
							return cssRule;                     // return the style object.
						}                                       // End delete Check
					}                                           // End found rule name
				}                                               // end found cssRule
				ii++;                                           // Increment sub-counter
			} while (cssRule)                                   // end While loop
		}                                                       // end For loop
	}                                                           // end styleSheet ability check
	return false;                                               // we found NOTHING!
}                                                               // end getCSSRule

function killCSSRule(ruleName) {                          // Delete a CSS rule
	return getCSSRule(ruleName,'delete');                  // just call getCSSRule w/delete flag.
}                                                         // end killCSSRule

function addCSSRule(ruleName) {                           // Create a new css rule
	if (document.styleSheets) {                            // Can browser do styleSheets?
		if (!getCSSRule(ruleName)) {                        // if rule doesn't exist...
			if (document.styleSheets[0].addRule) {           // Browser is IE?
				document.styleSheets[0].addRule(ruleName, null,0);      // Yes, add IE style
			} else {                                         // Browser is IE?
			document.styleSheets[0].insertRule(ruleName+' { }', 0); // Yes, add Moz style.
			}                                                // End browser check
		}                                                   // End already exist check.
	}                                                      // End browser ability check.
	return getCSSRule(ruleName);                           // return rule we just created.
}

/*
Scheme  								Description
------									-----------
document.getElementById 				Detects modern browsers in general, which covers IE5+, Firefox1+, and Opera7+
window.getComputedStyle 				Detects Firefox1+ and Opera 8+
Array.every 							Detects Firefox1.5+ (method detection)
window.Iterator 						Detects Firefox2+
document.all 							Detects IE4+
window.attachEvent 						Detects IE5+
window.createPopup 						Detects IE5.5+
document.compatMode && document.all 	Detects IE6+
window.XMLHttpRequest 					Detects IE7, Firefox1+, and Opera8+
window.XMLHttpRequest && document.all 	Detects IE7. Note: Will fail if visitor explicitly disables native xmlHTTPRequest support (under Toolbar-> Internet Options-> Advanced)
document.documentElement && typeof document.documentElement.style.maxHeight!="undefined" 	Another way of detecting IE7 that is more reliable than the above.
window.opera 							Detects Opera (any version)
*/

if (document.documentElement && typeof document.documentElement.style.maxHeight!="undefined") { // Detects IE7
}
else {
	if (document.compatMode && document.all) {		// Detects IE6
		var VerticalLine = getCSSRule('img.VerticalLine');
		VerticalLine.style.verticalAlign = 'top';
	}
}
