function CrossBrowserSupport() {
	var ua = navigator.userAgent.toLowerCase();
	var sf = ua.indexOf("safari") > -1;
	if (sf) {
		// find all text-less buttons and add text to them...
		var inputs = document.getElementsByTagName("INPUT");
		for (var i = 0; i < inputs.length; i++) {
			if (inputs[i].type == "submit") {
				if (inputs[i].value == "" || inputs[i].value == " ") {
					inputs[i].value = inputs[i].title ? inputs[i].title : inputs[i].id;
				}
			}
		}
	}
}

AttachOnload(CrossBrowserSupport);


function convertLinks(tagType) {
	var targets = document.getElementsByTagName(tagType); 
	if (targets) {
		for (var i = 0; i < targets.length; i++) {
			if (targets[i].rel) {
				if (targets[i].rel == "targetblank") {
					targets[i].target = "_blank";
				}
			}
		}
	}
}

function splitBrowsers(id) {
	if (typeof(document.styleSheets[id].cssRules) == "object") {
		return document.styleSheets[id].cssRules;
	}
	else {
		return document.styleSheets[id].rules;
	}
}

function getStyleBySelector( selector ) {
   var sheetList = document.styleSheets;
   var ruleList;
   var i, j;

   /* look through stylesheets in reverse order that they appear in the document */
   for (i=sheetList.length-1; i >= 0; i--) {
	   ruleList = splitBrowsers(i);
	   for (j=0; j<ruleList.length; j++) {
		   if (ruleList[j].selectorText == selector) {
				return ruleList[j].style;
		   }   
	   }
   }
   return null;
}

// Alternative to m.offsetLeft as some browsers take their offsets from the body while others take it from the parent element
function FindPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x) { curleft += obj.x; }
	return curleft;
}

// Alternative to m.offsetTop as some browsers take their offsets from the body while others take it from the parent element
function FindPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y) { curtop += obj.y; }
	return curtop;
}

function writeThickboxCSS() {
	var obj1=getStyleBySelector("#TB_overlay");
	obj1.Opacity="0.6";
	obj1.MozOpacity="0.6";
	obj1.filter="alpha(opacity=60)";

	var obj2=getStyleBySelector("#TB_HideSelect");
	obj2.Opacity="0";
	obj2.MozOpacity="0";
	obj2.filter="alpha(opacity=0)";
}
AttachOnload(CrossBrowserSupport);
AttachOnload(makeLinksPopup);
AttachOnload(writeThickboxCSS);