var isWindows						= (navigator.userAgent.indexOf("Windows") >= 0);
var isLinux							= (navigator.userAgent.indexOf("Linux") >= 0);
var isMac							= (navigator.userAgent.indexOf("Mac") >= 0);
var isIE 							= (document.all && !window.opera ? true : false);
var isFirefox						= (navigator.userAgent.indexOf("Firefox") >= 0);
var isOpera 						= (window.opera ? true : false);
var isSafari						= (navigator.userAgent.indexOf("Safari") >= 0);
var isCamino						= (navigator.userAgent.indexOf("Camino") >= 0);
var isKonquerer						= (navigator.appName == "Konquerer");
var ieVersion						= -1;

/*
Uncomment when actually using

if (isIE){
	var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");

	if (re.exec(navigator.userAgent) != null){
		ieVersion = parseFloat(RegExp.$1);
	}
}
*/

if (isMac && bDOM){
	var oLink = document.createElement("link");

	oLink.setAttribute("rel", "stylesheet")
	oLink.setAttribute("type", "text/css")
	oLink.setAttribute("href", "/css/common_mac.css")

	document.getElementsByTagName("head")[0].appendChild(oLink);
}



/**
 * AjaxTip
 * @version 0.1
 * @desc Extension for prototip.js. Now it supports dynamic loading of content. (http://www.nickstakenburg.com/projects/prototip/)
 * @author Markus Geiger 2007
 * @package AjaxTip
 * @license MIT
 * @url http://blog.evolution515.net
 */
var AjaxTip;
if (typeof(Class) != 'undefined') {
	AjaxTip = Class.create(Tip, {
		hasContentLoaded: false,

		start: function() {
			this.require('Tip');
		},

		initialize: function(elem, href) {
			this.elem = elem;
			this.href = href;
			this.options = arguments[2] || {};
			this.eventMousemove = this.mousemove.bindAsEventListener(this);

			Element.observe(this.elem, 'mousemove', this.eventMousemove);
		},

		mousemove: function(e) {
			if (this.tip)
				return false;

			// Initialize Tip
			// MODIFIED
			var content = '<div class="loading"><img src="/images/ajax_loader.gif" width="24" height="24" alt="Loading" style="vertical-align: top;" /> <p>Loading&hellip;</p></div>';

			this.tip = new Tip(
				this.elem,
				content,
				this.options
			);

			// Make AJAX Request and load content
			var tip = this.tip;
			this.request = new Ajax.Request(
				this.href,
				{
					method: 'get',
					onSuccess: function(transport) {
						tip.content = transport.responseText;
						tip.tip.innerHTML = transport.responseText;
					},

					// ADDED
					onFailure: function (transport){
						top.content = "FAIL";
					}
				}
			);

			this.elem.tip = this.tip;
			Event.stopObserving(this.elem, 'mousemove', this.eventMousemove);
		}
	});
}


function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function ShowHide(toggle, target)
{
	if (target == null)
		return;

	try
	{
		var itm = document.getElementById(target);
		if (itm == null)
			return;
		if (itm.style.display == "none")
			itm.style.display = "block";
		else
			itm.style.display = "none";
	}
	catch (ex)
	{
		return;
	}
}
