<?
    session_start();
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Bravacar – Autovermietung in Portugal – Online buchen</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<META NAME="Abstract" CONTENT="Autovermietung Madeira, Funchal, Lissabon, Algarve, Porto, online buchen">
<META NAME="Copyright" CONTENT="Bravacar">
<META NAME="Description" CONTENT="Bravacar – Autovermietung - Buchen Sie hier Ihren Mietwagen für den Urlaub in Portugal; Madeira, Lissabon, Algarve oder Porto. Den Gutschein erhalten Sie direkt nach der Buchungsbestätigung. Wir bieten Ihnen die Service-Qualität, die Sie von einer Autovermietung erwarten können.">
<META NAME="Generator" CONTENT="Bravacar">
<META NAME="Keywords" CONTENT="Autovermietung, Autovermietung in portugal, bravacar, Autovermietung in madeira, Autovermietung in lissabon, Autovermietung in porto, rent a car, car rental, rental, car rentals, rentals, holiday rentals, Preiswerte Autovermietung, Günstige Mietwagen für Ihren Urlaub, portugal rent a car, bravacar madeira, bravacar porto, bravacar lissabon, bravacar faro">
<META NAME="Language" CONTENT="de">
<META NAME="revisit-after" CONTENT="2 days">
<link rel="stylesheet" href="../assets/clases.css" type="text/css">

<meta name="robots" content="index,follow">
<meta name="googlebot" content="index,follow">

<script type="text/javascript" language="javascript" src="../assets/car_func.js"></script>
<script type="text/javascript" language="javascript" src="../assets/validation.js"></script>
<script type="text/javascript" language="javascript" src="../assets/script.js"></script>
<script type="text/javascript" language="javascript" src="../assets/effects.js"></script>

<SCRIPT TYPE="text/javascript" language="javascript">
<!--
function func_car_destination() {
var dest = document.bookcarLayout.car_destination.value;
var reg  = document.bookcarLayout.registos.value;
var reg1 = document.bookcarLayout.registos1.value;

change_drop_off(dest,reg);
desc_destination(dest,reg1);

}

function func_car_dropoff_loc() {
var dest = document.bookcarLayout.car_destination.value;
var reg  = document.bookcarLayout.registos.value;
var loc  = document.bookcarLayout.car_dropoff_loc.value;
desc_drop_off(dest,loc,reg);
}
//-->
</SCRIPT>

<LINK REL="STYLESHEET" TYPE="text/css" HREF="../html/style.css">
<LINK REL="STYLESHEET" TYPE="text/css" HREF="../html/site.css">

</HEAD>
<BODY STYLE="text-align: center; background-color: rgb(255,255,255); background-image: none; margin: 0px;">
    <DIV ALIGN="CENTER">
    <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="780">
        <TR>
            <TD>
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="780" STYLE="background-color: rgb(40,49,79); height: 21;">
                    <TR ALIGN="LEFT" VALIGN="middle">
                        <TD width="510" HEIGHT="21"></TD>
                        <TD WIDTH="20"><IMG ID="PictPT" HEIGHT="11" WIDTH="16" SRC="../assets/images/pt.gif" BORDER="0" ALT="pt"></TD>
                        <TD width="18"></TD>
                        <TD WIDTH="20"><IMG ID="PictGB" HEIGHT="11" WIDTH="16" SRC="../assets/images/gb.gif" BORDER="0" ALT="gb"></TD>
                        <TD width="18"></TD>
                        <TD WIDTH="20"><IMG ID="PictDE" HEIGHT="11" WIDTH="16" SRC="../assets/images/de.gif" BORDER="0" ALT="de"></TD>
                        <TD WIDTH="174" class="muda_link">                            
                            <P STYLE="text-align: center;">
                            <B><SPAN STYLE="font-family: Verdana,Tahoma,Arial,Helvetica,Sans-serif; font-size: xx-small;">
                            <A HREF="../../index.php">Português</A> | 
                            <A HREF="../../english/index.php">English</A> | 
                            <span class="link_actual"><A HREF="../index.php">Deutsch</A></span></SPAN></B></P>                                  
                        </TD>
                    </TR>
                </TABLE>       
                    
                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="780">
                    <TR>
                        <TD HEIGHT="48" WIDTH="780">
                            <IMG ID="Pict357" HEIGHT="48" WIDTH="780" SRC="../assets/images/bravacar_01.gif" BORDER="0" ALT=""></TD>
                    </TR>
                    <TR>
                        <TD HEIGHT="159" WIDTH="780">
                            <IMG ID="Pict358" HEIGHT="159" WIDTH="780" SRC="../assets/images/bravacar_02.jpg" BORDER="0" ALT=""></TD>
                    </TR>
                 </TABLE>
    
                 <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="780">
                    <TR VALIGN="TOP" ALIGN="LEFT">
                        <TD HEIGHT="7" WIDTH="780">
                            <IMG ID="Pict359" HEIGHT="7" WIDTH="780" SRC="../assets/images/linha01.jpg" BORDER="0" ALT=""></TD>
                    </TR>
                    <TR VALIGN="TOP" ALIGN="LEFT">
                        <TD HEIGHT="25" CLASS="TextObject">
                        <P><script type="text/javascript" language="javascript" src="../assets/menu_bravacar_de.js"></script></P></TD>
                    </TR>       
                    <TR VALIGN="TOP" ALIGN="LEFT">
                        <TD HEIGHT="25" CLASS="TextObject">&nbsp;</TD>
                    </TR>                                  
                </TABLE>  
				<?
                if ($_SERVER['REQUEST_METHOD'] == "GET") 
                {
                    include('main.php');    
                    include('book_car_functions.php');   
                
                    db_connect();	 
                   
                    $cod_rentacar = $_GET["rentacar"];
                    $cod_regiao   = $_GET["regiao"];
                    $data_in      = $_GET["date1"];
                    $data_out     = $_GET["date2"];
                
                    $date1        = $_GET["date1"];
                    $date2        = $_GET["date2"];
                
                    $hour_in      = $_GET["hour1"];
                    $hour_out     = $_GET["hour2"];
                    $min_in       = $_GET["min1"];
                    $min_out      = $_GET["min2"];
                    $group        = $_GET["cod_grupo"];
                    $class        = $_GET["car_class"];
                    $pick_up_loc  = $_GET["pickup_loc"];
                    
                    $endereco_pick_up = '';
                
                    $data_in  = FormatarDataHora($data_in,$hour_in,$min_in);
                    $data_out = FormatarDataHora($data_out,$hour_out,$min_out);             
                
                    $data_in_1  = FormatarData($date1);
                    $data_out_1 = FormatarData($date2);    
                
                    $nro_dias   = diff_days($data_in,$data_out);             
                    $hora_tol   = (fmod((strtotime($data_out) - strtotime($data_in)),86400)/3600);
                    
                    if ($nro_dias == 0)
                    {
                        $nro_dias = $nro_dias + 1;  
                        $hora_tol = 0;
                    }
                
                    $sql = "select b.nome, b.comissao, b.cidade, b.morada, f.descricao, ";
                    $sql = $sql." a.cod_grupo, a.descricao_de, g.codigo, g.descricao, d.horas_tol, d.cod_tarifa, ";
                    $sql = $sql." ((100*e.preco)/(100-b.comissao)) as preco_dia, ";    
                    $sql = $sql." ((100*e.preco)/(100-b.comissao))* ";
                    $sql = $sql." ($nro_dias + (case when $hora_tol > d.horas_tol then 1 else 0 end)) as preco, ";
                    $sql = $sql." c.endereco "; 
                    $sql = $sql." from tr_rentacar_grupos a, tr_rentacar b, ";
                    $sql = $sql." tr_rentacar_escritorios c, tr_rentacar_tarifas d, ";
                    $sql = $sql." tr_rentacar_tarifas_precos e, tbregiao f, tr_rentacar_categoria g ";
                    $sql = $sql." where a.cod_rentacar = b.cod_rentacar ";
                    $sql = $sql." and b.cod_rentacar   = $cod_rentacar ";
                    $sql = $sql." and c.cod_localidade = $pick_up_loc ";
                    $sql = $sql." and c.entrega = 1 ";
                    $sql = $sql." and c.cod_rentacar = b.cod_rentacar ";
                    $sql = $sql." and d.cod_rentacar = b.cod_rentacar ";
                    $sql = $sql." and e.cod_rentacar = b.cod_rentacar ";
                    $sql = $sql." and d.cod_tarifa = e.cod_tarifa ";
                    $sql = $sql." and ($nro_dias + (case when $hora_tol > d.horas_tol then 1 else 0 end)) >= e.day_from ";
                    $sql = $sql." and ($nro_dias + (case when $hora_tol > d.horas_tol then 1 else 0 end)) <= e.day_to ";
                    $sql = $sql." and d.data_inicio <= '$data_in' ";
                    $sql = $sql." and d.data_fim >= '$data_in' ";
                    $sql = $sql." and e.cod_grupo = a.cod_grupo ";
                    //$sql = $sql." and b.cod_regiao = $cod_regiao ";
                    $sql = $sql." and f.cod_regiao = $cod_regiao ";
                    $sql = $sql." and a.cod_categoria = g.codigo ";
                    $sql = $sql." and e.cod_grupo = '$group' ";
                    $sql = $sql." and b.activo = 1 ";
                    $sql = $sql." order by preco ";
                
                    $result = mysql_query($sql) or die("select rentacar fails");
                    $no     = mysql_num_rows($result);
                        
                    if ($no!=0) 
                    {                
                        $row = mysql_fetch_row($result);
                 
                        $nome              = $row[0];
                        $comissao          = $row[1];
                        $cidade            = $row[2];
                        $morada            = $row[3];
                        $desc_regiao       = $row[4];
                        $cod_grupo         = $row[5];
                        $desc_grupo        = $row[6];
                        $cod_categoria     = $row[7];
                        $desc_categoria    = $row[8];
                        $horas_tolerancia  = $row[9];
                        $cod_tarifa        = $row[10];
                        $preco_dia         = $row[11];
                        $preco_total       = $row[12];
                        $endereco_pick_up  = $row[13];
                
                        //$endereco        = $morada.' - '.$cidade.' - '.$desc_regiao;
                        $endereco          = $endereco_pick_up.' - '.$desc_regiao;
                       
                        $charged     = ($preco_total*$comissao)/100;
                        $balance     = ($preco_total*(100 - $comissao))/100;
                
                        $charged     = number_format($charged, 2, '.', '');
                        $balance     = number_format($balance, 2, '.', '');
                
                        $preco_dia   = number_format($preco_dia, 2, '.', '');
                        $preco_total = number_format($preco_total, 2, '.', '');  
                        
                        if ($nro_dias > 1)
                            $mensagem_dias = $nro_dias.' Tag';
                        else
                            $mensagem_dias = $nro_dias.' Tag';
                        
                        if ($hora_tol > $horas_tolerancia)
                        {
                            $nro_dias  = $nro_dias + 1; 
                            $dias_real = floor(((strtotime($data_out) - strtotime($data_in))/86400));
                            $dias_data = diff_days($data_in_1,$data_out_1);
                                       
                            if ($dias_real == $dias_data)
                                $mensagem_dias = ' (Dif hours > '.$horas_tolerancia.') ==> + 1 day  ==> '.$nro_dias.' days';
                            else
                                $mensagem_dias = $nro_dias.' days';      
                        }
                    }
                
                    $sql = "select descricao_de from tr_rentacar_localidades ";
                    $sql = $sql." where cod_localidade = $pick_up_loc ";
                    
                    $result = mysql_query($sql) or die("select location fails");
                    $no     = mysql_num_rows($result);
                        
                    if ($no!=0) 
                    {                
                        $row = mysql_fetch_row($result);
                        $desc_pick_up_loc  = $row[0];
                    }
                
                    $date_array  = explode("/",$_GET["date1"]);
                    $var_day     = $date_array[0]; 
                    $var_month   = $date_array[1]; 
                    $var_year    = $date_array[2]; 
                    $day_week_in = jddayofweek ( cal_to_jd(CAL_GREGORIAN,$var_month,$var_day,$var_year), 1 );
                	$day_week_in = traduzir_dia_de($day_week_in);
					
                    $data_pickup = $day_week_in.', '.$_GET["date1"].' um '.$hour_in.':'.$min_in;
                
                    $date_array    = explode("/",$_GET["date2"]);
                    $var_day       = $date_array[0]; 
                    $var_month     = $date_array[1]; 
                    $var_year      = $date_array[2]; 
                    $day_week_out  = jddayofweek ( cal_to_jd(CAL_GREGORIAN,$var_month,$var_day,$var_year), 1 );
    				$day_week_out  = traduzir_dia_de($day_week_out);
	                
                    $data_drop_off = $day_week_out.', '.$_GET["date2"].' um '.$hour_out.':'.$min_out;
                }                
                ?>
                <FORM NAME="bookcarLayout" ACTION="ins_prod.php" method="GET">
                    <INPUT type=hidden NAME="registos" VALUE="">
                    <INPUT type=hidden NAME="registos1" VALUE="">
                    <INPUT type=hidden NAME="desc_drop_off_loc" VALUE="">
                    <INPUT type=hidden NAME="desc_destination" VALUE="">
                    <INPUT type=hidden NAME="endereco_drop_off" VALUE="">                    
                    <TABLE width="780" border="0" cellspacing="0" cellpadding="0">
                        <tr>                
                            <td valign="top" width="159"><IMG ID="Pict1" HEIGHT="46"  WIDTH="159" SRC="../assets/images/autogen/a_botao-estatico_4.gif" BORDER="0" ALT=""><img ID="Pict2" HEIGHT="379" WIDTH="159" SRC="../assets/images/05megane1.jpg" alt=""></td>
                            <td width="31">&nbsp;</td>                    
                            <td width="560" valign="top">
                            	<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" bgcolor="#E41F1F" style="padding:2px;"><TR><TD>
                                <TABLE ID="Table48" BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
                                    <TR>
                                        <TD COLSPAN="2" STYLE="background-color: rgb(215,220,232); height:25px; text-align:center; vertical-align:middle">
                                            <B><SPAN STYLE="font-family: Verdana,Tahoma,Arial,Helvetica,Sans-serif; font-size:13px;">KONDITIONEN UND TARIFEN</SPAN></B>
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD WIDTH="220" STYLE="background-color: rgb(255,255,255); padding-left: 4pt; height:21px;">
                                            <SPAN class="text_site">Kategorie:</SPAN>
                                        </TD>
                                        <TD WIDTH="330" STYLE="background-color: rgb(255,255,255); padding-right: 8pt; text-align:right">
                                            <SPAN class="text_site"><? echo $desc_categoria;?></SPAN>
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-left: 4pt; height:21px;">
                                            <SPAN class="text_site">Autotyp:</SPAN>
                                        </TD>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-right: 8pt; text-align:right">
                                            <SPAN class="text_site"><? echo $desc_grupo;?></SPAN>
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-left: 4pt; height:21px; ">
                                            <SPAN class="text_site">Anmietstation:</SPAN>
                                        </TD>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-right: 8pt; text-align: right;">
                                            <SPAN class="text_site"><? echo $desc_pick_up_loc;?></SPAN>
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-left: 4pt; height:21px;">
                                            <SPAN class="text_site">Anmietdatum:</SPAN>
                                        </TD>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-right: 8pt; text-align: right;">
                                            <SPAN class="text_site"><? echo $data_pickup;?></SPAN>
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-left: 4pt; height:21px;">
                                            <SPAN class="text_site">Rückgabedatum:</SPAN>
                                        </TD>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-right: 8pt; text-align: right;">
                                            <SPAN class="text_site"><? echo $data_drop_off;?></SPAN>
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-left: 4pt; height:21px;">
                                            <SPAN class="text_site">Anzahl Tage:</SPAN>
                                        </TD>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-right: 8pt; text-align: right;">
                                            <SPAN class="text_site"><? echo $mensagem_dias; ?></SPAN>
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-left: 4pt; height:21px;">
                                            <SPAN class="text_site">Preis pro Tag:</SPAN>
                                        </TD>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-right: 8pt; text-align: right;">
                                            <SPAN class="text_site_r"><? echo $preco_dia.' EUR'; ?></SPAN>
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-left: 4pt; height:21px;">
                                            <SPAN class="text_site">Gesamtbetrag Mietwagen:</SPAN>
                                        </TD>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-right: 8pt; text-align: right;">
                                            <SPAN class="text_site_r">
                                            <?
                                            echo "<input type=\"hidden\" value=\"$preco_total\" name=hidden_preco_total_carro>";
                                            $preco_total_carro = $preco_total.' EUR';
                                            echo "<input type=\"text\" value=\"$preco_total_carro\" name=preco_total_carro style='border-width:0px; font-family: Verdana,Tahoma,Arial,Helvetica,Sans-serif,sans-serif; font-size: 11px; font-weight:normal; text-align: right' size='30' readonly='readOnly'>"; ?>
                                            </SPAN>
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-left:4px; height:21px">
                                            <SPAN class="text_site">Gesamtbetrag zusätzliche Extras:</SPAN>
                                        </TD>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-right: 8pt; text-align: right;">
                                            <SPAN class="text_site_r">
											<? $total_extras_euros = '0,00 EUR';
											echo "<input type=\"text\" value=\"$total_extras_euros\" name=total_extras1 style='border-width:0px; font-family: Verdana,Tahoma,Arial,Helvetica,Sans-serif,sans-serif; font-size: 11px; text-align: right' size='30' readonly='readOnly'>"; ?>
											</SPAN>
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD STYLE="background-color: rgb(215,220,232); padding-left:4px; height:21px">
                                            <B><SPAN class="text_site">Von der Kreditkarte abbuchen:</SPAN></B>
                                        </TD>
                                        <TD STYLE="background-color: rgb(215,220,232); padding-right: 8pt; text-align: right;">
                                            <B><SPAN class="text_site" STYLE="font-size: 13px;">
											<? echo $charged.' EUR'; ?></SPAN></B>
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-left:4px; height:21px">
                                            <SPAN class="text_site">Vor Ort beim Vermieter bezahlen:</SPAN>
                                        </TD>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-right: 8pt; text-align: right;">
                                            <B><SPAN class="text_site_r">
											<? $balance_euros = $balance.' EUR';
											echo "<input type=\"text\" value=\"$balance_euros\" name=balance1 style='border-width:0px; font-family: Verdana,Tahoma,Arial,Helvetica,Sans-serif,sans-serif; font-size: 11px; font-weight:bold; text-align: right' size='30' readonly='readOnly'>"; ?>
											</SPAN></B>
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-left: 4pt; height:21px">
                                            <SPAN class="text_site">Mietpreis insgesamt:</SPAN>
                                        </TD>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-right: 8pt; text-align: right;">
                                            <B><SPAN class="text_site_r">
											<?
												$preco_total_euros = $preco_total.' EUR';
												echo "<input type=\"text\" value=\"$preco_total_euros\" name=preco_total1 style='border-width:0px; font-family: Verdana,Tahoma,Arial,Helvetica,Sans-serif,sans-serif; font-size: 11px; font-weight:bold; text-align: right;' size='30' readonly='readOnly'>"; ?>
											</SPAN></B>
                                        </TD>
                                    </TR>
                                </TABLE> 
                                </TD></TR></TABLE>
                                <BR>
                                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" bgcolor="#E41F1F" style="padding:2px;"><TR><TD>
                                <TABLE ID="Table75" BORDER="0" CELLSPACING="0" CELLPADDING="0" bgcolor="#FFFFFF" WIDTH="100%">
                                    <TR>
                                        <TD WIDTH="260" STYLE="padding-left: 4pt; height:21px; vertical-align:bottom;">
                                            <SPAN class="text_site">
                                            <B>Stadt:</B> 
											<?
											function ConvertToJSArray_dest($PArray , $ArrayName, $filas)
											{
											$Row = $filas;
											$Col = 2;
											
											?>
											<SCRIPT type="text/javascript" language="javascript">
											<?=$ArrayName?> = new Array(<?=$Row?>);
											for (i=0; i < <?=$Row?>; i++) 
											{ 
											<?=$ArrayName?>[i] = new Array(<?=$Col?>);
											for (j=0; j < <?=$Col?>; j++) 
											<?=$ArrayName?>[i][j] = " ";
											}
											
											<? 
											for ($i=0;$i<$Row;$i++) 
											{
											for ($j=0;$j<$Col;$j++) 
											{
											$str = $PArray[$i][$j];
											?> 
											<?=$ArrayName?>[<?=$i?>][<?=$j?>] = "<?=$str?>"
											<?
											}
											}
											?> 
											document.bookcarLayout.registos1.value = <?=$Row?>;  
											</SCRIPT>
											
											<?
											
											}
											
											function ConvertToJSArray2D($PArray , $ArrayName, $filas)
											{
											$Row = $filas;
											$Col = 4;
											
											?>
											<SCRIPT type="text/javascript" language="javascript">
											<?=$ArrayName?> = new Array(<?=$Row?>);
											for (i=0; i < <?=$Row?>; i++) 
											{ 
											<?=$ArrayName?>[i] = new Array(<?=$Col?>);
											for (j=0; j < <?=$Col?>; j++) 
											<?=$ArrayName?>[i][j] = " ";
											}
											
											<? 
											for ($i=0;$i<$Row;$i++) 
											{
											for ($j=0;$j<$Col;$j++) 
											{
											$str = $PArray[$i][$j];
											?> 
											<?=$ArrayName?>[<?=$i?>][<?=$j?>] = "<?=$str?>"
											<?
											}
											}
											?> 
											document.bookcarLayout.registos.value = <?=$Row?>;
											</SCRIPT>
											
											<?
											
											}
											
											function create_drop_off_destination($Row)
											{
											?>
											<SCRIPT type="text/javascript" language="javascript">
											drop_off_destination(<?=$Row?>);
											</SCRIPT>
											<?
											}
											
											$sql = "SELECT a.cod_regiao, a.cod_localidade, b.descricao_de, a.endereco ";
											$sql = $sql." FROM tr_rentacar_escritorios a, tr_rentacar_localidades b ";
											$sql = $sql." WHERE a.cod_localidade = b.cod_localidade ";
											$sql = $sql." and a.recolha = 1 ";
											$sql = $sql." and a.cod_rentacar = $cod_rentacar ";
											$sql = $sql." GROUP BY a.cod_regiao, a.cod_localidade, b.descricao, a.endereco ";
											$sql = $sql." ORDER BY b.descricao ";
											
											$result = mysql_query($sql) or die("select fails");      
											$filas  = mysql_num_rows($result);   
											
											$i = 0;	
											while ($row = mysql_fetch_row($result))
											{     
											$tabela_loc[$i][0] = $row[0];
											$tabela_loc[$i][1] = $row[1];
											$tabela_loc[$i][2] = $row[2];
											$tabela_loc[$i][3] = $row[3];
											$i = $i + 1;
											}  
											ConvertToJSArray2D($tabela_loc, 'tb_loc', $filas);
											
											$sql = "SELECT a.cod_regiao, b.dedescricao ";
											$sql = $sql." FROM tr_rentacar_escritorios a, tbregiao b ";
											$sql = $sql." WHERE a.cod_rentacar = $cod_rentacar ";
											$sql = $sql." and a.cod_regiao = b.cod_regiao ";
											$sql = $sql." and a.recolha = 1 ";
											$sql = $sql." GROUP BY a.cod_regiao, b.descricao ";
											$sql = $sql." ORDER BY a.cod_regiao ";
											
											$result1  = mysql_query($sql) or die("select fails");   
											$num_row1 = mysql_num_rows($result1);
											
											$i = 0;	
											while ($row = mysql_fetch_row($result1))
											{     
											$tabela_dest[$i][0] = $row[0];
											$tabela_dest[$i][1] = $row[1];
											$i = $i + 1;
											}
											ConvertToJSArray_dest($tabela_dest, 'tb_dest', $num_row1);   
											
											?>
											</SPAN>
                                        </TD>
                                        <TD WIDTH="310" style="vertical-align:bottom;">
                                            <B><SPAN class="text_site">Rückgabestation:</SPAN></B>
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD STYLE="padding-left: 4pt; height:27px;">
                                            <SELECT ID="ID_car_destination" NAME="car_destination" style="width:180px" class="text_objects" onChange="return(func_car_destination())">
                                                <OPTION VALUE="0" SELECTED>Bitte wählen Sie ein Ort</OPTION>
                                            </SELECT>
                                        </TD>
                                        <TD>
                                            <SELECT ID="ID_car_dropoff_loc" NAME="car_dropoff_loc" style="width:210px" class="text_objects" onChange="return(func_car_dropoff_loc())">
                                                <OPTION VALUE="0" SELECTED>Bitte wählen Sie eine Rückgabestation</OPTION>
                                            </SELECT>
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD STYLE="padding-left: 4pt; height:21px; vertical-align:bottom;">
                                            <SPAN class="text_site"><B>Hotel:</B></SPAN>
                                        </TD>
                                        <TD STYLE="vertical-align:bottom;">
                                            <SPAN class="text_site"><B>Flugnummer:</B></SPAN>
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD STYLE="padding-left: 4pt; height:27px;">
                                            <INPUT ID="ID_nome_hotel" TYPE="TEXT" NAME="nome_hotel" VALUE="" SIZE="22" MAXLENGTH="50" style="width:180px; white-space: pre; font-size: 11px;" class="text_objects">
                                        </TD>
                                        <TD>
                                            <INPUT ID="ID_nro_voo" TYPE="TEXT" NAME="nro_voo" STYLE="white-space: pre;" VALUE="" SIZE="25" MAXLENGTH="15" class="text_objects">
                                        </TD>
                                    </TR>
                                </TABLE>  
                                </TD></TR></TABLE>
                                <BR>   
								<TABLE ID="Table74" BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="100%" STYLE="background-color: rgb(255,255,255); border-left-color:  rgb(255,255,255); border-top-color:  rgb(255,255,255); border-right-color:  rgb(255,255,255); border-bottom-color:  rgb(255,255,255); height: 18;">
                                    <TR STYLE="height:18px">
                                        <TD WIDTH="555" STYLE="background-color: rgb(255,255,255);">
                                            <P STYLE="text-align: center;">
                                            <SPAN STYLE="color: rgb(0,102,153);">_________________________________________________________</SPAN></P>
                                        </TD>
                                    </TR>
                                </TABLE>  
                                <BR>  
                                <?
                                if ($_SERVER['REQUEST_METHOD'] == "GET") 
                                {
                                    create_drop_off_destination($num_row1);
                                    
                                    // EXTRAS INCLUIDOS
                                    $sql = "select a.cod_extra, a.desc_extra_de, b.cod_interno ";
                                    $sql = $sql." from tr_rentacar_extras a, tr_rentacar_extras_values b ";
                                    $sql = $sql." where a.cod_rentacar = b.cod_rentacar ";
                                    $sql = $sql." and b.cod_rentacar   = $cod_rentacar ";
                                    $sql = $sql." and a.cod_extra  = b.cod_extra ";
                                    $sql = $sql." and b.cod_grupo  = '".$cod_grupo."' ";
                                    $sql = $sql." and b.cod_tarifa = $cod_tarifa ";
                                    $sql = $sql." and b.incluido   = 1 ";
                                    $sql = $sql." order by desc_extra ";    
                                
                                    $result = mysql_query($sql) or die("select extras fails");
                                    $no     = mysql_num_rows($result);
                                        
                                    if ($no!=0) 
                                    {
                                        $indice = 1;        
                                        draw_header_extras_included();                
                                        while ($row = mysql_fetch_row($result))
                                        {        
                                            $desc_extra    = $row[1];
                                            draw_body_extras_included($desc_extra);
                                        }
                                        draw_foot_extras_included();
                                        echo '<br>';
                                    }
                                
                                    // EXTRA FORA HORAS
                                    $total_extras_eur    = 0;
                                    $total_fh_extras_eur = 0;
                                
                                    $time_inicio = "'".$hour_in.":".$min_in."'";
                                
                                    $sql = "select a.cod_extra, a.desc_extra_de, b.cod_interno, b.preco ";
                                    $sql = $sql." from tr_rentacar_extras a, tr_rentacar_extras_values b, ";
                                    $sql = $sql." tr_rentacar_escritorios c ";
                                    $sql = $sql." where a.cod_rentacar = b.cod_rentacar ";
                                    $sql = $sql." and b.cod_rentacar   = $cod_rentacar ";
                                    $sql = $sql." and c.cod_rentacar   = $cod_rentacar ";
                                    $sql = $sql." and c.cod_localidade = $pick_up_loc ";
                                    $sql = $sql." and c.hora_inicio_fora_horas <> '00:00'";
                                    $sql = $sql." and c.hora_inicio_manha <> '00:00'";
                                    $sql = $sql." and c.entrega = 1 ";
                                    $sql = $sql." and (time_to_sec(c.hora_inicio_manha) > time_to_sec(".$time_inicio.")";
                                    $sql = $sql." or time_to_sec(c.hora_inicio_fora_horas) < time_to_sec(".$time_inicio."))";
                                    $sql = $sql." and a.cod_extra  = b.cod_extra ";
                                    $sql = $sql." and b.cod_grupo  = '".$cod_grupo."' ";
                                    $sql = $sql." and b.cod_tarifa = $cod_tarifa ";
                                    $sql = $sql." and b.incluido   = 0 ";
                                    $sql = $sql." and a.extra_fora_horas = 1 ";
                                    $sql = $sql." order by desc_extra ";    
                                    
                                    $result = mysql_query($sql) or die("select extra fora horas fails");
                                    $no     = mysql_num_rows($result);
                                        
                                    if ($no!=0) 
                                    {
                                        $indice = 1;
                                        $hidden_extras = "";        
                                        draw_header_extras_out_hours();                
                                        while ($row = mysql_fetch_row($result))
                                        {        
                                            $cod_extra_out = $row[0];
                                            $desc_extra    = $row[1];
                                            $cod_interno   = $row[2];            
                                            $preco         = $row[3];   
                                
                                            $total_extras_eur    = $total_extras_eur + $preco;
                                            $total_fh_extras_eur = $total_fh_extras_eur + $preco;
                                
                                            $preco = number_format($preco, 2, '.', '');         
                                            draw_body_extras_out_hours($desc_extra, $preco);
                                
                                            $var             = "cod_extra_out".$indice;   
                                            $var_desc        = "desc_extra_out".$indice;          
                                            $var_price       = "price_extra_out".$indice;      
                                            $var_total_price = "price_total_extra_out".$indice;      
                                        
                                            $hidden_extras = $hidden_extras."<input type=\"hidden\" value=\"$cod_extra_out\" name=".$var.">";             
                                            $hidden_extras = $hidden_extras."<input type=\"hidden\" value=\"$desc_extra\" name=".$var_desc.">";   
                                            $hidden_extras = $hidden_extras."<input type=\"hidden\" value=\"$preco\" name=".$var_price.">";   
                                            $hidden_extras = $hidden_extras."<input type=\"hidden\" value=\"$preco\" name=".$var_total_price.">";   
                                            $indice = $indice + 1;
                                        }
                                        draw_foot_extras_out_hours();
                                        echo '<br>';
                                        echo $hidden_extras;
                                    }
                                
                                    // EXTRAS NAO INCLUIDOS
                                    $sql = "select a.cod_extra, a.desc_extra_de, b.preco, a.preco_por_dia, b.cod_interno ";
                                    $sql = $sql." from tr_rentacar_extras a, tr_rentacar_extras_values b ";
                                    $sql = $sql." where a.cod_rentacar = b.cod_rentacar ";
                                    $sql = $sql." and b.cod_rentacar   = $cod_rentacar ";
                                    $sql = $sql." and a.cod_extra  = b.cod_extra ";
                                    $sql = $sql." and b.cod_grupo  = '".$cod_grupo."' ";
                                    $sql = $sql." and b.cod_tarifa = $cod_tarifa ";
                                    $sql = $sql." and b.incluido   = 0 ";
                                    $sql = $sql." and a.extra_fora_horas = 0 ";
                                    $sql = $sql." order by desc_extra ";    
                                
                                    $result = mysql_query($sql) or die("select extras fails");
                                    $no     = mysql_num_rows($result);
                                        
                                    if ($no!=0) 
                                    {
                                        $indice = 1;
                                        $hidden_extras = "";
                                        draw_header_extras();                
                                        while ($row = mysql_fetch_row($result))
                                        {        
                                            $cod_extra     = $row[0];
                                            $desc_extra    = $row[1];
                                            $preco         = $row[2];
                                            $preco_por_dia = $row[3];
                                            $cod_interno   = $row[4];
                                            $preco         = number_format($preco, 2, '.', '');        
                                            draw_body_extras($indice, $cod_extra, $desc_extra, $preco, $preco_por_dia, $nro_dias, $preco_total);
                                
                                            $var           = "cod_extra".$indice;      
                                            $var_desc      = "hidden_desc_extra".$indice;   
                                            $var_price     = "hidden_price_extra".$indice;   
                                            $var_hidden    = "hidden_price_total_extra".$indice;
                                            
                                            $hidden_extras = $hidden_extras."<input type=\"hidden\" value=\"$cod_extra\" name=".$var.">"; 
                                            $hidden_extras = $hidden_extras."<input type=\"hidden\" value=\"$desc_extra\" name=".$var_desc.">"; 
                                            $hidden_extras = $hidden_extras."<input type=\"hidden\" value=\"$preco\" name=".$var_price.">"; 
                                            $hidden_extras = $hidden_extras."<input type=\"hidden\" value=0 name=".$var_hidden.">"; 
                                            $indice = $indice + 1;
                                        }
                                        draw_foot_extras();
                                        echo $hidden_extras;
                                    }    
                                
                                    echo "<input type='hidden' value='Car' name=Type>"; 
                                    echo "<input type='hidden' value=1 name=id>"; 
                                    echo "<input type='hidden' value=$cod_rentacar name=cod_rentacar>"; 
                                    echo "<input type=\"hidden\" value=\"$nome\" name=desc_rentacar>"; 
                                    echo "<input type='hidden' value=$cod_regiao name=cod_regiao>"; 
                                    echo "<input type=\"hidden\" value=\"$desc_regiao\" name=desc_regiao>";      
                                    echo "<input type='hidden' value=$cod_categoria name=cod_categoria>"; 
                                    echo "<input type=\"hidden\" value=\"$desc_categoria\" name=desc_categoria>";     
                                    echo "<input type=\"hidden\" value=\"$cod_grupo\" name=cod_grupo>"; 
                                    echo "<input type=\"hidden\" value=\"$desc_grupo\" name=desc_grupo>"; 
                                    echo "<input type='hidden' value=$pick_up_loc name=pick_up_loc>"; 
                                    echo "<input type=\"hidden\" value=\"$desc_pick_up_loc\" name=desc_pick_up_loc>";
                                    echo "<input type=\"hidden\" value=\"$data_pickup\" name=data_pickup>";  
                                    echo "<input type=\"hidden\" value=\"$date1\" name=date1>"; 
                                    echo "<input type=\"hidden\" value=\"$hour_in\" name=hour1>"; 
                                    echo "<input type=\"hidden\" value=\"$min_in\" name=min1>";
                                    echo "<input type=\"hidden\" value=\"$data_drop_off\" name=data_drop_off>";  
                                    echo "<input type=\"hidden\" value=\"$date2\" name=date2>"; 
                                    echo "<input type=\"hidden\" value=\"$hour_out\" name=hour2>"; 
                                    echo "<input type=\"hidden\" value=\"$min_out\" name=min2>"; 
                                    echo "<input type=\"hidden\" value=\"$nro_dias\" name=nro_dias>"; 
                                    echo "<input type=\"hidden\" value=\"$comissao\" name=comissao>"; 
                                    echo "<input type=\"hidden\" value=\"$preco_dia\" name=preco_dia>"; 
                                    echo "<input type=\"hidden\" value=\"$charged\" name=charged>"; 
                                    echo "<input type=\"hidden\" value=\"$balance\" name=balance>"; 
                                    echo "<input type=\"hidden\" value=\"$preco_total\" name=preco_total>"; 
                                    echo "<input type=\"hidden\" value=0 name=total_extras>"; 
                                    echo "<input type='hidden' value='' name=special_request>";
                                    echo "<input type=\"hidden\" value=\"$endereco_pick_up\" name=endereco_pick_up>"; 
                                    echo "<input type='hidden' value=$cod_tarifa name=cod_tarifa>"; 
                                
                                    db_disconnect();
                                }
                                ?>
                                <BR>                                
                                <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" bgcolor="#E41F1F" style="padding:2px;"><TR><TD>        
                                <TABLE ID="Table78" BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
                                    <TR>
                                        <TD COLSPAN="2" class="text_site" STYLE="text-align:center; background-color: rgb(215,220,232); height:25px; vertical-align:middle; font-size:13px;">
                                            <B>GESAMTBETRAG</B>
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD STYLE="background-color: rgb(255,255,255); height:21px;" width="350">
                                            <P STYLE="margin-left: 4pt;">
                                            <SPAN STYLE="font-family: Verdana,Tahoma,Arial,Helvetica,Sans-serif; font-size: 11px;">Gesamtbetrag Mietwagen:</SPAN></P>
                                        </TD>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-right: 8pt; text-align: right;" width="200">
                                            <SPAN class="text_site_r"><? echo $preco_total.' EUR'; ?></SPAN>
                                        </TD>
                                                                               
                                    </TR>
                                    <TR>
                                        <TD STYLE="background-color: rgb(255,255,255); height:21px;">
                                            <P STYLE="margin-left: 4pt;">
                                            <SPAN STYLE="font-family: Verdana,Tahoma,Arial,Helvetica,Sans-serif; font-size: 11px;">Gesamtbetrag zusätzliche Extras:</SPAN></P>
                                        </TD>
                                        <TD STYLE="text-align: right; background-color: rgb(255,255,255); padding-right: 8pt; text-align:right;">
                                            <SPAN class="text_site_r">
											<?
											$total_extras_euros = '0,00 EUR';
											echo "<input type=\"text\" value=\"$total_extras_euros\" name=total_extras2 style='border-width:0px; font-family: Verdana,Tahoma,Arial,Helvetica,Sans-serif,sans-serif; font-size: 11px; text-align: right;' size='30' readonly='readOnly'>"; ?></SPAN>
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD STYLE="background-color: rgb(215,220,232); height:21px;">
                                            <P STYLE="margin-left: 4pt;">
                                            <B><SPAN STYLE="font-family: Verdana,Tahoma,Arial,Helvetica,Sans-serif; font-size: 11px;">Von der Kreditkarte abbuchen:</SPAN></B></P>
                                        </TD>
                                        <TD STYLE="text-align: right; background-color: rgb(215,220,232); padding-right: 8pt;">
                                            <B><SPAN class="text_site"><? echo $charged.' EUR'; ?></SPAN></B>
                                        </TD>                                                                              
                                    </TR>
                                    <TR>
                                        <TD class="text_site" STYLE="background-color: rgb(255,255,255); height:21px; padding-left:4pt;">
                                            Vor Ort beim Vermieter bezahlen:
                                        </TD>
                                        <TD class="text_site" STYLE="text-align: right; background-color: rgb(255,255,255); padding-right: 8pt;">
                                            <B>
											<? 
											$balance_euros = $balance.' EUR';
										    echo "<input type=\"text\" value=\"$balance_euros\" name=balance2 style='border-width:0px; font-family: Verdana,Tahoma,Arial,Helvetica,Sans-serif,sans-serif; font-size: 11px; font-weight:bold; text-align: right' size='30' readonly='readOnly'>"; ?></B>
                                        </TD>
                                    </TR>
                                    <TR>
                                        <TD STYLE="background-color: rgb(255,255,255); padding-left: 4pt; height:21px;">
                                            <SPAN class="text_site">Mietpreis insgesamt:</SPAN>
                                        </TD>
                                        <TD STYLE="text-align: right; background-color: rgb(255,255,255); padding-right: 8pt;">
                                            <B><SPAN class="text_site">
											<?
											$preco_total_euros = $preco_total.' EUR';
											echo "<input type=\"text\" value=\"$preco_total_euros\" name=preco_total2 style='border-width:0px; font-family: Verdana,Tahoma,Arial,Helvetica,Sans-serif,sans-serif; font-size: 11px; font-weight:bold; text-align: right' size='30' readonly='readOnly'>"; ?></SPAN></B>
                                        </TD>
                                    </TR>
                                </TABLE>
                                </TD></TR></TABLE>
                                <BR>
                                <TABLE ID="Table80" BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="100%" STYLE="height: 22;">
                                    <TR STYLE="height:24px">
                                        <TD ALIGN="RIGHT" WIDTH="280" STYLE="padding-right: 5pt;">
                                          <P><INPUT TYPE="BUTTON" NAME="FormsButton1" VALUE="Buchen" ID="FormsButton1" onClick="valida_fields()"></P>
                                        </TD>
                                  <TD ALIGN="LEFT" WIDTH="280" STYLE="padding-left: 5pt;">
                                    <P><INPUT TYPE="BUTTON" NAME="FormsButton2" VALUE="Zurück" ID="FormsButton2" onClick="javascript:history.back()"></P>
                                        </TD>
                                  </TR>
                                </TABLE>
                                <P><?      
							    echo "<SCRIPT type='text/javascript' language='javascript'>calcular_fora_horas(".$total_fh_extras_eur.");</SCRIPT>";
								?></P>                                
                            </td>
                            <td width="30">&nbsp;</td>
                        </tr>
                    </TABLE>   
                    
                    <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="780">
                        <TR VALIGN="TOP" ALIGN="LEFT">
                            <TD HEIGHT="50"></TD>
                        </TR>
                        <TR VALIGN="TOP" ALIGN="LEFT">
                            <TD STYLE="background-image: url('../assets/images/f000.jpg'); height: 42; vertical-align:middle" class="table_esq">
                                 <P STYLE="text-align: center; font-size: 12px;">&nbsp;&nbsp; 
                                 <A HREF="../index.php">Home</A>&nbsp;|&nbsp;
                                 <A HREF="../html/newsletter.php">Abonnieren sie unseren newsletter</A>&nbsp;|&nbsp;
                                 <A HREF="../html/custsuport.php">Kundenservice</A>&nbsp;|&nbsp;
                                 <A HREF="../html/questions.php">FAQ&#8217;s</A></P>
                            </TD>
                        </TR>
                        <TR>
                            <TD VALIGN="TOP" STYLE="background-color: rgb(209,36,36);height:34px" class="table_esq">
                                <SPAN STYLE="font-size: 8pt; color: rgb(255,255,255);">
                                Copyright &#169; 2006-2009 Bravacar, Lda - Rent a Car &#153; </SPAN></P>
                            </TD>
                        </TR>
                        <TR>
                            <TD class="table_esq" align="center" STYLE="height:45px; font-family: Tahoma,Verdana,Arial,Helvetica,Sans-serif; font-size: 11px; color: rgb(153,153,153);" >
                                <BR>Partnerseiten: 
                                <A HREF="http://www.baiabrava.pt/de/index.html" TARGET="_blank">Hotel Apartamentos Baía Brava</A>&nbsp;|&nbsp;
                                <A HREF="http://www.terrasdeaventura.com/german/index.html" TARGET="_blank">Terras de Aventura</A>&nbsp;|&nbsp;
                                <A HREF="http://www.albergariafozdosado.com/de/homede.html" TARGET="_blank">Albergaria Foz do Sado</A>&nbsp; |&nbsp;
                                <A HREF="http://www.parquetematicodamadeira.pt/en/default.asp" TARGET="_blank">The Madeira Island Theme Park</A>
                                <BR>
                            </TD>
                        </TR>
                    </TABLE>  
                </FORM>
            </TD>
        </TR>
    </TABLE>
    </DIV>
</BODY>
</HTML>
 