
	//toggles the key on the report pages
    function toggleKey()
    {
      if ( document.all['key'].style.display == "inline" )
      {
        document.all['key'].style.display = "none";

        document.ShowHideKey.src = "../../images/showHideKeyDown.gif";
      }
      else
      {
        document.all['key'].style.display = "inline";    

          document.ShowHideKey.src = "../../images/showHideKey.gif";
      }
    }

	function toggleTOC(TOC)
	{
		if ( document.getElementById(TOC).style.display == "inline" )
		{
			document.getElementById(TOC).style.display = "none";

			document.ShowHide.src = "../../images/showHideDown.gif";
		}
		else
		{
			document.getElementById(TOC).style.display = "inline";    

			document.ShowHide.src = "../../images/showHide.gif";
		}
	}

    var toggleAllJurisdictionOnOff = '0';

    function selectAllJurisdictions()
    {
      if (toggleAllJurisdictionOnOff=='0')
      {
        toggleAllJurisdictionOnOff = '1';
        setAllJurisdictions(true);
      }
      else
      {
        toggleAllJurisdictionOnOff = '0';
        setAllJurisdictions(false);
      }
    }

    function setAllJurisdictions(flag)
    {
      document.MultiForm.selectAllJurisdictionsBox.checked = flag;

      var allJurisdictions = document.MultiForm.Jurisdictions;

      if(allJurisdictions==null) return;

      //have to test if allJurisdictions is obj or an array first will fail if array single message
      allJurisdictions.checked=flag;

      //array e.g more than one message
      for(var i=0;i<allJurisdictions.length;i++)
      {
        allJurisdictions[i].checked =flag;
      }
    }



    var toggleAllQuestionOnOff = '1';

    function selectAllQuestions(groupID)
    {
  	  if (toggleAllQuestionOnOff=='0')
	  {
	  	toggleAllQuestionOnOff = '1';
	  	setAllQuestions(true, groupID);
	  }
	  else
	  {
	  	toggleAllQuestionOnOff = '0';
	  	setAllQuestions(false, groupID);
	  }
    }

    function setAllQuestions(flag, groupID)
    {
	  if (groupID == null || groupID == '')
	  {
		document.MultiForm.selectAllQuestionsBox.checked = flag;

		var allQuestions = document.MultiForm.Questions;
		
		var allQuestionsGroups = document.MultiForm.QuestionsGroups;

		if(allQuestions==null && allQuestionsGroups==null) return;

		//have to test if allQuestions is obj or an array first will fail if array single message
		if(allQuestions!=null) {
			allQuestions.checked=flag;
			//array e.g more than one message
			for(var i=0;i<allQuestions.length;i++)
			{
				allQuestions[i].checked =flag;
			}
		}
		
		if(allQuestionsGroups!=null) {
			allQuestionsGroups.checked=flag;
			//array e.g more than one message
			for(var i=0;i<allQuestionsGroups.length;i++)
			{
				allQuestionsGroups[i].checked =flag;
			}
		}
	  }
	  else
	  {
	    var QuestionsGroupID = 'QuestionsGroups_' + groupID;
		document.all[QuestionsGroupID].checked = flag;

		var allQuestionsGroupQuestions = document.all[groupID];

		if(allQuestionsGroupQuestions==null) return;

		//have to test if allQuestions is obj or an array first will fail if array single message
		allQuestionsGroupQuestions.checked=flag;

		//array e.g more than one message
		for(var i=0;i<allQuestionsGroupQuestions.length;i++)
		{
			allQuestionsGroupQuestions[i].checked =flag;
		}
      }
    }






    function OrangeTriangleToggle(id,mode)
    {
      // check getElementById function is supported 
      
      if(document.getElementById)
      {
        var objImg, strImg;
		
        // find element
        if (document.getElementById(id)!=null)
        {
          objImg = document.getElementById(id);
          objImg.src = '../../images/orangeTriangle'+mode+'.gif';
        }
        else
        { 
          // element not found
        }
     }
     else
     {
       // getElementById function not supported
       strImg = id;
       document[strImg].src =  '../../images/orangeTriangle'+mode+'.gif';
     }
   }


    var TermsWindow;

    function TermsPopUp()
    {
      if ( ! TermsWindow || TermsWindow.closed )
      {
        TermsWindow = window.open("../../nonindexed/sitetext/TermsPopUp.htm", "myNewTermsWin", "toolbar=no,location=no,scrollbars=yes,resizable=no,width=400,height=600,left=60,top=60");
      }

      TermsWindow.focus();
    }


    var PrivacyPolicyWindow;

    function PrivacyPolicyPopUp()
    {
      if ( ! PrivacyPolicyWindow || PrivacyPolicyWindow.closed )
      {
        PrivacyPolicyWindow = window.open("../../nonindexed/sitetext/PrivacyPolicyPopUp.htm", "myNewPrivacyWin", "toolbar=no,location=no,scrollbars=yes,resizable=no,width=400,height=600,left=80,top=80");
      }

      PrivacyPolicyWindow.focus();
    }

	var LinkToPopupWindow1;
    
        function LinkToPopupWindow(url,width,height,showMenuBar)
        {
         
		 if (!LinkToPopupWindow1 || LinkToPopupWindow1.closed )
			{

				if (width!=null&& height!=null && showMenuBar !=null)
				{
					LinkToPopupWindow1 = window.open(url,'myWindow','toolbar=0,scrollbars=1,location=0,statusbar=0,resizable=1,width='+ width + ',height='+ height+ ',menubar=' +showMenuBar);

				}
				else
				{
					LinkToPopupWindow1= window.open(url,'myWindow','toolbar=0,scrollbars=1,location=0,statusbar=0,resizable=1');
				}			
				LinkToPopupWindow1.focus();
			}	
	}


    var LoginHelpWindow;

    function LoginHelpPopUp()
    {
      if ( ! LoginHelpWindow || LoginHelpWindow.closed )
      {
        LoginHelpWindow = window.open("../../dynamic/login/loginHelpPopUp.aspx", "myNewLoginHelpWin", "toolbar=no,location=no,scrollbars=yes,resizable=no,width=400,height=150,left=80,top=80");
      }

      LoginHelpWindow.focus();
    }


    var notesWindow;

    function NotesPopUp( theNote )
    {
      if ( ! notesWindow || notesWindow.closed )
      {
        notesWindow = window.open("", "myNewWin", "toolbar=no,location=no,scrollbars=yes,resizable=no,width=300,height=200,left=20,top=20");
      }

      notesWindow.document.open();

      notesWindow.document.write( theNote );

      notesWindow.document.close();
      
      notesWindow.focus();
    }
    
    
    var DefinitionsWindow;

    var PreviousDefinitionsInWindow = "none";

    function DefinitionsPopUp( whichDefinitions, whichEntry )
    {
    
      if ( ! DefinitionsWindow || DefinitionsWindow.closed )
      {
        // WINDOW IS NOT USED YET, OR HAS BEEN CLOSED

        PreviousDefinitionsInWindow = NewDefinitions; // remember which definitions we are showing!

        // just open it and scroll to correct entry
        DefinitionsWindow = window.open("../../nonindexed/singlejurisdiction/" + whichDefinitions + "_definitions.htm#" + whichEntry, "myNewDefinitionsWin", "toolbar=no,location=no,scrollbars=yes,resizable=no,width=370,height=400,left=20,top=250");
      }
      else
      {
        // WINDOW IS ALREADY OPEN
        
        // ARE THE CORRECT DEFINITIONS LIST ON DISPLAY?

        var NewDefinitions = whichDefinitions; // e.g. "EnglandWales"

        if ( NewDefinitions == PreviousDefinitionsInWindow )
        {
          // just scroll to the relevant definition
          DefinitionsWindow.focus();
          DefinitionsWindow.location.hash = whichEntry;          
        }
        else
        {
          // CLOSE AND RE-OPEN WINDOW

          DefinitionsWindow.close();
        
          // update record of which definitions are currently showing!
          PreviousDefinitionsInWindow = NewDefinitions;
        
          // open and scroll to entry
          DefinitionsWindow = window.open("../../nonindexed/singlejurisdiction/" + whichDefinitions + "_definitions.htm#" + whichEntry, "myNewDefinitionsWin", "toolbar=no,location=no,scrollbars=yes,resizable=no,width=370,height=400,left=20,top=250");
        }
      }
    }
    
    var BackgroundPagesDefinitionsWindow;

    var PreviousBackgroundPagesDefinitionsInWindow = "none";

    function BackgroundPagesDefinitionsPopUp( whichDefinitions, whichEntry )
    {
    
      if ( ! BackgroundPagesDefinitionsWindow || BackgroundPagesDefinitionsWindow.closed )
      {
        // WINDOW IS NOT USED YET, OR HAS BEEN CLOSED

        PreviousBackgroundPagesDefinitionsInWindow = NewDefinitions; // remember which definitions we are showing!

        // just open it and scroll to correct entry
        BackgroundPagesDefinitionsWindow = window.open("../../nonindexed/sitetext/" + whichDefinitions + "_definitions.htm#" + whichEntry, "myNewDefinitionsWin", "toolbar=no,location=no,scrollbars=yes,resizable=no,width=370,height=400,left=20,top=250");
      }
      else
      {
        // WINDOW IS ALREADY OPEN
        
        // ARE THE CORRECT DEFINITIONS LIST ON DISPLAY?

        var NewDefinitions = whichDefinitions; // e.g. "EnglandWales"

        if ( NewDefinitions == PreviousBackgroundPagesDefinitionsInWindow )
        {
          // just scroll to the relevant definition
          BackgroundPagesDefinitionsWindow.focus();
          BackgroundPagesDefinitionsWindow.location.hash = whichEntry;          
        }
        else
        {
          // CLOSE AND RE-OPEN WINDOW

          BackgroundPagesDefinitionsWindow.close();
        
          // update record of which definitions are currently showing!
          PreviousBackgroundPagesDefinitionsInWindow = NewDefinitions;
        
          // open and scroll to entry
          BackgroundPagesDefinitionsWindow = window.open("../../nonindexed/sitetext/" + whichDefinitions + "_definitions.htm#" + whichEntry, "myNewDefinitionsWin", "toolbar=no,location=no,scrollbars=yes,resizable=no,width=370,height=400,left=20,top=250");
        }
      }
    }
    
    function jurisdictionClicked (jurisdictionID, filename, popup)
    {
        // user selected a country from right hand panel      
            
        var url = "../../dynamic/statistics/jurisdictionhit.aspx?jurisdiction=" + jurisdictionID + "&file=" + filename + "&comments=yes";
    	
    	//handle hashes (#)
    	url = url.replace('#', '%23');
    	
		if (popup)//if boolean is equal to true (fed through from DynamicText.xsl
		{
			BackgroundPagesPopUpWindow = window.open(url, "BackgroundPagesPopUpWindow", "toolbar=no,location=no,scrollbars=yes,resizable=no,width=700,height=500,left=20,top=250");
			BackgroundPagesPopUpWindow.focus();
		}
		else //else open in existing window
		{
			location = url;
		}
    }
    
    function jurisdictionClickedTemplated (jurisdictionID, filename)
    {
        // user selected a country from right hand panel      
        
        var comments = "no";
        
        if (document.forms['X'].elements['ShowCandQ'].checked) comments = 'yes';
    
        var url = "../../dynamic/statistics/jurisdictionhit.aspx?jurisdiction=" + jurisdictionID + "&file=" + filename + "&comments=" + comments;
		//handle hashes (#)
		url = url.replace('#', '%23');    
        location = url;
    }
    
    function homePageToggle(id, divID)
    {
      if ( document.all[divID].style.display == "inline" )
      {
        document.getElementById(divID).style.display = "none";
		document.getElementById(id).src = "../../images/KeyEventsPlus.gif";
      }
      else
      {
        document.getElementById(divID).style.display = "inline";
        document.getElementById(id).src = "../../images/KeyEventsMinus.gif";
      }
    }
    
    	
	var rssXMLHttp;		

	//get the xmlHTTP object to send and receive data
	function GetRssXmlHttpObject()
	{
		xmlHttp = null;
		try
		{
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
		}
		catch (e)
		{
		// Internet Explorer
		try
			{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			}
		catch (e)
			{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		return xmlHttp;
	}

	//feed group number to send to dynamic page
	//to only process specified feed group
	var feedGroupNumber

	function getRSS(number)
	{
		//assign feed group number
		feedGroupNumber = number;
		rssXMLHttp = GetRssXmlHttpObject();
		//rssXMLHttp.onreadystatechange = rssStateChanged;
		
		//wait for response before proceeding to ensure each feedgroup is 
		//processed before moving on to the next one
		rssXMLHttp.open("GET", "../../dynamic/rssfeeds/RSSFeed.aspx?group=" + number, false);
		rssXMLHttp.send(null);
		
		//display results of results
		document.getElementById("rss_" + feedGroupNumber).innerHTML = rssXMLHttp.responseText;
	}
	
	/*	Not currently used
	
	function rssStateChanged() 
	{ 
		if (rssXMLHttp.readyState == 4)
		{
			document.getElementById("rss_" + feedGroupNumber).innerHTML = rssXMLHttp.responseText;
		}
	}  	
	
	*/

