/// <summary>
        /// Loads the UrlSpider
        /// </summary>
        /// <param name="sender"> The sender object.</param>
        /// <param name="e"> The LoadLinksEventArgs.</param>
        private void LoadUrlSpider(object sender, LoadLinksEventArgs e)
        {
            int requestCount = e.Anchors.Count + e.Links.Count +  CurrentResponseBuffer.Scripts.Count;

            //			// enabled url spider commands
            //			if ( requestCount == 0 )
            //			{
            //				// disabled
            //				this.btnOpenTemplate.Enabled = false;
            //				this.btnRunUrlSpider.Enabled = false;
            //			}
            //			else
            //			{
            //				// enabled
            //				this.btnOpenTemplate.Enabled = true;
            //				//this.btnRunUrlSpider.Enabled = false;
            //			}

            urlSpiderControl.SuspendLayout();
            urlSpiderControl.Clear();
            TreeNode frameParent = urlSpiderControl.AddRootNode("Frames");
            TreeNode anchorParent = urlSpiderControl.AddRootNode("Anchor Elements");
            TreeNode linkParent = urlSpiderControl.AddRootNode("Link Elements");
            TreeNode scriptParent = urlSpiderControl.AddRootNode("External Scripts");

            this.urlSpiderControl.ImageList = this.imgIcons;
            anchorParent.ImageIndex = 7;
            anchorParent.SelectedImageIndex = 7;
            linkParent.ImageIndex = 7;
            linkParent.SelectedImageIndex = 7;
            scriptParent.SelectedImageIndex = 7;
            scriptParent.ImageIndex = 7;
            frameParent.ImageIndex = 7;
            frameParent.SelectedImageIndex = 7;

            // new session request collection to add urls
            SessionRequestList urlRequests = new SessionRequestList();
            string url = string.Empty;

            foreach ( HtmlAnchorTag tag in e.Anchors )
            {
                if ( tag.HRef.StartsWith("http") )
                {
                    // add node
                    urlSpiderControl.AddChildren(anchorParent.Index,tag.HRef,tag.HRef,1);

                    // add url request
                    AddUrlRequest(urlRequests,tag.HRef);
                }
            }

            foreach ( HtmlLinkTag tag in e.Links )
            {
                // add node
                urlSpiderControl.AddChildren(linkParent.Index,tag.HRef + " (" + tag.MimeType + ")",tag.HRef,1);

                url = UriResolver.ResolveUrl((Uri)this.CurrentResponseBuffer.ResponseHeaderCollection["Response Uri"],tag.HRef);

                // add url request
                AddUrlRequest(urlRequests,url);
            }

            foreach ( HtmlScript tag in CurrentResponseBuffer.Scripts )
            {
                if ( tag.Source != string.Empty )
                {
                    url = UriResolver.ResolveUrl((Uri)this.CurrentResponseBuffer.ResponseHeaderCollection["Response Uri"],tag.Source);

                    // add node
                    urlSpiderControl.AddChildren(scriptParent.Index,tag.Source,tag.Source,1);

                    // add url request
                    AddUrlRequest(urlRequests,url);
                }
            }

            foreach ( HtmlLinkTag frame in e.Frames  )
            {
                if ( frame.HRef != string.Empty )
                {
                    url = UriResolver.ResolveUrl((Uri)this.CurrentResponseBuffer.ResponseHeaderCollection["Response Uri"],frame.HRef);

                    // add node
                    urlSpiderControl.AddChildren(frameParent.Index,frame.HRef,frame.HRef,1);

                    // add url request
                    AddUrlRequest(urlRequests,url);
                }
            }

            urlSpiderControl.UrlRequests = urlRequests;
            urlSpiderControl.ResumeLayout(true);
        }
 /// <summary>
 /// Loads the links into the URL spider control.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void navForm_LoadLinksEvent(object sender, LoadLinksEventArgs e)
 {
     object[] args = new object[] {sender, e};
     this.Invoke(new LoadLinksEventHandler(LoadUrlSpider), args);
 }
        // Fires when the browser ActiveX control finishes loading a document
        private void OnComplete(IHTMLDocument2 htmlDoc)
        {
            // Adds some event handlers to the DOM Document
            AddEventsToDoc(htmlDoc);

            formCollection = HtmlDomTransformation.TransformFormElements(htmlDoc, new Uri(htmlDoc.location.toString()));
            // FIX: This might be no longer neccesary because
            // it injects code into the document.
            //SetFormOnSubmit(htmlDoc);

            // check if it is NewWindow
            if ( isNewWindow )
            {
                RequestGetEventArgs args = new RequestGetEventArgs();
                args.Url = (string)web.LocationURL;
                args.InspectorRequestAction = InspectorAction.WebBrowserGet;
                this.StartEvent(this, args);

                isNewWindow = false;
            }

            // raise load links event
            if ( LoadLinksEvent != null )
            {
                LoadLinksEventArgs args = new LoadLinksEventArgs();
                args.Frames = HtmlDomTransformation.TransformFrameElements(htmlDoc);
                args.Anchors = HtmlDomTransformation.TransformAnchorElements(htmlDoc);
                args.Links = HtmlDomTransformation.TransformLinksElements(htmlDoc);
                LoadLinksEvent.BeginInvoke(this, args, new AsyncCallback(FireAndForget), null);
            }

            // raise load forms event
            if ( LoadFormsEditorEvent != null )
            {
                // Transform form elements to HTML DOM Document.
                LoadFormsEditorEvent.BeginInvoke(this, new LoadFormsEditorEventArgs(postData, formCollection), new AsyncCallback(FireAndForget),null);
            }

            // reset
            inspectorState = InspectorAction.Idle;
        }