$(document).ready(function(){ 

	var nom_a = 'Town';
	var nom_b = 'Please Select';
	var air = 'Airport';
	var html_form;
	
	     html_form  =   			'<strong style="padding-right:100px;">'+nom_a+' : </strong>';
         html_form +=   		    '<select name="ciudades_cot_uni" id="ciudades_cot_uni" class="form_book">';
         html_form +=               '<option value="0"> - '+nom_b+' - </option>';
         html_form +=               '<option value="1">Miraflores</option>';
         html_form +=               '<option value="2">San Isidro</option>';
         html_form +=               '<option value="3">Lima Downtown</option>';
         html_form +=               '<option value="4">Barranco</option>';
         html_form +=               '<option value="5">Jesus Maria</option>';
         html_form +=               '<option value="6">La Molina</option>';
         html_form +=               '<option value="7">Lince</option>';
         html_form +=               '<option value="8">Magdalena</option>';
         html_form +=               '<option value="9">San Borja</option>';
         html_form +=               '<option value="10">San Miguel</option>';
         html_form +=               '<option value="11">Surco</option>';
         html_form +=               '</select>';


	$('#precio_cot').html('$0.00 USD');
	$('#images_carros').html('');
	$('#ciudades_cot_2').html(html_form);
	

	var msj   = 'Please select the information below.';
	

	$("#desdea").click(function(){
		
	$('#ciudades_cot_1').html('');
	$('#ciudades_cot_2').html(html_form);
	$('#precio_cot').html('$0.00 USD');
	$('#images_carros').html('');
	
	});
	
	
	$("#desdec").click(function(){
	
	$('#ciudades_cot_2').html('');
	$('#ciudades_cot_2').html('<strong style="padding-right:100px;">'+air+' </strong>');
	$('#ciudades_cot_1').html(html_form);
	$('#precio_cot').html('$0.00 USD');
	$('#images_carros').html('');

		
	});

	$('#ciudades_cot_uni').change(function(){
			

	});
	
	
	$('#get_quote').click(function(){
	
	//parseInt($('#maleta_cot').val()) == 0 ||
	if( parseInt($('#pasajero_cot').val()) == 0 || parseInt($('#ciudades_cot_uni').val()) == 0)
	{
		alert(msj);
	}
	else
	{
		var tipop = '';
	var cantidad = 0;
	var carro = '';
	var resp = new Array();
	var preciocat = 0;
	var city = 0;
	
	pasajeros = parseInt($('#pasajero_cot').val());
	//maletas = parseInt($('#maleta_cot').val())
	city   = $('#ciudades_cot_uni').val();
	
		//&& maletas <= 3
		if(pasajeros <= 3 )
		{
		  tipop = '1@s';
		}
		/*//&& maletas > 3
		else if(pasajeros <= 2 )
		{
		  tipop = '1@v';
		}*/
		else if(pasajeros > 3 && pasajeros <= 6)
		{
			tipop = '1@v';
		}
		else if(pasajeros > 6 && pasajeros <= 12)
		{
			tipop = '2@v';
		}
		else if(pasajeros > 12 && pasajeros <= 14)
		{
			tipop ='3@v';
		}

	
	resp = tipop.split("@");
	
	cantidad = parseInt(resp[0]);
	carro    = resp[1]
	
	switch(carro)
	{
		case 's':
		
		if(city == 10)
		{
			preciocat = 20;
		}
		else if(city == 9 || city == 11)
		{
			preciocat = 26;
		}
		else if(city == 6)
		{
			preciocat = 33;
		}
		else
		{
			preciocat = 22;
		}
		
		break;
		
		case 'v':
		
		if(city == 10)
		{
			preciocat = 25;
		}
		else if(city == 9 || city == 11)
		{
			preciocat = 45;
		}
		else if(city == 6)
		{
			preciocat = 49;
		}
		else
		{
			preciocat = 33;
		}

		break;
	}
		
	preciocat = cantidad*preciocat;
	$('#precio_cot').html('$'+preciocat+'.00 USD');
	$('#price_hidden').val(preciocat);
	
	$('#images_carros').html();
	
	if(carro == 's')
	{
		
		$('#images_carros').html('<img src="images/cot_s.png" style="float:left;">'+'<p class="titulos1" style="float:left; padding-left:10px; margin-top:10px;">x'+cantidad+'</p>');
	}
	else if(carro == 'v')
	{
		//for(i=1; i<=cantidad; i++){
		$('#images_carros').html('<img src="images/cot_v.png" style="float:left;">'+'<p class="titulos1" style="float:left; padding-left:10px; margin-top:10px;">x'+cantidad+'</p>');
		//}
	}
	}
		
	
		
	});	

});


function validar_coti()
{
	var quota = $('#precio_cot').html();
	
	if(quota == '$0.00 USD')
	{
		window.location = "reservations.php?acc=0";
	}
	else
	{
		document.coti.submit();
	}
}

