<div id="rightBox">
	<table border="0" cellpadding="0" cellspacing="0" class="rightBox_table">
		<tr>
			<td><img src="/files/contentBoxTop.jpg" alt="" width="690" height="16"/></td>
		</tr>
		<tr>
			<td valign="top" style="background-image: url(/files/contentBoxMiddle.jpg); width: 690px; height: 547px; background-position: center top; background-repeat: no-repeat;">
				<div id="rightBox_content">
				<?php $this->load->view('admin/switch_domain');?>
					<?php
						if($this->uri->segment('1')=='superadmin') 
							$link = 'superadmin';
						else		
							$link = 'admin';
							
						$kategoriaId = $this->uri->segment('4');
						if($kategoriaId == 0)
							$kategoriaId = 1;
					?>
					
						<div class="mediumButton"><a class="gray_link" <?php if($kategoriaId==1) echo 'style="color:#ec2323"'; ?> href="/<?=$link;?>/show_domain_chart/<?php echo $domain_id; ?>/1">dzienne</a></div>
						<div class="mediumButton"><a class="gray_link" <?php if($kategoriaId==2) echo 'style="color:#ec2323"'; ?> href="/<?=$link;?>/show_domain_chart/<?php echo $domain_id; ?>/2">tygodniowe</a></div> 
						<div class="mediumButton"><a class="gray_link" <?php if($kategoriaId==3) echo 'style="color:#ec2323"'; ?> href="/<?=$link;?>/show_domain_chart/<?php echo $domain_id; ?>/3">miesieczne</a></div>  
						<!--<div class="mediumButton"><a class="gray_link" <?php if($kategoriaId==4) echo 'style="color:#ec2323"'; ?> href="/<?=$link;?>/show_domain_chart/<?php /*echo $domain_id;*/ ?>/4">kwartalne</a></div>  -->
						<div class="mediumButton"><a class="gray_link" <?php if($kategoriaId==5) echo 'style="color:#ec2323"'; ?> href="/<?=$link;?>/show_domain_chart/<?php echo $domain_id; ?>/5">roczne</a></div>
					<br /><br /><br />
					
					<?php
					
						$type = $this->uri->segment(4);
						
						
						if ($type==null)
						{
							$type=1;
						}
						
					switch($type)
										{
										case 1: {
										    			// "Dzienne"; 
													//echo '<img src="/charts/chart_line/'.$domain_id.'" />';
                                                        $year = date("Y");
                                                        $month = date("m");
                                                        $day = date("d");

                                                        if($this->uri->segment(5) != null)
                                                        {
                                                            $year = $this->uri->segment(5);
                                                        }

                                                        if($this->uri->segment(6) != null)
                                                        {
                                                            $month = $this->uri->segment(6);
                                                        }
                                                        if($this->uri->segment(7) != null)
                                                        {
                                                            $day = $this->uri->segment(7);
                                                        }

                                                        for($i=1;$i<32;$i++)
                                                        {
                                                            $j=$i;
                                                            if($i<10) $j='0'.$i;
                                                            $data[$i] = '/'.$link.'/show_domain_chart/'.$domain_id.'/'.$type.'/'.$year.'/'.$month.'/'.$j.'';
                                                        }   
                                                        echo $this->calendar->generate($year, $month,$data);

														echo '<div id="my_chart">charts/flash_chart_line/'.$domain_id.'/'.$year.'/'.$month.'/'.$day.'/</div>';
														break;
													}
										case 2: {
										    			// "tygodniowe";
                                                        //
                                                        if(@$_POST['year']!=null)
                                                        {
                                                            $this->session->set_userdata('rok', $_POST['year']);
                                                            $rok = $this->session->userdata['rok'];
                                                        }
                                                        else
                                                        {
                                                            if (!isset($this->session->userdata['rok']))
                                                            {
                                                                $actual_year = date("Y");
                                                                $this->session->set_userdata('rok', $actual_year);
                                                                $rok = $this->session->userdata['rok'];
                                                            } $rok = $this->session->userdata['rok'];
                                                        }

                                                        echo '<b>ustaw rok</b><br />';
                                                        echo '<form action="/'.$link.'/show_domain_chart/'.$domain_id.'/2" method="post">';
                                                        echo '<table cellspacing="6">';
                                                        echo '<tr><td>';
                                                        echo '<select name="year">';
                                                              $cur_year = date("Y");
                                                              $roz = $cur_year - 2007;
                                                              for($i=$roz; $i>=0;$i--)
                                                              {
                                                                echo '<option value="'.$cur_year.'"';
                                                                if ($rok==$cur_year) echo 'selected="selected"';
                                                                echo '>'.$cur_year.'</option>';
                                                                $cur_year--;
                                                              }
                                                        echo '</select>';
                                                        echo '</td><td>';
                                                        echo '<input type="submit" value="wybierz" />';
                                                        echo '</td></tr></table>';
                                                        echo '</form>';
                                                        echo 'wybierz tydzień z roku: <b>'.$rok.'</b>';
                                                        echo br();

                                                        if($this->uri->segment(5) != null)
                                                        {
                                                            $week = $this->uri->segment(5);
                                                        }else  $week = date("W",time());

                                                        $weeks_in_year = strftime("%W",strtotime("12/31/".$rok));

                                                        for($i=1;$i<=$weeks_in_year;$i++)
                                                        {
                                                            echo '<a href="/'.$link.'/show_domain_chart/'.$domain_id.'/2/'.$i.'/'.$rok.'"/>'.$i.'</a>&nbsp;';
                                                            if($i==round(($weeks_in_year/2))) echo '<br />';
                                                        }

                                                        echo br(2);
														//echo '<img src="/charts/chart_line_weekly/'.$domain_id.'" />';
														echo '<div id="my_chart">charts/flash_chart_line_weekly/'.$domain_id.'/'.$week.'/'.$rok.'/</div>';
														break;
													}
										case 3: {
										    			// "miesieczne";
                                                        //
                                                        if(@$_POST['year']!=null)
                                                        {
                                                            $this->session->set_userdata('rok', $_POST['year']);
                                                            $rok = $this->session->userdata['rok'];
                                                        }
                                                        else
                                                        {
                                                            if (!isset($this->session->userdata['rok']))
                                                            {
                                                                $actual_year = date("Y");
                                                                $this->session->set_userdata('rok', $actual_year);
                                                                $rok = $this->session->userdata['rok'];
                                                            } $rok = $this->session->userdata['rok'];
                                                        }

                                                        echo '<b>ustaw rok</b><br />';
                                                        echo '<form action="/'.$link.'/show_domain_chart/'.$domain_id.'/3" method="post">';
                                                        echo '<table cellspacing="6">';
                                                        echo '<tr><td>';
                                                        echo '<select name="year">';
                                                                $cur_year = date("Y");
                                                                  $roz = $cur_year - 2007;
                                                                  for($i=$roz; $i>=0;$i--)
                                                                  {
                                                                    echo '<option value="'.$cur_year.'"';
                                                                    if ($rok==$cur_year) echo 'selected="selected"';
                                                                    echo '>'.$cur_year.'</option>';
                                                                    $cur_year--;
                                                                  }
                                                        echo '</select>';
                                                        echo '</td><td>';
                                                        echo '<input type="submit" value="wybierz" />';
                                                        echo '</td></tr></table>';
                                                        echo '</form>';
                                                        echo '</form>';
                                                        echo 'wybierz miesiąc: ';
                                                        echo br();

                                                        $months = array('styczeń','luty','marzec','kwiecień','maj','czerwiec','lipiec','sierpień','wrzesień','październik','listopad','grudzień');
                                                        //date('F',mktime(0,0,0,$i))
                                                        //echo '<select id="month" name="month">';
                                                        for ($i = 1; $i <= 12; $i++)
                                                        {
                                                            echo '<a href="/'.$link.'/show_domain_chart/'.$domain_id.'/3/';
                                                            if ($i<10) echo '0';
                                                            echo $i.'/'.$rok.'"/>'.$months[$i-1].'</a>&nbsp;';
                                                        //echo '</select>';
                                                        }

                                                        if($this->uri->segment(5) != null)
                                                        {
                                                            $month = $this->uri->segment(5);
                                                        }else  $month = date("m",time());

                                                        //$weeks_in_year = strftime("%W",strtotime("12/31/".$rok));

                                                        echo br(2);
														//echo '<img src="/charts/chart_line_monthly/'.$domain_id.'" />';	
														echo '<div id="my_chart">charts/flash_chart_line_monthly/'.$domain_id.'/'.$month.'/'.$rok.'/</div>';
														break;
													}
										case 4: {
										   			// "kwartalne"; 
													//echo '<img src="/charts/chart_line_quartely/'.$domain_id.'" />';
													echo '<div id="my_chart">charts/flash_chart_line_quartely/'.$domain_id.'</div>';								
													break;
												}
										
										case 5: {
							    			// "roczne";
                                            //
											//echo '<img src="/charts/chart_line_yearly/'.$domain_id.'" />';
                                            $rok = date("Y");

											echo '<div id="my_chart">charts/flash_chart_line_yearly/'.$domain_id.'/'.$rok.'/</div>';
											break;
										}						
					}
					?>
					
					<br /><br />
					<div>
					<?php 	
							
							/*
							$colors[0] = 'rgb(100, 149, 237)';
							$colors[1] = 'rgb(240, 128, 128)';
							$colors[2] = 'rgb(50, 205, 50)';
							$colors[3] = 'rgb(255, 215, 0)';
							$colors[4] = 'rgb(131, 111, 255)';
							$colors[5] = 'rgb(144, 238, 144)';
							$colors[6] = 'rgb(70, 130, 180)';
							$colors[7] = 'rgb(244, 164, 96)';
							$colors[8] = 'rgb(139, 121, 94)';
							$colors[9] = 'rgb(190, 190, 190)';
							*/
							/*
							$colors[0] = 'rgb(255, 0, 0)';
							$colors[1] = 'rgb(255, 255, 0)';
							$colors[2] = 'rgb(0, 255, 0)';
							$colors[3] = 'rgb(0, 255, 255)';
							$colors[4] = 'rgb(0, 0, 255)';
							$colors[5] = 'rgb(255, 0, 255)';
							$colors[6] = 'rgb(149, 149, 149)';
							$colors[7] = 'rgb(96, 57, 19)';
							$colors[8] = 'rgb(130, 123, 0)';
							$colors[9] = 'rgb(0, 88, 38)';
							$colors[10] = 'rgb(247, 151, 151)';
							$colors[11] = 'rgb(146, 39, 143)';
							$colors[12] = 'rgb(54, 54, 54)';
							$colors[13] = 'rgb(96, 92, 169)';
							$colors[14] = 'rgb(60, 184, 120)';
							$colors[15] = 'rgb(13, 0, 76)';
							$colors[16] = 'rgb(199, 178, 154)';
							$colors[17] = 'rgb(75, 0, 73)';
							*/								
						
						$i=0;
						foreach($keywords as $keyword)
						{
							$querystring = 'search?q='.str_replace(' ','+',$keyword['keyword']).'&num=10';
							echo '<div style="float:left;text-align:left;width:32px; height:14px; background-color:'.$colors[$i].'">&nbsp;</div><div style="float:left;"> &nbsp;&nbsp;&nbsp; <a href="http://google.'.$google_region.'/'.$querystring.'" target="_blank">'.$keyword['keyword'].'</a></div><br style="clear:both"/><br />';
							$i++;
						}
					?>
							<div style="float:left;text-align:left;width:32px; height:14px; background-color:#ffffff">PZ</div>
							<div style="float:left;"> &nbsp;&nbsp;&nbsp; poza zakresem</div>
					</div>	
						<br style="clear:both"/><br />
					<div class="smallButton2"><a class="gray_link" href="/<?=$link;?>/domain">WSTECZ</a></div>
				</div>
			</td>	
		</tr>
		<tr>
			<td><img src="/files/contentBoxBottom.jpg" alt="" width="690" height="17"/></td>
		</tr>
	</table>
</div>	

