
// just a general thingy to determine browsertype
var ua = navigator.userAgent;
var isOpera = isChrome = isSafari = isWebkit = isGecko = isGecko2 = isGecko3 = false;
isWebkit = /KHTML|WebKit/i.test(ua);
isOpera = /Opera/i.test(ua);
isChrome = /Chrome/i.test(ua);
isSafari = /Safari/i.test(ua) && !isChrome;
if (isGecko = !isIE && /Gecko/i.test(ua)) {
	if (/(Iceweasel|Firefox)\/3/i.test(ua)) {
		isGecko3 = true;
	} else {
		isGecko2 = true;
	}
}

// stylesheet functions to correct browsers
function createStyleSheet()
{
	var styleSheet = document.createElement('STYLE');
	styleSheet.setAttribute('type', 'text/css');
	styleSheet.setAttribute('media', 'all');
	styleSheet = document.getElementsByTagName('HEAD')[0].appendChild(styleSheet);
	if (typeof(document.styleSheets) != 'undefined' && document.styleSheets.length > 0 && !isWebkit) {
		styleSheet = document.styleSheets[document.styleSheets.length - 1];
	}
	return styleSheet;
}

function addStyleRule(styleSheet, selector, properties)
{
	if (selector.indexOf(',') != -1) {
		var parts = selector.split(',');
		for (var i = 0; i < parts.length; i++) {
			addStyleRule(styleSheet, parts[i], properties);
		}
		return;
	}
	if (typeof(styleSheet.addRule) != 'undefined' && !isWebkit) {
		styleSheet.addRule(selector, properties);
	} else if (typeof(styleSheet.insertRule) != 'undefined' && !isWebkit) {
		styleSheet.insertRule(selector + ' {' + properties + '}', styleSheet.cssRules.length);
	} else {
		styleSheet.appendChild(document.createTextNode(selector + ' {' + properties + '}'));
	}
}
