* @license http://www.gnu.org/licenses/gpl-3.0.txt     GNU General Public License v3  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
 * @copyright (C) 2015 by CodeGravity.com - All rights reserved!  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
 * @website http://www.codegravity.com  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
 */
defined('_JEXEC') or die('Restricted access');
sleep(1);
// it's a tooltip. Let's sleep for a while
/*define('DS', DIRECTORY_SEPARATOR);  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
$jBasePath = realpath(dirname(__FILE__) . DS . ".." . DS . ".." . DS . "..". DS);  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
define('JPATH_BASE2', $jBasePath);*/
include_once JPATH_BASE2 . DS . "components" . DS . "com_extrawatch" . DS . "includes.php";
$extraWatch = new ExtraWatchMain();
$extraWatch->helper->setNoindexHttpHeaders();
//setting explicitly for ajax requests
$extraWatchHTML = new ExtraWatchHTML();
$extraWatchTrendHTML = new ExtraWatchTrendHTML($extraWatch);
$extraWatch->block->checkBackendTokenFromUrl();
$extraWatch->config->initializeTranslations();
//echo $extraWatchHTML->renderAdminStyles();
echo $extraWatchHTML->renderPrint();
echo $extraWatchHTML->renderCloseWindow();
$group = (int) @ExtraWatchHelper::requestGet('group');
///
$name = ExtraWatchInput::validate(_EW_INPUT_ONE_STRING, urldecode(@ExtraWatchHelper::requestGet('name')));
///
$date = (int) @ExtraWatchHelper::requestGet('date');
///
?>
<center>
<h2><?php 
echo htmlentities($name);
 function renderPositionChangeDiff($rows, $day)
 {
     $output = "";
     if ($rows) {
         $lastAveragePosition = 0;
         foreach ($rows as $row) {
             $averagePosition = $row->averagePosition;
             if ($lastAveragePosition != $averagePosition) {
                 if ($lastAveragePosition) {
                     $diff = (double) ($averagePosition - $lastAveragePosition);
                     $diffColor = ExtraWatchTrendHTML::getDiffColor($diff, TRUE);
                     $diffImg = "<img src='" . $this->extraWatch->config->getLiveSiteWithSuffix() . "components/com_extrawatch/img/icons/trend_{$diffColor}.gif' border='0'/>";
                     if ($day == $row->date || !$day) {
                         $output .= sprintf("<td style='color: {$diffColor}' align='right'>%+.2f</td><td>{$diffImg}</td><td class='ewCentered'>%s</td>", $diff, ExtraWatchDate::getDateByDay($row->date));
                     }
                 }
                 $lastAveragePosition = $averagePosition;
             }
         }
     }
     return $output;
 }