var path = window.location.pathname; // Contains the path from the root for the file
var folderLevel = path.split("/") // Array items containing the directory names. The last item in the array is the file name.
/**************************************************************************************************/
// Name:...... globalNav
// Purpose:... Highlight navigation items
// Variables:
//	 nav - Contians the UL item with the ID value of 'nav'
//   anchs - Array containing all anchor items from the UL tagged with ID 'nav'
// 
// Summary: When the function is called, it first searches the current page for a 
//          tag with the 'id' attribute and value of 'nav'. (e.g. id="nav")
//			After obtaining the nav item from the DOM perform conditional check for null;
//          id="nav" not present skip processing, id="nav" present continue.  When present
//			use a collection to contain all the anchor tags from the nav item for 
// 			future processing.  Since, indexOf function is being used and the site's directory 
//    		structure has two directories with parents (i.e. parents and parent-sp) in it, 
//			processing needs to be branched. A conditional check for 'parents' on the directory
//			structure is performed; when present process criteria is '/parents/', not present
//			process the directory or folder name. Increment throgh the collection array and use a 
//			conditional check for a matching href with directory name, when present set anchor 
//			class to active.
//			
/*************************************************************************************************/
function globalNav(){
    var nav = document.getElementById('nav');
	// Conditional Check on variable nav
	if (nav != null){// (True if not equal to null)
		var anchs = nav.getElementsByTagName("a");//Array contianing all the nav anchors
		// Conditional Check for parents directory
		if (folderLevel[1] == "parents"){ //(True if equal to parents)
				var criteria = "/" + folderLevel[1] + "/"; // criteria = '/parents/'
				for(i=0;i<anchs.length;i++){// Increment through anchs array
					if (anchs[i].href.indexOf(criteria) >= 0){//Using indexOf to search the href attribute for criteria (criteria = "/parents/")
						anchs[i].className='active'; //Assign a class attribute and value to active i.e. class="active"  
						break;
					}
				}
		}else {
			for(i=0;i<anchs.length;i++){				
				if (anchs[i].href.indexOf(folderLevel[1]) > 0){										
					anchs[i].className='active';
					break;
				}
			}
		}
		setSubsection();
	}
}

function setSubsection(){
	var sectNav = document.getElementById('section_nav');
	if (sectNav != null){
		var anchs = sectNav.getElementsByTagName("a");		
		for(var x=0;x<anchs.length;x++){
			if(anchs[x].href.indexOf(path) >= 0){			
				anchs[x].className='active';
				break;	
			}
		}
	}
}

function newWin(which){
	nuWin = window.open(which,"definition","WIDTH=680, left=70,menubar=0,resizable=0,scrollbars=1");
	nuWin.focus(which);
}

function newWin1(which, iWidth, iHeight){
	if (!iWidth){
   		iWidth = 700;
	}
	if (!iHeight){
		iHeight = 500;
	}	

   nuWin = window.open(which,"definition"," WIDTH=" + iWidth + ", height=" + iHeight + ", left=50, top=50,menubar=0,resizable=0,scrollbars=1");
   nuWin.focus(which);
}

function newWin0(which, iWidth, iHeight){
	if (!iWidth){
   		iWidth = 700;
	}
	if (!iHeight){
		iHeight = 500;
	}	

   nuWin = window.open(which,"definition"," WIDTH=" + iWidth + ", height=" + iHeight + ", left=50, top=50,,menubar=0,resizable=1,scrollbars=1");   
   nuWin.focus(which);

}

function newWindemo(which, iWidth, iHeight){
	if (!iWidth){
   		iWidth = 980;
	}
	if (!iHeight){
		iHeight = 620;
	}	
   nuWin = window.open(which,"definition"," WIDTH=" + iWidth + ", height=" + iHeight + ", left=50, top=50,,menubar=0,resizable=0,scrollbars=1");
   nuWin.focus(which);
}

function newWin3(which){
   nuWin = window.open(which,"definition", "left=50, top=50,menubar=0,resizable=1,scrollbars=1,status=1,location=0,toolbar=0");
   nuWin.focus(which);
}

function newWinTestimonials(which, iWidth, iHeight){
	if (!iWidth){
   		iWidth = 700;
	}
	if (!iHeight){
		iHeight = 500;
	}	
   nuWin = window.open(which,"definition"," WIDTH=" + iWidth + ", height=" + iHeight + ",left=50,top=50,menubar=0,resizable=0,scrollbars=0");
   nuWin.focus(which);
}