/* Copyright IBM Corp. 2007, 2009  All Rights Reserved.              */

/* 5724-S31                                                          */
/* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */
/*                                                                   */
/*********************************************************************/


/*supporting util to show quickr stuff*/
QuickrSetupSupportUtil = {

	currentPageType: "list.htm",

	init: function()
	{
		//override the css stuff for the OneUI
		QuickrLocaleUtil.loadCssFiles("/qphtml/skins/iris82setup", "setup.css");

		//load js extension file
		QuickrGeneralUtil.loadSupplementalScript("/qphtml/skins/iris82setup/scripts/setup_ext.js");
		
		if (typeof(dojo) !="undefined") {
			dojo.addOnLoad(function(){
				QuickrSetupSupportUtil.massageUi();

			});
		}
	},
	

	massageUi: function ()
	{
		try {
			//clean up the body tag
			document.body.removeAttribute("class");
			
			
			// Show TOC if not empty
			var tocList=document.getElementById("tocList");
			if (tocList) {
				var tocItems=tocList.getElementsByTagName("li");

				var bShowTocList = 0;
				for (var i = 0; i < tocItems.length; ++i) {
					var item = tocItems[i];
					var aNode = item.childNodes[0];
					if (aNode) {
						var divNode = aNode.childNodes[0];
						if (divNode) {
							if (divNode.style == undefined) {
								bShowTocList = 1;
							}
							else if (divNode.style.display == "block") {
								bShowTocList = 1;
							}
						}
					}
				}

				if (tocItems.length>0 && bShowTocList) {
					var toc = document.getElementById("menu1");
					toc.style.display="block";
				}
			}			
			
			if (G_MyFilesUiEnabled == "false") {
				var linkPlaces = null;
				var linkFiles = null;
				if ((linkFiles=document.getElementById("typeFiles")) != null)
					linkFiles.style.visibility="hidden";
				// Hide the Places link since it serves no purpose without the 
				// files UI to link back from.
				if ((linkPlaces=document.getElementById("typePlaces")) != null)
					linkPlaces.style.visibility="hidden";			
			}

			if (this.currentPageType == "list.htm") {
			
			
				var navBot=document.getElementById("pageContentNavBot");
				if (navBot) {
					QuickrGeneralUtil.addIESpacingHack(navBot, "li");  //hack to get the spacing right
				}

				if (h_SetReadScene.indexOf("h_MyPlaces")>-1) {
					navBot.style.display="block";
				}
				else {
					var actions=document.getElementById("actions");
					if (actions) actions.style.display="block";
				}

				if (typeof(G_LdapSearchUIHint) != "undefined" && G_LdapSearchUIHint != null) {
					var elHint = document.getElementById("memberAddHint");
					if (elHint) {
						elHint.innerHTML = G_LdapSearchUIHint;
					}
				}


				var pTab=document.getElementById("placesTab");
				var sTab=document.getElementById("statsTab");
				if (pTab && sTab) {
					// Change test of usage stats because this SC does not respect replaceString
					var sTabA=sTab.getElementsByTagName("a");
					if (sTabA.length>0)
						sTabA[0].innerHTML=QuickrLocaleUtil.getStringResource("PAGE.USAGESTATISTICS");
					// Select correct places tab
					if (location.href.indexOf("MyPlacesDetails")>-1) {
						pTab.className="";
						sTab.className="lotusSelected";
					}
					else {
						sTab.className="";
						pTab.className="lotusSelected";
					}
				}


				if (h_SetReadScene == "h_MyPlacesList")
					QuickrGeneralUtil.showClassesIfTrue("lotusInfoBox", true );

				
			}
			else if (this.currentPageType == "edit.htm") {


				if (typeof(h_StepNumber) != "undefined") {
					if ((h_StepNumber == 2) && (h_SetEditNextScene == ""))
						QuickrGeneralUtil.showClassesIfTrue("lotusInfoBox", true );

					if ((h_StepNumber == 2) && (h_SetEditNextScene == "h_CreateAnimation"))
						QuickrGeneralUtil.hideClassesIfTrue("lotusHeader", true );
				}


			}
			else if (this.currentPageType == "page.htm") {


				if(h_SetReadScene =="h_AdminInstructions") {
					var siteadmin = document.getElementById("siteadmin");
					siteadmin.style.display="block";
				}
				
				//bidi support for the bullet images
				switch (h_SystemName) {
					case "h_AdminInstructions":

						if (document.body.dir == 'rtl') {
							elImgs = document.images;
							if (elImgs && elImgs.length > 0) {
								for (var ii = 0; ii < elImgs.length; ii++) {
									if (elImgs[ii].src.indexOf("silverbullet.gif") > -1) {
										if (elImgs[ii].src.indexOf("/") == 0) {
											elImgs[ii].src =elImgs[ii].src.replace(/silverbullet.gif/,"silverbullet_rtl.gif");
										} else {
											elImgs[ii].src = "/qphtml/html/common/silverbullet_rtl.gif";
										}
									}
								}
							}
						}
						
					
						

						break;
				
				}				


			}




			var SC_connDL = qp_getElementsByClassName("SC_conn_dl");
			var connDLs = qp_getElementsByClassName("conn_dl");
			if (SC_connDL) {
				for (var i = 0; i < connDLs.length; i++) {
					connDLs[i].href = SC_connDL[0].href;
				}
			}


			QuickrSetupUtil.showQuickrContent();

			QuickrGeneralUtil.hideClassesIfTrue("ConnectorSection", !h_ClientBrowser.isPlatformWin() );

			//SPR #LWOY7BZVQQ
			if (currentUserAccess >= 6)
				QuickrGeneralUtil.showClassesIfTrue("qpAdmin", true );



			var pNode = document.getElementById('pageTitlePlaces');
			var fNode = document.getElementById('pageTitleFiles');

			QuickrSetupUtil.fixPageTitle(pNode, 'PAGE.PLACES');
			QuickrSetupUtil.fixPageTitle(fNode, 'PAGE.FILES');			
			

			this.showMainFrame();
		}
		catch (e) {
			this.showMainFrame();
		}
	},
 
	showMainFrame: function() {
		// outermost tag in body
		var frame = dojo.byId("lotusFrame");
		if (frame) {
			frame.style.display = "block";
		}	
	}
}

