static function getCurrentWeek()
 {
     return ExtraWatchDate::getWeekFromTimestamp(ExtraWatchDate::getUserTimestamp());
 }
 /**
  * stats
  * upper side visits statistics - unique/loads/hits  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
  * @param unknown_type $week  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
  * @return unknown  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
  */
 function renderVisitsGraph($week = 0)
 {
     $output = "";
     $weekOfYear = ExtraWatchDate::getWeekFromTimestamp($week * 3600 * 24 * 7);
     $startDay = ExtraWatchDate::getWeekStartingDay($weekOfYear);
     $searchEngineStats = $this->extraWatch->stat->getSearchEnginesStatsBetweenDays($startDay - 1, $startDay + 6);
     $i = 0xff;
     $statsMax['unique'] = $this->extraWatch->stat->getMaxValueInGroupForWeek(EW_DB_KEY_UNIQUE, EW_DB_KEY_UNIQUE, $startDay);
     $statsMax['loads'] = $this->extraWatch->stat->getMaxValueInGroupForWeek(EW_DB_KEY_LOADS, EW_DB_KEY_LOADS, $startDay);
     //$statsMax['hits'] = $this->extraWatch->stat->getMaxValueInGroupForWeek(EW_DB_KEY_HITS, EW_DB_KEY_HITS, $startDay);
     ExtraWatchLog::debug("Start day: {$startDay} " . ExtraWatchDate::getDateByDay($startDay));
     for ($day = $startDay; $day < $startDay + 7; $day++) {
         $i -= 3;
         $percent = 0;
         //      $stats['search_engines'] = $this->extraWatch->seo->getTotalVisitsByKeyphrasesByDay($day);
         $stats['search_engines'] = $searchEngineStats[$day];
         $statsMax['search_engines'] = $stats['search_engines'];
         $stats['unique'] = $this->extraWatch->stat->getKeyValueInGroupByDate(EW_DB_KEY_UNIQUE, EW_DB_KEY_UNIQUE, $day);
         $stats['loads'] = $this->extraWatch->stat->getKeyValueInGroupByDate(EW_DB_KEY_LOADS, EW_DB_KEY_LOADS, $day);
         //$stats['hits'] = $this->extraWatch->stat->getKeyValueInGroupByDate(EW_DB_KEY_HITS, EW_DB_KEY_HITS, $day);
         if (!$stats['unique'] && !$stats['loads'] && !$stats['search_engines']) {
             //do not render empty values
             continue;
         }
         $once = "";
         foreach ($stats as $key => $value) {
             $progressBarIcon = $this->extraWatch->config->getLiveSiteWithSuffix() . "components/com_extrawatch/img/icons/progress_bar_{$key}.gif";
             $output .= "<tr><td>";
             $dow = ExtraWatchDate::getDateByDay($day, "D");
             ExtraWatchLog::debug("day of week: " . $day * 3600 * 24 . " returns: {$dow}");
             if (@(!$once[$dow])) {
                 $output .= substr(ExtraWatchDate::getDateByDay($day), 0, 6) . "&nbsp;" . $dow;
                 $once[$dow] = 1;
             }
             $output .= "</td>";
             $ratio = 0;
             if ($stats['unique']) {
                 $ratio = sprintf("%.2f", $stats['loads'] / $stats['unique']);
             }
             $percentWidth = 0;
             if ($statsMax[$key]) {
                 if ($statsMax['loads']) {
                     $percent = floor($value / $statsMax['loads'] * 145);
                 } else {
                     if (@$stats['search_engines']) {
                         $percent = floor($value / $statsMax['search_engines'] * 145);
                     }
                 }
                 $percentWidth = floor($percent);
             }
             if (@$value) {
                 switch ($key) {
                     /*            case 'hits' :  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                                   {
                                   $fontColor = "#aaaaaa";  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                                   $output .= "";//"<td align='right' style='color:" . $fontColor . "; background-color: " . $color . ";'>" . $value . "</td><td style='background-color: " . $color . ";'> <table cellpadding='0' cellspacing='0' ><tr><td style='background-color: " . $color . ";'></td><td style='color:" . $fontColor . "; background-color: " . $color . ";'>&nbsp;</td></tr></table></td>";  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                                   break;  	 	    	    		  	 	  	 	  		 	 		    	 			 	   		  	 	 		 	 	   	      	  	 		 		 				 			 		  		    	 		 		  
                                   }*/
                     case 'search_engines':
                         $fontColor = "#DFC4A5";
                         if ($stats['loads']) {
                             $percentagefromHits = floor($stats['search_engines'] / $stats['loads'] * 100);
                         }
                         $output .= "<td align='right' style='color:" . $fontColor . "; background-color: " . $color . ";'>" . $value . "</td><td style='background-color: " . $color . ";'> <table cellpadding='0' cellspacing='0' ><tr><td style='background-color: " . $color . ";'><img src='{$progressBarIcon}' style='width: " . $percentWidth . "px; height:10px' /></td><td style='color:" . $fontColor . "; background-color: " . $color . ";'> &nbsp;" . @$percentagefromHits . "%</td></tr></table></td>";
                         break;
                     case 'loads':
                         $fontColor = "#A4C9CF";
                         $output .= "<td align='right' style='color:" . $fontColor . "; background-color: " . $color . ";'>" . $value . "</td><td style='background-color: " . $color . ";'> <table cellpadding='0' cellspacing='0' ><tr><td style='background-color: " . $color . ";'><img src='{$progressBarIcon}' style='width: " . $percentWidth . "px; height:10px' /></td><td style='color:" . $fontColor . "; background-color: " . $color . ";'></td></tr></table></td>";
                         break;
                     default:
                         $fontColor = "#BFCBA7";
                         $output .= "<td align='right' style='color:" . $fontColor . "; background-color: " . $color . ";'>" . $value . "</td><td style='background-color: " . $color . ";'> <table cellpadding='0' cellspacing='0' ><tr><td style='background-color: " . $color . ";'><img src='{$progressBarIcon}' style='width: " . $percentWidth . "px; height:10px' /></td><td style='color: " . $fontColor . "; background-color: " . $color . ";'>&nbsp;" . $ratio . "x</td></tr></table></td>";
                 }
             } else {
                 $output .= "<td align='right' style='background-color: " . $color . ";'></td><td align='right' style='background-color: " . $color . ";'></td>";
             }
             $output .= "</tr>";
         }
     }
     $output .= "<tr><td colspan='3' align='right'>*  <span style='color:#DFC4A5;'>" . "from search engines" . "</span>, <span style='color:#BFCBA7;'>" . _EW_STATS_UNIQUE . "</span>, <span style='color:#A4C9CF;'>" . _EW_STATS_LOADS . "</span></td></tr>";
     return $output;
 }