<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">
                <div class="content_title"><a href="/<?php echo $this->uri->segment('1'); ?>/domain">Moje domeny</a> > wykresy pozycji słów kluczowych w google</div>
			
					<?php
						if($this->uri->segment('1')=='superadmin')
                        {
							$link = 'superadmin';
                            ?>

                                <div>
                                    <div style="float:left;"><?php $this->load->view('admin/switch_domain');?></div>
                                    <?php
                                            $controller     = $this->uri->segment(1);
                                            $domain_id      = (int)$this->uri->segment(3);
                                     ?>
                                    <div style="float:right;">
                                        <a title="pozycje w google" href="/<?php echo $controller.'/show_domain_stat/'.$domain_id; ?>" class="gray_link">
                                            <img alt="pozycje w google" src="/files/opcja1.gif">
                                        </a>&nbsp;
                                        <a title="wykresy pozycji w google" href="/<?php echo $controller.'/show_domain_chart/'.$domain_id; ?>" class="gray_link">
                                            <img alt="wykresy pozycji w google" src="/files/opcja2.gif">
                                        </a>
                                        <a title="statystyki odsłon strony" href="/<?php echo $controller.'/show_domain_statcounter/'.$domain_id; ?>" class="gray_link">
                                            <img alt="statystyki odsłon strony" src="/files/opcja3.gif">
                                        </a>
                                        <a title="szczegółowe statystyki odsłon strony" href="/<?php echo $controller.'/show_domain_keyword_activity/'.$domain_id; ?>" class="gray_link">
                                            <img alt="szczegółowe statystyki odsłon strony" src="/files/opcja4.gif">
                                        </a>
                                    </div>
                                </div>
                                <br class="clear"/>    
                                <?php
                        }
						else
                        {
                            $link = 'admin';
                            $this->load->view('admin/switch_domain');
                        }
							
						$type = $this->uri->segment(4);
    					if ($type==null)
						{
							$type=1;
						}
					?>
					
						<div class="mediumButton"><a class="gray_link" <?php if($type==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($type==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($type==3) echo 'style="color:#ec2323"'; ?> href="/<?=$link;?>/show_domain_chart/<?php echo $domain_id; ?>/3">miesięczne</a></div>
						<!--<div class="mediumButton"><a class="gray_link" <?php if($type==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($type==5) echo 'style="color:#ec2323"'; ?> href="/<?=$link;?>/show_domain_chart/<?php echo $domain_id; ?>/5">roczne</a></div>
					<br /><br /><br />
					
					<?php
					

						
					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_chart1">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" class="grey_button round_corners" value="wybierz" />';
                                                        echo '</td></tr></table>';
                                                        echo '</form><br/>';
                                                        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));

                                                        echo '<p>';
                                                        for($i=1;$i<=$weeks_in_year;$i++)
                                                        {
                                                            echo '<a class="week_link" href="/'.$link.'/show_domain_chart/'.$domain_id.'/2/'.$i.'/'.$rok.'"/>'.$i.'</a>&nbsp;';
                                                            if(($i%10==0)) echo '<br class="spacer"/>';
                                                        }
                                                        echo '</p>';
                                                        
                                                        echo br(2);
														//echo '<img src="/charts/chart_line_weekly/'.$domain_id.'" />';
														echo '<div id="my_chart1">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" class="grey_button round_corners" value="Wybierz" />';
                                                        echo '</td></tr></table>';
                                                        echo '</form>';
                                                        echo '</form><br/>';
                                                        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 class="month_link" href="/'.$link.'/show_domain_chart/'.$domain_id.'/3/';
                                                            if ($i<10) echo '0';
                                                            echo $i.'/'.$rok.'"/>'.$months[$i-1].'</a>&nbsp;';

                                                            if(($i%6==0)) echo '<br class="spacer"/>';
                                                        //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_chart1">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_chart1">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_chart1">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(' ','+',urlencode($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="formHr">&nbsp;</div>
                        <div class="form_buttons_v1">
                            <input type="button" onclick="document.location.href='/<?=$link;?>/domain';" class="formButton" value="wstecz" name="wstecz">
                        </div>
				</div>
			</td>	
		</tr>
		<tr>
			<td><img src="/files/contentBoxBottom.jpg" alt="" width="690" height="17"/></td>
		</tr>
	</table>
</div>	

