/*
|	Search manager
|
|	Shows and manages the "Search the site" dialog
|	Requires: core.js,connection.js
*/

		//Search
		{hp.search=function(){
			var oFSConn=hp.http.conn(),nCurrPage=1,nPageCount=1,oSearchFullGo,oSearchFullInput,oTList,oFSPages,oFSLinks,oFSLoader,oFSNoResult,oFullSearch_term,nNewPos=0,vCurrSearchType='Videos',vCurrentSearchTerm='';
			var oDataFlag=[],oVideosCache,oDocumentsCache,oEventsCache,oDiscussionsCache,oCommunityCache;
			return {
				attach:function(){
					//get
					oSearchFullInput=hp.utils.get('oSearchFullInput'),oFSNoResult=hp.utils.get('oFSNoResult'),oFSLoader=hp.utils.get('oFSLoader'),oFSLinks=hp.utils.get('oFSLinks'),oTList=hp.utils.get('oFSResultPane'),oFSPages=hp.utils.get('oFSPages'),oFullSearch_term=hp.utils.get('oFullSearch_term');

					//attach
					
					hp.utils.addEvent(hp.utils.get('oSearchFullGo'),'click',hp.search.run);
					hp.utils.addEvent(hp.utils.get('oFSVideosHolder'),'click',function(){hp.search.listing.switchSearchType('Videos');});
					//hp.utils.addEvent(hp.utils.get('oFSDocumentsHolder'),'click',function(){hp.search.listing.switchSearchType('Documents');});
					//hp.utils.addEvent(hp.utils.get('oFSEventsHolder'),'click',function(){hp.search.listing.switchSearchType('Events');});
					hp.utils.addEvent(hp.utils.get('oFSDiscussionsHolder'),'click',function(){hp.search.listing.switchSearchType('Discussions');});
					hp.utils.addEvent(hp.utils.get('oFSCommunityHolder'),'click',function(){hp.search.listing.switchSearchType('Community');});
					hp.utils.addEvent(window,'resize',function(){hp.utils.maximise('oFullSearch_u');}); //resize watcher
					//close
					hp.utils.addEvent(hp.utils.get('oFullSearchClose'),'click',hp.search.close);
					//first run
					hp.search.run();
				},
				vNoiseWords:"*or*near*not*a*about*again*all*almost*also*although*always*among*an*and*another*any*are*as*at*be*because*been*before*being*between*both*but*by*can*could*did*do*does*done*due*during*each*either*enough*especially*etc*for*found*from*further*had*has*have*having*here*how*however*i*if*in*into*is*it*its*itself*just*kg*km*made*mainly*make*may*mg*might*ml*mm*most*mostly*must*nearly*neither*no*nor*obtained*of*often*on*our*overall*perhaps*quite*rather*really*regarding*seem*seen*several*should*show*showed*shown*shows*significantly*since*so*sum*such*than*that*the*their*theirs*them*then*there*therefore*these*they*this*those*through*thus*to*upon*use*used*using*various*very*was*we*were*what*when*which*while*with*within*without*would*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*1*2*3*4*5*6*7*8*9*0*",
				entire:function(){
					//get search from quicksearch
					var oP=hp.utils.get('oSearchPortal');
					if(oP.value!=''){
						//
						oSearchFullInput.value=oP.value.trim().stripTags().replace('\\',' ').replace('/',' ');
						//clear last searchtype class
						hp.utils.get('oFS'+vCurrSearchType+'Holder').className='';
						hp.utils.get('oFS'+vCurrSearchType+'Holder').style.cursor='pointer';
						//set new and clear mini search
						oP.value='';vCurrSearchType='Videos';
						hp.search.run();hp.search.open();hp.minisearch.close();
					}
				},
				tags:function(vTag){
					//get search from tags
					if(vTag!=''){
						//clear last searchtype class
						hp.utils.get('oFS'+vCurrSearchType+'Holder').className='';
						hp.utils.get('oFS'+vCurrSearchType+'Holder').style.cursor='pointer';
						//set new search value and perform search
						oSearchFullInput.value=vTag;
						vCurrSearchType='Videos';
						hp.search.run();hp.search.open();
					}
				},
				run:function(){
					//get term					
					vCurrentSearchTerm=oSearchFullInput.value;
					(vCurrentSearchTerm!='')?oFullSearch_term.innerHTML=': '+vCurrentSearchTerm.trim().stripTags():null;
					//clear previous
					(oDataFlag.length>0)?oDataFlag.splice(0,oDataFlag.length):null;
					hp.utils.get('oFSVideosCount').innerHTML=hp.utils.get('oFSDiscussionsCount').innerHTML=hp.utils.get('oFSCommunityCount').innerHTML='';
					//send search
				hp.search.listing.switchSearchType(vCurrSearchType);

				},
				listing:function(){
					return {
						calculateScroll:function(){
							nPageCount=Math.ceil(oTList.offsetHeight/400);
							(nPageCount<1)?oFSPages.innerHTML='No pages.':oFSPages.innerHTML='Page '+nCurrPage+' of '+nPageCount;
							//output options
							(nPageCount>1)?((nCurrPage==1)?oFSLinks.innerHTML='Previous | <a href="javascript:hp.search.listing.scroll(true);">Next</a>':((nCurrPage==nPageCount)?oFSLinks.innerHTML='<a href="javascript:hp.search.listing.scroll(false);">Previous</a> | Next':oFSLinks.innerHTML='<a href="javascript:hp.search.listing.scroll(false);">Previous</a> | <a href="javascript:hp.search.listing.scroll(true);">Next</a>')):oFSLinks.innerHTML='';
						},
						scroll:function(bDown){
							(bDown)?nCurrPage++:nCurrPage--;
							hp.search.listing.calculateScroll();
							hp.animate.run({init:hp.animate.moveTo,target:'oFSResultPane',y:((bDown)?nNewPos-=400:nNewPos+=400)});
						},
						switchSearchType:function(vNew){
							if(vCurrentSearchTerm!=''){
								
								//set nav
								hp.utils.get('oFS'+vCurrSearchType+'Holder').className='',hp.utils.get('oFS'+vCurrSearchType+'Holder').style.cursor='pointer';
								hp.utils.get('oFS'+vNew+'Holder').className='on',hp.utils.get('oFS'+vNew+'Holder').style.cursor='default';
								//set type
								vCurrSearchType=vNew;
								//show loader
								oTList.style.display='none',oFSNoResult.style.display='none',oFSLoader.style.display='block';
								oTList.style.top='399px';
								hp.animate.run({init:hp.animate.moveTo,target:'oFSResultPane',y:400});
								//refresh data
								nCurrPage=1,nPageCount=1;
								hp.search.listing.getData();
							} else {
								oFSNoResult.innerHTML='<h2>Please enter a search term below and hit \'Search\'.</h2>';
								oFSNoResult.style.display='block';
							}
						},
						getData:function(){
							//set search term
							vCurrentSearchTerm=vCurrentSearchTerm.trim().stripTags().replace('\\',' ').replace('/',' ');
							//check data doesnt already exist
							var bDataExists=false;
							for(var i=0;i<oDataFlag.length;i++){
								if(oDataFlag[i]==vCurrSearchType){
									bDataExists=true;
								}
							}
							//get data, cached or new
							oFSConn.abort();//clean up previous request
							if(!bDataExists){
								oFSConn.open("get","/get/search/full/?s="+vCurrentSearchTerm+"&t="+vCurrSearchType.toLowerCase(),true);
								oFSConn.onreadystatechange=function() {
									if(oFSConn.readyState==4){
										if (oFSConn.status==200) {
											(vCurrSearchType=='Videos')?oVideosCache=eval("("+oFSConn.responseText+")")
											:(vCurrSearchType=='Documents')?oDocumentsCache=eval("("+oFSConn.responseText+")")
											:(vCurrSearchType=='Events')?oEventsCache=eval("("+oFSConn.responseText+")")
											:(vCurrSearchType=='Discussions')?oDiscussionsCache=eval("("+oFSConn.responseText+")")
											:(vCurrSearchType=='Community')?oCommunityCache=eval("("+oFSConn.responseText+")")
											:alert('A data directive has failed. Please reload the page. Sorry for an inconvenience.');;;;;
											oDataFlag.push(vCurrSearchType);
											hp.search.listing.showNewPage();
										} else {
											hp.search.listing.showNewPage(true);
										}
									}
								}
								oFSConn.send(null);
							}else{
								hp.search.listing.showNewPage();
							}
						},
						showNewPage:function(bError){
							if(bError){
								hp.search.listing.sendError();
							}else{
								var oData=eval('o'+vCurrSearchType+'Cache'),vSearchItems='',nLength=oData.results.length;
								hp.utils.get('oFS'+vCurrSearchType+'Count').innerHTML='&nbsp;('+nLength+')';
								//loop thru results
								if(nLength>0){
									for(var i=0;i<nLength;i++){
										if(vCurrSearchType=='Videos'){
											vSearchItems+='<div class="fs_list_item"><a href="tv.asp?id='+oData.results[i].id+'"><div class="imgholder left"><img src="http://video.telecomtv.com/web2/ugc/thumb/'+oData.results[i].imgurl+'_small.jpg" /></div><div class="left" style="width:280px;"><span class="right darktext" style="margin-left:10px;">'+hp.utils.simpledate(oData.results[i].date)+'</span><h3>'+oData.results[i].title+'</h3><p>'+oData.results[i].snippet.stripBreaks()+'</p></div><div style="clear:left;"></div></a></div>';
										}else if(vCurrSearchType=='Documents'){
											vSearchItems+='<div class="fs_list_item"><a href="documents.asp?view='+oData.results[i].id+'"><span class="right darktext" style="margin-left:10px;">'+hp.utils.simpledate(oData.results[i].date)+'</span><h3>'+oData.results[i].title+'</h3><p>'+oData.results[i].snippet.stripBreaks()+'</p></a></div>';
										}else if(vCurrSearchType=='Events'){
											vDay=oData.results[i].startdate.substring(0,2);
											vMonth=oData.results[i].startdate.split(' ')[1].substring(0,3);
											vSearchItems+='<div class="fs_list_item"><a href="documents.asp?view='+oData.results[i].id+'"><div class="calenderbox left"><h1>'+vDay+'</h1><div><h3>'+vMonth+'</h3></div></div><div class="left" style="width:420px;"><span class="right darktext" style="margin-left:10px;">'+oData.results[i].startdate+' &ndash;<br/>'+oData.results[i].enddate+'<br/></span><h3>'+oData.results[i].title+'</h3><h4 class="darkgrey">'+oData.results[i].type+'</h4><p>'+oData.results[i].snippet.stripBreaks()+'</p></div><div style="clear:left;"></div></a></div>';
										}else if(vCurrSearchType=='Discussions'){
											var vBody=oData.results[i].body.stripBreaks().stripTags(),nId=oData.results[i].id,vImage,vComments;vSnippet=(vBody.length>170)?vBody.substring(0,167).trim().trimFullStops()+'...':vBody;
											vImage=(oData.results[i].image=="True")?vImage='/images/discussions/'+nId+'.jpg':'/images/discussions/discussion.gif';
											vComments=(parseInt(oData.results[i].commentcount))?'Comment':'Comments';
											vSearchItems+='<div class="fs_list_item"><a href="discussion.asp?view='+nId+'"><div class="imgholder left"><img src="'+vImage+'" /></div><div class="left" style="width:380px;"><span class="right darktext" style="margin-left:10px;">'+hp.utils.simpledate(oData.results[i].date)+'</span><h3>'+oData.results[i].title+'</h3><h4 class="darkgrey">'+oData.results[i].username+', '+oData.results[i].country+' | '+oData.results[i].commentcount+' '+vComments+'</h4><p>'+vSnippet+'</p></div><div style="clear:left;"></div></a></div>';
										}else if(vCurrSearchType=='Community'){
											var vImage,nId,vLink='',vLinkClose='';
											nId=oData.results[i].id;vImage=(oData.results[i].image=="True")?'/images/profiles/thmb_'+nId+'.jpg':'/images/profile.gif';
											vLink='<a href="community.asp?id='+parseInt(nId)+'#'+parseInt(nId)+'">',vLinkClose='</a>';
											vTel=(oData.results[i].number!="")?'<p><h4>Telephone: '+oData.results[i].number+'</h4></p>':'';
											vSearchItems+='<div class="fs_list_item">'+vLink+'<div class="imgholder left"><img src="'+vImage+'" /></div><div class="left" style="width:380px;"><h3>'+oData.results[i].name+' &ndash; '+oData.results[i].company+'</h3><h4 class="darkgrey">'+oData.results[i].job+'</h4><h4 class="light darkgrey">'+oData.results[i].country+'</h4></div><div style="clear:left;"></div>'+vLinkClose+'</div>';
										}
									};
								}else{
									oFSNoResult.innerHTML='<h2>Sorry, no results for \''+vCurrentSearchTerm+'\' found in '+vCurrSearchType+'!</h2><h4>Try a different category or refine your search.</h4>';
									oFSNoResult.style.display='block';
								}
								//output new data
								oTList.innerHTML=vSearchItems;								
								//refresh screen
								nCurrPage=1,nPageCount=1,nNewPos=0;
								oTList.style.display='block';
								oFSLoader.style.display='none';
								hp.search.listing.calculateScroll();
								hp.animate.run({init:hp.animate.moveTo,target:'oFSResultPane',y:0});
							}
						},
						openContactMail:function(nId){
							hp.search.close();
							hp.mailbox.composeFromContactId.compose(nId);
						},
						sendError:function(){
							oFSLoader.style.display='none';
							oFSNoResult.innerHTML='<h2>Sorry, an internal error has occurred.</h2>';
							oFSNoResult.style.display='block';
						}
					}
				}(),
				open:function(){
					hp.utils.get('oFullSearch_o').style.display='block';
					hp.utils.get('oFullSearch_u').style.display='block';
					window.scrollTo(0,0);
					hp.utils.maximise('oFullSearch_u');
				},
				close:function(){
					hp.utils.get('oFullSearch_o').style.display='none';
					hp.utils.get('oFullSearch_u').style.display='none';
				}
			}
		}()}
		
		
		//Mini Search function
		{hp.minisearch=function(){
			var oSR=hp.http.conn(),vSearchListBody_Docs,vSearchListBody_Discussions,vSearchListBody_Events,vSearchListBody_Videos;
			return {
				nPos:0,
				attach:function(){
					//add events
					hp.utils.addEvent(hp.utils.get('oSearchPortal'),'focus',function(){if(this.value!=''){hp.minisearch.show();}});
					hp.utils.addEvent(hp.utils.get('oSearchPortal'),'keyup',hp.minisearch.show); //search site button
					hp.utils.addEvent(hp.utils.get('oSearchClose'),'click',hp.minisearch.close); //explore site button
				},
				show:function(e) {
					var oP=hp.utils.get('oSearchPortal');
					if(oP.value!='') {
						var nKey=(e!=undefined)?e.keyCode:65; //fake keypress if required (a used)
						if(!hp.utils.isInvalidKey(nKey)){
							vTerm=oP.value.trim().stripTags().replace('\\',' ').replace('/',' ');
							if (hp.utils.get('oSearch_o').style.display!='block'){
								//position and show
								var nOT=0,nOL=0;
								oT=hp.utils.get('oSearch_o');
								oT.style.display='block';
								while(oP.offsetParent!=null){nOT+=oP.offsetTop;nOL+=oP.offsetLeft;oP=oP.offsetParent;}
								oT.style.top=(nOT-30)+"px",oT.style.left=(nOL-(oT.offsetWidth+4))+"px";
							}
							//set search term
							hp.utils.get('oSearch_term').innerHTML='"'+vTerm+'"';
							//results loading
							hp.utils.get('oResultLoader').style.visibility='visible';
							//results pane
							var oRP=hp.utils.get('oRP'),oRP_Docs=hp.utils.get('oSearch_Docs'),oRP_Discussions=hp.utils.get('oSearch_Discussions'),oRP_Events=hp.utils.get('oSearch_Events'),oRP_Videos=hp.utils.get('oSearch_Videos');
							var oTitle_Docs=hp.utils.get('oTitle_Docs'),oTitle_Discussions=hp.utils.get('oTitle_Discussions'),oTitle_Events=hp.utils.get('oTitle_Events'),oTitle_Videos=hp.utils.get('oTitle_Videos');
							oSR.abort();//clean up previous request
							oSR.open("get","/get/search/mini/?s="+vTerm,true);
							oSR.onreadystatechange=function() {
								if(oSR.readyState==4){
									if (oSR.status==200) {
										//clear loader
										hp.utils.get('oResultLoader').style.visibility='hidden';
										//Clear messages
										oRP.innerHTML='';
										//output response
										oResponse=eval("("+oSR.responseText+")"),vSearchListBody_Docs='',vSearchListBody_Discussions='',vSearchListBody_Events='',vSearchListBody_Videos='';
										nSearchLength=oResponse.results.length;
										if(nSearchLength>0){
											for(var i=0;i<nSearchLength;i++){
												var vSearchType=oResponse.results[i].type,vSearchItem='';
												if(vSearchType=='Event'){vSearchLink='events.asp?id='+oResponse.results[i].id+'&last_search='+vTerm;}
												else if(vSearchType=='Discussion'){vSearchLink='discussion.asp?view='+oResponse.results[i].id+'&last_search='+vTerm;}
												else if(vSearchType=='Document'){vSearchLink='documents.asp?view='+oResponse.results[i].id+'&last_search='+vTerm;}
												else if(vSearchType=='Video'){vSearchLink='tv.asp?id='+oResponse.results[i].id+'&last_search='+vTerm;}
												else{vSearchLink='/?';};
												//get record to output/video thumb
												if(vSearchType=='Video'){
													vSearchItem='<li class="video"><a href="'+vSearchLink+'"><img src="http://video.telecomtv.com/web2/ugc/thumb/'+oResponse.results[i].thumb+'_small.jpg" class="left" /><h4>'+hp.minisearch.highlight(oResponse.results[i].title,vTerm)+'</h4><div style="clear:left;"></div></a></li>';
												}else if(vSearchType=='Event'){
													vSearchItem='<li><a href="'+vSearchLink+'"><h4>'+hp.minisearch.highlight(oResponse.results[i].title,vTerm)+'<br/><span class="grey light"><em>'+oResponse.results[i].datestart+' - '+oResponse.results[i].dateend+'</em></span></h4></a></li>';
												}else{
													vSearchItem='<li><a href="'+vSearchLink+'"><h4>'+hp.minisearch.highlight(oResponse.results[i].title,vTerm)+'</h4></a></li>';
												}
												
												if(vSearchType=='Document'){
													vSearchListBody_Docs+=vSearchItem;
												}else if(vSearchType=='Discussion'){
													vSearchListBody_Discussions+=vSearchItem;
												}else if(vSearchType=='Event'){
													vSearchListBody_Events+=vSearchItem;
												}else if(vSearchType=='Video'){
													vSearchListBody_Videos+=vSearchItem;
												}
											};
											if(vSearchListBody_Docs!=''){oRP_Docs.innerHTML='<ul>'+vSearchListBody_Docs+'</ul>';oRP_Docs.style.display='block';oTitle_Docs.style.display='block';}else{oRP_Docs.style.display='none';oTitle_Docs.style.display='none';};
											if(vSearchListBody_Discussions!=''){oRP_Discussions.innerHTML='<ul>'+vSearchListBody_Discussions+'</ul>';oRP_Discussions.style.display='block';oTitle_Discussions.style.display='block';}else{oRP_Discussions.style.display='none';oTitle_Discussions.style.display='none';};
											if(vSearchListBody_Events!=''){oRP_Events.innerHTML='<ul>'+vSearchListBody_Events+'</ul>';oRP_Events.style.display='block';oTitle_Events.style.display='block';}else{oRP_Events.style.display='none';oTitle_Events.style.display='none';};
											if(vSearchListBody_Videos!=''){oRP_Videos.innerHTML='<ul>'+vSearchListBody_Videos+'</ul>';oRP_Videos.style.display='block';oTitle_Videos.style.display='block';}else{oRP_Videos.style.display='none';oTitle_Videos.style.display='none';};
										}else{
											oRP_Docs.style.display='none';oTitle_Docs.style.display='none';
											oRP_Discussions.style.display='none';oTitle_Discussions.style.display='none';
											oRP_Events.style.display='none';oTitle_Events.style.display='none';
											oRP_Videos.style.display='none';oTitle_Videos.style.display='none';
											oRP.innerHTML='<div style="margin:10px 0 0 0;" class="grey"><em>Your Quick Search for <span style="font-weight: bold;color:#FFF !important;">\''+vTerm+'\'</span> has returned no results. Please refine your search.</em></div>';
										}
										
										//full search link
										oRP.innerHTML+='<ul class="endlink"><li><h4><a href="javascript:hp.search.entire();">Didn\'t find what you were looking for in this Quick Search? Search the entire website &raquo;</a></h4></li></ul>';

									}
								}
							};
							oSR.send(null);
						};
					}else{
						hp.minisearch.close();
					}
				},
				close:function(){
					hp.utils.get('oSearch_o').style.display='none';
				},
				highlight:function(vText,vTerms){
					var aTerm=vTerms.split(' '),vRE='';
					for(var i=0;i<aTerm.length;i++){
						if(aTerm[i].trim()!=''&&hp.search.vNoiseWords.indexOf("*"+aTerm[i]+"*")<0){
							vRE+=aTerm[i]+"|";
						}
					};vRE=vRE.substring(0,(vRE.length-1));
					vText=vText.replace(new RegExp("("+vRE+")","ig"),'<span class="highlight">$1</span>');
					return vText;
				},
				lastsearch:function(vS){
					var oP=hp.utils.get('oSearchPortal');
					oP.value=vS;oP.focus();
				}
			}
		}()};
		
		//Mini Search Users function
		{hp.minisearchUser=function(){
			var oSR=hp.http.conn(),vSearchListBody_Docs,vSearchListBody_Discussions,vSearchListBody_Events,vSearchListBody_Videos;
			return {
				nPos:0,
				attach:function(){
					//add events
					hp.utils.addEvent(hp.utils.get('oSearchPortalUsers'),'focus',function(){if(this.value!=''){hp.minisearchUser.show();}});
					hp.utils.addEvent(hp.utils.get('oSearchPortalUsers'),'keyup',hp.minisearchUser.show); //search site button
					hp.utils.addEvent(hp.utils.get('oSearchCloseUsers'),'click',hp.minisearchUser.close); //explore site button
				},
				show:function(e) {
					var oP=hp.utils.get('oSearchPortalUsers');
					if(oP.value!='') {
						var nKey=(e!=undefined)?e.keyCode:65; //fake keypress if required (a used)
						if(!hp.utils.isInvalidKey(nKey)){
							vTerm=oP.value.trim().stripTags().replace('\\',' ').replace('/',' ');
							if (hp.utils.get('oSearch_oUsers').style.display!='block'){
								//position and show
								var nOT=0,nOL=0;
								oT=hp.utils.get('oSearch_oUsers');
								oT.style.display='block';
								while(oP.offsetParent!=null){nOT+=oP.offsetTop;nOL+=oP.offsetLeft;oP=oP.offsetParent;}
								oT.style.top=(nOT)+"px",oT.style.left=(nOL-(oT.offsetWidth-508))+"px";
							}
							//set search term
							hp.utils.get('oSearch_termUsers').innerHTML='"'+vTerm+'"';
							//results loading
							hp.utils.get('oResultLoaderUsers').style.visibility='visible';
							//results pane
							var oRP=hp.utils.get('oRPusers'),oRP_Docs=hp.utils.get('oSearch_DocsUsers'),oRP_Discussions=hp.utils.get('oSearch_DiscussionsUsers'),oRP_Events=hp.utils.get('oSearch_EventsUsers'),oRP_Videos=hp.utils.get('oSearch_VideosUsers');
							var oTitle_Docs=hp.utils.get('oTitle_DocsUsers'),oTitle_Discussions=hp.utils.get('oTitle_DiscussionsUsers'),oTitle_Events=hp.utils.get('oTitle_EventsUsers'),oTitle_Videos=hp.utils.get('oTitle_VideosUsers');
							oSR.abort();//clean up previous request
							oSR.open("get","/get/search/users/?s="+vTerm,true);
							oSR.onreadystatechange=function() {
								if(oSR.readyState==4){
									if (oSR.status==200) {
										//clear loader
										hp.utils.get('oResultLoaderUsers').style.visibility='hidden';
										//Clear messages
										oRP.innerHTML='';
										//output response
										oResponse=eval("("+oSR.responseText+")"),vSearchListBody_Docs='',vSearchListBody_Discussions='',vSearchListBody_Events='',vSearchListBody_Videos='';
										nSearchLength=oResponse.results.length;
										if(nSearchLength>0){
											for(var i=0;i<nSearchLength;i++){
												var vSearchType=oResponse.results[i].type,vSearchItem='';
												if(vSearchType=='Event'){vSearchLink='events.asp?id='+oResponse.results[i].id+'&last_search='+vTerm;}
												else if(vSearchType=='Discussion'){vSearchLink='discussion.asp?view='+oResponse.results[i].id+'&last_search='+vTerm;}
												else if(vSearchType=='Document'){vSearchLink='documents.asp?view='+oResponse.results[i].id+'&last_search='+vTerm;}
												else if(vSearchType=='Video'){vSearchLink='tv.asp?id='+oResponse.results[i].id+'&last_search='+vTerm;}
												else{vSearchLink='/?';};
												//get record to output/video thumb
												if(vSearchType=='Video'){
													vSearchItem='<li class="video"><a href="'+vSearchLink+'"><img src="http://video.telecomtv.com/web2/ugc/thumb/'+oResponse.results[i].thumb+'_small.jpg" class="left" /><h4>'+hp.minisearchUser.highlight(oResponse.results[i].title,vTerm)+'</h4><div style="clear:left;"></div></a></li>';
												}else if(vSearchType=='Event'){
													vSearchItem='<li><a href="'+vSearchLink+'"><h4>'+hp.minisearchUser.highlight(oResponse.results[i].title,vTerm)+'<br/><span class="grey light"><em>'+oResponse.results[i].datestart+' - '+oResponse.results[i].dateend+'</em></span></h4></a></li>';
												}else{
													vSearchItem='<li><a href="'+vSearchLink+'"><h4>'+hp.minisearchUser.highlight(oResponse.results[i].title,vTerm)+'</h4></a></li>';
												}
												
												if(vSearchType=='Document'){
													vSearchListBody_Docs+=vSearchItem;
												}else if(vSearchType=='Discussion'){
													vSearchListBody_Discussions+=vSearchItem;
												}else if(vSearchType=='Event'){
													vSearchListBody_Events+=vSearchItem;
												}else if(vSearchType=='Video'){
													vSearchListBody_Videos+=vSearchItem;
												}
											};
											if(vSearchListBody_Docs!=''){oRP_Docs.innerHTML='<ul>'+vSearchListBody_Docs+'</ul>';oRP_Docs.style.display='block';oTitle_Docs.style.display='block';}else{oRP_Docs.style.display='none';oTitle_Docs.style.display='none';};
											if(vSearchListBody_Discussions!=''){oRP_Discussions.innerHTML='<ul>'+vSearchListBody_Discussions+'</ul>';oRP_Discussions.style.display='block';oTitle_Discussions.style.display='block';}else{oRP_Discussions.style.display='none';oTitle_Discussions.style.display='none';};
											if(vSearchListBody_Events!=''){oRP_Events.innerHTML='<ul>'+vSearchListBody_Events+'</ul>';oRP_Events.style.display='block';oTitle_Events.style.display='block';}else{oRP_Events.style.display='none';oTitle_Events.style.display='none';};
											if(vSearchListBody_Videos!=''){oRP_Videos.innerHTML='<ul>'+vSearchListBody_Videos+'</ul>';oRP_Videos.style.display='block';oTitle_Videos.style.display='block';}else{oRP_Videos.style.display='none';oTitle_Videos.style.display='none';};
										}else{
											oRP_Docs.style.display='none';oTitle_Docs.style.display='none';
											oRP_Discussions.style.display='none';oTitle_Discussions.style.display='none';
											oRP_Events.style.display='none';oTitle_Events.style.display='none';
											oRP_Videos.style.display='none';oTitle_Videos.style.display='none';
											oRP.innerHTML='<div style="margin:10px 0 0 0;" class="grey"><em>Your Quick Search for <span style="font-weight: bold;color:#FFF !important;">\''+vTerm+'\'</span> has returned no results. Please refine your search.</em></div>';
										}
										
										//full search link
										oRP.innerHTML+='<ul class="endlink"><li><h4><a href="javascript:hp.search.entire();">Didn\'t find what you were looking for in this Quick Search? Search the entire website &raquo;</a></h4></li></ul>';

									}
								}
							};
							oSR.send(null);
						};
					}else{
						hp.minisearchUser.close();
					}
				},
				close:function(){
					hp.utils.get('oSearch_oUsers').style.display='none';
				},
				highlight:function(vText,vTerms){
					var aTerm=vTerms.split(' '),vRE='';
					for(var i=0;i<aTerm.length;i++){
						if(aTerm[i].trim()!=''&&hp.search.vNoiseWords.indexOf("*"+aTerm[i]+"*")<0){
							vRE+=aTerm[i]+"|";
						}
					};vRE=vRE.substring(0,(vRE.length-1));
					vText=vText.replace(new RegExp("("+vRE+")","ig"),'<span class="highlight">$1</span>');
					return vText;
				},
				lastsearch:function(vS){
					var oP=hp.utils.get('oSearchPortalUsers');
					oP.value=vS;oP.focus();
				}
			}
		}()};