var childFound = false;
function openChildren(node){
 for(var c=0;c<node.childNodes.length;c++){
	if(node.childNodes[c].nodeName=="UL"){
		node.childNodes[c].style.display="block";
	}
 }
}
function highlightMenu(n) {
	var children = n.childNodes;
	var breadCrumb = document.getElementById("breadcrumb");
	var breadCrumbLinks;
	if(document.all){	
		breadCrumbLinks = breadCrumb.innerHTML.split("</LI>");
	}else{
		breadCrumbLinks = breadCrumb.innerHTML.split("</li>");
	}
	for(b=1; b<breadCrumbLinks.length;b++){
		breadCrumbLinks[b] = breadCrumbLinks[b].substring(breadCrumbLinks[b].indexOf("tabid")+6, breadCrumbLinks[b].indexOf("/Default"));
	}
	for(var i=0; i < children.length; i++) {
		 if(children[i].nodeName == "A"){
			var linkId;
			if(document.all){
				linkId = children[i].getAttribute("href").substring(children[i].getAttribute("href").indexOf("link=")+5,children[i].getAttribute("href").indexOf("&"));
			}else{
				linkId = children[i].href.substring(children[i].href.indexOf("link=")+5,children[i].href.indexOf("&"));
			}
			for(var r=0;r<breadCrumbLinks.length;r++){
				if(breadCrumbLinks[r]==linkId){
					children[i].parentNode.parentNode.parentNode.parentNode.className="selected";
					children[i].parentNode.parentNode.parentNode.className="selected";
					children[i].parentNode.parentNode.className="selected";
					children[i].parentNode.className="selected";
					children[i].className="selected";
				}
			}
		 }
		 childTag = highlightMenu(children[i]);
 }
}

function highlightTopMenu(n){
	var loc = window.location.href;		
		if(loc.indexOf("/ConservatoryBlinds/")>-1){
			document.getElementById("conservatory").className="selected";
		}
		if(loc.indexOf("/Awnings/")>-1){
			document.getElementById("awnings").className="selected";
		}
		if(loc.indexOf("/WindowBlindsandShutters/")>-1){
			document.getElementById("blinds_shutters").className="selected";
		}
		if(loc.indexOf("/WhyChooseThomasSanderson/")>-1){
			document.getElementById("why_choose").className="selected";
		}
		if(loc.indexOf("/Offers/")>-1){
			document.getElementById("offers").className="selected";
		}
		if(loc.indexOf("/NewsEvents/")>-1){
			document.getElementById("news_events").className="selected";
		}
}
function topNavNewWindow(headerNav){
	var children = headerNav.childNodes;
	for(var i=0; i < children.length; i++) {
		 if(children[i].nodeName == "LI"){
		 	if(children[i].firstChild.getAttribute("href").indexOf('http://www.business')!=-1){
				children[i].firstChild.target ="_blank";
			}
		 }
	}
}
function highlightTab(n){
		var children = n.childNodes;
		for(var i=0; i < children.length; i++) {
			if(children[i].nodeName=="LI"){
				if(children[i].firstChild.nodeName == "A"){
					var linkId = children[i].firstChild.getAttribute("href").substring(children[i].firstChild.getAttribute("href").indexOf("link=")+5,children[i].firstChild.getAttribute("href").indexOf("&"));
					if(location.href.indexOf(linkId)!=-1){
						children[i].firstChild.className="on";
					}
				}
			}
		}
}
if(document.getElementById("IconBar.ascx_lblMode")==null) {
	if(document.getElementById("tertiary_list_nav") !=null){
		var tabBlock=document.getElementById("tertiary_list_nav");
		highlightTab(tabBlock);
	}
	if(document.getElementById("header_nav") !=null){
		var headerNav = document.getElementById("houseMenuVstatic0");
		topNavNewWindow(headerNav);
	}
}
	if(document.getElementById("dnn_LeftPane") !=null){
		var leftNav = document.getElementById("dnn_LeftPane");
	}
	var topNav = document.getElementById("main_nav");

	var cp_indexOfTabid = window.location.href.indexOf("tabid")+6;
	var cp_indexOfSlashDefault = window.location.href.indexOf("/Default.aspx");
	var currentPage = window.location.href.substring(cp_indexOfTabid, cp_indexOfSlashDefault);

	if(document.getElementById("IconBar.ascx_lblMode")==null) {
		highlightTopMenu(topNav);
		document.write('<style>#lh_nav_container ul li ul{display:none;}#lh_nav_container ul li ul li ul{display:none;}</style>');
		if(document.getElementById("dnn_LeftPane") !=null){
				highlightMenu(leftNav);
		}
	}
	var pgmain = document.getElementById("pgmain");
	var footertest = document.getElementById("main_footer_lhs").innerHTML;
	var thumb = document.getElementById("pgtitle");
	if(pgmain!=null){
		pgmain.firstChild.title = thumb.firstChild.innerHTML;
	}