if ( isset($_SESSION['AIPagesVisitedStack']) && isset($_SESSION['AIQuickLinksDetails']) )
{
	
	
	$AILinksToChange = array();
	
	if (count($_SESSION['AIPagesVisitedStack']) > 0 )
	{
			
			
			foreach ($_SESSION['AIPagesVisitedStack'] as $k => $AILink)
			{
					//if we have the data to change for this link, we try to change it
					if (isset($_SESSION['AIQuickLinksDetails'][$AILink]))
					{
						
						
						foreach ($_SESSION['AIQuickLinksDetails'][$AILink] as $kk => $AIPagesForLink)	
						{
							$tmpAILinkChange = array();
							
							$tmpAILinkChange['URL'] = $AIPagesForLink['Collection_396_2'];
							$tmpAILinkChange['Text'] = $AIPagesForLink['Collection_396_3'];
							
							$AILinksToChange[] = $tmpAILinkChange;
						}	
					
					}//end if we have to change the link
			}//end foreach links to change
			
			
									
			if (count($AILinksToChange) > 0)
			{
					$AIhtml = str_get_html($templatedata);
					
					//we get all the links from the quicklinks div
					$AICount = 0;					
					foreach($AIhtml->find('div#ai-quicklinks ul li a') as $e)
					{
						if (isset($AILinksToChange[$AICount]))
						{
								$e->innertext = $AILinksToChange[$AICount]['Text'];
								$e->href = $AILinksToChange[$AICount]['URL'];
						}		
						
						$AICount++;
					}	
					
					
					
					$templatedata = $AIhtml->save();

					// clean up memory
					$AIhtml->clear();
					unset($AIhtml);
			
			}
			
	}
	
	
}//end if we have something to change inside the quicklinks

