﻿// JScript File


		///////////////////
		// Member variables
		var m_bIsEmbedded = false; // assume the page is being loaded from the CHM file
        var m_strOriginalValue = "";
	    var m_firstCall = true;
	
        //code added by mashrur on 13/04/07 starts here       
        var m_divFilterHover = "divFilterHover"; //Default style class, which was written previously.
        var m_divFilterImgHover = "divFilterImgHover"; //Default style class, which was written previously.
        var m_divFilter = "divFilter"; //Default style class, which was written previously.
        var m_divFilterImg = "divFilterImg"; //Default style class, which was written previously.
        
        
        var m_strSelExpand = "Select to expand";
        var m_strSelExpand_clause = ""
        var m_strSelContract = "Select to contract";
        var m_divFilterImgA = "divFilterImgCWa";
        var m_divFilterImgB = "divFilterImgCWb";
        
        var m_str_alphabets = "1ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        var m_start = true;
        //code added by mashrur on 13/04/07 ends here.
        
        //CC 6/2/08 - Added transparent image code to allow drag 'n' drop in Scheduler
        var m_elemTransp; // transparent image used for drag and drop
        var m_elemPrev; // previous row selected
        var m_strUID; //Holds the UID of the product the transparent image is over
        
		////////////////////
		// SHARED METHODS //
		////////////////////
		
		//Used on Home page to give user name field the focus
		function Main()
        {
            // If the username field exists then give the focus to this
            var inpUserName = document.getElementById("inpUserName");
            if(inpUserName)
            {
                inpUserName.select()
                inpUserName.focus()
            }
        }

		// Optionally used constructor when the page is trapped in a product (Scheduler/Building)
		function SetIsEmbedded()
		{
			m_bIsEmbedded = true;
		}
		
		// code added by mashrur on 13/04/07 starts here 
		// Optionally used function when the page uses modified styles
		function SetAZStyle()
		{
			m_divFilterHover = "divFilterHoverAZ";
			m_divFilterImgHover = "divFilterImgHoverAZ";
			m_divFilter = "divFilterAZ";
			m_divFilterImg = "divFilterImgAZ";
		}
		
		function SetCWStyle()
		{
			m_divFilterHover = "divFilterHoverCW";
			m_divFilterImgHover = "divFilterImgCW";
			m_divFilter = "divFilterCW";
			m_divFilterImg = "divFilterImgCW";
			m_strSelExpand = "Select to show all work sections in this group";
			m_strSelExpand_clause = "Select to show clauses in this work section";
			
		}
		//code added by mashrur on 13/04/07 ends here. 
		
		
		// CC 20/02/2008
		// Called from Scheduler to change the text on product buttons
		function SetPlusButton(strSelectedItemType, strSelectedItemTitle, strSelectedConstructionNumber)
		{
			if(strSelectedItemType=="WItm" || strSelectedItemType == "WProp")
			{
			    // Add after #work item
			    var arrButtons = document.getElementsByTagName("input");
			    for (var x in arrButtons)
                {
                    if(arrButtons[x].type == "button")
                    {
                        arrButtons[x].disabled = false
                        arrButtons[x].value = "Add after " + strSelectedItemTitle;
                    }
                }
			}
			else if(strSelectedItemType == "Cons" || strSelectedItemType == "CProp")
			{
			    // Add to #construction
			    var arrButtons = document.getElementsByTagName("input");
			    for (var x in arrButtons)
                {
                    if(arrButtons[x].type == "button")
                    {
                        arrButtons[x].disabled = false
                        arrButtons[x].value = "Add to " + strSelectedConstructionNumber + " " + strSelectedItemTitle;
                    }
                }
			}
			else
			{
			    // Default: Add to Schedule
			    // Disable button?
			    var arrButtons = document.getElementsByTagName("input");
			    for (var x in arrButtons)
                {
                    if(arrButtons[x].type == "button")
                    {
                        arrButtons[x].value = "Add to Schedule"
                        arrButtons[x].disabled = true
                    }
                }
			}
		}

		function AddToMyDoc(value, ris, productTitle)
		{
		    var strXML = "";	
		    var elemXML, elemInp;
		    
			elemXML = document.getElementById("xmlisland"+value);
			elemInp = document.getElementById("input"+value);
								
			// to work with the web stats - differ from product page
			productTitle = productTitle + "_Add"; 
						
			if (elemXML && elemInp)
			{
			    strXML = elemXML.xml;
			    // we have the objects - things should be fine
			    if (m_bIsEmbedded)
			    {	
					// transfer the XML to a simple input element
					elemInp.value = strXML;
					// call the parent and tell them things are ready
					window.external.AddToSpec(value);
					AttemptLog(productTitle, ris, "ProductAdd");
				}
				else
				{
				    var bResult = false; // assume it hasn't worked
		            bResult = window.clipboardData.setData("Text", strXML); // this returns true on success
		            if(bResult)
		            {
		                alert("The product has been copied to the clipboard.\n\nPlease right click in your Section Editor and select 'Paste NBS Plus'.");
		                AttemptLog(productTitle, ris, "ProductAdd");
		            }
		            else
		            {
		                alert("Sorry, there was an error copying the data to the clipboard.");
		            }
				}
			
			}
			else
			{
				// There has been a problem (should never happen)
				alert("Error: There has been a problem extracting the product data from the page");
			}		
			
		}


        function NavigateToWebsite(url, ris, pageId, isPS)
        {
            // navigate to website
            if(url.length>4)
            {
                if(url.substring(0,4)!="http")
                {
                    // add the http bit
                    url = "http://" + url
                }
                window.open(url, "_blank");
                // Log it
                
                var strActionType;
                if(isPS==true)
                {
                    // if the page is a filename we log the stat as a catalogue
                    if(pageId.indexOf('.') > 0)
                    {
                        strActionType = "CatalogueClick";
                        pageId = pageId + "_Cat"
                    }
                    else
                    {
                        strActionType = "ProductSelectorClick";
                        pageId = pageId + "_PS"
                    }
                }
                else
                {
                    strActionType = "WebSiteClick";
                    pageId = pageId + "_Web"
                }
                AttemptLog(pageId, ris, strActionType);
            }
            else
            {
            alert("It was not possible to navigating to this website");
            }
        }

        function SendEmail(emailAdd, ris, pageId)
        {
            // navigate to website
            if(emailAdd.length>4)
            {
                emailAdd = "mailto://" + emailAdd + "?subject=Enquiry from NBS Plus"
                window.navigate(emailAdd);
                // Log it
                AttemptLog(pageId+"_Email", ris, "EmailClick");
            }
            else
            {
            alert("It was not possible to send this email");
            }
        }

        function AttemptLog(uniquePageId, risCode, pageType)
        {
            // only log visits that come from the online version
            var strURL;
            strURL = document.URL;
            if(strURL.length>4)
            {
                if(strURL.substring(0,4)=="http")
                {
                    // Let's log it
                          xmlHttp=GetXmlHttpObject();
	                      if (xmlHttp==null)
	                      {
		                      // no point in an error message as we should just move on
		                      // user needs to know
		                      // alert ("Browser does not support HTTP Request");
		                      return;
	                      } 
                                                    
                          var myRand=parseInt(Math.random()*99999999); // cache buster

                          var strURL; 
	                      strURL = "AJAXUserClick.aspx";
                      
	                      strURL += "?pageid=" + uniquePageId + "&ris=" + risCode +  "&pagetype=" + pageType + "&rand=" + myRand;
                      
	                      // 3. Set up the event handler
	                      //xmlHttp.onreadystatechange=stateChangedPopulateOne;
                    				
	                      // 4. call the ASP page
	                      xmlHttp.open("GET", strURL, true);
	                      xmlHttp.send(null);	
                
                }            
            }
        }



		///////////////////////////////////////
		// Standard code - a copy and paste job
		function GetXmlHttpObject(handler)
		{ 
			var objXMLHttp=null;
			if (window.XMLHttpRequest)
			{
				// IE7, Mozilla, Safari - a native object NOT ActiveX
				objXMLHttp = new XMLHttpRequest();
			}
			else if (window.ActiveXObject)
			{
				objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			return objXMLHttp;
		}
		
	    //used when we are viewing a product as opposed to a clause
        function ShowClickMessage()
        {
            alert('NBS subscribers will use this button to add your product directly into their specification or schedule of work');
        } 
        
          
        //Link to product selector 
        function ShowProductSelector()
        {
            alert('Within the NBS software clicking this hyperlink\ntakes the user to the relevant page on RIBA Product Selector');
        } 
       

		// This method is used in both the product and manufacturer collection page
		// to show additonal values
		function ExpandProperties(id, strAction)
		{				
			var objDiv=document.getElementById('divHiddenProps' + id);	
//		    if (testBrowserMain() == true)
//		    {
			    if(objDiv)
			    {				
				    if(strAction=='expand')
				    {
					    objDiv.style.display ='block';
				    }
				    else
				    {	
					    objDiv.style.display ='none';
				    }				
    					
				    if (strAction=="expand")
				    {
					    document.getElementById('aContract' + id).style.display = 'inline';
					    document.getElementById('aExpand' + id).style.display = 'none';
				    }
				    else
				    {
					    document.getElementById('aExpand' + id).style.display = 'inline';
					    document.getElementById('aContract' + id).style.display = 'none';
				    }
			    }
//		    }
//		    else
//		    {
//		        objDiv.style.display ='block';
//		        document.getElementById('aExpand' + id).style.display = 'none';
//		        document.getElementById('aContract' + id).style.display = 'none';
//		    }
		}
		
		
		
    function testBrowserMain() 
    {
        if (navigator.appName == "Microsoft Internet Explorer")             //test the application name
            return true;
        else
            return false;
    }
		
		
		function ShowToBeImplemented()
		{
			alert("This page is not part of the prototype or has not been implemented yet");
		}
		
		
		//////////////////////////////////////////
		// MANUFACTURER COLLECTION PAGE METHODS //
		//////////////////////////////////////////		
         
     function ClickMe()
    {
        alert("Not implemented yet");
    }
   
    function MCTRMouseOver(elem)
    {
        if(elem)
        {
            elem.style.backgroundColor = "#f2f2f2";

        }            
    }
    
    function MCTRMouseOut(elem)
    {
        if(elem)
        {
            elem.style.backgroundColor = "#ffffff";
        }
    }

		
		/////////////////////////////////////
		// PRODUCT COLLECTION PAGE METHODS //
		/////////////////////////////////////
		
		
		// Change the button text if the user wants a different number
		function ChangeClauseNumber(value)
		{
			var elemCNum = document.getElementById("inpCNum"+value);
			var elemCRev = document.getElementById("inpCRev"+value);
			
			if(elemCNum && elemCRev)
			{				
				var strCNum = elemCNum.value;   // Clause number
				var strCRev = elemCRev.value;   // Clause revision
				
				// Change all clause numbers as the user types
				ChangeAllClauseNumbers(strCNum, strCRev);			
			}
		}
		
		// SJH 07/12/07 -
		// This method is invoked from .Net
		// Example value K21
		function SetHiddenSectionNumber(sectionCodeAndNumber)
		{
		    var elemHiddenWSInput;
		    elemHiddenWSInput = document.getElementById("inpWsIdHidden");
		    if(elemHiddenWSInput)
		    {
		        elemHiddenWSInput.value=sectionCodeAndNumber;
		    }
		}
		
		// AS 08/05/07 -- Set the value of the 2 hidden input boxes to the specifeid values.
		// This method is invoked from .NET
		function SetHiddenClauseNumber(strClauseNumber, strClauseRevision)
		{
		    var elemHiddenInput;            // Hidden element from the DOM
		    var elemUniqueIds;              // List of unique ids
		    var i = 0;                      // Index
		    
		    // Set value of hidden inputs
		    elemHiddenInput = document.getElementById("inpCNumHidden");
		    if (elemHiddenInput)
		    {
		        elemHiddenInput.value = strClauseNumber;
		    }
		    
		    elemHiddenInput = document.getElementById("inpCRevHidden");
		    if (elemHiddenInput)
		    {
		        elemHiddenInput.value = strClauseRevision;
		    }
		    
		    ChangeAllClauseNumbers(strClauseNumber, strClauseRevision);
		}
		
		// AS 09/05/07 -- Changes the text in all the clause number text boxes and on the add buttons
		function ChangeAllClauseNumbers(strClauseNumber, strClauseRevision)
		{
		    var elemUniqueIds;              // List of unique ids
		    var i = 0;                      // Index
		    
		    elemUniqueIds = document.getElementsByName("inpUniqueId");
		    
		    for (i = 0; i < elemUniqueIds.length; i++) 
            {
                var strUniqueId;            // Next unique id
                var elemClauseNumber;       // Clause number element
                var elemClauseRevision;     // Clause revision element
                var elemAddButton;          // Add to document button
			    var elemWsId;               // Worksection id
            
                // Get next unique id
                strUniqueId = elemUniqueIds(i).value;
                
                // Get Clause number and revision
                elemClauseNumber = document.getElementById("inpCNum" + strUniqueId);
                elemClauseRevision = document.getElementById("inpCRev" + strUniqueId);
                elemAddButton = document.getElementById("inpAdd" + strUniqueId);
			    elemWsId = document.getElementById("inpWsIdHidden");
                
                if (elemClauseNumber && elemClauseRevision && elemAddButton && elemWsId)
                {
                    var strNewNumber = "";          // New number - cast to string
				    var strWsId = "";               // Worksection Id - cast to string
				    
                    elemClauseNumber.value = strClauseNumber;
                    elemClauseRevision.value = strClauseRevision;
				    strWsId = elemWsId.value;
				    strNewNumber = strClauseNumber + strClauseRevision;
				    elemAddButton.value = "Add as " + strWsId + " " + strNewNumber;
    				
				    if (strNewNumber=="475"||strNewNumber=="472")
				    {
					    elemAddButton.disabled = true;
				    }
				    else
				    {
					    elemAddButton.disabled = false;
				    }			
			    }
            }
		}
		
		// AS 09/05/07 -- Loop through "add to xxx" buttons and enable or disable them.
		// This method is invoked from .NET
		function DisableButtons(intDisabled)
		{
		    var elemUniqueIds;              // List of unique ids
		    var i = 0;                      // Index
		    
		    elemUniqueIds = document.getElementsByName("inpUniqueId");
		    
		    for (i = 0; i < elemUniqueIds.length; i++) 
            {
                var strUniqueId;            // Next unique id
                var elemAddButton;          // Add to document button
                
                // Get next unique id
                strUniqueId = elemUniqueIds(i).value;
                
                // Get add to button
                elemAddButton = document.getElementById("inpAdd" + strUniqueId);
                
                if (elemAddButton)
                {
                    if (intDisabled == 0)
                    {
                        elemAddButton.disabled = false;
                    }
                    else
                    {
                        elemAddButton.disabled = true;
                    }
                }
            }
		}
		
		// Show/Hide the filters/products
		function ToggleFilter(value)
		{
		    RecordLastClick(value);
			// everything we need to show or hide is in a DIV - just get this and toggle it
			// remember we also must change the tool tip and image too
			var elemDivFilterHolder = document.getElementById("divFilterHolder" + value);
			var elemDivFilter = document.getElementById("divFilter" + value);
			var elemImgFilter = document.getElementById("imgFilter" + value);
			
			var strExpandText = "Select to expand";
			var strContractText = "Select to contract";
			
			if(elemDivFilterHolder && elemDivFilter && elemImgFilter)
			{
				if(elemDivFilterHolder.style.display == "none")
				{
					elemDivFilterHolder.style.display = "block";
					elemDivFilter.title = strContractText;
					elemImgFilter.alt = strContractText;
					elemImgFilter.src = "_Images/filterIcon_minus.gif";
				}
				else
				{
					elemDivFilterHolder.style.display = "none";
					elemDivFilter.title = strExpandText;
					elemImgFilter.alt = strExpandText;
					elemImgFilter.src = "_Images/filterIcon_plus.gif";
				}
			}
		}
	
		// Mouse over filter
		function MouseOverFilter(value)
		{
			var elemDivFilter = document.getElementById("divFilter" + value);
			var elemImgFilter = document.getElementById("divImgFilter" + value);
			var elemImgFolder = document.getElementById("divImgFolder" + value);
			if(elemDivFilter&&elemImgFilter)
			{
				elemDivFilter.className=m_divFilterHover;
				//elemDivFilter.style.background-color = "#F5E0CF";
				elemImgFilter.className=m_divFilterImgHover;
				
				//status="MouseOutFilter m_divFilterHover=" + m_divFilterHover + " - m_divFilterImgHover=" + m_divFilterImgHover;
				
				//This extra folder icon, is only in CAWS page
				if(elemImgFolder!=null)
				{
				    elemImgFolder.className=m_divFilterImgHover;
				}
			}
		}
		
		// Mouse out filter
		function MouseOutFilter(value)
		{
			var elemDivFilter = document.getElementById("divFilter" + value);
			var elemImgFilter = document.getElementById("divImgFilter" + value);
			var elemImgFolder = document.getElementById("divImgFolder" + value);
			if(elemDivFilter&&elemImgFilter)
			{
			    
				elemDivFilter.className=m_divFilter;
				
				if(!isNaN(value))
				{
				    elemImgFilter.className=m_divFilterImg;
				}
				else
				{
				    // nasty fix - too much shared use of this for different purposes
				    // this code is used AZ, CAWS and clause pages
				    // careful with any changes
				    if(value.indexOf("_")==-1)
				    {
				        elemImgFilter.className=m_divFilterImg; // clause page
		                //status="MouseOutFilter (Clause) - value: " + value + " class=" + m_divFilterImgB;
				    }
				    else
				    {
				        elemImgFilter.className=m_divFilterImgB; // az or caws index page
		                //status="MouseOutFilter (AZ) - value: " + value + " class=" + m_divFilterImgB;
				    }
				}
				
				//This extra folder icon, is only in CAWS page
				if(elemImgFolder!=null)
				{
				    elemImgFolder.className=m_divFilterImg;
				}
			}
		}
		
		function ShowScheduler(val)
		{
			if(val=='true')
			{		
				document.getElementById('divBuildingProd').style.display = "none";
				document.getElementById('divSchedulerProd').style.display = "block";
				document.getElementById('pSchedulerSwitch').style.display = "none";
				document.getElementById('pBuildingSwitch').style.display = "block";

			}
			else
			{
				document.getElementById('divBuildingProd').style.display = "block";
				document.getElementById('divSchedulerProd').style.display = "none";
				document.getElementById('pBuildingSwitch').style.display = "none";
				document.getElementById('pSchedulerSwitch').style.display = "block";

			}
		}
		
		
		// code added by mashrur on 05/04/07 starts here
		function ExpandFilter(value)
		{
			// everything we need to show or hide is in a DIV - just get this and toggle it
			// remember we also must change the tool tip and image too
			var elemDivFilterHolder = document.getElementById("divFilterHolder" + value);
			var elemDivFilter = document.getElementById("divFilter" + value);
			var elemImgFilter = document.getElementById("imgFilter" + value);
			var elemImgFolder = document.getElementById("imgFolder" + value);
			
			var strContractText = m_strSelContract;
			
			if(elemDivFilterHolder && elemDivFilter && elemImgFilter)
			{
				
				elemDivFilterHolder.style.display = "block";
				elemDivFilter.title = strContractText;
				elemImgFilter.alt = strContractText;
				elemImgFilter.src = "_Images/filterIcon_minus.gif";
				
				if(elemImgFolder!=null)
				{
				    if(value.length==1)
				    elemImgFolder.src = "_Images/openedFolder.gif";
			    else
				    elemImgFolder.style.display = "inline";
				}
			}
		}
		
		function ContractFilter(value)
		{
		    // everything we need to show or hide is in a DIV - just get this and toggle it
			// remember we also must change the tool tip and image too
			var elemDivFilterHolder = document.getElementById("divFilterHolder" + value);
			var elemDivFilter = document.getElementById("divFilter" + value);
			var elemImgFilter = document.getElementById("imgFilter" + value);
			var elemImgFolder = document.getElementById("imgFolder" + value);
			
			var strExpandText;
			
			if(value.length==1)
			{
			strExpandText = m_strSelExpand;
			}
			else
			{
			strExpandText = m_strSelExpand_clause;
			}
			
			if(elemDivFilterHolder && elemDivFilter && elemImgFilter)
			{
					elemDivFilterHolder.style.display = "none";
					elemDivFilter.title = strExpandText;
					elemImgFilter.alt = strExpandText;
					elemImgFilter.src = "_Images/filterIcon_plus.gif";
					if(elemImgFolder!=null){
					if(value.length==1)
					{
					elemImgFolder.src = "_Images/closedFolder.gif";
										
					}
					}
					
			}
		}
		
		function ExpandAll()
		{
		     var outputSpan;
		     for(i=0;i<28;i++)
		    {
		        ExpandFilter(m_str_alphabets.charAt(i));
		        outputSpan = document.getElementById("spnManufacturers" + m_str_alphabets.charAt(i)); 
		        if (outputSpan && outputSpan.innerHTML == "")
		        {
		            //alert(m_str_alphabets.charAt(i));
		            GetLetterHtml(m_str_alphabets.charAt(i));
		        }
		    }	    
		}
		
		function ContractAll()
		{
		    for(i=0;i<28;i++)
		    {
		        ContractFilter(m_str_alphabets.charAt(i));
		    if ( m_start)
                {
                    j=1;
                    while(document.getElementById("divFilter" + m_str_alphabets.charAt(i)+ j + "a")!=null)
                    {
                        ContractFilter(m_str_alphabets.charAt(i) + j + "a");
                        j++;
                    }
                }
            }
            m_start = false;
		
		}
		// code added by mashrur on 05/04/07 ends here
		
		// Ajax methods added by PW 06/06/07

        var m_strLetter = "";

        function GetLetterHtml(strLetter)

          {
            var outputSpan;
            outputSpan = document.getElementById("spnManufacturers" + strLetter);
            
            RecordLetterClick(strLetter);
            
            if (outputSpan.innerHTML == "" || outputSpan.innerHTML == "Loading...")
            {
                var httpRequest
                // 1. Does the browser support AJAX?		
                httpRequest=GetXmlHttpObject();
                if (httpRequest==null)
                {
	                alert ("Browser does not support HTTP Request");
	                return;
                }
             
                outputSpan.innerHTML = "<span class='spnAJAX'>Loading...</span>";
               
                var strURL;  
                var myRand=parseInt(Math.random()*99999999); // cache buster 
                strURL = "AJAXGetAZManufacturers.aspx";
                strURL += "?Letter=" + strLetter + "&rand=" + myRand;

                // 3. Set up the event handler
                
                httpRequest.onreadystatechange = function() { stateChangedAZ(httpRequest); };
            						
	            // 4. call the ASP page
                httpRequest.open("GET", strURL, true);
                httpRequest.send(null);
             }

        }
            
        function stateChangedAZ(httpRequest)
        {
	        if(httpRequest.readyState==4 || httpRequest.readyState=="complete")
	        { 
		        DisplayAZOutput(httpRequest.responseText);
	        } 
        }

        function DisplayAZOutput(value)
        {		
           var outputSpan;
          //split the response into letter and html
           var temp = new Array();
           temp = value.split('|');
           outputSpan = document.getElementById("spnManufacturers" + temp[0]);
           outputSpan.innerHTML = temp[1];
        }
        
         function GetSectionHTML(strGroup,strSection)

          {
            RecordSectionId(strSection);
            var outputSpan;
            outputSpan = document.getElementById("spnSection" + strGroup + strSection);
            
            if (outputSpan.innerHTML == "" || outputSpan.innerHTML == "Loading...")
            {
                var httpRequest
                // 1. Does the browser support AJAX?		
                httpRequest=GetXmlHttpObject();
                if (httpRequest==null)
                {
	                alert ("Browser does not support HTTP Request");
	                return;
                }
             
                outputSpan.innerHTML = "<span class='spnAJAX'>Loading...</span>";
               
                var strURL;  
                var myRand=parseInt(Math.random()*99999999); // cache buster 
                strURL = "AJAXGetCAWSClauses.aspx";
                strURL += "?Group=" + strGroup + "&Section=" + strSection + "&rand=" + myRand;

                // 3. Set up the event handler
                
                httpRequest.onreadystatechange = function() { stateChangedCAWS(httpRequest); };
            						
	            // 4. call the ASP page
                httpRequest.open("GET", strURL, true);
                httpRequest.send(null);
             }

        }
        
        function stateChangedCAWS(httpRequest)
        {
	        if(httpRequest.readyState==4 || httpRequest.readyState=="complete")
	        { 
		        DisplaySectionOutput(httpRequest.responseText);
	        } 
        }
        
        function DisplaySectionOutput(value)
        {		
           var outputSpan;
           //split the response into section id and html
           var temp = new Array();
           temp = value.split('|');

           outputSpan = document.getElementById("spnSection" + temp[0]);
           outputSpan.innerHTML = temp[1];
        }

        function ShowLargeImage(manFolderName, imageFileName, winTitle, isSyndication)
        {
            // image is never going to larger than 640px wide
            var strHeightWidth = "height=570,width=730,";
            var strURL = "LargeImage.aspx?man=" + manFolderName + "&img=" + imageFileName + "&title=" + winTitle + "&isback=" + isSyndication;
            var objWindow;
            objWindow = window.open(strURL, null, strHeightWidth+"status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=yes,left=100,top=100");
            objWindow.focus();
        }
        
    
    function RecordLastClick(value)
    {
        var objGroupValue=document.getElementById("inpGroupValue");
    	
	    // Toggle item
	    if(objGroupValue)
	    {
	        objGroupValue.value = value;
	    }
    }
    
    function RecordSectionId(value)
    {
    
        var objSectionValue=document.getElementById("inpSectionValue");
    	
	    // Toggle item
	    if(objSectionValue)
	    {
	        objSectionValue.value = value;
	    }
    }
    
    function CAWSPageLoaded()
    {
	    var objGroupValue=document.getElementById("inpGroupValue");
	    var objSectionValue=document.getElementById("inpSectionValue");
    	
	    // If we have a group id and a section id in the save history
	    // then we show it
	    if(objGroupValue && objSectionValue)
	    {
	        var strGroupValue, strSectionValue;
	        strGroupValue = objGroupValue.value;
	        strSectionValue = objSectionValue.value;
	        if(strGroupValue !="" && strSectionValue !="")
	        {
	            var strGroupKey;
	            strGroupKey = strGroupValue.substring(0,1);
    	        ToggleFilter(strGroupKey);
    	        ToggleFilter(strGroupValue);
    	        GetSectionHTML(strGroupKey, strSectionValue);
	        }
	    }	    
    }
    
    function RecordLetterClick(value)
    {
    
        var objAZValue=document.getElementById("inpLetterValue");
    	
	    // Toggle item
	    if(objAZValue)
	    {
	        objAZValue.value = value;
	    }
    }
    
    function AZPageLoaded()
    {
	    var objAZValue=document.getElementById("inpLetterValue");
    	
	    // If we have a letter id in the save history
	    // then we show it
	    if(objAZValue)
	    {
	        var strAZValue;
	        strAZValue = objAZValue.value;
	        if(strAZValue !="")
	        {
    	        ExpandFilter(strAZValue);
    	        GetLetterHtml(strAZValue);
	        }
	    }	    
}

    function CopyProductInformation(ris, productTitle)
    {
    
      var strVal = document.getElementById("TAClauseInfo").innerText;
      
      if (window.clipboardData) {                                     
            window.clipboardData.setData("Text",strVal);   //set the clipboard to the text information passed  
            alert("The product clause has been successfully copied to clipboard.\n\nYou may now paste this into your project specification.");
            AttemptLog(productTitle, ris, "SyndProductCopy");
        } 
    
    return;
}

    // CC 6/2/08 - Added transparent image function to allow drag 'n' drop in Scheduler
    //********* BEGIN 6/2/08
    function TableRowMouseOver(elem, UID)
    {
          m_strUID = UID;
          if(!m_elemTransp)
          {
              m_elemTransp = document.getElementById("TIMG");
              
              // CC 3/11/2009
              // Fix for aardvark issue #17595
              // We're trying to use an element that hasn't been loaded into the dom
              // So, if it's not there just exit the function              
              if(!m_elemTransp)
              {
                return;
              }
          }        
          
          ResetPrevious();
          
          var intLeftOffset = 0;
          var intTopOffset = 0;
          elem.style.backgroundColor = "#FE9900";
          var obj = elem.offsetParent;
          
          do 
          {
			    intLeftOffset += obj.offsetLeft;
			    intTopOffset += obj.offsetTop;
			    obj = obj.offsetParent;
		  } while (obj.offsetParent)

          m_elemTransp.style.left =  intLeftOffset - 1;
          m_elemTransp.style.top = intTopOffset -3;
          m_elemTransp.style.width = elem.scrollWidth +3;
    	  m_elemTransp.style.height = elem.scrollHeight +6;
    	  m_elemPrev = elem;
    	  
    	  m_elemPrev.style.backgroundColor = "#FFFFFF";
    	  
     }
     
     function ResetPrevious()
     {
          if(m_elemPrev)
          {
                m_elemPrev.style.backgroundColor = "#FFFFFF";
                m_elemTransp.style.width = 1;
    		    m_elemTransp.style.height = 1;
          }
     }
     
     function SetBGColour()
     {
          if(m_elemPrev)
          {
                m_elemPrev.style.backgroundColor = "#FE9900";
          }
     
     }
     
     // I'm going to produce a bastardisation of two current methods to add a work item to scheduler:
     // + Button click from NBS Plus
     // + Drag and drop from the library 
     // I pass in the same parameters that are used by the button press to extract the xml data island
     // and prepend this with the drag and drop string
     function SetDragData()
     {
            var strXML = "";	
		    var elemXML;
		    
			elemXML = document.getElementById("xmlisland"+m_strUID);						
						
			if (elemXML)
			{
			    strXML = elemXML.xml;
	            var strData;
                strData = "***NBSOOBJECT***|w|***NBSPLUSONLINE***|" + strXML + "|" + document.URL
                event.dataTransfer.setData("Text", strData);
			}
			else
			{
				// There has been a problem (should never happen)
				alert("Error: There has been a problem extracting the product data from the page");
			}     
     }
     //********* END 6/2/08
     
     /* 
        CC 29/01/2009     
        RPS Catalogue methods */
     
     	// Show/Hide the catalogues
     	// Same function essentially as toggleFilter
     	// but seperated out to keep things simple
		function ToggleCats(value, strFilterCaption)
		{
		
		    RecordLastClick(value);
			// everything we need to show or hide is in a DIV - just get this and toggle it
			// remember we also must change the tool tip and image too
			var elemDivFilterHolder = document.getElementById("divFilterHolder" + value);
			var elemDivFilter = document.getElementById("divFilter" + value);
			var elemImgFilter = document.getElementById("imgFilter" + value);
		
			var strExpandText = "Select to expand";
			var strContractText = "Select to contract";
			
			if(elemDivFilterHolder && elemDivFilter && elemImgFilter)
			{
				if(elemDivFilterHolder.style.display == "none")
				{
					elemDivFilterHolder.style.display = "block";
					elemDivFilter.innerText = "Show only 4 catalogues";
					elemDivFilter.title = strContractText;
					elemImgFilter.alt = strContractText;
					elemImgFilter.src = "_Images/filterIcon_minus.gif";
				}
				else
				{
					elemDivFilterHolder.style.display = "none";
					elemDivFilter.innerText = strFilterCaption;
					elemDivFilter.title = strExpandText;
					elemImgFilter.alt = strExpandText;
					elemImgFilter.src = "_Images/filterIcon_plus.gif";
				}
			} 
		}
