<?php

function cloudfw_ga
			(
			$id = NULL,
			$case = 'hourly',
			$start = NULL,
			$end =NULL
			) {
	
	global $_opt, $ga_page;
	$_opt = getCO(NULL, array(PFIX."_ga_id", PFIX."_ga_pass", PFIX."_ga_profile"));

	
	if (defined("GA_ID")&&defined("GA_PASS")):
		 
		 $ga_id = GA_ID;
		 $ga_pass = GA_PASS;
		 
		else:
		
		 $ga_id = $_opt[PFIX."_ga_id"];
		 $ga_pass = $_opt[PFIX."_ga_pass"];
		
		endif;
		
		$ga_profile = $_opt[PFIX."_ga_profile"];
		
		
	
	$echo = NULL;
	$start ? NULL: 	$start = date("Y-m-d", mktime(0, 0, 0, date("m"),date("d"),date("Y")));	
	$end ?	 NULL:	$end = date("Y-m-d", mktime(0, 0, 0, date("m"),date("d"),date("Y")));	
	$time_difference = strtotime($end)-strtotime($start);
	
	try
	  {
		$ga = new gapi($ga_id,$ga_pass);
	  }
		  
	catch(Exception $e)
	  {
		 if ($e->getMessage()=="NOAUTH"): return '
		 
		 <div class="module">
		 	<div class="error-div box-div" style="margin:-10px 20px 10px; width:auto;">'.__('Connection is failed.','cloudfw').'  <a href="'.$ga_page.'">'.__('Please check your Google Analytics account informations','cloudfw').'</a></div>
		 </div>
		 ';  
	
	update_option(PFIX."_ga_id", NULL);
	update_option(PFIX."_ga_pass", NULL);
	update_option(PFIX."_ga_profile", NULL);
			
	cloud_cache_delete('ga_today_'.$_opt[PFIX."_ga_profile"].'.cache');
	cloud_cache_delete('ga_lastweek_'.$_opt[PFIX."_ga_profile"].'.cache');
	cloud_cache_delete('ga_lastmonth_'.$_opt[PFIX."_ga_profile"].'.cache');
	cloud_cache_delete('ga_thisyear_'.$_opt[PFIX."_ga_profile"].'.cache');
	
		$error = TRUE;
		
		endif;
		
		if ($e->getMessage() !==""):
		
			return '
					 <div class="module">
						<div class="error-div box-div" style="margin:-10px 20px 10px; width:auto;">'.__('An Error Has Occurred','cloudfw').' '.$e->getMessage().'</div>
					 </div>
				';  
		 
		$error = TRUE;
		
		
		endif;
		
		}// Cactch Error
	
	if (!$error):

	$isfirst =TRUE;
	$unique_id = cloudfw_randomizer(10);
	
	switch ($case) {
		case "hourly":
			
			$ga->requestReportData($ga_profile,array('hour','day','month','year'),array('pageviews','visits','timeOnSite','bounces','newVisits','exits','entrances'),array('year','month'),NULL,$start,$end,1,24);
			
			break;
		
		case "daily":
			
			$ga->requestReportData($ga_profile,array('day','month','year'),array('pageviews','visits','visitors','timeOnSite','bounces','newVisits','exits','entrances'),array('year','month'),NULL,$start,$end,1,31);
			break;

			$time_difference = round($time_difference / 86400 );
			
		case "monthly":
			
			$ga->requestReportData($ga_profile,array('month','year'),array('pageviews','visits','visitors','timeOnSite','bounces','newVisits','exits','entrances'),array('year','month'),NULL,$start,$end,1,12);
			
			$time_difference = round($time_difference / 2419200 );
			break;
		
		case "yearly":
			
			$ga->requestReportData($ga_profile,array('year'),array('pageviews','visits','visitors','timeOnSite','bounces','newVisits','exits','entrances'),array('year'),NULL,$start,$end,1,30);
			
			$time_difference = round($time_difference / 29030400 );
			break;
		
		}
	
	foreach($ga->getResults() as $result):

		$i++;
		
		// Begin Datas To Vars
		$item_pg_views = $result->getPageviews();		 $item_pg_views = $item_pg_views ? $item_pg_views:0;
		$item_pg_visits = $result->getVisits(); 		 $item_pg_visits = $item_pg_visits ? $item_pg_visits:0;
		
		$item_pg_visitors = $case == 'hourly' ? $result->getVisits():$result->getVisitors();	 $item_pg_visitors = $item_pg_visitors ? $item_pg_visitors:0;
		
		$item_timeonsite = $result->getTimeOnSite();	 $item_timeonsite = $item_timeonsite ? $item_timeonsite:0;
		$item_bounce = $result->getBounces();			 $item_bounce = $item_bounce ? $item_bounce:0;
		$item_new_visits = $result->getNewVisits();		 $item_new_visits = $item_new_visits ? $item_new_visits:0;
		$item_exits = $result->getExits();				 $item_exits = $item_exits ? $item_exits:0;
		$item_entrances = $result->getEntrances();		 $item_entrances = $item_entrances ? $item_entrances:0;
		
		//Calculations
		$pg_views[] = $item_pg_views ? $item_pg_views: 0;
		$pg_visits[] = $item_pg_visits ? $item_pg_visits: 0;
		$pg_visitors[] = $item_pg_visitors ? $item_pg_visitors:0;
		
		
		$bounce[] = $item_bounce;
		$new_visits[] = $item_new_visits;
		$exits[] = $item_exits;
		$entrances[] = $item_entrances;
		$timeonpage[] = $item_timeonsite;
		
		//Percents
		$average_pg_views[] = @($item_pg_views / $item_pg_visits)*1;
		$percent_bounce[] = @($item_bounce / $item_entrances)*100;
		$percent_new_visits[] = @($item_new_visits / $item_pg_visits)*100;
		
		
			switch ($case) {
			case "hourly":
			
			$todate = mktime($result->getHour(), 0, 0, $result->getMonth(), $result->getDay(), $result->getYear());
			$todate_onehour = mktime($result->getHour()+1, 0, 0, $result->getMonth(), $result->getDay(), $result->getYear());
			$pg_date[] = ($i%2==0) ? '' :   date("H:00",$todate);
			$table_row_title = ''.date("H:00",$todate).' - '.date("H:00",$todate_onehour).'';
			
			$isfirst ? 	$first_date = $todate : NULL;
						$last_date 	= $todate;
			
			$date_between = ''.date("F d, Y l",$first_date).'';
			
			break; case "daily":
			
			$todate = mktime(0, 0, 0, $result->getMonth(), $result->getDay(), $result->getYear());
			$pg_date[] = ($i%2==0 && $time_difference>15) ? '' : date("d M",$todate);
			$table_row_title = ''.date("d F Y, l",$todate).'';

			$isfirst ? 	$first_date = $todate : NULL;
						$last_date 	= $todate;
			
			$date_between = ''.date("F d, Y D",$first_date).' - '.date("F d, Y D",$last_date).'';

			break; case "monthly":
			
			$todate = mktime(0, 0, 0, $result->getMonth(), 1, $result->getYear());
			$pg_date[] = ($i%2==0 && $time_difference>15) ? '' : date("M Y",$todate);
			$table_row_title = ''.date("Y F",$todate).'';

			$isfirst ? 	$first_date = $todate : NULL;
						$last_date 	= $todate;
								
			$date_between = ''.date("F, Y",$first_date).' - '.date("F, Y",$last_date).'';
			
			break; case "yearly":
			
			$todate = mktime(0, 0, 0, 1, 1, $result->getYear());
			$pg_date[] = ($i%2==0 && $time_difference>15) ? '' : date("Y",$todate);
			$table_row_title = ''.date("Y",$todate).'';

			$isfirst ? 	$first_date = $todate : NULL;
						$last_date 	= $todate;

			$date_between = 'Between '.date("Y",$first_date).' And '.date("Y",$last_date).'';

			break;}
		
		
		
		($i%2==0)?$highlight='even':$highlight='odd';
		if ($old_value < $item_pg_visitors) {$col_class = "ga-rise"; $col_icon = "&uarr;";} else {$col_class = "ga-fall"; $col_icon = "&darr;"; };
		$changing = ($item_pg_visitors-$old_value);


//			<td class="text text_wrapper">'.date("d F Y, H:00 ",$todate).'-'.date("H:00 ",$todate-1).'</td>

		
		
		
		
		$echo_montly_table .= '	
		
		<tr class="'.$highlight.'">
			
			<td class="text text_wrapper">'.$table_row_title.'</td>
			<td class="'.$col_class.'" >'; 
			
		$echo_montly_table .= ($isfirst || $changing == 0 ) ? '-' : '	'.number_format(($changing), 0, '', ',').' <span style="font:bold 16px "Lucida Sans Unicode", "Lucida Grande", sans-serif;">'.$col_icon.'</span>';
		
		$echo_montly_table .= '</td>
			<td>'.number_format($item_pg_visitors, 0, '', ',').'</td>
			
		</tr>     

		
		';
		
		$old_value = $item_pg_visitors;
		$isfirst = FALSE;
		
	endforeach;
	
	$max_pg_views = make_mod(max($pg_views),50) * 1.2;
	$max_pg_visits = make_mod(max($pg_visits),50) * 1.2;
	$max_pg_visitors = make_mod(max($pg_visitors),50) * 1.2;
	
	$linechart_x_axis = number_format((100 / ($i-1)), 2, '.', '.');
	
	
	
	$echo .= '
	

	
	<div>
	
	<div class="ga-between">'.$date_between.'</div>
	<div class="divider"></div>
	
	<div class="module">
	
		<div style="padding:15px 25px 0;">
	
		<div class="grid oneof2">
		
			<div class="grid oneof3"><img src="http://chart.apis.google.com/chart?chs=75x18&cht=ls&chco=FF9900,FF9900&chds=0,'.($max_pg_visits).'&chd=t:'.implode(",",$pg_visits).'|0,0&chdlp=l&chls=2|1&chm=b,3399CC44,0,1,0,-1" alt=""/></div>
			<div class="grid twoof3 last"><span class="ga-value">'.number_format(array_sum($pg_visits), 0, ',', ',').'</span> <span class="ga-label">'.__('Visits','cloudfw').'</span></div>';
		
			$case == 'hourly' ? NULL: $echo .= '<div class="grid oneof3"><img src="http://chart.apis.google.com/chart?chs=75x18&cht=ls&chco=FF9900,FF9900&chds=0,'.($max_pg_visitors).'&chd=t:'.implode(",",$pg_visitors).'|0,0&chdlp=l&chls=2|1&chm=b,3399CC44,0,1,0,-1" alt=""/></div>
			<div class="grid twoof3 last"><span class="ga-value">'.number_format(array_sum($pg_visitors), 0, ',', ',').'</span> <span class="ga-label">'.__('Unique Visitors','cloudfw').'</span></div>';
			
			$echo .= '<div class="grid oneof3"><img src="http://chart.apis.google.com/chart?chs=75x18&cht=ls&chco=FF9900,FF9900&chds=0,'.($max_pg_views).'&chd=t:'.implode(",",$pg_views).'|0,0&chdlp=l&chls=2|1&chm=b,3399CC44,0,1,0,-1" alt=""/></div>
			<div class="grid twoof3 last"><span class="ga-value">'.number_format(array_sum($pg_views), 0, ',', ',').'</span> <span class="ga-label">'.__('Pageviews','cloudfw').'</span></div>
			
			<div class="grid oneof3"><img src="http://chart.apis.google.com/chart?chs=75x18&cht=ls&chco=FF9900,FF9900&chds=0,'. (make_mod(max($average_pg_views),5)) * 1.3 .'&chd=t:'.implode(",",$average_pg_views).'|0,0&chdlp=l&chls=2|1&chm=b,3399CC44,0,1,0,-1" alt=""/></div>
			<div class="grid twoof3 last"><span class="ga-value">'.@number_format(@(array_sum($pg_views) / array_sum($pg_visits)), 2, '.', '.').'</span> <span class="ga-label">'.__('Average Pageviews','cloudfw').'</span></div>
		
		</div>
		
		<div class="grid oneof2 last">
		
			<div class="grid oneof3"><img src="http://chart.apis.google.com/chart?chs=75x18&cht=ls&chco=FF9900,FF9900&chds=0,'. (make_mod(max($timeonpage),5)) * 1.3 .'&chd=t:'.implode(",",$timeonpage).'|0,0&chdlp=l&chls=2|1&chm=b,3399CC44,0,1,0,-1" alt=""/></div>
			<div class="grid twoof3 last"><span class="ga-value">'.date("H:i:s", @(array_sum($timeonpage) / (array_sum($pg_visits)))).'</span> <span class="ga-label">'.__('Time On Site','cloudfw').'</span></div>
			
			<div class="grid oneof3"><img src="http://chart.apis.google.com/chart?chs=75x18&cht=ls&chco=FF9900,FF9900&chds=0,'. (make_mod(max($percent_bounce),5)) * 1.3 .'&chd=t:'.implode(",",$percent_bounce).'|0,0&chdlp=l&chls=2|1&chm=b,3399CC44,0,1,0,-1" alt=""/></div>
			<div class="grid twoof3 last"><span class="ga-value">'.@number_format(@(array_sum($bounce) / array_sum($entrances))*100, 2, '.', '.').' %</span> <span class="ga-label">'.__('Bounce Rate','cloudfw').'</span></div>
		
			<div class="grid oneof3"><img src="http://chart.apis.google.com/chart?chs=75x18&cht=ls&chco=FF9900,FF9900&chds=0,'. (make_mod(max($percent_new_visits),5)) * 1.3 .'&chd=t:'.implode(",",$percent_new_visits).'|0,0&chdlp=l&chls=2|1&chm=b,3399CC44,0,1,0,-1" alt=""/></div>
			<div class="grid twoof3 last"><span class="ga-value">'.@number_format(@(array_sum($new_visits) / array_sum($pg_visits))*100, 2, '.', '.').' %</span> <span class="ga-label">'.__('New Visits','cloudfw').'</span></div>
		
		
		
		
		</div>
		<div class="clear"></div>
		
		
		</div>
	
	</div>
	
	
<div class="divider"></div>
<br />
<br />


<div style="text-align:center;">
<img src="http://chart.apis.google.com/chart?chxl=0:|'.implode("|",$pg_date).'&chxr=1,0,'.$max_pg_visitors.'&chxtc=0,50&chxt=x,y&chs=700x250&cht=ls&chd=t:0,0|'.implode(",",$pg_visitors).'&chg='.$linechart_x_axis.',12,1,2&chls=0.75,-1,-1|2,4,1&chm=o,FF9900,1,-1,8,1|b,3399CC44,0,1,0&chxs=0,676767,9.5,0,lt,676767|1,676767,10.5,0.5,lt,676767&chds=0,'.$max_pg_visitors.'" />
</div>
<br/>
	';
	
	
	$echo .= '
	<div class="module">
	
		<div style="padding:0 25px 30px; display:none;" id="'.$unique_id.'">
		
		
		<table class="ga"> 
		
		<thead> 
		<tr> <th class="text"><div title="Months" class="text_wrapper"><div class="text_wrapper">Months</div></div> </th>  <th> <div title="'.__('PageViews','cloudfw').'" class="text_wrapper"><div class="text_wrapper">'.__('Exchange Value','cloudfw').'</div></div> </th>   <th> <div title="'.__('Page Visit','cloudfw').'" class="text_wrapper"><div class="text_wrapper">'.__('Page Visit','cloudfw').'</div></div> </th>  </tr> 
		
		</thead>
		
		<tbody>   
		
		'.$echo_montly_table.'
		
		</tbody> 
		
		</table>
		
		</div>
	
		<div style="text-align:center; margin-bottom:30px;"><a href="#" class="small-button small-brown" onclick="jQuery(\'#'.$unique_id.'\').slideDown(); jQuery(this).remove(); return false;"><span>'.__('Show More Data','cloudfw').'</span></a></div>

	</div>


	
	
	';
	
	
	if (array_sum($pg_visits)>0):
	
	

//	<img src="http://chart.apis.google.com/chart?chxl=1:|'.implode("|",$pg_date).'|&chxr=0,0,'.make_mod(max($pg_views),1000).'&chxs=0,676767,11.5,0,lt,676767|1,676767,11.5,0,lt,676767&chxt=y,x&chbh=a,0,12&chs=750x400&cht=bvg&chco=A2C180,3D7930&chds=0,'.make_mod(max($pg_views),1000).',0,'.make_mod(max($pg_visits),1000).'&chd=t:'.implode(",",$pg_views).'|'.implode(",",$pg_visits).'&chdl=PgView|Visits&chg=25,25&chtt=Montly+PageViews+And+Visits(2010)" />
	
	
	$pie_color = array('058DC7','50B432','ED561B','EDEF00','24CBE5','64E572','FF9655','FFF263','6AF9C4','B2DEFF');

	
	// BROWSERS
	$ga->requestReportData($ga_profile,array('browser'),array('visits'),array('-visits'),NULL,$start,$end, 1, 10); 
	foreach($ga->getResults() as $result):
		
		$item_pg_visits = $result->getVisits();
		
		$pg_browsers_views[] = $item_pg_views ? $item_pg_views: 0;
		$pg_browsers_visits[] = $item_pg_visits ? $item_pg_visits: 0;
		$pg_browsers_visits_[] = $item_pg_visits ? $item_pg_visits/1000: 0;
		$pg_browsers[] = $result->getBrowser();
		
	endforeach;
	
	
	// -- Calculate The Percents
	$total_browsers_visits = @array_sum($pg_browsers_visits); $ii=0;
	
	if ($item_pg_visits) { 
	
	foreach($pg_browsers_visits as $e_pg_visits):
	
		$pg_browser_percent[] = $item_browser_percent = ''.@number_format(@(100 * $e_pg_visits) / $total_browsers_visits, 2, '.', '.').'';	
		$pg_browsers_with_percent[] = $item_browser_percent.'%';
		
		
		$echo_browsers .= '
			<tr>
				<td class="text text_wrapper"><div class="pie-color" style="background:#'.$pie_color[$ii].';"></div>'.$pg_browsers[$ii].'</td>
				<td>'.number_format($pg_browsers_visits[$ii], 0, ',', ',').'</td>
				<td>'.$item_browser_percent.' %</td>
			</tr>     
		';
		
		$ii++;
	endforeach;
	
		}; // end if
		
	// END BROWSERS
	
	
	// OPERATION SYSTEMS
	$ga->requestReportData($ga_profile,array('operatingSystem'),array('visits'),array('-visits'),NULL,$start,$end, 1, 10); 
	foreach($ga->getResults() as $result):
		
		$item_pg_visits = $result->getVisits();
		
		$pg_opsystem_views[] = $item_pg_views ? $item_pg_views: 0;
		$pg_opsystem_visits[] = $item_pg_visits ? $item_pg_visits: 0;
		$pg_opsystem_visits_[] = $item_pg_visits ? $item_pg_visits/1000: 0;
		$pg_opsystem[] = $result->getOperatingSystem();
		
	endforeach;
	
	
	// -- Calculate The Percents
	$total_opsystem_visits = @array_sum($pg_opsystem_visits); $ii=0;
	
	if ($pg_opsystem_views) { 
	
	foreach($pg_opsystem_visits as $e_opsystem_visits_):
	
		$pg_ops_percent[] = $item_ops_percent = ''.@number_format(@(100 * $e_opsystem_visits_) / $total_opsystem_visits, 2, '.', '.').'';	
		$pg_opsystem_with_percent[] = $item_ops_percent.'%';
		
		
		$echo_opsystem .= '
			<tr>
				<td class="text text_wrapper"><div class="pie-color" style="background:#'.$pie_color[$ii].';"></div>'.$pg_opsystem[$ii].'</td>
				<td>'.number_format($pg_opsystem_visits[$ii], 0, ',', ',').'</td>
				<td>'.$item_ops_percent.' %</td>
			</tr>     
		';
		
		$ii++;
	endforeach;
	
	
	
		}; // end if
	
	// END opsystem
	
	
	// SEARCH KEYWORDS
	$ga->requestReportData($ga_profile,array('keyword'),array('visits'),array('-visits'),NULL,$start,$end, 1, 10); 
	foreach($ga->getResults() as $result):
		
		$item_pg_visits = $result->getVisits();
		
		$pg_srckyw_views[] = $item_pg_views ? $item_pg_views: 0;
		$pg_srckyw_visits[] = $item_pg_visits ? $item_pg_visits: 0;
		$pg_srckyw_visits_[] = $item_pg_visits ? $item_pg_visits/1000: 0;
		$pg_srckyw[] = $result->getKeyword();
		
	endforeach;
	
	
	// -- Calculate The Percents
	$total_srckyw_visits = @array_sum($pg_srckyw_visits); $ii=0;
	
	if ($pg_srckyw_views) { 
	
	foreach($pg_srckyw_visits as $e_srckyw_visits_):
	
		$pg_skw_percent[] = $item_skw_percent = ''.@number_format(@(100 * $e_srckyw_visits_) / $total_srckyw_visits, 2, '.', '.').'';	
		$pg_srckyw_with_percent[] = $item_skw_percent.'%';
		
		
		$echo_srckyw .= '
			<tr>
				<td class="text text_wrapper"><div class="pie-color" style="background:#'.$pie_color[$ii].';"></div>'.$pg_srckyw[$ii].'</td>
				<td>'.number_format($pg_srckyw_visits[$ii], 0, ',', ',').'</td>
				<td> '.$item_skw_percent.'</td>
			</tr>     
		';
		
		$ii++;
	endforeach;
	
	
	
		}; // end if
	
	// END SEARCH KEYWORDS
	

	// SEARCH SOURCES
	$ga->requestReportData($ga_profile,array('source'),array('visits'),array('-visits'),NULL,$start,$end, 1, 5); 
	foreach($ga->getResults() as $result):
		
		$item_pg_visits = $result->getVisits();
		
		$pg_source_views[] = $item_pg_views ? $item_pg_views: 0;
		$pg_source_visits[] = $item_pg_visits ? $item_pg_visits: 0;
		$pg_source_visits_[] = $item_pg_visits ? $item_pg_visits/1000: 0;
		$pg_source[] = $result->getSource();
		
	endforeach;
	
	
	// -- Calculate The Percents
	$total_source_visits = @array_sum($pg_source_visits); $ii=0;
	
	if ($pg_source_views) { 
	
	foreach($pg_source_visits as $e_source_visits_):
	
		$pg_source_percent[] = $item_source_percent = ''.@number_format(@(100 * $e_source_visits_) / $total_source_visits, 2, '.', '.').'';	
		$pg_source_with_percent[] = $item_source_percent.'%';
		
		
		$echo_source .= '
			<tr>
				<td class="text text_wrapper"><div class="pie-color" style="background:#'.$pie_color[$ii].';"></div>'.$pg_source[$ii].'</td>
				<td>'.number_format($pg_source_visits[$ii], 0, ',', ',').'</td>
				<td> '.$item_source_percent.'</td>
			</tr>     
		';
		
		$ii++;
	endforeach;
		}; // end if
	
	// END SEARCH SOURCES



	
	$echo .= '
	<div class="divider"></div>
		<div class="tabs">   
		<ul>
			<li class="firsttab"><a href="#'.$id.'_'.$case.'_browsers">'.__('Browsers','cloudfw').'</a></li>
			<li><a href="#'.$id.'_'.$case.'_ops">'.__('Operation Systems','cloudfw').'</a></li>
			<li class="lasttab"><a href="#'.$id.'_'.$case.'_searchkeywords">'.__('Sources &amp; Search Keywords','cloudfw').'</a></li>
		</ul>
        <div class="clear"></div>
                    
  	
	
	
	<div id="'.$id.'_'.$case.'_browsers">
	<div class="module">
		<div style="padding:0 25px 50px;">
		<div class="grid oneof2">
		<table class="ga"> 
		
		<thead> 
		<tr> <th class="text"><div class="text_wrapper"><div class="text_wrapper">'.__('Browsers','cloudfw').'</div></div> </th>  <th> <div class="text_wrapper"><div class="text_wrapper">'.__('Visits','cloudfw').'</div></div> </th> <th> <div class="text_wrapper"><div class="text_wrapper">'.__('Visit Rate','cloudfw').'</div></div> </th>  </tr> 
		
		</thead>
		
		<tbody>   
			'.$echo_browsers.'
		</tbody> 
		</table>
		</div>
		<div class="grid oneof2 last" style="text-align:right;">
			<img src="http://chart.apis.google.com/chart?chs=300x200&cht=p&chdlp=b&chco='.implode("|",$pie_color).'&chd=t:'.implode(",",array_slice($pg_browser_percent,0,3)).'&chl='.urlencode(implode("|",array_slice($pg_browsers_with_percent,0,3))).'" alt="'.__('Browsers','cloudfw').'" />
		</div>
		<div class="clear"></div>
		</div>
	</div>	
	</div>
	
	
	<div id="'.$id.'_'.$case.'_ops">
	
	<div class="module">
		<div style="padding:0 25px 50px;">
		<div class="grid oneof2">
		<table class="ga"> 
		
		<thead> 
		<tr> <th class="text"><div class="text_wrapper"><div class="text_wrapper">'.__('Operating Systems','cloudfw').'</div></div> </th>  <th> <div class="text_wrapper"><div class="text_wrapper">'.__('Visits','cloudfw').'</div></div> </th> <th> <div class="text_wrapper"><div class="text_wrapper">'.__('Visit Rate','cloudfw').'</div></div> </th>  </tr> 
		
		</thead>
		
		<tbody>   
			'.$echo_opsystem.'
		</tbody> 
		</table>
		</div>
		
		<div class="grid oneof2 last" style="text-align:right;">
			<img src="http://chart.apis.google.com/chart?chs=300x200&cht=p&chdlp=b&chco='.implode("|",$pie_color).'&chd=t:'.implode(",",array_slice($pg_ops_percent,0,3)).'&chl='.urlencode(implode("|",array_slice($pg_opsystem_with_percent,0,3))).'" alt="'.__('Operation Systems','cloudfw').'" />
		</div>
		<div class="clear"></div>
		</div>
	</div>	
	
	</div>

	<div id="'.$id.'_'.$case.'_searchkeywords">
	
	<div class="module">
		<div style="padding:0 25px 50px;">
		<div class="grid oneof2">
		<table class="ga"> 
		
		<thead> 
		<tr> <th class="text"><div class="text_wrapper"><div class="text_wrapper">'.__('Sources','cloudfw').'</div></div> </th>  <th> <div class="text_wrapper"><div class="text_wrapper">'.__('Visits','cloudfw').'</div></div> </th> <th> <div class="text_wrapper"><div class="text_wrapper">'.__('Visit Rate','cloudfw').'</div></div> </th>  </tr> 
		
		</thead>
		
		<tbody>   
			'.$echo_source.'
		</tbody> 
		</table>
		</div>
		
		<div class="grid oneof2 last" style="text-align:right;">
			<img src="http://chart.apis.google.com/chart?chs=300x200&cht=p&chdlp=b&chco='.implode("|",$pie_color).'&chd=t:'.implode(",",array_slice($pg_source_percent,0,3)).'&chl='.urlencode(implode("|",array_slice($pg_source_with_percent,0,3))).'" />
		</div>
		<div class="clear"></div>
		
		
		
		<div class="grid oneof2">
		<table class="ga"> 
		
		<thead> 
		<tr> <th class="text"><div class="text_wrapper"><div class="text_wrapper">'.__('Search Keywords','cloudfw').'</div></div> </th>  <th> <div class="text_wrapper"><div class="text_wrapper">'.__('Visits','cloudfw').'</div></div> </th> <th> <div class="text_wrapper"><div class="text_wrapper">'.__('Visit Rate','cloudfw').'</div></div> </th>  </tr> 
		
		</thead>
		
		<tbody>   
			'.$echo_srckyw.'
		</tbody> 
		</table>
		</div>
		
		<div class="grid oneof2 last" style="text-align:right;">
			<img src="http://chart.apis.google.com/chart?chs=300x200&cht=p&chdlp=b&chco='.implode("|",$pie_color).'&chd=t:'.implode(",",array_slice($pg_skw_percent,0,3)).'&chl='.urlencode(implode("|",array_slice($pg_srckyw_with_percent,0,3))).'" />
		</div>
		<div class="clear"></div>

		</div>
	</div>	
	
	</div>	
	</div>
	
	</div>
	';
	
	endif;
	
	
	
	
	return $echo;
	
	
	
	
	endif; // ERROR
	
	
	
	};?>