


 function enviaReserva(idioma) {	
        computePayment(getCheckedValue(document.forms[0].Payment));
	if (validaReserva(idioma)) { 
                if (getCheckedValue(document.forms[0].Payment) != 'Transfer') {document.forms[0].target='tpv';openCyberpac(); } 
                document.getElementById('buttons').style.visibility="hidden";
                document.getElementById('loadingImg').style.visibility="visible";
		document.forms[0].submit();
	} 
}


function validaReserva(idioma) {
//de momento no se tiene en cuenta el idioma
var formulari = document.forms[0];

  if (formulari.Contact_Name.value == "")
  { alert(vfcontactn[idioma]); formulari.Contact_Name.focus(); return false; }
  if (formulari.Address.value == "")
  { alert(vfaddress[idioma]); formulari.Address.focus(); return false; }
  if (formulari.City.value == "")
  { alert(vfcity[idioma]); formulari.City.focus(); return false; }
  if (formulari.Region.value == "")
  { alert(vfregion[idioma]); formulari.Region.focus(); return false; }
  if (formulari.ZipCode.value == "")
  { alert(vfzipcode[idioma]); formulari.ZipCode.focus(); return false; }
  if (formulari.Country.value == "")
  { alert(vfcountry[idioma]); formulari.Country.focus(); return false; }
  if (formulari.Contact_Email.value.indexOf('@', 0) == -1 ||
      formulari.Contact_Email.value.indexOf('.', 0) == -1)
  { alert(vfemail[idioma]); formulari.Contact_Email.focus(); return false; }
  if (formulari.Contact_Phone.value == "")
  { alert(vfphone[idioma]); formulari.Contact_Phone.focus(); return false; }


  if (getValueSelected(formulari.Trip)== "")
  { alert(vftrip[idioma]); formulari.Trip.focus(); return false; }


  qpers = getValueSelected(document.forms[0].Num_Persons);
  if (qpers == '') { 	
  	 alert(vfnumpers[idioma]); formulari.Num_Persons.focus(); return false; 
  }
  if (qpers == '2') {
 	 if (formulari.Name_2.value == "")
  	{ alert(vfperson2[idioma]); formulari.Name_2.focus(); return false; }
  }
  if (qpers== '3') {
 	 if (formulari.Name_2.value == "")
  	{ alert(vfperson2[idioma]); formulari.Name_2.focus(); return false; }
 	 if (formulari.Name_3.value == "")
  	{ alert(vfperson3[idioma]); formulari.Name_3.focus(); return false; }
  }
  if (qpers== '4') {
 	 if (formulari.Name_2.value == "")
  	{ alert(vfperson2[idioma]); formulari.Name_2.focus(); return false; }
 	 if (formulari.Name_3.value == "")
  	{ alert(vfperson3[idioma]); formulari.Name_3.focus(); return false; }
 	 if (formulari.Name_4.value == "")
  	{ alert(vfperson4[idioma]); formulari.Name_4.focus(); return false; }
  }



  if (getCheckedValue(document.forms[0].Payment).length==0) 
  { alert(vfpayment[idioma]);  return false; }
  
 if (document.forms[0].numOrder.value.length==0) { document.forms[0].numOrder.value=numOrder();}

  return true;
}


function computePrice() {

var wtrip=getValueSelected(document.forms[0].Trip);
if (wtrip.length==0) {wtrip='_'}
var npers=getValueSelected(document.forms[0].Num_Persons);
if (npers=='--') {npers=0}

var trips = new Array();
trips['_'] = '0#0';
trips['Flamenco_Seville'] = '330#40';
trips['Flamenco_Barcelona'] = '350#65';
trips['Flamenco_Granada'] = '899#140';
trips['Bollywood_Barcelona'] = '350#65';
trips['Salsa_Barcelona'] = '340#65';
trips['Salsa_Berlin'] = '299#60';
trips['Salsa_Havana'] = '535#125';
trips['Tango_Barcelona'] = '355#65';
trips['Tango_Berlin'] = '399#85';
trips['Bellydance_Marrakech'] = '330#40';
trips['Bellydance_Morocco'] = '699#85';

vcodeTrip = wtrip.split('_');
codeTrip = vcodeTrip[0]+'_'+vcodeTrip[1];

prices = trips[codeTrip].split('#');
totalPrice = prices[0]*npers;

var wsupl = getValueSelected(document.forms[0].Single_Rooms);
if (wsupl=='--') {wsupl=0}

if (wsupl > 0) {
totalPrice = totalPrice + (prices[1]*wsupl);
}

document.forms[0].Total.value=totalPrice.toFixed(2);
document.getElementById('qtotal').innerHTML=totalPrice.toFixed(2);
computePayment(getCheckedValue(document.forms[0].Payment));
}


function computePayment(payopt) {
eltotal=Number(document.forms[0].Total.value);
switch(payopt)
{
case 'OnlineTotal':
  document.getElementById('qtotal').innerHTML=eltotal.toFixed(2);
  document.forms[0].ImportPayment.value=eltotal.toFixed(2);
  document.getElementById('qpending').innerHTML='0.00';
  break;    
case 'OnlineDeposit':
  document.getElementById('qtotal').innerHTML=eltotal.toFixed(2);
  document.forms[0].ImportPayment.value=(eltotal*0.3).toFixed(2);
  document.getElementById('qpending').innerHTML=(eltotal - (eltotal*0.3)).toFixed(2);
  break;
default:
  document.getElementById('qtotal').innerHTML=eltotal.toFixed(2);
  document.forms[0].ImportPayment.value='0.00';
  document.getElementById('qpending').innerHTML=eltotal.toFixed(2);
}
}


function checkRooms(idioma) {
p=getValueSelected(document.forms[0].Num_Persons);
numsingle=getValueSelected(document.forms[0].Single_Rooms);
if (numsingle=='' || p=='') { 
	document.forms[0].Double_Rooms.value='--';
	} else {
	if (numsingle > p ) {numsingle=p;document.forms[0].Single_Rooms.value=numsingle;}
	calcula=(p-numsingle)/2; 
	      switch (isInteger(calcula))
  			{
    		     case true:
       			     document.forms[0].Double_Rooms.value=calcula;
       			     break;
       		     case false:
			     alert(vfrooms[idioma]);
      			     document.forms[0].Single_Rooms[0].selected=-1;
			     document.forms[0].Double_Rooms.value='--';
      			}
	}
}

function resetRooms() {
document.forms[0].Single_Rooms[0].selected=-1;
document.forms[0].Double_Rooms.value='--';
}


function displaySection ( objHtml )
{
 if ( objHtml.style.display == "none" )
 {
  objHtml.style.display = "block";

 } 
 else
 {
  objHtml.style.display = "none";
 } 
}


function getCheckedValue(radioObj) {
if(!radioObj)
return "";
var radioLength = radioObj.length;
if(radioLength == undefined)
if(radioObj.checked)
return radioObj.value;
else
return "";
for(var i = 0; i < radioLength; i++) {
if(radioObj[i].checked) {
return radioObj[i].value;
}
}
return "";
}



function getValueSelected(obj){
var x = obj.selectedIndex;
return obj.options[x].value;
}

function isInteger(myNum) {
         // get the modulus: if it's 0, then it's an integer
         var myMod = myNum % 1;

         if (myMod == 0) {
                 return true;
         } else {
                 return false;
         }
}


function numOrder() {
	var mydate=new Date();
	var day=mydate.getDay();
	var year=mydate.getFullYear();
	var month=mydate.getMonth()+1;
	if (month<10) 
		month="0"+month;
	var daym=mydate.getDate();
	if (daym<10)
		daym="0"+daym;
    var hora=mydate.getHours();
	if (hora<10)
		hora="0"+hora;
    var minut=mydate.getMinutes();
	if (minut<10)
		minut="0"+minut;
   var segon=mydate.getSeconds();
	if (segon<10)
		segon="0"+segon;

return ( year.toString().substr(2,2) + month + daym + hora + minut + segon  );
}

function openCyberpac() {
vent=window.open('','tpv','width=725,height=600,scrollbars=no,resizable=yes,status=yes,menubar=no,location=no');
}


function infoVisa()
{
window.open("https://sis-t.sermepa.es:25443/sis/html/verifiedByVisa1.html","Info","width=500,height=500");	
}

function infoMastercard()
{
window.open("http://www.mastercard.com/mcbiz/corporate/index.jsp?template=/securecode&content=popup","Info","width=550,height=500");	
}

