// JavaScript Document
var ns=(document.layers);
var ie=(document.all);
var ns6=(document.getElementById);
var tmpObj = null;

function findPosX(obj)
{
	var curleft = 0;
	if (ie || ns6)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (ns)
		curleft += obj.x + obj.width;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (ie || ns6)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (ns)
		curtop += obj.y + obj.height;
	return curtop;
}

/*********************************
	Codes for Help Popup
**********************************/

function getObj(objname) {
	if (ie) {
		this.obj = document.all(objname);
		this.style = document.all(objname).style;
	} else if (ns6) {
		this.obj = document.getElementById(objname); 
		this.style = document.getElementById(objname).style; 
	} else { 
		this.obj = null;
		this.steyl = null;
	}
}

function getObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(ns6 && document.getElementById(objectId)) {
	// W3C DOM
			return document.getElementById(objectId);
    } else if (ie && document.all(objectId)) {
	// MSIE 4 DOM
			return document.all(objectId);
    } else if (ns && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
			return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(ns6 && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (ie && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (ns && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

function moveObject(objectId, newXCoordinate, newYCoordinate) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.left = newXCoordinate;
	styleObject.top = newYCoordinate;
	return true;
    } else {
	// we couldn't find the object, so we can't very well move it
	return false;
    }
} // moveObject

// store variables to control where the popup will appear relative to the cursor position
// positive numbers are below and to the right of the cursor, negative numbers are above and to the left
var xOffset = -350;
var yOffset = 0;

function showPopup (targetObjectId, linkObj) {
	var newXCoordinate = findPosX(linkObj) + xOffset + linkObj.width;
	var newYCoordinate = findPosY(linkObj) + yOffset;
	moveObject(targetObjectId, newXCoordinate, newYCoordinate);
	swapVisibility(targetObjectId);
} // showPopup

function swapVisibility(id) {
	var lyr, lyrcss;
	lyrcss = getStyleObject(id);
	if (lyrcss) {
		tmpObj = lyrcss;
		displayVal = (lyrcss.display == '')? "none" : '';
		window.setTimeout('tmpObj.display = displayVal;',10);
	}
	
}

function setCookie(name, value, expires, path, domain, secure) {
	var thisCookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
	document.cookie = thisCookie;
}

var hostStr = location.host;
var realTime = new Date();
var realTimeStr = realTime.getFullYear() + '-' + (realTime.getMonth() + 1) + '-' + realTime.getDate();
if (!isNaN(hostStr.substr(0,hostStr.indexOf('.'))))
	setCookie("ctime",realTimeStr,false,"/",hostStr,false);
else
	setCookie("ctime",realTimeStr,false,"/",hostStr.substr(hostStr.indexOf('.')),false);
