var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

function isValidEmailAddress(inEmailAddress)
{
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
    
    return re.test(inEmailAddress);
}

function popWindow(url, w, h)
{
	var win = window.open(url, 'win', 'width=' + w + ',height=' + h + ',scrollbars,resizable');
	win.moveTo(screen.width/2 - w/2, screen.height/2 - h/2);
	win.focus();
}

function showTag(obj, obj2, e, hOff, vOff, col, colCount)
{
	if (obj.style.visibility == 'visible')
		hideObj(obj);
	else
	{
		ns4 = (document.layers)? true:false
		ie4 = (document.all)? true:false
		
		var msX, msY;
		
		if (ie4)
			{
			msX = e.clientX + document.body.scrollLeft;
			msY = e.clientY + document.body.scrollTop;
			brW = document.body.offsetWidth;
			brH = document.body.offsetHeight;
			}
		else
			{
			msX = e.pageX;
			msY = e.pageY;
			brW = window.innerWidth;
			brH = window.innerHeight;
			}
		if (msX < 0) {msX = 0;}
		if (msY < 0) {msY = 0;}
		
		//posX = parseInt(obj2.style.left);
		//posY = parseInt(obj2.style.top) + parseInt(obj2.style.height);
		
		//posX = 80;
		//posY = 150;
		
		//obj.style.left = posX + 'px';
		//obj.style.top = posY + 'px';
		
		//obj.style.left = parseInt(msX + hOff) + 'px';
		posX = (brW / parseFloat(colCount)) * parseInt(col) - (brW / parseFloat(colCount));
		obj.style.left = posX + 'px';
		//window.alert('brW : ' + brW + " | posX : " + posX);
		//obj.style.top = parseInt(msY + vOff) + 'px';
		obj.style.top = '280px';
		
		if (OS != "Mac")
		{
			obj.style.visibility = 'visible';
		}
	}
}

function showSubMenu(obj, e, hOff, vOff)
{
	if (st != null)
	{
		hideAllTags();
	}
	
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false
	
	obj.style.left = parseInt(hOff) + 'px';
	obj.style.top = parseInt(vOff) + 'px';
	
	if (OS != "Mac")
	{
		obj.style.visibility = 'visible';
	}
}

function maintainTag(obj)
{
	obj.style.visibility = 'visible';
}

function hideTag(obj)
{
	obj.style.visibility = 'hidden';
	obj.style.left = '-5000px';
	obj.style.top = '-5000px';
}

function hiliteCell(c, colspec)
{
	c.style.background = colspec;
}

function externaliseLinks()
{
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i < anchors.length; i++)
	{ 
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
		{
			anchor.target = "_blank";
		}
	}
}

function UpdateAllTextAreas(id, count)
{
	if (count != null)
	{
		for (var i = 1; i != (count + 1); i++)
		{
			updateTextArea(id + i);
		}
	}
}
