function popup(name, url, width, height, args) {
		var newWin = new Object();

		newWin.args = args;
		newWin.url = url;
		newWin.name = name;
		newWin.width = width;
		newWin.height = height;

		if (document.layers) {// browser is NN
			newWin.left = window.screenX + ((window.outerWidth - newWin.width) / 2);
			newWin.top = window.screenY + ((window.outerHeight - newWin.height) / 2);
			var attr = 'screenX=' + newWin.left + ',screenY=' + newWin.top + ',resizable=yes,width=' + newWin.width + ',height=' + newWin.height + ',' + newWin.args;
		}
		else {// browser is MSIE
			newWin.left = (screen.width - newWin.width) / 2;
			newWin.top = (screen.height - newWin.height) / 2;
			var attr = 'left=' + newWin.left + ',top=' + newWin.top + ',scrollbars=1,' + ',width=' + newWin.width + ',height=' + newWin.height + ',' + newWin.args;
		}

		newWin.win=window.open(newWin.url, newWin.name, attr);
		newWin.win.opener=self;
		newWin.win.focus();
	}
	
	
function getmydate(obj){
	return document.all[obj].value;
	}
	
	
	
function UpdatePrices(){
//TotalField
//CUSTOHIDXX
//STOCKDD
//RoomsIDHID
	_Rooms = document.all['RoomsIDHID'];
	_s_ids = _Rooms.value;
	_ids = _s_ids.split(',');
	var newtotal = 0;
	var i;
	for(i=0;i<_ids.length;i++){
		Preco = eval(document.all['STOCKDD'+_ids[i]].value);
		newtotal = newtotal + eval(Preco);
	}
	TOTAL = document.all['TotalField'];
	TOTAL.value = newtotal;
}
	
//--LB--2008/04/21--
function UpdatePrices2(RoomsID, HotelID){

	_Rooms = document.getElementById('RoomsIDHID');
	_s_ids = _Rooms.value;
	_ids = _s_ids.split(',');

	var newtotal = 0;
	var i;
	for(i=0;i<_ids.length;i++){
	 try
	 {		
		Preco = document.all['STOCKDD_'+HotelID+'_'+_ids[i]].value;
		PrecoItems = Preco.split(',');
		PrecoFinal = eval(PrecoItems[0]);
		newtotal = newtotal + eval(PrecoFinal);
	 }
	 catch (e)
	 {}

	}		
	TOTAL = document.all['TotalField'];
	TOTAL.value = newtotal;
    //QuartoID
    NQUARTOVal = document.all['STOCKDD_'+HotelID+'_'+RoomsID].value;
    NQUARTO = document.all['QuartoID'+RoomsID];
    document.all['QuartoID'+RoomsID].value=NQUARTOVal;
    NQUARTO.Value = NQUARTOVal;

}

function EnableCheckBox(idCheck){ 
/*    
   var box = document.all['SERVICESTOCKDD_'+idCheck];
   var i, blen;
   try{
      blen = box.length;
   } catch{ 
      blen=0;
   }
   if (undefined === blen) { 
      blen = 1; 
      try{
        box.disabled = false;
      }catch(err){ alert('err:'+err.description); }
   } else {   
     for (i=0; i<blen; i++){
       try{
        box[i].disabled = false;
       }catch(err){ alert('err:'+err.description); }
     }
   }
   

/*      
   try
   {
      while( document.all[box+i].disabled ) {
         document.all[box+i].disabled = false;    
         i++;
      }          
   } catch(err) {
      //Handle errors here
   }     
*/   
}

/* --Cris--2009/07/16--Update:--LB--2009/07/20-- */
function UpdatePricesRoomChecked(RoomsID, Ciclo, PrecoQuarto, Lotacao, TotalPessoa){

    EnableCheckBox(Ciclo);   

	// coloca os dados por quarto 
    OBJ = document.all['TotalQuarto'+Ciclo];
    OBJ.value = eval(PrecoQuarto);
    //-- Guardar Quarto (ID) seleccionado (por Quarto)
    OBJ = document.all['QuartoID'+Ciclo];
    OBJ.value = eval(RoomsID);
    //-- Guardar Lotação (Qtd) seleccionado (por Quarto)
    OBJ = document.all['Lotacao'+Ciclo];
    OBJ.value = eval(Lotacao);    
    
    var lottotal = 0;
	var i;
    
    // calcula total da lotacao
	for(i=0;i<TotalPessoa;i++){
	     try
	     {		    	      			 
    	    OBJ = document.all['Lotacao'+i];   
    	    Val = OBJ.value;
    	    if (Val=="") { Val = 0 }  	
            lottotal = lottotal + eval(Val)   
	     }
	     catch (e)
	     {}	     
	}
	OBJ = document.all['TotalLotacao'];
    OBJ.value = lottotal;	 
    
    UpdateReservaPrecoTotal(TotalPessoa); 
}

/* --LB--2009/07/20-- */
function UpdatePricesServiceCheckedBox(ServiceID, Ciclo, PrecoService, TotalPessoa, FieldName){        
    var cbox = document.all[FieldName.name];
    var sbox;
    var i;
    var serviceItems = "";
    /* Limpar Total Serviço */
    OBJ = document.all['TotalServico'+Ciclo];
    OBJ.value = 0;
   
    /* Verificar serviços e actualizar total */
    for (i=0; i<cbox.length; i++){
        if (cbox[i].checked==true) {            
            sbox = document.all['ServiceCostID'+cbox[i].value+'_'+Ciclo];
            OBJ.value = eval(OBJ.value) + eval(sbox.value);                 
            serviceItems += cbox[i].value + ",";
        }
    }
  
    OBJ = document.all['ServiceID'+Ciclo];
    OBJ.value = serviceItems;            
    UpdateReservaPrecoTotal(TotalPessoa);
}

function UpdateReservaPrecoTotal(TotalPessoa){

    var newtotal = 0;
    var PrecoQ=0, PrecoS=0;
	var j;

    // Calculo Preço Total
	for(j=0;j<TotalPessoa;j++)
	{
	    PrecoQ = document.all['TotalQuarto'+j].value;
        if (PrecoQ=="") { PrecoQ=0; }  
   
	    PrecoS = document.all['TotalServico'+j].value;
        if (PrecoS=="") { PrecoS=0; }  
	    
	    newtotal = newtotal + eval(PrecoQ) + eval(PrecoS);
	}	
	TotalReserva = document.all['TotalReserva'];
	TotalReserva.value = newtotal;	
}

function UpdateOpNewReserva(){
//RoomsIDHID
//TOTALHID

//QID
//HOTELField
//ROOMField
//LOTACAOField
//STOCKField
//QTRDD

	TOTAL = document.all['TOTALHID'];
	TOTAL.value = '';
	
	_Rooms = document.all['RoomsIDHID'];
	_s_ids = _Rooms.value;
	_ids = _s_ids.split(',');

	var newtotal = '';
	var i;
	for(i=0;i<_ids.length;i++){
		Nqts = eval(document.all['QTRDD'+_ids[i]].value)
		if(eval(Nqts)>0)
		{
			STOCK = _ids[i]+ '|' + Nqts + ',';
			newtotal = newtotal + STOCK;
		}
	}	
	TOTAL.value = newtotal;
}

function Validatah2o()
{
    sdti = document.all['FrontOffice_FAST_OUTTER_SEARCH_H2o1:SearchDateInField'].value; 
    sdtf = document.all['FrontOffice_FAST_OUTTER_SEARCH_H2o1:SearchDateOutField'].value;
    
    adti = sdti.split("-");
    adtf = sdti.split("-");

    dti = new Date(adti[2],adti[1]-1,adti[0], 0,0,0);
    dtf = new Date(adtf[2],adtf[1]-1,adtf[0], 0,0,0);

    d = new Date();
    p_Number = new Number(1);
    diff = dti-d;
    if (diff < 0 )
    {
         document.all['FrontOffice_FAST_OUTTER_SEARCH_H2o1:SearchDateInField'].value = d.getDate() + "-" + d.getMonth()+1 + "-" + d.getFullYear();	
	 d.setDate(d.getDate()+p_Number);
         document.all['FrontOffice_FAST_OUTTER_SEARCH_H2o1:SearchDateOutField'].value = d.getDate() + "-" + d.getMonth()+1 + "-" + d.getFullYear();
    } 
     if (diff > 0 )
    {  
	dti.setDate(dti.getDate()+p_Number);
        document.all['FrontOffice_FAST_OUTTER_SEARCH_H2o1:SearchDateOutField'].value = dti.getDate() + "-" + dti.getMonth()+1 + "-" + dti.getFullYear();
    }
   
    dti = new Date(adti[2],adti[1]-1,adti[0], 0,0,0);
    dtf = new Date(adtf[2],adtf[1]-1,adtf[0], 0,0,0);
    diff = dtf-dti;
    if (diff < 0 )
    {
	dti.setDate(dti.getDate()+p_Number);
        document.all['FrontOffice_FAST_OUTTER_SEARCH_H2o1:SearchDateOutField'].value = dti.getDate() + "-" + dti.getMonth()+1 + "-" + dti.getFullYear();
    }     
     
}

