
function BrowserDetect() {
   var ua = navigator.userAgent.toLowerCase(); 

   // browser engine name
   this.name		  = ua;
   this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);

   // browser name
   this.isKonqueror   = (ua.indexOf('konqueror') != -1); 
   this.isSafari      = (ua.indexOf('safari') != - 1);
   this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
   this.isOpera       = (ua.indexOf('opera') != -1); 
   this.isIcab        = (ua.indexOf('icab') != -1); 
   this.isAol         = (ua.indexOf('aol') != -1); 
   this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) ); 
   this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isFirebird    = (ua.indexOf('firebird/') != -1);
   this.isNS          = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
   
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // rendering engine versions
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
   this.appleWebKitVersion = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isGecko && !this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
   }
   else if (this.isOmniweb) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
   }
   else if (this.isOpera) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
   }
   else if (this.isIcab) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin    = (ua.indexOf('win') != -1);
   this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac    = (ua.indexOf('mac') != -1);
   this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux  = (ua.indexOf('linux') != -1);
   
   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
}
var browser = new BrowserDetect();

// if IE5.5+ on Win32, then display PNGs with AlphaImageLoader
if ((browser.isIE55 || browser.isIE6up) && browser.isWin32) 
{
	var pngAlpha = true;
// else, if the browser can display PNGs normally, then do that
} else if ((browser.isGecko) || (browser.isIE5up && browser.isMac) || 
	(browser.isOpera && browser.isWin && browser.versionMajor >= 6) || 
	(browser.isOpera && browser.isUnix && browser.versionMajor >= 6) || 
	(browser.isOpera && browser.isMac && browser.versionMajor >= 5) || 
	(browser.isOmniweb && browser.versionMinor >= 3.1) || 
	(browser.isIcab && browser.versionMinor >= 1.9) || 
	(browser.isWebtv) || (browser.isDreamcast)) 
{
	var pngNormal = true;
}









var nav = (navigator.appName=="Netscape") ? true : false;
var mac = (navigator.appVersion.indexOf("Mac") != -1);
var ie = (document.all) ? true : false;

var clipboardData = "";

//*****************************************************************
//* Hashtable definitions
	Hashtable.prototype.hash = null;
	Hashtable.prototype.keys = null;
	Hashtable.prototype.location = null;

	function Hashtable()
	{
		this.hash = new Array();
		this.keys = new Array();

		this.location = 0;
	}

	Hashtable.prototype.get = function (key) {
		return this.hash[key];
	}

	Hashtable.prototype.put = function (key, value)
	{
		if (value == null)
			return null;

		if (this.hash[key] == null)
			this.keys[this.keys.length] = key;

		this.hash[key] = value;
	}
//*
//*****************************************************************

if(!document.getElementById || !document.childNodes || !document.createElement ) 
{
	alert('Your browser does not support W3C DOM functions.  You will not be able to use the features of this website correctly.  Please update your browser to a compatible version, or use a different compatible browser (example: IE 5.5+ or Netscape 6+).\n\n'+
	      'Browser information: ' + browser.name);
}

if (browser.isIE)
{
	if (!browser.isIE5up)
		alert('Your version of Internet Explorer: ' + browser.versionMajor + '.' + browser.versionMinor + ', cannot support the features of this website.  Please update Internet Explorer to at least version 5.5.');
}
else if (browser.isNS)
{
	if (!browser.isNS6up)
		alert('Your version of Netscape: ' + browser.versionMajor + '.' + browser.versionMinor + ', cannot support the features of this website.  Please update Netscape to at least version 6.0.');
}

function cursor_wait() 
{
	document.documentElement.className = 'waitCursor';
	//document.body.style.cursor = 'wait';
}

function cursor_clear() 
{
	document.documentElement.className = ''; 
	//document.body.style.cursor = 'default';
}

function setDocumentColor(color)
{
	document.body.style.backgroundColor = color;
}

function clearForm() 
{
	while (document.childNodes[0])
		document.removeChild(document.childNodes[0]);
}

function clearObject(objID)
{
	var obj = getObject(objID);
	
	if (obj)
	{
		while (obj.childNodes[0])
			obj.removeChild(obj.childNodes[0]);
	}
}

function leaveHTML(objectID)
{
	var obj = getObject(objectID);
	var iHtml = obj.innerHTML;
	
	document.body.innerHTML = iHtml;
	iHtml = document.body.outerHTML;
	
	var iHead = document.documentElement.innerHTML;
	document.write(iHead);
}

function leaveObject(objectID)
{
	var obj = getObject(objectID);
	
	if (obj)
	{
		// get the parent
		var parentObj = obj.parentNode;
		while (parentObj)
		{
			// remove all siblings
			var i=0;
			while (parentObj.childNodes[i])
			{
				if (parentObj.childNodes[i] == obj)
					i++
				else
					parentObj.removeChild(parentObj.childNodes[i]);
			}
			obj = parentObj;
			parentObj = parentObj.parentNode;
			
			if (parentObj == document)
				parentObj = null;
		}
	}
}

function setText(objID, text)
{
	clearObject(objID);
	
	var obj = getObject(objID);
	if (obj)
	{
		obj.innerHTML = text;
	}
}

function changeLocation(newLocation)
{
	//var locString = "location='"+newLocation+"'";
	//setTimeout(locString, 100);
	location=newLocation;
}

function getStyleObject(objectId) 
{
    if(document.getElementById && document.getElementById(objectId)) {
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	return document.layers[objectId];
    } else {
	return false;
    }
} 

function getObject(objectId)
{
    if(document.getElementById && document.getElementById(objectId)) {
	return document.getElementById(objectId);
    } else if (document.all && document.all(objectId)) {
	return document.all(objectId);
    } else if (document.layers) {
	return eval('document.'+objectId);
    } else {
	return false;
    }
}

function getObjectVisibility(objectId)
{
    var styleObject = getStyleObject(objectId);
    if(styleObject) 
    {
		return styleObject.visibility;
    } 
    else 
    {
        return 'hidden';
    }
}

function changeObjectVisibility(objectId, newVisibility) 
{
    var styleObject = getStyleObject(objectId);
    if(styleObject) 
    {
		styleObject.visibility = newVisibility;
		return true;
    } 
    else 
    {
		alert('no style: ' + objectId);
		return false;
    }
}

function moveObject(objectId, newXCoordinate, newYCoordinate) 
{
    var styleObject = getStyleObject(objectId);
    if(styleObject) 
    {
	 styleObject.position = 'absolute';
	 styleObject.left = newXCoordinate + 'px';
	 styleObject.top = newYCoordinate + 'px';
	 return true;
    } else {
	return false;
    }
}

function moveObjectToEvent(objectId, eventObj, offX, offY, bVAlign)
{
	var obj = getObject(objectId);
	if (!obj)
	{
		alert('No object found: ' + objectId);
		return;
	}

	var viewWidth  = (ie)?document.body.clientWidth:window.innerWidth;
	var viewHeight = (ie)?document.body.clientHeight:window.innerHeight;

	var x=0;
	var y=0;
	if ((eventObj != null))
	{
		x = (nav)?eventObj.pageX:event.clientX+document.body.scrollLeft;
		y = (nav)?eventObj.pageY:event.clientY+document.body.scrollTop;
		x += offX;
		y += offY;
	}
	else
	{
		x = viewWidth/2;
		x += (ie)?document.body.scrollLeft:window.pageXOffset;
		x -= obj.offsetWidth/2;
		if (x<0) x=0;
		y = viewHeight/2;
		y += (ie)?document.body.scrollTop:window.pageYOffset;
		y -= obj.offsetHeight/2;
		if (y<0) y=0;
	}

	if(mac&&ie){//mac ie bug fix
		winWidth = document.body.clientWidth;
		if(winWidth > 612) x -= (winWidth - 612)/2;
	}

	/////////////////////////////////////////////////////////////////
	// If the x-position will cause the object to disappear off the
	// right side of the window, try to move the object to the left
	// so that the maximum amount of object will be visible.
	if ((x+obj.offsetWidth) > viewWidth)
	{
		x -= ((x+obj.offsetWidth) - viewWidth);
		x -= 40;
		if (x < 0) x=5;
	}

	/////////////////////////////////////////////////////////////////
	// Caller can specify that the object is vertically aligned in
	// the visible browser window.
	if (bVAlign)
	{	
		y = viewHeight/2;
		y += (ie)?document.body.scrollTop:window.pageYOffset;
		y -= obj.offsetHeight/2;
		if (y<0) y=0;
	}

	/////////////////////////////////////////////////////////////////
	// Move the object to final x,y position
	moveObject(objectId, x, y);
} 

function moveObjectToMouse(objectId, eventObj)
{
    var mouseX;
    var mouseY;
    
    if (!eventObj)
        var eventObj = window.event||window.Event;

    if('undefined'!=typeof eventObj.pageX)
    {
        mouseX = eventObj.pageX;
        mouseY = eventObj.pageY;
    }
    else
    {
        var de = document.documentElement;
        var b = document.body;
        mouseX = eventObj.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        mouseY = eventObj.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
    
    moveObject(objectId, mouseX+10, mouseY);
}

function getElementPosition(elemID) 
{
    var offsetTrail = document.getElementById(elemID);
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    return {left:offsetLeft, top:offsetTop};
}

function getObjectPosition(obj)
{
    var offsetTrail = obj;
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    return {left:offsetLeft, top:offsetTop};
}

function findPos (objName)
{
	var oElmnt = getObject(objName);
	var loopE = "oElmnt";
	var XY = new Array;
	XY['locationX']=0;
	XY['locationY']=0;
	while((eval(loopE+".tagName")).toLowerCase()!="body"){
		loopE += ".offsetParent";
		XY['locationX'] += eval(loopE+".offsetLeft");
		XY['locationY'] += eval(loopE+".offsetTop");
	}
	return XY
}

function pause(numberMillis) 
{
    var now = new Date();
    var exitTime = now.getTime() + numberMillis;
    while (true) {
        now = new Date();
        if (now.getTime() > exitTime)
            return;
    }
}

function mouseInElement(elementID, eventObj)
{
    var mouseX;
    var mouseY;
    
    if (!eventObj)
        var eventObj = window.event||window.Event;

    if('undefined'!=typeof eventObj.pageX)
    {
        mouseX = eventObj.pageX;
        mouseY = eventObj.pageY;
    }
    else
    {
        var de = document.documentElement;
        var b = document.body;
        mouseX = eventObj.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        mouseY = eventObj.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
    
    return pointInElement(mouseX, mouseY, elementID);
}

function pointInElement(x, y, elementID)
{
	var obj = getObject(elementID);
	if (obj)
	{
	    return pointInObject(x, y, obj);
	}
	else
	{
	    alert('no object ' + elementID);
	}
	
	return false;
}

function pointInObject(x, y, obj)
{
	if (obj)
	{
		var objPos = getObjectPosition(obj);
		var aX = objPos.left;
		var aY = objPos.top;
		var aW = obj.offsetWidth;
		var aH = obj.offsetHeight;
		
		if ((x >= aX) && (x <= (aX+aW)) &&
			(y >= aY) && (y <= (aY+aH)))
			return true;
		else
			return false;
	}
	else
	{
	    alert('no object ');
	}
	
	return false;
}

function hLineInElement(x1, x2, y, elementID)
{
	var obj = getObject(elementID);
	if (obj)
	{
		var objPos = getElementPosition(elementID);
		var aX = objPos.left-3;  // add a little more for borders
		var aY = objPos.top-3;
		var aW = obj.offsetWidth+6;
		var aH = obj.offsetHeight+6;
		
		if ( (((x1 <= aX) && (x2 >= aX)) || 
			 ((x1 <= (aX+aW)) && (x2 >= (aX+aW)))) &&
			 ((y >= aY) && (y <= (aY+aH))) )
		{
			return true;
		}
		else
			return false;
	}
	
	return false;
}

function vLineInElement(y1, y2, x, elementID)
{
	var obj = getObject(elementID);
	if (obj)
	{
		var objPos = getElementPosition(elementID);
		var aX = objPos.left-3;  // add a little more for borders
		var aY = objPos.top-3;
		var aW = obj.offsetWidth+6;
		var aH = obj.offsetHeight+6;

		if ( (((y1 <= aY) && (y2 >= aY)) || 
			 ((y1 <= (aY+aH)) && (y2 >= (aY+aH)))) &&
			 ((x >= aX) && (x <= (aX+aW))) )
		{
			return true;
		}
		else
			return false;
	}
	
	return false;
}

function trimString (str) 
{
	while (str.charAt(0) == ' ')
		str = str.substring(1);
	while (str.charAt(str.length - 1) == ' ')
		str = str.substring(0, str.length - 1);
	return str;
}

function copyElementValueToClipboard(elementID)
{
	var obj = getObject(elementID);
	if (obj)
	{
	    if (window.netscape)
	        copyToClipboard(obj.value);
	    else
		    copyToClipboard(obj.innerText);
	}
}

function copyToClipboard(text2copy)
{
	if (window.clipboardData) 
	{
		window.clipboardData.setData("Text", text2copy);
	}
	else
	{
        var so = new SWFObject('_clipboard.swf', 'copy_contents', '0', '0', '4');
        so.addVariable('clipboard', escape(text2copy));
        so.write('flashcontent');
    }
/*    
	else
	{ 
	    alert('netscape');
		netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
		var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
		if (!clip) return;
		
		var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
		if (!trans) return;

		trans.addDataFlavor('text/unicode');

		var str = new Object();
		var len = new Object();
		var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
		var copytext=text2copy;
		str.data=copytext;
		trans.setTransferData("text/unicode",str,copytext.length*2);
		var clipid=Components.interfaces.nsIClipboard;
		if (!clip) return false;
		clip.setData(trans,null,clipid.kGlobalClipboard);
	} 
*/	
}

function hextorgb(n1,n2,n3,n4,n5,n6) 
{
	n1 = replacevals(n1);
	n2 = replacevals(n2);
	n3 = replacevals(n3);
	n4 = replacevals(n4);
	n5 = replacevals(n5);
	n6 = replacevals(n6);

	var returnval = ((16 * n1) + (1 * n2));
	var returnval1 = 16 * n3 + n4;
	var returnval2 = 16 * n5 + n6;

	return ((16 * n1) + (1 * n2))+","+((16 * n3) + (1 * n4))+","+((16 * n5) + (1 * n6));
}

function replacevals(n) 
{
	if (n == "a") { n = "10"; }
	if (n == "b") { n = "11"; }
	if (n == "c") { n = "12"; }
	if (n == "d") { n = "13"; }
	if (n == "e") { n = "14"; }
	if (n == "f") { n = "15"; }

	return n
}

function doBGFadeMem(elem,startRGB,endRGB,steps,intervals,powr) {
//BG Fader with Memory by www.hesido.com
	if (elem.bgFadeMemInt) window.clearInterval(elem.bgFadeMemInt);
	var actStep = 0;
	elem.bgFadeMemInt = window.setInterval(
		function() {
			elem.currentbgRGB = [
				easeInOut(startRGB[0],endRGB[0],steps,actStep,powr),
				easeInOut(startRGB[1],endRGB[1],steps,actStep,powr),
				easeInOut(startRGB[2],endRGB[2],steps,actStep,powr)
				];
			elem.style.backgroundColor = "rgb("+
				elem.currentbgRGB[0]+","+
				elem.currentbgRGB[1]+","+
				elem.currentbgRGB[2]+")";
			actStep++;
			if (actStep > steps) window.clearInterval(elem.bgFadeMemInt);
		}
		,intervals)
}

function easeInOut(minValue,maxValue,totalSteps,actualStep,powr) {
//Generic Animation Step Value Generator By www.hesido.com
	var delta = maxValue - minValue;
	var stepp = minValue+(Math.pow(((1 / totalSteps)*actualStep),powr)*delta);
	return Math.ceil(stepp)
}
