function genEmailLink (o) {
    var subjTxt = "subject=" + "Esri ArcGIS Explorer Help Topic"
    var bodyTxt = "body=" + 
              "Here's a useful topic I found on Esri's ArcGIS Explorer Help Site: " + 
              encodeURIComponent (window.location.href)                
    o.href = "mailto:?"+ subjTxt + "&" + bodyTxt                
}

function onBeforePrint() {
			var wparts = ["wpart0", "wpart1", "wpart2", "wh_footer"]
			for (var i=0; i<wparts.length; i++) {	
				var ele = document.getElementById (wparts[i])
				if (ele) {
					ele.style.display = "none"
				}
			}
}
function printTopic () {
		if (window.print){
			window.print()
			}
		else{
			window.alert("Your browser doesn't support this functionality")
			}
}
function onAfterPrint(){
			var wparts = ["wpart0", "wpart1", "wpart2", "wh_footer"]
			for (var i=0; i<wparts.length; i++) {	
				var ele = document.getElementById (wparts[i])
				if (ele) {
					ele.style.display = "inline"
				}
			}
}

function syncToc2 (pathname, hash) {
	if (!hash) {
		hash = ""
	}
	
	paths = pathname.split ("/")
	if (paths.length == 5) {
		window.location = "index.html#" + paths[paths.length-1] + hash
	} else if (paths.length == 6) {
		window.location = "../index.html#" + paths[paths.length-2] + "/" +paths[paths.length-1] + hash
	}

}

//		 this is the event handler for page load event
//		it does 2 thing
//		1. redirect page to sync with toc
//      or
//		2. exec print function - mod css 
function ifWebPrint () {
    var hash = document.location.hash 

	//if url has a hash

    if (hash) {
		//if url is encode as http://xyz#webprint
		if (hash == "#webprint") {
			var wparts = ["wpart0", "wpart1", "wpart2", "wh_footer"]

			for (var i=0; i<wparts.length; i++) {	
				var ele = document.getElementById (wparts[i])
				if (ele) {
					ele.style.display = "none"
				}
			}
		} else {
			//if top-level page, no frame
			if (parent == self) {
				syncToc2 (self.location.pathname, hash)
			}
		}
		
    } else {
	//if url does not have a hash	
			//if top-level page, no frame
			if (parent == self) {		
				syncToc2 (self.location.pathname, hash)
			}
	}
}