function NumberFormat(num, numDec, decSep, thousandSep){
    var arg;
    var Dec;
    Dec = Math.pow(10, numDec); 
    if (typeof(num) == 'undefined') return; 
    if (typeof(decSep) == 'undefined') decSep = ',';
    if (typeof(thousandSep) == 'undefined') thousandSep = '.';
    if (thousandSep == '.')
     arg=/./g;
    else
     if (thousandSep == ',') arg=/,/g;
    if (typeof(arg) != 'undefined') num = num.toString().replace(arg,'');
    num = num.toString().replace(/,/g, '.'); 
    if (isNaN(num)) num = "0";
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num * Dec + 0.50000000001);
    cents = num % Dec;
    num = Math.floor(num/Dec).toString(); 
    if (cents < (Dec / 10)) cents = "0" + cents; 
    for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
     num = num.substring(0, num.length - (4 * i + 3)) + thousandSep + num.substring(num.length - (4 * i + 3));
    if (Dec == 1)
     return (((sign)? '': '-') + num);
    else
     return (((sign)? '': '-') + num + decSep + cents);
}  

function SwapOneWay2(){
if (document.getElementById('cajaOneWay2').style.display=='none')
	{
	document.getElementById('cajaOneWay2').style.display='block';
	}
else
	{
	document.getElementById('cajaOneWay2').style.display='none';
	}
}

function ocultacaja(precio){

if (document.getElementById('cajaidayvuelta').style.display=='none')
	{
	document.getElementById('cajaidayvuelta').style.display='block';
	document.getElementById('cajaidayvuelta2').style.display='block';
	document.getElementById('precio').value=parseFloat(precio)*2;
	}
else
	{
	document.getElementById('cajaidayvuelta').style.display='none';
	document.getElementById('cajaidayvuelta2').style.display='none';
	document.getElementById('precio').value=precio;
	}
}

function cambiaprecio(preciosilla, precioviaje){
	var totalsillas= document.getElementById('bebes_llegada').selectedIndex + document.getElementById('ninos_llegada').selectedIndex + document.getElementById('bebes_vuelta').selectedIndex + document.getElementById('ninos_vuelta').selectedIndex;

if (document.getElementById('cajaidayvuelta').style.display != 'none')
	{
	document.getElementById('precio').value=(parseFloat(precioviaje)*2)+(totalsillas * parseFloat(preciosilla));
	}
else
	{
	document.getElementById('precio').value=parseFloat(precioviaje) +(totalsillas * parseFloat(preciosilla));
	}
}

function quote_in(){
var msgerror='';
var msgerror1='';

with(document.forms['f']){
	if ((id_destino.options[id_destino.selectedIndex].value=="")){ 
		msgerror = '* Please, Select one destination\n'; 
	}
	if ((tipo_coche.options[tipo_coche.selectedIndex].value=="")){ 
		msgerror1 = '* Please, Select one type of car\n'; 
	}

	if (msgerror!='' || msgerror1!=''){
		alert('Error:\n\n'+msgerror+'\n'+msgerror1);
		return false;
		}
	else{
		return true;
		}
	}
}

function quote_in2(){
var msgerror='';
var msgerror1='';

with(document.forms['f2']){
	if ((id_destino.options[id_destino.selectedIndex].value=="")){ 
		msgerror = '* Please, Select one destination\n'; 
	}
	
	if (msgerror!='' || msgerror1!=''){
		alert('Error:\n\n'+msgerror+'\n'+msgerror1);
		return false;
		}
	else{
		return true;
		}
	}
}

