try{
/********************
   Searching for PERSON / PHONE
/********************/

/* FUNCTION Search for PHONE/PERSON
     Returns list of coincident PERSONS and show markers on the map
*/

Site.SearchPhones = function(json,product,service,ul_id){
		// declaring variables
		Site.qP=json;var puntos=0;var ul=Site.get(ul_id);var html;var marker;var showpopup=false;
		var add_i_to_text='';var iconH;var iconW;var offX=0;var offY=0;
		
		//Guardando LOG
 		LOG.addLog(99,1,1,0,0,'Buscando telf ');
		
		Site.clearLayer('PhoneLayer');
		
		// Show ItemList div
		Site.ShowObject('PhoneList',true);
		
		// if no records returned exit
		if (Site.qP.totalCount>0){
		
			Site.PhoneMarkers = Array(Site.qP.totalCount);
			
			//join product and service in one variable
			var SearchType = product+'/'+service;
			
			
			
			switch(SearchType){
		
			case 'geobusiness/searchperson':                    // FIND PERSON/PHONE
					// If the addresses are full
				// add head info to the list
								html=Site.Searcher.html_list_start;
								var nam=''; var tel='';
								
								for (var i=0;i<Site.qP.totalCount;i++){
									var t=Site.qP.searchperson[i];
									if (t.lon!=0 && t.lat!=-90){
				
											if (Site.qP.totalCount==1){
													//Only obtain one address 			
													// set marker style
													marker='/img/markers/person.png'; 
													showpopup=true; add_i_to_text='';
													iconH=40;iconW=33;
													offX=-12;offY=-30;
													
													Site.putHTML('PhoneListTitle', Site.Locale.get('tit_personfound'));
					
											}else{
													//Get more than one related address							
													// set marker style
													//marker= '/img/estrellaD'+(i+1)+'.gif'; 
													marker='/img/markers/person.png'; 
													showpopup=false; add_i_to_text=(i+1)+') ';
													iconH=40;iconW=33;
													offX=-12;offY=-30;
													// Old system... Site.get_lbl ('tit_maybeyouwannasay','ItemListTitle',Site.CurrentLanguage);
													Site.putHTML('PhoneListTitle', Site.Locale.get('tit_personsfound')+ ' (' +Site.qP.totalCount +')');
		
											}
								
											
										// add ITEM information to the list
										html+=Site.Searcher.html_list_item(i,'phone'+i,
															t.name+'<br>'+t.address+'<br>'+ Site.Locale.get('tit_phoneabr')+' '+t.phone,
												 "Site.Map.CenterandZoomPhone("+ t.lon+","+ t.lat+
																						",13,"+i+");");
						
									
												// Popup HTML text content
												var html_popup_content='<div onclick="Site.Map.CenterandZoomPhone('+ 
																						t.lon+','+ t.lat+
																						',12,'+i+');">'+
																						'<div class="popupAddressTit"><b>'+t.name+'</b></div>'+
																						'<div class="popupAddressText">'+ t.address+'<br><b>'+
																					    Site.Locale.get('tit_phoneabr')+" "+t.phone+'</b></div></div>';
									
												// Add info related the marker on the map
												Site.Map.CreatePhoneMarker(i,
															  t.lon,
															  t.lat,
															  marker,
															  iconW,iconH,    // icon size
															  Site.PhoneLayer,
															 html_popup_content,
															  showpopup,
															  offX,offY // offset
															  );
												
												
										}				
									}
									//add end info to the list
									html+=Site.Searcher.html_list_end;
								
									//Inject list to ul
									Site.get(ul).dom.innerHTML=html;
									//Set zoom to the result markers area
									Site.PhoneMarkersFitZoom();
				
				break;
				
				case 'geobusiness/searchpersonbyphone':                    // FIND PERSON/PHONE
					// If the addresses are full
				// add head info to the list
								html=Site.Searcher.html_list_start;
								var nam=''; var tel='';
								
								
								
								for (var i=0;i<Site.qP.totalCount;i++){
									
									var tel=Site.qP.searchpersonbyphone[i];
								
								
									if (tel.lon!=0 && tel.lat!=-90){
				
											if (Site.qP.totalCount==1){
													//Only obtain one address 			
													// set marker style
													marker='/img/markers/phone.png'; 
													showpopup=true; add_i_to_text='';
													iconH=40;iconW=33;
													offX=-12;offY=-30;
													
													Site.putHTML('PhoneListTitle', Site.Locale.get('tit_phonefound'));
					
											}else{
													//Get more than one related address							
													// set marker style
													//marker= '/img/estrellaD'+(i+1)+'.gif'; 
													marker='/img/markers/phone.png'; 
													showpopup=false; add_i_to_text=(i+1)+') ';
													iconH=40;iconW=33;
													offX=-12;offY=-30;
													// Old system... Site.get_lbl ('tit_maybeyouwannasay','ItemListTitle',Site.CurrentLanguage);
													Site.putHTML('PhoneListTitle', Site.Locale.get('tit_phonesfound')+ ' (' +Site.qP.totalCount +')');
		
											}
								
											
										// add ITEM information to the list
										html+=Site.Searcher.html_list_item(i,'phone'+i,
															tel.name+'<br>'+tel.address+'<br>'+ Site.Locale.get('tit_phoneabr')+' '+tel.phone,
												 "Site.Map.CenterandZoomPhone("+ tel.lon+","+ tel.lat+
																						",13,"+i+");");
						
									
												// Popup HTML text content
												var html_popup_content='<div onclick="Site.Map.CenterandZoomPhone('+ 
																						tel.lon+','+ tel.lat+
																						',12,'+i+');">'+
																						'<div class="popupAddressTit"><b>'+tel.name+
																						'</b></div><div class="popupAddressText">'+ tel.address+'<br><b>'+
																						 Site.Locale.get('tit_phoneabr')+' '+tel.phone+'</b></div></div>';
									
												// Add info related the marker on the map
												Site.Map.CreatePhoneMarker(i,
															  tel.lon,
															  tel.lat,
															  marker,
															  iconW,iconH,    // icon size
															  Site.PhoneLayer,
															 html_popup_content,
															  showpopup,
															  offX,offY // offset
															  );
												
												
										}				
									}
									//add end info to the list
									html+=Site.Searcher.html_list_end;
								
									//Inject list to ul
									Site.get(ul).dom.innerHTML=html;
									//Set zoom to the result markers area
									Site.PhoneMarkersFitZoom();
				
			break;
						
			} //End Switch
		} // If there is more than one record...
					
}; // End search address function


}catch(err){}
