

function cancelEmailFriend(fm){
	var vl = document.forms[fm].elements["posts"].value;
	if (!vl) vl = 1;
	vl++;
	history.go(-vl);
	
	
}




function submitForm(fm,act){

	if (updateSummary()){
		alert(emptyStr);
		return;
	}


	document.forms[fm].action=act;
	document.forms[fm].elements["submitFm"].click();
}

function eBrochureGoto(act,fm,tgt,opt){
	document.forms[fm].target=tgt;
	document.forms[fm].action=act;
	document.forms[fm].elements["gid"].value = gid;
	document.forms[fm].elements["options"].value = opt;
	document.forms[fm].elements["submitForm"].click()
}

menu = {};
menu.open = [];


function showMenu(nm,level){
	for (var i=level;i<menu.open.length;i++){
		if (menu.open[i]) menu.open[i].style.visibility = "hidden";
	}

	var id = document.getElementById(nm);
	//id.style.visibility = "visible";
	fade.display(nm,true);
	menu.open[level] = id;

	var o = document.getElementById('summary');
	//o.style.left="800px";//(300+((level+1)*250))+"px"
}



function setSubCheckboxes(o,v,e){

	for (var i=0;i<o.childNodes.length;i++){
		if (o.childNodes[i] && o.childNodes[i].childNodes) setSubCheckboxes(o.childNodes[i],v)
		if (o.childNodes[i] && o.childNodes[i].tagName=="INPUT") o.childNodes[i].checked = v;
	}		

}


function updateSummary(){
	o = document.getElementById('selectMenus')
	if (!o) return;
	var dt = [];
	var level=0;
	var baseNm = "";
	var summaryEmpty=true;
	updateSummarySub(o);
	renderSummaryMenu(dt);

	function updateSummarySub(o){
		for (var i=0;i<o.childNodes.length;i++){
			var o2 = o.childNodes[i];
			if (o2 && o2.childNodes) updateSummarySub(o2)
			if (o2 && o2.tagName=="INPUT" && o2.id.substring(0,2)=="tg" && o2.id.indexOf("true")==-1){
				//dt[dt.length] = [o2.alt,o2.id.substring(0,2)=="tg"];	
				baseNm = o2.alt;
			}
			if (o2 && o2.tagName=="INPUT" && o2.id.substring(0,2)=="ip" && o2.checked){
				if (!dt[baseNm]) dt[baseNm]=[];
				dt[baseNm][dt[baseNm].length] = o2.alt;
				summaryEmpty=false;
			}
		}
	}
	return summaryEmpty;
}

var initSummaryContents="";
var summaryEmpty=true;

function renderSummaryMenu(dt){
	var str="";
	for (var i in dt){
		str+="<li style=\"padding-top:5px;\">";
		str+="<span class=\"wd2\">&nbsp;</span><span class=\"content large\">"+i+"</span><br clear=\"all\"/>";
		str+="</li>";

		for (j=0;j<dt[i].length;j++){
			str+="<li>";
			str+="<span class=\"wd2\">&nbsp;</span><span class=\"content small\">"+dt[i][j]+"</span><br clear=\"all\"/>";
			str+="</li>";
			summaryEmpty=false;	
		}
	}
	var o = document.getElementById('summary');
	//if (initSummaryContents=="") initSummaryContents=o.innerHTML;

	//o.innerHTML = initSummaryContents + str;
	o.innerHTML = str;
	//o.style.visibility="visible";
}

function addEvent(obj, evType, fn){ 
	if (obj.addEventListener){ 
		obj.addEventListener(evType, fn, false); 
		return true; 
	} else if (obj.attachEvent){ 
		var r = obj.attachEvent("on"+evType, fn); 
		return r; 
	} else { 
		return false; 
	} 
}

addEvent(window, "load", function(){updateSummary();});



fade = {};
fade.id = null;
fade.ind = 0;
fade.int = -1;
fade.show = false;
fade.step = 0.09;
fade.active = false;
fade.nm = "";

fade.repeat = function(){
	fade.ind+=  (fade.show) ? fade.step : -fade.step;
	fade.id.style.opacity = fade.ind;
	fade.id.style.filter="alpha(opacity="+(fade.ind*100)+")";	
	if (fade.ind>=1 || fade.ind<0){
		clearInterval(fade.int);
		//fade.id.style.visibility = (fade.show) ? "visible" : "hidden";
		if (!fade.show) fade.id.style.visibility = "hidden";
		fade.id.style.filter="";
		fade.active = false;
		
	}

}

fade.display = function(nm,show,posNm){
	//if (this.active) return;
	if (this.nm==nm && this.show==show){
		document.getElementById(nm).style.visibility = "visible" ;
		return;
	}
	this.nm = nm;
	if (this.active){	
		clearInterval(this.int);
		if (!this.show){
			this.id.style.visibility = "hidden";
			this.ind = 0;
			this.id.style.opacity = 0;
			this.id.style.filter="";	
		} else {
			this.ind = 1;
			this.id.style.opacity = 1;
			this.id.style.filter="";	
		}
	}

	this.active = true;
	this.id = document.getElementById(nm);
	if (posNm){
		var id1 = document.getElementById(posNm);
		this.id.style.left = (id1.offsetLeft-8)+"px";
		this.id.style.top = (id1.offsetTop+id1.offsetHeight+((document.all) ? 3 : 0))+"px";
	}
	this.id.style.visibility = "visible" ;
	this.show = show;
	if (show){
		this.ind = 0;
		this.id.style.opacity = 0;
		this.id.style.filter="alpha(opacity=0)";	
	
	} else {

		this.ind = 1;
		this.id.style.opacity = 1;
		this.id.style.filter="alpha(opacity=100)";	
	}
	this.int = setInterval(this.repeat,20);
}


function hideMenu(e,o,nm){
	var el = o.firstChild.firstChild;	
	var srcEl,relEl;

	srcEl = (document.all) ? e.srcElement : e.target;
	relEl = e.relatedTarget || e.toElement;	
	if (!inSubNav(relEl)) fade.display(nm,false);
}

	function inSubNav(o){
	str="";
		while (o!=document.body){
		str+=o.tagName+">";
			if (o.tagName=="A") {

			return true;
			}

			o = o.parentNode;
		}
//document.getElementById("test").innerHTML = str;
		return false;
	}
	
	
	

