//D. Porter, Winchester, MA for BenBenjamin.com/.net website 9/2010
//	Editing directions are at the end of this file.

//************global variables set below ****************

var navArray = new Array();	//[][0] & [][1] elements are top nav name and links, others are leftnav
var ix = -1; //ix++;	//start at [0] is home, 1+ is site.

//old index array, MH 3-18-2011
// navArray [++ix] = new Array("Home","index.html","Webinars","webinars.php","Are You in Pain?","pain.html","About Ben","ben.html","Private Practice","therapy.html","Workshops","sched.html","Publications","pubs.html","Products","store/index.php","Contact Us","contact.php");

navArray [++ix] = new Array("Home","index.html","Webinars","http://www.benbenjamin.com/webinars.php","Ben's Blog","http://blog.benbenjamin.com","About Ben","ben.html","Private Practice","therapy.html","Workshops","http://www.benbenjamin.com/workshops.html","Publications","http://www.benbenjamin.com/pubs.html","Products","http://www.benbenjamin.com/store/index.php","Contact Us","contact.php");
//   store/index.php for actual store, store/index.html for test site store code
//   webinars.php for actual store, webinars.html for test site store code

navArray [++ix] = new Array("Are You in Pain?","pain.html","The Secret of Chronic Pain","pain.html","Accurate Assessment","assess.html","Effective<br>Treatment","treat.html","Client Stories","clients.html","Contact Us","contact.php");

navArray [++ix] = new Array("Ben's Blog","http://blog.benbenjamin.com");

navArray [++ix] = new Array("About Ben","ben.html","Biography","ben.html","AMTA 2000 Pres. Award","pres.html","Other Awards","awards.html","Contact Us","contact.php");

//navArray [++ix] = new Array("Private Practice","therapy.html","Muscular Therapy","therapy.html","Active Isolated Stretching","ais.html","Evaluation<br>Sessions","esess.html","Treatment<br>Sessions","tsess.html","Trauma Survivors","trauma.html","What To Expect","expect.html","Appointment Policies/Fees","policy.html","By Phone/ Videophone","phone.html","Nationwide<br>Network","network.html","Directions to the Office","directions.html");

navArray [++ix] = new Array("Private Practice","therapy.html","Muscular Therapy","therapy.html","Are You in Pain?","pain.html","Active Isolated Stretching","ais.html","Evaluation<br>Sessions","esess.html","Treatment<br>Sessions","tsess.html","What To Expect","expect.html","Appointment Policies/Fees","policy.html","Nationwide<br>Network","network.html","Directions to the Office","directions.html","Contact Us","contact.php");

//navArray [++ix] = new Array("Client Stories","clients.html","Excerpts from Letters","clients.html");

navArray [++ix] = new Array("Webinars","http://www.benbenjamin.com/webinars.php","Webinars","webinars.php","Affiliate<br>Program","user.php","Contact Us","contact.php");

navArray [++ix] = new Array("Workshops","http://www.benbenjamin.com/workshops.html","Teaching<br>Schedule","sched.html","Descriptions","workshops.html","Contact Us","contact.php");

//this is the old Publications array - MH 3/18/2011
//navArray [++ix] = new Array("Publications","pubs.html","Books","pubs.html","Articles","articles.html","Contact Us","contact.php");
navArray [++ix] = new Array("Publications","http://www.benbenjamin.com/pubs.html","Books","pubs.html","Contact Us","contact.php");

navArray [++ix] = new Array("Products","http://www.benbenjamin.com/store/index.php","Products","store/index.php","Contact Us","contact.php");


var numtopnav = 99;	//edit to set max number of topnav links. 99=all

//************end of editable global variables ****************

var lastslashG = document.URL.lastIndexOf("/");

var navupone = ""; if(document.URL.substring(lastslashG-3, lastslashG+1) != "com/" && document.URL.substring(lastslashG-3, lastslashG+1) != "net/"){navupone = "../";} ;
if(document.URL.substring(lastslashG-5, lastslashG+1) == "store/"){navupone = "../../../";}

//************end of global variables ****************

function maketopnav(arg){		//optional arg is URL to force top nav active if set
   if(arg == undefined ){arg = "";}	

   var lastslash = document.URL.lastIndexOf("com/");
   if(lastslash == -1){lastslash = document.URL.lastIndexOf("net/");}
   var endurl = document.URL.substring(lastslash+4, document.URL.length);
		//note: IE on desktop lists as .com\ and .net\. Live as .com/ and .net/

   var ndex=99;
   var topnavend = Math.min(numtopnav+1,navArray.length);

   if(arg != ""){endurl = arg;}
	for (var i=1; i<topnavend; i++){	//find page url in navArray to set active
	   for (var j=1; j<navArray[i].length; j=j+2){
		if( endurl == navArray[i][j]){ndex=i;}	
	   }
     }

   for (var i = 2; i<topnavend; i++) {	//output top nav  -- MH - I set this to 2 becuase they no longer wanted Are you In pain? to be a Top level link, but it still needs its left nav menu
	var setclass="topnavtext";if(ndex == i){setclass="topnavtexton";}	

	if(i > 2){document.write('<span class="topnavdot">&nbsp;</span>');}
	
	//correct for blog
	if (navArray[i][1].search(/blog/i) != -1) navuponeC = "";
	else navuponeC = navupone;
	
	
	document.write('<a href="'+navuponeC+navArray[i][1]+'" class="'+setclass+'" ALT="'+navArray[i][0]+'">'+navArray[i][0]+'</a>');
   }

}

function makeleftnav(arg){		//optional arg is URL to force navArray[arg] leftnav list if set
   if(arg == undefined ){arg = "";}	

   var lastslash = document.URL.lastIndexOf("com/");
   if(lastslash == -1){lastslash = document.URL.lastIndexOf("net/");}
   var endurl = document.URL.substring(lastslash+4, document.URL.length);
		//note: IE on desktop lists as .com\ and .net\. Live as .com/ and .net/

   var ndex=99;
   if(arg != ""){endurl = arg;}
	for (var i=1; i<navArray.length; i++){	//find page url in navArray to set active
	   for (var j=1; j<navArray[i].length; j=j+2){
		if( endurl == navArray[i][j]){ndex=i;}
	   }
     }

   if(ndex >= navArray.length){ndex=1;}

   var lftnavid = "sddm";
   if(endurl == "index.html"){ndex = 0; lftnavid="sddmh"; if(navigator.appName.match("Microsoft")){lftnavid="sddmhIE";}}

   document.write('<ul id="'+lftnavid+'">');
	for (var i = 2; i< navArray[ndex].length; i=i+2){	//output left nav
	   var setclass="class=navoff";if( endurl == navArray[ndex][i+1] && arg == ""){setclass="class=navon";}	

	//added div and class because IE miscalculates box size and shifts. Can't pad in box.
		var ieboxbug = "class=shiftit"; if(navigator.appName.match("Microsoft")){ieboxbug = "class=shiftitIE";}
		


	   document.write('<li><div '+setclass+'><a href="'+navupone+navArray[ndex][i+1]+'"><div '+ieboxbug+'>'+navArray[ndex][i]+'</div></a></div></li>');

	}
   document.write('</ul>');

}

function footer(){
var today = new Date(); 
var year = today.getYear(); //years since 1900
var temp = navigator.appName;
var delta = 1900; if (temp.match("Microsoft")){delta = 0;}
var thisyear = year + delta;

document.write('<tr>');
document.write('<td >&nbsp;</td>');

document.write('<TD align="right"><FONT SIZE="-1" COLOR="#CC99CC" FACE="verdana, arial">');

document.write('<div style="float:left;margin-left:20px;margin-top:15px;">');

document.write('<a href="javascript:popUp(\'joinList.html\');" style="color:#cc99cc">Join Our Mailing List</a>');

document.write('</div>');

document.write('<div style="float:right;margin-left:20px;margin-top:15px;">');

document.write('&copy; copyright Ben Benjamin '+thisyear+'&nbsp;</FONT></td>');
document.write('<td >&nbsp;</td>');
document.write('</tr>');

document.write('</div>');
}


function zipfinder(URL){var newwindow =
window.open(URL,"zipfinder","scrollbars=yes,toolbar=no,directories=no,menubar=no,resizable=no,status=no,width=300,height=250");
     newwindow.focus();}

//<!-- Idea by:  Nic Wolfe -->
//<!-- This script and many more are available free online at -->
//<!-- The JavaScript Source!! http://javascript.internet.com -->

//<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=650');");
}
// End -->

//************no longer used. Preload in BODY tag ****************

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) { //v3.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); 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];}
}


/*
TO ADD A PAGE
*copy and rename an existing page (I used pain.html) and change the body text to be what you desire.
*rename the page and save
*you will need to add the page to the navigation so continue below.

TO CHANGE THE NAVIGATION
*decide if the page will be a main top navigation page or a subpage to an existing top navigation page
*locate and open the file css_js/bben.js using notepad or some other web-friendly editor. Save a backup copy first but work in the original.

If the page will be a top navigation page:
*ignore the top-most  “navArray [++ix] =…” block. It was for the proposed new home page.
*starting with the second navArray block (“Are You in Pain?”), the order of the navArray blocks (top to bottom) is the order in which the top nav links are listed left to right.
*locate, copy, and paste back in one “navArray [++ix] =…” block.
*edit the new navArray block with (link-name,link-page) couplets for the new page. For Instance: “My Top Page”,”pg0.html”
*if that new top navigation page will have sub pages assigned to it, also list those subpages in the order you want them to appear (top to bottom). For instance: 
“My Top Page”,”pg0.html”,”highest left nav”, “lft1.html”, “Middle lft nav”, “lft2.html”, “Bottom nav”, “lft3.html”
so you see the top navigation name and link are the first two elements and the left nav link-names and link pages are the subsequent elements pairs.
*remember to not change any other code in the line or on the page. Remember the plain-text quotes and commas.
*save the file up to the server and verify it works correctly (of test it on your desktop if you can, even better).

If the page will be a sub navigation page to an existing top navigation page:
*locate the “navArray [++ix] =…” block where the first element is the name of the top navigation link under which you want the new page. For instance: 
navArray [++ix] = new Array("Workshops","sched.html","Teaching Schedule","sched.html","Descriptions","workshops.html");
*the order of the navArray elements (left to right) is the order in which the left nav links are listed top to bottom. The very first link pair is the top nav name and link.
*edit the navArray block to add or change the names, links, or order of the link-name,link-page couplets (past the first one) to incorporate the new page. For Instance:
navArray [++ix] = new Array("Workshops","sched.html","Teaching Schedule","sched.html","My New subpage","lft4.html","Descriptions","workshops.html");
This will place your new page in the left navigation under the “Teaching Schedule” link and above the “Descriptions” link.
*save the file up to the server and verify it works correctly (of test it on your desktop if you can, even better).


That’s it!


*/

