var helpup = false;

function FormSubmit() {
		return true;
}

function SetAppt(TimeInt, ApptDate) {

	document.forms[0].timeslot.value = TimeInt;
	document.forms[0].apptdate.value = ApptDate;
	document.forms[0].action.value = "a";
	document.forms[0].submit();
	return false;
}

function SetGroupAppt(TimeInt, ApptDate) {

	document.forms[0].timeslot.value = TimeInt;
	document.forms[0].apptdate.value = ApptDate;
	document.forms[0].action.value = "b";
	document.forms[0].submit();
	return false;
}

function GetAppt(ApptID) {

	document.forms[0].apptid.value = ApptID;
	document.forms[0].action.value = "e";
	document.forms[0].submit();
	return false;
}


function Approve(ApptID) {

	document.forms[0].apptid.value = ApptID;
	document.forms[0].action.value = "r";
	document.forms[0].submit();
	return false;
}

function GetZone(ApptID) {

	document.forms[0].apptid.value = ApptID;
	document.forms[0].action.value = "g";
	document.forms[0].submit();
	return false;
}

function NextWeek() {
	document.forms[0].action.value = "n";
	document.forms[0].submit();
	return false;
}

function NextMonth() {
	document.forms[0].action.value = "nm";
	document.forms[0].submit();
	return false;
}

function NextYear() {
	document.forms[0].action.value = "ny";
	document.forms[0].submit();
	return false;
}

function LastWeek() {
	document.forms[0].action.value = "p";
	document.forms[0].submit();
	return false;
}

function LastMonth() {
	document.forms[0].action.value = "pm";
	document.forms[0].submit();
	return false;
}

function LastYear() {
	document.forms[0].action.value = "py";
	document.forms[0].submit();
	return false;
}

function ThisWeek() {
	document.forms[0].action.value = "t";
	document.forms[0].submit();
	return false;
}

function DoLogin() {
	document.forms[0].action.value = "l";
	return true;
}

function DoLogOut() {
	document.forms[0].action.value = "o";
	return true;
}

function DoView() {
	document.forms[0].action.value = "v";
	return true;
}


function DoViewList() {
	document.forms[0].action.value = "v";
	document.forms[0].submit();
	return true;
}

function DoGroup() {
	document.forms[0].action.value = "w";
	return true;
}

function DoGroupList() {
	document.forms[0].action.value = "w";
	document.forms[0].submit();
	return true;
}


function DoComposite() {
	document.forms[0].action.value = "s";
	document.forms[0].submit();
	return true;
}

function DoManage() {
	document.forms[0].action.value = "u";
	document.forms[0].submit();
	return true;
}

//User group functions
function DoUser() {
	document.forms[0].action.value = "ug";
	return true;
}

function OnOutLookSynch()
{
	var strRet;
	window.status = "Synchronizing with Outlook. Please wait...";
	strRet = Appointment.object.OutLookSynch();
	window.status = "Synchronization with Outlook complete.";
	alert(strRet);
	return strRet;
}

function SynchOutLook()
{
	var strRet;
	window.status = "Synchronizing with Outlook. Please wait...";
//	strRet = Appointment.object.OutLookSynch("//drswitch/DriveE/SoulSoft.com/4me4.us/data/scheduler.mdb");
	strRet = Appointment.object.GetOutLookAppts();
	if (strRet == "") {
		window.status = "Synchronization Failed!";
		return false;
	}
	else {
		window.status = "Synchronization with Outlook complete.";
		document.forms[0].apptdate.value = strRet;
		document.forms[0].action.value = "os";
		document.forms[0].submit();
		return true;
	}
}

function EditProfile()
{
	document.forms[0].action.value = "pf";
	document.forms[0].submit();
	return true;
}

function DoSearch()
{
	if (document.forms[0].lookfor.value != "")
	{
		document.forms[0].action.value = "sa";
		document.forms[0].submit();
		return true;
	}
	else
	{
		alert("Please Enter Search Criteria");
		document.forms[0].lookfor.focus();
		return false;
	}
}

function ShowTip(fArg)
{
	var tooltipOBJ = (document.getElementById) ? document.getElementById('tt' + fArg) : eval("document.all['tt" + fArg + "']");
	if (tooltipOBJ != null) {
		var tooltipLft = (document.body.offsetWidth?document.body.offsetWidth:document.body.style.pixelWidth) - (tooltipOBJ.offsetWidth?tooltipOBJ.offsetWidth:(tooltipOBJ.style.pixelWidth?tooltipOBJ.style.pixelWidth:380)) - 30;
		var tooltipTop = 10;
		if ('ShonenScape' == 'Netscape') {
			tooltipTop = (document.body.scrollTop>=0?document.body.scrollTop+10:event.clientY+10);
 			tooltipOBJ.style.top = tooltipTop+"px";
			tooltipOBJ.style.left = tooltipLft+"px";
		}
		else {
			tooltipTop = (document.body.scrollTop>=0?document.body.scrollTop+10:event.clientY+10);
			tooltipTop = (document.body.scrollTop>=0?document.body.scrollTop+10:event.clientY+10);
			if ((event.clientX > tooltipLft) && (event.clientY < (tooltipOBJ.scrollHeight?tooltipOBJ.scrollHeight:tooltipOBJ.style.pixelHeight) + 10)) {
				tooltipTop = (document.body.scrollTop?document.body.scrollTop:document.body.offsetTop) + event.clientY + 20;
			}
			tooltipOBJ.style.left = tooltipLft;
			tooltipOBJ.style.top = tooltipTop;
		}
		tooltipOBJ.style.visibility = "visible";
	}
}

function HideTip(fArg)
{
	var tooltipOBJ = (document.getElementById) ? document.getElementById('tt' + fArg) : eval("document.all['tt" + fArg + "']");
	if (tooltipOBJ != null) {
		tooltipOBJ.style.visibility = "hidden";
	}
}

function ShowHelp(divid)
{
	if (document.layers)
		document.layers[divid].visibility="show";
	else
		document.getElementById(divid).style.visibility="visible";
		
	helpup = true;
}

function HideHelp(divid)
{
	if (document.layers)
		document.layers[divid].visibility="hide";
	else
		document.getElementById(divid).style.visibility="hidden";
		
	helpup = false;
}

function slothelp(ID)
{
	if (helpup)
	{
		HideHelp("popup");
		//if (sText.length > 0)
		//{
			//document.getElementById("glossary_text").innerHTML = sTitle + sText;
			//document.getElementById("glossary").style.left = document.getElementById("maintable").style.left;
			//document.all['glossary'].style.left = document.all['maintable'].style.left;
			//showTerm("glossary");
		//}
	}
	else
	{
	    var p_width, p_height, a_top, a_left;
	    var coor;
	    
	    a_top = getAbsoluteTop(ID);
	    a_left = getAbsoluteLeft(ID);
	    p_width = document.getElementById("popup").offsetWidth;
	    p_height = document.getElementById("popup").offsetHeight;
	    
	    coor = "<p>top = " + a_top + ", left = " + a_left + ", width = " + p_width + ", height = " + p_height + "</p>";
	    
		//document.getElementById("popup_text").innerHTML =  sText + coor;
		document.getElementById("popup_text").innerHTML =  htmlfilter(document.getElementById(ID).title);

		if (a_left
		 > p_width)
		    a_left -= p_width;
		else
		    a_left += 40;
		    
		if (a_top > p_height)
		    a_top -= p_height;
		else
		    a_top += 20;
		    
		document.getElementById("popup").style.left = a_left;
		document.getElementById("popup").style.top = a_top;
		//alert("Left = " + getAbsoluteLeft("maintable") + ", Left = " + document.getElementById("maintable").style.left + ", Left = " + document.getElementById("maintable").offsetLeft);
		ShowHelp("popup");
	}
}

function getAbsoluteLeft(objectId) {
	// Get an object left position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId)
	oLeft = o.offsetLeft            // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent    // Get parent object reference
		oLeft += oParent.offsetLeft // Add parent left position
		o = oParent
	}
	// Return left postion
	return oLeft
}

function getAbsoluteTop(objectId) {
	// Get an object top position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId)
	oTop = o.offsetTop            // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent  // Get parent object reference
		oTop += oParent.offsetTop // Add parent top position
		o = oParent
	}
	// Return top position
	return oTop
}

function htmlfilter(strText)
{
    var strRet;
    strRet = strText.replace(/</g,"&lt;");
    strRet = strRet.replace(/>/g,"&gt;");    
    return strRet;
}
