//Adds subnav on the leftbox	
	var allHTMLTags = new Array(),
	topNav = document.getElementById('topnav'),
	library = [
			["sectionid_73", "sectionid_90", "sectionid_91", "sectionid_93", "sectionid_92"], /* page Ids */
			["menu_44", "menu_44", "menu_3", "menu_44", "menu_44"] /* menu to be used */
		];
	
	function addLoadEvents() {
		var homePage = document.getElementById('sectionid_1');
		if ( homePage == null) {
			document.getElementById('centerbox').innerHTML = "<div class='centertop'></div><div class='wrap'><div class='introsection'>" + document.getElementById('centerbox').innerHTML + '</div></div>';
		}
		if ( homePage == null && document.getElementById('sectionid_6') == null) { // if not blog
				miniNav();
		} else if (homePage != null) {
			childParentClass('pushedid_10');
			childParentClass('pushedid_11');
			childParentClass('pushedid_12');
			homeTabs();
			document.getElementById('rightbox').style.visibility = 'visible';
		}

		var centerbox = document.getElementById('centerbox');
		var leftbox = document.getElementById('leftbox');
		
		var myTags = new Array();
		var geta = new Array();

		
		
		//initMiniNavAccordion();
		
		changeLink('menu_2', '/?sectionid=43&sectiontree=2,43');//about
		changeLink('menu_3', '/?sectionid=16&sectiontree=3,16');// solutions
		changeLink('menu_4', '/?sectionid=55&sectiontree=4,55');// Results
		changeLink('menu_5', '/?sectionid=26&sectiontree=5,26');// News
		changeLink('menu_7', '/?sectionid=31&sectiontree=7,31');// ContacUs
		changeLink('menu_44', '/?sectionid=45&sectiontree=44,45');// Support
		
		readMore('sectionlink')
		comments('comments');
		setCurrent();
		setIntro('introsection');
		
	}
	
	// :::: COPY CURRENT PAGE PARENT MENU TO THE LEFTCOLUMN ::::
		function miniNav() {
			
			var allLinks = topNav.getElementsByTagName('a'),
				currentPage = document.location.href,
				parentMenu,
				sectionId, sectionIdIndex, sectiontreeIndex,
				win_sectionId, win_sectionIdIndex, win_sectiontreeIndex;
			
			//get section Id from current page
			if(currentPage.indexOf('sectionid=') != -1) {
				win_sectionIdIndex = currentPage.indexOf('sectionid=');
				if(currentPage.indexOf('tree') != -1 || currentPage.indexOf('parent') != -1 || currentPage.indexOf('item') != -1 || currentPage.indexOf('&') != -1) {
					win_sectiontreeIndex = currentPage.indexOf('&');
					win_sectionId = currentPage.substring(win_sectionIdIndex, win_sectiontreeIndex);
				} else {
					win_sectionId = currentPage.substring(win_sectionIdIndex);
				}
			}	
			//look thru nav links
			for (var q = 0; q < allLinks.length; q++) {
				//get section Id from link
				if(allLinks[q].href.indexOf('sectionid=') != -1) {
					sectionIdIndex = allLinks[q].href.indexOf('sectionid=');
					if(allLinks[q].href.indexOf('tree') != -1) {
						sectiontreeIndex = allLinks[q].href.indexOf('&');
						sectionId = allLinks[q].href.substring(sectionIdIndex, sectiontreeIndex);
					} else {
						sectionId = allLinks[q].href.substring(sectionIdIndex);
					}
				}
				
				//var myString = allLinks[q].href + '<br><br>' + sectionId + '<br><br>' + win_sectionId;
				//document.getElementById('leftbox').innerHTML = myString;
				
				/*compare section id taken from current url and a menu link*/
				// :::: SECTION IDS FROM THE LIBRARY Force chosen menu ::::
					for (var m = 0; m < library[0].length; m++) {
						
						//if (document.getElementById(library[0][m]) !=null && document.getElementById('miniNav') == null) {
						if (document.getElementById(library[0][m]) !=null) {
							miniNavCustom(library[1][m]);
							
						}
					}
					
				
				if (win_sectionId == sectionId) {
					if (allLinks[q].parentNode.parentNode.parentNode.parentNode.parentNode.tagName.toLowerCase() == 'li') {
						parentMenu = allLinks[q].parentNode.parentNode.parentNode.parentNode.parentNode;
					} 
					//else if (allLinks[q].parentNode.parentNode.parentNode.parentNode == "[object HTMLLIElement]"){
					else if (allLinks[q].parentNode.parentNode.parentNode.tagName.toLowerCase() == 'li') {
						parentMenu = allLinks[q].parentNode.parentNode.parentNode;
					} 
					else if (allLinks[q].parentNode.tagName.toLowerCase() == 'li') {
						parentMenu = allLinks[q].parentNode;
					} else {
						
					}
					

					document.getElementById('leftbox').innerHTML = "<div class='myNav' id='miniNav'> " + parentMenu.innerHTML + "</div>";
					
					parentMenu.setAttribute('id','current');
					removeLink();
					//setClass();
					//alert("");	
					
			
					
					
				}
				
			}
			
		}
	
	function miniNavCustom(theClass) {
			var allHTMLTags=document.getElementsByTagName('*');
			for (i=0; i<allHTMLTags.length; i++) {
				if (allHTMLTags[i].className==theClass) {
					 document.getElementById('leftbox').innerHTML = "<div class='myNav'> " + allHTMLTags[i].innerHTML + "</div>";
					allHTMLTags[i].setAttribute('id','current');
					//setClass();
					removeLink();
					
				}
			}
			
		}
	
	function childParentClass(pushId) {
		var myPush = document.getElementById(pushId);
		var pushHeading = myPush.getElementsByTagName('h4');
		var pushContent = myPush.getElementsByTagName('ul');
		//pushHeading[0].setAttribute('class','tabbedPush');
		//pushContent[0].setAttribute('class','tabbedContent');
		pushHeading[0].className = "tabbedPush";
		pushContent[0].className = "tabbedContent";
	}
	
	function homeTabs() {
			//Initialize first demo:
				ddaccordion.init({
					headerclass: "tabbedPush", //Shared CSS class name of headers group
					contentclass: "tabbedContent", //Shared CSS class name of contents group
					revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
					mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
					collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
					defaultexpanded: [0], //index of content(s) open by default [index1, index2, etc]. [] denotes no content.
					onemustopen: true, //Specify whether at least one header should be open always (so never all headers closed)
					animatedefault: false, //Should contents open by default be animated into view?
					persiststate: true, //persist state of opened contents within browser session?
					toggleclass: ["", "openpet"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
					togglehtml: ["none", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
					animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
					oninit:function(expandedindices){ //custom code to run when headers have initalized
						//do nothing
					},
					onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
						//do nothing
					}
				});
		}
		function initMiniNavAccordion() {
			ddaccordion.init({
			headerclass: "menuheaders", //Shared CSS class name of headers group
			contentclass: "menucontents", //Shared CSS class name of contents group
			revealtype: "clickgo", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
			mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
			collapseprev: true, //Collapse previous content (so only one open at any time)? true/false
			defaultexpanded: [0], //index of content(s) open by default [index1, index2, etc] [] denotes no content
			onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
			animatedefault: false, //Should contents open by default be animated into view?
			persiststate: true, //persist state of opened contents within browser session?
			toggleclass: ["expanded", "collapsed"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
			togglehtml: ["", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively ["position", "html1", "html2"] (see docs)
			animatespeed: "normal", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
			oninit:function(headers, expandedindices){  //custom code to run when headers have initalized
			//do nothing
			},
			onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
			//do nothing 
			}  });
			
			
            //return false;
			
		}
		
		
		
		// :::: UPDATE MENU CLASSES TO WORK WITH ACCORDION ::::
		
			
		function setClass() {
			/*
			var myLi = new Array(),
				getli = new Array(),
				myMiniNav, s, i, w, r, n;
			
			myMiniNav = document.getElementById("miniNav");
			myLi = myMiniNav.getElementsByTagName('li');

			for (s = 0; s < myLi.length; s++) {
				var setUl = myLi[s].parentNode;
				setUl.setAttribute('class', 'menucontents');
			}
			for (i = 0; i < myLi.length; i++) {
				var getAtags = myLi[i].getElementsByTagName('a');
				for (w = 1; w < getAtags.length; w++) {
					getAtags[0].setAttribute('class', 'menuheaders');
				}
			}
			for (r = 0; r < myLi.length; r++) {
				getli = myLi[r].getElementsByTagName('Li');
				for (w = 0; w < getli.length; w++) {
					getli[w].setAttribute('class', 'menuitem');
				}
			}
			var myUl = myNav.getElementsByTagName('Ul');
			for (n = 0; n < 1; n++) {
				myUl[n].setAttribute('class', '');
			}*/
			var myLi = new Array(),
				getli = new Array(),
				myMiniNav = document.getElementById("miniNav"),
				getAtags,ss, setUl, ii, ww, rr, wr, ns, contentParent;
				myLi = myMiniNav.getElementsByTagName('li');
				var myUl = myMiniNav.getElementsByTagName('ul');
				 
			
			for ( ss = 0; ss < myUl.length; ss++) {
				myUl[ss].setAttribute('class', 'menucontents');
				myUl[0].setAttribute('class', '');
			}
			for (ii = 0; ii < myLi.length; ii++) {
					getAtags = myLi[ii].getElementsByTagName('ul');
				for (ww = 0; ww < getAtags.length; ww++) {
					var mH = getAtags[ww].parentNode.getElementsByTagName('a');
					mH[0].setAttribute('class', 'menuheaders');
					
				}
			}

			for (rr = 0; rr < myLi.length; rr++) {
				getli = myLi[rr].getElementsByTagName('li');
				
				for (wr = 0; wr < getli.length; wr++) {
					getli[wr].setAttribute('class', 'menuitem');
				}
			}

		}
	
		

	//change URL to # all left headings.
    	function removeLink() {
			var leftId = document.getElementById('leftbox');
    		var myTags=leftId.getElementsByTagName('A');
			for (s=0; s<1; s++) {
				myTags[0].setAttribute('href','#');
    		}
    	}
	//add classes to comments
		function comments(theClass) {
    		var myTags=document.getElementsByTagName('*');
			for (i=0; i<myTags.length; i++) {
				if (myTags[i].className==theClass) {
					var geta = myTags[i].getElementsByTagName('*');
					for (w=0; w<geta.length; w++) {
							geta[1].setAttribute('target', '_blank');
							geta[2].setAttribute('target', '_blank');
						if (document.all) { //if IE
							geta[0].setAttribute('className', 'commentsLink');
							geta[1].setAttribute('className', 'delicious');
							geta[2].setAttribute('className', 'digg');
						}
						else {
							geta[0].setAttribute('class', 'commentsLink');
							geta[1].setAttribute('class', 'delicious');
							geta[2].setAttribute('class', 'digg');
						}
					}
    			}
    		}
    	}
	//change Read More value
    	function readMore(theClass) {
    		var myTags=document.getElementsByTagName('*');
			for (s=0; s<myTags.length; s++) {
				if (myTags[s].className==theClass) {
					var geta = myTags[s].getElementsByTagName('*');
					for (w=0; w<geta.length; w++) {
						geta[0].innerHTML = "Read More &raquo;"
					}
    			}
    		}
    	}
		
	
		
    	function changeLink(theClass, theLink) {
    		var myTags = topNav.getElementsByTagName('li');
			for (s=0; s<myTags.length; s++) {
				if (myTags[s].className==theClass) {
					var geta = myTags[s].getElementsByTagName('a');
					for (w=0; w<geta.length; w++) {
						geta[0].setAttribute('href',theLink);
					}
    			}
    		}
    	}


	//Compare link to link, set Active state 'current'	
	function setCurrent() {
		var links = leftbox.getElementsByTagName('*');
		for (var i = 0; i <links.length; i++) {
			if(links[i].href == window.location.href) {
				if (links[i].className != "") {
						links[i].className = links[i].className + ' current';
					} else {
						links[i].className = 'current';
					}
			}
		}
	}
	
	
	//add intro if missing	
	function setIntro(theClass) {
		var myTags=document.getElementsByTagName('*');
			for (s=0; s<myTags.length; s++) {
				if (myTags[s].className == theClass) {
					myTags[s].setAttribute('id', 'intro');
    			}
    		}
		if (document.getElementById('intro') == null) {
			centerbox.innerHTML = "<div class='introsection'></div>" + centerbox.innerHTML;
		}
    }

// :::: FOR TEXTBOXES ::::
function iFocus(e) {
if (e.value == e.defaultValue) {
	e.value = "";
	e.style.color = "#000";
}
}
function iBlur(e) {
    if (e.value == "") {
        e.value = e.defaultValue;
        e.style.color = "#444";
    }
}


	