//alert("loading script");

//Error Handler
/*
var errWin;
function reportError(message,url,lineNumber,name) {
	//alert("reportError");
	var errWin = window.open('','errWin','width=400,height=400,top=20,left=20,scrollbars=yes');
	//errWin?alert("Exists"):alert("Doesn't Exist");
	if ( message && url && lineNumber && errWin ) {
		errWin.document.write('<h3>Error!</h3><p>Error Message:</p><p>Error: '+message+'</p><p>Location: '+url+'</p><p>Line: '+lineNumber+'</p>');
	errWin.focus();
	return true;
	} else {
		errWin.document.write('<h3>Error!</h3><p>Error Message:</p><p>Error: '+message+'</p><p>Location: '+url+'</p><p>Name: '+name+'</p>');
	errWin.focus();
	return true;
	}
}

function doNothing(){
	return true;
}
window.onerror=reportError;
//window.onerror=doNothing;
//window.testError();
*/

function setMenu(){
	if (pageName=='Articles') swapImage('document.menuTable','menu_1','../images/menuOvr_1.jpg');
}

function ns_reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {
  		if ( (appName=="Netscape") && (parseInt(appVersion)==4) ) {
    		document.ns_pgW=innerWidth; 
			document.ns_pgH=innerHeight; 
			onresize=ns_reloadPage; 
		}
	} else if (innerWidth!=document.ns_pgW || innerHeight!=document.ns_pgH) {
		location.reload();
	}	
}
ns_reloadPage(true);

//************** Find Object Generic: ******************
function findObj(n,d) {
  	var p,i,x;
	//d=document referenced
	if (!d) {
		d=document;
	}
	//p=first index ? of n: object name-id/frame ref 'objName?frameName', if first argument
	if ( (p = n.indexOf("?")) > 0 && parent.frames.length ) {
		d = parent.frames[n.substring(p+1)].document; //frameName
		n = n.substring(0,p);//obj name-id
	}
	for( i=0;!x && d.layers && i<d.layers.length;i++) {
		x = findObj(n,d.layers[i].document);
	}
	for ( i=0;!x && i<d.forms.length;i++) {
		x=d.forms[i][n];
	}
	for ( i=0;!x && i<d.images.length;i++) {
		x=d.images[i][n];
	}
	if ( !(x = d[n]) && d.all) {
		x = d.all[n];
	}
  	if ( !x && document.getElementById ) {
		x = document.getElementById(n);//if not x look in GEBI
	}
	if (x) {
		return x;
	}
}

//onmouseover="swapImage('document','imgname1','path/imagefile1','imgname2','path/imagefile2'...);" object/path pairs. onmouseout="swapImgRestore();"
function swapImage() {//requires findObj() to be loaded
	var a,i,d,s,obj;
	a = swapImage.arguments;
	if(a[0].length>0&&document.layers){
		d=eval(a[0]+'.document');
	} else {
		d=document;
	}
  	document.old_src = new Array; 
	s=document.old_src;
  	for(i=1;i<(a.length-1);i+=2) {
		if ((obj=findObj(a[i],d))){
			s[i-1] = obj; 
			s[i] = obj.src; 
			obj.src=a[i+1];
		}
	}
}

// Swap Image Restore onmouseout="swapImgRestore();"
function swapImgRestore() {
	var i,obj,s;
	if ( document.old_src ) {
		s = document.old_src;
		for( i=0; i < s.length-1; i+=2 ) {
			obj = s[i];
			obj.src = s[i+1];
		}
	}
} 

// preload images on page load
// put in <body onload="preloadImage('images/image1','images/image2',...)"
function preloadImages() 
{
	if (document.images) 
	{
       var imgFiles = preloadImages.arguments;
       var preloadArray = new Array();
       for (var i=0; i < imgFiles.length; i++) 
	   {
            preloadArray[i] = new Image;
            preloadArray[i].src = imgFiles[i];
       }
    }
}
