/*----------------------------------------------------------------------------------------------------
Javascript functions used in specific parts of the site.  One-off functions.  When adding a function 
to this toolkit, comment in your name, date you added the function, what the function does, where 
it is used and describe any parameters your function takes.
----------------------------------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------------------------------
Added by George Chiu: 1/1/2003
Pops up banner for NetConnect.  Used up on support pages only.
newURL: URL to page to display in window
newWidth: Width of window
newHeight: Height of window
----------------------------------------------------------------------------------------------------*/

function openAdWindow(newURL, newWidth, newHeight){
	var calcLeft = 100;
	var calcTop = 100;
	var remoteWindow
	
	if (parseInt(navigator.appVersion) >= 4){
  		calcTop = screen.availHeight /2 - newHeight / 2;
  		calcLeft = screen.availWidth / 2 - newWidth / 2;}
		
	remoteWindow = window.open('/shared/banners/' + newURL, 'remote', 'height=221,width=300,menubar=no,location=no,status=no,scrollbars=no,toolbar=no,resizable=yes,left=' + calcLeft + ',top=' + calcTop)
	remoteWindow.focus();
}	


//---------------------------------------------------------------------------------------------------
//-- Pre-Load Images
//---------------------------------------------------------------------------------------------------

var images = new Array();

function jsLoadImages(){ 
	for (var i=0; i < jsLoadImages.arguments.length; i++){
		images[i] = new Image();
		images[i].src = jsLoadImages.arguments[i];
	}
}


//---------------------------------------------------------------------------------------------------
//-- Image Swap function
//---------------------------------------------------------------------------------------------------

function Swap(imgName,imgObjName)
{
 if (document.images)
  {
   document.images[imgName].src = eval(imgObjName + ".src");
  }
}


//---------------------------------------------------------------------------------------------------
//-- Image Swap function
//---------------------------------------------------------------------------------------------------

function imgSwap(imgName,imgSrc) 
{
	document.images[imgName].src = imgSrc;
}

/*---------------------------------------------------------------------------------------------------
Added by Rodney Amian: 5/21/2004
Preload images for registration button on eBook pages.  Button located on sidebal.
----------------------------------------------------------------------------------------------------*/

jsLoadImages('/shared/images/glb_btn_register_on.gif');
if (document.images)
{

	glb_btn_register_on = new Image(100,21); glb_btn_register_on.src = "/shared/images/glb_btn_register_on.gif";
	glb_btn_register_off = new Image(100,21); glb_btn_register_off.src = "/shared/images/glb_btn_register_off.gif";
}


/*------------------------------------------------------------------------------------------------------
Added by Rodney Amian: 5/21/2004
Launches Auto Demo for SM, VSM and Security Solutions
Used by the following files 

/products/sm/tour.asp 
/products/vsm/tour.asp 
/solutions/security/default.asp
-------------------------------------------------------------------------------------------------------*/

var openedWin = null;
var wpercent = 100;

function launch()
{
	var args = launch.arguments;
	var url = args[0];
	var width = args[1];
	var height = args[2];
	
	if (!url || !width || !height) {
		alert('Error in arguments');
	} else {
		var scr_w = screen.availWidth;
		var scr_h = screen.availHeight;
		var target_w = 0;
		var target_h = 0;
		
		wpercent = 100;
		var scr_w = screen.availWidth;
		var scr_h = screen.availHeight;
		
		if (width >= scr_w || height >= scr_h) {
			if (width >= scr_w && height < scr_h) {
				wpercent = Math.floor(((scr_w - 8) * 100) / width);
			} else if (height > scr_h) {
				wpercent = Math.floor(((scr_h - 27) * 100) / height);
			}
			width = Math.floor((width * wpercent) / 100);
			height = Math.floor((height * wpercent) / 100);
		}
		
		_launch(url, width, height, args[3], args[4], args[5], args[6], args[7], args[8], args[9]);
	}
}

function _launch()
{
	closeChild();
	
	var args = _launch.arguments;
	var url = args[0];
	var width = args[1];
	var height = args[2];
	var resizable = args[3] ? 'yes' : 'no';
	var scrollbars = args[4] ? 'yes' : 'no';
	var toolbar = args[5] ? 'yes' : 'no';
	var menubar = args[6] ? 'yes' : 'no';
	var status = args[7] ? 'yes' : 'no';
	var address = args[8] ? 'yes' : 'no';
	var directories = args[9] ? 'yes' : 'no';
	
	var NewX = Math.max(0, Math.floor((screen.availWidth - (width + 8)) / 2));
	var NewY = Math.max(0, Math.floor((screen.availHeight - (height + 27)) / 2));
	
	var params = new Array();
	params.push('width=' + width);
	params.push('height=' + height);
	params.push('screenx=' + NewX);
	params.push('screeny=' + NewY);
	params.push('left=' + NewX);
	params.push('top=' + NewY);
	params.push('resizable=' + resizable);
	params.push('scrollbars=' + scrollbars);
	params.push('toolbar=' + toolbar);
	params.push('menubar=' + menubar);
	params.push('status=' + status);
	params.push('location=' + address);
	params.push('directories=' + directories);
	
	openedWin = window.open(url, '', params.join(','));
}

function closeChild()
{
	if (openedWin != null) {
		if (!openedWin.closed) {
			openedWin.close();
		}
	}
}

onunload = closeChild;