<script type="text/javascript">
	function get_domain(domain,s1,s2)
	{
		//alert(domain.options[domain.selectedIndex].value);
		window.location	= "http://panel.networds.pl/"+s1+"/"+s2+"/"+domain.options[domain.selectedIndex].value;
		//alert("http://panel.networds.pl/"+s1+"/"+s2+"/"+domain.options[domain.selectedIndex].value);
	}
</script>

<?php
	
	$s1 = $this->uri->segment(1);
	$s2 = $this->uri->segment(2);
	$s3 = $this->uri->segment(3);
	
	if($s1=='admin')
	{
		$domains = $this->baza->get_domains($this->session->userdata['di']);
	}	
	elseif($s1=='superadmin')
	{
		$domains = $this->baza->superadmin_get_domains($user, $this->session->userdata['di_sa']);
	}	
	elseif($s1=='master')
	{
		$domains = $this->baza->superadmin_get_domains('admin');
	}
	$ses_domians = array();
	
	foreach($domains as $d)
	{
		$ses_domians[$d['domain_id']] = $d['domain'];
	}
	
	$ile_domen = count($ses_domians);
	
	if($ile_domen > 1)
	{
		echo 'Wybierz domenę: <select name="switch_domain" onchange="return get_domain(this,\''.$s1.'\',\''.$s2.'\')">';
				foreach($ses_domians as $k=>$v)
				{
					if($k==$s3)
						echo '<option value="'.$k.'" selected="selected">'.$v.'</option>';	
					else
						echo '<option value="'.$k.'">'.$v.'</option>';
				}
		echo '</select><br /><br />';
	}
?>