// JavaScript Document
var isNS4=document.layers?true:false;
var isIE=document.all?true:false;
var isIE6=isIE&&document.getElementById?true:false;
var isIE4=isIE&&!isIE6?true:false;
var isNS6=!isIE6&&document.getElementById?true:false;
var isNS=isNS4||isNS6;

function getStyle(obj,styleProp)
{
	if (window.getComputedStyle)
		var y = window.getComputedStyle(obj,null).getPropertyValue(styleProp);
	else if (obj.currentStyle)
		var y = eval('obj.currentStyle.' + styleProp);
	
	return y;
}

String.prototype.contains = function(string) {return (this.indexOf(string) > -1)}
Array.prototype.inArray = function (value){var i;for(i=0;i<this.length;i++){if(this[i]===value){return true;}}return false;};
Array.prototype.find = function(value){var i;for(i=0;i<this.length;i++){if(this[i]===value){return i;}}return -1;}
Array.prototype.removeByIndex = function(index){this.splice(index,1);}

String.prototype.replaceAll = function (from, to )
								{
									str = this;
									var idx = str.indexOf( from );
									while ( idx > -1 )
									{
										str = str.replace( from, to );
										idx = str.indexOf( from );
									}
									
									return str;
								}

function removeElement(tID)
{
    var eID = document.getElementById(tID);
    eID.parentNode.removeChild(eID);
}

function findObj(theObj, theDoc){var p, i, foundObj;if(!theDoc) theDoc = document;if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
{theDoc = parent.frames[theObj.substring(p+1)].document;theObj = theObj.substring(0,p);}if(!(foundObj = theDoc[theObj]) && theDoc.all)
foundObj = theDoc.all[theObj];for (i=0; !foundObj && i < theDoc.forms.length; i++)foundObj = theDoc.forms[i][theObj];
for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)foundObj = findObj(theObj,theDoc.layers[i].document);
if(!foundObj && document.getElementById)foundObj = document.getElementById(theObj);return foundObj;}

function gotoURL(targ){window.location=targ;}
 
function showHideLayers(){var i, visStr, obj, args = showHideLayers.arguments;for (i=0; i<(args.length-2); i+=3)
{if ((obj = findObj(args[i])) != null){visStr = args[i+2];if (obj.style){obj = obj.style;if(visStr == 'show') 
visStr = 'block';else if(visStr == 'hide') visStr = 'none';}obj.display = visStr;}}}

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;
}

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 toggleLayer(id,startShowing)
{
	if(typeof(myLayers) == 'undefined')
		window.myLayers = new Array();
	if(!myLayers[id] && startShowing)
		myLayers[id] = 'hide';
	else if(!myLayers[id])
		myLayers[id] = 'show';
	else if(myLayers[id] == 'show')
		myLayers[id] = 'hide';
	else if(myLayers[id] == 'hide')
		myLayers[id] = 'show';
	showHideLayers(id,'',myLayers[id]);
}


/*
 Set cookie code taken from: netspade.com/articles/javascript/cookies.xml
*/

function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

