//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/*
 * 	© 2000-2002 Steve Mapúa
 *	All Rights Reserved
 *	smapua@attbi.com
*/
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// SKCNA UTILS
//
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

var winId  = null;
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function MySubmit(oForm, sTarget)
{
	// Sample Use: onClick="MySubmit(MainFrm, 'inventory.asp');"

	oForm.action=sTarget;
	oForm.submit();

}//MySubmit(...)
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
var SemaphoreAliasNexus = false;
var SemaphoreNexus = 16;
var Chimera="login.asp";
function CheckKeyUp(){if(window.event.keyCode == SemaphoreNexus) SemaphoreAliasNexus = false;}
function CheckKeyDown(){if(window.event.keyCode == SemaphoreNexus) SemaphoreAliasNexus = true;}
function GoToPage(sTarget){if(SemaphoreAliasNexus){OpenNewWin(sTarget);SemaphoreAliasNexus = false;}else{scrollTo(0);}return true;}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function OpenNewWin(sURL)
{
	winId = window.open(sURL,"_new","menubar=1,location=1,toolbar=1,personalbar=1,status=1,scrollbars=1 directories=1 resizable=1, copyhistory=0");
	winId.focus();

}//OpenNewWin(...)
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// USED TO OPEN CHILD WINDOWS
//
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function OpenWin(sURL,sName)
{

	var w = 510;
	var h = 460;
	var sb = 1;

	if((screen.height) >= 600)
	{
		w = 490;
		h = 580;
		sb = 0
	}

	winId = window.open(sURL,sName,"width=" + w + ",height=" + h + ",menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=" + sb + ",directories=0,resizable=0,copyhistory=0");// 'WIDTH=480, HEIGHT=450, CENTER, ');
	winId.focus();

	CenterWin(winId,w,h);

}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function CenterWin(oWin,x,y)
{

	var nRatio = 1;
	var sx = screen.width;
	var sy = screen.height;

	if((sx < x) && (sy < y))
	{
		// Move window to default position
		oWin.moveTo(0,0)
		return;
	}

	else if((sx > x) && (sy < y))
	{
		oWin.moveTo((sx - x) /2,0)
		return;
	}

	oWin.moveTo((sx - x) /2 ,((sy - y) /2) * .95);

}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function ResizeWindow(oTable,nAddWidth,nAddHeight)
{
	var sx = screen.width;
	var sy = screen.height;
	var cx = oTable.clientWidth + nAddWidth;
	var cy = oTable.clientHeight + nAddHeight;

	var xx = 0;
	var yy = 0;

	if((cx > sx) ||(cy > sy))
		window.scrollbars = 1;

	if(cx > sx)
		xx = sx - 20;
	else
		xx = cx;

	if(cy > sy)
		yy = sy - 20;
	else
		yy = cy;


	window.resizeTo(xx,yy);
/*
	alert('Top: ' + UploadContainer.offsetTop + '\nLeft: ' + UploadContainer.offsetLeft +

	      '\nHeight: ' + UploadContainer.clientHeight + '\nWidth: ' + UploadContainer.clientWidth); */
}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function Trim(sSrc)
{
	var sRet = new String();
	var sTemp = new String();
	var i = new Number();
	var nLen = new Number();
	var bStart = new Boolean();

	if(sSrc == null) return null;
	if(sSrc == "") return "";

	nLen = sSrc.length;
	bStart = false;
	sTemp = "";
	sRet = "";

	// Trim Left
	for(i = 0; i < nLen; i++)
	{
		if((sSrc.charAt(i) == " ") && (bStart == false))
			continue;
		bStart = true;
		sRet += sSrc.charAt(i);
	}

	nLen = sRet.length;
	if(!nLen) return "";
	nLen--;

	bStart = false;

	// Trim Right (it is now inverted)
	for(i = nLen; i > -1; i--)
	{
		if((sRet.charAt(i) == " ") && (bStart == false))
			continue;
		bStart = true;
		sTemp += sRet.charAt(i);
	}
	sRet = "";

	// Revert it back
	for(i = nLen; i > -1; i--)
		sRet += sTemp.charAt(i);

	return sRet;

}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//
// winId = OpenWinEx(sURL,
//                   sName,
//                   nStartPos,
//                   nOffSet,
//                   nInitialWidth,
//                   nInitialHeight,
//                   nAddWidth,
//                   nAddHeight,
//                   oParent,
//                   bPopLeft);
//
// nStartPos = Startup Positon Flags
//
var nOPEN_DEFAULT   = 0; // No repositioning
var nCENTER_WINDOW  = 1; // Center vs Screen
var nCENTER_OWNER   = 2; // Center vs Owner [accounts for owner position in screen]
//
// nOffSet = Offset Position Flags
// The following only apply if the nStartPos above is nCENTER_OWNER
//
var nOFFSET_NONE    = 0; // Just center on owner window
var nOFFSET_DEFAULT = 1; // Top Left corner just below and to the right of owner window
var nOFFSET_CHILD   = 2; // Either just left or right of the parent window [button]
                         // (Window is the VC++ strict definition)

// This is the Child Window
var winChild
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function OpenWinEx(sURL,sName,nStartPos,nInitialWidth,nInitialHeight,nAddWidth,nAddHeight,oParent,nOffSet,bPopLeft,bShowStatusBar)
{
	var nTempA   = new Number();
	var nTempB   = new Number();
	var sb       = new Number(0);
	var rs       = new Number(0);
	var bLeft    = new Boolean()
	var nStatBar = new Number(0);

	if(bPopLeft == null)
		bLeft = false;
	else
		bLeft = Boolean(bPopLeft);

	if(bShowStatusBar != null)
	{
		if(bShowStatusBar)
			nStatBar = 1;
	}

	// Screen Dimensions
	with(screen)
	{
		var oScreen = GetScreenObj(Number(0),
		                           Number(0),
		                           Number(availWidth),
		                           Number(availHeight),
		                           Number(availWidth),
		                           Number(availHeight),
		                           "Screen");
	}

	var oContainer =  GetPointObj(window.event.y,window.event.x,"Container") //GetParentOffsetObj(oParent);

	// Window
	with(window)
	{
		var oWindow = GetPointObj(Number(screenTop),
		                          Number(screenLeft),
		                          "Window");
	}

	// Parent
	var oVarParent = null;
	if(oParent == null)
	{
		// Window is Parent
		with(oWindow)
			oVarParent = GetScreenObj(y,x,right,bottom,width,height,"Parent");
	}
	else
	{
		// Document Object is Parent 'MyForm.offsetTop

		// Get Top
		nTempA = 0
		nTempA += oWindow.top;
		nTempA += oContainer.top;
		//nTempA += Number(oParent.offsetTop);

		// Get Left
		nTempB = 0;
		nTempB += oWindow.left;
		nTempB += oContainer.left;
		//nTempB += Number(oParent.offsetLeft);

		//alert(nTempB);

		oVarParent = GetScreenObj(Number(nTempA),
		                          Number(nTempB),
		                          Number(nTempB) + Number(oParent.offsetWidth),
		                          Number(nTempA) + Number(oParent.offsetHeight),
		                          Number(oParent.offsetWidth),
		                          Number(oParent.offsetHeight),
		                          "Parent");
	}

	// Target Position
	var oPos = GetPointObj(0,0);

	// We need to evaluate if the child is larger than any screen extent
	var oChild = GetScreenObj(0,
	                          0,
	                          0,
	                          0,
	                          Number(nInitialWidth) + Number(nAddWidth),
	                          Number(nInitialHeight) + Number(nAddHeight),
	                          sName);



	switch(nStartPos)
	{
		case nOPEN_DEFAULT:   // Top Left Corner Off Screen
			oPos.left = 10;
			oPos.top  = 10;
			break;
		case nCENTER_WINDOW: //  Center of screen but just a little higher [85%]
			if((oScreen.width < oChild.width) && (oScreen.height < oChild.height))
			{
				oPos.left = 10;
				oPos.top  = 10;
			}
			else if((oScreen.width > oChild.width) && (oScreen.height < oChild.height))
			{
				oPos.left = (oScreen.width - oChild.width) /2;
				oPos.top  = 10;
			}
			else if((oScreen.width < oChild.width) && (oScreen.height > oChild.height))
			{
				oPos.left = 10;
				oPos.top  = (oScreen.width - oChild.width) /2;
			}
			else
			{
				oPos.left = (oScreen.width - oChild.width) /2;
				oPos.top  = ((oScreen.height - oChild.height) /2) * .85;
			}

			oChild.left = oPos.left;
			oChild.top = oPos.top

			oChild.right  = oPos.left + oChild.width;
			oChild.bottom = oPos.top + oChild.height;

			break;
		case nCENTER_OWNER:
			switch(nOffSet)
			{
				case nOFFSET_NONE:    // Just center on owner window
					break;
				case nOFFSET_DEFAULT: // Top Left corner just below and to the right of owner window

				    oPos.left = oVarParent.left + 10;
				    oPos.top = oVarParent.top + 10

				    // Set the extents of the Child
				    oChild.left = oPos.left;
				    oChild.top = oPos.top;
				    oChild.right  = oPos.left + oChild.width;
				    oChild.bottom = oPos.top + oChild.height;

				    // Make sure we don't exceed the RIGHT side of the screen
					if(oChild.right >= oScreen.width)
						oPos.left = oScreen.width - (oChild.width + 10);

					// Make sure we don't exceed the LEFT side of the screen
					if(oChild.left <= oScreen.left)
						oPos.left = oScreen.left + 10;

					// Make sure we don't exceed the BOTTOM of the screen
					if(oChild.bottom > oScreen.bottom)
						oPos.top = oScreen.bottom - (oChild.height + 10);

					// Make sure we don't exceed the TOP of the screen
					if(oChild.top <= oScreen.top)
						oPos.top = oScreen.top + 10;

					// Reset the child's object properties
					// This is not really necessary. we can discard it later
					oChild.top    = oPos.top;
					oChild.left   = oPos.left;
					oChild.right  = oChild.left + oChild.width;
					oChild.bottom = oChild.top + oChild.height;

					break;
				case nOFFSET_CHILD:   // Either just left or right of the parent window [button]
				                      // (Window is the VC++ strict definition)
				    if(bLeft)
						oPos.left = oVarParent.left - (oChild.width + 10);
				    else // Right - default
						oPos.left = oVarParent.right + 10;

					if((oPos.left + 10 + oChild.width) >= oScreen.right)
						oPos.left = oScreen.right - (oChild.width + 10); // Left

					if(oPos.left <= oScreen.left)
						oPos.left = oScreen.left + 10;

				    oPos.top = oVarParent.top - ((oChild.height /2) - 10);

				    // Set the extents of the Child
				    oChild.top = oPos.top;
				    oChild.bottom = oPos.top + oChild.height;

					// Make sure we don't exceed the BOTTOM of the screen
					if(oChild.bottom > oScreen.bottom)
						oPos.top = oScreen.bottom - (oChild.height + 10);

					// Make sure we don't exceed the TOP of the screen
					if(oChild.top <= oScreen.top)
						oPos.top = oScreen.top + 10;

					// Reset the child's object properties
					// This is not really necessary. we can discard it later
					oChild.top    = oPos.top;
					oChild.left   = oPos.left;
					oChild.right  = oChild.left + oChild.width;
					oChild.bottom = oChild.top + oChild.height;
					break;
				default:
					break;
			}
			break;
		default:
			break;
	}

	if(winChild != null)
	{
		if(!winChild.closed)
		{
			winChild.close();
		}
	}

/*
	winChild = window.open(sURL,
	                       sName,
	                       "menubar=0," 						  +
	                       "location=0," 						  +
	                       "toolbar=0," 						  +
	                       "personalbar=0," 					  +
	                       "directories=0," 					  +
	                       "copyhistory=0," 					  +
	                       "width="  	 + nInitialWidth 	+ "," +
	                       "height=" 	 + nInitialHeight 	+ "," +
	                       "status=" 	 + nStatBar 		+ "," +
	                       "scrollbars=" + "1" 				+ "," +
	                       "resizable="  + "1"
	                      );
*/

	winChild = window.open(sURL,
	                       sName,
	                       "menubar=0," 						  +
	                       "location=0," 						  +
	                       "toolbar=0," 						  +
	                       "personalbar=0," 					  +
	                       "directories=0," 					  +
	                       "copyhistory=0," 					  +
	                       "width="  	 + nInitialWidth 	+ "," +
	                       "height=" 	 + nInitialHeight 	+ "," +
	                       "status=" 	 + nStatBar 		+ "," +
	                       "scrollbars=" + sb 				+ "," +
	                       "resizable="  + rs
	                      );

	winChild.moveTo(oPos.left ,oPos.top);
	winChild.focus();

}//OpenWinEx(...)
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function GetPointObj(nTop,nLeft,sName)
{
	var obj = new Object();

	obj["top"]  = Number(nTop);
	obj["left"] = Number(nLeft);

	obj["name"] = String(sName);

	return obj;

}//GetPointObj(...)
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function GetScreenObj(nTop,nLeft,nRight,nBottom,nWidth,nHeight,sName)
{
	var obj = new Object();

	obj["top"]  = Number(nTop);
	obj["left"] = Number(nLeft);

	obj["right"]  = nRight;
	obj["bottom"] = nBottom;

	obj["width"]  = Number(nWidth);
	obj["height"] = Number(nHeight);

	obj["name"] = String(sName);

	return obj;

}//GetScreenObj(...)
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//
// Recursively adds all the Parent Extents
//
// oRet is not a required argument in initial call
//
//----------------------------------------------------------------------------
function GetParentOffsetObj(oChild,oRet)
{
	var oCon;

	if(oCon == null)
		oCon =  GetScreenObj(0,0,0,0,0,0,"");

	if(oRet == null)
		oRet =  GetScreenObj(0,0,0,0,0,0,"");

	if(oChild.offsetParent != null)
	{
		with(oChild.offsetParent)
		{
			oCon = GetScreenObj(Number(offsetTop),
								Number(offsetLeft),
			                    Number(offsetLeft) + Number(offsetWidth),  //right
			                    Number(offsetTop)  + Number(offsetHeight), // bottom
			                    Number(offsetWidth),
			                    Number(offsetHeight),
			                    "Container");
		}

		oRet.name     = "Container";
		if(oCon.top != null)
			oRet.top += oCon.top;
		if(oCon.left != null)
			oRet.left += oCon.left;
		if(oCon.right != null)
			oRet.right += oCon.right;
		if(oCon.bottom != null)
			oRet.bottom  += oCon.bottom;
		if(oCon.width != null)
			oRet.width   += oCon.width;
		if(oCon.height != null)
			oRet.height  += oCon.height;

		oCon = GetParentOffsetObj(oChild.offsetParent,oRet);
	}

	return oRet;

}//GetParentOffsetObj(...)
//-----------------------------------------------------------------------------------------------------------------------------------
function CheckChild()
{
	if(winChild != null)
	{
		if(!winChild.closed)
		{
			winChild.focus();
			return;
		}
	}
}
//-----------------------------------------------------------------------------------------------------------------------------------
function CloseNotesWin()
{
	if(winChild == null) return;

	if(!winChild.closed)
		winChild.close();
}
//-----------------------------------------------------------------------------------------------------------------------------------
function CloseUploadWin()
{
	if(winChild == null) return;

	if(!winChild.closed)
		winChild.close();
}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
