//Pop up window for another site (appears to be unused -- cmj 26sep2005)
function openWindow(url) {
	popupWin = 	window.open(url,'remote','resizable,scrollbars,location,status,menubar,toolbar,width=750,height=600,');
	//return popupWin;
}

//Pop up window for
function openWin(url) {
	popupWin = 	window.open(url,'remote','resizable,scrollbars,width=480,height=410,');
	//return popupWin;
}

//Pop up window - accepts arguments for window height and width
function NewWindow(mypage, myname, w, h, scroll) {
	self.name = "Parent_Window";
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=yes';
	win = window.open(mypage, myname, winprops);
	if (window.focus) { win.focus(); }
	return false;
}


// fix for NS resize bug
NS4 = document.layers;
if (NS4) {
	origWidth = innerWidth;
	origHeight = innerHeight;
}
function reDo() {
   if (innerWidth != origWidth || innerHeight != origHeight) 
      location.reload();
}
if (NS4) onresize = reDo;
//  end fix for NS resize bug


// Preload navigation images. Rewritten for rebrand cmj 03Oct2005
var precacheImages = new Array();

/* Because over and on state are the same, the same image is used for both states. 
Three states are retained for backward compatibility. */
var IMGOFF = "0";
var IMGOVER = "1";
var IMGON = "2";

var suffix = new Array();
	suffix[IMGOFF] = "_off.gif";
	suffix[IMGOVER] = "_on.gif"; // was: _over.gif
	suffix[IMGON] = "_on.gif";

function preload() {
	if (document.images) {
		var precacheKeys = new Object();
		for(i=0;i<document.images.length;i++) {
			myimg = document.images[i];
			if(myimg.src.indexOf("images/forms/")>-1 && myimg.src.indexOf("btn")>-1) {
				s = myimg.src.lastIndexOf('/');
				path = myimg.src.substr(0,s+1);
				filename = myimg.src.substr(s+1);
				us = filename.lastIndexOf('_');
				btnname = filename.substr(0,us);
				if(!precacheKeys[btnname]) {
					precacheImages[btnname+IMGOFF] = new Image();
					precacheImages[btnname+IMGOFF].src = path + btnname + suffix[IMGOFF];
					precacheImages[btnname+IMGON] = new Image();
					precacheImages[btnname+IMGON].src = path + btnname + suffix[IMGON];
					precacheImages[btnname+IMGOVER] = new Image();	
					precacheImages[btnname+IMGOVER].src = path + btnname + suffix[IMGOVER];
				}
				precacheKeys[btnname] = 1;
			} 
		}
	}
}

function setImg() {
	if (document.images) {
		for (var i=0; i < setImg.arguments.length; i+=3) {
			var key = setImg.arguments[i];
			var status = setImg.arguments[i+1];
			var imgname = setImg.arguments[i+2];	
	
			if (typeof(document.images[imgname])!='undefined'){
				document.images[imgname].src = precacheImages[key+status].src;
			} else {
				myimg = document.getElementById(key);
				if(myimg) {
					us = myimg.src.lastIndexOf('_');
					myimg.src = myimg.src.substr(0,us) + suffix[status];
				}
			}
		}
	}
}
//End Preload

function doSubmit(myform){

   // message for the Submit alert box
   // note how \n is used for line formatting
   var S = "SUBMIT - look in the code, and replace this alert box \n"+
           "with whatever action you wish to perform when the submit \n"+
           "image 'button' is clicked.\n\n"+
           "If you wish to call an html page, then you would use...\n\n"+
           "window.location='http://www.address.com/page.html' \n\n"+
           "If you wish to call a script, then use the address of the\n"+
           "the script. Additional code would be required if you need\n"+
           "to pass values from the form fields to the cgi script. \n"
   
   // call the alert box        
   //alert(S)
   myform.submit();
   
   // optional -- but it gets the lines off the image in IE
   self.focus()
   
   // if you wanted to call an html page, this is where you would
   // do it, in the format of the following example line...
   // window.location='http://www.codebrain.com/java/index.html'
}

// Used for secondary page navigation (i.e. Internet Access Splash Page)
function setCurrent(name) {
	p = document.getElementById('linklist');
	items = p.childNodes;
	for(i=0;i<items.length;i++) {
		c = items.item(i);
		if(c.className == 'current') c.className = '';
	}
	l = document.getElementById(name);
	l.className='current';

}

// Set Knowledgebase links to open in new window
function nw() {
	return NewWindow(this.href,'CP11102',950,600,'yes');
}
function targetLinks() {
	var arrLinks=document.getElementsByTagName('A');
	for(i=0;i<arrLinks.length;i++) {
		thisLink=arrLinks.item(i);
		if(thisLink.href.indexOf('knowledgebase.net') != -1) {
			thisLink.onclick = nw;
		}
	}
}

function init() {
	preload();
	targetLinks();
}
window.onload = init;