/*
	' *************************************************************
	' Name:			StandardClientProcessing.asp
	' Description:	DHTML Library for screens.
	' Parameters:	Name		Type		Purpose/Domain
	'				===============================================
	'				<<NAME>>	<<Type>>	<< Domain >>
	' 
	' Date			Developer		Description
	' =============================================================
	' 09/09/1999	John Hodson		Create File
	' 10/09/1999    John Hodson		Add Popup Functions
	' 13/09/1999    John Hodson		Add Slider Content Functions
	' 13/09/1999    John Hodson		Add Slider Control Functions	
	' 14/09/1999	John Hodson		Add Image Swap Function
	' 14/09/1999    John Hodson		Update Popup Functions
	' 15/09/1999	John Hodson		Add Repopulate Function
	' 15/09/1999    John Hodson		Add Drag Restrict Functions
	' 16/09/1999	John Hodson		Update Drag Restrict Functions	
	' 16/09/1999    John Hodson		zIndex Control Functions
	' 08/11/1999	Steven Tein		Added Global functions - VES, Ramp, Board, Albums, Charts
	' 20/11/1999	Derek Chan		Added Global Xtreme Games Here and Now function
	' 07/12/1999	Steven Tein		Modified LaunchVES to take optional X Y coordinates
	' 09/12/99		Derek Chan		Modified repopulate function to fix MediaDisplayImage problem
	' 12/01/2000	Steven Tein		Modified LaunchVES to include default channel and Radio/Video
	' 20/01/2000	Derek Chan		Added Global Form Validation functions
	' 27/01/2000	Derek Chan		Added Registration form function
	' 07/03/2000	Steven Tein		Created new GenerateVideoButton & GenerateAudioButton functions
	' 10/03/2000	Derek Chan		Added Platform Tests to standard detection function
	' 22/03/2000	Steven Tein		Added regular expressions to SimplePopupRepopulate to handle single quotes
	' 07/04/2000	Mark Hampton	Amendment to single quote escape - only perform for IE
	' 13/04/2000	Chris Saunders	Added LaunchKgrindLive (Ln 125)
	' 25/05/2000	Chris Saunders	Changed browser detection for VES (Ln 93)
	' *************************************************************
	' Copyright:	KGrind Pty Ltd
	
*/

// *************************** CLIENT BROWSER and PLATFORM DETECTION ******************************
//	==========================
//	Perform Browser Check
//	==========================
function BrowserCheck() {
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.version = navigator.appVersion
	this.v = parseInt(this.version)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (this.version.indexOf('MSIE 4')>0)
	this.ie5 = (this.version.indexOf('MSIE 5')>0)
	this.min = (this.ns||this.ie)
	this.mac=( this.version.indexOf('Macintosh')>0 || this.version.indexOf('PPC')>0)
}
is = new BrowserCheck();



// *************************** CLIENT SIDE PARAMETERS **********************************
//	==========================
//	DHTML Parameters
//	==========================
// Popup
var iPopupScrollWidth, iPopupHeaderHeight, bPopupBorder
	iPopupScrollWidth = 25;
	iPopupHeaderHeight = 25;
	bPopupBorder = 0;

// Slider
var iMouseX, iMouseY
	iMouseX=0;
	iMouseY=0;
	
// zIndex
var iZmax, iZTop, iZBottom, iZLow, iZHigh, zIndexScreen
	iZmax=2000000;
	iZTop=iZmax;
	iZBottom = 10;
	iZLow = 1000;
	iZHigh = 1500000;
	zIndexScreen = 10000;

// Video Path
//	sVideoPath = 'top.Kgrind.TopRight'
	
// VES Width for NS & IE
var iVESWidth, iVESHeight
	iVESWidth=225;
	iVESHeight=361;
if (navigator.appName.substring(0,8)=="Netscape") { //if netscape
	iVESWidth=551;
	iVESHeight=363;
}

//	===========================
//	 Kgrind Email Addresses
//	 ===========================
	var sEmailKgrindInfo
	sEmailKgrindInfo = 'info@kgrind.com'

// ********************************** GLOBAL FUNCTIONS ***************************************
//	==========================
//	Launch VES
//	==========================
function LaunchVES(iDefChannel, sType, iX, iY) {
// iDefChannel = Channel ID; 0=None;
// sType = R:Radio Channel, V:Video Channel
// iX = Opening X position of the VES
// iY = Opening Y position of the VES

	if ((iX == '') || (iX == null)) {
		iX=0;
	}
	if ((iY == '') || (iY == null)) {
		iY=0;
	}
	open("/kgrind/ves/core/ves_fs.asp?DefChannel="+iDefChannel+"&Type="+sType,"VES","width="+iVESWidth+",height="+iVESHeight+",status=no,toolbar=no,menubar=no,resizable=no,directories=no,location=no,Scrollbars=no,fullscreen=no,left=" +iX+",top="+iY);

}

// ===========================
// Launch KGrind Live
// ===========================
function LaunchKgrindLive() {
  window.open("/affiliates/live/default.asp","KGrindLive","width=235,height=153,scrollbars=no,toolbar=no,resizable=no",null)
  //window.open("/affiliates/live/core/launch.asp","KGrindLive","width=235,height=359,scrollbars=no,toolbars=no,resizable=no",null);
}

//	==========================
//	Launch The Ramp
//  NOTE: See /Kgrind/Ramp/Library/RampChannels.asp for correct ID's
//	==========================
function LaunchRamp(iChannelID,iChatID) {
	open("/KGrind/ramp/ramp.asp?ChannelID="+iChannelID+"&ChatID="+iChatID,"The_Ramp","width=520,height=371,status=no,toolbar=no,menubar=no,resizable=no,directories=no,location=no,Scrollbars=no,fullscreen=no");
} 
//	==========================
//	Launch the Bulletin Board
//	==========================
function LaunchBoard(iChannelID, sChannelSection, sSectionItem, iItemID) {
	open("/KGrind/Global/GLB_BULB_MAIN_SCRN.asp?ChannelID="+iChannelID+"&ChannelSection="+sChannelSection+"&SectionItem="+sSectionItem+"&ItemID="+iItemID,"Board","width=630,height=270,status=no,toolbar=no,menubar=no,resizable=no,directories=no,location=no,Scrollbars=no,fullscreen=no");
}
//	==========================
//	Launch the Albums Window
//	==========================
function LaunchCD(iChannelID, iArtistID, iAlbumID, sAlbumType) {
	open("/Kgrind/Global/GLB_ALBM_MAIN_SCRN.asp?ChannelID="+iChannelID+"&ArtistID="+iArtistID+"&AlbumID="+iAlbumID+"&AlbumType="+sAlbumType,"CD","width=355,height=240,status=no,toolbar=no,menubar=no,resizable=no,directories=no,location=no,Scrollbars=no,fullscreen=no");
}
//	==========================
//	Launch the Charts Window
//	==========================
function LaunchCharts(iChannelID, iChartID, iShowAudio) {
	open("/Kgrind/Global/GLB_CHRT_MAIN_FRME.asp?ChannelID="+iChannelID+"&ChartID="+iChartID+"&ShowAudio="+iShowAudio,"Charts","width=355,height=240,status=no,toolbar=no,menubar=no,resizable=no,directories=no,location=no,Scrollbars=no,fullscreen=no");
}

//===========================
// Launch Login Window
//===========================
function showLogin(sTargetURL)	{

sTargetURL="/Kgrind/PAM/GLB_KGND_LOGN_SCRN.asp?URL=" + sTargetURL + "&window=1"

window.open(sTargetURL,"Login","height=153,width=350")

}

//============================
//Launch Kline Schedule screen
//============================
function PopKlineSchedule() {
	window.open('http://kline.kgrind.com/default.htm','SCHEDULE',"width=520,height=371,status=no,toolbar=no,menubar=no,resizable=no,directories=no,location=no,Scrollbars=no,fullscreen=no");
}



//**********************XTREME GLOBAL POPUP***********************************
function LaunchHereAndNow()
{
window.open ("/Kgrind/Xtreme/Core/XTR_HERE_MAIN_SCRN.asp","HereAndNow","width=533,height=300");
}

//*****************************************************************************
// ****************************** GENERAL FUNCTIONS ************************************
//	==========================
//	Standard Code Snippits
//	==========================
sHTMLTableStart = '<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">'


//	==========================
//	Gap Image (For spacing)
//	==========================
function GenerateGap(iWidth, iHeight) {
	var sGap
	sGap = '<IMG BORDER="0" SRC="/KGRIND/GLOBAL/IMAGES/EMPTY.GIF" WIDTH="'+iWidth+'" HEIGHT="'+iHeight+'">';
	return sGap
}

//	==========================
//	Create standard GLOBAL VIDEO Button
//	==========================
function GenerateVideoButton(sVideoSource, sPopupName, sPopupLayer, sButton0, sButton1) {
	var sHTML, sOn, sOff, sClick	

	if (sVideoSource == '') {
		sHTML = '<img src="images/empty.gif" Width="54" Height="28" Alt="" Border="0">'
	} else {
		sOn = ' onMouseOver="JavaScript:swapImageC(\''+sPopupName+ '\',\'' +sPopupLayer+'\',\'GlobalVideo\',\''+sButton1+'\');"';
		sOff = ' onMouseOut="JavaScript:swapImageC(\''+sPopupName+ '\',\'' +sPopupLayer+'\',\'GlobalVideo\',\''+sButton0+'\');"';
		sClick = ' onMouseUp="JavaScript:MediaPlayerPlay(\''+sVideoSource+'\');"';
	
		sHTML = '<a href="#"';
		sHTML += sOn;
		sHTML += sOff;
		sHTML += sClick;
		sHTML += '><img src="' + sButton0 + '" name="GlobalVideo" Width="54" Height="28" Border="0" Alt="Play Video">';
		sHTML += '</a>';
	}
	return sHTML
}

//	==========================
//	Create standard GLOBAL AUDIO Button
//	==========================
function GenerateAudioButton(sAudioSource, sPopupName, sPopupLayer, sButton0, sButton1) {
	var sHTML, sOn, sOff, sClick

	if (sAudioSource == '') {
		sHTML = '<img src="images/empty.gif" Width="54" Height="28" Alt="" Border="0">'
	} else {
		sOn = ' onMouseOver="JavaScript:swapImageC(\''+sPopupName+ '\',\'' +sPopupLayer+'\',\'GlobalAudio\',\''+sButton1+'\');"';
		sOff = ' onMouseOut="JavaScript:swapImageC(\''+sPopupName+ '\',\'' +sPopupLayer+'\',\'GlobalAudio\',\''+sButton0+'\');"';
		sClick = ' onMouseUp="JavaScript:MediaPlayAudio(\''+sAudioSource+'\');"';
	
		sHTML = '<a href="#"';
		sHTML += sOn;
		sHTML += sOff;
		sHTML += sClick;
		sHTML += '><img src="' + sButton0 + '" name="GlobalAudio" Width="54" Height="28" Border="0" Alt="Play Audio">';
		sHTML += '</a>';
	}
	return sHTML
}



//=========================================
//	Standard Form Validation Functions
//=========================================

function ValidEmail(sEmailAddress)	{
	
	var regExpValidEmail= (/\b(^(\S+@)).+\..+/gi);
	
	if (sEmailAddress.match(regExpValidEmail))
		return true;
		
	return false;
	}
	
function HasWords(sCheckString,iWordCount)		{
	
	var regExpSpace= (/\x20/g)
	var arrSpace=sCheckString.match(regExpSpace)
	
	if (arrSpace != null)
		if ((arrSpace.length)+1 > iWordCount)
			return false;
	
	return true;
	}
function OpenRegistration(iFormID)	{

var url="/kgrind/global/glb_kgnd_regn_scrn.asp?Form=" + iFormID;

window.open(url,"Registration","width=200,height=392,status=no,toolbar=no,menubar=no,resizable=no,directories=no,location=no,Scrollbars=no,fullscreen=no");

}
//	==========================
//	Load a Channel
//	==========================
function LoadChannel(sChannel) {
	var sURL
	sURL = '/Kgrind/' + sChannel + '/Default.asp';
	location = sURL;
}

// ==========================
// Swap Image
// ==========================

function swapImage(sName, sImage) {
	
	eval('document.'+sName+'.src=\''+sImage+'\'')
}

// ==========================
// Swap Image Cross Browser
// ==========================
function swapImageC(sPopupName,sPopupLayer, sImageName, sImage) 
{  var sLayerType 
	sLayerType = eval(sPopupName+'.PopupType');
	if (is.ns) 
	{
		if ((sPopupLayer==null) || sPopupLayer=='') 
			if (sLayerType=='SIMPLE')
				sName= sPopupName+'BackDiv.document.'+sPopupName+'ContentDiv.document.'+sImageName
			else
				sName= sPopupName+'BackDiv.document.'+sImageName
		
		else 
			{if (sPopupLayer=='ScrollContent')
			{var sLayerDiv, sTemp
			sLayerDiv = sPopupName+sPopupLayer+'Div';
			var sBackDiv = sPopupName+'BackDiv';
			var sWindowDiv = sPopupName+'ScrollWindowDiv';
					
			sName= sBackDiv+'.document.' + sWindowDiv + '.document.' + sLayerDiv+ '.document.'+sImageName
			
			}
			else
			sName= sPopupName+'BackDiv.document.'+sPopupName+sPopupLayer+'Div.document.'+sImageName
			}
		}
		else {
			// IE
			sName = sImageName
		}
	eval('document.'+sName+'.src=\''+sImage+'\'')
}

// ==========================
// Delay for n seconds
// ==========================

function delay(iSeconds) {
	var iStart, iEnd
	
}

// ==========================
// Repopulate Layer
// ==========================

function repopulate(sName, sContent, sType) {
	// sType is for a popup repopulate
	// sType = 'BASIC' - popup background
	// sType = 'SCROLL' - Scroll Section
	// sType = 'DYNA' - DYNA LAYER (Div Extension)
	// sType = '' Normal DHTML layer
	var sScrollLayerDiv, sBackLayerDiv, sLayerDiv
	
	if (!sType) {
	// Normal DHTML Layer
		sLayerDiv = sName;
	}
	else {
		switch (sType) {
			// Popup Background
			case 'BASIC':
				sLayerDiv = sName + 'BackDiv';
				break;
			// Popup Scroll Layer
			case 'SCROLL':
				sLayerDiv = sName + 'ContentDiv';
				break;
			// Dyna Layer
			case 'DYNA':
				sLayerDiv = sName + 'Div';
				break;
		}
	}
	// Change the content
    if (is.ns) {
    //next line commented out by Derek 09/12/1999
		//eval('document.layers[\''+sLayerDiv+'\'].document.open()')
        eval('document.layers[\''+sLayerDiv+'\'].document.write(sContent)')
		eval('document.layers[\''+sLayerDiv+'\'].document.close()')
    }
	else if (is.ie) {
		eval('document.all[\''+sLayerDiv+'\'].innerHTML=\''+sContent+'\'');		
	}
}

// *************************** SIMPLE POPUP LIBRARY **********************************
//	==========================
//	Open Simple Popup
//	==========================
function GenerateSimplePopup(sName, sParent, iTop, iLeft, iWidth, iHeight, sContent, sVisible, iZIndex, sBackImage) {		
		//alert(sName)	//Learn all the layer names
						
		var sBackDiv
		// zIndex
		if (iZIndex==null) {
			iZIndex = zIndexScreen++
		}

		// Create Base Layer
		sBackDiv = sName + 'BackDiv'
		if (sBackImage==null || sBackImage=='') {
			sBackImageContent='';
		}
		else	{
			sImageName = 'img' + sName + 'Background'
			sBackImageContent = '<IMG BORDER="0" WIDTH="'+iWidth+'" HEIGHT="'+iHeight+'" SRC="'+sBackImage+'" NAME="'+sImageName+'">'
		}
		createLayer(sBackDiv,sParent,iLeft,iTop,iWidth,iHeight,sBackImageContent,null,sVisible, iZIndex);
		if (sParent!=null) {
			eval(sName+' = new DynLayer("'+sBackDiv+'", "'+ sParent +'")'); }
		else {
			eval(sName+' = new DynLayer("'+sBackDiv+'")'); }
		eval( sName+'.PopupName = \''+sName+'\' ' );
		eval( sName+'.PopupType = \'SIMPLE\' ' );				

		// Create Content Layer
		var sContentDiv = sName + 'ContentDiv';
		var sContentName = sName + 'Content';			
		createLayer(sContentDiv,sBackDiv,0,0,iWidth,iHeight,sContent);
		eval(sContentName+' = new DynLayer("'+sContentDiv+'", "'+ sBackDiv +'")');
			
		if (is.ns) {
			eval( sName+'.zLow()')
			if (sVisible=='visible') {
				eval( sName+'.pshow()');
			}
		}
}

function CloseSimplePopup(sName) {
		var	sBackDiv, sContentDiv
		sBackDiv = sName + 'BackDiv';
		sContentDiv = sName + 'ContentDiv';

		// Remove from drag
		drag.remove(sName);
		
		// Destroy Content		
		destroyLayer( sContentDiv );
		eval('delete '+ sName );				
		// Destroy Back Layer		
		destroyLayer( sContentDiv );
		eval('delete '+ sName + 'Content' );				
}


//	==========================
//	Simple Popup Repopulate
//	==========================
function SimplePopupRepopulate(sName, sLayerContent) {
	var sLayerDiv, sBackDiv, regexp
	sLayerDiv = sName+'ContentDiv'
	sBackDiv = sName+'BackDiv'
	
    if (is.ns) {
		// Netscape does not like escaped quotes - replace all escaped quotes with normal quotes
		if (sLayerContent != '') {
			regexp = /\\\'/g
			sLayerContent=sLayerContent.replace(regexp,"'");
		}
		
		var lyr
		eval('lyr=document.'+sBackDiv+'.document.'+sLayerDiv);
		sLayerContent = '<IMG SRC="/kgrind/global/images/empty.gif">' + sLayerContent
		lyr.document.open();
		lyr.document.write(sLayerContent);
		lyr.document.close();
    }
	else if (is.ie) {
		// IE needs escaped quotes - replace all quotes with escaped quotes
		if (sLayerContent != '') {
			regexp = /\\\'/g
			sLayerContent=sLayerContent.replace(regexp,"'");	// remove first to avoid doubling up on escapes
			regexp = /\'/g
			sLayerContent=sLayerContent.replace(regexp,"\\\'");
		}

		eval('document.all[\''+sLayerDiv+'\'].innerHTML=\''+sLayerContent+'\'');		
	}
}

//	==========================
//	Generate Simple Popup Close
//	==========================
function GenerateSimplePopupClose(sName, iWidth, iHeight, sContent) {
	var sClose
	if (is.ns) {
		sClose = '<A HREF="#" onMouseUp="javascript:'+sName+'.phide()">';
	}
	else {
		sClose = '<A HREF="#" onMouseUp="javascript:'+sName+'.phide()">';
	}
	sClose += '<IMG SRC="/kgrind/Global/Images/empty.gif" BORDER="0" WIDTH="'+iWidth+'" HEIGHT="'+iHeight+'">';
	sClose += sContent
	sClose += '</A>';
	return sClose
}

//	==========================
//	Simple Popup Drag
//	==========================
function SimplePopupDragAll(sName) {
		// Add to Drag Object	
		MakeDrag(eval(sName));
		eval(sName+'.zNormal');
}

//	==========================
//	Simple Popup Drag Area
//	==========================
function SimplePopupDragArea(sName,iTop, iRight, iBottom, iLeft){
		// Add to Drag Object		
		MakeDragBar(eval(sName),iTop, iRight, iBottom, iLeft);
		eval(sName+'.zNormal');
}

// *************************** BASIC POPUP LIBRARY **********************************
//	==========================
//	Open Basic Popup
//	==========================
function GenerateBasicPopup(sName, sParent, iTop, iLeft, iWidth, iHeight, iHeadHeight, sHeadContent, iBodyHeight, iScrollWidth, sScrollContent, sScrollType, iRightBarWidth, sBackContent, sVisible, bDrag, iZIndex, bClose) {
	iStripHeight = 0;
	sStripContent = '';
	iLeftBarWidth = 0;
	sLeftBarContent = '';
	iFootHeight = 0;
	sFootContent = '';
	if ((bClose!=true)&&(bClose!=false)) {
		bClose=true
	}
	
	if (iHeadHeight>0) {
		iButtonHeight=iHeadHeight;
	}
	else {
		iButtonHeight=15;
	}
	
	iBodyHeight = iBodyHeight - 2
	
	sHeaderContent='';
	sRightBarContent = '';
	
	// Generate the Scroll Bar
	iRightCellHeight = (iHeight-iHeadHeight) / 2;
	sScrollDown = GeneratePopupScrollDown(sName, iRightBarWidth, iButtonHeight, '');
	sScrollUp = GeneratePopupScrollUp(sName, iRightBarWidth, iButtonHeight, '');  
	sRightBarContent =  '<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0">';
	sRightBarContent += '<TR VALIGN="TOP" HEIGHT="'+iRightCellHeight+'"><TD VALIGN="TOP" HEIGHT="'+iRightCellHeight+'">' + sScrollUp + '</TD></TR>';
	sRightBarContent += '<TR VALIGN="BOTTOM" HEIGHT="'+iRightCellHeight+'"><TD VALIGN="BOTTOM" HEIGHT="'+iRightCellHeight+'">' + sScrollDown + '</TD></TR>';
	sRightBarContent += '</TABLE>';
	
	// Generate the Header
	iCellWidth = iWidth - iRightBarWidth;
	sClose = GeneratePopupHide(sName, iRightBarWidth, iHeadHeight, '');
	if (bClose==true) {
		sHeaderContent =  '<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR VALIGN="BOTTOM" WIDTH="'+iWidth+'">';
		sHeaderContent += '<TD WIDTH="'+iCellWidth+'" align="left">' + sHeadContent + '&nbsp;</TD>';
		sHeaderContent += '<TD WIDTH="'+iRightBarWidth+'" align="right">' + sClose + '</TD>';
		sHeaderContent += '</TR></TABLE>';
	} else {
		sHeaderContent =  '<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR VALIGN="BOTTOM" WIDTH="'+iWidth+'">';
		sHeaderContent += '<TD WIDTH="'+iWidth+'" align="left">' + sHeadContent + '&nbsp;</TD>';
		sHeaderContent += '</TR></TABLE>';
	}
	
	GeneratePopup(sName, sParent, iTop, iLeft, iWidth, iHeight, iHeadHeight, sHeaderContent, iStripHeight, sStripContent, iBodyHeight, iFootHeight, sFootContent, iLeftBarWidth, sLeftBarContent, iScrollWidth, sScrollContent, sScrollType, iRightBarWidth, sRightBarContent, sBackContent, sVisible, iZIndex)
	if (bDrag==true) {
		PopupDragArea(sName, 0, iCellWidth, iHeadHeight, 0)
	}
}

// *************************** GENERIC POPUP LIBRARY **********************************
//	==========================
//	Open Generic Popup
//	==========================

function GeneratePopup(sName, sParent, iTop, iLeft, iWidth, iHeight, iHeadHeight, sHeadContent, iStripHeight, sStripContent, iBodyHeight, iFootHeight, sFootContent, iLeftBarWidth, sLeftBarContent, iScrollWidth, sScrollContent, sScrollType, iRightBarWidth, sRightBarContent, sBackContent, sVisible, iZIndex) {

		var iStripTop, iBodyTop, iFootTop, iScrollLeft, iRightBarLeft, sBackDiv

		// zIndex
		if (iZIndex==null) {
			iZIndex = zIndexScreen;
		}

		// Perform Layer Analysis 
		iStripTop = iHeadHeight
		iBodyTop = iStripTop + iStripHeight
		iFootTop = iBodyTop + iBodyHeight
		iScrollLeft = iLeftBarWidth
		iRightBarLeft = iScrollLeft + iScrollWidth
		
		// Create Base Layer
		sBackDiv = sName + 'BackDiv'
		createLayer(sBackDiv,sParent,iLeft,iTop,iWidth,iHeight,sBackContent,null,sVisible, iZIndex);
		if (sParent!=null) {
			eval(sName+' = new DynLayer("'+sBackDiv+'", "'+ sParent +'")'); }
		else {
			eval(sName+' = new DynLayer("'+sBackDiv+'")'); }
		eval( sName+'.Popup = \'1\' ' );
		eval( sName+'.PopupName = \''+sName+'\' ' );		
		eval( sName+'.PopupType = \'GENERIC\' ' );
		if (is.ns) {
			eval( sName+'.zLow()')
		}
		
		// Set Popup Parameters & Create Layers
		// Create Head Layer
		if (iHeadHeight > 0) { 
			var sHeadDiv = sName + 'HeadDiv';
			var sHeadName = sName + 'Head';			
			eval( sName+'.HeadLayer = \'1\' ' );	
			createLayer(sHeadDiv,sBackDiv,0,0,iWidth,iHeadHeight,sHeadContent);
			eval(sHeadName+' = new DynLayer("'+sHeadDiv+'", "'+ sBackDiv +'")');
		}
		else {
			eval( sName+'.HeadLayer = \'0\' ' );
		}
		// Create Strip Layer
		if (iStripHeight > 0) { 
			var sStripDiv = sName + 'StripDiv';
			var sStripName = sName + 'Strip';
			createLayer(sStripDiv,sBackDiv,0,iStripTop,iWidth,iStripHeight,sStripContent);
			eval(sStripName+' = new DynLayer("'+sStripDiv+'", "'+ sBackDiv +'")');
			eval( sName+'.StripLayer = \'1\' ' );	
		}
		else {
			eval( sName+'.StripLayer = \'0\' ' );
		}
		// Create Left Side Layer
		if (iLeftBarWidth > 0) { 
			var sLeftBarDiv = sName + 'LeftBarDiv';
			var sLeftBarName = sName + 'LeftBar';			
			createLayer(sLeftBarDiv,sBackDiv,0,iBodyTop,iLeftBarWidth,iBodyHeight,sLeftBarContent);
			eval(sLeftBarName+' = new DynLayer("'+sLeftBarDiv+'", "'+ sBackDiv +'")');
			eval( sName+'.LeftBarLayer = \'1\' ' );	
		}
		else {
			eval( sName+'.LeftBarLayer = \'0\' ' );
		}
		// Create Scroll Layer
		if (iScrollWidth > 0) { 
		
			var sScrollContentDiv = sName + 'ScrollContentDiv';
			var sScrollContentName = sName + 'ScrollContent';			
			var sScrollWindowDiv = sName + 'ScrollWindowDiv';
			var sScrollWindowName = sName + 'ScrollWindow';
			var sScrollName = sName + 'Scroll';	
			
			switch (sScrollType) {
				case 'V': 
				{ 
					// Verticle Scroll
					// Scroll Window Layer
					createLayer(sScrollWindowDiv,sBackDiv, iScrollLeft,iBodyTop,iScrollWidth, iBodyHeight,'');
					eval(sScrollWindowName+' = new DynLayer("'+sScrollWindowDiv+'", "'+ sBackDiv +'")');

					// Scroll Content Layer
					if (is.ns) {
						createNsNestedLayer(sScrollContentDiv, sBackDiv, sScrollWindowDiv, 0, 0,iScrollWidth, 5000, sScrollContent);
						eval(sScrollContentName+' = new DynLayer("'+sScrollContentDiv+'", "'+ sBackDiv +'.document.'+sScrollWindowDiv +'")');						
					}
					else {
						createLayer(sScrollContentDiv,sScrollWindowDiv, 0, 0,iScrollWidth, 5000, sScrollContent);
						eval(sScrollContentName+' = new DynLayer("'+sScrollContentDiv+'", "'+ sScrollWindowDiv +'")');
					}

					// Create Scroll Window
					eval(sScrollName + "= new MiniScroll("+sScrollWindowName+", "+sScrollContentName+")");
					break;
				} 
				case 'H': 
				{ 
					// Horizontal Scroll
					// Scroll Window Layer
					createLayer(sScrollWindowDiv, sBackDiv, iScrollLeft, iBodyTop, iScrollWidth, iBodyHeight,'');
					eval(sScrollWindowName+' = new DynLayer("'+sScrollWindowDiv+'", "'+ sBackDiv +'")');

					// Scroll Content Layer
					if (is.ns) {
						createNsNestedLayer(sScrollContentDiv, sBackDiv, sScrollWindowDiv, 0, 0, 3400, iBodyHeight, sScrollContent);
						eval(sScrollContentName+' = new DynLayer("'+sScrollContentDiv+'", "'+ sBackDiv +'.document.'+sScrollWindowDiv +'")');						
					}
					else {
						createLayer(sScrollContentDiv, sScrollWindowDiv, 0, 0, 3400, iBodyHeight, sScrollContent);
						eval(sScrollContentName+' = new DynLayer("'+sScrollContentDiv+'", "'+ sScrollWindowDiv +'")');
					}

					// Create Scroll Window
					eval(sScrollName + "= new MiniScroll("+sScrollWindowName+", "+sScrollContentName+")");
					
					break;
				} 
				case 'B': 
				{ 
					// Both Scroll
					// Scroll Window Layer
					createLayer(sScrollWindowDiv, sBackDiv, iScrollLeft, iBodyTop, iScrollWidth, iBodyHeight,'');
					eval(sScrollWindowName+' = new DynLayer("'+sScrollWindowDiv+'", "'+ sBackDiv +'")');

					if (is.ns) {
						createNsNestedLayer(sScrollContentDiv, sBackDiv, sScrollWindowDiv, 0, 0, 600, 600, sScrollContent);
						eval(sScrollContentName+' = new DynLayer("'+sScrollContentDiv+'", "'+ sBackDiv +'.document.'+sScrollWindowDiv +'")');						
					}
					else {
						createLayer(sScrollContentDiv, sScrollWindowDiv, 0, 0, 600, 600, sScrollContent);
						eval(sScrollContentName+' = new DynLayer("'+sScrollContentDiv+'", "'+ sScrollWindowDiv +'")');
					}

					// Create Scroll Window
					eval(sScrollName + "= new MiniScroll("+sScrollWindowName+", "+sScrollContentName+")");
					
					break;
				}
				default: 
				{ 
					// Both Scroll
					// Scroll Window Layer
					createLayer(sScrollWindowDiv, sBackDiv, iScrollLeft, iBodyTop, iScrollWidth, iBodyHeight,'');
					eval(sScrollWindowName+' = new DynLayer("'+sScrollWindowDiv+'", "'+ sBackDiv +'")');

					if (is.ns) {
						createNsNestedLayer(sScrollContentDiv, sBackDiv, sScrollWindowDiv, 0, 0, 600, 600, sScrollContent);
						eval(sScrollContentName+' = new DynLayer("'+sScrollContentDiv+'", "'+ sBackDiv +'.document.'+sScrollWindowDiv +'")');						
					}
					else {
						createLayer(sScrollContentDiv, sScrollWindowDiv, 0, 0, 600, 600, sScrollContent);
						eval(sScrollContentName+' = new DynLayer("'+sScrollContentDiv+'", "'+ sScrollWindowDiv +'")');
					}

					// Create Scroll Window
					eval(sScrollName + "= new MiniScroll("+sScrollWindowName+", "+sScrollContentName+")");
					
					break;
				} // default */
			} // Switch
			eval( sName+'.ScrollLayer = \'1\' ' );	
		}
		else {
			eval( sName+'.ScrollLayer = \'0\' ' );
		}
		// Create Right Layer
		if (iRightBarWidth > 0) { 
			var sRightBarDiv = sName + 'RightBarDiv';
			var sRightBarName = sName + 'RightBar';			
			createLayer(sRightBarDiv,sBackDiv,iRightBarLeft,iBodyTop,iRightBarWidth,iBodyHeight,sRightBarContent);
			eval(sRightBarName+' = new DynLayer("'+sRightBarDiv+'", "'+ sBackDiv +'")');
			eval( sName+'.RightBarLayer = \'1\' ' );	
		}
		else {
			eval( sName+'.RightBarLayer = \'0\' ' );
		}
		// Create Foot Layer
		if (iFootHeight > 0) { 
			var sFootDiv = sName + 'FootDiv';
			var sFootName = sName + 'Foot';			
			createLayer(sFootDiv,sBackDiv,0,iFootTop,iWidth,iFootHeight,sFootContent);
			eval(sFootName+' = new DynLayer("'+sFootDiv+'", "'+ sBackDiv +'")');
			eval( sName+'.FootLayer = \'1\' ' );	
		}
		else {
			eval( sName+'.FootLayer = \'0\' ' );
		}
	
		if (is.ns) {	
			if (sVisible=='visible') {
				eval( sName+'.pshow()');
			}
		}
}

function PopupScrollActivate(sName) {
	var sScrollContentName = sName + 'ScrollContent';			
	var sScrollWindowName = sName + 'ScrollWindow';
	var sScrollName = sName + 'Scroll';	
	eval(sScrollName + "= new MiniScroll("+sScrollWindowName+", "+sScrollContentName+")");
}


function PopupDragAll(sName) {
		// Add to Drag Object		
		MakeDrag(eval(sName));
		eval(sName+'.zNormal()');
}

function PopupShow(sName){
		if (sName) {
			eval(sName+'.show();');
			if (is.ns) {
				var	sBackDiv, sLayerActive, sLayerName, sLayerType
				sBackDiv = sName + 'BackDiv';
				sLayerType = eval( sName+'.PopupType');
				if (sLayerType=='SIMPLE') {
					// Simple Popup Content
					sLayerName = sName + 'Content';
					eval(sLayerName+'.show()');				
				}
				else {		
					sLayerActive = eval( sName+'.HeadLayer');
					if (sLayerActive == '1') { 
						sLayerName = sName + 'Head';
						eval(sLayerName+'.show()');				
					}
					sLayerActive = eval( sName+'.StripLayer');
					if (sLayerActive == '1') { 
						sLayerName = sName + 'Strip';
						eval(sLayerName+'.show()');				
					}
					sLayerActive = eval( sName+'.LeftBarLayer');
					if (sLayerActive == '1') { 
						sLayerName = sName + 'LeftBar';
						eval(sLayerName+'.show()');				
					}
					sLayerActive = eval( sName+'.ScrollLayer');
					if (sLayerActive == '1') { 
						var sScrollContentDiv = sName + 'ScrollContent';
						var sScrollWindowDiv = sName + 'ScrollWindow';
						eval(sScrollWindowDiv+'.show()');				
						eval(sScrollContentDiv+'.show()');				
					}		
					sLayerActive = eval( sName+'.RightBarLayer');
					if (sLayerActive == '1') { 
						sLayerName = sName + 'RightBar';
						eval(sLayerName+'.show()');				
					}
					sLayerActive = eval( sName+'.FootLayer');
					if (sLayerActive == '1') { 
						sLayerName = sName + 'Foot';
						eval(sLayerName+'.show()');				
					} 
				}	// Simple/Generic Popup
			}  // Netscape
		}	// Name Defined
}
function PopupHide(sName){
		if (sName) {
		eval(sName+'.hide()');
			if (is.ns) {
				var	sBackDiv, sLayerActive, sLayerName, sLayerType
				sBackDiv = sName + 'BackDiv';
				sLayerType = eval( sName+'.PopupType');
				if (sLayerType=='SIMPLE') {
					// Simple Popup Content Image
					sLayerName = sName + 'Content';
					eval(sLayerName+'.hide()');				
				}
				else {		
					sLayerActive = eval( sName+'.HeadLayer');
					if (sLayerActive == '1') { 
						sLayerName = sName + 'Head';
						eval(sLayerName+'.hide()');				
					}
					sLayerActive = eval( sName+'.StripLayer');
					if (sLayerActive == '1') { 
						sLayerName = sName + 'Strip';
						eval(sLayerName+'.hide()');				
					}
					sLayerActive = eval( sName+'.LeftBarLayer');
					if (sLayerActive == '1') { 
						sLayerName = sName + 'LeftBar';
						eval(sLayerName+'.hide()');				
					}
					sLayerActive = eval( sName+'.ScrollLayer');
					if (sLayerActive == '1') { 
						var sScrollContentDiv = sName + 'ScrollContent';
						var sScrollWindowDiv = sName + 'ScrollWindow';
						eval(sScrollWindowDiv+'.hide()');				
						eval(sScrollContentDiv+'.hide()');				
					}		
					sLayerActive = eval( sName+'.RightBarLayer');
					if (sLayerActive == '1') { 
						sLayerName = sName + 'RightBar';
						eval(sLayerName+'.hide()');				
					}
					sLayerActive = eval( sName+'.FootLayer');
					if (sLayerActive == '1') { 
						sLayerName = sName + 'Foot';
						eval(sLayerName+'.hide()');				
					} 
				}	// Simple/Generic Popup
			}	// is Netscape
		} // sName Defined
}
function PopupDragArea(sName,iTop, iRight, iBottom, iLeft){
		// Add to Drag Object		
		MakeDragBar(eval(sName),iTop, iRight, iBottom, iLeft);
		eval(sName+'.zNormal()');
}

function PopupRepopulate(sName, sLayer, sContent) {
	// sLayer: Back, Head, Strip, RightBar, ScrollContent, LeftBar, Foot
	var sLayerDiv, sTemp, regexp
	sLayerDiv = sName+sLayer+'Div';
	if (sLayer=='ScrollContent') {
		var sScrollName = sName + "Scroll"
		eval(sScrollName + '.home()')
	}

	if (is.ns) {
		// Netscape does not like escaped quotes - replace all escaped quotes with normal quotes
		if (sContent != '') {
			regexp = /\\\'/g
			sContent=sContent.replace(regexp,"'");
		}

		sContent = '<IMG SRC="/kgrind/global/images/empty.gif">' + sContent
		if (sLayer=='ScrollContent') {
			var sBackDiv = sName+'BackDiv';
			var sWindowDiv = sName+'ScrollWindowDiv';
			var lyr
			eval('lyr=document.'+sBackDiv+'.document.' + sWindowDiv + '.document.' + sLayerDiv);
			lyr.document.open();
			lyr.document.write(sContent);
			lyr.document.close();
		}
		else {
			var lyr
			var sBackDiv = sName+'BackDiv';
			eval('lyr=document.'+sBackDiv+'.document.' + sLayerDiv);
			lyr.document.open();
			lyr.document.write(sContent);
			lyr.document.close();
		}
	}
	else if (is.ie) {
		// IE needs escaped quotes - replace all quotes with escaped quotes
		if (sContent != '') {
			regexp = /\\\'/g
			sContent=sContent.replace(regexp,"'");	// remove first to avoid doubling up on escapes
			regexp = /\'/g;
			sContent=sContent.replace(regexp,"\\\'");
		}

		eval('document.all[\''+sLayerDiv+'\'].innerHTML=\''+sContent+'\'');		
	}
	if (sLayer=='ScrollContent') {
		PopupScrollActivate(sName)
	}
}

function GeneratePopupClose(sName, iWidth, iHeight, sContent) {
	var sClose
	if (is.ns) {
		sClose = '<A HREF="#" onMouseUp="javascript:'+sName+'.phide()">';
	}
	else {
		sClose = '<A HREF="#" onMouseUp="javascript:'+sName+'.phide()">';
		// sClose = '<A HREF="#" onMouseUp="javascript:CloseGenericPopup(\''+sName+'\')">';
	}
	if (sContent=='') {
		sClose += '<IMG SRC="/kgrind/Global/Images/empty.gif" ALT="Close" BORDER="0" WIDTH="'+iWidth+'" HEIGHT="'+iHeight+'">';
	} else {
		sClose += '<IMG SRC="'+sContent+'" ALT="Close" BORDER="0" WIDTH="'+iWidth+'" HEIGHT="'+iHeight+'">';
	}
	sClose += '</A>';
	return sClose
}

function GeneratePopupHide(sName, iWidth, iHeight, sContent) {
	var sClose
	if (is.ns) {
		sClose = '<A HREF="javascript:'+sName+'.phide()">';
	}
	else {
		sClose = '<A HREF="#" onMouseUp="javascript:'+sName+'.phide()">';
	}
	if (sContent=='') {
		sClose += '<IMG SRC="/kgrind/Global/Images/empty.gif" ALT="Close" BORDER="0" WIDTH="'+iWidth+'" HEIGHT="'+iHeight+'">';
	} else {
		sClose += '<IMG SRC="'+sContent+'" ALT="Close" BORDER="0" WIDTH="'+iWidth+'" HEIGHT="'+iHeight+'">';
	}
	sClose += '</A>';
	return sClose
}

function HideGenericPopup (sName) {
	eval(sName + '.phide()');
}

function GeneratePopupScrollUp(sName, iWidth, iHeight, sContent, sImage) {
	var sUp,sScrollName
	sScrollName = sName + "Scroll"
	sUp = '<A HREF="#" onMouseDown="javascript:'+sScrollName+'.up()" onMouseUp="javascript:'+sScrollName+'.stop()">';
	if ((sImage==null) || (sImage=='')) {
		sImage='/kgrind/Global/Images/empty.gif'
	}
	sUp += '<IMG SRC="'+sImage+'" BORDER="0" WIDTH="'+iWidth+'" HEIGHT="'+iHeight+'" ALT="Scroll Up" NAME="img'+sName+'ScrollUp">';
	sUp += sContent;
	sUp += '</A>';
	return sUp
}

function GeneratePopupScrollDown(sName, iWidth, iHeight, sContent, sImage) { 
	var sDown,sScrollName
	sScrollName = sName + "Scroll"
	sDown = '<A HREF="#" onMouseDown="javascript:'+sScrollName+'.down()" onMouseUp="javascript:'+sScrollName+'.stop()" >';
	if ((sImage==null) || (sImage=='')) {
		sImage='/kgrind/Global/Images/empty.gif'
	}
	sDown += '<IMG SRC="'+sImage+'" ALT="Scroll Down" BORDER="0" WIDTH="'+iWidth+'" HEIGHT="'+iHeight+'" NAME="img'+sName+'ScrollDown">';
	sDown += sContent;
	sDown += '</A>';
	return sDown
}

function GeneratePopupScrollRight(sName, iWidth, iHeight, sContent, sImage) {
	var sRight,sScrollName
	sScrollName = sName + "Scroll"
	if ((sImage==null) || (sImage=='')) {
		sImage='/kgrind/Global/Images/empty.gif'
	}
	sRight = '<A HREF="#" onMouseDown="javascript:'+sScrollName+'.right()" onMouseUp="javascript:'+sScrollName+'.stop()" >';
	sRight += '<IMG SRC="'+sImage+'" ALT="Scroll Right" BORDER="0" WIDTH="'+iWidth+'" HEIGHT="'+iHeight+'">';
	sRight += sContent;
	sRight += '</A>';
	return sRight
}

function GeneratePopupScrollLeft(sName, iWidth, iHeight, sContent, sImage) {
	var sLeft,sScrollName
	sScrollName = sName + "Scroll"
	if ((sImage==null) || (sImage=='')) {
		sImage='/kgrind/Global/Images/empty.gif'
	}
	sLeft = '<A HREF="#" onMouseDown="javascript:'+sScrollName+'.left()" onMouseUp="javascript:'+sScrollName+'.stop()">';
	sLeft += '<IMG SRC="'+sImage+'" BORDER="0" WIDTH="'+iWidth+'" HEIGHT="'+iHeight+'" ALT="Scroll Left">';
	sLeft += sContent;
	sLeft += '</A>';
	return sLeft
}


function PopupScrollDown(id) {
		eval(id+'.down()');
}

function PopupScrollStop(id) {
		eval(id+'.stop()');
}

function PopupScrollRight(id) {
		eval(id+'.right()');
}

function PopupScrollLeft(id) {
		eval(id+'.left()');
}

function PopupScrollUp(id) {
		eval(id+'.up()');
}

//	==========================
//	Close Generic Popup
//	==========================
function CloseGenericPopup(sName) {

		var	sBackDiv, sLayerActive
		sBackDiv = sName + 'BackDiv';

		// Remove from drag
		drag.remove(sName);

		if (is.ns){
			// Remove Head Layer
			sLayerActive = eval( sName+'.HeadLayer');
			if (sLayerActive == '1') { 
				var sHeadDiv = sName + 'HeadDiv';
				var sHeadName = sName + 'Head';			
				destroyLayer(sHeadDiv);
				eval('delete '+sHeadName);				
			}
			// Create Strip Layer
			sLayerActive = eval( sName+'.StripLayer');
			if (sLayerActive == '1') { 
				var sLayerDiv = sName + 'StripDiv';
				var sLayerName = sName + 'Head';			
				destroyLayer(sLayerDiv);
				eval('delete '+sLayerName);				
			}
			// Create Left Side Layer
			sLayerActive = eval( sName+'.LeftBarLayer');
			if (sLayerActive == '1') { 
				var sLayerName = sName + 'LeftBar';					
				var sLayerDiv = sName + sLayerName + 'Div';
				destroyLayer(sLayerDiv);
				eval('delete '+sLayerName);				
			}
			// Destroy Scroll Layer
			sLayerActive = eval( sName+'.ScrollLayer');
			if (sLayerActive == '1') { 
				var sScrollContentDiv = sName + 'ScrollContentDiv';
				var sScrollContentName = sName + 'ScrollContent';			
				var sScrollWindowDiv = sName + 'ScrollWindowDiv';
				var sScrollWindowName = sName + 'ScrollWindow';
				destroyLayer(ScrollWindowDiv);
				eval('delete '+ScrollWindow);				
				destroyLayer(ScrollContentDiv);
				eval('delete '+ScrollContent);				
			}		
			// Destroy Right Layer
			sLayerActive = eval( sName+'.RightBarLayer');
			if (sLayerActive == '1') { 
				var sLayerName = sName + 'RightBar';					
				var sLayerDiv = sName + sLayerName + 'Div';
				destroyLayer(sLayerDiv);
				eval('delete '+sLayerName);				
			}
			// Destroy Foot Layer
			sLayerActive = eval( sName+'.FootLayer');
			if (sLayerActive == '1') { 
				var sLayerName = sName + 'Foot';					
				var sLayerDiv = sName + sLayerName + 'Div';
				destroyLayer(sLayerDiv);
				eval('delete '+sLayerName);				
			} 
		} // Netscape !
		// Destroy Back Layer		
		destroyLayer( sBackDiv );
		eval('delete '+ sName );				
				
}

// Popup Drag Resist
function PopupDragRestrict (sName, t, r, b, l) {
	eval(sName+'.DragRestrict('+t+','+r+','+b+','+l+')');
}
function PopupDragRestrictOff (sName) {
	eval(sName+'.DragRestrictOff()');
}

// Popup Float Functions
function PopupzTop (sName) {
	var sLayerType
	sLayerType = eval(sName+'.LayerType');
	switch (sLayerType) {
		case 'BASIC':
		{
			eval(sName+'.zTop()');
			break;
		}
		case 'SCROLL':
		{
			eval(sName+'.zTop()');
			eval(sName+'Window.zTop()');
			eval(sName+'Content.zTop()');
			break;
		}
	}
}
function PopupzFloat (sName, izIndex) {
	var sLayerType
	sLayerType = eval(sName+'.LayerType');
	switch (sLayerType) {
		case 'BASIC':
		{
			eval(sName+'.zFloat('+izIndex+')');
			break;
		}
		case 'SCROLL':
		{
			eval(sName+'.zFloat('+izIndex+')');
			eval(sName+'Window.zFloat('+izIndex+')');
			eval(sName+'Content.zFloat('+izIndex+')');
			break;
		}
	}
}

function PopupzBottom (sName) {
	var sLayerType
	sLayerType = eval(sName+'.LayerType');
	switch (sLayerType) {
		case 'BASIC':
		{
			eval(sName+'.zBottom()');
			break;
		}
		case 'SCROLL':
		{
			eval(sName+'.zBottom()');
			eval(sName+'Window.zBottom()');
			eval(sName+'Content.zBottom()');
			break;
		}
	}
}
function PopupzNormal (sName) {
	var sLayerType
	sLayerType = eval(sName+'.LayerType');
	switch (sLayerType) {
		case 'BASIC':
		{
			eval(sName+'.zNormal()');
			break;
		}
		case 'SCROLL':
		{
			eval(sName+'.zNormal()');
			eval(sName+'Window.zNormal()');
			eval(sName+'Content.zNormal()');
			break;
		}
	}
}

// ******************************** DHTML Library **************************************

// Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at http://www.dansteinman.com/dynduo/

function DynLayer(id,nestref,frame) {
	if (!DynLayer.set && !frame) DynLayerInit()
	this.frame = frame || self
	if (is.ns) {
		if (is.ns4) {
			if (!frame) {
				if (!nestref) var nestref = DynLayer.nestRefArray[id]
				if (!DynLayerTest(id,nestref)) return
				this.css = (nestref)? eval("document."+nestref+".document."+id) : document.layers[id]
			}
			else this.css = (nestref)? eval("frame.document."+nestref+".document."+id) : frame.document.layers[id]
			this.elm = this.event = this.css
			this.doc = this.css.document
		}
		if (is.ns5) {
			this.elm = document.getElementById(id)
			this.css = this.elm.style
			this.doc = document
		}
		this.x = this.css.left
		this.y = this.css.top
		this.w = this.css.clip.width
		this.h = this.css.clip.height
	}
	else if (is.ie) {
			this.elm = this.event = this.frame.document.all[id]
			this.css = this.frame.document.all[id].style
			this.doc = document
			this.x = this.elm.offsetLeft
			this.y = this.elm.offsetTop
			this.w = (is.ie4)? this.css.pixelWidth : this.elm.offsetWidth
			this.h = (is.ie4)? this.css.pixelHeight : this.elm.offsetHeight 
			
		}
	this.id = id
	this.nestref = nestref
	this.obj = id + "DynLayer"
	this.zFloat = 0; // - SPYDA
	this.dRestrict = 0;	// - SPYDA
	this.obj.zIndex = zIndexScreen++;
	eval(this.obj + "=this")
}
function DynLayerMoveTo(x,y) {
		if (this.dRestrict==1) {
			// Drag Restrict Enabled - SPYDA
			var iDLeft, iDTop, iDRight, iDBottom
			iDLeft = this.dLeft
			iDRight = this.dRight - this.w
			iDTop = this.dTop
			iDBottom = this.dBottom - this.h
			if (x!=null) {
				// Check Right - SPYDA
				if (x>iDRight) {
					x = iDRight;}
				// Check Left - SPYDA
				if (x<iDLeft) {
					x = iDLeft;}
				// Perform Move
				this.x = x
				if (is.ns) this.css.left = this.x
				else this.css.pixelLeft = this.x
			}
			if (y!=null) {
				// Check Top - SPYDA
				if (y<iDTop) {
					y = iDTop;}
				// Check Bottom - SPYDA
				if (y>iDBottom) {
					y = iDBottom;}
				this.y = y
				if (is.ns) this.css.top = this.y
				else this.css.pixelTop = this.y
			}
		}
		else {
			if (x!=null) {
				this.x = x
				if (is.ns) this.css.left = this.x
				else this.css.pixelLeft = this.x
			}
			if (y!=null) {
				this.y = y
				if (is.ns) this.css.top = this.y
				else this.css.pixelTop = this.y
			}
		}	
}
function DynLayerMoveBy(x,y) {
	this.moveTo(this.x+x,this.y+y)
}
function DynLayerShow() {
	this.css.visibility = (is.ns)? "show" : "visible"
}
function DynLayerHide() {
		this.css.visibility = (is.ns)? "hide" : "hidden"
}
// Spyda Popup Shortcuts
function DynLayerPHide() {
	PopupHide(this.PopupName);
}	
function DynLayerPShow() {
	PopupShow(this.PopupName);
}	

DynLayer.prototype.moveTo = DynLayerMoveTo
DynLayer.prototype.moveBy = DynLayerMoveBy
DynLayer.prototype.show = DynLayerShow
DynLayer.prototype.hide = DynLayerHide
DynLayerTest = new Function('return true')
DynLayer.prototype.pshow = DynLayerPShow
DynLayer.prototype.phide = DynLayerPHide

// DynLayerInit Function
function DynLayerInit(nestref) {
	if (!DynLayer.set) DynLayer.set = true
	if (is.ns) {
		if (nestref) ref = eval('document.'+nestref+'.document')
		else {nestref = ''; ref = document;}
		for (var i=0; i<ref.layers.length; i++) {
			var divname = ref.layers[i].name
			DynLayer.nestRefArray[divname] = nestref
			var index = divname.indexOf("Div")
			if (index > 0) {
				eval(divname.substr(0,index)+' = new DynLayer("'+divname+'","'+nestref+'")')
			}
			if (ref.layers[i].document.layers.length > 0) {
				DynLayer.refArray[DynLayer.refArray.length] = (nestref=='')? ref.layers[i].name : nestref+'.document.'+ref.layers[i].name
			}
		}
		if (DynLayer.refArray.i < DynLayer.refArray.length) {
			DynLayerInit(DynLayer.refArray[DynLayer.refArray.i++])
		}
	}
	else if (is.ie) {
		for (var i=0; i<document.all.tags("DIV").length; i++) {
			var divname = document.all.tags("DIV")[i].id
			var index = divname.indexOf("Div")
			if (index > 0) {
				eval(divname.substr(0,index)+' = new DynLayer("'+divname+'")')
			}
		}
	}
	return true
}
DynLayer.nestRefArray = new Array()
DynLayer.refArray = new Array()
DynLayer.refArray.i = 0
DynLayer.set = false

// Slide Methods
function DynLayerSlideTo(endx,endy,inc,speed,fn) {
	if (endx==null) endx = this.x
	if (endy==null) endy = this.y
	var distx = endx-this.x
	var disty = endy-this.y
	this.slideStart(endx,endy,distx,disty,inc,speed,fn)
}
function DynLayerSlideBy(distx,disty,inc,speed,fn) {
	var endx = this.x + distx
	var endy = this.y + disty
	this.slideStart(endx,endy,distx,disty,inc,speed,fn)
}
function DynLayerSlideStart(endx,endy,distx,disty,inc,speed,fn) {
	if (this.slideActive) return
	if (!inc) inc = 10
	if (!speed) speed = 20
	var num = Math.sqrt(Math.pow(distx,2) + Math.pow(disty,2))/inc
	if (num==0) return
	var dx = distx/num
	var dy = disty/num
	if (!fn) fn = null
	this.slideActive = true
	this.slide(dx,dy,endx,endy,num,1,speed,fn)
}
function DynLayerSlide(dx,dy,endx,endy,num,i,speed,fn) {
	if (!this.slideActive) return
	if (i++ < num) {
		this.moveBy(dx,dy)
		this.onSlide()
		if (this.slideActive) setTimeout(this.obj+".slide("+dx+","+dy+","+endx+","+endy+","+num+","+i+","+speed+",\""+fn+"\")",speed)
		else this.onSlideEnd()
	}
	else {
		this.slideActive = false
		this.moveTo(endx,endy)
		this.onSlide()
		this.onSlideEnd()
		eval(fn)
	}
}
DynLayerSlideInit = new Function()
DynLayer.prototype.slideInit = new Function()
DynLayer.prototype.slideTo = DynLayerSlideTo
DynLayer.prototype.slideBy = DynLayerSlideBy
DynLayer.prototype.slideStart = DynLayerSlideStart
DynLayer.prototype.slide = DynLayerSlide
DynLayer.prototype.onSlide = new Function()
DynLayer.prototype.onSlideEnd = new Function()

// Clip Methods
function DynLayerClipInit(clipTop,clipRight,clipBottom,clipLeft) {
	if (is.ie) {
		if (arguments.length==4) this.clipTo(clipTop,clipRight,clipBottom,clipLeft)
		else if (is.ie4) this.clipTo(0,this.css.pixelWidth,this.css.pixelHeight,0)
	}
}
function DynLayerClipTo(t,r,b,l) {
	if (t==null) t = this.clipValues('t')
	if (r==null) r = this.clipValues('r')
	if (b==null) b = this.clipValues('b')
	if (l==null) l = this.clipValues('l')
	if (is.ns) {
		this.css.clip.top = t
		this.css.clip.right = r
		this.css.clip.bottom = b
		this.css.clip.left = l
	}
	else if (is.ie) this.css.clip = "rect("+t+"px "+r+"px "+b+"px "+l+"px)"
}
function DynLayerClipBy(t,r,b,l) {
	this.clipTo(this.clipValues('t')+t,this.clipValues('r')+r,this.clipValues('b')+b,this.clipValues('l')+l)
}
function DynLayerClipValues(which) {
	if (is.ie) var clipv = this.css.clip.split("rect(")[1].split(")")[0].split("px")
	if (which=="t") return (is.ns)? this.css.clip.top : Number(clipv[0])
	if (which=="r") return (is.ns)? this.css.clip.right : Number(clipv[1])
	if (which=="b") return (is.ns)? this.css.clip.bottom : Number(clipv[2])
	if (which=="l") return (is.ns)? this.css.clip.left : Number(clipv[3])
}
DynLayer.prototype.clipInit = DynLayerClipInit
DynLayer.prototype.clipTo = DynLayerClipTo
DynLayer.prototype.clipBy = DynLayerClipBy
DynLayer.prototype.clipValues = DynLayerClipValues

// Write Method
function DynLayerWrite(html) {
	if (is.ns) {
		this.doc.open()
		this.doc.write(html)
		this.doc.close()
	}
	else if (is.ie) {
		this.event.innerHTML = html
	}
}
DynLayer.prototype.write = DynLayerWrite

// CSS Function
function css(id,left,top,width,height,color,vis,z,other) {
	if (id=="START") return '<STYLE TYPE="text/css">\n'
	else if (id=="END") return '</STYLE>'
	var str = (left!=null && top!=null)? '#'+id+' {position:absolute; left:'+left+'px; top:'+top+'px;' : '#'+id+' {position:relative;'
	if (arguments.length>=4 && width!=null) str += ' width:'+width+'px;'
	if (arguments.length>=5 && height!=null) {
		str += ' height:'+height+'px;'
		if (arguments.length<9 || other.indexOf('clip')==-1) str += ' clip:rect(0px '+width+'px '+height+'px 0px);'
	}
	if (arguments.length>=6 && color!=null) str += (is.ns)? ' layer-background-color:'+color+';' : ' background-color:'+color+';'
	if (arguments.length>=7 && vis!=null) str += ' visibility:'+vis+';'
	if (arguments.length>=8 && z!=null) str += ' z-index:'+z+';'
	if (arguments.length==9 && other!=null) str += ' '+other
	str += '}\n'
	return str
}
function writeCSS(str,showAlert) {
	str = css('START')+str+css('END')
	document.write(str)
	if (showAlert) alert(str)
}

// All functions below have been added from individual libraries Dan
// calls Extensions.
function DynLayerWipeInit(clipTop,clipRight,clipBottom,clipLeft) {
	if (arguments.length==4) this.clipInit(clipTop,clipRight,clipBottom,clipLeft)
	else this.clipInit()
}
function DynLayerWipeTo(endt,endr,endb,endl,num,speed,fn) {
	var distt = (endt!=null)? endt-this.clipValues('t'):0
	var distr = (endr!=null)? endr-this.clipValues('r'):0
	var distb = (endb!=null)? endb-this.clipValues('b'):0
	var distl = (endl!=null)? endl-this.clipValues('l'):0
	this.wipeStart(distt,distr,distb,distl,endt,endr,endb,endl,num,speed,fn)
}
function DynLayerWipeBy(distt,distr,distb,distl,num,speed,fn) {
	this.wipeStart(distt,distr,distb,distl,distt+this.clipValues('t'),distr+this.clipValues('r'),distb+this.clipValues('b'),distl+this.clipValues('l'),num,speed,fn)
}
function DynLayerWipeStart(distt,distr,distb,distl,endt,endr,endb,endl,num,speed,fn) {
	if (this.wipeActive) return
	if (!fn) fn = null
	this.wipeActive = true
	this.wipe(distt/num,distr/num,distb/num,distl/num,endt,endr,endb,endl,this.clipValues('t'),this.clipValues('r'),this.clipValues('b'),this.clipValues('l'),num,1,speed,fn)
}
function DynLayerWipe(dt,dr,db,dl,endt,endr,endb,endl,st,sr,sb,sl,num,i,speed,fn) {
	if (!this.wipeActive) return
	if (i++ < num) {
		this.clipTo(st+i*dt,sr+i*dr,sb+i*db,sl+i*dl)
		setTimeout(this.obj+".wipe("+dt+","+dr+","+db+","+dl+","+endt+","+endr+","+endb+","+endl+","+st+","+sr+","+sb+","+sl+","+num+","+i+","+speed+",\""+fn+"\")",speed)
	}
	else {
		this.wipeActive = false
		this.clipTo(endt,endr,endb,endl)
		eval(fn)	
	}
}
DynLayer.prototype.wipeInit = DynLayerWipeInit
DynLayer.prototype.wipeTo = DynLayerWipeTo
DynLayer.prototype.wipeBy = DynLayerWipeBy
DynLayer.prototype.wipeStart = DynLayerWipeStart
DynLayer.prototype.wipe = DynLayerWipe

function DynLayerGlideTo(startSpeed,endSpeed,endx,endy,angleinc,speed,fn) {
	if (endx==null) endx = this.x
	if (endy==null) endy = this.y
	var distx = endx-this.x
	var disty = endy-this.y
	this.glideStart(startSpeed,endSpeed,endx,endy,distx,disty,angleinc,speed,fn)
	return
}
function DynLayerGlideBy(startSpeed,endSpeed,distx,disty,angleinc,speed,fn) {
	var endx = this.x + distx
	var endy = this.y + disty
	this.glideStart(startSpeed,endSpeed,endx,endy,distx,disty,angleinc,speed,fn)
}
function DynLayerGlideStart(startSpeed,endSpeed,endx,endy,distx,disty,angleinc,speed,fn) {

	if (this.glideActive) { return}
	if (endx==this.x) var slantangle = 90
	else if (endy==this.y) var slantangle = 0
	else var slantangle = Math.abs(Math.atan(disty/distx)*180/Math.PI)
	if (endx>=this.x) {
		if (endy>this.y) slantangle = 360-slantangle
	}
	else {
		if (endy>this.y) slantangle = 180+slantangle
		else slantangle = 180-slantangle
	}
	slantangle *= Math.PI/180
	var amplitude = Math.sqrt(Math.pow(distx,2) + Math.pow(disty,2))
	if (!fn) fn = null
	this.glideActive = true
	if (startSpeed == "fast") {
		if (endSpeed=="fast") this.glide(1,amplitude/2,0,90,this.x,this.y,slantangle,endx,endy,distx,disty,angleinc,speed,fn)
		else this.glide(0,amplitude,0,90,this.x,this.y,slantangle,endx,endy,distx,disty,angleinc,speed,fn)
	}
	else {
		if (endSpeed=="fast") this.glide(0,amplitude,-90,0,this.x+distx,this.y+disty,slantangle,endx,endy,distx,disty,angleinc,speed,fn)
		else this.glide(0,amplitude/2,-90,90,this.x+distx/2,this.y+disty/2,slantangle,endx,endy,distx,disty,angleinc,speed,fn)
	}
}
function DynLayerGlide(type,amplitude,angle,endangle,centerX,centerY,slantangle,endx,endy,distx,disty,angleinc,speed,fn) {
	if (angle < endangle && this.glideActive) {
		angle += angleinc
		var u = amplitude*Math.sin(angle*Math.PI/180)
		var x = centerX + u*Math.cos(slantangle)
		var y = centerY - u*Math.sin(slantangle)		
		x = Math.round(x)
		y = Math.round(y)				
		this.moveTo(x,y)
		this.onGlide()
		if (this.glideActive) setTimeout(this.obj+'.glide('+type+','+amplitude+','+angle+','+endangle+','+centerX+','+centerY+','+slantangle+','+endx+','+endy+','+distx+','+disty+','+angleinc+','+speed+',\''+fn+'\')',speed)
		else this.onGlideEnd()
	}
	else {
		if (type==1) this.glide(0,amplitude,-90,0,this.x+distx/2,this.y+disty/2,slantangle,endx,endy,distx,disty,angleinc,speed,fn)
		else {
			this.glideActive = false
			this.moveTo(endx,endy)
			//this.onGlide()
			//this.onGlideEnd()
			eval(fn)
		}
	}
	return
}
DynLayerGlideInit = new Function()
DynLayer.prototype.glideInit = new Function()
DynLayer.prototype.glideTo = DynLayerGlideTo
DynLayer.prototype.glideBy = DynLayerGlideBy
DynLayer.prototype.glideStart = DynLayerGlideStart
DynLayer.prototype.glide = DynLayerGlide
DynLayer.prototype.onGlide = new Function()
DynLayer.prototype.onGlideEnd = new Function()

function Drag(dynlayer) {
	this.element = dynlayer
	this.obj = null
	this.array = new Array()
	this.active = false
	this.offsetX = 0
	this.offsetY = 0
	this.zIndex = zIndexScreen++
	this.resort = true
	this.add = DragAdd
	this.remove = DragRemove
	this.setGrab = DragSetGrab
	this.mouseDown = DragMouseDown
	this.mouseMove = DragMouseMove
	this.mouseUp = DragMouseUp
}
function DragAdd() {
	for (var i=0; i<arguments.length; i++) {
		var l = this.array.length
		this.array[l] = arguments[i]
		this.array[l].dragGrab = new Array(0,this.array[l].w,this.array[l].h,0)
		this.zIndex = zIndexScreen++
	}
}
function DragSetGrab(dynlayer,top,right,bottom,left) { 
	dynlayer.dragGrab = new Array(top,right,bottom,left)
}
function DragRemove() {
	for (var i=0; i<arguments.length; i++) {
		for (var j=0; j<this.array.length; j++) {
			if (this.array[j]==arguments[i]) {
				for (var k=j;k<=this.array.length-2;k++) this.array[k] = this.array[k+1]
				this.array[this.array.length-1] = null
				this.array.length -= 1
				break
			}
		}
	}
}
function DragMouseDown(x,y) {
	for (var i=this.array.length-1;i>=0;i--) {
		var lyr = this.array[i]
		if (this.element) {x+=this.element.x; y+=this.element.y}
		if (checkWithin(x,y,lyr.x+lyr.dragGrab[3],lyr.x+lyr.dragGrab[1],lyr.y+lyr.dragGrab[0],lyr.y+lyr.dragGrab[2])) {
			this.obj = this.array[i]
			this.offsetX = x-this.obj.x
			this.offsetY = y-this.obj.y
			this.active = true
			break
		}
	}
	if (this.active && this.resort) {
		// Float Modifications - SPYDA
		if (this.obj.zFloat!=1) {
			this.zIndex = zIndexScreen++
			this.obj.css.zIndex = this.zIndex
		}
		for (var j=i;j<=this.array.length-2;j++) this.array[j] = this.array[j+1]
		this.array[this.array.length-1] = this.obj
	}
	if (!this.active) return false
	else return true
}
function DragMouseMove(x,y) {
	if (!this.active) return false
	else {
		if (this.element) {x+=this.element.x; y+=this.element.y}		
		this.obj.moveTo(x-this.offsetX,y-this.offsetY)
		return true
	}
}
function DragMouseUp() {
	if (!this.active) return false
	else {
		this.active = false
		return true
	}
}

// automatically define the "drag" object
drag = new Drag()

// checkWithin() function is required
function checkWithin(x,y,left,right,top,bottom) {
	if (x>=left && x<right && y>=top && y<bottom) return true
	else return false
}

function MakeDrag(Which) {
	drag.add(Which);
	document.onmousedown = mouseDown
	document.onmousemove = mouseMove
	document.onmouseup = mouseUp
	if (is.ns) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP)
}

// Custom Drag Bar
function MakeDragBar(Which,t,r,b,l) {
	drag.add(Which);
	drag.setGrab(Which,t,r,b,l);
	document.onmousedown = mouseDown
	document.onmousemove = mouseMove
	document.onmouseup = mouseUp
	if (is.ns) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP)
}

// ************************** SPYDA Customised DynLayer *******************************
// SPYDA MEDIA P/L
// Johnathan Hodson

// Drag Restrict
function DynLayerDragRestrict(t,r,b,l) {
		this.dRestrict = 1;
		this.dTop = t;
		this.dRight = r;
		this.dBottom = b;
		this.dLeft = l;
}

function DynLayerDragRestrictOff() {
		this.dRestrict = 0;
}
DynLayer.prototype.DragRestrict = DynLayerDragRestrict
DynLayer.prototype.DragRestrictOff = DynLayerDragRestrictOff

// Floating Library
function DynLayerzFloatNormal() {
		this.zFloat = 0;
		this.css.zIndex = zIndexScreen++;
}

function DynLayerzFloat(izIndex) {
		this.zFloat = 1;
		if (izIndex < iZmax)
		{
			izIndex = iZmax;
		}
		if (izIndex < -iZmax) 
		{
			izIndex = -iZmax;
		}
		this.css.zIndex = izIndex;
}

function DynLayerzTop() {
		this.css.zIndex = iZTop;
		this.zFloat = 1;
}
function DynLayerzBottom() {
		this.css.zIndex = iZBottom;
		this.zFloat = 1;
}
function DynLayerzLow() {
		this.zFloat = 1;
		this.css.zIndex = iZLow;
}
function DynLayerzHigh() {
		this.zFloat = 1;
		this.css.zIndex = iZHigh;
}
DynLayer.prototype.zTop = DynLayerzTop
DynLayer.prototype.zBottom = DynLayerzBottom
DynLayer.prototype.zFloat = DynLayerzFloat
DynLayer.prototype.zNormal = DynLayerzFloatNormal
DynLayer.prototype.zLow = DynLayerzLow
DynLayer.prototype.zHigh = DynLayerzHigh

// ************************ STANDARD SCREEN MOUSE TRAPS *****************************

function mouseDown(e) {
	if (is.ns && e.target!=document) routeEvent(e)
	if ((is.ns && e.which!=1) || (is.ie && event.button!=1)) return true
	var x = (is.ns)? e.pageX : event.x+document.body.scrollLeft
	var y = (is.ns)? e.pageY : event.y+document.body.scrollTop
	PageMouseDown();
	if (drag.mouseDown(x,y)) {
		// put more code here to do something else when starting a drag
		return false
	}
	else return true
}

function mouseMove(e) {
	// Setup Slide Parameters
	if (is.ns) {
		iMouseX=e.pageX;
		iMouseY=e.pageY;
	}
	if (is.ie) {
		iMouseX=event.x;
		iMouseY=event.y;
	}
	
	// Page Mouse Call
	PageMouseMove();
	
	// Layer Move	
	if (is.ns && e.target!=document) routeEvent(e)
	var x = (is.ns)? e.pageX : event.x+document.body.scrollLeft
	var y = (is.ns)? e.pageY : event.y+document.body.scrollTop
	if (drag.mouseMove(x,y)) {
		// put more code here to do something else while dragging
		return false
	}
	else return true
}
function mouseUp(e) {
	if (is.ns && e.target!=document) routeEvent(e)
	var x = (is.ns)? e.pageX : event.x+document.body.scrollLeft
	var y = (is.ns)? e.pageY : event.y+document.body.scrollTop
	PageMouseUp();	
	if (drag.mouseUp()) {
		// put more code here to do something else when finished a drag
		return false
	}
	else return true
}

// ***************************** CREATE / DESTROY LAYER *******************************

function createLayer(id,nestref,left,top,width,height,content,bgColor,visibility,zIndex) {
	if (is.ns) {
		if (nestref) {
			var lyr = eval("document."+nestref+".document."+id+" = new Layer(width, document."+nestref+")")
		}
		else {
			var lyr = document.layers[id] = new Layer(width)
			eval("document."+id+" = lyr")
		}
		lyr.name = id
		lyr.left = left
		lyr.top = top
		if (height!=null) lyr.clip.height = height
		if (bgColor!=null) lyr.bgColor = bgColor
		lyr.visibility = 'hide'		
		// lyr.visibility = (visibility=='hidden')? 'hide' : 'show'
		if (zIndex!=null) lyr.zIndex = zIndex
		if (content) {
			lyr.document.open()
			lyr.document.write(content)
			lyr.document.close()
		}
	}
	else if (is.ie) {
		
		//alert(id);
		var str = '\n<DIV id='+id+' name='+id+'  style="position:absolute; left:'+left+'; top:'+top+'; width:'+width
		if (height!=null) {
			str += '; height:'+height
			str += '; clip:rect(0,'+width+','+height+',0)'
		}
		if (bgColor!=null) str += '; background-color:'+bgColor		
		if (zIndex!=null) str += '; z-index:'+zIndex
		if (visibility) str += '; visibility:'+visibility
		str += ';">'+((content)?content:'')+'</DIV>'
		
		if (nestref) {
			index = nestref.lastIndexOf(".")
			var nestlyr = (index != -1)? nestref.substr(index+1) : nestref
			document.all[nestlyr].insertAdjacentHTML("BeforeEnd",str);
		}
		else {
			document.body.insertAdjacentHTML("BeforeEnd",str)
		}
		
	}
}
function destroyLayer(id,nestref) {
	if (is.ns) {
		if (nestref) eval("document."+nestref+".document."+id+".visibility = 'hide'")
		else document.layers[id].visibility = "hide"
	}
	else if (is.ie) {
		document.all[id].innerHTML = ""
		document.all[id].outerHTML = ""
	}
}

function createNsNestedLayer(id,nestref1,nestref2,left,top,width,height,content,bgColor,visibility,zIndex) {
		var lyr = eval("document."+nestref1+".document."+nestref2+".document."+id+" = new Layer(width, document."+nestref1+".document."+nestref2+")")
		lyr.name = id
		lyr.left = left
		lyr.top = top
		if (height!=null) lyr.clip.height = height
		if (bgColor!=null)lyr.bgColor = bgColor
		lyr.visibility = 'hide'
		if (zIndex!=null) lyr.zIndex = zIndex
		if (content) {
			lyr.document.open()
			lyr.document.write(content)
			lyr.document.close()
		}
}


// ***************************** MINISCROLL LIBRARY *******************************

function MiniScroll(window,content) {
	this.window = window
	this.content = content
	this.content.slideInit()
	this.inc = 8
	this.speed = 20
	this.contentHeight = (is.ns)? this.content.doc.height : this.content.elm.scrollHeight
	this.contentWidth = (is.ns)? this.content.doc.width : this.content.elm.scrollWidth
	this.up = MiniScrollUp
	this.home = MiniScrollHome
	this.down = MiniScrollDown
	this.left = MiniScrollLeft
	this.right = MiniScrollRight
	this.stop = MiniScrollStop
	this.activate = MiniScrollActivate
	this.activate(this.contentWidth,this.contentHeight)
}
function MiniScrollActivate(w,h) {
	this.offsetHeight = h-this.window.h
	this.offsetWidth = w-this.window.w
	this.enableVScroll = (this.offsetHeight>0)
	this.enableHScroll = (this.offsetWidth>0)
}
function MiniScrollUp() {
	if (this.enableVScroll) this.content.slideTo(null,0,this.inc,this.speed)
}
function MiniScrollDown() {
	if (this.enableVScroll) this.content.slideTo(null,-this.offsetHeight,this.inc,this.speed)
}
function MiniScrollLeft() {
	if (this.enableHScroll) this.content.slideTo(0,null,this.inc,this.speed)
}
function MiniScrollRight() {
	if (this.enableHScroll) this.content.slideTo(-this.offsetWidth,null,this.inc,this.speed)
}
function MiniScrollStop() {
	this.content.slideActive = false
}
function MiniScrollHome() {
	if (this.enableVScroll) this.content.slideTo(null,0,1000,1000)
	if (this.enableHScroll) this.content.slideTo(0,null,1000,1000)
}

// ***************************** TRAP MOUSE CALLS ***********************************

document.onmousedown = mouseDown
document.onmousemove = mouseMove
document.onmouseup = mouseUp
if (is.ns) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP)

