/////////////////////////////////////////
// GENERAL SCRIPTS SHARED BY MOST PAGES
// Copyright © PBMS Consultants 2004 
/////////////////////////////////////////


// script for date on homepage header
var months = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var days = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var time = new Date();
var month = months[time.getMonth()];
var day = days[time.getDay()];
var date = time.getDate();
var year = time.getYear();
if (year < 2000) year = year + 1900;
//-->

//  original script to open window as pop-up with a default size of 600 x 600
function postpopm(m)
{ if (m != ""){ window.open(m,'postwin','menubar=yes,status=yes,scrollbars=yes,resizable=yes,width=600,height=600'); 
	} 
}	
//-->

// Popup Caller page: Open target as separate pop up window with dimensions unspecified
// 'PBMS' is passed to the target 'opener.name' to indicate it was opened from a PBMS site link
//  If PBMS the 'setwindow' function sizes the window using each target's 'wid' and 'ht' variables.
function openpop (pg) {
	window.name = "PBMS";
	var popfile = open (pg,'popwin','menubar=yes,status=yes,scrollbars=yes,resizable=yes');
	popfile.opener.name = "PBMS"
//	alert ("Opener = "+popfile.opener.name)
}
//-->

// AnnWebCom script to open Privacy page
function popPage(page,w,h)
		{
		pop1 = window.open(page,'pop1','toolbar=no,location=no,directories=no,status=yes,menubar=yes,resizable=yes,copyhistory=no,scrollbars=yes,width=' + w + ',height=' + h);
		pop1.focus();
		}

// PBMS equivalent
function popPBMS(page)
		{
		PBMS = window.open(page,'PBMS','toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes');
		PBMS.focus();
		}
//-->

// MM Rollover Script

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->




// Popup Called pages

// Override default exit button IMAGE if opened by another PBMS page
//	if (window.opener.name == "PBMS") {
	if (window.self.name == "PBMS") {
		setimage ()
	}


/* If opened from a PBMS site, 'window.opener.name' will be 'PBMS' so dimension window as popup
	Note: The 'name' property of 'window.opener' causes an error in FrontPage but works OK
	in IE and Netscape */

function setwindow(pWid,pHt) {
//	alert ("Opened by :"+window.opener.name) // test purposes
//	if (window.opener.name == "PBMS") {

	if (window.self.name == "PBMS") {
		window.resizeTo(pWid, pHt)
	}
}


// Override default exit button LINK from 'PBMS Home' to 'Close' if opened by another PBMS page
function setlink() {
	if (window.self.name == "PBMS") {

//	if (window.opener.name == "PBMS") {
//	alert ("Opened by PBMS") // test purposes
		window.close()
		}
}

// Override default exit button IMAGE from 'PBMS Home' to 'Close' if opened by another PBMS page
// Called at end of <body> after default page settings loaded

function setimage() {
	if (window.self.name == "PBMS") {
document.fpAnimswapImgFP2.src="images/btnTopBackN.gif"
document.fpAnimswapImgFP2.lowsrc="images/btnTopBackL.gif"
	}
}

//-->



// Alternative script to open window as pop-up and apply 'wid' and 'ht' dimensions in target page from this function
// Not used because Netscape times out before target dimensions are retrieved
function popwin(pg,blnpop) { 
var pWid // deliberately undefined to trap undefined situation in while loop
var pHt // deliberately undefined
var ctr = 0

// open target as separate window with dimensions unspecified:
var popwin = window.open(pg,'postwin','menubar=yes,status=yes,scrollbars=yes,resizable=yes'); 

// loop to delay until dimensions are found:
// works OK for IE, Netscape times out
while (pWid == undefined || pHt == undefined) { 
	ctr++;
	pWid = popwin.wid;
	pHt = popwin.ht;
	if (ctr > 100000) break; // prevent continuous loop 
	}

// resize target window its stated dimensions:
if (blnpop == true) {
	popwin.window.resizeTo(pWid, pHt);
	}
} 
//-->


