function LeftOf(StringToSearch,SubString){	var i = StringToSearch.indexOf(SubString);	if(i<0){return '';}	return StringToSearch.substr(0,i);}function LeftBackOf(StringToSearch,SubString){	var i = StringToSearch.lastIndexOf(SubString);	if(i<0){return '';}	return StringToSearch.substr(0,i);}function RightOf(StringToSearch,SubString){	var i = StringToSearch.indexOf(SubString);	if(i<0){return '';}	return StringToSearch.substring(i+SubString.length,StringToSearch.length);}function RightBackOf(StringToSearch,SubString){	var i = StringToSearch.lastIndexOf(SubString);	if(i<0){return '';}	return StringToSearch.substring(i+SubString.length,StringToSearch.length);}function Middle( _cString, _cStart, _cEnd){	var cEndPart = RightOf( _cString, _cStart );	var cMiddle = LeftOf( cEndPart, _cEnd );	if(cMiddle.length == 0){return cEndPart;}	return cMiddle;}function NoSpaceStr( _cString , _nPart ){   var nFirst = 0;   var nLast = _cString.length-1;   // Left   if (_nPart & 1){while (_cString.charAt(nFirst)==" "){nFirst++;}}   // Right   if (_nPart & 2){while (_cString.charAt(nLast)==" "){   nLast--;}}   return _cString.substring(nFirst,nLast+1);}function SetCookie(pname, pvalue, validity){	if(pvalue != null){		if(validity > 0){					var today = new Date();			var expiry = new Date(today.getTime() + validity);			document.cookie = pname + '=' + pvalue + '; expires=' + expiry.toGMTString() + '; path=/;';		}		else{document.cookie = pname + '=' + pvalue + '; path=/;';}	}}function GetCookie(pname){	var index = document.cookie.indexOf(pname + '=');	if (index == -1){return null;}	index = document.cookie.indexOf("=", index) + 1;	var endstr = document.cookie.indexOf(";", index);	if (endstr == -1){endstr = document.cookie.length;}	return document.cookie.substring(index, endstr);}function SetElementPosition(_cElementID, _cTargetElementID, _cLeftPosition, _cTopPosition){	var g_oElement = document.getElementById(_cElementID);	if(g_oElement){		if(_cLeftPosition.length > 0 && _cTopPosition.length > 0){			g_oElement.style.position = 'absolute';			g_oElement.style.left = _cLeftPosition;			g_oElement.style.top = _cTopPosition;		}		else{			var g_oTargetElement = document.getElementById(_cTargetElementID);			if(g_oTargetElement){				if(g_oTargetElement.appendChild){g_oTargetElement.appendChild(g_oElement);}			}		}	}}function DisplayElement(_cElementID, _cTargetElementID){	var bCheckTarget = false;	var g_oElement = document.getElementById(_cElementID);	var g_oTargetElementID = document.getElementById(_cTargetElementID);	if(_cTargetElementID.length == 0)	{		bCheckTarget = true	}	else	{		if(g_oTargetElementID){bCheckTarget = true}	}	if(g_oElement && bCheckTarget){		if(g_oElement.style){			g_oElement.style.display = '';		}	}}function HideElement(_cElementID){	var g_oElement = document.getElementById(_cElementID);	if(g_oElement){		if(g_oElement.style){			g_oElement.style.display = 'none';		}	}}function ListKeywordValue(sLKAlias , bReturn){	if( sLKAlias == '') return '';	str = document.forms[0].ListKeywordValueTranslation.value;	strbeg = str.indexOf(sLKAlias);	if(strbeg > -1){		str = str.substring(strbeg);		str = str.substring(str.indexOf(':=') + 2);		strend = str.indexOf('~');		if(strend > -1){str = str.substring(0,strend);}	}	else{str = sLKAlias;}	if( bReturn ){return str;	}	else{			result=document.write(str);   	          document.close();   	}}function LabelValue(sLNum){	str = document.forms[0].FormLabels.value;	if(arguments[2]){str = arguments[2];}	strbeg = str.indexOf(sLNum);	if(strbeg > -1){		str = str.substring(strbeg);		str = str.substring(str.indexOf(':=') + 2);		strend = str.indexOf('~');		if(strend > -1){str = str.substring(0,strend);}	}	else{str = sLNum;}	if(arguments[1]){return str;}	else{		result=document.write(str);		document.close();	}}Redirected = false;function Redirect(){	//if(!g_cIsMultiSite){return;}	if(g_cIsMultiSite=='1'){		var map = g_cMapping.split(',');		var redir_srv, redir_remote, redir_remote_part, remote, match=0, tmp_match;		remote = g_cRemote_Addr.split('.');		var i=0;		while(i<map.length && match<4){			redir_remote = map[i].substring(0,map[i].indexOf(':=')).split('.');			if(redir_remote.length<5){				tmp_match = 0;				var k = 0;				while(k < redir_remote.length && tmp_match >= 0){					redir_remote_part = parseInt(redir_remote[k]);					if( ! isNaN(redir_remote_part)){						if(remote[k] == redir_remote_part){tmp_match++;}						else{tmp_match = -1;}						k++;																}					else{k = redir_remote.length}									}				if(match < tmp_match){					match = tmp_match;					redir_srv = map[i].substring(map[i].indexOf(':=') + 2, map[i].length);				}			}			i++;		}		if(match == 0){redir_srv = g_cDefaultServer;}		if(redir_srv){			var url_tmp1 = window.location.href.substring(0,window.location.href.indexOf('//') + 2);			var url_tmp2 = window.location.href.substring(window.location.href.indexOf('//') + 2, window.location.href.length);			var url_tmp3 = url_tmp2.substring(url_tmp2.indexOf('/'), url_tmp2.length);			var cur_srv = url_tmp2.substring(0,url_tmp2.indexOf('/'));			if(cur_srv.toLowerCase() != redir_srv.toLowerCase()){window.location.href = url_tmp1 + redir_srv + url_tmp3;}			else{Redirected = true;}		}	}	else{Redirected = true;}}function Search(_nSearchType){	var goForm = window.document.forms[0];	var gdDate1;	var gdDate2;	var gaDate1 = '';	var gaDate2 = '';	var gcExpToReplace = '';	var gcNewExp = '';	var gcResultView = '';	var gnStartSearch = true;	var gcKeywLength = 0;	var gcTxtQuery = '';	var gcKeywordQuery = '';	var gcDocTypeQuery = '';	var gcListQuery = '';	var gcCatQuery = '';	var gcDateQuery = '';	var gcDepartmentQuery = '';	var gcContentOnlySuffix = '';	if(g_cContentOnly == '1'){gcContentOnlySuffix = '&contentonly=1'}	if(g_cForceTargetNew == '1'){gcContentOnlySuffix = gcContentOnlySuffix + '&targetnew=1'}	switch(_nSearchType)	{		case 1: //Simple search			gcResultView = 'vEmPageSearch';			if( goForm.QueryForSearchR ){gcTxtQuery = goForm.QueryForSearchR.value;}			else{gcTxtQuery = goForm.QueryForSearch.value;}			break;		case 2: //Advanced search			gcTxtQuery = goForm.FTQuery.value;			if(goForm.AdvSearchDocType){				for(i=1;i < goForm.AdvSearchDocType.options.length;i++)				{					if(goForm.AdvSearchDocType.options[i].selected){gcDocTypeQuery = gcDocTypeQuery + "+OR+([PageSelectedLists]+CONTAINS+(" + goForm.AdvSearchDocType.options[i].value + "))";}				}				gcDocTypeQuery = RightOf(gcDocTypeQuery,"+OR+");			}			gcResultView = 'vEmPageSearch';			break;		case 3: //List search			gcTxtQuery = goForm.FTQuery.value;			if(gcListToSearch != ''){				gcDocTypeQuery = "([PageSelectedLists]+CONTAINS+(" + gcListToSearch + "))";				gcListQuery = '&searchorder=4&lst=' + gcListAliasToSearch+ '&lstc=' + gcListContainerAliasToSearch;			}			gcCatQuery = GetCategoryQueryPart();			if(gcCatQuery != ''){gcDocTypeQuery = gcDocTypeQuery + gcCatQuery;}			gcResultView = 'vEmListSearch';			break;	}	gcTxtQuery = NoSpaceStr(gcTxtQuery, 3);	gcExpToReplace = / /gi;	gcNewExp = g_cPageSearchRequestType;	if(gcNewExp == '+AND+' || gcNewExp == '+OR+'){gcNewExp = '"' + gcNewExp + '"';}	gcTxtQuery = gcTxtQuery.replace(gcExpToReplace, gcNewExp);	if(gcTxtQuery != null && gcTxtQuery != ''){gcTxtQuery = '("' + gcTxtQuery + '")';}	if(_nSearchType == 2 || _nSearchType == 3)	{		if(goForm.AdvSearchKeywords){			for(j=1;j < goForm.AdvSearchKeywords.options.length;j++)			{				if(goForm.AdvSearchKeywords.options[j].selected){gcKeywordQuery = gcKeywordQuery + "+OR+([PageSearchKeyw]+CONTAINS+(" + goForm.AdvSearchKeywords.options[j].value + "))";}			}			gcKeywordQuery = RightOf(gcKeywordQuery,"+OR+");		}		if(goForm.AdvSearchDocDept){			for(k=1;k < goForm.AdvSearchDocDept.options.length;k++)			{				if(goForm.AdvSearchDocDept.options[k].selected){gcDepartmentQuery = gcDepartmentQuery + "+OR+([PageDepartment]+CONTAINS+(" + goForm.AdvSearchDocDept.options[k].value + "))";}			}			gcDepartmentQuery = RightOf(gcDepartmentQuery,"+OR+");		}		if(goForm.AdvSearchLastUpdate && goForm.AdvSearchLastUpdate_1)		{			if(goForm.AdvSearchLastUpdate.value != '' && goForm.AdvSearchLastUpdate_1.value != '')			{				gaDate1 = goForm.AdvSearchLastUpdate.value.split('/');				gaDate2 = goForm.AdvSearchLastUpdate_1.value.split('/');				if(gnDateFormat == '2'){					gdDate1 = new Date(parseInt(Number(gaDate1[2])), parseInt(Number(gaDate1[0]))-1, parseInt(Number(gaDate1[1]))); // year, month, day					gdDate2 = new Date(parseInt(Number(gaDate2[2])), parseInt(Number(gaDate2[0]))-1, parseInt(Number(gaDate2[1])));				}				else{					gdDate1 = new Date(parseInt(Number(gaDate1[2])), parseInt(Number(gaDate1[1]))-1, parseInt(Number(gaDate1[0])));					gdDate2 = new Date(parseInt(Number(gaDate2[2])), parseInt(Number(gaDate2[1]))-1, parseInt(Number(gaDate2[0])));				}				if(gdDate1>gdDate2){					gnStartSearch = false;					alert(gcDateRangeErrMsg);					return;				}				else{					if(String(gdDate1).length > 0){gcDateQuery = "([PageLastModified]>=" + goForm.AdvSearchLastUpdate.value + ")";}					if(gcDateQuery.length > 0 && String(gdDate2).length > 0){gcDateQuery = gcDateQuery + "+AND+" + "([PageLastModified]<=" + goForm.AdvSearchLastUpdate_1.value + ")";}				}			}		}		if(gcTxtQuery == '' && gcKeywordQuery == '' && gcDateQuery == '' && gcDocTypeQuery == '' && gcDepartmentQuery == ''){			gnStartSearch = false;			alert(gcNoCriterionErrMsg);			return;		}		if(gnStartSearch){			gcQuery = gcTxtQuery;			if(gcKeywordQuery.length > 0){if(gcQuery.length > 0){gcQuery = gcQuery + "+AND+";}gcQuery = gcQuery+gcKeywordQuery;}			if(gcDateQuery.length > 0){if(gcQuery.length > 0){gcQuery = gcQuery + "+AND+";}gcQuery = gcQuery+gcDateQuery;}			if(gcDocTypeQuery.length > 0){if(gcQuery.length > 0){gcQuery = gcQuery + "+AND+";}gcQuery = gcQuery+gcDocTypeQuery;}			if(gcDepartmentQuery.length > 0){if(gcQuery.length > 0){gcQuery = gcQuery + "+AND+";}gcQuery = gcQuery+gcDepartmentQuery;}			if(g_cWebUserLanguageCode != null && g_cWebUserLanguageCode != ''){				gcQuery = gcQuery + '+AND+([PageLanguageForSelection]+CONTAINS+(' + g_cWebUserLanguageCode + '))';			}			window.location = "" + g_cDbName + '/' + gcResultView + '?SearchView' + gcListQuery + '&Query=' + escape(gcQuery) + '&unid=-' + gcContentOnlySuffix;		}	}	else{		if(gcTxtQuery.length > 0){			if(g_cWebUserLanguageCode != null && g_cWebUserLanguageCode != ''){				gcTxtQuery = gcTxtQuery + '+AND+([PageLanguageForSelection]+CONTAINS+(' + g_cWebUserLanguageCode + '))';			}			window.location = "" + g_cDbName + '/' + gcResultView + '?SearchView&Query=' + escape(gcTxtQuery) + '&unid=-' + gcContentOnlySuffix;		}	}}function GetCategoryQueryPart(){	var gcCatFieldPrefix = '';	var gcCatFieldPrefix2 = 'Cat';	var gcCatQuery = '';	var goForm = document.forms[0];	switch(gcListToSearch)	{		case 'EventsList':		gcCatFieldPrefix = 'PageEvents';		case 'EducationsList':		gcCatFieldPrefix = 'PageEvents';		break;		case 'FAQList':		gcCatFieldPrefix = 'PageFAQ';		break;		case 'PressReleasesList':		gcCatFieldPrefix = 'PagePressReleases';		break;		case 'PublicationsList':		gcCatFieldPrefix = 'PagePublications';		break;		case 'NewsList':		break;		default:		gcCatFieldPrefix = 'PageList';		break;	}	for(i=1;i<=6;i++)	{		if(eval("goForm.AdvSearchCategory" + i))		{			if(eval("goForm.AdvSearchCategory" + i + ".selectedIndex") >= 0)			{				if(eval("goForm.AdvSearchCategory" + i + ".options[goForm.AdvSearchCategory" + i +".selectedIndex].value.length") > 0)				{					if(gcCatFieldPrefix == 'PageList')					{						gcCatQuery = gcCatQuery + "+AND+(([" + gcCatFieldPrefix + "1" + gcCatFieldPrefix2 + i + "]+CONTAINS+(" + eval("goForm.AdvSearchCategory" + i + ".options[goForm.AdvSearchCategory" + i + ".selectedIndex].value") + "))";						gcCatQuery = gcCatQuery + "+OR+([" + gcCatFieldPrefix + "2" + gcCatFieldPrefix2 + i + "]+CONTAINS+(" + eval("goForm.AdvSearchCategory" + i + ".options[goForm.AdvSearchCategory" + i + ".selectedIndex].value") + ")))";					}					else					{						gcCatQuery = gcCatQuery + "+AND+([" + gcCatFieldPrefix + gcCatFieldPrefix2 + i + "]+CONTAINS+(" + eval("goForm.AdvSearchCategory" + i + ".options[goForm.AdvSearchCategory" + i + ".selectedIndex].value") + "))";					}				}			}		}	}	return gcCatQuery;}function CommonSubmit(){	Search(1);	return false;}function ContentRefresh(sLanguage){	var TrPageURLField = eval('g_cPageLanguage' + sLanguage + 'URL');	if(TrPageURLField){		if(TrPageURLField.length > 0){window.location.href = TrPageURLField;}		else{window.location.reload();}	}	else{window.location.reload();	}}function Login(){	if(top.location.href.indexOf('&login=1') < 0){top.location.href = top.location.href + '&login=1'}}function LaunchBookmark(_cTargetPageUNID, _oHotspot){	var cCurrentPageUNID = '';	var cTarget = '';	var cURL = '';	if(_oHotspot.target!=''){cTarget = _oHotspot.target;}	_oHotspot.target = '_self';	if (g_cPageCurrentPageUNID){cCurrentPageUNID = g_cPageCurrentPageUNID;}	if (_cTargetPageUNID != '' && cCurrentPageUNID != ''){		cURL = g_cDbName + "/PageLaunchBookmark?openagent&targetpageunid=" + _cTargetPageUNID + "&currentpageunid=" + cCurrentPageUNID + "&";		if(cTarget != ''){window.open(cURL, cTarget);}		else{window.location = cURL;}	}}function AddDocRequest(_cUNID){	var addDocReqWin = window.open('/' + g_cRequestsRepID + '/fAddDocRequest?OpenForm&unid=' + _cUNID,'AddDocRequestWin');	addDocReqWin.focus();}function AddDocRequest_CreateSyntax( _cUnid ){	return '<A href="javascript:AddDocRequest(\''+ _cUnid +'\')"> '+ g_cRequestsImage +' </A>';}function EventRegistration(_cUNID){	var oRegWin = window.open('/' + g_cRequestsRepID + '/fEventRegistration?OpenForm&unid=' + _cUNID,'RegistrationWin');	oRegWin.focus();}function OnlineReg_CreateSyntax( _cUnid ){	return '<A href="javascript:EventRegistration(\''+ _cUnid +'\')"> '+ g_cRequestsImage +' </A>';}function GetQueryType(){	var goRadioButtonField = document.forms[0].AdvSearchFTCondition;	if(goRadioButtonField)	{		for(i=0;i<goRadioButtonField.length;i++)		{			if(goRadioButtonField[i].checked){g_cPageSearchRequestType = goRadioButtonField[i].value;}		}	}}function GetCategory(_cCategories,_nCatNbr,_cPreviousCat,_nLabelAlias){	var gcCatAlias = Middle(_cCategories,"Cat" + _nCatNbr + _cPreviousCat + ":=","#");	if(gcCatAlias == '')return '';	var gcAliasReplaced = LeftOf(gcCatAlias,"-") + RightOf(gcCatAlias,"-");	var gcCatLab = '';	if(gcAliasReplaced == ''){return '';}	else{gcCatLab = eval("gc" + g_cWebUserLanguageCode + gcAliasReplaced);}	if(_nLabelAlias == 1){return gcCatAlias;}	else{return gcCatLab;}}function GetCategoryFieldValue(goSelectField){	if(goSelectField)	{		for(i=0;i<goSelectField.options.length;i++)		{			if(goSelectField.options[i].selected){return goSelectField.options[i].value;}		}	}	else{return "";}}function PopulateCategoryField(_nCurCatNbr,_cPreviousCatAlias){	var goForm = document.forms[0];	var gnOptionIndex = 0;	var gnInsert = true;	var gcText = "";	var gcValue = "";	var gcMacro = "\"\"";	if(_nCurCatNbr == 1 || (eval("goForm.AdvSearchCategory" + _nCurCatNbr) && eval("goForm.AdvSearchCategory" + (_nCurCatNbr - 1))))	{		for(j=_nCurCatNbr;j<=6;j++){ClearCategoryField(j);}		if(_nCurCatNbr == 1 || (eval("goForm.AdvSearchCategory" + (_nCurCatNbr - 1) + ".options[goForm.AdvSearchCategory" + (_nCurCatNbr - 1) + ".options.selectedIndex].value !=''")))		{			for(x=1;x<gcCategoriesNbr;x++)			{				gcText = eval("GetCategory(gcCategory"+x+"," + _nCurCatNbr + ",\"" + _cPreviousCatAlias + "\",2)");				gcValue = eval("GetCategory(gcCategory"+x+"," + _nCurCatNbr + ",\"" + _cPreviousCatAlias + "\",1)");				if(gcText != "" && gcValue != "")				{					gcMacro = gcMacro + ",\"" + gcText + "|" + gcValue + "\"";				}			}			if(gcMacro != "")			{				var gcCatArray = eval("new Array(" + gcMacro + ")");				gcCatArray.sort();			}			for(y=0;y<gcCatArray.length;y++)			{				gnInsert = true;				if(gnOptionIndex == 0)				{					eval("goForm.AdvSearchCategory" + _nCurCatNbr + ".options[" + gnOptionIndex + "] = new Option(\"\",\"\");");					eval("goForm.AdvSearchCategory" + _nCurCatNbr + ".options[" + gnOptionIndex + "].selected = true");					gnOptionIndex++;				}				else				{					gcText = LeftOf(gcCatArray[y],"|");					gcValue = RightOf(gcCatArray[y],"|");					for(j=0;j<eval("goForm.AdvSearchCategory" + _nCurCatNbr + ".options.length");j++)					{						if(eval("goForm.AdvSearchCategory" + _nCurCatNbr + ".options[" + j + "].value") == gcValue){gnInsert = false;}					}					if(gnInsert)					{						eval("goForm.AdvSearchCategory" + _nCurCatNbr + ".options[" + gnOptionIndex + "] = new Option(gcText,gcValue);");						gnOptionIndex++;					}				}			}			if(gnOptionIndex > 1)			{				var goSelect = eval("document.getElementById('cat" + _nCurCatNbr + "');");				if(goSelect){					goSelect.style.display = 'block';					var goCategoryRow = document.getElementById('categoriestr');					if(goCategoryRow){goCategoryRow.style.display = '';}				}			}		}	}}function ClearCategoryField(_nCatNbr){	var goForm = document.forms[0];	var gnIndex = 0;	var goField = null;	if(eval("goForm.AdvSearchCategory" + _nCatNbr))	{		gnIndex = eval("goForm.AdvSearchCategory" + _nCatNbr + ".options.length");		for(i=0;i<gnIndex;i++)		{			if(eval("goForm.AdvSearchCategory" + _nCatNbr + ".options[" + i + "]"))			{				eval("goForm.AdvSearchCategory" + _nCatNbr + ".options[" + i + "].selected = false");				eval("goForm.AdvSearchCategory" + _nCatNbr + ".options[" + i + "] = null");			}		}		goField = eval("document.getElementById('cat" + _nCatNbr + "');")		if(goField){goField.style.display = 'none';}	}}
