	//VisualVault client scripts (C) 2006 Auersoft

	// load images
	preloadImages();

	var callbackString = '';
	var curElement;
	var ctrlKey = false;
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	var dragType;
	var sourceNode;
	var targetNode;
	var sourceParentNode;
	var tree;
	var progress;
	var selectedNode;
	var lastKeyCode;
	var expandedNodes;
	var checkedNodes;
	var rowsDropDownValue;
	var gridSortField;
	var gridSortDirection;
	var gridDisplayFilter;	
	var gridRowCount;
	var gridPageCount;
	var gridPage;
	var gridRowsPerPage;
	var encodedFormData;	
	var hidingTree = false;
	var setColumnWidth = false;
	var treeColumnWidth;
	var childrenWindows = new Array();
	var postback;
	var updateFilterControl = false;

	//var bFilterTimer = false;
	//var divFilterTimer;
	//detect enter and tab keys for non IE browser
	if (document.layers)
		window.captureEvents(Event.KEYPRESS);

	window.onkeypress = keyHandler;
	window.onbeforeunload = handleOnClose;

	//detect drag event for non IE browser
	if (document.layers)
	{

		if(window.Event){
			document.captureEvents(Event.MOUSEDOWN);
			document.onmousedown=doDragStart;
			document.captureEvents(Event.KEYPRESS);
			document.onkeypress = keyHandler();
			}

	}
		
	function submitEnter(e){

		try {
			if (window.event.keyCode == 13){
				//document.forms(0).submit();
				e.cancelBubble = true;
				e.returnValue = false;
			}
		}
		catch (ex){
			if (e.which == 13){
				//alert('Enter pressed');
				//document.forms(0).submit();
				e.cancelBubble = true;
				e.returnValue = false;
			}
		}
	}
	
	//This event is fired before an action is executed.  This event can be cancelled.
	//Note: The implementation below shows an advanced use of undocumented parameters 
	//(parameters p4,p5,p6,p7,p8 are not public, and are subject to change in future releases)
	//Because these parameters are undocumented and may change in the future, 
	//you should only use them with the understanding that backwards compatibility is not guaranteed.
	function EmailTemplateEditor_BeforeAction(oEditor, actID, oEvent, p4, p5, p6, p7, p8)
	{
		debugger;
		var emailTokenType = "";
		
		if(!oEditor) return;
		
		if(p6 == "select") {
			emailTokenType = p5;
			
			switch (emailTokenType){
				case "User Email Address":
					oEditor.focus();
					var text='[EmailAddress]';
					
					text+=oEditor.getText();
					oEditor.setText(text);
					
					break;			
			}
			
		}
		
		cancelEditorEvent(actID, oEvent);
	}

	function setPopupStatus() {
		if (window.opener) {
			if (document.getElementById('__isPopup')){
				document.getElementById('__isPopup').value = 'true';
			}
		}
	}
	
	//used to determine if popup window opener's need refreshed
	
	function setRefreshOpener(){
	
	 try{
			if (window.opener && !window.opener.closed){	
				if(document.getElementById('__refreshOpener')){
					document.getElementById('__refreshOpener').value=true;
				}	
			}		
	    }
	  catch(e){
	 
	  }
	}
	
	
	function getBrowser() {
		var agt=navigator.userAgent.toLowerCase();
		
		if (agt.indexOf("opera") != -1) return 'Opera';
		if (agt.indexOf("staroffice") != -1) return 'Star Office';
		if (agt.indexOf("webtv") != -1) return 'WebTV';
		if (agt.indexOf("beonex") != -1) return 'Beonex';
		if (agt.indexOf("chimera") != -1) return 'Chimera';
		if (agt.indexOf("netpositive") != -1) return 'NetPositive';
		if (agt.indexOf("phoenix") != -1) return 'Phoenix';
		if (agt.indexOf("firefox") != -1) return 'Firefox';
		if (agt.indexOf("safari") != -1) return 'Safari';
		if (agt.indexOf("skipstone") != -1) return 'SkipStone';
		if (agt.indexOf("msie") != -1) return 'IE';
		if (agt.indexOf("netscape") != -1) return 'Netscape';
		if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
		if (agt.indexOf('\/') != -1) {
			if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
				return navigator.userAgent.substr(0,agt.indexOf('\/'));
			} else return 'Netscape';
		} else if (agt.indexOf(' ') != -1) {
			return navigator.userAgent.substr(0,agt.indexOf(' '));
		} else return navigator.userAgent;
	}
	
	
	
	
	
	
	
	
	
	//call this using the onbeforeunload event of a popup page (setup in page body)
	//use to determine if the parent window needs to be refreshed
	
	//DO NOT MODIFY
	
	function handleOnClose(evt,bAllowLinkToClose) {
	 var refresh; 
	 var checkinForm = false;
	 var e = (window.event) ? window.event : evt;
	 var folderProperties=false; 
	 var mousex = LL_mousex;
	 var mousey = LL_mousey;
	 var url = '';

		
	 if(typeof(e)=='undefined') {
		e = null;
		//e = (window.Event) ? window.Event : evt;
	 }

	  try {
			if (window.location.href.toLowerCase().indexOf('checkin.aspx') > -1) {
				refresh='true';			
			}else if (window.location.href.toLowerCase().indexOf('workflowmanager') > -1) {
				refresh='true';				
				folderProperties=true;
			}else if (window.location.href.toLowerCase().indexOf('wfdesigner') > -1) {			
				folderProperties=true;	
				refresh=document.getElementById('__refreshOpener').value;				
			}else if (window.location.href.toLowerCase().indexOf('childrefresh') > -1) {
				refresh='true';			
			}else if (window.location.href.toLowerCase().indexOf('newtrainingmember') > -1) {
				refresh='true';	
			}else if (window.location.href.toLowerCase().indexOf('formtemplatedetails') > -1) {
				refresh='true';
			}else if (window.location.href.toLowerCase().indexOf('documentupload') > -1) {
				refresh='true';
			}else if (window.location.href.toLowerCase().indexOf('wfquickroute') > -1) {
				refresh=document.getElementById('__refreshOpener').value;
			}else if(document.getElementById('__refreshOpener')){
				refresh=document.getElementById('__refreshOpener').value;		 
			}
			
			if (window.location.href.toLowerCase().indexOf('sendemail.aspx') > -1) {
				refresh='true';		 
			} 			
						
			if(document.getElementById('__checkinForm')) {
				if (document.getElementById('__checkinForm').value.toLowerCase() == 'true') {
					checkinForm = true;
				}	
			}
			
			if (document.getElementById('__EVENTTARGET')) {
				//If a control inside of ctrlPanelHolder (ie: form viewer controls) caused the page to unload in firefox
				//then do not attempt to check-in the form or close parent window, etc.
				var indexPanelHolder=document.getElementById('__EVENTTARGET').value.indexOf('ctrlPanelHolder');
				
				if(indexPanelHolder >= 0) {
					checkinForm = false;
				}
					
			}
			
			if (checkinForm==true && bAllowLinkToClose==true) {
				url=window.location.href.toLowerCase();
				tryCheckinFormDataID(url);
				
				if(document.getElementById('inputFormSaved')){
					refresh=document.getElementById('inputFormSaved').value;	
				}
				
				//refresh='true';
			} else if (checkinForm==true && mousey<150) {
				url=window.location.href.toLowerCase();
				tryCheckinFormDataID(url);
				
				if(document.getElementById('inputFormSaved')){
					refresh=document.getElementById('inputFormSaved').value;	
				}
			}	
			
							
			var browserName = getBrowser(); 
			if (browserName == 'IE') {
				oW = document.body.clientWidth; 
				oH = document.body.clientHeight;
			}else{
				oH = window.outerHeight; 
				oW = window.outerWidth; 
			}				
			
								
			if (window.opener && !window.opener.closed) { //only close when there is an opener 		
				if (e){
					
					//if not bAllowLinkToClose then mouse click must be on the window's close button
					if (mousey < 150 && mousex > (oW - 40)) {	//if (e.clientY < 0 && e.clientX > (oW - 40)) {
										
						//Only refresh when refreshOpener is true (onChange flag)
						if(refresh.toLowerCase()=='true') {													
							refreshOpener(true,folderProperties);								
						}else if(bAllowLinkToClose==true){	
							//close the window and all children windows
							closeChildren();																														
						}else if(document.all){ //allow IE to close children
							closeChildren();
						}
						
					}else if(bAllowLinkToClose) { 
						if(bAllowLinkToClose==true) {
							//Only refresh when refreshOpener is true (onChange flag)
							if(refresh.toLowerCase()=='true') {													
								refreshOpener(true,folderProperties);								
							}else if(bAllowLinkToClose==true){	
								//close the window and all children windows
								closeChildren();																														
							}else if(document.all){ //allow IE to close children
								closeChildren();
							}
						}

					//firefox will use this if the window close button was clicked:
					}else if (!e.clientY && refresh.toLowerCase()=='true' || !e.clientY && checkinForm==true) {		
						var runScript = true;
						
						if (document.getElementById('__EVENTTARGET')) {
							//If a control inside of ctrlPanelHolder (ie: form viewer controls) caused the page to unload in firefox
							//then do not attempt to check-in the form or close parent window, etc.
							var indexPanelHolder=document.getElementById('__EVENTTARGET').value.indexOf('ctrlPanelHolder');
							
							if(indexPanelHolder >= 0)
								runScript = false;
						}
						
						if (runScript==true) {
						
							if (checkinForm==true) {	
								var url=window.location.href.toLowerCase();
								tryCheckinFormDataID(url);
							}						
							
							if (refresh.toLowerCase()=='true'){
								if (bAllowLinkToClose==true)									
									refreshOpener(true,folderProperties);
								else		
									refreshOpener(false,folderProperties);
							}
								
						}else{
							runScript = true;
						}						
													
					}else if (bAllowLinkToClose) {
						if(bAllowLinkToClose==true)	
							closeChildren();							
					}

				}else if (bAllowLinkToClose) { 
					if(bAllowLinkToClose==true) {
						//Only refresh when refreshOpener is true (onChange flag)
						if (refresh.toLowerCase()=='true')							
							refreshOpener(true,folderProperties);							
						else //Otherwise just close the window and all children windows
							closeChildren();
							
					}

				}		

					
			}else{ 
				if (e){										
					if (e.clientY < 0 && e.clientX > (oW - 40)) {	
						//IE main browser window closed event, we may need to check-in a form
						var url=window.location.href.toLowerCase();
						tryCheckinFormDataID(url);
					}else if (!e.clientY){
						//could be firefox main browser window closed event (cannot trap for mouse click on window close button in Mozilla browsers)
						var url=window.location.href.toLowerCase();
						tryCheckinFormDataID(url);
					}
				}
			}	
			
			
		}catch(e){}		
	}
	
	function closeChildren() {
	
		try {
			if (childrenWindows.length > 0) {
				for(var cWinCount=0; cWinCount < childrenWindows.length; cWinCount++){
					cWindow = childrenWindows[cWinCount];
					if (cWindow && !cWindow.closed) {
						cWindow.closeChildren();
						var url=cWindow.location.href.toLowerCase();
						tryCheckinFormDataID(url);
						cWindow.close();
					}
				
				}	
			} 
			var url=window.location.href.toLowerCase();
			tryCheckinFormDataID(url);
			window.close();
		}
		catch(e) {
			var url=window.location.href.toLowerCase();
			tryCheckinFormDataID(url);			
			//window.close();
		}
	}
	
	
	//Form Checkin Functions
	var checkinWindow;	
	var checkinUrl;
		
	function tryCheckinFormDataID(url,useParent) {
		//used to unlock (check-in) a form data instance when the user closes the form window
		
		if (url.indexOf('form_details') > -1) {
			//get the form's data ID from the URL
			
			if (document.getElementById('divMain')){
				var inputDataID=document.getElementById('inputDataID');
				var inputFormCheckinURL=document.getElementById('inputFormCheckinURL');				
				var inputFormSaved=document.getElementById('inputFormSaved');	
				var inputFormUsID=document.getElementById('inputFormUsID');
				
				if (inputDataID && inputFormCheckinURL && inputFormSaved && inputFormUsID){
				
				var formDataID=inputDataID.value;
				var formSaved=inputFormSaved.value;
				var formUsID=inputFormUsID.value;
				
				checkinUrl=inputFormCheckinURL.value;
				checkinWindow=window;
														
					if(formDataID.length > 0 && checkinUrl.length>0 && formUsID.length>0){
					
						//append formID to the url
						checkinUrl=checkinUrl + '?formDataID=' + formDataID + '&formUsId=' + formUsID + '&formSaved=' + formSaved
					
					   if (useParent==true){
							//ask parent to checkin the form. Parent checkin required for non-IE browswers
							//when the window close button clicked because we don't know if its a real
							//window close event.  The parent checks the window state before form checkin.
							if (window.opener && !window.opener.closed){
								window.opener.tryCheckinChildFormDataID(checkinWindow,checkinUrl)
							}							
					   }else{
							//if close link clicked in child window or IE window close clicked then
							//just checkin the form.
							checkinFormDataID();					   
					   }		
					}	
				}				
			}		
			
		}		
	}
	
	function tryCheckinChildFormDataID(win,url) {
		//used to unlock (check-in) a form data instance when the user closes the form window
		//this function called by child window, asking parent window to check-in form if the
		//child window is no longer open.  Required for non IE browsers because there is no
		//way to detect if a window close event is due to the user clicking the window's close button.
		
				
		checkinWindow=win;		
		checkinUrl=url;
				
		//wait one half second before calling checkin function.  checkin function only runs if the child
		//window is closed.  This prevents the form check-in from being called unless the form window
		//was really closed.
		
		setTimeout('checkinClosedWindowFormDataID()',500);
	}
	
	function checkinClosedWindowFormDataID(){
			 
		if (checkinWindow.closed){
			checkinFormDataID();
		}
	 
	}
	
	function checkinFormDataID() {
		//used to unlock (check-in) a form data instance when the user closes the form window
				
			
		try{
															
			if(checkinUrl.length>0){
			
				//send formID to the server
				//wait for response from server before continuing script processing;
				var xmlhttp = new GetXmlHttp();
				xmlhttp.open("GET",checkinUrl,false);
	   			xmlhttp.send(null);						
			}
				
		} catch(e) {
		  
		}	
	}
	
	function addChildWindow(win) {
		try{		    
			childrenWindows.push(win);
		} catch(e) {
			//alert(e);
		}
	}
	
	function removeChildWindow(win) {
	
	}
	function refreshOpener(bCloseChildren,folderProperties){
		try{ 
				if(window.opener && !window.opener.closed)
                    {
                        try{
                          if (folderProperties==false && ((window.opener.location.href.toLowerCase().indexOf('document_library.aspx') > -1) || (window.opener.location.href.toLowerCase().indexOf('folderdocuments.aspx') > -1))) {
								if (navigator.appName.indexOf("Microsoft") != -1) {
									window.opener.vvCallbackGetHTML('','loadgrid','divRight','divRight','divDG1','','');
								} else {
									//Logic for non ie browsers to refresh the parent window.  If the refresh target is a specific folder
									//then determine if there is a valid folder ID and if the parent window's URL already contains a folderID
									//querystring parameter or not.
									
									var FolderID = window.opener.document.getElementById('__folderID').value;
									
									if (FolderID.length == 36) {
										if (window.opener.location.href.toLowerCase().indexOf('fsid') > -1){
											window.opener.location = window.opener.location;
										}else{
											window.opener.location = window.opener.location + '?FsID=' + FolderID;
										}
										
									} else {
										window.opener.location = window.opener.location;
									}
								}
                            }
                            else if(window.opener.location.href.toLowerCase().indexOf('userportal.aspx') > -1) {
                                //do not refresh the portal screen when a form is the child window
                                if(window.location.href.toLowerCase().indexOf('form_details.aspx') < 0)
                                {
									window.opener.location = window.opener.location;
								}
                            }
                            else if(window.opener.location.href.toLowerCase().indexOf('document_details.aspx') > -1) {
                               	var parentURL= window.opener.location.href.replace('&tab=tabRevisions','');
								window.opener.location = parentURL + '&childRefresh=1';							
                            }
                            else if(window.opener.location.href.toLowerCase().indexOf('site_details.aspx') > -1) {
                               	var parentURL= window.opener.location.href;
								window.opener.location = parentURL + '&childRefresh=1';
                            }
                             else if(window.opener.location.href.toLowerCase().indexOf('project_details.aspx') > -1) {
                               	var parentURL= window.opener.location.href;
								window.opener.location = parentURL + '&childRefresh=1';
                            }
                            else if(window.opener.location.href.toLowerCase().indexOf('workflowreport.aspx') > -1) {
                               	var parentURL= window.opener.location.href;
								window.opener.location = parentURL + '?childRefresh=1';
                            }
                            else {
                                window.opener.__doPostBack('','');
                            }
                        }
                        catch(e)
                        {}
                    }
                    
                    if (bCloseChildren!=false){
						closeChildren();
                    }
                }
        catch(ex)
        {}
	
	}
	
	function CheckRadioButton(radioid)
	{
	
		if (document.forms[0].radioid.checked) {
			alert('Is True'); return false;
		}else {
			alert('Is False'); return true;
		}
	}
	function ToggleClientChk(chkid, clientchkid)
	{
		if (document.getElementById(chkid).checked==true) {
			document.getElementById(clientchkid).checked=true;
		}else {
			document.getElementById(clientchkid).checked=false;
		}
	}
	function ToggleClientChkEnabled(args)
	{
		var params = args.split(',');
		var chkid = params[0];
		var clientchkid = params[1];
	
		if (document.getElementById(chkid).disabled==true) {
			document.getElementById(clientchkid).disabled=true;
		}else {
			document.getElementById(clientchkid).disabled=false;
		}
	}

	function ToggleDiv(id,imageid)
	{

		if (document.getElementById(id).style.display=='none') {
			document.getElementById(id).style.display='block';
			document.getElementById(imageid).src='images/std_minus1.gif';
			document.getElementById(imageid).alt='Collapse';
			document.getElementById(imageid).tooltip='Click to collapse additional information';
			document.getElementById(imageid).title='Click to collapse additional information';
		} else {
			document.getElementById(id).style.display='none';
			document.getElementById(imageid).src='images/std_plus1.gif';
			document.getElementById(imageid).alt='Expand';
			document.getElementById(imageid).tooltip='Click to show additional information';
			document.getElementById(imageid).title='Click to show additional information';
		}
	}
	
	function RegisterEvent(elem, type, listener, useCapture)
	{
		//var proto = arguments.callee.prototype;

		this.e = elem;
		this.type = type;
		this.cap = useCapture;
		this.l = listener;


		if( this.e.attachEvent )
		{
			//alert('attachEvent ' + type);
			this.e.attachEvent("on" + this.type, this.l);
		}
		else if( this.e.addEventListener )
		{
			//alert('addEventListener ' + e);
			this.e.addEventListener(this.type, this.l, this.cap);
		}
	}

	function onResponseEnd()
	{
		//test
		//alert('Callback request is completed. Response is processed.');
	}

	function toggleFolderProperties(value)
	{
		//toggles display between folder properties and document list
		var value=document.getElementById('btnFolderProperties').innerText;

		if (value=='Folder Properties')
		{
			folderProperties('tabDetails');
		}
		else
		{
			document.location = './document_library.aspx?fsid=' + document.getElementById('__folderID').value;
		}


	}

	function folderProperties(tab)
	{
		document.location = './document_library.aspx?fsid=' + document.getElementById('__folderID').value + '&tab=' + tab;
	}

	function newFolder()
	{
		var tab='newfolder';
		document.location = './document_library.aspx?fsid=' + document.getElementById('__folderID').value + '&tab=' + tab;
	}
	
	function newDocumentLibraryFolder()
	{
		document.location = './document_library.aspx?fsid=' + document.getElementById('__folderID').value + '&newTldFolder=true';
	}

	function setRowCount(listBoxID)
	{
		//alert(listBoxID);

		var listbox = document.getElementById(listBoxID);

		if (listbox != null)
		{
			//alert(listbox.value);
		}


	}

	function preloadImages()
	{
		var i = 0;

		imageObj = new Image();
		images = new Array();

		images[0]="Images/ContextMenu/spinner.gif"
		images[1]="Images/Icons/ICDOC.gif"
		images[2]="Images/Icons/ICXLS.gif"
		images[3]="Images/Icons/ICPDF.gif"
		images[4]="Images/Icons/ICXML.gif"
		images[5]="Images/Icons/ICZIP.gif"
		images[6]="Images/Icons/ICDWG.gif"
		images[7]="Images/Icons/ICGEN.gif"
		images[8]="Images/Icons/ICJPG.gif"
		images[9]="Images/Icons/ICGIF.gif"
		images[10]="Images/folder.gif"


		for(i=0; i<=3; i++)
		{
			imageObj.src=images[i];
		}

	}

	function keyHandler (evt)
	{

		try{

			if ((evt.which && evt.which == 13) || (evt.keyCode && evt.keyCode == 13))
			{
					evt.cancelBubble = true;
					evt.returnValue = false;
					lastKeyCode = 13;
					return false;
			}


			if ((evt.which && evt.which == 9) || (evt.keyCode && evt.keyCode == 9))
			{
					evt.cancelBubble = true;
					evt.returnValue = false;
					lastKeyCode = 9;
					return true;
			}
		}
		catch (ex){

		}

	}

	
	function cbGetFilterData(){
		
		var ctrlFilter = document.getElementById('divFilter');
				
				
		try{
			//recursively parse html element and retrieve all form field values
			if (ctrlFilter) {
							
				if (ctrlFilter.childNodes.length > 0){			
					cbParseFormFields (ctrlFilter);
				}
			}
		}
		catch (e){	
		}	
		
		
	}
	
	
	function cbParseFormFields(container){
	

		for(var elementIndex=0; elementIndex < container.childNodes.length; elementIndex++){
			
				var element = container.childNodes[elementIndex];
					//if (element.name) {
				var elementValue = null;
					
					if (element.nodeName == "INPUT") {
						var inputType = element.getAttribute("TYPE").toUpperCase();
						if (inputType == "TEXT" || inputType == "PASSWORD" || inputType == "HIDDEN") {
							elementValue = element.value;
						} else if (inputType == "CHECKBOX" || inputType == "RADIO") {
							if (element.checked) {
								elementValue = element.value;
							}
						}
					} else if (element.nodeName == "SELECT") {
						if (element.multiple) {
							elementValue = [];
							for (var i = 0; i < element.length; ++i) {
								if (element.options[i].selected) {
									elementValue.push(element.options[i].value);
								}
							}
						} else {
							elementValue = element.value;
						}
					} else if (element.nodeName == "TEXTAREA") {
						elementValue = element.value;
					}
					if (elementValue instanceof Array) {
						for (var i = 0; i < elementValue.length; ++i) {
							if (encodedFormData.length > 0){
								encodedFormData += "&" + element.name + "=" + encodeURIComponent(elementValue[i]);
							}
							else{
								encodedFormData += element.name + "=" + encodeURIComponent(elementValue[i]);
							}
						}
					} else if (elementValue) {
						if (encodedFormData.length > 0){
							encodedFormData += "&" + element.name + "=" + encodeURIComponent(elementValue);
						}
						else{
							encodedFormData += element.name + "=" + encodeURIComponent(elementValue);
						}
					}
					elementValue = null;
				
				//recurse
				cbParseFormFields(element);
			
		}//end for		
		
	}
	
	function findPosX(obj)
	{
		var curleft = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;
		return curleft;
	}

	function findPosY(obj)
	{
		var curtop = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
		return curtop;
	}

	function getNodeByGuid(guid){

			var tree = PowerUpTreeViewArray[0];

			try{

				for (var i = 0; i < tree.nodes.length; i++)
				{
					var node = tree.nodes[i];

					if (node.getValue()==guid){
						return tree.nodes[i];
					}
				}
			}
			catch(ex){
				return null;
			}

	}

	function refreshParentNodeByGuid(guid){

		var node=getNodeByGuid(guid);
		var parentNode;

		if (node != null){
			parentNode=node.getParentTreeNode();

			if (parentNode != null){
				parentNode.resetPopulateOnDemand();
				parentNode.select();
				try {
					parentNode.toggle();

				}
				catch (ex){
				///////

					var ancestors = parentNode.getAncestors();
										
					for (var i = ancestors.length; i > 0; i--)
					{
						parentNode = ancestors[i-1];

						if (parentNode.isExpanded()){
							var test = parent.getText();
							parentNode.resetPopulateOnDemand();
							parentNode.toggle();

						}
					}
					
					parentNode.select();

				///////
				}
			}
			else{
				//could not find parent so refresh top level
				var tree = PowerUpTreeViewArray[0];
				var nodes = tree.getNodes();
				parentNode = nodes[0];
				parentNode.resetPopulateOnDemand();
				parentNode.toggle();
				parentNode.select();
			}
		}
		
		if (document.getElementById('__folderID') && parentNode){
			document.getElementById('__folderID').value = parentNode.getValue();			
		}		

		return false;
	}

	function refreshNodeByGuid(guid){

		var node=getNodeByGuid(guid);

		if (node != null){

				var nodeParent = node.getParentTreeNode();
				
				try{
					node.resetPopulateOnDemand();
					node.toggle();
				}
				catch (ex){
					if (nodeParent != null){
					
						try{
							nodeParent.resetPopulateOnDemand();
							nodeParent.toggle();
						}
						catch(ex){
							//could not find node so refresh top level
							var tree = node.getParentTreeView();
							var nodes = tree.getNodes();
							nodes[0].resetPopulateOnDemand();
							nodes[0].toggle();
						}
					}
					else{
						//could not find node so refresh top level
						var tree = node.getParentTreeView();
						var nodes = tree.getNodes();
						nodes[0].resetPopulateOnDemand();
						nodes[0].toggle();
					}
				}
			}
		else{
		
			try{
				//could not find node so refresh top level
				var tree = PowerUpTreeViewArray[0];
				var nodes = tree.getNodes();
				nodes[0].resetPopulateOnDemand();
				nodes[0].toggle();
			}
			catch(ex){
			}
		}
		try {
			resizeForm(true);
		}
		catch(ex){
		}
	 }

	function refreshParentNodeAndGridByGuid(guid){

		var node=getNodeByGuid(guid);
		var parentNode;

		if (node != null){
			parentNode=node.getParentTreeNode();

			if (parentNode != null){
				parentNode.resetPopulateOnDemand();
				parentNode.select();
				try {
					parentNode.toggle();	
					vvCallbackGetHTML('','loadgrid','divRight','divRight','divDG1','resizeForm','true');	
				}	
				catch (ex){
				///////

					var ancestors = parentNode.getAncestors();

					for (var i = ancestors.length; i > 0; i--)
					{
						parentNode = ancestors[i-1];

						if (parentNode.isExpanded()){
							parentNode.resetPopulateOnDemand();
							parentNode.toggle();
							parentNode.select();
							vvCallbackGetHTML('','loadgrid','divRight','divRight','divDG1','resizeForm','true');
							return;
						}
					}

				///////
				}
			}
			else{
				//could not find parent so refresh top level
				var tree = PowerUpTreeViewArray[0];
				var nodes = tree.getNodes();
				parentNode = nodes[0];
				parentNode.resetPopulateOnDemand();
				parentNode.toggle();
				parentNode.select();
				vvCallbackGetHTML('','loadgrid','divRight','divRight','divDG1','resizeForm','true');
			}
		}
		
		
		if (document.getElementById('__folderID') && parentNode){
			document.getElementById('__folderID').value = parentNode.getValue();			
		}

	}
	
	function clearClientFolderID() {
		if (document.getElementById('__folderID')){
			document.getElementById('__folderID').value = '';
			document.getElementById('__folderID') = null;
			//alert('hi');
		}	
	}
	function refreshFolderAfterRename(guid){

		var node=getNodeByGuid(guid);
		var parentNode;

		if (node != null){
			parentNode=node.getParentTreeNode();

			if (parentNode != null){
								
				try {
					parentNode.resetPopulateOnDemand();
					parentNode.toggle();
					node=getNodeByGuid(guid);
					if (node != null){
						node.select();
					}
				}
				catch (ex){		
				}
			}			
		}
		
		if (document.getElementById('__folderID') && node){
			document.getElementById('__folderID').value = node.getValue();			
		}		
		try {
			//resizeForm(true);
		}
		catch (ex){
		}
		return false;
	}
		
	function refreshAfterFolderDelete(args){

		//args contains deleted folder ID and recycle bin id
		var folders = args.split(',');
		
		var node = getNodeByGuid(folders[0]);
		var recycleBin = getNodeByGuid(folders[1]);
		var parentNode;
		
		tree = node.getParentTreeView();
		tree.unselectAll();
		
		if (node != null){
			parentNode=node.getParentTreeNode();

			if (parentNode != null){
				parentNode.resetPopulateOnDemand();				
				try {
					parentNode.toggle();
					
					if (recycleBin != null && recycleBin.isSelected()){
						recycleBin.select();
						document.getElementById('__folderID').value=recycleBin.getValue();					
					}else{
						parentNode.select();
						document.getElementById('__folderID').value=parentNode.getValue();
					}	
					
					vvCallbackGetHTML('','selectfolder','divRight','divRight','divRight','resizeForm','true');	
				}	
				catch (ex){
				///////

					var ancestors = parentNode.getAncestors();

					for (var i = ancestors.length; i > 0; i--)
					{
						parentNode = ancestors[i-1];

						if (parentNode.isExpanded()){
							parentNode.resetPopulateOnDemand();
							parentNode.toggle();
							
							if (recycleBin != null && recycleBin.isSelected()){
								recycleBin.select();
								document.getElementById('__folderID').value=recycleBin.getValue();
							}else{
								parentNode.select();
								document.getElementById('__folderID').value=parentNode.getValue();
							}	
							
							vvCallbackGetHTML('','selectfolder','divRight','divRight','divRight','resizeForm','true');
							return;
						}
					}

				///////
				}
			}
			else{
				//could not find parent so refresh top level
				var tree = PowerUpTreeViewArray[0];
				var nodes = tree.getNodes();
				parentNode = nodes[0];
				parentNode.resetPopulateOnDemand();
				parentNode.toggle();
				
				if (recycleBin != null && recycleBin.isSelected()){
					recycleBin.select();
					document.getElementById('__folderID').value=recycleBin.getValue();
				}else{
					parentNode.select();
					document.getElementById('__folderID').value=parentNode.getValue();
				}	
				
				vvCallbackGetHTML('','selectfolder','divRight','divRight','divRight','resizeForm','true');
			}
		}
		
		
	}
	

	function refreshGrid(){

		vvCallbackGetHTML('','loadgrid','divRight','divRight','divDG1','resizeForm','true');	
	}
	
	function refreshControls(param){
	
		args = param.split(',');
		vvCallbackGetHTML(args[1],'refreshcontrols',args[0],args[1],args[2],'','');	
	}
	
	function setEditIndex(param){
		
		var args;
		var dataGridID;
		var editIndex;
		
		args = param.split(',');
		dataGridID = '__' + args[0] + '__editIndex';
		editIndex = args[1];
						
		//see if a hidden input exists for this datagrid, if not create it
		var form = document.forms[0];
		var dataGrid;
		dataGrid = document.getElementById(dataGridID);
		
		if (dataGrid) {
			dataGrid.value = editIndex;
		} else {
			dataGrid = document.createElement("INPUT");
			dataGrid.setAttribute("id", dataGridID);
			dataGrid.setAttribute("name", dataGridID);
			dataGrid.setAttribute("type", 'HIDDEN');
			dataGrid.setAttribute("value", editIndex);			
			form.appendChild(dataGrid);														
		}
		
	}
	
	function onDocLibraryMessageTimerEnd(){
		
		var args;
		var sourceType;
		var sourceGuid;
		var targetGuid;
		var targetType;
		
		//if timer was running for a drag drop operation
		
		if (document.getElementById('__dragDropArguments')){
				args = document.getElementById('__dragDropArguments').value.split(',');
				
				if (args.length > 3)
				{
					sourceType = args[0];
					sourceGuid = args[1];
					targetType = args[2];
					targetGuid = args[3];
					
					if (sourceType == 'TreeNode'){
						//refresh the tree
						dragDropComplete(sourceGuid,targetGuid)
					} else if (sourceType == 'TreeImage'){
						//refresh the document listing
						vvCallbackGetHTML('','selectfolder','divRight','divRight','divRight','resizeForm','true');
					}
				}
		}
		
		//if timer was running for a document archiveType change		
			
	}


	function refreshAfterRestore(libraryGuid){
					
		var node=getNodeByGuid(libraryGuid);

		if (node != null){
			node.resetPopulateOnDemand();
			node.toggle();			
		}
		
		//refresh the recycle bin listing
		vvCallbackGetHTML('','selectfolder','divRight','divRight','divRight','resizeForm','true');
				
	}
	
	
	function getExpandedFolderGuids(){

		var tree = PowerUpTreeViewArray[0];
		var values='';

			try{

				for (var i = 0; i < tree.nodes.length; i++)
				{
					var node = tree.nodes[i];

					if (node.isExpanded()){
						values += node.getValue() + ",";
					}
				}
			}
			catch(ex){
				return null;
			}

		return values;

	}

	function onClientToggle (node)
	{

		//called after a tree node is finished expanding
		//on the server side, update the list of expanded nodes
		
		if (document.getElementById('__expandedFolders')){
			document.getElementById('__expandedFolders').value=getExpandedFolderGuids();
		}
		
		//post form data to server
		vvCallbackGetHTML('','nodelist','','','','','');
	
	}

	function onClientClickStart (node)
	{

		//first event fired when a tree node is clicked
		
		var updateElement='';var serverControl='';var loadingMsg='';

		tree = node.getParentTreeView();
		tree.unselectAll();
		node.select();
		selectedFolder=node;
		
		//server gets its selected folder id from a hidden element on the form
		//server creates this hidden element on the page during doc library page load
		//ctrlPanelHolder_ctrlDocTreeUpload_Ctrlpanelholder2_0_divMain
		
		//}else if(location.href.toLowerCase().indexOf('form_details') != -1){
		//updateElement='ctrlPanelHolder_0_Ctrlpanelholder2_0_divMain';
		//loadingMsg='ctrlPanelHolder_0_Ctrlpanelholder2_0_divLoadingMessage';
		//serverControl='ctrlPanelHolder:0:Ctrlpanelholder2:0:divMain';
		//ctrlPanelHolder_ctrlDocTreeUpload_Ctrlpanelholder2_0_divLoadingMessage
		
		if (document.getElementById('__folderID')){
			document.getElementById('__folderID').value=node.getValue();
		}
				
		//determine the element to update based on the URL
		if (location.href.toLowerCase().indexOf('document_library') != -1){
			updateElement='divRight';
			loadingMsg='divRight';
			serverControl='divRight';
		}else if(location.href.toLowerCase().indexOf('document_details') != -1){
			updateElement='ctrlPanelHolder_0_Ctrlpanelholder2_0_divMain';
			loadingMsg='ctrlPanelHolder_0_Ctrlpanelholder2_0_divLoadingMessage';
			serverControl='ctrlPanelHolder:0:Ctrlpanelholder2:0:divMain';
		}else if(location.href.toLowerCase().indexOf('site_details') != -1){
			updateElement='ctrlPanelHolder_ctrlDocTreeUpload_Ctrlpanelholder2_0_divMain';
			loadingMsg='ctrlPanelHolder_ctrlDocTreeUpload_Ctrlpanelholder2_0_divLoadingMessage';
			serverControl='ctrlPanelHolder:ctrlDocTreeUpload:Ctrlpanelholder2:0:divMain';
		}else if(location.href.toLowerCase().indexOf('project_details') != -1){
			updateElement='ctrlPanelHolder_0_Ctrlpanelholder2_0_divMain';
			loadingMsg='ctrlPanelHolder_0_Ctrlpanelholder2_0_divLoadingMessage';
			serverControl='ctrlPanelHolder:0:Ctrlpanelholder2:0:divMain';
		}else if(location.href.toLowerCase().indexOf('form_details') != -1){
			updateElement='ctrlPanelHolder_ctrlDocTreeUpload_Ctrlpanelholder2_0_divMain';
			loadingMsg='ctrlPanelHolder_ctrlDocTreeUpload_Ctrlpanelholder2_0_divMain';
			serverControl='ctrlPanelHolder:ctrlDocTreeUpload:Ctrlpanelholder2:0:divMain';
		}else if(location.href.toLowerCase().indexOf('folderview') != -1){
			updateElement='ctrlPanelHolder_0_divLabelFolderPath';
			loadingMsg='ctrlPanelHolder_0_divLabelFolderPath';
			serverControl='ctrlPanelHolder:0:divLabelFolderPath';
			if (window.opener) {
				if (window.opener.document.getElementById('__folderID')){
					window.opener.document.getElementById('__folderID').value = node.getValue();
					setRefreshOpener();
				}
				if (window.opener.document.getElementById('inputSelectedFolderId')){
					window.opener.document.getElementById('inputSelectedFolderId').value = node.getValue();
					setRefreshOpener();
				}
			}			
		}
		
		sourceParentNode=node.getParentTreeNode();
		uncheckAllDocuments();
		vvCallbackGetHTML('','selectfolder',updateElement,serverControl,loadingMsg,'resizeForm','true');				
		
		return false;

	}	
	
	
	function selectTab (p,htmlElementToUpdate,serverControlToRender,htmlElementLoadingMsgDisplay,onCallbackCompleteFunction,cbFunctionArguments)
	{
		//called from server side tab control's datalist item click
		try{
					
			var params = p.split(',');		
			var tabcontrolID;
			var tab;
			
			//if parameter contains two items then first item is the tab control's id
			//else first item is the tab to select
			
			if (params.length > 1){
				tabcontrolID = params[0];
				tab	= params[1];
			}
			else{
				tab	= params[0];
			}
					
			if (document.getElementById('__selectedTab')){	
						
				document.getElementById('__selectedTab').value=tab;
				vvCallbackGetHTML(tabcontrolID,'tabSelect',htmlElementToUpdate,serverControlToRender,htmlElementLoadingMsgDisplay,onCallbackCompleteFunction,cbFunctionArguments);
			}		
		
		}catch(e)
		{
		
		}		
			
	}

	function onClientDragDropStart(source, target, evt)
	{
			//setup the treeview display after the move\copy is finished
			var showButtons='false';

			try{
				sourceParentNode = source.getParentTreeNode;
			}
			catch (ex){
				sourceParentNode = null;
			}


			tree = target.getParentTreeView();
			targetNode=target;

			sourceNode=source;

			X = 100//findPosX(targetElement);
			Y = 100//findPosY(targetElement);

			//if source is a treeImage, there is no getValue function in the vendor's script library
			//get the source guid from the parent element (we wrap the treeImage in a span tag with the guid)
			var sourceValue;
			if (source.getType()== 'TreeImage'){
				if (source.getAttribute("id").toLowerCase().indexOf("imgmultifile") != -1) {
					sourceValue = source.getAttribute("multivalue");
				} else {
					sourceValue = source.span.parentNode.getAttribute("multivalue");
				}
				
			}
			else{
				sourceValue = source.getValue();
			}

			callbackString=	source.getType() + ',' + sourceValue + ',' + target.getType() + ',' + target.getValue();


			//if (isIE){
			try {
				ctrlKey=evt.ctrlKey;
			}
			catch(e) {
				
			}
				
			//}

			if (ctrlKey)
			{
				dragType = 'copy';
			}
			else
			{
				dragType = 'move';
			}

			if (target.getText()=='RecycleBin'){
				dragType='delete';
				showButtons='true';
			}
			
			if (document.getElementById('__dragType')){
				document.getElementById('__dragType').value=dragType;				
			}	
			
			//set the eventtarget to 
			//send event to server
			if (document.getElementById('__dragDropArguments')){
				document.getElementById('__dragDropArguments').value=callbackString;
				
				//initiate callback
				//no target id is required
				//event name is dragdrop
				//client element to update is MessageBox
				//Server control to render is MessageBox
				//no loading message will be displayed
				//no client side function to call
				uncheckAllDocuments();												
				vvCallbackGetHTML('','dragdrop','MessageBox','MessageBox','','','');
			}	

			//stop the tree from posting back on drag\drop
			return false;
	}

	function dragDropComplete(sourceGuid,targetGuid)
	{
			refreshParentNodeByGuid(sourceGuid);
			refreshParentNodeByGuid(targetGuid);
	}

	function doDragStart(e)
	{
			if(typeof(e)=='undefined')
			e=window.event||window.Event;

			// for non-IE browsers check if any Modifier Keys pressed
			ctrlKey  = document.layers ? e.modifiers & Event.CONTROL_MASK : e.ctrlKey;

	}

	function getCheckedDocumentValues()
	{
		var TotalBoxes = 0;
		var TotalOn = 0;
		var values = '';
		var form = document.forms[0];
		
		for (var i=0;i<form.elements.length;i++) {
			var e = form.elements[i];
			if ((e.name != 'allbox') && (e.type=='checkbox')) {
			TotalBoxes++;
			if (e.checked) {
			values += e.parentNode.getAttribute("value") + ",";
			TotalOn++;
			}
			}
		}
		
		if (document.getElementById('__checkedDocuments')){
			document.getElementById('__checkedDocuments').value=values;
		}		
		
		if (values.length==0) values=null;		
		
		return values;		
	}
	
	function uncheckAll() {
			var form = document.forms[0];

			for (var i=0;i<form.elements.length;i++) {
				var e = form.elements[i];
				if ((e.name != 'chkInclude') && (e.name != 'chkInclude2') && (e.type=='checkbox')) {
					e.checked = false;
				}
			}
		
    }
    
   function uncheckAllDocuments() {
		var chkAll=document.getElementById('checkall');
		var form = document.forms[0];
		if (chkAll != null){
			
			chkAll.checked=false;
			
			for (var i=0;i<form.elements.length;i++) {
				var e = form.elements[i];
				if ((e.name.indexOf("chkBatch") != -1) && (e.type=='checkbox')) {
					e.checked = false;
				}
			}
		}
    }
    
	function checkUncheckAll() {

		var chkAll=document.getElementById('checkall');
		var form = document.forms[0];
		if (chkAll != null){
			for (var i=0;i<form.elements.length;i++) {
				var e = form.elements[i];
				if ((e.name != 'checkall') && (e.name != 'checkall2') && (e.name != 'chkInclude') && (e.name != 'chkInclude2') && (e.type=='checkbox')) {
					e.checked = chkAll.checked;
				}
			}
		}
    }
    function checkUncheckAllExceptDisabled() {

		var chkAll=document.getElementById('checkall');
		var form = document.forms[0];
		if (chkAll != null){
			for (var i=0;i<form.elements.length;i++) {
				var e = form.elements[i];
				if ((e.name != 'checkall') && (e.disabled != true) && (e.name != 'checkall2') && (e.name != 'chkInclude') && (e.name != 'chkInclude2') && (e.type=='checkbox')) {
					e.checked = chkAll.checked;
				}
			}
		}
    }
    
    function checkUncheckSpecifiedExceptDisabled(src, containerName) {
		var chkAll=document.getElementById(src);
		var container=document.getElementById(containerName);
		
		if (chkAll != null){
			if (container != null){
				var checks = container.getElementsByTagName("input");
				for (var i = 0; i < checks.length; i++) { 
					var e = checks[i];
					if ((e.name != 'checkall') && (e.disabled != true) && (e.name != 'checkall2') && (e.name != 'chkInclude') && (e.name != 'chkInclude2') && (e.type=='checkbox')) {
						e.checked = chkAll.checked;
					}
				}			
			}
		}
    }

	function checkUncheckAllDocuments() {

		var chkAll=document.getElementById('checkall');
		var form = document.forms[0];
		if (chkAll != null){
			for (var i=0;i<form.elements.length;i++) {
				var e = form.elements[i];
				if ((e.name.indexOf("chkBatch") != -1) && (e.type=='checkbox')) {
					e.checked = chkAll.checked;
				}
			}
		}
    }    
    function disableAllCheckBoxes() {

		var form = document.forms[0];
		
		for (var i=0;i<form.elements.length;i++) {
			var e = form.elements[i];
			if (e.type=='checkbox') {
				//e.checked = chkAll.checked;
				e.enabled = false;
			}
		}
		
    }
    
    function enableAllCheckBoxes() {

		var form = document.forms[0];
		
		for (var i=0;i<form.elements.length;i++) {
			var e = form.elements[i];
			if (e.type=='checkbox') {
				//e.checked = chkAll.checked;
				e.enabled = true;
			}
		}
		
    }

	function checkForResize() {
		if (hidingTree == true) {
			setColumnWidth = false;
			hidingTree = false;
			resizeForm(true);
			document.getElementById('__hidingTree').value=hidingTree;
		}
		
	}

	function hideDivTree() {
		if (document.getElementById('tblLibrary')) {
			hidingTree = true;	
			setColumnWidth = false;	
			resizeForm(true);
		}
		document.getElementById('__hidingTree').value=hidingTree;
	}
	
	function resizeFormEvent() {		
		resizeForm(true);	
	}
	
	function resizeForm(bFinalizedVersion){
			var divTree = document.getElementById("TreeView1_div");
			var divRight;
			if (navigator.appName.indexOf("Microsoft") == -1) {
				divRight = document.getElementById("divRightAdjust");
			} else {
				divRight = document.getElementById("divRight");
			}
			var divDrag = document.getElementById("dragDiv1");
			var tblMain = document.getElementById("tblMain");
			var tblHeader = document.getElementById("TableHeader");
			var scrollBarWidth;
			
		    //check to make sure we are in the doc library 
		    if (divRight && divTree){
				try {
					if (typeof(bFinalizedVersion)=='undefined') {
						bFinalizedVersion=true;
					}				
					
					if (navigator.appName.indexOf("Microsoft") == -1) {
						scrollBarWidth = 13;
					} else {
						scrollBarWidth = 3;
					}
					
					if (tblMain){			
						winMenuH = tblMain.clientHeight;
					}
					if (tblHeader){
						winMenuH = winMenuH + tblHeader.clientHeight;
					}
					winMenuH = winMenuH + 20;
					
					if (document.body) {
						//IE
						winW = document.body.clientWidth;
						winH = document.body.clientHeight;
					} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
						winW = document.documentElement.clientWidth;
						winH = document.documentElement.clientHeight;
					} else if (self.innerWidth) {
						//Firefox
						winW = self.innerWidth;
						winH = self.innerHeight;
					} 
					
					winH = winH - scrollBarWidth;
					
					if (divRight){
						divRight.style.height = winH - winMenuH + 'px';
					}
					
					if (divDrag){
						divDrag.style.height = winH - winMenuH + 'px';	
					}
					
					if (divTree){
						divTree.style.height = winH - winMenuH + 'px';		
					}
					
					//set the width of the treeview 
					//try to use the __leftColWidthPercent hidden form field
					if (divTree) {
						if (setColumnWidth == false) {
							if (hidingTree == true) {
								treeColumnWidth = 0;
							} else {
								if (document.getElementById('__leftColWidthPercent')){
									var colW=Number(document.getElementById('__leftColWidthPercent').value);
									if (colW > .10 && colW < 1){
										treeColumnWidth = winW * colW;
									}else{
										treeColumnWidth = winW * .25;
									}
								}else{
									treeColumnWidth = winW * .25;
								}								
							}
						} 
				
						divTree.style.height = winH - winMenuH + 'px';
						divTree.style.width = treeColumnWidth + 'px';
						
					}
					
					if (divRight) {
						divRightWidth = winW - treeColumnWidth - scrollBarWidth;
						
						divRight.style.width = divRightWidth;
						divRight.style.height = winH - winMenuH;
						
						/*divRight.style.clip.width = divRightWidth;
						divRight.style.clip.height = winH - winMenuH + 'px';
						divRight.style.clip.right = winW;
						*/
					}	
					
					//Setup for FF or Mozilla
					if (navigator.appName.indexOf("Microsoft") == -1) {
						if (bFinalizedVersion == true) {
							divTree.style.overflow="auto";
							divRight.style.overflow="auto";
						} else {
							divTree.style.overflow="auto";
							divRight.style.overflow="auto";
						}
						
					} else {
						//IE
							divRight.style.overflow="auto";
							divTree.style.overflow="auto";
						
					}
			  		
				}	
				catch(e) {
					//alert(e);
				}
			}
			
}

	// Advanced Search Support
		var strFolderList = '';
		var FolderArray = new Array();

			function ParseFolderArray() {
				var strOutput = '';
				var oFolder = new Object();

				if (FolderArray.length > 0) {
					for (var i = 0; i < FolderArray.length; i++) {
						oFolder = FolderArray[i];
						if (oFolder.FolderSearchType == 'Include') {
							if (i > 0) {
								strOutput = strOutput + "~";
							}

							strOutput = strOutput +
										oFolder.FolderID + "^" +
										oFolder.FolderSearchType + "^" +
										oFolder.IncludeChildrenFolders + "^" +
										oFolder.Path;
						}
					}

					for (var i = 0; i < FolderArray.length; i++) {
						oFolder = FolderArray[i];
						if (oFolder.FolderSearchType == 'Exclude') {
							if (i > 0) {
								strOutput = strOutput + "~";
							}

							strOutput = strOutput +
										oFolder.FolderID + "^" +
										oFolder.FolderSearchType + "^" +
										oFolder.IncludeChildrenFolders + "^" +
										oFolder.Path;
						}
					}

				}
				return strOutput;
			}

			function FolderInfo(_FolderID, _FolderSearchType, _IncludeChildrenFolders, _Path)  {
				this.FolderID = _FolderID;
				this.FolderSearchType = _FolderSearchType;
				this.IncludeChildrenFolders = _IncludeChildrenFolders;
				this.Path = _Path;
			}

			function ReplaceFolderByFolderID(oFolderArray, oFolder, FolderID) {
				//var foundFolder = false
				try {
				
				if (oFolderArray.length > 0) {
				for (var i = 0; i < oFolderArray.length; i++) {
						testFolder = oFolderArray[i];
						if (testFolder.FolderID == FolderID) {
							oFolderArray[i] = oFolder;
							//foundFolder = true;
						}
					}
				}
				}
				catch(ex) {

				}

				return oFolderArray;
			}

			function FindFolderByFolderID(oFolderArray, FolderID) {
				var foundFolder = false;
				var testFolder = new Object();
				if (oFolderArray.length > 0) {
					for (var i = 0; i < oFolderArray.length; i++) {
						testFolder = oFolderArray[i];
						if (testFolder.FolderID == FolderID) {
							foundFolder = true;
							break;
						}
					}
				}

				return foundFolder;
			}

			function ReturnFolderByFolderID(oFolderArray, FolderID) {
				var foundFolder = false;
				var testFolder = new Object();
				var returnFolder = new Object();
				if (oFolderArray.length > 0) {
					for (var i = 0; i < oFolderArray.length; i++) {
						testFolder = oFolderArray[i];
						if (testFolder.FolderID == FolderID) {
							foundFolder = true;
							returnFolder = testFolder;
							break;
						}
					}
				}

				return returnFolder;
			}

			////////////////////////////////////////
			var _AncestorList;
			var _AncestorListReverse;
			var _SiblingList;

			function getCheckedChildren(node, PreviousParentNodeValue) {
				var oFolder = new FolderInfo('','','','');
				var oAncestorFolder = new FolderInfo('','','','');

				
				var childrenList;
				var tmpNode = new Object();
				var node2 = new Object();
				var nodeAncestor = new Object();
				var ancestorChecked = false;
				var ParentNode = new Object();

				var parentChecked = false;
				var siblingChecked = false;
				var childChecked = false;
				var hasSiblings = false;
				var hasChildren = false;
				
				var nodeText;
				var nodeValue;
				var node2Text;
				
				var siblingChecked = false;
				var childChecked = false;
					
				nodeText = node.getText();
				nodeValue = node.getValue();
				
				if (nodeText != 'Document Library' && nodeText != 'Recycle Bin') {
					oFolder.FolderID = node.getValue();
					
					ParentNode = node.getParentTreeNode();
					parentNodeName = ParentNode.getText();
					parentNodeValue = ParentNode.getValue();
					
					if (parentNodeValue != PreviousParentNodeValue) {
					_SiblingList = node.getParentTreeNode().getNodes();
						_AncestorList = node.getAncestors();
					}
					
					if (ParentNode.isChecked() == true) {
						parentChecked = true;
					}
					else {
						parentChecked = false;
					}
				}
				
				if (nodeText != 'Document Library' && nodeText != 'Recycle Bin') {
				

					
					//oFolder.IncludeChildrenFolders = false;
					if (_AncestorList.length > 0) {
						for (var i = 0; i < _AncestorList.length; i++) {
							node2 = _AncestorList[i]; //[ancestorList.length - 1];
							node2Text = node2.getText();
							if (node2.isChecked() == true) {
								ancestorChecked = true;
							}
							if (node2Text != 'Document Library' && node2Text != 'Recycle Bin') {
								oFolder.Path = oFolder.Path + '/' + node2Text;
							}
						}
						//Append the current folder path if it isn't the root folders...
						if (nodeText != 'Document Library' && nodeText != 'Recycle Bin') {
							oFolder.Path = oFolder.Path + '/' + nodeText;
						}
						else {
							oFolder.Path = '/';
						}
					}
					
				
			
					//DETERMINE IF ANY SIBLINGS ARE CHECKED

					//node.getParentTreeNode().getNodes()
					if (nodeText != 'Document Library' && nodeText != 'Recycle Bin') {
						
						if (_SiblingList != null) {
							if (_SiblingList.length > 1) {	//Length of 1 means this node is the only node
								hasSiblings = true;
								for (var s = 0; s < _SiblingList.length - 1; s++) {
									siblingNode = _SiblingList[s];

									if (siblingNode.getValue() != nodeValue) { //Don't check the node against itself
										if (siblingNode.isChecked() == true) {
											siblingChecked = true;
											break;
										}
									}
								}
							}
						}
					//	else {
					//		hasSiblings = false; //already set to false;
					//	}
					}


					//DETERMINE IF ANY IMMEDIATE CHILDREN ARE CHECKED
					childrenList = node.getNodes();
					try {
						if (childrenList != null) {
							if (childrenList.length > 0) {
								for (var c = 0; c < childrenList.length; c++) {
									childNode = childrenList[c];
									if (childNode.isChecked() == true) {
										childChecked = true;
										break;
									}
								}
							}
						}
					} catch(ex) {
						//alert(ex);
					}
					//RECURSE THROUGH THE ANCESTORS AND FIND ANY THAT AREN'T CHECKED IF THERE IS A CHECKED ANCESTOR
					if (node.isChecked() == true && ancestorChecked == false) {
						oFolder.FolderSearchType = 'Include';
						oFolder.IncludeChildrenFolders = true;
						FolderArray[FolderArray.length] = oFolder;

					}
					else if (node.isChecked() != true && ancestorChecked == true) {
						if (nodeText != 'Document Library' && nodeText != 'Recycle Bin') {
							if (parentChecked == true || siblingChecked == true) {
								oFolder.FolderSearchType = 'Exclude';
								oFolder.IncludeChildrenFolders = true;
								if (FindFolderByFolderID(FolderArray, nodeValue) != true) {
									FolderArray[FolderArray.length] = oFolder;
								}
							}
						}
					}
					else if (node.isChecked() == true && ancestorChecked == true) {
						if (_AncestorList.length > 0) {
							_AncestorListReverse = _AncestorList;
							_AncestorListReverse.reverse();
							for (var i = 0; i < _AncestorListReverse.length; i++) {
								nodeAncestor = _AncestorListReverse[i];

								tmpAncestorChecked = false;

								try {
									ancestorList2 = nodeAncestor.getAncestors();
									ancestorList2.reverse();
									if (ancestorList2.length > 0) {
										for (var j = 0; j < ancestorList2.length; j++) {
											tmpNode = ancestorList2[j];
											if (tmpNode.isChecked() == true) {
												tmpAncestorChecked = true;
												break;
											}
										}
									}
								} catch(ex) {
									//alert(ex); //comment out after debug
								}
								if (tmpAncestorChecked == false) {
									break; //Exit the for loop
								}
								else {
									
									if (nodeAncestor.isChecked() != true && node.isChecked() == true && nodeAncestor.getText != 'Document Library' && nodeAncestor.getText != 'Recycle Bin') {
										// NEED TO ADD THIS NODE TO THE INCLUDE FOLDERS BECAUSE IT'S PARENT IS EXCLUDED
										if (FindFolderByFolderID(FolderArray, node.getValue()) != true) {
											oFolder.FolderID = node.getValue();
											
											oFolder.FolderSearchType = 'Include';
											oFolder.IncludeChildrenFolders = true;

											FolderArray[FolderArray.length] = oFolder; //This adds onto the end  FolderArray[10] = blah; in an array where indexes are 0-9 and array.length = 10;
										}

										FolderArray = GetSiblingExcludedFolders(node, node, FolderArray)

										// Add the ancestor folder to the excluded folders list
										if (FindFolderByFolderID(FolderArray, nodeAncestor.getValue()) == true) {
											//Folder already exists, just change its value
											try {
												tmpAncestorPath = GetNodePath(nodeAncestor);
									
												oAncestorFolder = new FolderInfo('','','','');

												oAncestorFolder = ReturnFolderByFolderID(FolderArray, nodeAncestor.getValue());
												oAncestorFolder.Path = tmpAncestorPath;
												oAncestorFolder.FolderSearchType = 'Exclude';
												oAncestorFolder.IncludeChildrenFolders = false;

												FolderArray = ReplaceFolderByFolderID(FolderArray, oAncestorFolder, oAncestorFolder.FolderID);
											}
											catch(ex) {
												//alert(ex);
											}
										}
										else {
											//New Folder, add it to the folderArray
											tmpAncestorPath = GetNodePath(nodeAncestor);
									
											oAncestorFolder = new FolderInfo('','','','');
											oAncestorFolder.FolderID = nodeAncestor.getValue();

											oAncestorFolder.Path = tmpAncestorPath;
											oAncestorFolder.FolderSearchType = 'Exclude';
											oAncestorFolder.IncludeChildrenFolders = false;

											FolderArray[FolderArray.length] = oAncestorFolder; //This adds onto the end  FolderArray[10] = blah; in an array where indexes are 0-9 and array.length = 10;

										}

										//NOW CHECK THE SIBLINGS OF EACH ANCESTOR

										//IF THE SIBLING IS IN THE LIST DON'T MESS WITH IT

										//IF THE SIBLING IS NOT CHECKED AND NOT IN THE LIST ADD IT TO THE EXCLUDED LIST
										//Get the parent node
										FolderArray = GetSiblingExcludedFolders(nodeAncestor, node, FolderArray)
									}

								}
							}
						}
					}

					if (childrenList != null) {
						for (var i = 0; i < childrenList.length; i++) {
							node2 = childrenList[i];
							getCheckedChildren(node2,parentNodeValue);
						}
					}
				}
				else {
					//This is Document Library or Recycle Bin
					if (node.isChecked() == true) {
						oFolder.FolderID = nodeValue;
						oFolder.Path = "/";
						oFolder.FolderSearchType = 'Include';
						oFolder.IncludeChildrenFolders = true;
						if (FindFolderByFolderID(FolderArray, nodeValue) != true) {
							FolderArray[FolderArray.length] = oFolder;
						}
					}
				}

			}


			/////////////////////////////////////////



			function onClientCheckHandler(node) {
				CheckHandler(node, 'ClientCheck')
			}

			function CheckHandler(node, handleType) {
				var containsFolderID = false;
				var strConcat = '';
				var FirstInsert = true;
				var tv = node.getParentTreeView();
				var node2 = new Object();

				var nodeList = tv.getNodes();
				var oFolder = new Object();

				strFolderList = '';
				FolderArray = new Array();

				if (nodeList[0].getText() == 'Document Library') {
					node = nodeList[0];
					if (node.isChecked() == true) {
						oFolder.FolderID = node.getValue();
						oFolder.Path = "/";
						oFolder.FolderSearchType = 'Include';
						oFolder.IncludeChildrenFolders = true;
						if (FindFolderByFolderID(FolderArray, node.getValue()) != true) {
							FolderArray[FolderArray.length] = oFolder;
						}
					}
					nodeList = nodeList[0].getNodes();
				}
				for (var i = 0; i < nodeList.length; i++) {
					node2 = nodeList[i];
					getCheckedChildren(node2,'');
				}

				strOutput = ParseFolderArray();
							
				if (document.getElementById('__searchFolders')){
					document.getElementById('__searchFolders').value=strOutput;
					//alert(strOutput);
					
					var clientID = null;
					var uniqueID = null;
					
					if (document.getElementById('__filterClientID')){
						clientID=document.getElementById('__filterClientID').value;
					}
					
					if (document.getElementById('__filterUniqueID')){
						uniqueID=document.getElementById('__filterUniqueID').value;
					}
						
					if (clientID && uniqueID){
						//if (typeof(divFilterTimer) != 'unknown') {
						//	clearTimeout(divFilterTimer);
						//}
						updateFilterControl = true;
						//bFilterTimer=true;
						//divFilterTimer = setTimeout('filterUpdateTimer()',1500);
						
						//vvCallbackGetHTML(clientID,'searchfolders',clientID,uniqueID,clientID,'','');
					}				
				}				
			}

			function onClientLoadHandler(node) {
				//Make sure that the tree is in sync in the event of page refresh.
				var rootNode = new Object();
				var nodeList = node.getNodes();

				rootNode = nodeList[0];

				var tv = rootNode.getParentTreeView();

				//tv.uncheckAll();

			}

			function GetCheckedLoadNodes(node) {
				var rootNode = new Object();
				var nodeList = node.getNodes();

				rootNode = nodeList[0];

				var tv = rootNode.getParentTreeView();

				CheckHandler(rootNode, 'SearchLoadCheck')
				//onClientCheckHandler(rootNode)

			}

			function GetNodePath(node) {
				tmpPath = '/';
				strNodeText = node.getText();
				
				if (strNodeText != 'Document Library' && strNodeText != 'Recycle Bin') {
					tmpPath = '/' + strNodeText;
				}

				AncestorList = node.getAncestors();
				AncestorList.reverse();
				try {
					if (AncestorList.length > 0) {
						for (var t = 0; t < AncestorList.length; t++) {
							tmpNode = AncestorList[t];
							strTmpNodeText = tmpNode.getText();
							if (strTmpNodeText != 'Document Library' && strTmpNodeText != 'Recycle Bin') {
								tmpPath = "/" + strTmpNodeText + tmpPath;
							}
						}
					}
				} catch(ex) {
					//alert(ex); //comment out after debug
				}
				return tmpPath;
			}

			function GetSiblingExcludedFolders(oNode, primaryNode, oFolderArray) {
				//PrimaryNode is the node that was selected or unselected to fire the events
				var oNodeValue = oNode.getValue();
				var oPrimaryNodeValue = primaryNode.getValue();
				var nodeSiblingValue;
				oParentNode = oNode.getParentTreeNode();
				
				
				if (oParentNode != null) {
					if (oParentNode.isChecked() != true) {
						//IF THE PARENT NODE IS CHECKED, WE SHOULD HAVE ALREADY EXCLUDED THE FOLDERS
						oSiblings = oParentNode.getNodes();
						if (oSiblings != null) {
							for (var s = 0; s < oSiblings.length; s++) {
								nodeSibling = oSiblings[s];
								//alert('sibling: ' + nodeSibling.getText() + ' : ' + nodeSibling.getDepth());
								nodeSiblingValue = nodeSibling.getValue();
								if (nodeSiblingValue != oNodeValue && nodeSiblingValue != oPrimaryNodeValue) {
									//THE ANCESTOR IS ALREADY IN THE EXCLUDE LIST

									//GET THE PATH FOR THE SIBLING
									tmpSiblingPath = GetNodePath(nodeSibling);

									//DON'T ALTER ANY EXISTING FOLDER ARRAY ITEMS
									//alert(tmpSiblingPath + ' : ' + nodeSibling.isChecked());
									if (nodeSibling.isChecked() != true) {
										if (FindFolderByFolderID(oFolderArray, nodeSiblingValue) != true) {
												oSiblingFolder = new FolderInfo('','','','');
												oSiblingFolder.FolderID = nodeSiblingValue;

												oSiblingFolder.Path = tmpSiblingPath;
												oSiblingFolder.FolderSearchType = 'Exclude';
												oSiblingFolder.IncludeChildrenFolders = true;

												oFolderArray[oFolderArray.length] = oSiblingFolder; //This adds onto the end  FolderArray[10] = blah; in an array where indexes are 0-9 and array.length = 10;
										}
									}
								}
									// FINISHED WITH SIBLINGS
							}
						}
					}
				}

				return oFolderArray;
			}



//RESIZE screen panes
//setup a div inside a TD like this:
//
//<td>
//	<div id="dragDiv1" style= "WIDTH: 3px; CURSOR: w-resize; HEIGHT: 100%; BACKGROUND-COLOR: silver; zIndex: 100" onmousedown="startDrag('tdDocLibraryLeft')" title='Drag to adjust width'></div>
//</td>	
//
//the onmousedown event for the div starts a drag operation, the required parameter for startDrag is the id of the column being resized
//this is generic except for the drag function which contains some document library specific resize script
//you can place script for other pages in the drag function as well, make sure it will not cause errors if the objects do not exist
//so it can be used by all screens.

var selCol=null;
var selColoffL=null;
var selTbl=null;
var selTbloffL = null;
var mouseX = null;
var tableArray = new Array()
var docBody = (document.documentElement)?document.documentElement:(document.body)?document.body:document.getElementsByTagName("body").item(0);
var mouseDir="";

document.onmousemove = captureMouse;

function falsefunc() { return false; }

function endDrag(colID){
	resizeForm(true);
}
function startDrag(colID){
		setColumnWidth = true;
		
		document.onmousedown = falsefunc;
		document.onmouseup = drop;

  		selCol=document.getElementById(colID);
  		selTbl=selCol.parentNode.parentNode;

		if (mouseX) {
			selColoffL = mouseX-parseInt(selCol.scrollWidth);
 			selTbloffL = mouseX-parseInt(selTbl.scrollWidth);
		} else {
			selColoffL = 0;
 			selTbloffL = 0;
		}
		
  		//docBody.style.cursor = 'w-resize';
  		if (hidingTree == false) {
			document.onmousemove = drag;
		}
}

function drag(e){
	var leftWidth = 0;
	try{
		captureMouse(e);

/*		if (document.body) {
			//IE
			winW = document.body.clientWidth;
			winH = document.body.clientHeight;
		} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
			winW = document.documentElement.clientWidth;
			winH = document.documentElement.clientHeight;
		} else if (self.innerWidth) {
			//Firefox
			winW = self.innerWidth;
			winH = self.innerHeight;
		}
*/		 
		if(selCol)
		{		
			
			selCol.style.width=mouseX-selColoffL + 'px';
					
			//begin document library specific resize script
		
			//once we have resized the div we need to resize the
			//other elements on the screen
			leftWidth = parseInt(selCol.style.width);
			treeColumnWidth = leftWidth;
			document.getElementById("dragDiv1").style.left=leftWidth+1;
			resizeForm(false);
								
		}
		return false;
	}
	catch(e){
	}
}

function drop(){
	
	selCol = null;
	selTbl = null;

  	//docBody.style.cursor = 'auto';

	document.onmousemove = captureMouse;
	document.onmousedown = null;
	document.onmouseup = null;
}


function clientLeft(o) {
	oLeft = o.offsetLeft;
	while(o.offsetParent!=null) {
		oParent = o.offsetParent;
		oLeft += oParent.offsetLeft;
		o = oParent;
	}
	return oLeft;
}

function clientTop(o) {
	oTop = o.offsetTop;
	while(o.offsetParent!=null) {
		oParent = o.offsetParent;
		oTop += oParent.offsetTop;
		o = oParent;
	}
	return oTop;
}

function captureMouse(e){
    //cross browswer compatible script to
    //get the current mouse position on x-axis
	if (!e) e = window.event;

	if (e)
	{ 
		if (e.pageX)
			mouseX=e.pageX;
		else if(e.clientX)
			mouseX=e.clientX + docBody.scrollLeft;
	}
	
	//determine mouse direction
	//not using this right now but was usefull during debugging
	if (selCol){
		var xPos, yPos, offset, dir;
		mouseDir = "";

		if (mouseX < selCol.offsetWidth - 5) mouseDir += "w";
		else if (mouseX > selCol.offsetWidth - 5) mouseDir += "e";
	}
}


//SCRIPTS FOR SHOWING FOLDER PATH
var displayedLayer;
var clonedLayerName;
var cloningLayerName = 'subscriptionDiv';
var xOffset = 20;
var yOffset = 0;
var LL_mousex;
var LL_mousey;
var cID = '';

bNS4 = bNS6 = bIE = bOPERA = false;
if     (navigator.userAgent.indexOf("Opera") != -1) { bOPERA = true; }
else if(navigator.userAgent.indexOf("Gecko") != -1) { bNS6 = true;   }
else if(document.layers)                            { bNS4 = true;   }
else if(document.all)                               { bIE = true;    }

LLx = LLxx = LLy = LLyy = 0;
if(bNS4 || bNS6 || bOPERA) { document.captureEvents(Event.MOUSEMOVE); }
document.onmousemove = LL_getmouseposition;



function Null() { return; }

function LL_getmouseposition(e)
{
if(bIE || bOPERA) { 
 LL_mousex = event.clientX;
 LL_mousey = event.clientY;
 }
else if(bNS6 || bNS4) {
 LL_mousex = e.pageX;
 LL_mousey = e.pageY;
 }
 return true;
} // LL_getmouseposition()

// Functions to relay browser type to custom functions
function LL_ShowLayer(_LayerName) 
{
LL_hideallinfo(_LayerName);
     if(bIE)    { LL_bIE_showit(_LayerName); }
else if(bNS6)   { LL_bNS6_showit(_LayerName); }
else if(bOPERA) { LL_bOPERA_showit(_LayerName); }
else if(bNS4)   { LL_bNS4_showit(_LayerName); }
return true;
} // LL_showinfo()

function LL_hideallinfo(_LayerName) {
     if(bIE)    { LL_bIE_hidesection(_LayerName); }
else if(bNS6)   { LL_bNS6_hidesection(_LayerName); }
else if(bOPERA) { LL_bOPERA_hidesection(_LayerName); }
else if(bNS4)   { LL_bNS4_hidesection(_LayerName); }
return true;
} // LL_hideallinfo()

// IE functions
function LL_bIE_hidesection(_LayerName) {
	document.getElementById(_LayerName).style.visibility = "hidden";
	document.getElementById(_LayerName).style.display = "none";
	return true;
} // LL_bIE_hidesection()


function LL_bIE_showit(_LayerName) {
 var x = LL_mousex + xOffset;
 if(x < 0) { x = 0; }
 var y = LL_mousey + yOffset;
 if(y < 0) { y = 0; }
 document.getElementById(_LayerName).style.left = x;
 document.getElementById(_LayerName).style.top= y;
 document.getElementById(_LayerName).style.visibility = "visible";
 document.getElementById(_LayerName).style.display = "block";
 LLx = parseInt(document.getElementById(_LayerName).style.pixelLeft);
 LLxx = parseInt(document.getElementById(_LayerName).scrollWidth) + LLx;
 LLy = parseInt(document.getElementById(_LayerName).style.pixelTop);
 LLyy = parseInt(document.getElementById(_LayerName).scrollHeight) + LLy;
 return true;
 } // LL_bIE_showit()


// Netscape 6 functions

function LL_bNS6_hidesection(_LayerName) {
	document.getElementById(_LayerName).style.visibility="hidden";
	return true;
}

function LL_bNS6_showit(_LayerName) {
	var x = LL_mousex + xOffset;
	if(x < 0) { x = 0; }
	var y = LL_mousey + yOffset;
	if(y < 0) { y = 0; }
	document.getElementById(_LayerName).style.left = x + 'px';
	document.getElementById(_LayerName).style.top = y + 'px';
	document.getElementById(_LayerName).style.visibility="visible";
	var padding = 0;
	if(parseInt(document.getElementById(_LayerName).style.padding) > 0) { padding = parseInt(document.getElementById(_LayerName).style.padding) * 2; }
	LLx = parseInt(document.getElementById(_LayerName).style.left);
	LLxx = parseInt(document.getElementById(_LayerName).style.width) + LLx + padding;
	LLy = parseInt(document.getElementById(_LayerName).style.top);
	LLyy = parseInt(document.getElementById(_LayerName).style.height) + LLy + padding;
	return true;
} 

// Opera 6 functions
function LL_bOPERA_hidesection(_LayerName) {
	document.getElementById(_LayerName).style.visibility="hidden";
	return true;
} // LL_bOPERA_hidesection()

function LL_bOPERA_showit(_LayerName) {
	var x = LL_mousex + xOffset;
	if(x < 0) { x = 0; }
	var y = LL_mousey + yOffset;
	if(y < 0) { y = 0; }
	document.getElementById(_LayerName).style.left = x + 'px';
	document.getElementById(_LayerName).style.top = y + 'px';
	document.getElementById(_LayerName).style.visibility="visible";
	var padding = 0;
	if(parseInt(document.getElementById(_LayerName).style.padding) > 0) { padding = parseInt(document.getElementById(_LayerName).style.padding) * 2; }
	LLx = parseInt(document.getElementById(_LayerName).style.left);
	LLxx = parseInt(document.getElementById(_LayerName).style.width) + LLx + padding;
	LLy = parseInt(document.getElementById(_LayerName).style.top);
	LLyy = parseInt(document.getElementById(_LayerName).style.height) + LLy + padding;
	return true;
} 

// Netscape 4 functions
function LL_bNS4_hidesection(_LayerName) {
	eval('document.' + _LayerName + '.visibility="hide"');
	return true;
} 

function LL_bNS4_showit(_LayerName) {
	var x = LL_mousex + xOffset;
	if(x < 0) { x = 0; }
	var y = LL_mousey + yOffset;
	if(y < 0) { y = 0; }
	eval('document.' + _LayerName + '.left="' + x + '"');
	eval('document.' + _LayerName + '.top="' + y + '"');
	eval('document.' + _LayerName + '.visibility="show"');
	LLx = eval('parseInt(document.' + _LayerName + '.left)');
	LLxx = eval('parseInt(document.' + _LayerName + '.clip.width)') + LLx;
	LLy = eval('parseInt(document.' + _LayerName + '.top)');
	LLyy = eval('parseInt(document.' + _LayerName + '.clip.height)') + LLy;
	return true;
} 
function LL_showstatusinfo(_InnerText) 
{
	window.status=_InnerText;
	return true;
}

function LL_hidestatusinfo() 
{
	window.status="";
	return true;
}

function LL_showinfo(_InnerText, _LayerName) 
{
LL_hideallinfo(_LayerName);
document.getElementById(_LayerName).innerHTML = _InnerText;

     if(bIE)    { LL_bIE_showit(_LayerName); }
else if(bNS6)   { LL_bNS6_showit(_LayerName); }
else if(bOPERA) { LL_bOPERA_showit(_LayerName); }
else if(bNS4)   { LL_bNS4_showit(_LayerName); }
return true;
} // LL_showinfo()
// END Functions to relay browser type to custom functions


var divTimer = '';
function hideDivTimer(divName) {
	divtimer = setTimeout('LL_hideallinfo("' + divName + '")',8000); //8 seconds
	return true;

}

function limitListBoxSelection(select) {
  try {
	for (var i = 0; i < select.options.length; i++) 
	{
		if (select.options[i].enabled=='false') {
			select.options[i].selected=false;
		}
	}	
  }
  catch(e) {
	//alert(e);
  
  } 
}

function viewDocument(DhID) {
	window.location='File_Download.aspx?id=' + DhID;
}

function checkForFilterUpdate() {
	try {
		if (updateFilterControl==true) {
			//bFilterTimer=false;
			updateFilterControl=false;
			var clientID = null;
			var uniqueID = null;
			
			if (document.getElementById('__filterClientID')){
				clientID=document.getElementById('__filterClientID').value;
			}
			
			if (document.getElementById('__filterUniqueID')){
				uniqueID=document.getElementById('__filterUniqueID').value;
			}
			
			if (clientID && uniqueID){
				vvCallbackGetHTML(clientID,'searchfolders',clientID,uniqueID,clientID,'','');
			}
		
		} 
	} catch(ex) {}
	return true;
}

function resizeFullWindow() {
	window.moveTo(0,0);
	window.resizeTo(screen.width, screen.height);
}


// ===================================================================
// Popup Div
// 
//

/* 
Last modified: 09/28/06

DESCRIPTION: This object allows you to easily and quickly popup a window
in a certain place. The window can either be a DIV or a separate browser
window.

COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small
positioning errors - usually with Window positioning - occur on the 
Macintosh platform. Due to bugs in Netscape 4.x, populating the popup 
window with <STYLE> tags may cause errors.

USAGE:
// Create an object for a WINDOW popup
var divPopup = new PopupDiv(); 

// Create an object for a DIV window using the DIV named 'mydiv'
var divPopup = new PopupDiv('mydiv'); 

// Set the window to automatically hide itself when the user clicks 
// anywhere else on the page except the popup
divPopup.autoHide(); 

// Show the window relative to the anchor name passed in
divPopup.showPopup(anchorname);

// Hide the popup
divPopup.hidePopup();

// Set the size of the popup window (only applies to WINDOW popups
divPopup.setSize(width,height);

// Populate the contents of the popup window that will be shown. If you 
// change the contents while it is displayed, you will need to refresh()
divPopup.populate(string);

// set the URL of the window, rather than populating its contents
// manually
divPopup.setUrl("http://www.site.com/");

// Refresh the contents of the popup
divPopup.refresh();

// Specify how many pixels to the right of the anchor the popup will appear
divPopup.offsetX = 50;

// Specify how many pixels below the anchor the popup will appear
divPopup.offsetY = 100;

NOTES:
1) Requires the anchor functions (See below)

2) Your anchor tag MUST contain both NAME and ID attributes which are the 
   same. For example:
   <A NAME="test" ID="test"> </A>

3) There must be at least a space between <A> </A> for IE5.5 to see the 
   anchor tag correctly. Do not do <A></A> with no space.

4) When a PopupDiv object is created, a handler for 'onmouseup' is
   attached to any event handler you may have already defined. Do NOT define
   an event handler for 'onmouseup' after you define a PopupDiv object or
   the autoHide() will not work correctly.
*/ 

// Set the position of the popup window based on the anchor
function PopupDiv_getXYPosition(anchorname) {
	var coordinates;
	if (this.type == "WINDOW") {
		coordinates = getAnchorWindowPosition(anchorname);
		}
	else {
		coordinates = getAnchorPosition(anchorname);
		}
	this.x = coordinates.x;
	this.y = coordinates.y;
	}
// Set width/height of DIV/popup window
function PopupDiv_setSize(width,height) {
	this.width = width;
	this.height = height;
	}
// Fill the window with contents
function PopupDiv_populate(contents) {
	this.contents = contents;
	this.populated = false;
	}
// Set the URL to go to
function PopupDiv_setUrl(url) {
	this.url = url;
	}
// Set the window popup properties
function PopupDiv_setWindowProperties(props) {
	this.windowProperties = props;
	}
// Refresh the displayed contents of the popup
function PopupDiv_refresh() {
	if (this.divName != null) {
		// refresh the DIV object
		if (this.use_gebi) {
			document.getElementById(this.divName).innerHTML = this.contents;
			}
		else if (this.use_css) { 
			document.all[this.divName].innerHTML = this.contents;
			}
		else if (this.use_layers) { 
			var d = document.layers[this.divName]; 
			d.document.open();
			d.document.writeln(this.contents);
			d.document.close();
			}
		}
	else {
		if (this.PopupDiv != null && !this.PopupDiv.closed) {
			if (this.url!="") {
				this.PopupDiv.location.href=this.url;
				}
			else {
				this.PopupDiv.document.open();
				this.PopupDiv.document.writeln(this.contents);
				this.PopupDiv.document.close();
			}
			this.PopupDiv.focus();
			}
		}
	}
// Position and show the popup, relative to an anchor object
function PopupDiv_showPopup(anchorname) {
	this.getXYPosition(anchorname);
	this.x += this.offsetX;
	this.y += this.offsetY;
	if (!this.populated && (this.contents != "")) {
		this.populated = true;
		this.refresh();
		}
	if (this.divName != null) {
		// Show the DIV object
		if (this.use_gebi) {
			document.getElementById(this.divName).style.left = this.x + "px";
			document.getElementById(this.divName).style.top = this.y + "px";
			document.getElementById(this.divName).style.visibility = "visible";
			}
		else if (this.use_css) {
			document.all[this.divName].style.left = this.x;
			document.all[this.divName].style.top = this.y;
			document.all[this.divName].style.visibility = "visible";
			}
		else if (this.use_layers) {
			document.layers[this.divName].left = this.x;
			document.layers[this.divName].top = this.y;
			document.layers[this.divName].visibility = "visible";
			}
		}
	else {
		if (this.PopupDiv == null || this.PopupDiv.closed) {
			// If the popup window will go off-screen, move it so it doesn't
			if (this.x<0) { this.x=0; }
			if (this.y<0) { this.y=0; }
			if (screen && screen.availHeight) {
				if ((this.y + this.height) > screen.availHeight) {
					this.y = screen.availHeight - this.height;
					}
				}
			if (screen && screen.availWidth) {
				if ((this.x + this.width) > screen.availWidth) {
					this.x = screen.availWidth - this.width;
					}
				}
			var avoidAboutBlank = window.opera || ( document.layers && !navigator.mimeTypes['*'] ) || navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled );
			this.PopupDiv = window.open(avoidAboutBlank?"":"about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"");
			}
		this.refresh();
		}
	}
// Hide the popup
function PopupDiv_hidePopup() {
	if (this.divName != null) {
		if (this.use_gebi) {
			document.getElementById(this.divName).style.visibility = "hidden";
			}
		else if (this.use_css) {
			document.all[this.divName].style.visibility = "hidden";
			}
		else if (this.use_layers) {
			document.layers[this.divName].visibility = "hidden";
			}
		}
	else {
		if (this.PopupDiv && !this.PopupDiv.closed) {
			this.PopupDiv.close();
			this.PopupDiv = null;
			}
		}
	}
// Pass an event and return whether or not it was the popup DIV that was clicked
function PopupDiv_isClicked(e) {
	if (this.divName != null) {
		if (this.use_layers) {
			var clickX = e.pageX;
			var clickY = e.pageY;
			var t = document.layers[this.divName];
			if ((clickX > t.left) && (clickX < t.left+t.clip.width) && (clickY > t.top) && (clickY < t.top+t.clip.height)) {
				return true;
				}
			else { return false; }
			}
		else if (document.all) { // Need to hard-code this to trap IE for error-handling
			var t = window.event.srcElement;
			while (t.parentElement != null) {
				if (t.id==this.divName) {
					return true;
					}
				t = t.parentElement;
				}
			return false;
			}
		else if (this.use_gebi && e) {
			var t = e.originalTarget;
			while (t.parentNode != null) {
				if (t.id==this.divName) {
					return true;
					}
				t = t.parentNode;
				}
			return false;
			}
		return false;
		}
	return false;
	}

// Check an onMouseDown event to see if we should hide
function PopupDiv_hideIfNotClicked(e) {
	if (this.autoHideEnabled && !this.isClicked(e)) {
		this.hidePopup();
		}
	}
// Call this to make the DIV disable automatically when mouse is clicked outside it
function PopupDiv_autoHide() {
	this.autoHideEnabled = true;
	}
// This global function checks all PopupDiv objects onmouseup to see if they should be hidden
function PopupDiv_hidePopupDivs(e) {
	for (var i=0; i<PopupDivObjects.length; i++) {
		if (PopupDivObjects[i] != null) {
			var p = PopupDivObjects[i];
			p.hideIfNotClicked(e);
			}
		}
	}
// Run this immediately to attach the event listener
function PopupDiv_attachListener() {
	if (document.layers) {
		document.captureEvents(Event.MOUSEUP);
		}
	window.PopupDivOldEventListener = document.onmouseup;
	if (window.PopupDivOldEventListener != null) {
		document.onmouseup = new Function("window.PopupDivOldEventListener(); PopupDiv_hidePopupDivs();");
		}
	else {
		document.onmouseup = PopupDiv_hidePopupDivs;
		}
	}
// CONSTRUCTOR for the PopupDiv object
// Pass it a DIV name to use a DHTML popup, otherwise will default to window popup
function PopupDiv() {
	if (!window.PopupDivIndex) { window.PopupDivIndex = 0; }
	if (!window.PopupDivObjects) { window.PopupDivObjects = new Array(); }
	if (!window.listenerAttached) {
		window.listenerAttached = true;
		PopupDiv_attachListener();
		}
	this.index = PopupDivIndex++;
	PopupDivObjects[this.index] = this;
	this.divName = null;
	this.PopupDiv = null;
	this.width=0;
	this.height=0;
	this.populated = false;
	this.visible = false;
	this.autoHideEnabled = false;
	
	this.contents = "";
	this.url="";
	this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";
	if (arguments.length>0) {
		this.type="DIV";
		this.divName = arguments[0];
		}
	else {
		this.type="WINDOW";
		}
	this.use_gebi = false;
	this.use_css = false;
	this.use_layers = false;
	if (document.getElementById) { this.use_gebi = true; }
	else if (document.all) { this.use_css = true; }
	else if (document.layers) { this.use_layers = true; }
	else { this.type = "WINDOW"; }
	this.offsetX = 0;
	this.offsetY = 0;
	// Method mappings
	this.getXYPosition = PopupDiv_getXYPosition;
	this.populate = PopupDiv_populate;
	this.setUrl = PopupDiv_setUrl;
	this.setWindowProperties = PopupDiv_setWindowProperties;
	this.refresh = PopupDiv_refresh;
	this.showPopup = PopupDiv_showPopup;
	this.hidePopup = PopupDiv_hidePopup;
	this.setSize = PopupDiv_setSize;
	this.isClicked = PopupDiv_isClicked;
	this.autoHide = PopupDiv_autoHide;
	this.hideIfNotClicked = PopupDiv_hideIfNotClicked;
	}

// ===================================================================
// Anchor Functions
// ===================================================================

function getAnchorPosition(anchorname){var useWindow=false;var coordinates=new Object();var x=0,y=0;var use_gebi=false, use_css=false, use_layers=false;if(document.getElementById){use_gebi=true;}else if(document.all){use_css=true;}else if(document.layers){use_layers=true;}if(use_gebi && document.all){x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);}else if(use_gebi){var o=document.getElementById(anchorname);x=AnchorPosition_getPageOffsetLeft(o);y=AnchorPosition_getPageOffsetTop(o);}else if(use_css){x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);}else if(use_layers){var found=0;for(var i=0;i<document.anchors.length;i++){if(document.anchors[i].name==anchorname){found=1;break;}}if(found==0){coordinates.x=0;coordinates.y=0;return coordinates;}x=document.anchors[i].x;y=document.anchors[i].y;}else{coordinates.x=0;coordinates.y=0;return coordinates;}coordinates.x=x;coordinates.y=y;return coordinates;}
function getAnchorWindowPosition(anchorname){var coordinates=getAnchorPosition(anchorname);var x=0;var y=0;if(document.getElementById){if(isNaN(window.screenX)){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else{x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}}else if(document.all){x=coordinates.x-document.body.scrollLeft+window.screenLeft;y=coordinates.y-document.body.scrollTop+window.screenTop;}else if(document.layers){x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;}coordinates.x=x;coordinates.y=y;return coordinates;}
function AnchorPosition_getPageOffsetLeft(el){var ol=el.offsetLeft;while((el=el.offsetParent) != null){ol += el.offsetLeft;}return ol;}
function AnchorPosition_getWindowOffsetLeft(el){return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;}
function AnchorPosition_getPageOffsetTop(el){var ot=el.offsetTop;while((el=el.offsetParent) != null){ot += el.offsetTop;}return ot;}
function AnchorPosition_getWindowOffsetTop(el){return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;}


function GetSelectedModuleDocs(target)
{
	//alert('getting docs ' + target);
	var TotalBoxes = 0;
	var TotalOn = 0;
	var values='';
	var form = document.forms[0];
		
	for (var i=0;i<form.elements.length;i++) {
		var e = form.elements[i];
		if ((e.name != 'allbox') && (e.type=='checkbox')) {
			TotalBoxes++;
			if (e.checked) {
				values += e.parentNode.getAttribute("value") + ":";
				TotalOn++;
			}
		}
	}
	document.getElementById(target).setAttribute("multivalue", values);
}

function GetSelectedModuleDocsSingleIcon(target, iconValue)
{
	//alert('getting docs ' + target);
	var TotalBoxes = 0;
	var TotalOn = 0;
	var values='';
	var form = document.forms[0];
	var curvalue='';
		
	values = iconValue + ":";
	
	for (var i=0;i<form.elements.length;i++) {
		var e = form.elements[i];
		if ((e.name != 'allbox') && (e.type=='checkbox')) {
			TotalBoxes++;
			if (e.checked) {
				curvalue=e.parentNode.getAttribute("value");
				if (curvalue!=null && curvalue!='') {
					if (iconValue.toLowerCase()!=curvalue.toLowerCase()) {
						values += curvalue + ":";
						TotalOn++;
					}
				}
			}
		}
	}
	document.getElementById(target).setAttribute("multivalue", values);
}

/**
 * X-browser event handler attachment and detachment
 * TH: Switched first true to false per http://www.onlinetools.org/articles/unobtrusivejavascript/chapter4.html
 *
 * @argument obj - the object to attach event to
 * @argument evType - name of the event - DONT ADD "on", pass only "mouseover", etc
 * @argument fn - function to call
 */
function addEvent(obj, evType, fn){
 if (obj.addEventListener){
    obj.addEventListener(evType, fn, false);
    return true;
 } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
 } else {
    return false;
 }
}
function removeEvent(obj, evType, fn, useCapture){
  if (obj.removeEventListener){
    obj.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.detachEvent){
    var r = obj.detachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
}

/**
 *
 * Gets the full width/height because it's different for most browsers.
 */
function getViewportHeight() {
	if (window.innerHeight!=window.undefined) return window.innerHeight;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight; 

	return window.undefined; 
}
function getViewportWidth() {
	var offset = 17;
	var width = null;
	if (window.innerWidth!=window.undefined) return window.innerWidth; 
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
	if (document.body) return document.body.clientWidth; 
}

/**
 * Gets the real scroll top
 */
function getScrollTop() {
	if (self.pageYOffset) // all except Explorer
	{
		return self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		return document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		return document.body.scrollTop;
	}
}
function getScrollLeft() {
	if (self.pageXOffset) // all except Explorer
	{
		return self.pageXOffset;
	}
	else if (document.documentElement && document.documentElement.scrollLeft)
		// Explorer 6 Strict
	{
		return document.documentElement.scrollLeft;
	}
	else if (document.body) // all other Explorers
	{
		return document.body.scrollLeft;
	}
}

//used by ctrlAdd_Document to set the check-in state when user changes the drop down list
function setCheckinState(obj){
	try{
		
		if(document.getElementById('__checkInState')){
		    var state = obj[obj.selectedIndex].value;
			document.getElementById('__checkInState').value = state;
		}
				
	}
	catch(e)
	{
	}
}

//used by ctrlAdd_Document to set the selected project when user changes the drop down list
function setSelectedProject(obj){
	try{
		
		if(document.getElementById('__selectedProjectID')){
		    var projectID = obj[obj.selectedIndex].value;
			document.getElementById('__selectedProjectID').value = projectID;
		}
		
		if(document.getElementById('__selectedProjectName')){
		    var projectName = obj.options[obj.selectedIndex].text;
			document.getElementById('__selectedProjectName').value = projectName;
		}
				
	}
	catch(e)
	{
	}
}

//used by ctrlAdd_Document
function setDocumentUploadRevision(obj){
	try{
		
		if(document.getElementById('__checkinRevision')){
		    var value = obj.value;
			document.getElementById('__checkinRevision').value = value;
		}				
	}
	catch(e)
	{
	}
}

//used by ctrlAdd_Document
function setDocumentUploadDocID(obj){
	try{
		
		if(document.getElementById('__checkinDocID')){
		    var value = obj.value;
			document.getElementById('__checkinDocID').value = value;
		}				
	}
	catch(e)
	{
	}
}

//used by ctrlAdd_Document
function setDocumentUploadDescription(obj){
	try{
		
		if(document.getElementById('__checkinDescription')){
		    var value = obj.value;
			document.getElementById('__checkinDescription').value = value;
		}				
	}
	catch(e)
	{
	}
}

//used by ctrlAdd_Document
function setDocumentUploadUseFileNameAsDescription(obj,txtDescriptionID){
	try{
		
		if(document.getElementById('__checkinUseFileNameAsDescription')){
		    var value = obj.checked;
			document.getElementById('__checkinUseFileNameAsDescription').value = value;
			
			if (obj.checked){
			    if(document.getElementById(txtDescriptionID)){
					var txtDescription = document.getElementById(txtDescriptionID);
					
					txtDescription.disabled = true;
					txtDescription.style.backgroundColor = "#DCDCDC";
				}
			}else{
				if(document.getElementById(txtDescriptionID)){
					var txtDescription = document.getElementById(txtDescriptionID);
					
					txtDescription.disabled = false;
					txtDescription.style.backgroundColor = "#FFFFFF";
				}
			}
		}				
	}
	catch(e)
	{
	}
}

//used by ctrlAdd_Document
function setDocumentUploadUseFileNameAsDocID(obj,txtDocID){
	try{
		
		if(document.getElementById('__checkinUseFileNameForDocID')){
		    var value = obj.checked;
			document.getElementById('__checkinUseFileNameForDocID').value = value;
			
			if (obj.checked){
			    if(document.getElementById(txtDocID)){
					var txtDocID = document.getElementById(txtDocID);
					
					txtDocID.disabled = true;
					txtDocID.style.backgroundColor = "#DCDCDC";
				}
			}else{
				if(document.getElementById(txtDocID)){
					var txtDocID = document.getElementById(txtDocID);
					
					txtDocID.disabled = false;
					txtDocID.style.backgroundColor = "#FFFFFF";
				}
			}
		}				
	}
	catch(e)
	{
	}
}

// Used by vvPopUp to retrieve values from form elements 
// and build out the querystring for the popup
function GetElementValue(elementID) {
	var value;
	
	if(document.getElementById(elementID)){
		value = document.getElementById(elementID).value;
	}
	
	return value;
}

//
//Task list set scroll position
//Sets the page scroll position to the top of the 
//first expanded task by looking for the expanded task image
function setTaskListScrollPosition(){    
  
  var imgs = document.getElementsByTagName('img'); 
  
  for(var i=0;i<imgs.length;i++){
     //for each image element determine if its the open task image    
          
     if(imgs[i].src!=null){
		 if(imgs[i].src.indexOf('images/std_minus1.gif') != -1){
			//found an expanded task image
			
			//set scroll position and quit
			var position = findPos(imgs[i]);			
			window.scrollTo(position[0],position[1]);
						
			break;
		 }
	 }
  }
}

//find the real x,y coordinates of an object
function findPos(obj) {
	var curleft = 0;
	var curtop = 0;

	if (obj.offsetParent) {

		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
		while (obj = obj.offsetParent);

	return [curleft,curtop];
	}
}

//force a parent window to set focus to its child windows
function focusChild() {	
		try {	
		
			if (childrenWindows.length > 0) {
				for(var cWinCount=0; cWinCount < childrenWindows.length; cWinCount++){
					cWindow = childrenWindows[cWinCount];
					if (cWindow && !cWindow.closed) {
						cWindow.focus();						
					}				
				}		
			}	
		}
		catch(e) {				
			
		}
}


function SetupSearchButtonTie() {
	var txtSearch = document.getElementById('txtSearch');
	
	if (window.addEventListener){
		txtSearch.addEventListener('keydown', SetTieToSearch, false);

	} else if (window.attachEvent){
		txtSearch.attachEvent('onkeydown', SetTieToSearch);
	}
}
		
		
function SetTieToSearch(evt) {
	if ((evt.which && evt.which == 13) || (evt.keyCode && evt.keyCode == 13)) { 
		try {
			document.Form1.elements['btnSearch'].click();
		} catch(e) {
			document.getElementById('btnSearch').onclick.call();
		}
		return false;
	} else {
		return true;
	}	
}
function ValidateName(el) {
	var str = el.value;
	if (IsAlphaNumeric(str) != true) {
		alert('Please enter only Alpha Numeric characters for a valid Template Name');
		return false;
	} else {
		return true;
	}
}
function IsAlphaNumeric(val) {
	if (val.match(/^[a-zA-Z0-9]+$/))
	{
		return true;
	} else {
		return false;
	} 
}

function DoCenterDetailWindow() {
	var divDetail = document.getElementById('divDetail');
	if (divDetail != null) {
		if (divDetail.style.display.toLowerCase() != 'none') {
		
			var scrollX = 0;
			var scrollY = 0;

			if (typeof document.all != 'undefined') {
				if (!document.documentElement.scrollLeft)
					scrollX = document.body.scrollLeft;
				else
					scrollX = document.documentElement.scrollLeft;
					
				if (!document.documentElement.scrollTop)
					scrollY = document.body.scrollTop;
				else
					scrollY = document.documentElement.scrollTop;
			} else {
				scrollX = window.pageXOffset;
				scrollY = window.pageYOffset;
			}
			
			var winW = 0;
			var winH = 0;

			if( typeof( window.innerWidth ) == 'number' ) {
				//Non-IE
				winW = window.innerWidth;
				winH = window.innerHeight;
			} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
				//IE 6+ in 'standards compliant mode'
				winW = document.documentElement.clientWidth;
				winH = document.documentElement.clientHeight;
			} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
				//IE 4 compatible
				winW = document.body.clientWidth;
				winH = document.body.clientHeight;
			}
			var H = winH / 2;
			var W = winW / 2;
			

			divDetail.style.top = (H - (divDetail.offsetHeight / 2)) + scrollY;
			divDetail.style.left = (W - (divDetail.offsetWidth / 2)) + scrollX;
		}
	}
}

function CenterDetailWindow(divDetail) {
	if (divDetail != null) {
		if (divDetail.style.display.toLowerCase() != 'none') {
		
			var scrollX = 0;
			var scrollY = 0;

			if (typeof document.all != 'undefined') {
				if (!document.documentElement.scrollLeft)
					scrollX = document.body.scrollLeft;
				else
					scrollX = document.documentElement.scrollLeft;
					
				if (!document.documentElement.scrollTop)
					scrollY = document.body.scrollTop;
				else
					scrollY = document.documentElement.scrollTop;
			} else {
				scrollX = window.pageXOffset;
				scrollY = window.pageYOffset;
			}
			
			var winW = 0;
			var winH = 0;

			if( typeof( window.innerWidth ) == 'number' ) {
				//Non-IE
				winW = window.innerWidth;
				winH = window.innerHeight;
			} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
				//IE 6+ in 'standards compliant mode'
				winW = document.documentElement.clientWidth;
				winH = document.documentElement.clientHeight;
			} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
				//IE 4 compatible
				winW = document.body.clientWidth;
				winH = document.body.clientHeight;
			}
			var H = winH / 2;
			var W = winW / 2;
			

			divDetail.style.top = (H - (divDetail.offsetHeight / 2)) + scrollY;
			divDetail.style.left = (W - (divDetail.offsetWidth / 2)) + scrollX;
		}
	}
}

function DoCenterDetailWindow1() {
	var divDetail = document.getElementById('divDetail1');
	if (divDetail != null) {
		if (divDetail.style.display.toLowerCase() != 'none') {
		
			var scrollX = 0;
			var scrollY = 0;

			if (document.all)
			{
				if (!document.documentElement.scrollLeft)
					scrollX = document.body.scrollLeft;
				else
					scrollX = document.documentElement.scrollLeft;
					
				if (!document.documentElement.scrollTop)
					scrollY = document.body.scrollTop;
				else
					scrollY = document.documentElement.scrollTop;
			}   
			else
			{
				scrollX = window.pageXOffset;
				scrollY = window.pageYOffset;
			}
			
			
			var winW = 0;
			var winH = 0;

			if( typeof( window.innerWidth ) == 'number' ) {
				//Non-IE
				winW = window.innerWidth;
				winH = window.innerHeight;
				
				var H = winH / 2;
				var W = winW / 2;
				
				var HalfDialog_H = divDetail.offsetHeight;
				var HalfDialog_W = divDetail.offsetWidth / 2;
				
				divDetail.style.top = (H - HalfDialog_H) - 40;
				divDetail.style.left = (W - HalfDialog_W) - 40;				
			} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
				//IE 6+ in 'standards compliant mode'
				winW = document.documentElement.clientWidth;
				winH = document.documentElement.clientHeight;
				
				var H = winH / 2;
				var W = winW / 2;
				
				var HalfDialog_H = divDetail.offsetHeight / 2;
				var HalfDialog_W = divDetail.offsetWidth / 2;
				
				divDetail.style.top = (H - HalfDialog_H) - 40;
				divDetail.style.left = (W - HalfDialog_W) - 40;
			} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
				//IE 4 compatible
				winW = document.body.clientWidth;
				winH = document.body.clientHeight;
				
				var H = winH / 2;
				var W = winW / 2;
				
				var HalfDialog_H = divDetail.offsetHeight / 2;
				var HalfDialog_W = divDetail.offsetWidth / 2;
				
				divDetail.style.top = (H - HalfDialog_H) - 40;
				divDetail.style.left = (W - HalfDialog_W) - 40;
			}


			//divDetail.style.top = (H - (divDetail.offsetHeight / 2)) + scrollY;
			//divDetail.style.left = (W - (divDetail.offsetWidth / 2)) + scrollX;
			
			//window.status="H=" + H + " W=" + W + " scrollY=" + scrollY + " scrollX=" + scrollX + " Width=" + divTask.offsetWidth + " Height=" + divTask.offsetHeight;
		}
	}
}

function BuildVVEmailUrl(baseUrl,dhID){

	//If any documents are selected (check box checked) then set DhID query string param to the comma separated list of selected ID's else
	//set the DhID query string param to the passed in dhID.

	var url=baseUrl + "SendEmail.aspx?Dhid=" + (getCheckedDocumentValues() || dhID) + "&hidemenu=true&title=Send Email";
		
	var	x=(document.all)?window.screenLeft+120:window.screenX+120;
	var y=(document.all)?window.screenTop+60:window.screenY+80;
	var nwidth=(450>screen.availWidth)?650:screen.availWidth-200;
	var nheight=(650>screen.availHeight)?650:screen.availHeight-200;
	
	var options = 'height=650,width=650,status=yes,resizable=yes,scrollbars=yes,menubar=no,toolbar=no,location=no,copyhistory=no,left='+ x + ',top=' + y +',screenX=' + x + ',screenY=' + y + '';
	
	var newwindow=window.open(url,'Send_Mail',options);	
		
	addChildWindow(newwindow);
	
	if(newwindow){
		newwindow.focus();
	}
	
	if(newwindow){
		newwindow.setTimeout('window.focus()',500);		
	}
		
}

function SendOutlookAddInEmail(baseUrl,dhID){

	//If any documents are selected (check box checked) then set DhID string to the comma separated list of selected ID's else
	//set the DhID string to the passed in dhID.

	var dhId=(getCheckedDocumentValues() || dhID);
	
	var emailTo = getRequestParameter('email');
	
	var cc = getRequestParameter('cc');
	
	//Subject "VVWEBATTACH" tells the outlook add-in this is a special message format
	//Body contains the baseUrl separated by a delimiter (:) then a comma separated list of the document dhId's or a single dhId value.
	var mailTo = 'mailto:' + emailTo + '?Subject=VVWEBATTACH&Body=' + baseUrl + ';' + dhId
	
	if(cc.length>0){
		mailTo = mailTo + '&cc=' + cc;
	}
	
	var win = window.open(mailTo,'emailWindow'); 
	if (win && win.open &&!win.closed) win.close(); 
		
}

function getRequestParameter( name ){  
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
	var regexS = "[\\?&]"+name+"=([^&#]*)";  
	var regex = new RegExp( regexS );  
	var results = regex.exec( window.location.href );  
	
	if( results == null )    
		return "";  
	else   
		return results[1];
}


