// Routines for	location and size of window
var _orgWidth, _orgHeight, _orgLeft, _orgTop, _dw, _dh,	_dx, _dy;
var	sw=screen.width;
var	sh=screen.height;
var	asw=screen.availwidth;
var	ash=screen.availheight;
function cfGetInsets(winName){
	// Store the old document position
	var oldScreenLeft = winName.screenLeft;
	var oldScreenTop = winName.screenTop;
	// if no previous inset	calculated assume one
	if (winName._insets == null)
		winName._insets	= {left: 5, top: 80};
	// move	to a known position
	winName.moveTo(oldScreenLeft - winName._insets.left,oldScreenTop - winName._insets.top);
	// Measure the new document position
	var newScreenLeft = winName.screenLeft;
	var newScreenTop = winName.screenTop;
	// ... and store the insets result
	var res	= {
		left:	newScreenLeft -	oldScreenLeft +	winName._insets.left,
		top:	newScreenTop - oldScreenTop + winName._insets.top
	};
	// move	back the window	to its original	place
	winName.moveTo(oldScreenLeft - res.left, oldScreenTop -	res.top);
	// and backup the insets for next time
	winName._insets	= res;
	return res;
}
function cfGetLeft(winName){
	return winName.screenLeft - cfGetInsets(winName).left;
}
function cfGetTop(winName){
	return winName.screenTop - cfGetInsets(winName).top;
}
function cfGetInnerSize(winName){
	return {
		width:	winName.document.body.clientWidth,
		height:	winName.document.body.clientHeight
	};
}
function cfGetSize(winName){
	// Store old size
	var oldInnerSize = cfGetInnerSize(winName);
	// if no previous diff calculated assume one
	if (winName._diff == null)
		winName._diff =	{width:	10, height: 90};
	// resize to known size
	winName.resizeTo(oldInnerSize.width + winName._diff.width, oldInnerSize.height + winName._diff.height);
	// calculate inner size	again
	var newInnerSize = cfGetInnerSize(winName);
	// store diff result
	var diff = {
		width:	oldInnerSize.width - newInnerSize.width	+ winName._diff.width,
		height:	oldInnerSize.height - newInnerSize.height + winName._diff.height
	};
	// restore size	to old size
	winName.resizeTo(oldInnerSize.width + diff.width, oldInnerSize.height +	diff.height);
	// backup diff for future calculations
	winName._diff =	diff;

	return {
		width:	oldInnerSize.width + diff.width,
		height:	oldInnerSize.height + diff.height
	};
}
// -----------------------------------
// wintype "A" = full availible	space
// wintype "C" = centered
// wintype "F" = full-screen
// if autoclose	has a value, created window will be closed when	creator	window is closed or URL	changes.
//
function newBorderlessx(pageUrl,winName,windowW,windowH,windowX,windowY,winType,autoclose){
	if (winType=="A") {
		var windowW=screen.availwidth // wide
		var windowH=screen.availheight // high
		var windowX = 0	// from	left
		var windowY = 0	// from	top
	}
	if (winType=="F") {
		var windowW=screen.width // wide
		var windowH=screen.height // high
		var windowX = 0	// from	left
		var windowY = 0	// from	top
	}
	if (winType=="C") {
		var windowX = (screen.width/2)-(windowW/2) // center from left to right
		var windowY = (screen.height/2)-(windowH/2) // center from top to bottom
	}
	features = "width="+windowW+",height="+windowH;
	var isExplorer = document.all?true:false
	if (isExplorer){
   newWindow = window.open("",winName,"fullscreen,"+features)
		newWindow.blur()
		newWindow.resizeTo(windowW,windowH)
		newWindow.moveTo(windowX,windowY)
      }	else {
		newWindow=window.open("",winName,features)
		newWindow.blur()
		newWindow.resizeTo(windowW,windowH)
		newWindow.moveTo(windowX,windowY)
	}
	newWindow.location.href=pageUrl;
	newWindow.focus();
	if (autoclose){
		window.onunload	= function(){newWindow.close()}
	}
	return newWindow;
}
//
function newBorderless(pageUrl,winName,windowW,windowH,windowX,windowY,winType,autoclose){
	if (winType=="A") {
		var windowW=screen.availwidth // wide
		var windowH=screen.availheight // high
		var windowX = 0	// from	left
		var windowY = 0	// from	top
	}
	if (winType=="F") {
		var windowW=screen.width // wide
		var windowH=screen.height // high
		var windowX = 0	// from	left
		var windowY = 0	// from	top
	}
	if (winType=="C") {
		var windowX = (screen.width/2)-(windowW/2) // center from left to right
		var windowY = (screen.height/2)-(windowH/2) // center from top to bottom
	}
	features = "width="+windowW+",height="+windowH;
	var isExplorer = document.all?true:false
	if (isExplorer){
   newWindow = window.open("",winName,features)
		newWindow.blur()
		newWindow.resizeTo(windowW,windowH)
		newWindow.moveTo(windowX,windowY)
      }	else {
		newWindow=window.open("",winName,features)
		newWindow.blur()
		newWindow.resizeTo(windowW,windowH)
		newWindow.moveTo(windowX,windowY)
	}
	newWindow.location.href=pageUrl;
	newWindow.focus();
	if (autoclose){
		window.onunload	= function(){newWindow.close()}
	}
	return newWindow;
}
//
// Slide window
// special "L" = along left side of screen
// special "T" = along top of screen
// special "R" = along right side of screen
// special "B" = along bottom of screen
// any other value will	slide window to	x/y values supplied as arguments
function slideWindow(wName,newX,newY,speed,special) {
	var windowLeft=cfGetLeft(wName);
	var windowTop=cfGetTop(wName);
	var windowWidth=cfGetSize(wName).width;
	var windowHeight=cfGetSize(wName).height;
	if ((speed == null) || (speed <	1)) {
		speed=1
	}
	if (special == 'C') {
		newX=(screen.width/2)-(windowWidth/2)
		newY=(screen.height/2)-(windowHeight/2)
	}
	if (special=='L') {
		newX=0
		newY=windowTop
	}
	if (special=='T') {
		newX=windowLeft
		newY=0
	}
	if (special=='R') {
		newX=screen.width-windowWidth
		newY=window.Top
	}
	if (special=='B') {
		newX=windowLeft
		newY=screen.height-windowHeight
	}
//	timeDelay(1);
	if (newX<windowLeft) {
		for (i=windowLeft; i>newX; i=i-speed) {
			if (i<newX) {
				i=newX
			}
			wName.moveTo(i,windowTop)
		}
		windowLeft=newX
	}
	if (newX>windowLeft) {
		for (i=windowLeft; i<newX; i=i+speed) {
			if (i>newX) {
				i=newX
			}
			wName.moveTo(i,windowTop)
		}
		windowLeft=newX
	}
	if (newY<windowTop) {
		for (i=windowTop; i>newY; i=i-speed) {
			if (i<newY) {
				i=newY
			}
			wName.moveTo(windowLeft,i)
		}
		windowTop=newY
	}
	if (newY>windowTop) {
		for (i=windowTop; i<newX; i=i+speed) {
			if (i>newY) {
				i=newY
			}
			wName.moveTo(windowLeft,i)
		}
		windowTop=newY
	}
}
// Slide Borderless Window
// special "L" = along left side of screen
// special "T" = along top of screen
// special "R" = along right side of screen
// special "B" = along bottom of screen
// any other value will	slide window to	x/y values supplied as arguments
//
function slideBWindow(wName,newX,newY,speed,special) {
	var windowLeft=wName.screenLeft;
	var windowTop=wName.screenTop;
	var windowHeight=wName.document.body.clientHeight;
	var windowWidth=wName.document.body.clientWidth;
	if ((speed == null) || (speed <	1)) {
		speed=1
	}
	if (special == 'C') {
		newX=(screen.width/2)-(windowWidth/2)
		newY=(screen.height/2)-(windowHeight/2)
	}
	if (special=='L') {
		newX=0
		newY=windowTop
	}
	if (special=='T') {
		newX=windowLeft
		newY=0
	}
	if (special=='R') {
		newX=screen.width-windowWidth
		newY=window.Top
	}
	if (special=='B') {
		newX=windowLeft
		newY=screen.height-windowHeight
	}
//	timeDelay(1);
	if (newX<windowLeft) {
		for (i=windowLeft; i>newX; i=i-speed) {
			if (i<newX) {
				i=newX
			}
			wName.moveTo(i,windowTop)
		}
		windowLeft=newX
	}
	if (newX>windowLeft) {
		for (i=windowLeft; i<newX; i=i+speed) {
			if (i>newX) {
				i=newX
			}
			wName.moveTo(i,windowTop)
		}
		windowLeft=newX
	}
	if (newY<windowTop) {
		for (i=windowTop; i>newY; i=i-speed) {
			if (i<newY) {
				i=newY
			}
			wName.moveTo(windowLeft,i)
		}
		windowTop=newY
	}
	if (newY>windowTop) {
		for (i=windowTop; i<newY; i=i+speed) {
			if (i>newY) {
				i=newY
			}
			wName.moveTo(windowLeft,i)
		}
		windowTop=newY
	}
//	alert('Restore Desktop function has been run in '+self.name);
}
// Clear Desktop & Restore Desktop
// *** Special functions for Two  Borderless Windowed Desktop  ***
// Clears windows named	opener.interfaceWin & contentWin from desktop
function clearDesktop(speed) {
	var iwindowLeft=opener.interfaceWin.screenLeft;
	var iwindowTop=opener.interfaceWin.screenTop;
	var iwindowWidth=opener.interfaceWin.document.body.clientWidth;
	var iwindowHeight=opener.interfaceWin.document.body.clientHeight;
	var cwindowLeft=opener.contentWin.screenLeft;
	var cwindowTop=opener.contentWin.screenTop;
	var cwindowWidth=opener.contentWin.document.body.clientWidth;
	var cwindowHeight=opener.contentWin.document.body.clientHeight;
	var mwindowLeft=opener.morphWin.screenLeft;
	var mwindowTop=opener.morphWin.screenTop;
	var mwindowWidth=opener.morphWin.document.body.clientWidth;
	var mwindowHeight=opener.morphWin.document.body.clientHeight;
	var newInterfaceX=iwindowLeft-(screen.width+10);
	var newInterfaceY=iwindowTop;
	slideBWindow(opener.interfaceWin,newInterfaceX,newInterfaceY,speed,null);
	var newContentX=cwindowLeft+(screen.width+10);
	var newContentY=cwindowTop;
	slideBWindow(opener.contentWin,newContentX,newContentY,speed,null);
	var newMorphX=mwindowLeft;
	var newMorphY=mwindowTop+(screen.height+10);
	slideBWindow(opener.morphWin,newMorphX,newMorphY,speed,null);
//	alert('Clear Desktop function has been run in '+self.name);
}
// Restore Desktop
function restoreDesktop(speed) {
	var iwindowLeft=opener.interfaceWin.screenLeft;
	var iwindowTop=opener.interfaceWin.screenTop;
	var iwindowWidth=opener.interfaceWin.document.body.clientWidth;
	var iwindowHeight=opener.interfaceWin.document.body.clientHeight;
	var cwindowLeft=opener.contentWin.screenLeft;
	var cwindowTop=opener.contentWin.screenTop;
	var cwindowWidth=opener.contentWin.document.body.clientWidth;
	var cwindowHeight=opener.contentWin.document.body.clientHeight;
	var mwindowLeft=opener.morphWin.screenLeft;
	var mwindowTop=opener.morphWin.screenTop;
	var mwindowWidth=opener.morphWin.document.body.clientWidth;
	var mwindowHeight=opener.morphWin.document.body.clientHeight;
	var newInterfaceX=iwindowLeft+(screen.width+10);
	var newInterfaceY=iwindowTop;
	slideBWindow(opener.interfaceWin,newInterfaceX,newInterfaceY,speed,null);
	var newContentX=cwindowLeft-(screen.width+10);
	var newContentY=cwindowTop;
	slideBWindow(opener.contentWin,newContentX,newContentY,speed,null);
	var newMorphX=mwindowLeft;
	var newMorphY=mwindowTop-(screen.height+10);
	slideBWindow(opener.morphWin,newMorphX,newMorphY,speed,null);
//	alert('Restore Desktop function has been run in '+self.name);
}
// Minimize Window
function minimizeWindow(wName) {
	var offScreenX=cfGetLeft(wName)+(screen.width+10);
	var offScreenY=cfGetTop(wName)+(screen.height+10);
	wName.moveTo(offScreenX,offScreenY);
//	alert('Minimize Window function has been run in '+self.name);
}
// Restore Window
function restoreWindow(wName) {
	var offScreenX=cfGetLeft(wName)-(screen.width+10);
	var offScreenY=cfGetTop(wName)-(screen.height+10);
	wName.moveTo(offScreenX,offScreenY);
	wName.focus();
//	alert('Restore Window function has been run in '+self.name);
}
// Minimize Borderless Window
function minimizeBWindow(wName)	{
	var offScreenX=wName.screenLeft+screen.width+10;
	var offScreenY=wName.screenTop+screen.height+10;
	wName.moveTo(offScreenX,offScreenY);
//	alert('Minimize Bordrless Window function has been run in '+self.name);
}
// Restore Borderless Window
function restoreBWindow(wName) {
	var offScreenX=wName.screenLeft-(screen.width+10);
	var offScreenY=wName.screenTop-(screen.height+10);
	wName.moveTo(offScreenX,offScreenY);
	wName.focus();
//	alert('Restore Bordrless Window function has been run in '+self.name);
}
function sizeBWindow(wName,newWidth,newHeight,speed,special) {
	var windowLeft=wName.screenLeft;
	var windowTop=wName.screenTop;
	var windowWidth=wName.document.body.clientWidth;
	var windowHeight=wName.document.body.clientHeight;
if ((speed == null) || (speed <	1)) {
		speed=1
	}
	if (special=="O") {
		newWidth=(screen.width/2)
		newHeight=(screen.height/2)
	}
	if (special=="F") {
		newWidth=screen.width
		newHeight=screen.height
	}
	if (special=="A") {
		newWidth=screen.availwidth
		newHeight=screen.availheight
	}
	if (newWidth<windowWidth) {
		for (i=windowWidth; i>newWidth;	i=i-speed) {
			if (i<newWidth)	{
				i=newWidth
			}
			wName.resizeTo(i,windowHeight)
		}
		windowWidth=newWidth
	}
	if (newWidth>windowWidth) {
		for (i=windowWidth; i<newWidth;	i=i+speed) {
			if (i>newWidth)	{
				i=newWidth
			}
			wName.resizeTo(i,windowHeight)
		}
		windowWidth=newWidth
	}
	if (newHeight<windowHeight) {
		for (i=windowHeight; i>newHeight; i=i-speed) {
			if (i<newHeight) {
				i=newHeight
			}
			wName.resizeTo(windowWidth,i)
		}
		windowHeight=newHeight
	}
	if (newHeight>windowHeight) {
		for (i=windowHeight; i<newHeight; i=i+speed) {
			if (i>newHeight) {
				i=newHeight
			}
			wName.resizeTo(windowWidth,i)
		}
		windowHeight=newHeight
	}
}
function sizeWindow(wName,newWidth,newHeight,speed,special) {
	var windowLeft=cfGetLeft(wName);
	var windowTop=cfGetTop(wName);
	var windowWidth=cfGetSize(wName).width;
	var windowHeight=cfGetSize(wName).height;
	if ((speed == null) || (speed <	1)) {
		speed=1
	}
	if (special=="O") {
		newWidth=(screen.width/2)
		newHeight=(screen.height/2)
	}
	if (special=="F") {
		newWidth=screen.width
		newHeight=screen.height
	}
	if (special=="A") {
		newWidth=screen.availwidth
		newHeight=screen.availheight
	}
	if (newWidth<windowWidth) {
		for (i=windowWidth; i>newWidth;	i=i-speed) {
			if (i<newWidth)	{
				i=newWidth
			}
			wName.resizeTo(i,windowHeight)
		}
		windowWidth=newWidth
	}
	if (newWidth>windowWidth) {
		for (i=windowWidth; i<newWidth;	i=i+speed) {
			if (i>newWidth)	{
				i=newWidth
			}
			wName.resizeTo(i,windowHeight)
		}
		windowWidth=newWidth
	}
	if (newHeight<windowHeight) {
		for (i=windowHeight; i>newHeight; i=i-speed) {
			if (i<newHeight) {
				i=newHeight
			}
			wName.resizeTo(windowWidth,i)
		}
		windowHeight=newHeight
	}
	if (newHeight>windowHeight) {
		for (i=windowHeight; i<newHeight; i=i+speed) {
			if (i>newHeight) {
				i=newHeight
			}
			wName.resizeTo(windowWidth,i)
		}
		windowHeight=newHeight
	}
}
function gotoMovieLabel(movie,target,movieLabel) {
	movie.TCallLabel(target,movieLabel);
}
// Change Page
function changePage(windowFrame,newPage) {
	windowFrame.location.href=newPage;
}
// close window
function closeWindow(wName) {
	setTimeout('wName.close()',5000)
}
// Set Flash Movie Variable
function setFlashMovieVariable(movie,flashVariable,vValue) {
//	alert('VariableName='+flashVariable+' Value='+vValue+' Sent from '+self.name);
	movie.SetVariable(flashVariable,vValue);
}
function getMovieVarToMovie(movie1,fVariable1,movie2,fVariable2) {
	var x=movie1.GetVariable(fVariable);
	movie2.SetVariable(fVariable2,x);
}
function setMovieVar(movie,fVariable,vValue) {
	movie.SetVariable(fVariable,vValue);
}

function getMovievar(movie,fVariable) {
	var x=movie.GetVariable(fVariable);
	return x;
}
function doNothing() {}
function timeDelay(secs) {
	msecs=secs*1000;
	setTimeout('doNothing()',msecs);
}
// Back Button
function goBack() {
	window.history.back();
}
// Forward button
function goForward() {
	window.history.forward();
}
// Function to return window location
function getWinLoc(bWin) {
	wLocation=bWin.location;
	return wLocation;
}
// Function to send window location to a flash movie
function winLocationToFlashMovie(bWin,movie) {
	wLocation=getWinLoc(bWin);
	setFlashMovieVariable(movie,'/:wLocation',wLocation);
}
// Function to return window location domain
function getWinDom(bWin) {
	wDomain=bWin.location.hostname;
	return wDomain;
}
// Function to send window Domain to a flash movie
function winDomToFlashMovie(bWin,movie) {
	wDomain=getWinDom(bWin);
	setFlashMovieVariable(movie,'/:wDomain',wDomain);
}
// Function to lock window loc to a domain
function checkPageChange() {
	if (lockedDomain) {
		if (lockedDomain != self.location.hostname) {
			self.history.back()
		}
	}
}
// Function to lock a window to a domain
function lockDomain(bWin,winDomain) {
	bWin.lockedDomain=winDomain;
	bWin.onunload=checkPageChange;
}
function unlockDomain(bWin) {
	bWin.lockedDomain=null;
}
// Seismic window by Paul Anderson, copyright 1999 CNET, Inc.
var quakeID=0;
var deltaX=0;
var deltaY=0;
function tremor(dir) { // -10 to 10
with(Math) return ceil(random()*10)*2*(floor(random()*2)-.5);
}
function winQuake() {
clearTimeout(quakeID);
for (i=0;i<=((Math.random()*35)+5);i++) {
xShift = tremor();
yShift = tremor();
window.moveBy(xShift,yShift);
deltaX -= xShift;
deltaY -= yShift;
}
winReset();
quakeID=setTimeout("winQuake()",Math.ceil(Math.random()*3500)+250);
}
function winReset() {
window.moveBy(deltaX,deltaY);
deltaX=0; deltaY=0;
}
// No Right Clicks
function noRightClick(evnt) {
errMsg="All Web Content\n(unless otherwise noted)\n is Copyright Cuttlefish Technologies 2001"
if (navigator.appName.toUpperCase().match(/NETSCAPE/) != null) {
if (evnt.which == 3){alert(errMsg);return false;}}else
if (event.button==2)alert(errMsg);}
document.onmousedown=noRightClick;
