// The following are global variables which can be used to inspect the client's browser type and capabilities.
var VERSION = "1.0";
var isDHTML = 0;
var isID = 0;
var isAll = 0;
var isLayers = 0;
var isIE = 0;
var isIE5 = 0;
var isIE6 = 0;
if ( navigator.appName.indexOf( 'Microsoft Internet Explorer' ) != -1 ) { 
	isIE = 1;
	if ( navigator.userAgent.indexOf( 'MSIE 5' ) > -1 ) {
		isIE5 = 1;
	}
	if ( ( navigator.userAgent.indexOf( 'MSIE 6') > -1 ) && ( navigator.userAgent.indexOf( 'Opera' ) == -1 ) ) {
		isIE6 = 1;
	}
	
}

if ( document.getElementById ) { isID = 1; isDHTML = 1; } else {
	if ( document.all ) { isAll = 1; isDHTML = 1; } 
	else {
		browserVersion = parseInt( navigator.appVersion );
		if ( ( navigator.appName.indexOf( 'Netscape' ) != -1 ) && ( browserVersion == 4 ) ) {
			isLayers = 1; isDHTML = 1; 
		}
	}
}
var strUserAgent = navigator.userAgent.toLowerCase(); 
var isNS  = strUserAgent.indexOf("netscape") > -1 && parseFloat(navigator.appVersion ) > 5 
var isNS6 = strUserAgent.indexOf("netscape6") > -1; 
var isNS4 = !isIE && !isNS6  && parseFloat(navigator.appVersion ) < 5; 
var isMoz = ( strUserAgent.indexOf( "ecko" ) != -1 ) ? 1 : 0;
var isOpera = ( strUserAgent.indexOf( "Opera" ) != -1 ) ? 1 : 0;
var isSafari = ( strUserAgent.indexOf( "Safari" ) != -1 ) ? 1 : 0;
var isFirefox = ( strUserAgent.indexOf( "firefox" ) != -1 ) ? 1 : 0;

// Return the version of this library.
function getDHTMLLibraryVersion() {
	return( VERSION );
}

// #region Retrieve the Object or the Objects Style.
// <summary>
// Given an Object Id, return the actual Object regardless of the browser type.
// getObject( 'myobjectsid' ).value = '123';
// </summary>
// <param name="objectID">The id of the Object to retrieve</param>
function getObject( objectID ) {
	try {
		if ( isID ) {
			return( document.getElementById( objectID ) );
		} else if ( isAll ) {
			return( document.all[ objectID ] );
		} else if ( isLayers ) {
			return( document.layers[ objectID ] );
		}
	} catch(e) {
		return( null );
	}
}
// <summary>
// Retrieve the actual DOM object, or it's style object.  
// findDOM( 'myobjecsid', 1 ).backgroundColor = '#FF0000';
// </summary>
// <param name="objectID">The id of the Object to retrieve</param>
// <param name="withStyle">1 or true if the style object should be retrieved.  
// Or 0 or false to retrieve the object.</param>
function findDOM( objectID, withStyle ) {
	try {
		if ( withStyle ) {
			if ( isID ) {
				return( document.getElementById( objectID ).style );
			} else if ( isAll ) {
				return( document.all[ objectID ].style );
			} else if ( isLayers ) {
				return( document.layers[ objectID ] );
			}
		} else {
			return( getObject( objectID ) );
		}
	} catch(e) {
		return( null );
	}
}
// #endregion

// #region createObject()
// <summary>
// Given the specified Tag Name, create a new Element and return it.
// </summary>
// <param name="tagName">The name of the Tag to create</param>
function createObject( tagName ) {
	return( document.createElement( tagName ) );
}
// #endregion

// #region getPageMode()
// <summary>
// Determine if we should be rendering anything special 
// based on the browser's handling of CSS.
// </summary>
function getPageMode() {
	if ( document.compatMode ) {
		switch ( document.compatMode ) {
			case "BackCompat":
				return 0;
			case "CSS1Compat":
				return 1;
			case "QuirksMode":
				return 0;
		}
	}
	else {
		if (isIE5()) {
			return 0;
		}
		if (isSafari()) {
			return 1;
		}
	}
	return 0;
}
// #endregion

// #region Object Properties
// get the true offset of anything on NS4, IE4/5 & NS6, even if it's in a table!
// <summary>
// Return the Absolute X position for the specified object reference.
// </summary>
// <param name="el">The object reference to query.</param>
function getObjectAbsX(el ) {
	return (el.x ) ? el.x : getObjectAbsPos(el,"Left"); 
}

// <summary>
// Return the Absolute X positon for the specified Object Id.
// </summary>
// <param name="el">The object reference to query.</param>
function getAbsX(objectID ) { 
	var el = findDOM( objectID, 0 );
	return (el.x ) ? el.x : getAbsPos(el,"Left"); 
}

// <summary>
// Return the Absolute Y position for the specified object reference.
// </summary>
// <param name="el">The object reference to query.</param>
function getObjectAbsY(el ) { 
	return (el.y ) ? el.y : getObjectAbsPos(el,"Top"); 
}

// <summary>
// Return the Absolute Y positon for the specified Object Id.
// </summary>
// <param name="objectID">The Id of the Object to query.</param>
function getAbsY(objectID ) { 
	var el = findDOM( objectID, 0 );
	return (el.y ) ? el.y : getAbsPos(el,"Top"); 
}

// <summary>
// Determines the actual offsetTop or offsetLeft of the object specified.
// </summary>
// <param name="el">The actual Element reference to use.</param>
// <param name="which">Which location are we concerned with?  (i.e. Top or Left)</param>
function getObjectAbsPos(el,which ) {
	iPos = 0;
	while (el != null ) {
		iPos += el["offset" + which];
		el = el.offsetParent;
	}
	return iPos;
}

// <summary>
// Determines the actual offsetTop or offsetLeft of the object specified.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
// <param name="which">Which location are we concerned with?  (i.e. Top or Left)</param>
function getAbsPos(objectID,which ) {
	var el = findDOM( objectID, 0 );
	iPos = 0;
	while (el != null ) {
		iPos += el["offset" + which];
		el = el.offsetParent;
	}
	return iPos;
}

// <summary>
// Returns the absolute bottom position for an Object.  Useful for Dropdown
// controls.
// </summary>
// <param name="el">The actual Element reference to use.</param>
function getObjectAbsBottom( el ) {
	return( getObjectAbsY( el ) + getObjectHeight( el ) );
}

// <summary>
// Returns the absolute top position for an Object.  Useful for Dropdown
// controls.
// </summary>
// <param name="el">The actual Element reference to use.</param>
function getObjectAbsTop( el ) {
	return( getObjectAbsY( el ) );
}

// <summary>
// Returns the absolute top right position for an Object.  Useful for Dropdown
// controls.
// </summary>
// <param name="el">The actual Element reference to use.</param>
function getObjectAbsRight( el ) {
	return( getObjectAbsX( el ) + getObjectWidth( el ) );
}

// <summary>
// Returns the absolute top left position for an Object.  Useful for Dropdown
// controls.
// </summary>
// <param name="el">The actual Element reference to use.</param>
function getObjectAbsLeft( el ) {
	return( getObjectAbsX( el ) );
}

// <summary>
// Return the Width of the specified Object reference.
// </summary>
// <param name="el">The Object reference to use.
function getObjectWidth( el ) {
	if ( el.offsetWidth ) {
		if ( el.offsetWidth != null ) {
			return( el.offsetWidth );
		}
		else {
			var o = 0;
			while( ( el = el.offsetParent ) != null ) {
				o += el.offsetLeft;
			}
			return( o );
		}
	}
	else if ( el.width ) {
		return( el.width );
	}
	else if ( el.clip.width ) {
		return( el.clip.width );
	}
	else {
		return( null );
	}
}

// <summary>
// Return the Width of the specified Object.  It must have a predefined CSS style to work correctly.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
function getWidth( objectID ) {
	var dom = findDOM( objectID, 0 );
	if ( dom.offsetWidth ) { 
		if ( dom.offsetWidth != null ) {
			return( dom.offsetWidth ); 
		}
		else {
			var o = 0;
			while( ( dom = dom.offsetParent ) != null ) {
				o += dom.offsetLeft;
			}
			return( o );
		}
	}
	else if ( dom.width ) { 
		return( dom.width ); 
	}
	else if ( dom.clip.width ) { 
		return( dom.clip.width ); 
	}
	else { 
		return( null ); 
	}
}

// <summary>
// Return the Height of the specified Object reference.
// </summary>
// <param name="el">The Object to use.</param>
function getObjectHeight( el ) {
	if ( el.offsetHeight ) { 
		if ( el.offsetHeight != null ) {
			return( el.offsetHeight ); 
		}
		else {
			var o = 0;
			while( ( el = el.offsetParent ) != null ) {
				o += el.offsetHeight;
			}
			return( o );
		}
	}
	else if ( el.height ) { 
		return( el.height );
	}
	else if ( el.clip ) {
	    if ( el.clip.height ) {
		    return( el.clip.height );
		}
		return( null );
	}
	else {
		return( null );
	}
}

// <summary>
// Return the Height of the specified Object.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
function getHeight( objectID ) {
	var dom = findDOM( objectID, 0 );
	if ( dom.offsetHeight ) { 
		if ( dom.offsetHeight != null ) {
			return( dom.offsetHeight ); 
		}
		else {
			var o = 0;
			while( ( dom = dom.offsetParent ) != null ) {
				o += dom.offsetHeight;
			}
			return( o );
		}
	}
	else if ( dom.height ) { 
		return( dom.height );
	}
	else if ( dom.clip.height ) {
		return( dom.clip.height );
	}
	else {
		return( null );
	}
}

// <summary>
// Return the Left coordinate (x) of the specified Object.
// </summary>
// <param name="el">The Object to use.</param>
function getObjectLeft( el ) {
	var domStyle = findDOM( el.id, 1 );
	var dom = el;
	if ( domStyle.left ) { 
		if ( domStyle.left != null ) {
			return( domStyle.left ); 
		}
		else {
			var o = 0;
			while( ( dom = dom.offsetParent ) != null ) {
				o += dom.offsetLeft;
			}
			return( o );
		}
	}
	else if ( domStyle.pixelLeft ) { 
		return( domStyle.pixelLeft );
	}
	else if ( dom.offsetLeft ) { 
		if ( navigator.userAgent.indexOf( "Mac" ) != -1 && typeof document.body.leftMargin != "undefined" ) {
			return( dom.offsetLeft + document.body.leftMargin );
		}
		return( dom.offsetLeft );
	}
	else {
		// Try one last ditch effort to retrieve the offsetLeft
		var o = 0;
		while( ( dom = dom.offsetParent ) != null ) {
			o += dom.offsetLeft;
		}
		return( o );
	}
}

// <summary>
// Return the Left coordinate (x) of the specified Object.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
function getLeft( objectID ) {
	var domStyle = findDOM( objectID, 1 );
	var dom = findDOM( objectID, 0 );
	if ( domStyle.left ) { 
		if ( domStyle.left != null ) {
			return( domStyle.left ); 
		}
		else {
			var o = 0;
			while( ( dom = dom.offsetParent ) != null ) {
				o += dom.offsetLeft;
			}
			return( o );
		}
	}
	else if ( domStyle.pixelLeft ) { 
		return( domStyle.pixelLeft );
	}
	else if ( dom.offsetLeft ) { 
		if ( navigator.userAgent.indexOf( "Mac" ) != -1 && typeof document.body.leftMargin != "undefined" ) {
			return( dom.offsetLeft + document.body.leftMargin );
		}
		return( dom.offsetLeft );
	}
	else {
		// Try one last ditch effort to retrieve the offsetLeft
		var o = 0;
		while( ( dom = dom.offsetParent ) != null ) {
			o += dom.offsetLeft;
		}
		return( o );
	}
}

// <summary>
// Return the Top coordinate (y) of the specified Object.
// </summary>
// <param name="el">The Object to use.</param>
function getObjectTop( el ) {
	var domStyle = findDOM( el.id, 1 );
	var dom = el;
	if ( domStyle.top ) { 
		return( domStyle.top );
	}
	else if ( domStyle.pixelTop ) { 
		return( domStyle.pixelTop );
	}
	else if ( dom.offsetTop ) { 
		if ( navigator.userAgent.indexOf( "Mac" ) != -1 && typeof document.body.leftMargin != "undefined" ) {
			return( dom.offsetTop + document.body.topMargin );
		}
		return( dom.offsetTop );
	}
	else {
		// Try one last ditch effort to retrieve the offsetTop
		var o = 0;
		while( ( dom = dom.offsetParent ) != null ) {
			o += dom.offsetTop;
		}
		return( o );
	}
}

// <summary>
// Return the Top coordinate (y) of the specified Object.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
function getTop( objectID ) {
	var domStyle = findDOM( objectID, 1 );
	var dom = findDOM( objectID, 0 );
	if ( domStyle.top ) { 
		return( domStyle.top );
	}
	else if ( domStyle.pixelTop ) { 
		return( domStyle.pixelTop );
	}
	else if ( dom.offsetTop ) { 
		if ( navigator.userAgent.indexOf( "Mac" ) != -1 && typeof document.body.leftMargin != "undefined" ) {
			return( dom.offsetTop + document.body.topMargin );
		}
		return( dom.offsetTop );
	}
	else {
		// Try one last ditch effort to retrieve the offsetTop
		var o = 0;
		while( ( dom = dom.offsetParent ) != null ) {
			o += dom.offsetTop;
		}
		return( o );
	}
}

// <summary>
// Returns the Right coordinate of the specified Object.  (x + width)
// </summary>
// <param name="el">The Object to use.</param>
function getObjectRight( el ) {
	var domStyle = findDOM( el.id, 1 );
	var dom = el;
	if ( dom.left ) {
		return( domStyle.left + domStyle.clip.width );
	}
	if ( domStyle.pixelLeft ) {
		return( domStyle.pixelLeft + dom.offsetWidth );
	}
	if ( dom.offsetLeft ) {
		return( dom.offsetLeft + dom.offsetWidth );
	}
	else {
		return( null );
	}
}

// <summary>
// Returns the Right coordinate of the specified Object.  (x + width)
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
function getRight( objectID ) {
	var domStyle = findDOM( objectID, 1 );
	var dom = findDOM( objectID, 0 );
	if ( dom.left ) {
		return( domStyle.left + domStyle.clip.width );
	}
	if ( domStyle.pixelLeft ) {
		return( domStyle.pixelLeft + dom.offsetWidth );
	}
	if ( dom.offsetLeft ) {
		return( dom.offsetLeft + dom.offsetWidth );
	}
	else {
		return( null );
	}
}

// <summary>
// Returns the Bottom coordinate of the specified Object.  (y + height)
// </summary>
// <param name="el">The Object to use.</param>
function getObjectBottom( el ) {
	var domStyle = findDOM( el.id, 1 );
	var dom = el;
	if ( domStyle.top ) {
		return( domStyle.top + domStyle.clip.height );
	}
	if ( domStyle.pixelTop ) {
		return( domStyle.pixelTop + dom.offsetHeight );
	}
	if ( dom.offsetTop ) {
		return( dom.offsetTop + dom.offsetHeight );
	}
	return( null );
}

// <summary>
// Returns the Bottom coordinate of the specified Object.  (y + height)
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
function getBottom( objectID ) {
	var domStyle = findDOM( objectID, 1 );
	var dom = findDOM( objectID, 0 );
	if ( domStyle.top ) {
		return( domStyle.top + domStyle.clip.height );
	}
	if ( domStyle.pixelTop ) {
		return( domStyle.pixelTop + dom.offsetHeight );
	}
	if ( dom.offsetTop ) {
		return( dom.offsetTop + dom.offsetHeight );
	}
	return( null );
}


// <summary>
// Move the specified object to the specified coordinates.  Please note that the object should be marked as position: absolute in it's style definition.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
// <param name="x">The x coordinate to move to.</param>
// <param name="y">The y coordinate to move to.</param>
function moveObject( objectID, x, y ) {
	var domStyle = findDOM( objectID, 1 );
	var dom = findDOM( objectID, 0 );
	
	domStyle.left = x;
	domStyle.top = y;
}

// <summary>
// Move the object diagonally using the specified x and y deltas.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
// <param name="deltaX">The x coordinate to change by.</param>
// <param name="deltaY">The y coordinate to change by.</param>
function moveObjectBy( objectID, deltaX, deltaY ) {
	var domStyle = findDOM( objectID, 1 );
	var dom = findDOM( objectID, 0 );
	if ( domStyle.pixelLeft ) {
		domStyle.pixelLeft += deltaX;
		domStyle.pixelTop += deltaY;
	} else {
		if ( dom.offsetLeft != null ) {
			var plusLeft = dom.offsetLeft;
			var plusTop = dom.offsetTop;
			domStyle.left = deltaX + plusLeft;
			domStyle.top = deltaY + plusTop;
		} else {
			dom.moveBy( deltaX, deltaY );
		}
	}
}

// <summary>
// Center the object in the middle of the visible screen.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
/*  Old Code 
function centerObject( objectID ) {
	var left = documentXCenter() - ( getWidth( objectID ) / 2 ) + 'px';
	var top = documentYCenter() - ( getHeight( objectID ) / 2 ) + 'px';
	moveObject( objectID, left, top );
}
*/
function centerObject( objectID ) {
    var left = 0, top = 0;
    var myWidth = 0, myHeight = 0;
    if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    left = ( myWidth / 2 ) - ( getWidth( objectID ) / 2 ) + 'px';
    top  = ( myHeight / 2 ) - ( getHeight( objectID ) / 2 ) + 'px';
    moveObject( objectID, left, top ); 
}


// <summary>
// Method which will determine the browser window's Width.
// </summary>
function windowWidth() {
	var windowWidth;
    if ( isFirefox ) {
	    windowWidth = window.innerWidth;
	} else if ( isIE ) {
	    if ( document.documentElement && document.documentElement.clientWidth ) {
    		windowWidth = document.documentElement.clientWidth;
    	}
    	else {
    		windowWidth = document.body.clientWidth;
    	}
	} else if ( isID ) {
		windowWidth = self.innerWidth;
	} else {
		windowWidth = document.body.clientWidth;
	}
	return( windowWidth );
}

// <summary>
// Method which will determine the browser window's Height.
// </summary>
function windowHeight() {
	var windowHeight;
    if ( isFirefox ) {
	    windowHeight = window.innerHeight;
	} else if ( isIE ) {
	    if ( document.documentElement && document.documentElement.clientHeight ) {
    		windowHeight = document.documentElement.clientHeight;
    	}
    	else {
    		windowHeight = document.body.clientHeight;
    	}
	} else if ( isID ) {
		windowHeight = self.innerHeight;
	} else {
		windowHeight = document.body.clientHeight;
	}
	return( windowHeight );
}

// <summary>
// Returns the width of the document minus any scrollbar width which may exist.
// </summary>
function documentWidth() {
	var documentWidth;
    if ( isFirefox ) {
	    documentWidth = document.width - 20;
	} else if ( isIE ) {
		documentWidth = document.body.offsetWidth + document.body.scrollLeft - 20;
	} else if ( isID ) {
		documentWidth = self.innerWidth + window.pageXOffset - 20;
	} else {
		documentWidth = window.innerWidth + window.pageXOffset - 20;
	}
	return( documentWidth );
}

// <summary>
// Returns the height of the document minus any scrollbar height which may exist.
// </summary>
function documentHeight() {
	var documentHeight;
	if ( isFirefox ) {
	    if ( window.innerHeight ) {
	        documentHeight = window.innerHeight;
	    }
	    else {
	        documentHeight = document.height;
	    }
	} else if ( window.innerHeight != null ) {
	    documentHeight = window.innerHeight;
	} else if ( document.body.ClientHeight != null ) {
	    documentHeight = document.body.clientHeight;
	} else if ( isIE ) {
		documentHeight = document.body.offsetHeight + document.body.scrollTop - 20;
	} else if ( isID ) {
		documentHeight = self.innerHeight + window.pageYOffset - 20;
	} else {
		documentHeight = window.innerHeight + window.pageYOffset - 20;
	}
	return( documentHeight );
}

// <summary>
// Returns the x coordinate of the document center.
// </summary>
function documentXCenter() {
	return( documentWidth() / 2 );
}

// <summary>
// Returns the y coordinate of the document center.
// </summary>
function documentYCenter() {
	return( documentHeight() / 2 );
}

// <summary>
// Return the Z-index of the object.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
function getZIndex( objectID ) {
	var domStyle = findDOM( objectID, 1 );
	if ( domStyle.zIndex != null ) {
		return( domStyle.zIndex );
	}
	return( null );
}

// <summary>
// Change the Z-index of the object.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
// <param name="idx">The Z-index to assign to this Object.</param>
function setZIndex( objectID, idx ) {
	var domStyle = findDOM( objectID, 1 );
	domStyle.zIndex = idx;
}

// <summary>
// Set the clip which exists for an object.  Useful if you want to hide certain portions of the content.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
// <param name="clipTop">The top clip coordinate.</param>
// <param name="clipRight">The right clip coordinate.</param>
// <param name="clipBottom">The bottom clip coordinate.</param>
// <param name="clipLeft">The left clip coordinate.</param>
function setClip( objectID, clipTop, clipRight, clipBottom, clipLeft ) {
	var dom = findDOM( objectID, 1 );
	if ( dom.clip.left ) { 
		dom.clip.top = clipTop;
		dom.clip.right = clipRight;
		dom.clip.bottom = clipBottom;
		dom.clip.left = clipLeft;
	}
	dom.clip = 'rect(' + clipTop + ' ' + clipRight + ' ' + clipBottom + ' ' + clipLeft + ')';
}

// <summary>
// Return the Clipping top coordinate for the Object.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
function getClipTop( objectID ) {
	var dom = findDOM( objectID, 1 );
	if ( dom.clip.top ) {
		return( dom.clip.top );
	}
	if ( dom.clip != null ) {
		var clip = getClipArray( dom.clip );
		return( clip[0] );
	}
	return( null );
}

// <summary>
// Return the Clipping right coordinate for the Object.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
function getClipRight( objectID ) {
	var dom = findDOM( objectID, 1 );
	if ( dom.clip.right ) {
		return( dom.clip.right );
	}
	if ( dom.clip != null ) {
		var clip = getClipArray( dom.clip );
		return( clip[1] );
	}
	return( null );
}

// <summary>
// Return the Clipping bottom coordinate for the Object.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
function getClipBottom( objectID ) {
	var dom = findDOM( objectID, 1 );
	if ( dom.clip.bottom ) {
		return( dom.clip.bottom );
	}
	if ( dom.clip != null ) {
		var clip = getClipArray( dom.clip );
		return( clip[2] );
	}
	return( null );
}

// <summary>
// Return the Clipping left coordinate for the Object.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
function getClipLeft( objectID ) {
	var dom = findDOM( objectID, 1 );
	if ( dom.clip.left ) {
		return( dom.clip.left );
	}
	if ( dom.clip != null ) {
		var clip = getClipArray( dom.clip );
		return( clip[3] );
	}
	return( null );
}

// <summary>
// Return the clipping width for the Object.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
function getClipWidth( objectID ) {
	var dom = findDOM( objectID, 1 );
	if ( dom.clip.width ) {
		return( dom.clip.width );
	}
	if ( dom.clip != null ) {
		var clip = getClipArray( dom.clip );
		return( clip[1] - clip[3] );
	}
	return( null );
}

// <summary>
// Return the clipping height for the Object.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
function getClipHeight( objectID ) {
	var dom = findDOM( objectID, 1 );
	if ( dom.clip.height ) {
		return( dom.clip.height );
	}
	if ( dom.clip != null ) {
		var clip = getClipArray( dom.clip );
		return( clip[2] - clip[0] );
	}
	return( null );
}

// <summary>
// Return an Array for a clip definition.
// </summary>
// <param name="clipStr">The clipping definition to parse.</param>
function getClipArray( clipStr ) {
	var clip = new Array();
	var i;
	i = clipStr.indexOf( '(');
	clip[0] = parseInt( clipStr.substring( i + 1, clipStr.length ), 10 );
	i = clipStr.indexOf( ' ', i + 1 );
	clip[1] = parseInt( clipStr.substring( i + 1, clipStr.length ), 10 );
	i = clipStr.indexOf( ' ', i + 1 );
	clip[2] = parseInt( clipStr.substring( i + 1, clipStr.length ), 10 );
	i = clipStr.indexOf( ' ', i + 1 );
	clip[3] = parseInt( clipStr.substring( i + 1, clipStr.length ), 10 );
	return( clip );
}

// Visibility
// <summary>
// Set the CSS visiblity of the specified Object.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
// <param name="state">The state of visibility for the object to set.</param>
function setVisibility( objectID, state ) {
	var dom = findDOM( objectID, 1 );
	dom.visibility = state;
}

// <summary>
// Return the current CSS visibility value.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
function getVisibility( objectID ) {
	var dom = findDOM( objectID, 1 );
	if ( ( dom.visibility == 'show' ) || ( dom.visibility == 'visible' ) ) {
		return( 'visible' );
	}
	return( 'hidden' );
}

// <summary>
// Toggle the CSS visibility of the object.  (i.e. Hide or Show the object based on it's previous state)
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
function toggleVisibility( objectID ) {
	var dom = findDOM( objectID, 1 );
	state = dom.visibility;
	if ( state == 'hidden' || state == 'hide' || state == 'none' ) {
		dom.visibility = 'visible';
	} else {
		if ( state == 'visible' || state == 'show' ) {
			dom.visibility = 'hidden';
		}
		else {
			dom.visibility = 'visible';
		}
	}
}

function toggleObject( objectID ) {
	var domStyle = findDOM( objectID, 1 );
	if ( domStyle.display != "block" || domStyle.display == "none" ) {
	    expandObject( objectID );
	}
	else {
	    collapseObject( objectID );
	}
}

// Collapse the object
// <summary>
// Hide all child objects underneath the specified Object.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
function collapseObject( objectID ) {
	var domStyle = findDOM( objectID, 1 );
	if ( isID ) { 
	    try {
		    domStyle.display = "none"; 
		} catch( e ) {
		}
	}
	else {
		domStyle.display = "none";
	}
}

// <summary>
// Show all child objects underneath the specified Object.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
function expandObject( objectID ) {
	var domStyle = findDOM( objectID, 1 );
	if ( isID ) { 
		domStyle.display = "block"; 
	}
	else {
		domStyle.display = "block";
	}
}

// <summary>
// Is the specified Object currently visible?
// </summary>
function isExpanded( objectID ) {
	var domStyle = findDOM( objectID, 1 );
	if ( domStyle.display == "block" )
	    return true;
	return false;
}

// <summary>
// Hide the specified Object.  Mark it's CSS visiblity as 'hidden'.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
function hideObject( objectID ) {
	var domStyle = findDOM( objectID, 1 );
	if ( isID ) { 
		domStyle.visibility = "hidden"; 
	}
	else {
		domStyle.visibility = "hide";
	}
}

// <summary>
// Show the specified Object.  Mark it's CSS visibility as 'visible'.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
function showObject( objectID ) {
	var domStyle = findDOM( objectID, 1 );
	if ( isID ) { 
		domStyle.visibility = "visible";
	}
	else { 
		domStyle.visibility = "show";
	}
}

// <summary>
// Hide all objects which match the specified tag.  For example, "select" which would 
// hide all select objects on the page.  Useful since selects will appear above any floating content.
// </summary>
// <param name="objectType">The tag to use to select objects.</param>
function hideElements( objectType ) { 
	var elements = document.getElementsByTagName( objectType ); 
	for ( var i = 0; i < elements.length; i++ ) { 
		hideObject( elements[i].id );
	} 
}

// <summary>
// Show all objects which match the specified tag.  Useful if you've hidden them before.
// </summary>
// <param name="objectType">The tag to use to select objects.</param>
function showElements( objectType ) { 
	var elements = document.getElementsByTagName( objectType ); 
	for ( var i = 0; i < elements.length; i++ ) { 
		showObject( elements[i].id );
	} 
}

// <summary>
// Open a new window.
// </summary>
// <param name="contentURL">The Url to navigate the window to.</param>
// <param name="windowName">The internal name of the window</param>
// <param name="windowWidth">The width of the window.</param>
// <param name="windowHeight">The height of the window.</param>
var newWindow = null;
function openWindow( contentURL, windowName, windowWidth, windowHeight ) {
	widthHeight = 'height=' + windowHeight + ',width=' + windowWidth;
	newWindow = window.open( contentURL, windowName, widthHeight );
	newWindow.focus();
	return( newWindow );
}

// <summary>
// Close any previously opened windows.
// </summary>
function closeWindow() {
	if ( newWindow != null ) {
		newWindow.close();
		newWindow = null;
	}
}

// <summary>
// Open and set the focus on the newly opened window.
// </summary>
// <param name="contentURL">The Url to navigate the window to.</param>
// <param name="windowName">The internal name of the window</param>
// <param name="windowWidth">The width of the window.</param>
// <param name="windowHeight">The height of the window.</param>
function toggleWindow( contentURL, windowName, windowWidth, windowHeight ) {
	if ( newWindow == null ) {
		widthHeight = 'height=' + windowHeight + ',width=' + windowWidth;
		newWindow = window.open( contentURL, windowName, widthHeight );
		newWindow.focus();
	} else {
		newWindow.close();
		newWindow = null;
	}
}

// <summary>
// Maximize the browser window.
// </summary>
function maximizeNetscapeScreen() {
	if (window.screen ) {
		window.moveTo(0,0 );
		window.outerHeight = screen.availHeight;
		window.outerWidth = screen.availWidth;
		window.focus();
	} else {
		window.moveTo(0,0 );
		window.resizeTo(screen.availWidth,screen.availHeight );
		window.focus();
	}
}

// Event Locations
// <summary>
// Determine the x coordinate for the event (usually a mouse click).
// </summary>
// <param name="evt">The event to inspect.</param>
function getXLoc( evt ) {
  if ( !evt ) {
    var evt = window.event;
  }
  if ( evt.x ) {
     return( evt.x );
  }
  else if ( evt.pageX ) {
	return( evt.pageX );
  }
  else {
	if ( isSafari ) {
		return( evt.clientX - document.documentElement.scrollLeft );
	}
	else {
		return( evt.clientX );
	}
  }
}

// <summary>
// Determine the y coordinate for the event (usually a mouse click).
// </summary>
// <param name="evt">The event to inspect.</param>
function getYLoc( evt ) {
  if ( !evt ) {
    var evt = window.event;
  }
  if ( evt.y ) {
     return( evt.y );
  }
  else if ( evt.pageY ) {
	return( evt.pageY );
  }
  else {
	if ( isSafari ) {
		return( evt.clientY - document.documentElement.scrollTop );
	}
	else {
		return( evt.clientY );
	}
  }
}

// <summary>
// Locate the id of the Object which was just clicked.
// </summary>
// <param name="evt">The event to inspect.</param>
function getObjectClicked( evt ) {
	var name = null;
	if ( document.layers ) {
		var testObj;
		var xpos = getXLoc( evt );
		var ypos = getYLoc( evt );
		for ( var i = document.layers.length - 1; i >= 0; i-- ) {
			testObj = document.layers[i];
			if ( ( xpos > testObj.left ) &&
				 ( xpos < testObj.left + testObj.clip.width ) &&
				 ( ypos > testObj.top ) &&
				 ( ypos < testObj.top + testObj.clip.height ) ) {
				objectID = testObj.id;
				return( objectID );
			}
		}
	} else {
		objectID = event.srcElement.id;
		return( objectID );
	}
	return;
}

// Style Functions
// <summary>
// Set the CSS class on the specified Object.
// </summary>
// <param name="objectID">The Id of the Object to use.</param>
// <param name="newClass">The CSS class to assign to the object.</param>
function setClass( objectID, newClass ) {
	var dom = findDOM( objectID, 0 );
	dom.className = newClass;
}

// <summary>
// Disable the specified style.
// </summary>
// <param name="styleName">The name of the style to disable.</param>
function disableStyle( styleName ) {
	eval( 'document.styleSheets.' + styleName + '.disabled = true' );
}

// <summary>
// Re-enable a disabled style.
// </summary>
// <param name="styleName">The name of the style to enable.</param>
function enableStyle( styleName ) {
	eval( 'document.styleSheets.' + styleName + '.disabled = false' );
}

// Image Functions
// <summary>
// Preload a image.
// </summary>
// <param name="imgObj">The image object assigned the image.</param>
// <param name="imgSrc">The Uri of the image to load.</param>
function preloadImage( imgObj, imgSrc ) {
	if ( document.images ) {
		eval( imgObj + ' = new Image()' );
		eval( imgObj + '.src = "' + imgSrc + '"' );
	}
}

// <summary>
// Swap the url of an image.
// </summary>
// <param name="layer">Specify if a layer exists.  Else pass in null.</param>
// <param name="imgName">The name of the Image to change.</param>
// <param name="imgObj">The preloaded Image object which contains the new image source.</param>
function changeImage( layer, imgName, imgObj ) {
	if ( document.images ) {
		if ( document.layers && layer != null ) { 
			eval( 'document.' + layer + '.document.images["' + imgName + '"].src = ' + imgObj + '.src' );
		}
		else { 
			document.images[imgName].src = eval( imgObj + ".src" );
		}

	}
}

// Layer Functions
// <summary>
// Create and append the specified Text as a child of the specified Layer.
// </summary>
// <param name="layerid">The Id of the object to append to.</param>
// <param name="text">The Text to append.</param>
function writeLayerContent( layerid, text ) {
	if ( isDHTML ) {
		var doc = findDOM( layerid, 0 );
		var child = document.createTextNode( text );
		doc.appendChild(child );
	} else {
		var doc = findDOM( layerid, 0 ).document;
		doc.open();
		doc.write( text );
		doc.close();
	}
}


// <summary>
// Restart a paused sliding Object.
// </summary>
var pause = false;
var pauseobjs = new Array();
function startSlide() {
	pause = false;
}

// <summary>
// Intialize and start the specified Object sliding.
// </summary>
// <param name="objectID">the Object to start sliding.</param>
function startObjectSlide( objectID ) {
   var copy = new Array();
   for ( i = 0; i < pauseobjs.length; i++ ) {
	if ( pauseobjs[i] != objectID ) {
	   copy[copy.length] = pauseobjs[i];
	}
   }
   pauseobjs = copy;
}

// <summary>
// Pause all sliding which is occurring.
// </summary>
function pauseSlide() {
	pause = true;
}

// <summary>
// Pause the specified Object from sliding.
// </summary>
// <param name="objectID">The Id of the object to stop sliding.</param>
function pauseObjectSlide( objectID ) {
	pauseobjs[pauseobjs.length] = objectID;
}

// <summary>
// Move the specified object in a horizontal and vertical direction over time.
// </summary>
// <param name="objectID">The Id of the object to move.</param>
// <param type="x">The ending X coordinate.</param>
// <param name="y">The ending Y coordinate.</param>
// <param name="xinterval">The interval to increment the X coordinate by.</param>
// <param name="yinterval">The interval to increment the Y coordinate by.</param>
// <param name="delay">How much time should be elapsed between each movement.</param>
function slideObject( objectID, x, y, xinterval, yinterval, delay ) {
	var pausethis = false;
	try {
		for ( idx = 0; idx < pauseobjs.length; idx++ ) {
			if ( pauseobjs[idx] == objectID ) {
				pausethis = true;
			}
		}   
	} catch(ex ){
		window.status = ex;
	}

	if ( pause == true ) {
		setTimeout( "slideObject('" + objectID + "'," + x + "," + y + "," + xinterval + "," + yinterval + "," + delay + ")", delay );
	} 
	else if ( pausethis == true ) {
		setTimeout( "slideObject('" + objectID + "'," + x + "," + y + "," + xinterval + "," + yinterval + "," + delay + ")", delay );
	} 
	else 
	{
		// Convert to local coordinates and remove any extraneous CSS identifiers
		var xpos = parseInt( getLeft( objectID ) );
		var ypos = parseInt( getTop( objectID ) );
		x = parseInt( x );
		y = parseInt( y );

		if ( xpos < x && ypos < y ) {
			moveObject( objectID, xpos + xinterval, ypos + yinterval );
			setTimeout( "slideObject('" + objectID + "'," + x + "," + y + "," + xinterval + "," + yinterval + "," + delay + ")", delay );
		} 
		else if ( xpos > x && ypos > y ) {
			moveObject( objectID, xpos - xinterval, ypos - yinterval );
			setTimeout( "slideObject('" + objectID + "'," + x + "," + y + "," + xinterval + "," + yinterval + "," + delay + ")", delay );
		}
		else if ( xpos > x && ypos < y ) {
			moveObject( objectID, xpos - xinterval, ypos + yinterval );
			setTimeout( "slideObject('" + objectID + "'," + x + "," + y + "," + xinterval + "," + yinterval + "," + delay + ")", delay );
		}
		else if ( xpos < x && ypos > y ) {
			moveObject( objectID, xpos + xinterval, ypos - yinterval );
			setTimeout( "slideObject('" + objectID + "'," + x + "," + y + "," + xinterval + "," + yinterval + "," + delay + ")", delay );
		}
		else if ( xpos < x && ypos == y ) {
			moveObject( objectID, xpos + xinterval, ypos );
			setTimeout( "slideObject('" + objectID + "'," + x + "," + y + "," + xinterval + "," + yinterval + "," + delay + ")", delay );
		}
		else if ( xpos > x && ypos == y ) {
			moveObject( objectID, xpos - xinterval, ypos );
			setTimeout( "slideObject('" + objectID + "'," + x + "," + y + "," + xinterval + "," + yinterval + "," + delay + ")", delay );
		}
		else if ( xpos == x && ypos < y ) {
			moveObject( objectID, xpos, ypos + yinterval );
			setTimeout( "slideObject('" + objectID + "'," + x + "," + y + "," + xinterval + "," + yinterval + "," + delay + ")", delay );
		}
		else if ( xpos == x && ypos > y ) {
			moveObject( objectID, xpos, ypos - yinterval );
			setTimeout( "slideObject('" + objectID + "'," + x + "," + y + "," + xinterval + "," + yinterval + "," + delay + ")", delay );
		} 
	}
}

// <summary>
// Move the specified object in a horizontal direction over time.
// </summary>
// <param name="objectID">The Id of the object to move.</param>
// <param name="x">The ending X coordinate.</param>
// <param name="xinterval">The interval to increment the X coordinate by.</param>
// <param name="delay">How much time should be elapsed between each movement.</param>
function slideObjectHorizontal( objectID, x, xinterval, delay ) {
	// Convert to local coordinates and remove any extraneous CSS identifiers
	var xpos = parseInt( getLeft( objectID ) );
	var ypos = parseInt( getTop( objectID ) );
	x = parseInt( x );
	y = ypos;

	slideObject( objectID, x, y, xinterval, 0, delay );
}

// <summary>
// Move the specified object in a vertical direction over time.
// </summary>
// <param name="objectID">The Id of the object to move.</param>
// <param name="y">The ending Y coordinate.</param>
// <param name="yinterval">The interval to increment the Y coordinate by.</param>
// <param name="delay">How much time should be elapsed between each movement.</param>
function slideObjectVertical( objectID, y, yinterval, delay ) {
	// Convert to local coordinates and remove any extraneous CSS identifiers
	var xpos = parseInt( getLeft( objectID ) );
	var ypos = parseInt( getTop( objectID ) );
	x = xpos;
	y = parseInt( y );

	slideObject( objectID, x, y, 0, yinterval, delay );
}

// <summary>
// Returns the dimensions of the space which is encapsulated within the scrollbars.
// </summary>
function scrollLocation() {
	if (document.all && typeof document.body.scrollTop != "undefined") {
		var loc = document.compatMode != "CSS1Compat" ? document.body : document.documentElement;
		return {
			left:	loc.scrollLeft,
			top:	loc.scrollTop,
			width:	loc.clientWidth,
			height:	loc.clientHeight
		};
	}
	else {
		return {
			left:	window.pageXOffset,
			top:	window.pageYOffset,
			width:	window.innerWidth,
			height:	window.innerHeight
		};
	}
}

// Window Operations
// <summary>
// Scroll the current Page to the specified location.
// </summary>
// <param name="x">The X coordinate on the page.</param>
// <param name="y">The Y coordinate on the page.</param>
function scrollPageTo( x, y ) {
	if ( isIE ) {
		document.body.scrollLeft = x;
		document.body.scrollTop = y;
		return;
	} else {
		scrollTo(x,y );
		return;
	}
}

// Tooltip functionality
// <summary>
// Functionality used by the Tooltip control to toggle the visibility and 
// location associated with a Tooltip.
// </summary>
// <param name="id">The Id of the Tooltip.</param>
// <param name="e">The Event which is being processed.</param>
var tipid;	
function showTooltip( id, e ) { 
	var x = getXLoc( e ); 
	var y = getYLoc( e ); 
	if ( tipid != null ) { 
		hideObject( tipid ); 
	} 
	var tooltip = findDOM( id, 1 ); 
	moveObject( id, x + 5, y + 12 ); 
	if ( id != tipid ) {  
		toggleVisibility( id ); 
		tipid = id; 
	} else { 
		tipid = null; 
	} 
}

// Cookie Functionality
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name + "=" + value + expires + "; path=/;";
	//document.cookie = name + "=" + value + expires + "; path=/; domain=ciradar.com";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
    createCookie(name, "", -1);
    readCookie(name);
}

// Notify Atlas that we have been loaded
if(typeof(Sys) !== "undefined")
	Sys.Application.notifyScriptLoaded();

