var bgSwap = '';
var myHiEl = ''; //global variable shared between mouseover and mouseout
var leadArticle = '';//global var shared to allow FCKeditor to do stuff like inline file attachment
var il_article = '';
var il_uri = '';
var il_302 = '';
var thisWindow = window;

function doPopUp (editor_href, content_alias, is_lead, inline_article, inline_uri, inline_302, rmid, rtag, site_key, has_quote, comment_id, requested_uri ) {
	
	sH=screen.height - 16;
	sW=screen.width - 16;
	
	myPopUp = document.getElementById("popOverHelp");

	if (!myPopUp) {
		popOverHelp = document.createElement("div");
		popOverHelp.setAttribute("id","popOverHelp");
		popOverHelp.onclick = Function("hidePopOverHelp(document);");

		document.getElementsByTagName("body")[0].appendChild(popOverHelp);
		myPopUp = document.getElementById("popOverHelp");
	} else {
		while (myPopUp.childNodes.length > 0) {
			myPopUp.removeChild(myPopUp.childNodes[myPopUp.childNodes.length - 1]);
		}
	}

        myPopUp.style.backgroundColor = '#eeeeee'; 
        myPopUp.style.border = '1px ridge lightgrey'; 
        myPopUp.style.width = '126px';

	containerDiv = document.createElement("div");
	containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:125px;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");
	myPopUp.appendChild(containerDiv);
	
	span1 = document.createElement("span");
	span1.setAttribute("style","width:125px;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:2px 0px 2px 0px;cursor:pointer;");
	anchor1 = document.createElement("a");
	anchor1.setAttribute("href", "#");
	anchor1.onclick=Function("window.open(\'" + editor_href + "\', \'contentEditorWindow\', \'top=10px, left=10px, width=900px, height=670px, status=no, scrollbars=no, resizable=yes\');hidePopOverHelp(document);");
	text1 = document.createTextNode("Edit");

	anchor1.className = 'popupItem';

	anchor1.appendChild(text1);
	span1.appendChild(anchor1);
	containerDiv.appendChild(span1);

        // containerDiv = document.createElement("div");
        //containerDiv.setAttribute("style", "position:relative;float:none;clear:both;width:100%;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");
        //myPopUp.appendChild(containerDiv);

        //span1 = document.createElement("span");
        //span1.setAttribute("style","width:100%;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:0px;cursor:pointer;");
        //anchor1 = document.createElement("a");
        //anchor1.setAttribute("href", "#");
        //anchor1.onclick=Function("window.open(\'/cms/artcateditor/" + content_alias + "\', \'contentCatEditorWindow\', \'top=10px, left=10px, width=900px, height=670px, status=no, scrollbars=no, resizable=yes\');hidePopOverHelp(document);");
        //text1 = document.createTextNode("Categories");

	//anchor1.className = 'popupItem';

        //anchor1.appendChild(text1);
        //span1.appendChild(anchor1);
        //containerDiv.appendChild(span1);
	
	containerDiv = document.createElement("div");
	containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:125px;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");
	myPopUp.appendChild(containerDiv);
	
	span1 = document.createElement("span");
	span1.setAttribute("style","width:125px;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:0px;");
	anchor1 = document.createElement("a");
	anchor1.setAttribute("href","#");
	anchor1.onclick = Function("window.open(\'/cms/history/" + content_alias + "\', \'contentEditorWindow\', \'top=0px, left=0px, width=" + sW + "px, height=" + "660px, scrollbars=yes, resizable=yes\');hidePopOverHelp(document);");
	text1 = document.createTextNode("History");
	anchor1.className = 'popupItem';
	
	anchor1.appendChild(text1);
	span1.appendChild(anchor1);
	containerDiv.appendChild(span1);
	
	if (is_lead == "true") {
	
		il_article = inline_article;
		il_uri = inline_uri;
		il_302 = inline_302;

                containerDiv = document.createElement("div");
                containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:125px;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");
                myPopUp.appendChild(containerDiv);
		popUpSeparator(myPopUp);

		containerDiv = document.createElement("div");
		containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:125px;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");
		myPopUp.appendChild(containerDiv);
						
		span1 = document.createElement("span");
		span1.setAttribute("style","width:125px;height:auto;position:relative;float:left;margin:0px;padding:0px;");
		anchor1 = document.createElement("a");
		anchor1.setAttribute("href","#");
		anchor1.onclick = Function("leadArticle = '"+content_alias+"';window.open(\'/global/FCKeditorfc/editor/filemanager/browser/default/browser.html?Type=File&Connector=/cms/document\', \'contentEditorWindow\', \'top=0px, left=0px, width=900px, height=670px, scrollbars=yes, resizable=yes\');hidePopOverHelp(document);");
		text1 = document.createTextNode("Add Document");
		
		anchor1.className = 'popupItem';

		anchor1.appendChild(text1);
		span1.appendChild(anchor1);
		containerDiv.appendChild(span1);


		containerDiv = document.createElement("div");
		containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:125px;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");
		myPopUp.appendChild(containerDiv);
						
		span1 = document.createElement("span");
		span1.setAttribute("style","width:125px;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:0px;");
		anchor1 = document.createElement("a");
		anchor1.setAttribute("href","/cms/inlineadmin/" + inline_article + "?action=add&tag=callout&uri=" + inline_uri + "&uri302=" + inline_302);
 		anchor1.className = 'popupItem';
		text1 = document.createTextNode("Add Callout");
		
		anchor1.appendChild(text1);
		span1.appendChild(anchor1);
		containerDiv.appendChild(span1);

                if ( has_quote == '0' ) {
                   containerDiv = document.createElement("div");
                   containerDiv.setAttribute("style", "position:relative;float:left;clear:both;125px;auto;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");                             myPopUp.appendChild(containerDiv);
                   span1 = document.createElement("span");
                   span1.setAttribute("style","width:125px;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:0px;");
                   anchor1 = document.createElement("a");
                   anchor1.setAttribute("href","#quote");
                   anchor1.onclick = Function("window.open('/cms/commenteditor?is_quote=Y&parent_type=element&parent_alias="+content_alias+"&requested_uri="+requested_uri+"\', \'commentEditorWindow\', \'top=20px, left=20px, width=900px, height=670px, scrollbars=no, resizable=yes\');");
                   text1 = document.createTextNode("Add Quote");

                   anchor1.className = 'popupItem';
                   anchor1.appendChild(text1);
                   span1.appendChild(anchor1);
                   containerDiv.appendChild(span1);
               }
               if (  has_quote > 0 && comment_id > 0 ) {
                  containerDiv = document.createElement("div");
                  containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:125px;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");
                  myPopUp.appendChild(containerDiv);
                  span1 = document.createElement("span");
                  span1.setAttribute("style","width:125px;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:0px;");
                  anchor1 = document.createElement("a");
                  anchor1.setAttribute("href","#quote");
                  anchor1.onclick = Function("window.open('/cms/commenteditor/"+comment_id+"\', \'commentEditorWindow\', \'top=20px, left=20px, width=900px, height=670px, scrollbars=no, resizable=yes\');");
                  text1 = document.createTextNode("Edit quote");

                  anchor1.className = 'popupItem';
                  anchor1.appendChild(text1);

                  span1.appendChild(anchor1);
                  containerDiv.appendChild(span1);

                  containerDiv = document.createElement("div");
                  containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:125px;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");
                  myPopUp.appendChild(containerDiv);
                  span1 = document.createElement("span");
                  span1.setAttribute("style","width:125px;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:0px;");
                  anchor1 = document.createElement("a");
                  anchor1.setAttribute("href","#quote");
                  anchor1.onclick = Function("window.open('/cms/commenteditor/suppress/"+comment_id+"\', \'commentEditorWindow\', \'top=300px, left=300px, width=300px, height=150px, scrollbars=no, resizable=yes\');");
                  text1 = document.createTextNode("Remove quote");
        
                  anchor1.className = 'popupItem';
                  anchor1.appendChild(text1);

                  span1.appendChild(anchor1);
                  containerDiv.appendChild(span1);

               }
                 popUpSeparator(myPopUp);
                containerDiv = document.createElement("div");                containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:125px;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");                myPopUp.appendChild(containerDiv);                span1 = document.createElement("span");                span1.setAttribute("style","width:125px;height:auto;position:relative;float:left;margin:0px;padding:0px;");                anchor1 = document.createElement("a");                anchor1.setAttribute("href","#");                anchor1.onclick = Function("window.open(\'/cms/relmanager/element/element/fragment/" + content_alias + "\', \'contentEditorWindow\', \'top=0px, left=0px, width=" + sW + "px, height=" + "660px, scrollbars=yes, resizable=yes\');hidePopOverHelp(document);");                text1 = document.createTextNode("Edit relationships");                anchor1.className = 'popupItem';                anchor1.appendChild(text1);                span1.appendChild(anchor1);                containerDiv.appendChild(span1);

		containerDiv = document.createElement("div");
		containerDiv.setAttribute("style", "position:relative;float:none;clear:both;width:100%;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");
		myPopUp.appendChild(containerDiv);

  	        span1 = document.createElement("span");
		span1.setAttribute("style","width:100%;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:0px;");
		anchor1 = document.createElement("a");
                anchor1.setAttribute("href","#");		
                anchor1.onclick = Function("window.open('/cms/inlineadmin/" + inline_article + "?action=linksearch&tag=featured1&uri=" + inline_uri + "&uri302=" + inline_302+"\', \'linkArticleWindow\', \'top=10px, left=10px, width=900px, height=470px, scrollbars=no, resizable=yes\');");

 		anchor1.className = 'popupItem';
		text1 = document.createTextNode("Link Article");
		
		anchor1.appendChild(text1);
		span1.appendChild(anchor1);
		containerDiv.appendChild(span1);

                popUpSeparator(myPopUp);

	}
        else {

                if ( has_quote == '0' ) {
                   containerDiv = document.createElement("div");
                   containerDiv.setAttribute("style", "position:relative;float:left;clear:both;100%:auto;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");
                   myPopUp.appendChild(containerDiv);
                   span1 = document.createElement("span");
                   span1.setAttribute("style","width:125px;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:0px;");
                   anchor1 = document.createElement("a");
                   anchor1.setAttribute("href","#quote");
                   anchor1.onclick = Function("window.open('/cms/commenteditor?is_quote=Y&parent_type=element&parent_alias="+content_alias+"&requested_uri="+requested_uri+"\', \'commentEditorWindow\', \'top=20px, left=20px, width=900px, height=670px, scrollbars=no, resizable=yes\');");
                   text1 = document.createTextNode("Add Quote");

		   anchor1.className = 'popupItem';
                   anchor1.appendChild(text1);
                   span1.appendChild(anchor1);
                   containerDiv.appendChild(span1);
               }
               if (  has_quote > 0 && comment_id > 0 ) {
                  containerDiv = document.createElement("div");
                  containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:125px;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");
                  myPopUp.appendChild(containerDiv);
                  span1 = document.createElement("span");
                  span1.setAttribute("style","width:125px;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:0px;");
                  anchor1 = document.createElement("a");
                  anchor1.setAttribute("href","#quote");
                  anchor1.onclick = Function("window.open('/cms/commenteditor/"+comment_id+"\', \'commentEditorWindow\', \'top=20px, left=20px, width=900px, height=670px, scrollbars=no, resizable=yes\');");
                  text1 = document.createTextNode("Edit quote");

		  anchor1.className = 'popupItem';
                  anchor1.appendChild(text1);

                  span1.appendChild(anchor1);
                  containerDiv.appendChild(span1);

               }
               popUpSeparator(myPopUp);

               containerDiv = document.createElement("div");
               containerDiv.setAttribute("style", "position:relative;float:none;clear:both;width:auto;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");
               myPopUp.appendChild(containerDiv);

               span1 = document.createElement("span");
               span1.setAttribute("style","width:auto;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:0px;");
               anchor1 = document.createElement("a");
               anchor1.className = 'popupItem';
               anchor1.setAttribute("href","/cms/inlineadmin/" + inline_article + "?action=up&tag=" + rtag + "&uri=" + inline_uri + "&uri302=" + inline_302 + "&rmid=" + rmid);
               text1 = document.createTextNode("Move up");
                                        
               anchor1.appendChild(text1);
               span1.appendChild(anchor1);
               containerDiv.appendChild(span1);
               containerDiv1 = document.createElement("div");
               containerDiv1.setAttribute("style", "position:relative;float:none;clear:both;width:auto;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");
               myPopUp.appendChild(containerDiv1);
       
               span2 = document.createElement("span");
               span2.setAttribute("style","width:auto;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:0px;");
               anchor1 = document.createElement("a");
               anchor1.className = 'popupItem';
               anchor1.setAttribute("href","/cms/inlineadmin/" + inline_article + "?action=down&tag=" + rtag + "&uri=" + inline_uri + "&uri302=" + inline_302 + "&rmid=" + rmid);
               text1 = document.createTextNode("Move down");

               anchor1.appendChild(text1);
               span2.appendChild(anchor1);
               containerDiv1.appendChild(span2);

               containerDiv2 = document.createElement("div");
               containerDiv2.setAttribute("style", "position:relative;float:none;clear:both;width:auto;height:auto;vertical-align:middle;margin:2px 0px 0px 0px;padding:0px;");
               myPopUp.appendChild(containerDiv2);

               span3 = document.createElement("span");
               span3.setAttribute("style","width:auto;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:0px;");
               anchor1 = document.createElement("a");
               anchor1.className = 'popupItem';
               anchor1.setAttribute("href","/cms/inlineadmin/" + inline_article + "?action=remove&tag=" + rtag + "&uri=" + inline_uri + "&uri302=" + inline_302 + "&rmid=" + rmid);
               text1 = document.createTextNode("Remove");

               anchor1.appendChild(text1);
               span3.appendChild(anchor1);
               containerDiv2.appendChild(span3);
               popUpSeparator(myPopUp);
        } 
        containerDiv = document.createElement("div");
        containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:125px;height:auto;vertical-align:middle;margin:0px;padding:0px;");
        myPopUp.appendChild(containerDiv);

        span1 = document.createElement("span");
        span1.setAttribute("style","width:125px;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:0px;");
        anchor1 = document.createElement("a");
        anchor1.setAttribute("href","#");
        anchor1.onclick = Function("window.open(\'/cms/admin\', \'\', \'top=0px, left=0px, width=" + sW + "px, height=" + "550px, menubar=yes,location=yes,toolbar=yes,status=yes,scrollbars=yes, resizable=yes\');hidePopOverHelp(document);");
        text1 = document.createTextNode("Administration");
        anchor1.className = 'popupItem';

        anchor1.appendChild(text1);
        span1.appendChild(anchor1);
        containerDiv.appendChild(span1);

	popUpSeparator(myPopUp);

        containerDiv = document.createElement("div");
        containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:125px;height:auto;vertical-align:middle;margin:0px;padding:0px;");
        myPopUp.appendChild(containerDiv);

        span1 = document.createElement("span");
        span1.setAttribute("style","width:125px;height:auto;position:relative;float:left;margin:0px 0px 0px 0px;padding:0px;");
        anchor1 = document.createElement("a");
        anchor1.setAttribute("href","/cms/logout");
        text1 = document.createTextNode("Logout");
        anchor1.className = 'popupItem';

        anchor1.appendChild(text1);
        span1.appendChild(anchor1);
        containerDiv.appendChild(span1);

}


function popUpSeparator(myPopUp) {
                containerDiv = document.createElement("div");
                containerDiv.setAttribute("style", "position:relative;float:none;clear:both;width:125px;height:auto;vertical-align:middle;margin:0px;")

                myPopUp.appendChild(containerDiv);

		span1 = document.createElement("span");
                span1.setAttribute("style","display:inline;width:125px;position:relative;height:1px;float:left;clear:both;margin-top:5px;padding-top;5px;border-bottom:1px solid darkgrey;");
                
                var detect = navigator.userAgent.toLowerCase(); 	        
                if ( detect.indexOf('msie') + 1 ) {
                   var img1 = document.createElement("img");     
                   img1.setAttribute("src","/global/images/icons/nav_separator_line.gif");
                   img1.setAttribute("style","width:100px;");
                   span1.appendChild(img1);
                }


		containerDiv.appendChild(span1);

		span1 = document.createElement("span");
		span1.setAttribute("style","width:125px;position:relative;float:left;clear:both;margin-bottom:5px;");
		text1 = document.createTextNode("");

		span1.appendChild(text1);
		containerDiv.appendChild(span1);

}

function editCursor(myEl) {
		myEl.style.cursor = 'pointer';
		bgSwap = myEl.style.backgroundColor;
		myEl.style.backgroundColor = '#EFEFEF';
}

function regularCursor(myEl) {
		myEl.style.cursor = 'default';
		myEl.style.backgroundColor = bgSwap;
}

function addEditIcon(myEl, e) {
	
	var mySource;

	if(!e){e=window.event;}
	
	if(e) {
		mySource=e.target?e.relatedTarget:e.fromElement;
	}
	if(!e){return;}

	//the next line checks to see if the luser moved outside myEl

	if (myEl && !document.getElementById('editIcon')) {
		myImage = document.createElement("img");
		myImage.id = "editIcon";
		myImage.src = "/global/images/toolbar/edit3d.gif";
		myImage.style.position = "absolute";
		myImage.style.width = '16px';
		myImage.style.height = '16px';
		myImage.style.margin = '0px';
		myImage.style.padding = '0px';
		myImage.style.border = '0';
		myEl.style.marginTop?myImage.style.top = parseInt(myEl.style.marginTop) + 'px':myImage.style.top = '0px';
		myEl.style.marginRight?myImage.style.left = parseInt(myEl.offsetWidth) - 16 - parseInt(myEl.style.marginRight) + 'px':myImage.style.left = parseInt(myEl.offsetWidth) - 16 + 'px';
   		myEl.appendChild(myImage);
	}
}

function removeEditIcon(myEl, e) {

	var myEvent;
	var myDestination;

	if(!e){e=window.event;}
	
	if(e) {
		//myEl=e.target?e.target:e.srcElement;
		myDestination=e.target?e.relatedTarget:e.toElement;
	}
	if(!e){return;}

	//the next line checks to see if the luser moved outside myEl

	if (myDestination && myEl) {
           if (myDestination.parentNode) {
              if ( (myDestination.parentNode != myEl) && (myDestination != myEl) ) {
		 if (document.getElementById('editIcon')) {
		   myEl.removeChild(document.getElementById('editIcon'));
		 }
              }
           } 
	}
}

function SetUrl( url ) {
	 var $dest_url = '/cms/inlineadmin/'+il_article+'?action=addfile&file='+url+'&uri='+il_uri+'&uri302='+il_302;
         try {
            window.parent.location = $dest_url;
         }
         catch(exception)
         {  if ( thisWindow ) {
               thisWindow.location = $dest_url;
            }
            if ( exception.description == null ) {
               // alert("Error is "+exception.message);
            }
            else {
                //alert("Error is "+exception.description); 
            }
         }
         return;
}

function unlinkFile( url, il_uri, il_302, il_article ) {
	 var $dest_url = '/cms/inlineadmin/'+il_article+'?action=delfile&file='+url+'&uri='+il_uri+'&uri302='+il_302;
	 window.parent.location = $dest_url;
}

function docPopUp (alias, il_uri, il_302, il_article, title, position ) {
	 
	 
	sH=screen.height - 16;
	sW=screen.width - 16;
	
	myPopUp = document.getElementById("popOverHelp");

	if (!myPopUp) {
		popOverHelp = document.createElement("div");
		popOverHelp.setAttribute("id","popOverHelp");
		popOverHelp.onclick = Function("hidePopOverHelp(document);");

		document.getElementsByTagName("body")[0].appendChild(popOverHelp);
		myPopUp = document.getElementById("popOverHelp");
	} else {
		while (myPopUp.childNodes.length > 0) {
			myPopUp.removeChild(myPopUp.childNodes[myPopUp.childNodes.length - 1]);
		}
	}

        myPopUp.style.backgroundColor = '#eeeeee'; 
        myPopUp.style.border = '1px ridge lightgrey'; 
        myPopUp.style.width = '62px';

	containerDiv = document.createElement("div");
	containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:61px;height:auto;vertical-align:middle;margin:0px 0px 0px 0px;padding:0px;");
	myPopUp.appendChild(containerDiv);
	
	span1 = document.createElement("span");
	span1.setAttribute("style","width:61px;height:auto;position:relative;float:left;margin:0px 2px 0px 0px;padding:2px 0px 2px 0px;cursor:pointer;");
	anchor1 = document.createElement("a");
	anchor1.setAttribute("href", "#");
	anchor1.onclick=Function("document.getElementById('formFileEdit"+position+"').btnEditFile"+position+".click();");
	text1 = document.createTextNode("Edit");

	anchor1.className = 'popupItem';
        anchor1.style.width = '60px';


	anchor1.appendChild(text1);
	span1.appendChild(anchor1);
	containerDiv.appendChild(span1);

	containerDiv = document.createElement("div");
	containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:61px;height:auto;vertical-align:middle;margin:0px 0px 0px 0px;padding:0px;");
	myPopUp.appendChild(containerDiv);
	
	span1 = document.createElement("span");
	span1.setAttribute("style","width:61px;height:auto;position:relative;float:left;margin:0px 2px 0px 0px;padding:2px 0px 2px 0px;cursor:pointer;");
	anchor1 = document.createElement("a");
	anchor1.setAttribute("href", "#");
	anchor1.onclick=Function("if ( delFileConfirm('"+title+"')  == true ) { unlinkFile('"+alias+"','"+il_uri+"','"+il_302+"','"+il_article+"')};");
	text1 = document.createTextNode("Remove");

	anchor1.className = 'popupItem';
        anchor1.style.width = '60px';

	anchor1.appendChild(text1);
	span1.appendChild(anchor1);
	containerDiv.appendChild(span1);

	containerDiv = document.createElement("div");
	containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:61px;height:auto;vertical-align:middle;margin:0px 0px 0px 0px;padding:0px;");
	myPopUp.appendChild(containerDiv);
	

	containerDiv = document.createElement("div");
	containerDiv.setAttribute("style", "position:relative;float:left;clear:both;width:61px;height:auto;vertical-align:middle;margin:0px 0px 0px 0px;padding:0px;");
	myPopUp.appendChild(containerDiv);

	span1 = document.createElement("span");
	span1.setAttribute("style","width:61px;height:auto;position:relative;float:left;margin:0px 2px 0px 0px;padding:2px 1px 2px 0px;cursor:pointer;");
	anchor1 = document.createElement("a");
	anchor1.setAttribute("href", "#");
	anchor1.onclick=Function("doFileUploadPopUp('"+alias+"','"+title+"');");
	text1 = document.createTextNode("Replace");

	anchor1.className = 'popupItem';
        anchor1.style.width = '60px';

	anchor1.appendChild(text1);
	span1.appendChild(anchor1);
	containerDiv.appendChild(span1);	 

	myPopUp.appendChild(containerDiv);

}

function popupform(myform, windowname) {
   if (! window.focus) return true;
   window.open('', windowname, 'top=20px, left=20px, width=600px, height=545px, scrollbars=no, resizable=yes');
   myform.target=windowname;
  return true;
}

function OnUploadSubmit() {
   if ( document.getElementById('NewFile').value.length == 0 )	{
	alert( 'Please select a file from your computer' ) ;
	return false ;
   }

   // Set the interface elements.
   document.getElementById('eUploadMessage').innerHTML = 'Upload a new file in this folder (Upload in progress, please wait...)' ;
   document.getElementById('btnUpload').disabled = true ;
	
   return true ;
}

function OnUploadCompleted( errorNumber, fileName ) {
	
	// Reset the upload form (On IE we must do a little trick to avout problems).
	if ( document.all )
		document.getElementById('NewFile').outerHTML = '<input id="NewFile" name="NewFile" style="WIDTH: 100%" type="file">' ;
	else
		document.getElementById('frmUpload').reset() ;
	
	// Reset the interface elements.
	document.getElementById('eUploadMessage').innerHTML = 'Upload a new file in this folder' ;
	document.getElementById('btnUpload').disabled = false ;
	
	switch ( errorNumber )	{
		case 0 :
			window.parent.frames['frmResourcesList'].Refresh() ;
			break ;
		case 201 :
			window.parent.frames['frmResourcesList'].Refresh() ;
			alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ;
			break ;
		case 202 :
			alert( 'Invalid file' ) ;
			break ;
		default :
			alert( 'Error on file upload. Error number: ' + errorNumber ) ;
			break ;
	}
}

function doFileUploadPopUp(alias,title) {
      sH=screen.height - 16;
      sW=screen.width - 16;
 
      var myPopUpWin = window.open('', 'fileUploadwin', 'top=200px, left=200px, width=450px, height=100x, status=no; scrollbars=no, resizable=no');
      myPopUpWin.document.write( startUploadDoc() );
      myPopUpWin.document.write('<fieldset style="position:relative;float:left;clear:both;width:98%;padding:2px;"><legend style="border:1px solid darkgrey;font-weight:bold;padding:2px;background-color:lightgrey;">'+title+'</legend>');
      myPopUpWin.document.write('<span style="position:relative;clear:both;float:left;">Select a replacement file to upload</span><br/>');
 
      myPopUpWin.document.write('<form method="POST" style="display:block;" name="frmUpload" id="frmUpload" action="/cms/document" enctype="multipart/form-data">'+"\n");

      myPopUpWin.document.write('<input type="hidden" name="Command" value="FileUpload"/>'+"\n");
      myPopUpWin.document.write('<input type="hidden"  name="replace" value="'+alias+'"/>'+"\n");
      myPopUpWin.document.write('<input type="file" size="30" name="NewFile" id="NewFile" style="width:75%;position:relative;float:left;clear:none;"/>'+"\n");
      myPopUpWin.document.write('<input type="submit" name="btnUpload" id="btnUpload" value="Replace File" style="width:20%;position:relative;float:clear:none;right;" onclick="if ( document.getElementById('+"'NewFile'"+').value.length == 0 ){alert( '+"'Please select a file from your computer'"+' );return false;}return true;"/>'+"\n");
      myPopUpWin.document.write('</form></fieldset>');

      myPopUpWin.document.write( endpopupDoc() );
      myPopUpWin.document.close();
}	 

function startUploadDoc() {
	 return '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">'+"\n"+'<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">'+"\n"+'<link rel="stylesheet" href="/global/css/main.css" />'+"\n"+'<title>File Upload</title></head>'+"\n"+'<body><div id="upload" style="padding:2px;">';
};

function endpopupDoc() {
	 return '</div></body></html>';
};

