// JavaScript Document
function CambioClass(Fila, Como)
	{
	document.getElementById(Fila).className = Como;
	document.getElementById(Fila).style.cursor='pointer'; 
	}


function imagechange(Elemento, imgName) 
    {
	  document.getElementById(Elemento).style.cursor='pointer';
	  document.getElementById(Elemento).style.background = BtnSelected;
	}



function isEmpty(str) {
	for (var intLoop = 0; intLoop < str.length; intLoop++)
		if (" " != str.charAt(intLoop))
			return false;
	return true;
}
	

function DFocus(TheForm, TheElement)
	{
	document.forms[TheForm][TheElement].focus();	
	}
	

function numbersonly2(e, TheForm, ElObj)
	{
	var unicode=e.charCode? e.charCode : e.keyCode
	
	if(unicode==46 && document.forms[TheForm][ElObj].value.indexOf('.') != -1) return false;
	
	if (unicode!=13){
		if (unicode!=46){
			if (unicode<48||unicode>57) return false
			}
		}
	}


function numbersonly(e)
	{
	var unicode=e.charCode? e.charCode : e.keyCode
	if (unicode!=13)
		{
		if (unicode<48||unicode>57)
		return false
		}
	}
	
	
function DoNothing()
	{
	var xxxx = '';
	}
	
	
function ValidaFormulario(TheForm, Show, ShMsj, Tipo, Cajas, Dishabilita, QueDes)
	{
		if (Dishabilita == 1) document.forms[TheForm][QueDes].disabled = true;
		if (Cajas == 1)
			{
			var CajasCheked = false;
			var NoChekedMsj = 'checkbox';
			for (var intLoop = 0; intLoop<document.forms[TheForm].elements.length; intLoop++)
					{
					if(document.forms[TheForm].elements[intLoop].type == 'checkbox' && null!=document.forms[TheForm].elements[intLoop].getAttribute("requiredbox"))
						{
						if (ShMsj == 1) NoChekedMsj = document.forms[TheForm].elements[intLoop].Msj;
						if (document.forms[TheForm].elements[intLoop].checked) CajasCheked = true;
						}
					}	
			if (!CajasCheked)
				{
				if (ShMsj == 1) alert('Este dato es requerido:\n\n' + NoChekedMsj);
				if (Dishabilita == 1) document.forms[TheForm][QueDes].disabled = false;
				return false;
				}
			}
		
		var Como = 'TextBoxReq';
		var ComoOk = 'TextBox';

		for (var intLoop = 0; intLoop<document.forms[TheForm].elements.length; intLoop++)
			{
			if (null!=document.forms[TheForm].elements[intLoop].getAttribute("required")) 
				{
				if (isEmpty(document.forms[TheForm].elements[intLoop].value))
				   {
				   document.forms[TheForm].elements[intLoop].focus();
				   if (Show == 1) {document.getElementById(document.forms[TheForm].elements[intLoop].name).className=Como;}
				   if (ShMsj == 1) {alert('Este dato es requerido:\n\n' + document.forms[TheForm].elements[intLoop].getAttribute("Msj"));}
				   if (Dishabilita == 1) document.forms[TheForm][QueDes].disabled = false;
				   return false;
				   }
				else
					{
					if (Show == 1) document.getElementById(document.forms[TheForm].elements[intLoop].name).className=ComoOk;	
					}
				}
			
			if (Tipo == 1 && !isEmpty(document.forms[TheForm].elements[intLoop].value))
				{
				if (null!=document.forms[TheForm].elements[intLoop].getAttribute("TipoDato"))
					{
					if(!isTipoDato(document.forms[TheForm].elements[intLoop].getAttribute("TipoDato"), document.forms[TheForm].elements[intLoop].value))
						{
						document.forms[TheForm].elements[intLoop].focus();
						if (Show == 1) {document.getElementById(document.forms[TheForm].elements[intLoop].name).className=Como;}
						if (ShMsj == 1) {alert('Este dato es requerido:\n\n' + document.forms[TheForm].elements[intLoop].getAttribute("Msj"));}
						if (Dishabilita == 1) document.forms[TheForm][QueDes].disabled = false;
						return false;
						}
					else
						{
						if (Show == 1) document.getElementById(document.forms[TheForm].elements[intLoop].name).className=ComoOk;
						}
					}
				}
			
			if(null!=document.forms[TheForm].elements[intLoop].getAttribute("MenEQue"))
				{
				if(eval(document.forms[TheForm].elements[intLoop].value) > eval(document.forms[TheForm][document.forms[TheForm].elements[intLoop].getAttribute("MenEQue")].value))
					{
					document.forms[TheForm].elements[intLoop].focus();
					if (Show == 1) {document.getElementById(document.forms[TheForm].elements[intLoop].name).className=Como;}
					if (ShMsj == 1) {alert('Este dato es requerido:\n\n' + document.forms[TheForm].elements[intLoop].getAttribute("Msj"));}
					if (Dishabilita == 1) document.forms[TheForm][QueDes].disabled = false;
					return false;	
					}
				else
					{
					if (Show == 1) document.getElementById(document.forms[TheForm].elements[intLoop].name).className=ComoOk;	
					}
				}
			
			if(null!=document.forms[TheForm].elements[intLoop].getAttribute("MayEQue"))
				{
				if(eval(document.forms[TheForm].elements[intLoop].value) < eval(document.forms[TheForm][document.forms[TheForm].elements[intLoop].getAttribute("MayEQue")].value))
					{
					document.forms[TheForm].elements[intLoop].focus();
					if (Show == 1) {document.getElementById(document.forms[TheForm].elements[intLoop].name).className=Como;}
					if (ShMsj == 1) {alert('Este dato es requerido:\n\n' + document.forms[TheForm].elements[intLoop].getAttribute("Msj"));}
					if (Dishabilita == 1) document.forms[TheForm][QueDes].disabled = false;
					return false;	
					}
				else
					{
					if (Show == 1) document.getElementById(document.forms[TheForm].elements[intLoop].name).className=ComoOk;	
					}
				}
			
			if(null!=document.forms[TheForm].elements[intLoop].getAttribute("MenQue"))
				{
				if(eval(document.forms[TheForm].elements[intLoop].value) >= eval(document.forms[TheForm][document.forms[TheForm].elements[intLoop].getAttribute("MenQue")].value))
					{
					document.forms[TheForm].elements[intLoop].focus();
					if (Show == 1) {document.getElementById(document.forms[TheForm].elements[intLoop].name).className=Como;}
					if (ShMsj == 1) {alert('Este dato es requerido:\n\n' + document.forms[TheForm].elements[intLoop].getAttribute("Msj"));}
					if (Dishabilita == 1) document.forms[TheForm][QueDes].disabled = false;
					return false;	
					}
				else
					{
					if (Show == 1) document.getElementById(document.forms[TheForm].elements[intLoop].name).className=ComoOk;	
					}
				}
			
			if(null!=document.forms[TheForm].elements[intLoop].getAttribute("MayQue"))
				{
				if(eval(document.forms[TheForm].elements[intLoop].value) <= eval(document.forms[TheForm][document.forms[TheForm].elements[intLoop].getAttribute("MayQue")].value))
					{
					document.forms[TheForm].elements[intLoop].focus();
					if (Show == 1) {document.getElementById(document.forms[TheForm].elements[intLoop].name).className=Como;}
					if (ShMsj == 1) {alert('Este dato es requerido:\n\n' + document.forms[TheForm].elements[intLoop].getAttribute("Msj"));}
					if (Dishabilita == 1) document.forms[TheForm][QueDes].disabled = false;
					return false;	
					}
				else
					{
					if (Show == 1) document.getElementById(document.forms[TheForm].elements[intLoop].name).className=ComoOk;	
					}
				}
			}
		return true;
	}


function DisEnaCampo(TheForm, TheElement, Status)
	{
		if(Status==0) document.forms[TheForm][TheElement].disabled=true;
		else  document.forms[TheForm][TheElement].disabled=false;
	}
	

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}


function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}


function Mid(str, start, len)
{
    if (start < 0 || len < 0) return "";
    var iEnd, iLen = String(str).length;
    if (start + len > iLen)
          iEnd = iLen;
    else
          iEnd = start + len;
    return String(str).substring(start,iEnd);
}

	
function isTipoDato(ElTipo, ElValor)
	{
	if(ElTipo == 'Numerico') return IsNumeric(ElValor, 0);
	
	if(ElTipo == 'Entero') return IsNumeric(ElValor, 1);
	
	if(ElTipo == 'Fecha') return IsFecha(ElValor);
	
	return false;
	}


function IsNumeric(ElValor, Entero)
	{
	if(Entero == 1)
		{
		var ValidChars = '0123456789';	
		}
	else
		{
		var ValidChars = '0123456789.';
		}
		
	ElContador = 0;
	
	for (i = 0; i < ElValor.length; i++) 
		{ 
		if (ValidChars.indexOf(ElValor.charAt(i)) == -1) 
			{
			return false;
			}
		
		if (ElValor.charAt(i) == '.')
			{
			ElContador = ElContador + 1;
			
			if(ElContador > 1) return false;
			}
		}
	
	return true;
	}


function IsFecha(ElValor)
	{
	if(ElValor.length != 10 || ElValor.charAt(4) != '-' || ElValor.charAt(7) != '-' || !IsNumeric(ElValor.substring(0,4), 1) || !IsNumeric(ElValor.substring(5,7), 1) || !IsNumeric(ElValor.substring(8,10), 1) || ElValor.substring(5,7) > 12 || ElValor.substring(5,7) < 1 || ElValor.substring(8,10) > 31 || ElValor.substring(8,10) < 1 || ElValor.substring(0,4) > 2054 || ElValor.substring(0,4) < 1918) return false;
	
	if(ElValor.substring(5,7) == '02')
		{
		if(ElValor.substring(8,10) > DiasFeb(ElValor.substring(0,4))) return false;
		}
	
	if(ElValor.substring(5,7) == '04' || ElValor.substring(5,7) == '06' || ElValor.substring(5,7) == '09' || ElValor.substring(5,7) == '11')
		{
		if(ElValor.substring(8,10) > 30) return false;
		}
		
	//if() return false;
	
	return true;
	}
	
	
function DiasFeb(Ano){
    return (((Ano % 4 == 0) && ( (!(Ano % 100 == 0)) || (Ano % 400 == 0))) ? 29 : 28 );
}


function Ask(Pregunta)
	{
	var x=window.confirm(Pregunta + '?')
	if (x)
		return true;
	else
		return false;
	}

	
function MDRBuscar(TheForm, Show, ShMsj, Tipo, Cajas, Dishabilita, QueDes)
	{
	if(!ValidaFormulario(TheForm, Show, ShMsj, Tipo, Cajas, Dishabilita, QueDes))
		{
		if (Dishabilita == 1) document.forms[TheForm][QueDes].disabled = false;
		return false;
		}
	
	var Como = 'TextBoxCalReq';
	var ComoOk = 'TextBoxCal';
	if (Show == 1) {document.getElementById('Fin').className=ComoOk;}
	if (Show == 1) {document.getElementById('Inicio').className=ComoOk;}
	
	if(!ComparaFechas(document.forms[TheForm].Inicio.value, '>=', document.forms[TheForm].FechaDeHoy.value))
		{
		if (Dishabilita == 1) document.forms[TheForm][QueDes].disabled = false;
		if (Show == 1) {document.getElementById('Inicio').className=Como;}
		document.forms[TheForm].Inicio.focus();
		return false	
		}
	
	if(!ComparaFechas(document.forms[TheForm].Fin.value, '>', document.forms[TheForm].Inicio.value))
		{
		if (Dishabilita == 1) document.forms[TheForm][QueDes].disabled = false;
		if (Show == 1) {document.getElementById('Fin').className=Como;}
		document.forms[TheForm].Fin.focus();
		return false	
		}
		
	return true;
	}

function DateAdd(ItemType, DateToWorkOn, ValueToBeAdded)
	{
		DateToWorkOn = new Date(Left(DateToWorkOn, 4), DateToWorkOn.substring(5,7) - 1, Right(DateToWorkOn, 2));

		switch (ItemType)
		{		
			//date portion         
			case 'd': //add days
				DateToWorkOn.setDate(DateToWorkOn.getDate() + ValueToBeAdded)
				break;
			case 'm': //add months
				DateToWorkOn.setMonth(DateToWorkOn.getMonth() + ValueToBeAdded)
				break;
			case 'y': //add years
				DateToWorkOn.setYear(DateToWorkOn.getFullYear() + ValueToBeAdded)
				break;
			//time portion         
			case 'h': //add days
				DateToWorkOn.setHours(DateToWorkOn.getHours() + ValueToBeAdded)
				break;
			case 'n': //add minutes
				DateToWorkOn.setMinutes(DateToWorkOn.getMinutes() + ValueToBeAdded)
				break;
			case 's': //add seconds
				DateToWorkOn.setSeconds(DateToWorkOn.getSeconds() + ValueToBeAdded)
				break;
		}
		return DateToWorkOn;
	}


function ComparaFechas(str1, Como, str2)
	{
	var dt1   = parseInt(str1.substring(8,10),10); 
	var mon1  = parseInt(str1.substring(5,7),10);
	var yr1   = parseInt(str1.substring(0,4),10); 
	var dt2   = parseInt(str2.substring(8,10),10); 
	var mon2  = parseInt(str2.substring(5,7),10); 
	var yr2   = parseInt(str2.substring(0,4),10); 
	var date1 = new Date(yr1, mon1-1, dt1); 
	var date2 = new Date(yr2, mon2-1, dt2); 
	
	switch(Como)
		{
		case '=':
		  return date1 == date2;
		  break;
		case '<>':
		  return date1 != date2;
		  break;
		case '>':
		  return date1 > date2;
		  break;
		case '<':
		  return date1 < date2;
		  break;
		case '>=':
		  return date1 >= date2;
		  break;
		case '<=':
		  return date1 <= date2;
		  break;
		default:
		  return false;
		}	
	}
	

function MDRNextCal(Target)
	{
	if (null!=document.getElementById(Target).getAttribute("NextCal"))
		{
		NxtDate = DateAdd('d', document.getElementById(Target).value, 7);
		
		ElMes = NxtDate.getMonth() + 1;
		ElDia = NxtDate.getDate();
		
		if(ElMes < 10) ElMes = '0' + ElMes;
		if(ElDia < 10) ElDia = '0' + ElDia;
		
		document.getElementById(document.getElementById(Target).getAttribute("NextCal")).value = NxtDate.getFullYear() + '-' + ElMes + '-' + ElDia;
		
		
		
		document.getElementById(document.getElementById(Target).getAttribute("NextCal")).focus();	
		}
	}

	
function PopUpsetOpacity(Valor, Que) {
 document.getElementById(Que).style.opacity = Valor / 10;
 document.getElementById(Que).style.filter = 'alpha(opacity=' + Valor * 10 + ')';
}


function PopUpfadeInMyPopup(Que) {
 for( var i = 0 ; i <= 100 ; i++ )
   setTimeout('PopUpsetOpacity(' + (i / 10) + ', \'' + Que + '\')' , 8 * i);
}


function PopUpfadeOutMyPopup(Que) {
 for( var i = 0 ; i <= 100 ; i++ ) {
   setTimeout('PopUpsetOpacity(' + (10 - i / 10) + ', \'' + Que + '\')' , 8 * i );
 }

 setTimeout('PopUpcloseMyPopup(\'' + Que + '\')', 800 );
}


function PopUpcloseMyPopup(Que) {
 document.getElementById(Que).style.display = "none"
}


function PopUpfireMyPopup(Que) {
 PopUpsetOpacity(0, Que);
 document.getElementById(Que).style.display = "block";
 PopUpfadeInMyPopup(Que);
}
	
	
function GoTo(Pagina)
	{
	document.location = Pagina;
	}
	
function GoToHab(Inicio, Fin, Hab, Adu, Men, Age, Hot, Sty, Tok)
	{
	var Pagina = 'mdr_hab.php?Inicio=' + Inicio + '&Fin=' + Fin + '&Habitaciones=' + Hab + '&Adultos=' + Adu + '&Menores=' + Men + '&Age=' + Age + '&Hot=' + Hot + '&Sty=' + Sty + '&Token=' + Tok;
	
	document.location = Pagina;
	}

function MDRReservar(Formulario, RoomType, PlanType)
	{
		var TheForm = 'Paypal';
		
		switch (Formulario) { 
			case '1': 
			   TheForm = 'Club'; 
			   break; 
			case '2': 
			   TheForm = 'Hotel'; 
			   break; 
			default: 
			   TheForm = 'Paypal'; 
		} 

		PopUpfireMyPopup(TheForm + 'Form');
		document.forms[TheForm+'Reservar'].elements[TheForm+'Nombre'].focus();
		document.forms[TheForm+'Reservar'].elements['Habitacion'].value = RoomType;
		document.forms[TheForm+'Reservar'].elements['Plan'].value = PlanType;
	}

function ValidaPaypal(TheForm, Show, Dishabilita, QueDes)
	{
		if (Dishabilita == 1) document.forms[TheForm][QueDes].disabled = true;
		
		var Como = 'PaypalTextBoxReq';
		var ComoOk = 'PaypalTextBox';

		for (var intLoop = 0; intLoop<document.forms[TheForm].elements.length; intLoop++)
			{
			if (null!=document.forms[TheForm].elements[intLoop].getAttribute("required")) 
				{
				if (isEmpty(document.forms[TheForm].elements[intLoop].value))
				   {
				   document.forms[TheForm].elements[intLoop].focus();
				   if (Show == 1) {document.getElementById(document.forms[TheForm].elements[intLoop].name).className=Como;}
				   if (Dishabilita == 1) document.forms[TheForm][QueDes].disabled = false;
				   return false;
				   }
				else
					{
					if (Show == 1) document.getElementById(document.forms[TheForm].elements[intLoop].name).className=ComoOk;	
					}
				}
			}
		return true;
	}
	
function ValidaClub(TheForm, Show, Dishabilita, QueDes)
	{
		if (Dishabilita == 1) document.forms[TheForm][QueDes].disabled = true;
		
		var Como = 'ClubTextBoxReq';
		var ComoOk = 'ClubTextBox';

		for (var intLoop = 0; intLoop<document.forms[TheForm].elements.length; intLoop++)
			{
			if (null!=document.forms[TheForm].elements[intLoop].getAttribute("required")) 
				{
				if (isEmpty(document.forms[TheForm].elements[intLoop].value))
				   {
				   document.forms[TheForm].elements[intLoop].focus();
				   if (Show == 1) {document.getElementById(document.forms[TheForm].elements[intLoop].name).className=Como;}
				   if (Dishabilita == 1) document.forms[TheForm][QueDes].disabled = false;
				   return false;
				   }
				else
					{
					if (Show == 1) document.getElementById(document.forms[TheForm].elements[intLoop].name).className=ComoOk;	
					}
				}
			}
		return true;
	}
	
function ValidaHotel(TheForm, Show, Dishabilita, QueDes)
	{
		if (Dishabilita == 1) document.forms[TheForm][QueDes].disabled = true;
		
		var Como = 'HotelTextBoxReq';
		var ComoOk = 'HotelTextBox';

		for (var intLoop = 0; intLoop<document.forms[TheForm].elements.length; intLoop++)
			{
			if (null!=document.forms[TheForm].elements[intLoop].getAttribute("required")) 
				{
				if (isEmpty(document.forms[TheForm].elements[intLoop].value))
				   {
				   document.forms[TheForm].elements[intLoop].focus();
				   if (Show == 1) {document.getElementById(document.forms[TheForm].elements[intLoop].name).className=Como;}
				   if (Dishabilita == 1) document.forms[TheForm][QueDes].disabled = false;
				   return false;
				   }
				else
					{
					if (Show == 1) document.getElementById(document.forms[TheForm].elements[intLoop].name).className=ComoOk;	
					}
				}
			}
		return true;
	}
	
function GrpRescheckRequired(TheForm, Show, Ejecutar)
	{
		var Personas = eval(document.Grid.Adultos.options[document.Grid.Adultos.options.selectedIndex].value) + eval(document.Grid.Menores.options[document.Grid.Menores.options.selectedIndex].value);
		var QueRegreso = false;
		
		if (checkRequired(TheForm, Show, Ejecutar))
			{
				if (Personas == document.Grid.PerSel.value && Personas > 0)
					{
						QueRegreso = true;
					}
				else
					{
						alert('Cantidad incorrecta');
						document.Grid.elements[Ejecutar].disabled = false;
					}
			}
		
		return QueRegreso;
	}
	
function checkRequired(TheForm, Show, Ejecutar)
	{
	var Como = 'TextBoxReq';
	var ComoOk = 'TextBox';
	var Como1 = 'TextAreaReq';
	var ComoOk1 = 'TextArea';
	if (Ejecutar != '') document.forms[TheForm][Ejecutar].disabled = true;
	for (var intLoop = 0; intLoop<document.forms[TheForm].elements.length; intLoop++)
		{
		if (null!=document.forms[TheForm].elements[intLoop].getAttribute("required")) 
			if (isEmpty(document.forms[TheForm].elements[intLoop].value))
			   {
			   document.forms[TheForm].elements[intLoop].focus();
			   if (Show == 1)
			   	{
					if (document.getElementById(document.forms[TheForm].elements[intLoop].name).type == 'text')
						{
							document.getElementById(document.forms[TheForm].elements[intLoop].name).className=Como;
						}
					else
						{
							document.getElementById(document.forms[TheForm].elements[intLoop].name).className=Como1;
						}
				}
			   if (Ejecutar != '') document.forms[TheForm][Ejecutar].disabled = false;
			   return false;
			   }
			else
				{
				if (Show == 1)
					{
						if (document.getElementById(document.forms[TheForm].elements[intLoop].name).type == 'text')
							{
								document.getElementById(document.forms[TheForm].elements[intLoop].name).className=ComoOk;
							}
						else
							{
								document.getElementById(document.forms[TheForm].elements[intLoop].name).className=ComoOk1;
							}
					}
				}
		}

	return true;
	}
		
	
function GrpResAsiento(Autobus, Asiento, Numero)
	{
		var Personas = eval(document.Grid.Adultos.options[document.Grid.Adultos.options.selectedIndex].value) + eval(document.Grid.Menores.options[document.Grid.Menores.options.selectedIndex].value);
		
		if (document.Grid.elements['Aut' + Autobus].value == '' && Personas > document.Grid.PerSel.value && document.Grid.elements['CamDis' + Autobus].value >= 1)
			{
				document.Grid.elements['Aut' + Autobus].value = Asiento;
		        document.Grid.elements['Cam' + Autobus].value = Numero;
				
				document.Grid.elements['CamDis' + Autobus].value = document.Grid.elements['CamDis' + Autobus].value - 1;
								
				document.Grid.PerSel.value = eval(document.Grid.PerSel.value) + 1;
				
				var varComo = 'CellAs'+document.getElementById('CellAs'+Autobus+'_'+Numero).className.substring(6,7)+'s';
				
				document.getElementById('CellAs'+Autobus+'_'+Numero).className = varComo;
			}
		else
			{
				var arrAut = document.Grid.elements['Aut' + Autobus].value.split(',');
				var arrCam = document.Grid.elements['Cam' + Autobus].value.split(',');
				
				var AutIndex = arrAut.indexOf(Asiento)
				
				if (AutIndex >= 0)
					{
						arrAut.splice(AutIndex, 1);
						arrCam.splice(AutIndex, 1);
						
						document.Grid.elements['CamDis' + Autobus].value = eval(document.Grid.elements['CamDis' + Autobus].value) + 1;
						
						document.Grid.PerSel.value = eval(document.Grid.PerSel.value) - 1;
						
						var varComo = 'CellAs' + document.getElementById('CellAs'+Autobus+'_'+Numero).className.substring(6,7);
				
						document.getElementById('CellAs'+Autobus+'_'+Numero).className = varComo;
					}
				else
					{
						if (Personas > document.Grid.PerSel.value && document.Grid.elements['CamDis' + Autobus].value >= 1)
							{
								arrAut.push(Asiento);
								arrCam.push(Numero);
								
								document.Grid.elements['CamDis' + Autobus].value = document.Grid.elements['CamDis' + Autobus].value - 1;
								
								document.Grid.PerSel.value = eval(document.Grid.PerSel.value) + 1;
								
								var varComo = 'CellAs'+document.getElementById('CellAs'+Autobus+'_'+Numero).className.substring(6,7)+'s';
				
				                document.getElementById('CellAs'+Autobus+'_'+Numero).className = varComo;
							}
					}
				
				document.Grid.elements['Aut' + Autobus].value = arrAut.join(',');
		        document.Grid.elements['Cam' + Autobus].value = arrCam.join(',');
			}
		
	}
	
function GrpTotal()
	{
		if (document.Grid.Adultos.options.selectedIndex > 0)
			{
				document.Grid.TarifaA.options.selectedIndex = document.Grid.Adultos.options.selectedIndex - 1;
			}
		else
			{
				document.Grid.TarifaA.options.selectedIndex = 0;
			}
		
		var TotalA = Math.round(document.Grid.Adultos.options[document.Grid.Adultos.options.selectedIndex].value * document.Grid.TarifaA.options[document.Grid.TarifaA.options.selectedIndex].value * 100) / 100;
		var TotalM = Math.round(document.Grid.Menores.options[document.Grid.Menores.options.selectedIndex].value * document.Grid.TarifaM.options[document.Grid.TarifaM.options.selectedIndex].value * 100) / 100;
		var TotalN = Math.round(document.Grid.Ninos.options[document.Grid.Ninos.options.selectedIndex].value * document.Grid.TarifaN.options[document.Grid.TarifaN.options.selectedIndex].value * 100) / 100;
		var TotalT = Math.round((TotalA + TotalM + TotalN) * 100) / 100
		
		document.Grid.AdultoT.value = TotalA;
		document.Grid.MenorT.value = TotalM;
		document.Grid.NinoT.value = TotalN;
		document.Grid.Total.value = TotalT;
		
		document.Grid.PerSel.value = 0;
		
		for (var intLoop = 0; intLoop<document.Grid.elements.length; intLoop++)
			{
				if (document.Grid.elements[intLoop].name.substring(0,6) == 'CamDis')
					{
						document.Grid.elements[intLoop].value = document.Grid.elements['CamDix' + document.Grid.elements[intLoop].name.replace('CamDis', '')].value;
					}
					
				if (document.Grid.elements[intLoop].name.substring(0,3) == 'Aut')
					{
						var arrSelectedAsi = document.Grid.elements['Cam' + document.Grid.elements[intLoop].name.replace('Aut', '')].value.split(',');
						
						for (var arrSelectedAsiIndex = 0; arrSelectedAsiIndex < arrSelectedAsi.length; arrSelectedAsiIndex++)
							{ 
								var varComo = 'CellAs' + document.getElementById('CellAs'+document.Grid.elements[intLoop].name.replace('Aut', '')+'_'+arrSelectedAsi[arrSelectedAsiIndex]).className.substring(6,7);
								
								document.getElementById('CellAs'+document.Grid.elements[intLoop].name.replace('Aut', '')+'_'+arrSelectedAsi[arrSelectedAsiIndex]).className = varComo;
							}
						
						document.Grid.elements[intLoop].value = '';
						document.Grid.elements['Cam' + document.Grid.elements[intLoop].name.replace('Aut', '')].value = '';
					}
			}
			
		switch(document.Grid.TarifaA.options[document.Grid.TarifaA.options.selectedIndex].text.substring(0,3))
			{
				case 'Sgl':
					document.Grid.Ocupacion.value = 1;
					break;
				case 'Dbl':
					document.Grid.Ocupacion.value = 2;
					break;
				case 'Tpl':
					document.Grid.Ocupacion.value = 3;
					break;
				default:
					document.Grid.Ocupacion.value = 4;
			}
	}
