// WestBankMC.js  2010.01.06,  harald ~hn
// Opera does not like trimX: function (s), add try-catch to choosepix, choosead
// Pix 220x165,  Ads 289x165  Sponsors page 
// Removed many comments from this file. See westbankmc2_SourceComments_200904.js
/* functions in this file ~hn 2008.07.09  Lets clean this up in 2010 ~hn
2010.02.03 Change topper pic link to toppics.htm
2009.03.22 Added popup0(...)
function RandomizeArrays()
function InitArrays()
function trims(str,br,sz,nbr)
function trim( s )
trimX: function( s )
function banner1()
function popup0(winURL, winWidth, winHeight, winScroll, winResize, winLeft, winTop, winMenu, winTool, winStat, winLoc, winDir)
  winName = winName0;
  if (typeof(winWidth) == "undefined") { var winWidth = 640; }
  if (typeof(winHeight) == "undefined") { var winHeight = 480; }
  if (typeof(winScroll) == "undefined") { var winScroll = 0; }
  if (typeof(winResize) == "undefined") { var winResize = 0; }
  if (typeof(winLeft) == "undefined") { var winLeft = 10; }
  if (typeof(winTop) == "undefined") { var winTop = 10; }
  if (typeof(winDir) == "undefined") { var winDir = 0; }
  if (typeof(winMenu) == "undefined") { var winMenu = 0; }
  if (typeof(winTool) == "undefined") { var winTool = 0; }
  if (typeof(winStat) == "undefined") { var winStat = 0; }
  if (typeof(winLoc) == "undefined") { var winLoc = 0; }
  if (typeof(winDir) == "undefined") { var winDir = 0; }
  javascript:popup0('sponsors.htm#Mayslacks',670,680,1,1,10,10,1)
  javascript:popup0('YearlyEvents/YearBegin/2009/Officers%20Meeting%202009.03.20.htm',%20670,%20680,%201,%201,%207,%207)

function popup1(winURL, winWidth, winHeight, winScroll, winResize, winLeft, winTop)  Show Menu bar
function popup(winURL, winWidth, winHeight, winScroll, winResize)
function newWindow(url, width, height)  was function newWindow(url, height, width)
function refresh2()
function loadpage2(pg)
function changead()
function choosead()
function changepix()
function choosepix()
function openpopup(url)
function GetDayDate(id)
function countdown(obj)
function cd_Calcage(secs, num1, num2)
function cd_CountBack(secs)
function cd_Setup()
function getElementById_s(id)
function addEvent(obj, evType, fn)
function addLoadEvent(func) 
function addLoadEvent1(func) 
function ImagePopup( title, target, imagesrc, look )
function geovisit()
function button_on ( imgId )
function button_off ( imgId )
function updateClock ()
function DLM ( ) // Document Last Modified
*/

// addEvent(window, 'load', function);
function addEvent(obj, evType, fn){
 if (obj.addEventListener){
   obj.addEventListener(evType, fn, false);
   return true;
 } else if (obj.attachEvent){
   var r = obj.attachEvent("on"+evType, fn);
   return r;
 } else {
   return false;
 }
}

var speed=7;
// var msg=" The Beginning of Year Ride & Party will be on April 28th - 'Hi-Ya-Busa' Dave is hosting... ";
// var msg2="  Beginning of Year Ride & Party is this Sataturday, April 28th - 'Hi-Ya-Busa' Dave is hosting...";
var msg=" The Year End Party and Awards presentation will be on October 11th at Dicks Porting in Andover... ";
var msg2="  Year End Party this Sataturday, October 11th at Dicks Porting in Andover...";
var msg1=pad(msg,(msg.length) * 2, " ", STR_PAD_LEFT);
var id,pause=0,position=0,revol=3;
//alert("msg.length=" + msg.length*2 + "\n   msg1=\""+ msg1 + "\"");

function banner1() {
  if (revol == 1) { 
  	//alert("revol=" + revol);
  	msg1 = msg1 + "  That's All Folks - See ya at the party";
  	revol--;
  } 
  document.thisform.thisbanner.value=msg1.substring(position,position+msg1.length);
  if(position++==msg1.length) 
  {
      if (revol-- < 1) { 
	      msg1 = msg2;
	      document.thisform.thisbanner.backgroundcolor="#666699"; 
	      document.thisform.thisbanner.value=msg1;
	      //alert("revol=" + revol);
	      return; 
      };
      position=0;
      //alert("revol=" + revol);
  }
  id=setTimeout("banner1()",1000/speed);
}

// for cycling ads and pix
 var dbg = 0;	// >0=debug
 var timer_pix = ""; //used in changepix()
 var timer_ad = ""; //used in changead()
 var timer_weather = ""; //used in changeweather()
 var weatherbannertype="";	// used in changeweather() to change banner type so time updates
 var cnt_pix=240; // count of pictures
 var cnt_ads=20; // count of ads to display. Not necessary - calculated from the array.
 var ad_path = "topads/";	// was "ads/topper/" - AdBlockPlus blocks /ads by default
 var ad_split = "";
 var ad_banner = "";
 var ad_url = "";
 var ad_alt = "";
 var ad_txt = "";
 var ad_idx = "";
 var ad_target = '\"doc_frame\" '
 var ad_onclick = "onclick=\"propopup({url:this.href,width:669,height:580,xpos:'left',xoffset:10,ypos:'top',yoffset:10,name:'topad'});return false;\""
 var ad_title = ' title="West Bank Motorcycle Club Sponsors "'
 var idx_pix=cnt_pix;
 var idx_ads=cnt_ads;
 var ary_pix=new Array();
 var ary_ads=new Array();
 var ary_ads1=new Array();
 var msec_lo = 15000; // 15 seconds - remember to fix number
 var msec_hi = 25000; // 25 seconds
 var msec_dif = msec_hi-msec_lo; 
 var msec_lo_ad = 15000; // 15 seconds
 var msec_hi_ad = 25000; // 25 seconds
 var msec_dif_ad = msec_hi_ad-msec_lo_ad; 
 var msec_lo_pix = 13000; // 13 seconds
 var msec_hi_pix = 24000; // 25 seconds
 var msec_dif_pix = msec_hi_pix-msec_lo_pix;
// format for ad string: "Banner URL~ AD URL~ Alt_Text~ Text"  Delimiter must be ~. Leading and trailing spaces are trimmed
// Add new sponsors Ads at end just before the BecomeASponsor line. Remember the comma at the end of the line
// These pointers will be moved to the index.htm file during the winter 2008 cleanup for the 2009 year. If I'm still in charge of the website. ~hn
 var ary_ads1 = ["tpr_BecomeSponsor.jpg~ topads/index.html~  This could be your ad...~  This could be your ad...",
"tpr_AutoMax.jpg~ sponsors.htm#AutoMax~ Auto Max Brakes & Mufflers, 7125 151st Street West  #101, Apple Valley, MN 55124, (952) 432-7995~ Auto Max Brakes & Mufflers, 7125 151st Street West  #101, Apple Valley, MN 55124, (952) 432-7995  [2010.06.14]",
"tpr_BoatDrinks1.gif~ sponsors.htm#BoatDrinks~ BoatDrinks - Prescott, WI~ BoatDrinks - Prescott, WI",
"tpr_CloverLeafBar.gif~ sponsors.htm#CloverLeaf~ CloverLeaf Bar & Grill, 1428 4th Street&nbsp;&nbsp;Newport, MN 55055&nbsp;612-789-9862~ CloverLeaf Bar &amp; Grill, 1428 4th Street&nbsp;&nbsp;Newport, MN 55055&nbsp;612-789-9862  [2010.04.01]",
"tpr_DaveTilsen1.jpg~ sponsors.htm#DavidTilsen~ Dave Tilsen's Blog on http://blog.dtilsen.net/blogs/dave/~ Dave Tilsen's Blog at http://blog.dtilsen.net/blogs/dave/  [2010.04.01]",
"tpr_DonsLittleBar.jpg~ sponsors.htm#DonsLittleBar~ Don's Little Bar, White Bear Lake, MN~ Don's Little Bar, White Bear Lake, MN  [2010.04.01]",
"tpr_Drifters.jpg~ sponsors.htm#Drifters~ Drifters Bar &amp; Grill, Inver Grove Heights, MN~ Drifters Bar &amp; Grill, Inver Grove Heights, MN  [2010.04.01]",
"tpr_DrMudspringer.jpg~ sponsors.htm#DrMudspringer~ Dr. Mudspringers, 8465 Plaza Blvd. NE, Spring Lake Park, MN 55432~ Quality Motorcycle Accessories for your Metric Touring Motorcycle, Metric Cruiser & Harley Davidson Baggers",
"tpr_Glockenspiel.jpg~ sponsors.htm#Glockenspiel~ Glockenspiel German Restaurant, 605 7th Street West, Saint Paul, MN 55102, 651-292-9421~ www.GlockenspielRestaurant.com  [2010.04.01]",
"tpr_HeritageLiquor.jpg~ sponsors.htm#HeritageLiquor~ Heritage Liquor, Maplewood, MN~ Heritage Liquor, Maplewood, MN   www.heritageliquoronline.com  [2010.06.25]",
"tpr_HogWild.jpg~ sponsors.htm#HogWild~ Hog Wild Saloon and Eatery, Henderson, MN~ Hog Wild Saloon and Eatery, Henderson, MN",
"tpr_joe&amp;stans.jpg~ sponsors.htm#Joe&amp;Stans~ Joe & Stan's Bar &amp; Grill, 949 West Seventh Street Saint Paul, MN 55102  (651)293-0571~ www.joeandstans.com",
"tpr_Keenans.jpg~ sponsors.htm#Keenans~ Keenans~ Keenans  [2010.04.01]",
"tpr_KendallsAceHardware.jpg~ sponsors.htm#KendallsAceHardware~ KendallsAceHardware, St. Paul~ Kendall’s Ace Hardware, St. Paul [2010.06.30]",
"tpr_KlinkersKorner.jpg~ sponsors.htm#KlinkersKorner~ Klinker's Korner Bar in Baldwin, WI~ Klinker's Korner Bar in Baldwin, WI  [2010.04.01]",
"tpr_LeosSouth2010b.jpg~ http://www.leossouth.com~ Leo's South, 16375 Kenrick Ave, Lakeville, MN 55044  952-435-5371~ Leo's South, Lakeville, MN  [2010.04.01]",
"tpr_MikesMidtownBarberShop.jpg~ sponsors.htm#MikesMidtownBarberShop~ Mikes Midtown Barber Shop - Hastings, WI~ Mikes Midtown Barber Shop - Hastings, WI  [2010.04.01]",
"tpr_MuddyWaters.jpg~ sponsors.htm#MuddyWaters~ MuddyWaters, Prescott, WI~ MuddyWaters, Prescott, WI  [2010.04.01]",
"tpr_OlePiper3.jpg~ sponsors.htm#OlePiper~ Ole Piper Restaurant &amp; Sports Bar~ Ole Piper Restaurant &amp; Sports Bar  [2010.06.25]",
"tpr_PilotHouse.jpg~ sponsors.htm#PilotHouse~ Pilot House - Prescott, WI~ Pilot House - Prescott, WI  [2010.04.01]",
"tpr_RudysAutoService.jpg~ sponsors.htm#RudysAutoService~ Rudy's Auto Service~ Rudy's Auto Service  [2010.04.01]",
"tpr_TheBar.jpg~ sponsors.htm#TheBar~ The Bar in Hastings, MN~ The Bar in Hastings, MN  [2010.04.01]",
"tpr_Yarusso.jpg~ http://www.yarussos.com/~ Yarusso-Bros. Italian Restaurant~ Yarusso-Bros. Italian Restaurant  [2010.04.01]",
"tpr_tomthetailor.jpg~ sponsors.htm#TomTheTailor~ Tom the Tailor, Zip-R-Strip - The leather expert~ http://www.zip-r-strip.com  [2010.04.01]",
"tpr_DicksPorting.jpg~ sponsors.htm#DicksPorting~ Dick's Porting~ Dick's Porting  [2010.04.01]",
"tpr_MacsPizza.jpg~ sponsors.htm#MacsPizza~ Mac's Pizza at Whiskey Junction~ http://www.whiskeyjunction.com  [2010.04.01]",
"tpr_Junction40Yr-2.jpg~ sponsors.htm#TheJunction2~ The Whiskey Junction - Whiskey on Stage~ http://www.whiskeyjunction.com  [2010.04.01]",
"tpr_Junction40Yr-4.jpg~ http://www.thewhiskeyjunction.com~ The Whiskey Junction - Whiskey on Stage~ http://www.thewhiskeyjunction.com  [2010.04.01]",
"tpr_BecomeSponsor.jpg~ topads/index.html~  This could be your ad...~  This could be your ad..."
 ];
// Removed in 2010
//"tpr_AlsCenterSaloon.jpg~ sponsors.htm#AlsCenterSaloon~ Al's Center Saloon, 325 Summit Ave, Center City, MN 55012, (651) 257-5757~ Al's Center Saloon, 325 Summit Ave, Center City, MN 55012, (651) 257-5757",
//"tpr_BambooBettys.jpg~ sponsors.htm#BambooBettys~ Bamboo Bettys Party Bar & Grill~ Bamboo Bettys Party Bar & Grill",
//"tpr_BeachUpholstery.jpg~ sponsors.htm#Beach~ Beach Upholstery, Hudson, WI~ Beach Upholstery, Hudson, WI",
//"tpr_BeachUpholstery.jpg~ sponsors.htm#Beach~ Beach Upholstery, Hudson, WI~ Beach Upholstery, Hudson, WI",
//"tpr_TheCardinalBar&amp;Grill.jpg~ http://www.cardinaltavern.com~ The Cardinal Restaurant &amp; Bar~ The Cardinal Restaurant &amp; Bar",
//"tpr_CloverLeafBar.gif~ sponsors.htm#CloverLeaf~ CloverLeaf Bar & Grill~ CloverLeaf Bar &amp; Grill",
//"tpr_DeansTavern.jpg~ sponsors.htm#DeansTavern~ DeansTavern~ www.deanstavern.com",
//"tpr_EarthsTreasureChest.jpg~ sponsors.htm#EarthsTreasureChest~ Earths Treasure Chest - Finest Loose Gem Stones on Earth from Milo, milokendall@Yahoo.com~ Earths Treasure Chest - Finest Loose Gem Stones on Earth from Milo, milokendall@Yahoo.com",
//"tpr_GoMoto.jpg~ http://www.gomotomn.com~ Go Moto, 8617 Jefferson Hwy, Osseo, MN 55369, 763-315-MOTO (6686)~ www.gomotomn.com",
//"tpr_goodoldays-logo.jpg~ sponsors.htm#GoodOlDays~ Good Ol' Days Bar &amp; Grill in Tower, MN~ Good Ol' Days Bar &amp; Grill in Tower, MN",
//"tpr_HeritageLiquor.jpg~ sponsors.htm#HeritageLiquors~ Heritage Liquors, St. Paul~ Heritage Liquors, St. Paul  www.heritageliquoronline.com  2010.06.25",
//"tpr_Hi-PerSports.jpg~ sponsors.htm#HiPerSports~ Hi-Per Sports, 10550 County Road 81 # 211, Maple Grove, MN 55369, (763) 493-5620~ Hi-Per Sports, Maple Grove, MN",
//"tpr_KendallsAceHardware.jpg~ sponsors.htm#KendallsAceHardware~ KendallsAceHardware, St. Paul~ Kendall’s Ace Hardware, St. Paul [2010.06.30]",
//"tpr_KlineMotorsports.jpg~ sponsors.htm#KlineMotorsports~ KlineMotorsports~ www.kline-motorsports.com",
//"tpr_LarsonsCycle.jpg~ sponsors.htm#LarsonsCycle~ Larson Cycle Inc, 205 Garfield St S, Cambridge, MN 55008, (763) 689-2760~ www.larsonscycle.com",
//"tpr_Leather&Lace.jpg~ sponsors.htm#Leather&Lace~ Leather &amp; Lace, Afton, MN~ http://www.aftonleather.com/",
//"tpr_Legends.jpg~ http://www.legendsbarandgrill.com~ Legends Bar &amp; Grill, Minneapolis, MN~ Legends Bar &amp; Grill, Minneapolis, MN",
//"tpr_Luckys13Pub2.jpg~ sponsors.htm#Luckys13Pub~ Lucky's 13 Pub~ Lucky's 13 Pub",
//"tpr_Mayslacks.jpg~ http://www.mayslacksbar.com~ Mayslacks, NE Minneapolis~ Mayslacks, NE Minneapolis",
//"tpr_MidWestCycleSupply.jpg~ sponsors.htm#MidwestCycleSupply~ Midwest Cycle Supply~ Midwest Cycle Supply",
//"tpr_MuddyWaters.jpg~ sponsors.htm#MuddyWaters~ MuddyWaters, Prescott, WI~ MuddyWaters, Prescott, WI",
//"tpr_NorthPoint.jpg~ sponsors.htm#NorthPoint~ NorthPoint Bar &amp; Grill, 501 6th Street North, Hudson, WI 54016~ NorthPoint Bar &amp; Grill, 501 6th Street North, Hudson, WI 54016",
//"tpr_NorthwaySports.jpg~ sponsors.htm#NorthwaySports~ NorthwaySports, East Bethel, MN~ NorthwaySports, East Bethel, MN",
//"tpr_OlePiper3.jpg~ sponsors.htm#OlePiper~ Ole Piper Restaurant &amp; Sports Bar~ Ole Piper Restaurant &amp; Sports Bar",
//"tpr_Outpost-3.jpg~ sponsors.htm#OutPost~ OutPost Bar &amp; Grill / 6141 Hwy 10 / Ramsey, MN 55303 / (763)427-3381~ http://www.JrsOutPost.com/",
//"tpr_PrecisionPainting.jpg~ sponsors.htm#PrecisionPainting~ Precision Painting and Restoration by Mike Rodeck, 1319 42nd Ave. NE, Columbia Heights, MN 55421, (763) 781-7238~ Precision Painting and Restoration by Mike Rodeck, 1319 42nd Ave. NE, Columbia Heights, MN 55421, (763) 781-7238",
//"tpr_PRsPlace.jpg~ sponsors.htm#PRsPlace~ PR's Place, River Falls, WI~ http://www.prsplace.com/",
//"tpr_TavernOnTheAvenue.jpg~ sponsors.htm#TavernOnTheAvenue~ Tavern On The Avenue~ Tavern On The Avenue",
//"tpr_TheBar.jpg~ sponsors.htm#TheBar~ The Bar in Hastings, MN~ The Bar in Hastings, MN",
//"tpr_theo@Bunkers.jpg~ sponsors.htm#Bunkers~ Theo of Bunkers Music Bar &amp; Grill~ Theo of Bunkers Music Bar &amp; Grill",
//"tpr_Warners.jpg~ sponsors.htm#WarnerOutdoor~ Warner Outdoor Equip., Inc.~ Warner Outdoor Equip., Inc.",


//2009 Future Sponsors to be added
//"tpr_KlineMotorsports.jpg~ sponsors.htm#KlineMotorsports~ KlineMotorsports~ www.kline-motorsports.com",
//"tpr_DeansTavern.jpg~ sponsors.htm#DeansTavern~ DeansTavern~ www.deanstavern.com",

//
// 2009 Newsletter only - put the images on the Topper_Ads.html page anyway
//"tpr_DicksPorting.jpg~ sponsors.htm#DicksPorting~ Dick's Porting~ Dick's Porting",
//"tpr_Drifters.jpg~ sponsors.htm#Drifters~ Drifters Bar &amp; Grill, Inver Grove Heights, MN~ Drifters Bar &amp; Grill, Inver Grove Heights, MN",
//"tpr_DrMudspringer.jpg~ sponsors.htm#DrMudspringer~ Dr. Mudspringers, 8465 Plaza Blvd. NE, Spring Lake Park, MN 55432~ Quality Motorcycle Accessories for your Metric Touring Motorcycle, Metric Cruiser & Harley Davidson Baggers",
//"tpr_EarthsTreasureChest.jpg~ sponsors.htm#EarthsTreasureChest~ Earths Treasure Chest - Finest Loose Gem Stones on Earth from Milo, milokendall@Yahoo.com~ Earths Treasure Chest - Finest Loose Gem Stones on Earth from Milo, milokendall@Yahoo.com",
//"tpr_BeachUpholstery.jpg~ sponsors.htm#Beach~ Beach Upholstery, Hudson, WI~ Beach Upholstery, Hudson, WI",

// 2008
//"tpr_roysrepair.jpg~ sponsors.htm#RoysRepair~ Roy's Repair - Minneapolis~ Roy's Repair - Minneapolis",
//"tpr_Junction40Yr-3.jpg~ sponsors.htm#TheJunction~ The Whiskey Junction - Whiskey on Stage~ http://www.whiskeyjunction.com",
//"tpr_HondaTown2.jpg~ http://hondatown.net~ Honda Town~ Honda Town",
//"tpr_KnightCap.jpg~ sponsors.htm#KnightCap~ Knight Cap Bar &amp; Lounge, 1500 4th St NE, Mpls, MN 55413, (612) 789-5233~ Knight Cap Bar &amp; Lounge, 1500 4th St NE, Mpls, MN 55413, (612) 789-5233",
//"tpr_LeosSouth2010b.jpg~ http://www.leossouth.com~ Leo's South, 16375 Kenrick Ave, Lakeville, MN 55044  952-435-5371~ Leo's South, Lakeville, MN",

cnt_ads = ary_ads1.length-1;	// We will display starting from 0
idx_ads=cnt_ads;
//alert("cnt_ads=" + cnt_ads);
//if (dbg>1) {
  //alert("ary_ads[0]=" + ary_ads[0]);
  //alert("ary_ads[1]=" + ary_ads[1]);
  //alert("ary_ads[2]=" + ary_ads[2]);
  //for (var i=0; i<ary_ads.length; i++) {
    //alert("ary_ads[" + i + "]:\n" + ary_ads[i]);
  // }
//}

if (dbg>1) {
 for (var i=1; i<ary_ads1.length; i++) {
	var ad_stuff = ary_ads1[i].split("~");
	ad_banner = trim(ad_stuff[0]);
	ad_url = trim(ad_stuff[1]);
	ad_alt = trim(ad_stuff[2]);
	ad_txt = trim(ad_stuff[3]);
	ad_idx = i;
 	//alert("ary_ads[" + i + "]\nad_banner=" + ad_banner + "\n" + "ad_url=" + ad_url + "\n" + "ad_alt=" + ad_alt + "\n" + "ad_txt=" + ad_txt);
 }
}

function RandomizeArrays() {
 var now = new Date();
 var sec = now.getSeconds();
 var i, j, k;
	for (i=1;i<cnt_pix;i++) {
		j = Math.floor((Math.random() * (cnt_pix)) + 1);
		//if (j==0) alert("j==0: ary_pix[]: ary_pix[" + j + "]=" + ary_pix[j] + "ary_pix[" + i + "]=" + ary_pix[i]);
		k = ary_pix[j];
		//if (k==0) alert("k==0: ary_pix[]: ary_pix[" + j + "]=" + ary_pix[j] + "ary_pix[" + i + "]=" + ary_pix[i]);
		ary_pix[j] = ary_pix[i];
		ary_pix[i]=k;
	}

	for (i=1;i<cnt_ads;i++) {
		j = Math.floor((Math.random() * (cnt_ads)) + 1);
		//if (j==0) alert("ary_ads[j]: j=0");
		k = ary_ads[j];
		//if (k==0) alert("ary_ads[j]: k=0: j=" + j);
		ary_ads[j] = ary_ads[i];
		ary_ads[i]=k;
	}
	if (dbg>2) {
		document.write("Dump ary_pix[" + cnt_pix + "]<br>");
		for (j=0; j<=cnt_pix+1 ; j++) { document.write(j + " &#0009; " + ary_pix[j] + "<br>");}
	
		document.write("Dump ary_ads[" + cnt_ads + "]<br>");
		for (j=0; j<=cnt_ads+1 ; j++) { document.write(j + " &#0009; " + ary_ads[j] + "<br>");}
	
		//for (j=0; j<=pixcnt+1 ; j++) { document.write(j + " &#0009; " + pixarray[j] + "<br>");}
		//for (j=0; j<=pixcnt ; j++) { document.write(pixarray[j] + "<br>");}
	}
}

function InitArrays() {
 var i, j, k, s="";
	for (i=0;i<=cnt_pix;i++) {	// Add zero tags at head and tail for debug only
		ary_pix[i]=i;
	}
	ary_pix[cnt_pix+1]=0; // for debug only

	for (i=0;i<=cnt_ads;i++) {	// Add zero tags at head and tail for debug only
		ary_ads[i]=i;
	}
	ary_ads[cnt_ads+1]=0; // for debug only

// Mix-em up - this is also done in choosepix() 
	for (i=1;i<cnt_pix;i++) {
		j = Math.floor((Math.random() * (cnt_pix)) + 1);
		k = ary_pix[j];
		ary_pix[j] = ary_pix[i];
		ary_pix[i]=k;
	}
    idx_pix=0;	// needs to be zero because of initial increment in choosepix()

	//document.write("Init ary_ads[" + cnt_ads + "]<br>");

// Mix-em up - this is also done in choosead()
	for (i=1;i<cnt_ads;i++) {
		j = Math.floor((Math.random() * (cnt_ads)) + 1);
		s = ary_ads[i];
		ary_ads[i] = ary_ads[j];
		ary_ads[j]=s;
	}
   idx_ads=0;	// needs to be zero because of initial increment in choosead()
   
	if (dbg>2) {
		document.write("Dump randomized ary_pix[" + cnt_pix + "]<br>");
		for (i=0; i<=cnt_pix+1 ; i++) { document.write(i + " &#0009; &nbsp;&nbsp;&nbsp; " + ary_pix[i] + "<br>");}
		document.write("Dump randomized ary_ads[" + cnt_ads + "]<br>");
		for (i=0; i<=cnt_ads+1 ; i++) { document.write(i + "&nbsp;-&nbsp; " + ary_ads[i] + "&nbsp;-&nbsp; " + ary_ads1[ary_ads[i]] + "<br>");}
	}
}

function initpix(){	// initialize Pix array
	// If Pix cookie: get cookie data and build array and set starting Pix
	// else: build array and set starting element as 1
	var timeToKeep = 1000*60*60*24*365; // 60000 one minute; 7200000 two hours; 31536000000 one year.
	var expires = new Date();
	//expires.setTime(expires.getTime() + timeToKeep); 
	expires.setTime(expires.getDate() + 365); 
	debug_on();
//dump_cookies();
	var cookie_idx_pix = get_cookie("wbmc_idx_pix");
//alert("cookie_idx_pix: \n" + cookie_idx_pix);
	var cookie_expires_pix = get_cookie("wbmc_expires_pix");
//alert("cookie_expires_pix: \n" + cookie_expires_pix);

	set_cookie("wbmc_idx_pix", 3, expires);
	cookie_idx_pix = get_cookie("wbmc_idx_pix");
//alert('get_cookie("wbmc_idx_pix"): \n' + get_cookie("wbmc_idx_pix"));

	set_cookie("wbmc_expires_pix", expires.toGMTString(), expires);
	cookie_expires_pix = get_cookie("wbmc_expires_pix");
//alert('get_cookie("wbmc_expires_pix"): \n' + get_cookie("wbmc_expires_pix"));
//dump_cookies();
}

InitArrays ();

function initads(){	// initialize Ads array
	// If Ads cookie: get cookie data and build array and set starting Pix
	// else: build array and set starting element as 1
	var cookie_idx_ads = get_cookie("wbmc_idx_ads");
}

function changepix(){	// reset timmer
	// hi & lo are globals
	//msec = Math.round(msec_lo_pix + (msec_hi_pix-msec_lo_pix)*Math.random());
	msec = msec_lo_pix + Math.round(Math.random() * (msec_hi_pix-msec_lo_pix))
	clearTimeout(timer_pix);
	choosepix();
	// should probably be using setInterval() if time is always the same
	timer_pix = setTimeout("changepix()", msec);
}

function changead(){	// reset timmer
	// hi & lo are globals
	//msec = Math.round(msec_lo_ad + (msec_hi_ad-msec_lo_ad) * Math.random())
	msec = msec_lo_ad + Math.round(Math.random() * (msec_hi_ad-msec_lo_ad))
	clearTimeout(timer_ad);
	choosead();
	//if (!typeof(thetimer) == "undefined") {clearTimeout(thetimer);}
	// should probably be using setInterval() instead
//	thetimer = setTimeout("changead()", msec);
	timer_ad = setTimeout("changead()", msec);
}

//<!---------- Choose members pictures to display ---------->
function choosepix() {  // relies on ary_pix[] and cnt_pix
 var x = 220; // 217 x 163 = 1.3333 (220x165=4x3 photo = 1.333...)
 var y = 165;	// 220x165 or 216x162 = even number.   or follow ad height to 219x165 
 var id1 = "pix2";
 var id2 = "PixID";
 var S = "";
 var str="";
 var fn="";
 var fil="";
 var url = '<a href=\"photos.htm\" target=\"doc_frame\">'
 var url = '<a href=\"javascript:popup0(\'Topper_Pics10.htm\',610,620,1,1,7,7,0,1,1)\">'
  idx_pix++;
  if (idx_pix>cnt_pix) {	// randomize array and restart from top
	for (i=1;i<cnt_pix;i++) {
		j = Math.floor((Math.random() * (cnt_pix)) + 1);
		k = ary_pix[j];
		ary_pix[j] = ary_pix[i];
		ary_pix[i]=k;
	}
    idx_pix=1;
    // if cookie_pix exists: save array and idx_pix to cookie
  }
  fil = ary_pix[idx_pix] + '.jpg';
//  s = '<img src=\"..\/toppics\/' + fil + '\" border=\"0\" width=\"' + x + '\" height=\"' + y + '\">';
//  s = '<img src=\"toppics/' + fil + '\" border=\"0\" width=\"' + x + '\" height=\"' + y + '\">';
  s = '<img src=\"toppics/' + fil + '\" alt=\"' + fil +  '\" style=\"border:0; width:' + x + 'px; height:' + y + 'px; overflow:hidden;\">';
  //alert(s);
  str = url + s + "<\/a>"
  try {document.getElementById(id2).innerHTML=ary_pix[idx_pix];} catch (e){}	// Drop the ID# under the menu buttons for debug
  try {document.getElementById(id1).innerHTML=str;} catch (e){}
	msec = msec_lo_pix + Math.round(Math.random() * (msec_hi_pix-msec_lo_pix))
	clearTimeout(timer_pix);
	// should probably be using setInterval() if time is always the same
	timer_pix = setTimeout("choosepix()", msec);
 }

//<!---------- Choose Sponsors Ad to display ---------->
function choosead() { // relies on ary_ads[] and cnt_ads
 var id1 = "ad2";	// drop ad image and link here
 var id2 = "AdID";	// drop AdID here
 var x = 289; // old 285x163 = 1.75:1 = (3.5x2 business card);  220x165=4x3 photo
 var y = 165; // new 289 x 165 = odd number
 var i, j, k;
 var width=x.toString(10);
 var height=y.toString(10);
 var s="";
 var str="";
 var img="";
 var banner="";
 // if cookie_ads exists:
 	// Get idx_ from cookie
 idx_ads++;
 if (idx_ads>cnt_ads) {	// randomize array and restart from top
	for (i=1;i<cnt_ads;i++) {
		j = Math.floor((Math.random() * (cnt_ads)) + 1);
		s = ary_ads[i];
		ary_ads[i] = ary_ads[j];
		ary_ads[j]=s;
	}
   idx_ads=1;
   // if cookie_ads exists: save array and idx_ to cookie
 }
 ad = ary_ads[idx_ads];
 if(parent.location.search) { // get URI of parent. www.WestBankMC.org/index.htm?22
  str = parent.location.search;
  str = str.substring(1,str.length);
  str = str.substr(0,3);
  a = parseInt(str);
  if (!isNaN(a)) {
   if ((a > -1) & (a <= cnt_ads)) ad = a;
  }
 }

 ad_stuff = ary_ads1[ad].split("~");
 ad_banner = trim(ad_stuff[0]);
 ad_url = trim(ad_stuff[1]);
 ad_alt = trim(ad_stuff[2]);
 ad_txt = trim(ad_stuff[3]);
//alert("ary_ads[" + ad + "]\n" + "ad_banner=" + ad_banner + "\n" + "ad_url=" + ad_url + "\n" + "ad_alt=" + ad_alt + "\n" + "ad_txt=" + ad_txt);
 ad_banner = ad_path + ad_banner;
 url = ad_url;
 alt = ad_url;
 txt = ad_txt;
 img='<img src=\"'+ ad_banner + '\" alt=\"' + alt + '\" border=0 width=\"'+width+'\" height=\"'+height+'\">';
// str='<a href=\"' + ad_url + '\" ' + 'target=' + ad_target + '><img src=\"'+ ad_banner + '\" alt=\"' + ad_alt + '\" style=\"width:' + x + 'px; height:' + y + 'px; overflow:hidden; border:0;\">';
 str='<a href=\"' + ad_url + '\" ' + ad_onclick + ' ' + ad_title + ' ' + 'target=' + ad_target + '><img src=\"'+ ad_banner + '\" alt=\"' + ad_alt + '\" style=\"width:' + x + 'px; height:' + y + 'px; overflow:hidden; border:0;\">';
 try {document.getElementById(id2).innerHTML=ad;} catch (e){}	// Drop the ID# under the menu buttons for debug
 if (!url=="") {
 	try {document.getElementById(id1).innerHTML=str;} catch (e){}
 }
	msec = msec_lo_ad + Math.round(Math.random() * (msec_hi_ad-msec_lo_ad))
	clearTimeout(timer_ad);
	timer_ad = setTimeout("choosead()", msec);
}

function trims(str,br,sz,nbr){
var rtnStr="";
var subStr="";
var cbr=0;
if(str.length>sz){
var wdAr=str.split(" ");
for(var i=0;((i<wdAr.length)&&((cbr<nbr)||(nbr==-1)));i++) {
if((subStr.length+wdAr[i].length+1)<=sz) {
subStr=subStr+wdAr[i]+" ";
} 
else {
rtnStr=rtnStr+subStr+br;subStr=wdAr[i]+" ";cbr=cbr+1;
}
} 
if(nbr==-1) {
rtnStr=rtnStr+subStr;}
} 
else {
rtnStr=str;
} 
return rtnStr;
} 

function trim ( s )
{	//s = new String( s );
	s = s.replace( /^ +/g, "" );
	s = s.replace( / +$/g, "" );
	return s;		
}

/*
trimX: function ( s )
{	s = new String( s );
	s = s.replace( /^ +/g, "" );
	s = s.replace( / +$/g, "" );
	return s;		
}
*/

/* Complete Javascript popup opener   http://www.emanueleferonato.com/2007/09/21/complete-javascript-popup-opener/ */
// Call: 
var propopup = function(o) {
	o.url = (typeof o.url == 'undefined') ? 'http://www.westbankmc.org/': o.url;
	o.width = (typeof o.width == 'undefined') ? screen.width/2 : o.width;
	o.height = (typeof o.height == 'undefined') ? screen.height/2 : o.height;
	if((o.width<=1)&&(o.width>0)){o.width*=screen.width}
	if((o.height<=1)&&(o.height>0)){o.height*=screen.height}
	o.xpos = (typeof o.xpos == 'undefined') ? (screen.width/2)-(o.width/2) : o.xpos;
	o.ypos = (typeof o.ypos == 'undefined') ? (screen.height/2)-(o.height/2) : o.ypos;
	o.xoffset = (typeof o.xoffset == 'undefined') ? 0 : o.xoffset;
	o.yoffset = (typeof o.yoffset == 'undefined') ? 0 : o.yoffset;
	o.name = (typeof o.name == 'undefined') ? 'propup' : o.name;
	o.scrollbars = (typeof o.scrollbars == 'undefined') ? 'yes' : o.scrollbars;
	o.resizable = (typeof o.resizable == 'undefined') ? 'yes' : o.resizable;
	o.status = (typeof o.status == 'undefined') ? 'no' : o.status;
	o.locat = (typeof o.locat == 'undefined') ? 'no' : o.locat;
	o.toolbar = (typeof o.toolbar == 'undefined') ? 'no' : o.toolbar;
 
	if(o.xpos == "left"){o.xpos=0;}
	if(o.xpos == "right"){o.xpos = screen.width-o.width;}
 
	if(o.ypos == "top"){o.ypos=0;}
	if(o.ypos == "bottom"){o.ypos = screen.height-o.height;}
 
	o.xpos += o.xoffset
	o.ypos += o.yoffset
 
	var scrollbarstext = 'scrollbars = '+o.scrollbars+",";
	var resizabletext = 'resizable = '+o.resizable+",";
	var statustext = 'status = '+o.status+",";
	var locationtext = 'location = '+o.locat+",";
	var toolbartext = 'toolbar = '+o.toolbar+",";
 
	features = scrollbarstext+resizabletext+statustext;
	features = features + locationtext+toolbartext;
	features = features + 'width = '+o.width+',height = '+o.height;
	features = features + ',top = ' + o.ypos;
	features = features + ',left = ' + o.xpos;
 
	var win = null;
	win = window.open(o.url, o.name, features);
}

var winCount0 = 0;
var winName0 = "popWin0";
function popup0(winURL, winWidth, winHeight, winScroll, winResize, winLeft, winTop, winMenu, winTool, winStat, winLoc, winDir) {
  winName = winName0;
  if (typeof(winWidth)	== "undefined") { var winWidth = 640; }
  if (typeof(winHeight)	== "undefined") { var winHeight = 480; }
  if (typeof(winScroll)	== "undefined") { var winScroll = 1; }
  if (typeof(winResize)	== "undefined") { var winResize = 1; }
  if (typeof(winLeft)	== "undefined") { var winLeft = 10; }
  if (typeof(winTop)	== "undefined") { var winTop = 10; }
  if (typeof(winDir)	== "undefined") { var winDir = 0; }
  if (typeof(winMenu)	== "undefined") { var winMenu = 0; }
  if (typeof(winTool)	== "undefined") { var winTool = 0; }
  if (typeof(winStat)	== "undefined") { var winStat = 0; }
  if (typeof(winLoc)	== "undefined") { var winLoc = 0; }
  if (typeof(winDir)	== "undefined") { var winDir = 0; }
  //alert(winName + " " + winURL + " " + winWidth + " " + winHeight + " " + winScroll + " " + winResize);
  window.open(winURL, winName, "width=" + winWidth
           + ",height=" + winHeight + ",resizable=" + winResize + ", scrollbars=" + winScroll + ", left=" + winLeft + ", top=" + winTop + ",menubar=" + winMenu + ",toolbar=" + winTool + ",status=" + winStat + ",location=" + winLoc + ",directories=" + winDir);
}

var winCount1 = 0;
var winName1 = "popWin1";
function popup1(winURL, winWidth, winHeight, winScroll, winResize, winLeft, winTop) {
  winName = "popWin1" + winCount1++;
  if (typeof(winWidth)	== "undefined") { var winWidth = 660; }
  if (typeof(winHeight)	== "undefined") { var winHeight = 500; }
  if (typeof(winScroll)	== "undefined") { var winScroll = 1; }
  if (typeof(winResize)	== "undefined") { var winResize = 1; }
  if (typeof(winLeft)	== "undefined") { var winLeft = 7; }
  if (typeof(winTop)	== "undefined") { var winTop = 7; }
  //alert(winName + " " + winURL + " " + winWidth + " " + winHeight + " " + winScroll + " " + winResize);
  window.open(winURL, winName, "width=" + winWidth
           + ",height=" + winHeight + ",resizable=" + winResize + ", scrollbars=" + winScroll + ", left=" + winLeft + ", top=" + winTop + ",menubar=1,toolbar=0,status=0,location=0,directories=0");
	return false;
}

var winCount2 = 0;
var winName2 = "popWin2";  // This window will have a menu showing 
function popup2(winURL, winWidth, winHeight, winScroll, winResize, winLeft, winTop) {
	winName = winName2 + winCount2++;
	//alert(winName + " " + winURL + " " + winWidth + " " + winHeight + " " + winScroll + " " + winResize);
	window.open(winURL, winName, "width=" + winWidth
           + ",height=" + winHeight + ",resizable=" + winResize + ", scrollbars=" + winScroll + ", left=" + winLeft + ", top=" + winTop + ",menubar=1,toolbar=0,status=0,location=0,directories=0");
}
		
var winCount3 = 0;
var winName3 = "popWin3";  // Resize to full screen minus a little 
function popup3(winURL, winWidth, winHeight, winScroll, winResize, winLeft, winTop) {
	winName = winName3 + winCount3++;
	//alert(winName + " " + winURL + " " + winWidth + " " + winHeight + " " + winScroll + " " + winResize);
	window.open(winURL, winName, "width=" + winWidth
           + ",height=" + winHeight + ",resizable=" + winResize + ", scrollbars=" + winScroll + ", left=" + winLeft + ", top=" + winTop + ",menubar=1,toolbar=0,status=0,location=0,directories=0");
	//window.moveTo(7, 7);
	//var iWidth = document.images[0].width - window.innerWidth;
	//var iHeight = document.images[0].height - window.innerHeight;
	var iWidth = 600 - window.innerWidth;
	var iHeight = 600 - window.innerHeight;
	//alert("window.innerWidth =  " + window.innerWidth + ";  window.innerHeight = " + window.innerHeight + ";  \n " + "iWidth =  " + iWidth + ";  iHeight = " + iHeight + " ");
	//window.resizeBy(iWidth, iHeight);
	//window.resizeTo(window.innerWidth, window.innerHeight);
	//alert("window.screen.availWidth =  " + window.screen.availWidth + ";  window.screen.availHeight = " + window.screen.availHeight + ";  " + " ");
	window.resizeTo(window.screen.availWidth/1.25, window.screen.availHeight/1.25);
	//self.focus(); 
}
		
	 // function resizes the window to take up one quarter of the available screen.
function quarter() {
   window.resizeTo(window.screen.availWidth/2, window.screen.availHeight/2);
 }

var winCount = 0;
var winName = "popWin";
function popup(winURL, winWidth, winHeight, winScroll, winResize) {
  winName = "popWin" + winCount++;
  //alert(winName + " " + winURL + " " + winWidth + " " + winHeight + " " + winScroll + " " + winResize);
  window.open(winURL, winName, "width=" + winWidth
           + ",height=" + winHeight + ",resizable=" + winResize + ", scrollbars=" + winScroll + ", left=7, top=7");
}

/* <!----------------- Open New Window ----------------------> */
function newWindow(url, width, height) {
 nameW='newWin';
 if (navigator.appVersion.indexOf('4') != -1) {
    // Vars for centering the new window on Version 4 Browsers
    xTop = 5;
    yTop = 5;
    window.open(url, nameW, 'height='+height+',width='+width+',scrollbars=0,resizable=0,menubar=0,toolbar=0,status=0,location=0,directories=0,left=' + xTop + ',top=' + yTop + '');
    } else {
    window.open(url, nameW, 'height='+height+',width='+width+',scrollbars=0,resizable=0,menubar=0,toolbar=0,status=0,location=0,directories=0,left=2,top=20');
  }
}

//function refresh2() { choosepix(); choosead(); }
function refresh2() { choosepix(); changead(); }

function loadpage2(pg) { parent.if_home.location.href=pg; refresh2(); }

/* start- Picture Viewer1 */
var hwndPopup1;
function PictureViewer(url){
 var popupWidth = 800;
 var popupHeight = 680;
 var popupTop = 30;	// 300
 var popupLeft = 30;	// 300
 var isFullScreen = false;
 var isAutoCenter = true;
 var popupTarget = "popupwin_309f";
 var popupParams = "toolbar=0, scrollbars=1, menubar=0, status=0, resizable=1";

  if (isFullScreen) {
    popupParams += ", fullscreen=1";
  } else if (isAutoCenter) {
    popupTop  = parseInt((window.screen.height - popupHeight)/2);
    popupLeft = parseInt((window.screen.width - popupWidth)/2);
  }

var ua = window.navigator.userAgent;
var isMac = (ua.indexOf("Mac") > -1);

//IE 5.1 PR on OSX 10.0.x does not support relative URLs in pop-ups the way they're handled below w/ document.writeln
  if (isMac && url.indexOf("http") != 0) {
    url = location.href.substring(0,location.href.lastIndexOf('\/')) + "/" + url;
  }

var isOpera = (ua.indexOf("Opera") > -1);
var operaVersion;
  if (isOpera) {
    var i = ua.indexOf("Opera");
    operaVersion = parseFloat(ua.substring(i + 6, ua.indexOf(" ", i + 8)));
    if (operaVersion > 7.00) {
      var isAccessible = false;
      eval("try { isAccessible = ( (hwndPopup1 != null) && !hwndPopup1.closed ); } catch(exc) { } ");
      if (!isAccessible) {
        hwndPopup1 = null;
      }
    }
  }
  if ( (hwndPopup1 == null) || hwndPopup1.closed ) {
    if (isOpera && (operaVersion < 7)) {
      if (url.indexOf("http") != 0) {
        hwndPopup1 = window.open(url,popupTarget,popupParams + ((!isFullScreen) ? ", width=" + popupWidth +", height=" + popupHeight : ""));
        if (!isFullScreen) {
          hwndPopup1.moveTo(popupLeft, popupTop);
        }
        hwndPopup1.focus();
        return;
      }
    }
    if (!(window.navigator.appName == "Netscape" && !document.getElementById)) {
      //not ns4
      popupParams += ", width=" + popupWidth +", height=" + popupHeight + ", left=" + popupLeft + ", top=" + popupTop;
    } else {
      popupParams += ", left=" + popupLeft + ", top=" + popupTop;
    }
    //alert(popupParams);
    hwndPopup1 = window.open("",popupTarget,popupParams);
    if (!isFullScreen) {
      hwndPopup1.resizeTo(popupWidth, popupHeight);
      hwndPopup1.moveTo(popupLeft, popupTop);
    }
    hwndPopup1.focus();
    with (hwndPopup1.document) {
      open();
      write("<ht"+"ml><he"+"ad></he"+"ad><bo"+"dy onLoad=\"window.location.href='" + url + "'\"></bo"+"dy></ht"+"ml>");
      close();
    }
  } else {
    if (isOpera && (operaVersion > 7.00)) {
      eval("try { hwndPopup1.focus();  hwndPopup1.location.href = url; } catch(exc) { hwndPopup1 = window.open(\""+ url +"\",\"" + popupTarget +"\",\""+ popupParams + ", width=" + popupWidth +", height=" + popupHeight +"\"); } ");
    } else {
      hwndPopup1.focus();
      hwndPopup1.location.href = url;
    }
  }
}
/* end- Picture Viewer1 */

var months = new Array("", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
var days = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
function GetDayDate(id) {
 var time=new Date();
 var year=time.getYear();
 var lmonth=months[time.getMonth() + 1];
 var date=time.getDate();
 var day = time.getDay();
  if (year < 2000)    // Y2K Fix http://onyx.idbsu.edu/~ipowell
	year = year + 1900;
	// document.write(days[day] + " " + lmonth + " ");
	// document.write(date + ", " + year +"  ");
	//alert(days[day] + " " + lmonth + " " + date + ", " + year +"  ");
//   document.all(id).innerHTML=days[day] + " " + lmonth + " " + date + ", " + year +"  "; // This works in both IE & FF as of 2007.12.11 ~hn
   document.getElementById(id).innerHTML=days[day] + " " + lmonth + " " + date + ", " + year +"  "; // This works in both IE & FF as of 2007.12.11 ~hn
  //return(days[day] + " " + lmonth + " " + date + ", " + year + "  ");
}

// Multiple Countdown timers
function countdown(obj) { // Author: Robert Hashemian (http://www.hashemian.com/); Modified by: Munsifali Rashid (http://www.munit.co.uk/)
 this.obj  = obj;
 this.Div  = "RideClock1";
 this.BackColor  = "white";
 this.ForeColor  = "black";
 this.TargetDate  = "12/31/2008 12:00 PM";
 this.DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
 this.CountActive = true;
 this.DisplayStr;
 this.Calcage  = cd_Calcage;
 this.CountBack  = cd_CountBack;
 this.Setup  = cd_Setup;
 }
function cd_Calcage(secs, num1, num2) {
  s = ((Math.floor(secs/num1))%num2).toString();
  if (s.length < 2) s = "0" + s;
  return (s);
 }
function cd_CountBack(secs) {
  this.DisplayStr = this.DisplayFormat.replace(/%%D%%/g, this.Calcage(secs,86400,100000));
  this.DisplayStr = this.DisplayStr.replace(/%%H%%/g,  this.Calcage(secs,3600,24));
  this.DisplayStr = this.DisplayStr.replace(/%%M%%/g,  this.Calcage(secs,60,60));
  this.DisplayStr = this.DisplayStr.replace(/%%S%%/g,  this.Calcage(secs,1,60));
  document.getElementById(this.Div).innerHTML = this.DisplayStr;
  if (this.CountActive) setTimeout(this.obj +".CountBack(" + (secs-1) + ")", 990);
 }
function cd_Setup() {
 var dthen = new Date(this.TargetDate);
  var dnow = new Date();
 ddiff  = new Date(dthen-dnow);
 gsecs  = Math.floor(ddiff.valueOf()/1000);
 this.CountBack(gsecs);
 }

function getElementById_s(id) {	// workaround for IE
	var obj = null;
	if(document.getElementById) { /* Prefer the widely supported W3C DOM method, if available:- */
		obj = document.getElementById(id);
	} else if(document.all) { /* Branch to use document.all on document.all only browsers. Requires that IDs are unique to the page and do not coincide with NAME attributes on other elements:- */
		obj = document.all[id];
	} /* If no appropriate element retrieval mechanism exists on this browser this function always returns null:- */
	return obj;
}

// In html page:  addLoadEvent(function() { document.body.style.backgroundColor = 'yellow'; } )
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}

function addLoadEvent1(func) {  // updated 
  var oldonload = window.onload; 
  if (typeof window.onload != 'function') { 
    window.onload = func; 
  } else { 
    window.onload = function() { 
      oldonload(); 
      func(); 
    } 
  } 
}
 
function ImagePopup( title, target, imagesrc, look )
{
	popwin = window.open("",target,look);
	popwin.document.open();
	popwin.document.write('<html><head><title>'+title+'</title></head><body style="margin:0;padding:0;"><a href="" onclick="javascript:window.close()"><img src="'+imagesrc+'" border="0"><a/></body></html>');
	popwin.document.close();
	popwin.focus();
}

var ycsdone;
function geovisit()
{
  var z;
  if (ycsdone)
    return;
  z="&r="+escape(document.referrer);
  z=z+"&b="+escape(navigator.appName+" "+navigator.appVersion);
  w=parseFloat(navigator.appVersion);
  if (w > 2.0) {
    z=z+"&s="+screen.width+"x"+screen.height;
    z=z+"&o="+navigator.platform;
    v="1.2";
    if (navigator.appName != "Netscape") {
      z=z+"&c="+screen.colorDepth;
    } else {
      z=z+"&c="+screen.pixelDepth
    }
    z=z+"&j="+navigator.javaEnabled();
  } else {
    v=1.0;
  }
  z=z+"&v="+v;
  document.writeln("<img border=\"0\" style=\"display:none\" src=\"http://visit.westbankmc.org/visit.gif?"+z+"\">");
  ycsdone=1;
}

var STR_PAD_LEFT = 1;
var STR_PAD_RIGHT = 2;
var STR_PAD_BOTH = 3;
 
function pad(str, len, pad, dir) {
 
	if (typeof(len) == "undefined") { var len = 0; }
	if (typeof(pad) == "undefined") { var pad = ' '; }
	if (typeof(dir) == "undefined") { var dir = STR_PAD_RIGHT; }
 
	if (len + 1 >= str.length) {
 
		switch (dir){
 
			case STR_PAD_LEFT:
				str = Array(len + 1 - str.length).join(pad) + str;
			break;
 
			case STR_PAD_BOTH:
				var right = Math.ceil((padlen = len - str.length) / 2);
				var left = padlen - right;
				str = Array(left+1).join(pad) + str + Array(right+1).join(pad);
			break;
 
			default:
				str = str + Array(len + 1 - str.length).join(pad);
			break;
 
		} // switch
 
	}
 
	return str;
 
}

function SetFont(n)
{
var objarr = document.getElementsByTagName("td");
for (var i =0;i < objarr.length ;i++ )	{	objarr[i].style.fontSize = n; }
var objarr = document.getElementsByTagName("p");
for (var i =0;i < objarr.length ;i++ )	{	objarr[i].style.fontSize = n; }
var objarr = document.getElementsByTagName("font");
for (var i =0;i < objarr.length ;i++ )	{	objarr[i].style.fontSize = n; }
}
 
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function resizeIframe(iframeID) {
if(self==parent) return false; /* Checks that page is in iframe. */
else if(document.getElementById&&document.all) /* Sniffs for IE5+.*/
var FramePageHeight = framePage.scrollHeight + 10; 
/* framePage is the ID of the framed page's BODY tag. The added 10 pixels prevent an unnecessary scrollbar. */
parent.document.getElementById(iframeID).style.height=FramePageHeight;
/* "iframeID" is the ID of the inline frame in the parent page. 
   "<body id="framePage" onload="resizeIframe('idTopFrame')">" 
*/
}

//<!---------- Load a new Weather Icon every minute to get current time ---------->
function updateweatherbanner() {  // relies on ...
 var id = "weatherbanner";
 var msec = 1000*30;
 var URL = '<a target=\"_blank\" href=\"http://www.wunderground.com/US/MN/Minneapolis.html?bannertypeclick=gizmotimetemp\"><img src=\"http://banners.wunderground.com/weathersticker/gizmotimetemp_both/language/www/US/MN/Minneapolis.gif\" border=0 alt=\"Click for Minneapolis, Minnesota Forecast\"></a>'
 var width1="165%";
 var height1="110%";
 var width2="165%";
 var height2="110%";
 var DayNow="";
  if (weatherbannertype=="sunandmoon150_both" || weatherbannertype=="") {  // clean this up ~hn 2008.11.14
  	weatherbannertype="gizmotimetemp_both24";
  	// display only left half of image  img style=\"overflow:hidden; float:left; height:110%; width:165%; border:0\"
	URL = '<a target=\"_blank\" href=\"http:\/\/www.wunderground.com\/US\/MN\/Minneapolis.html?bannertypeclick=gizmotimetemp24\"><img style=\"overflow:hidden; float:left; height:65px; width:212px; border:0\" src=\"http://banners.wunderground.com/weathersticker/' + weatherbannertype + '/language/www/US/MN/Minneapolis.gif\" alt=\"Click for Minneapolis, Minnesota Forecast\"></a>'
  }
  else {
  	weatherbannertype="sunandmoon150_both";
  	// display only the right half of the image   img style=\"overflow:hidden; float:right; height:120%; width:160%; border:0\"
  	URL = '<a target=\"_blank\" href=\"http:\/\/www.wunderground.com\/US\/MN\/Minneapolis.html?bannertypeclick=sunandmoon150\"><img style=\"height:65px; width:212px; overflow:hidden; margin-left:-78px; float:left; border:0;\" src=\"http://banners.wunderground.com/weathersticker/' + weatherbannertype + '/language/www/US/MN/Minneapolis.gif\" alt=\"Click for Minneapolis, Minnesota Forecast\"></a>'
  	//URL="http:\/\/banners.wunderground.com\/weathersticker\/sunandmoon\/language\/www\/US\/MN\/Minneapolis.gif"
  	//URL='<a target=\"_blank\" href=\"http:\/\/www.wunderground.com\/US\/MN\/Minneapolis.html?bannertypeclick=sunandmoon150\"><img style=\"height:127px; width:212px; overflow:hidden; margin-left:-78px; float:left; border:0;\" src=\"' + URL + '\" alt=\"Click for Mpls, MN Forecast\"></a>'
  }
  clearTimeout(timer_weather);
  //alert("updateweatherbanner: " + URL);
  //document.getElementById(id).innerHTML = URL;
  try {document.getElementById(id).innerHTML = URL;} catch (e){}
  timer_weather = setTimeout("updateweatherbanner()", msec);
  try {GetDayDate("DayDate");} catch (e){}
}

function updateweather(){	// start timer for 2 minute update
	msec = 1000*30;
	clearTimeout(timer_weather);
	//chooseweather();
	timer_weather = setTimeout("updateweatherbanner()", msec);
}

function button_on ( imgId )	// rollover image on
{
  if ( document.images )
  {
    butOn = eval ( imgId + "_on.src" );
    document.getElementById(imgId).src = butOn;
  }
}

function button_off ( imgId )	// rollover image off
{
  if ( document.images )
  {
    butOff = eval ( imgId + "_off.src" );
    document.getElementById(imgId).src = butOff;
  }
}

function updateClock ( )
{
  var currentTime = new Date ( );

  var currentHours = currentTime.getHours ( );
  var currentMinutes = currentTime.getMinutes ( );
  var currentSeconds = currentTime.getSeconds ( );

  // Pad the minutes and seconds with leading zeros, if required
  currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
  currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

  // Choose either "AM" or "PM" as appropriate
  var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

  // Convert the hours component to 12-hour format if needed
  currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

  // Convert an hours component of "0" to "12"
  currentHours = ( currentHours == 0 ) ? 12 : currentHours;

  // Compose the string for display
  var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;

  // Update the time display
  document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}

function DLM ( )
{ // Document Last Modified
DLM=new Date(document.lastModified);
DLM_Y=DLM.getYear();
DLM_M=DLM.getMonth(); // Jan-Dec = 0-11
DLM_D=DLM.getDate();
if (DLM_Y < 70) { DLM_Y=DLM_Y*1+2000; }
if (DLM_Y < 1000) { DLM_Y=DLM_Y*1+1900; }
DLM_M=DLM_M*1+1; // Jan-Dec = 1-12
if (DLM_M*1 < 10) { DLM_M='0'+DLM_M; } // leading zero
if (DLM_D*1 < 10) { DLM_D='0'+DLM_D; }
Out=DLM_M+'/'+DLM_D+'/'+DLM_Y;
document.write(Out);
}


