// req: <iframe ID=IFrameContent name=IFrameContent>
function GetObj(id){return document.getElementById(id)}
function PreLoad(tmpl,page,inc){
	myURL="/comsite5/bin/manta_tt_basicpage.pl?template="+tmpl
	if(page){myURL=myURL+"&page="+page}
	if(inc){myURL=myURL+"&inc="+inc}
	IFrameContent.location.replace(myURL);
}
function DivPopup(inc,divid,qs,container){ // Create element and get the content in the IFrameContent 
	myDiv=GetObj(divid)
	if (!myDiv){
		if(!container){container='middle_content';myElement=GetObj(container);} // target a DIV to reside in
		else if (container=='body'){myElement=document.body}
		else {myElement=GetObj(container);} //container
		newNode = document.createElement("div");
		newNode.setAttribute("id",divid);
		newNode.className="popup";
		newNode.style.display="none"
		newNode.style.position="absolute"
		newNode.style.left="0px"
		newNode.style.top="0px"
		myElement.appendChild(newNode);
		myURL="/comsite5/bin/manta_tt_basicpage.pl?page=divpopup&inc="+inc+"&id="+divid+qs
		IFrameContent.location.replace(myURL);
		//GoIFrame("IFrameContent",myURL)
	} else if (myDiv.innerHTML==""){ // created but empty DIV
		myURL="/comsite5/bin/manta_tt_basicpage.pl?page=divpopup&inc="+inc+"&id="+divid+qs
		// IFrameContent.onload=""
		// GoIFrame("IFrameContent",myURL)
		IFrameContent.location.replace(myURL);
	}
}
function GoIFrame(iFrameName,myURL) { // not used yet
	 if (eval("document."+iFrameName)){
	 		eval(iFrameName).location.replace(myURL)
	 } else {
		 ifrm = document.createElement("IFRAME"); 
		 ifrm.setAttribute("id", iFrameName); 
		 ifrm.setAttribute("src", myURL); 
		 ifrm.setAttribute("frameborder","0"); 
		 ifrm.style.width = 0+"px"; 
		 ifrm.style.height = 0+"px"; 
		 document.body.appendChild(ifrm); 
	 }
} 
// create copy of DIV for abs. pos.
function CreatePopup(srcID,popID,container){
	myDiv=GetObj(popID)
	if (!myDiv){
		if(!container){container='middle_content'} //target
		ParentObj=GetObj(container);
		SrcObj=GetObj(srcID);
		newNode = document.createElement("div");
		newNode.setAttribute("id",popID);
		newNode.innerHTML=SrcObj.innerHTML
		newNode.className=SrcObj.className;
		newNodeStyle=newNode.style
		SrcStyle=SrcObj.style
		for(x=0; x <= SrcStyle.length; x++){ //copy style vals
			var str = "newNodeStyle."+SrcStyle[x]+" = SrcObj.style."+SrcStyle[x]+";";
			try{eval(str)}
			catch(e){}
		}
		newNodeStyle.width=SrcStyle.width // for IE
		ParentObj.appendChild(newNode);
	}
}
