
	var locationError;
	var pageError=false;
	var parentHost;
	var parentPath;
	var topWindow;
	var moveButton = true;

	var openNew =false;
 
	window.onerror = errorTrap;	
	locationError = true;
	pageError = false;
	parentHost = parent.location.hostname
	if (pageError == true)
	{
		topWindow = 'Different host';		
	}
	else
	{
		topWindow = parent.location.hostname + parent.location.pathname.substring(0, parent.location.pathname.indexOf('/', 1));
	}

	function PageDiscussion(index,id)
	{
		var curPageNumber = document.frmResults.PageNumber.value;
		document.frmResults.PageNumberContext.value="";
		document.frmResults.PageNumberType.value="";
		document.frmResults.PageNumber.value=index;
		document.frmResults.DiscussionGroupId.value=id;
		glPageNumber = index;
		document.frmResults.submit();
		document.frmResults.PageNumber.value = curPageNumber;
	}
	
	function AutoNavigate(module,webpage,context,itemid,columntype,columnfilter,overrideid)
	{
		ClearSearch();

		var theForm = document.frmDMart;
		if(webpage!=""){theForm.action=webpage;}
		if (module != "") { theForm.strTab.value = module; }
		if (context != "") { theForm.PageContext.value = context};
		if(columntype==""){columntype="search";}
		
		if(columntype=="search" && columnfilter !=""){
			for(var x=0; x< theForm.elements.length; x++){
				if(theForm.elements[x].name=="filter_" + columnfilter){
					theForm.elements[x].value=itemid;
					break;
				}
			}
		}
		theForm.PageType.value = columntype;

		
		    
		theForm.DMartId.value=itemid;
		theForm.submit();
	}

	function SearchResults(type, column, id) 
	
	{
	    if (document.frmResults.filter_opTextSearch) {
	        CheckText(document.frmResults.filter_opTextSearch); // Clear search box default text
	    }
		//Store current values for back button users
		ClearSearch();
		var curPageContext = document.frmResults.PageContext.value;
		var curDMartId = document.frmResults.DMartId.value;
		var curPageType = document.frmResults.PageType.value;
		var curColumn = document.frmResults.ColumnType.value;
		
		//Alter values and submit
		document.frmResults.PageContext.value = type;
		document.frmResults.DMartId.value = id;
		document.frmResults.PageType.value = "search";
		document.frmResults.ColumnType.value = column;
		document.frmResults.submit();
		
		//reset values for back button users
		document.frmResults.PageContext.value = curPageContext;
		document.frmResults.DMartId.value = curDMartId;
		document.frmResults.PageType.value = curPageType;
		document.frmResults.ColumnType.value = curColumn;
	}
	
	function GoPage(index)
	{
		
		var curPageNumber = document.frmResults.PageNumber.value;
		
		document.frmResults.PageNumberContext.value="";
		document.frmResults.PageNumberType.value="";
		document.frmResults.PageNumber.value=index;
		
		glPageNumber = index;
		
		if(glPostSaveGrid=="")
		{
			document.frmResults.submit();
			document.frmResults.PageNumber.value = curPageNumber;
		}
		else
		{
			SaveGrid(glPageContext,glPageContext);
			document.frmResults.PageNumber.value = curPageNumber;
		}	
		
	}
	
	/*function PostEPetitionToDiscussion(groupid,topicid)
	{	
	
		document.frmResults.action = "discussion.aspx";
		document.frmResults.filter_TopicId.value = topicid;
		document.frmResults.filter_GroupId.value = 25;
		document.frmResults.DMartId.value=topicid;
		document.frmResults.PageContext.value = "EpetitionDiscussion";
		//document.frmResults.strTab.value="Epetition";
		//alert(document.frmResults.StrTab);
		document.frmResults.submit();
	}*/
		
	/*function PrintEPetition(groupid,topicid)
	{	
		document.frmResults.action = "epetitions.aspx";
		document.frmResults.filter_TopicId.value = topicid;
		document.frmResults.filter_GroupId.value = groupid;
		document.frmResults.PageType.value = "item";
		document.frmResults.DMartId.value=topicid;
		document.frmResults.PageContext.value = "EPetitions";
		document.frmResults.submit();
	}*/
	
	/*function PostEPetition(groupid,topicid)
	{	
		document.frmDMart.action = "discussion.aspx";
		document.frmDMart.filter_TopicId.value = topicid;
		document.frmDMart.filter_GroupId.value = groupid;
		document.frmDMart.PageContext.value = "EPetitionDetails";
		document.frmDMart.submit();
	}*/
	
	function PostDiscussion(groupid,topicid)
	{	
		document.frmDMart.action = "discussion.aspx";
		document.frmDMart.filter_TopicId.value = topicid;
		document.frmDMart.filter_GroupId.value = groupid;
		document.frmDMart.PageContext.value = "Discussions";
		document.frmDMart.submit();
	}
	
	function PageDiscussion(index,id)
	{
		var curPageNumber = document.frmResults.PageNumber.value;
		document.frmResults.PageNumberContext.value="";
		document.frmResults.PageNumberType.value="";
		document.frmResults.PageNumber.value=index;
		document.frmResults.DiscussionGroupId.value=id;
		
		glPageNumber = index;
		
		document.frmResults.submit();
		document.frmResults.PageNumber.value = curPageNumber;
		
	}
	

	function SortGridColumn(sort)
	{
	    //FRF0556
	    if (document.frmResults.filter_opTextSearch) {
		        CheckText(document.frmResults.filter_opTextSearch); // Clear search box default text
		    }
		if(glPageType=="item")
		{
		alert("item");
			document.frmResults.SortColumn.value = sort;
			PostItem(glPageContext,glDMartId);
		}
		else
		{
			document.frmResults.SortColumn.value = sort;
			document.frmResults.submit();
		}
	}

	function HideArticle(SubId, hideArticles)
	{
		document.getElementById('SubArticle'+SubId).style.display='none';
		for (i = 0; i < document.forms.length; i++)
		{
			if(document.forms[i].name!="frmShowHelp"&&document.forms[i].name!="frmFormMain")
			{
				bHide = false;
				for(j = 0; j < document.forms[i].length;j++)
				{
					if(document.forms[i].elements[j].name == "hide")
					{
						document.forms[i].elements[j].value=document.forms[i].elements[j].value + "," + SubId;
						bHide=true;
					}
				}
				if(!bHide)
				{
					var oHide = document.createElement('INPUT');
					oHide.type = "hidden";
					oHide.name = "hide";
					oHide.value = hideArticles + "," + SubId;
					document.forms[i].appendChild(oHide);
				}
			}
		}
	}

	function MoveButton(row)
	{
		if(!moveButton)
		{
			return false;
		}
		if(glRowId==-1)
		{
			glRowId=row;
			for(i=0;i<numRows;i++)
			{
				vis = "hidden";
				if(i==row)
				{
					vis="visible";
				}
				if(vis=="visible"&&i!=row)
				{
					vis="hidden";
				}
				
				eval("document.frmResults.resultgrid_SaveButton_" + i + ".style.visibility='" + vis + "';");
			}

		}
		else if(row!=glRowId)
		{
			alert(glCannotProceedUntilSave);
		}
	}

	function checkFocus(row)
	{
		if (glRowId!=-1&&glRowId!=row)
		{
			alert(glCannotProceedUntilSave);
			window.focus();
		}
	}


	function PageDiscussion(index,id)
	{
		
		var curPageNumber = document.frmResults.PageNumber.value;
		
		document.frmResults.PageNumberContext.value="";
		document.frmResults.PageNumberType.value="";
		document.frmResults.PageNumber.value=index;
		document.frmResults.DiscussionGroupId.value=id;
		
		glPageNumber = index;
		
		document.frmResults.submit();
		document.frmResults.PageNumber.value = curPageNumber;
		
	}


	function hideButton()
	{
		eval("document.frmResults.resultgrid_SaveButton_" + glRowId + ".style.visibility='hidden';");
	}

	function Go(strDateField)
	{
		//in use by the date picker.
		setDateField(strDateField);
		top.newWin = window.open('../calendar/calendar.html','cal','dependent=yes,width=210,height=230,screenX=200,screenY=300,titlebar=yes');
	}

	function RefreshPage()
	{
		//form refresh code goes here
		//document.getElementById('tab' + glPageContext).onclick();
		document.frmResults.submit();
	}

	function DisableAndSend()
	{

	    	//FRF0556
	    	if (document.frmResults.filter_opTextSearch) {
		        CheckText(document.frmResults.filter_opTextSearch); // Clear search box default text
		    }
		for(i=0; i<document.frmResults.elements.length; i++)
		{
			document.frmResults.elements[i].onfocus = function preventFocus(e) { this.blur(); };
			document.frmResults.elements[i].style.backgroundColor = '#CCCCCC';
		}
		document.frmResults.PageNumber.value="";
		document.frmResults.ChangeFilters.value="true";
		if(glHideFilters=="true")
		{
			document.frmResults.PageType.value="filter";
		}
		

		document.frmResults.submit();
	}

	function EnableSubmit()
	{
		for(i=0; i<document.frmResults.elements.length; i++)
		{
			if(document.frmResults.elements[i].type == "submit")
			{
				document.frmResults.elements[i].style.visibility = "visible";
			}
		}
	}

	function SubmitForExport()
	{
		document.frmResults.PageNumber.value=-2;
		document.frmResults.submit();
		document.frmResults.PageNumber.value=0;
	}

	function fncSubmitTab(UserID,strTab,LoggedIn,strAction,strAccess)
	{	
		var currentWindow = window.location.hostname + window.location.pathname.substring(0, window.location.pathname.indexOf('/', 1));
		
		if (currentWindow == topWindow) // no frames involved
		{
			document.frmFormMain.target='_top';
		}
		else //target=self to ensure evaluated site is kept within frames.
		{
			document.frmFormMain.target='_self';
		}
		
		// sets tab variable values and submits form	
		document.frmFormMain.UserID.value=UserID;
		document.frmFormMain.strTab.value=strTab;
		
		if(glLoggedIn)
		{
			document.frmFormMain.LoggedIn.value=LoggedIn;
		}
		else
		{
			document.frmFormMain.LoggingIn.value='tempVar';
		}

		document.frmFormMain.NoAccess.value=strAccess;
		document.frmFormMain.action=strAction;
		document.frmFormMain.Language.value=glLanguage;
		document.frmFormMain.submit();
		return false;
	}

	function errorTrap(msg, url, line)
	{
		if (locationError == true)
		{
			pageError = true;
			return true;
		}
		else
		{
			return false;
		}
	}

	function SubmitLanguage(lang)
	{
		document.frmResults.Language.value=lang;
		document.frmResults.submit();
	}

	function ShowHelp()
	{
		var divs = document.getElementsByTagName("div");
		for(i=0; i < divs.length; i++) 
		{
			if(divs[i].id.indexOf("SubArticle") == 0)
			{
				divs[i].style.display = "block";
			}
		} 
		
		for (i = 0; i < document.forms.length; i++)
		{
			for(j = 0; j < document.forms[i].length;j++)
			{
				if(document.forms[i].elements[j].name == "hide")
				{
					document.forms[i].elements[j].value="";
				}
				bHelp = false;
				if(document.forms[i].elements[j].name == "ShowHelp")
				{
					bHelp = true;
					document.forms[i].elements[j].value=glPageName;
				}
			}
			if(!bHelp)
			{
				var oHide = document.createElement('INPUT');
				oHide.type = "hidden";
				oHide.name = "ShowHelp";
				oHide.value = glPageName;
				document.forms[i].appendChild(oHide);
			}
		}
	}

	function SubmitFilters()
	{
		document.frmResults.PageType.value = "search";
		document.frmResults.submit();
	}
	
	function ShowFiltersPane(isSaved)
	{
		if(!isSaved)
		{
			document.frmResults.filter_SearchText.value="";
		}
		document.frmResults.PageType.value = "filter";
		document.frmResults.submit();
		document.frmResults.PageType.value="search";
	}
	
	function ShowResultsPane()
	{
		document.frmResults.PageType.value = "search";
		document.frmResults.submit();
		//document.getElementById("ResultPane").style.display="block";
		//document.getElementById("FilterPane").style.display="none";
	}

	function RunBasicSearch() {

	    for (i = 0; i < document.frmResults.length; i++) {
	        var obj = document.frmResults.elements[i];
	        if (obj.name.indexOf("filter_") > -1 && obj.name != "filter_opTextSearch" && obj.name != "filter_ViewType" && obj.name != "filter_optSearchOptions" && obj.name != "filter_PreviousSearch" && obj.name != "filter_optSearchWithinSearch") {
	            if (obj.type == "checkbox") {
	                if (obj.checked) {
	                    obj.checked = false;
	                }
	            }

	            if (obj.type == "text") {
	                obj.value = "";
	            }

	            if (obj.type == "select-one") {
	                obj.selectedIndex = -1;
	            }

	        }
	    }
	    

	    document.frmResults.filter_SearchText.value = document.frmResults.filter_opTextSearch.value;
	    document.frmResults.filter_SearchOptions.value = document.frmResults.filter_optSearchOptions.value;
	   
	   if (document.frmResults.filter_optSearchWithinSearch) {
	        if (document.frmResults.filter_optSearchWithinSearch.checked)
	            document.frmResults.filter_SearchWithinSearch.value = 'Y'
	        else
	            document.frmResults.filter_SearchWithinSearch.value = 'N'
	    }
	    
	    document.frmResults.PageNumber.value = "";
	    document.frmResults.breadcrumbRecordCrumb.value = "false";

	    document.frmResults.submit();

	}
	
	function RunAdvancedSearch()
	{
		document.frmResults.filter_SearchText.value=document.frmResults.filter_opTextSearch.value;
		document.frmResults.PageType.value="search";
		document.frmResults.breadcrumbRecordCrumb.value = "false";
		document.frmResults.PageNumber.value="";
		document.frmResults.submit();		
	}
	
	function ResetSearch()
	{
		try{
			for(i = 0; i < document.frmResults.length;i++)
			{	
				var obj = document.frmResults.elements[i];
				if(obj.name.indexOf("filter_")>-1)
				{
					if(obj.type=="checkbox")
					{
						if(obj.checked)
						{
							obj.checked = false;
						}
					}
					
					if(obj.type=="text"||obj.type=="hidden")
					{
						obj.value = "";
					}
					
					if(obj.type=="select-one")
					{
						obj.selectedIndex = 0;
					}
				}
			}
		}
		catch(ex){
			return false;
		}
		return false;
	}
	
	function ClearSearch()
	{
		if(document.frmResults.filter_SearchText&&document.frmResults.filter_opTextSearch) {
		    CheckText(document.frmResults.filter_opTextSearch); // Clear search box default text
			document.frmResults.filter_SearchText.value=document.frmResults.filter_opTextSearch.value;	
		}
	}
	
	function ck(e)
	{
		var _ret=false;
		var key;
		/* IE */
		if(window.event)
		{
			key = e.keyCode;
		}
		/* NS/FF/OPERA */
		else if(e.which)
		{
			key = e.which;
		}
		keychar = String.fromCharCode(key);

		if(key==13)
		{
			_ret=true;
		}
		return _ret;
	}
	
	function ClickSearch(e,doAdvanced)
	{
		if(ck(e))
		{
			if(doAdvanced)
			{
				RunAdvancedSearch();
			}
			else
			{
				RunBasicSearch();
			}
			return false;
		}
	}

	function EditItem(type, id) 
	{
	    if (document.frmResults.filter_opTextSearch) {
	        CheckText(document.frmResults.filter_opTextSearch); // Clear search box default text
	    }
		//Store current values for back button users
		var curPageContext = document.frmResults.PageContext.value;
		var curDMartId = document.frmResults.DMartId.value;
		var curPageType = document.frmResults.PageType.value;
		
		//Alter values and submit
		document.frmResults.PageContext.value = type;
		document.frmResults.DMartId.value = id;
		document.frmResults.PageType.value = "item";
		//document.frmResults.breadcrumbRecordCrumb.value = "false";
		document.frmResults.submit();
		
		//reset values for back button users
		document.frmResults.PageContext.value = curPageContext;
		document.frmResults.DMartId.value = curDMartId;
		document.frmResults.PageType.value = curPageType;
		document.frmResults.breadcrumbRecordCrumb.value = "";
	}
	
	function DeleteItem(type, id)
	{
	    if (confirm('Are you sure you want to delete this item?')) 
		{
		    if (document.frmResults.filter_opTextSearch) {
		        CheckText(document.frmResults.filter_opTextSearch); // Clear search box default text
		    }
			//Store current values for back button users
			var curPageContext = document.frmResults.PageContext.value;
			var curDMartId = document.frmResults.DMartId.value;
			var curPageType = document.frmResults.PageType.value;
			
			//Alter values and submit
			document.frmResults.PageContext.value = type;
			document.frmResults.DMartId.value = id;
			document.frmResults.autopost_deleteitem.value = "y";
			document.frmResults.PageType.value = "item";
			document.frmResults.breadcrumbRecordCrumb.value = "false";
			document.frmResults.submit();
			
			//reset values for back button users
			document.frmResults.PageContext.value = curPageContext;
			document.frmResults.DMartId.value = curDMartId;
			document.frmResults.PageType.value = curPageType;
			document.frmResults.autopost_deleteitem.value = "";
			document.frmResults.breadcrumbRecordCrumb.value = "";
			
		}
		else
		{
			return false;
		}
	}
	
	function RunCommand(type, context, coltype, id, param, message)
	{
		if((message!=""&&confirm(message))||message=="")
		{
			//Store current values for back button users
			var curDMartId = document.frmResults.DMartId.value;
			//Alter values and submit
			document.frmPostToFrame.runCommand.value = type;
			document.frmPostToFrame.DMartId.value = id;
			document.frmPostToFrame.ActionParam.value = param;
			document.frmResults.PageNumber.value=glPageNumber;
			document.frmPostToFrame.ColumnType.value = coltype;
			document.frmPostToFrame.ReturnContext.value=context;
			
			for(i=0; i<document.frmResults.elements.length; i++)
			{
				if(document.frmResults.elements[i].name.indexOf("filter_")==0)
				{
					var elem = document.frmResults.elements[i];
					var name = elem.name.substring(7);
					 
					
					for(j=0; j<document.frmPostToFrame.elements.length; j++)
					{
						if(document.frmPostToFrame.elements[j].name.toUpperCase()==name.toUpperCase())
						{
							document.frmPostToFrame.elements[j].value=elem.value;
						}
					}
				}
			}
							
			document.frmPostToFrame.submit();
			
			//reset values for back button users
			document.frmPostToFrame.ActionParam.value = "";
			document.frmPostToFrame.RunCommand.value = type;
			document.frmPostToFrame.DMartId.value = curDMartId;
			document.frmResults.PageNumber.value="";
			
			
		}
		else
		{
			return false;
		}
	}
	
	function ReturnFromCommand(context, type, id)
	{
		if(context!="")
		{
			document.frmResults.PageContext.value = context;
			if(type=="")
			{
				type="search";
			}
			if(id!="")
			{
				document.frmResults.DMartId.value = id;
			}
			//document.frmResults.breadcrumbRecordCrumb.value = "false";
			document.frmResults.PageType.value = type;
			document.frmResults.submit();	
		}
		return false;
	}
	
	function GoPopUp(strValue) {
		// Upload file to server
		var wUpload,STRUrl, rstr
		
		rstr = strValue.match("FileString")
		if (rstr == "FileString")
		{
			STRUrl = "../admincenter/UploadPopup3.asp?nId=" + strValue

			uUpload = window.open(STRUrl,'UploadPopup','menubar=no,toolbar=no,location=no,status=yes,resizable=yes,width=700,height=200');

		}
		else
		{
		STRUrl = "../admincenter/UploadPopup2.asp?nId=" + strValue

		uUpload = window.open(STRUrl,'UploadPopup','menubar=no,toolbar=no,location=no,status=yes,resizable=yes,width=700,height=200');
		}
		
		}
	
	
	function UpdateGridField(popField, gridField)
	{
	
		popField.value="";
		if(gridField.length>0)
		{
			var inc;

			for (i=0;i<gridField.length;i++)
			{
				inc = true;
				if(gridField[i].type=="checkbox")
				{
					if(!gridField[i].checked)
					{
						inc=false;
					}
				}

				if(inc==true)
				{
					popField.value += gridField[i].value + "|";
				}
			}
		}
		else
		{
			if(gridField.checked)
			{
				popField.value = gridField.value + "|";
			}
		}
		
		if(popField.value.length>0)
		{
			popField.value = "|" + popField.value;
		}
		else
		{
			popField.value = "EMPTY";
		}

	}
	
	function LoadHtmlEditor(formField,columnLength)
	{
		var HtmlWindow = window.open("blank.htm","RichText","menubar=no,toolbar=no,location=no,status=yes,resizable=yes,width=700,height=550");
		
		var frm = document.frmPostRichText;
		
		frm.TextToLoad.value = eval("document.frmResults.resultgrid_" + formField + ".value");	
		frm.FormFieldId.value = formField;
		frm.ColumnLength.value = columnLength;
		frm.submit();

	}
	
	function ClearResults()
	{
		for(i=0; i<theForm.elements.length; i++)
		{
			if(theForm.elements[i].name.indexOf("autopost_")>-1)
			{
				theForm.elements[i].value="";
			}
		}
	}
	
	function DeleteValue(col)
	{
		
		var theForm = document.frmResults;
		
		for(i=0; i<theForm.elements.length; i++)
		{
			if(theForm.elements[i].name=="autopost_" + col)
			{
				theForm.elements[i].value="";
				break;
			}
		}
		
	}
	
	function UpdateRecord(val,context,type,filter)
	{
		document.frmResults.DMartId.value = val;
		document.frmResults.ColumnType.value = filter;
		document.frmPostToFrame.DMartId.value = val;
		//document.frmResults.breadcrumbRecordCrumb.value = "false";
		
		CancelRow(context,type);
	}
	
	//News centre
	function PostReport(id,name, path)
	{
		if (path != "")
		{
			//alert(sPath);
			document.frmResults.action=path;
		}
		document.frmResults.ReportId.value = id;
		document.frmResults.TopicId.value = "";
		document.frmResults.ReportName.value = name;
		document.frmResults.TopicName.value = "";
		document.frmResults.submit();
	}
	
	function PostTopic(id,name)
	{
		document.frmResults.TopicId.value = id;
		document.frmResults.TopicName.value = name;
		document.frmResults.submit();
	}
	
	function PostMoreLink(id,strTab)
	{
		document.frmResults.strTab.value = strTab;
		document.frmResults.SubArticleId.value = id;
	}

	
	function ClearTopic(frm)
	{
		frm.TopicId.value = '';
		frm.TopicName.value = '';
		frm.submit();				
	}
	
	function ClearLibrary(frm)
	{
		if(frm.TopicId)				frm.TopicId.value = '';
		if(frm.TopicName)			frm.TopicName.value = '';
		if(frm.ReportName)			frm.ReportName.value = '';
		if(frm.ReportId)			frm.ReportId.value = '';
		if(frm.SubArticleId)		frm.SubArticleId.value = '';
		frm.submit();				
	}
	
	function PostSearch(module,topicid,topicname,reportid,reportname,articleid)
	{
		var strTab = document.frmResults.strTab.value;
		var searching = document.frmResults.Searching.value;
		
		document.frmResults.strTab.value = module;
		
		document.frmResults.PageContext.value = module;
		
		document.frmResults.PageType.value = "library";
		
		document.frmResults.TopicName.value = topicname;
		
		document.frmResults.TopicId.value = topicid;
		
		document.frmResults.ReportName.value = reportname;
		document.frmResults.ReportId.value = reportid;
		document.frmResults.SubArticleId.value = articleid;
		document.frmResults.Searching.value = "N";
		
		document.frmResults.submit();
		
		//Reset searching in case back button is clicked
		document.frmResults.Searching.value = searching;
		document.frmResults.strTab.value = strTab;
		
	}
	
	function trimDescription(txt, size)
	{
		if(size=="")
		{
			return false;
		}
		var str=txt.value;
		if (str.length > parseInt(size))
		{
			txt.value = str.substring(0, parseInt(size));
		}
		return(txt.value);
	}
	
	//Scheduler specific
	
	function SwitchView()
	{
		var filterType = document.frmResults.filter_ViewType.value;
		if(filterType=="Calendar")
		{
			document.frmResults.filter_ViewType.value="Timeline";
		}
		else if(filterType=="Timeline")
		{
			document.frmResults.filter_ViewType.value="Calendar";
		}	
		
		document.frmResults.submit();	
		document.frmResults.filter_ViewType.value=filterType;
	}
	
	function SetDate(theDate)
	{
		document.frmResults.filter_StartDate.value=theDate;
		document.frmResults.submit();
	}
	
	function ExportElabToExcel(CampaignId,DisplayResultsAs)
	{
		document.frmElab.action = "elabexport.aspx";
		document.frmElab.CampaignId.value = CampaignId;
		document.frmElab.DisplayResultsAs.value = DisplayResultsAs;
		document.frmElab.submit();
		document.frmElab.action = "elab.aspx";
    }

    // CRF0336 - Previous version was slow and was not validating if more than 1 decimal in input
    function IsNumeric(input) {
        return (input - 0) == input && (input + '').length > 0;
    }
	
	function CheckText(sb)
	{
		if(sb.className=="searchDefault")
		{
			sb.className = "searchEntry";
			
			sb.value = "";
		}
	}
	
	function PrintPage()
	{
		window.print();
	}
	
	function AddFormElement(frmName,elemName,elemValue,inputType) {

		frm=document.getElementById(frmName);

		var node = document.createElement("input");

		node.name=elemName;
		node.value=elemValue;
		node.type = inputType;

		frm.appendChild(node);

	}
	
	function searchMe(tab){	
		var iBrowser = 0;
		var str;
		
		if (glUseGlossaryPopup != 'Y') return false;
		
		if (navigator.appName == "Microsoft Internet Explorer")
			iBrowser = 1;
		if (navigator.appName == "Netscape")
			iBrowser = 2;
		
		if (iBrowser == 2) {
			str = document.getSelection();
			if (str.length < 1)
				return;
		}
		
		if (iBrowser == 1) {
			var txt = document.selection.createRange();	
			str = txt.text
			if (str.length < 1)
				return;
			if (document.selection.type != 'Text')
				return;
			if (document.activeElement.tagName != 'TD')
				return;
		}
		window.open("../library/gloss.asp?Term=" + str, null, "height=400, width=400, scrollbars=yes, status=no, toolbar=no, menubar=no, location=no");
	}

	function searchTxt(txt){
		window.open("../library/gloss.asp?Term=" + txt, null, "height=400, width=400, scrollbars=yes, status=no, toolbar=no, menubar=no, location=no, resizable=yes");
	}
	
	function SelectAll(frmName)
	{
		document.getElementById("CheckAll_" + frmName).style.display = "none";
		document.getElementById("CheckNone_" + frmName).style.display = "block";
		var frm = document.frmResults;
		for(i=0;i<frm.length;i++)
		{
			if(frm[i].name.indexOf("resultgrid_" + frmName)==0)
			{
				frm[i].checked = true;	
			}
		}
	}
	
	function SelectNone(frmName)
	{
		document.getElementById("CheckAll_" + frmName).style.display = "block";
		document.getElementById("CheckNone_" + frmName).style.display = "none";
		var frm = document.frmResults;
		for(i=0;i<frm.length;i++)
		{
			if(frm[i].name.indexOf("resultgrid_" + frmName)==0)
			{
				frm[i].checked = false;	
			}
		}

}



function passwordStrength(password, minlength, maxlength, minnumeric, minalpha, minsymbol, minupper, minlower, minstrength) {
    var desc = new Array();
    desc[0] = "Very Weak";
    desc[1] = "Weak";
    desc[2] = "Better";
    desc[3] = "Medium";
    desc[4] = "Strong";
    desc[5] = "Strongest";

    var score = 0;
    var helptext = "";
    //if password bigger than minlength give 1 point
    if (password.length >= minlength) score++;

    //if password has both lower and uppercase characters give 1 point	
    if ((password.match(/[a-z]/)) && (password.match(/[A-Z]/))) score++;

    //if password has at least one number give 1 point
    if (password.match(/\d+/)) score++;

    //if password has at least one special caracther give 1 point
    if (password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/)) score++;

    //if password length equals or bigger than maxlength give another 1 point
    if (password.length >= maxlength) score++;

    if (!password.match(".[!,@,#,$,%,^,&,*,>,<,?,_,=,+,),(,£,¬,~,-,(,),.]{" + minsymbol + "}"))
        helptext += "Symbols: " + minsymbol + "<br/>";

    if (!password.match("[a-z]{" + minlower + "}"))
        helptext += "Lower Case Characters: " + minlower + "<br/>";

    if (!password.match("[A-Z]{" + minupper + "}"))
        helptext += "Upper case characters: " + minupper + "<br/>";

    if (!password.match("\\d{" + minnumeric + "}"))
        helptext += "Numeric Characters: " + minnumeric + "<br/>";

    if (password.length < minlength)
        helptext += "Minimum Length: " + minlength + "<br/>";

    if (score < minstrength)
        helptext += "PasswordStrength: " + desc[minstrength] + "<br/>";

    if (helptext.length > 0)
        helptext = "Please complete following requirements:<br/>" + helptext;

    document.getElementById("passwordrequirements").innerHTML = helptext;
    document.getElementById("passwordDescription").innerHTML = desc[score];
    document.getElementById("passwordStrength").className = "strength" + score;

    if (helptext.length > 0)
        return false;
    else
        return true;
}

function validatenewpassword(minlength, maxlength, minnumeric, minalpha, minsymbol, minupper, minlower, minstrength) {

    password = document.getElementById("newpassword").value;
    confirmpassword = document.getElementById("confirmpassword").value;

    if (!passwordStrength(password, minlength, maxlength, minnumeric, minalpha, minsymbol, minupper, minlower, minstrength)) {
        alert("Please complete the password requiremetns");
        return false;
    }
    else if (password != confirmpassword) {
        alert("Password do not match.");
        return false;
    }
    else
        return true;


}

function resizeText(multiplier) {
    if (document.body.style.fontSize == "") {
        document.body.style.fontSize = "1.0em";
    }
    document.body.style.fontSize = parseFloat(document.body.style.fontSize) + (multiplier * 0.2) + "em";
}    
    
	
		
	for (i = 0; i < document.forms.length; i++)
	{
		for(j = 0; j < document.forms[i].length;j++)
		{
			if(document.forms[i].elements[j].name == "AcceptedConditions")
			{
				document.forms[i].elements[j].value="";
			}
		}
	}
		
		
		
		

