// FICHERO DE FUNCIONES
// si pongo aqui el codigo de noright click se ejecutar en TODAS las paginas  No rightclick script v.2.5

// FUNCION PARA VALIDAR FORMULARIO
// dentro de la funcion respetar las mayus/minus de los nombres de los campos
// si no introducimos nombre da error y me pone el cursor en casilla nombre

function check_form()
{

  if (document.forms[0].elements["nombre"].value=="") 
  {
    window.alert("Introduzca su NOMBRE, por favor");
    document.forms[0].elements["nombre"].focus();
    return false;
  }

  if (document.forms[0].elements["ciudad"].value=="") 
  {
    window.alert("Introduzca su CIUDAD, por favor");
    document.forms[0].elements["ciudad"].focus();
    return false;
  }
  
  if (document.forms[0].elements["provincia"].value=="") 
  {
    window.alert("Introduzca su PROVINCIA, por favor");
    document.forms[0].elements["provincia"].focus();
    return false;
  }
  
  if ((document.forms[0].elements["telefono"].value=="") && (document.forms[0].elements["email"].value=="")) 
  {
    window.alert("Indíquenos al menos una forma de contactar con usted, bien mediante e-mail o bien por teléfono.");
    document.forms[0].elements["email"].focus();
    return false;
  }
  
  if (document.forms[0].elements["fecha de entrada"].value=="") 
  {
    window.alert("Introduzca su FECHA DE ENTRADA, por favor");
    document.forms[0].elements["fecha de entrada"].focus();
    return false;
  }
  
  
    if (document.forms[0].elements["fecha de salida"].value=="") 
  {
    window.alert("Introduzca su FECHA DE SALIDA, por favor");
    document.forms[0].elements["fecha de salida"].focus();
    return false;
  }
  
  document.forms[0].submit();
  return true;
}
//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////

function newwinn(fich)
{
  var numargs = arguments.length;
  if (numargs < 2) {
     var a= Math.random() *100000;
     window.open(fich,"w" + Math.round(a),"width=620,height=470,scrollbars=no,resizable=no,top=10,left=10");
  } else {
       var w= arguments[1];
       var h= arguments[2];
       window.open(fich,"w" + Math.round(a),"width=" + w + ",height=" + h + ",resizable=no,top=10,left=10");      
    }
}

function newwins(fich)
{ 
      var a= Math.random() *100000;
      var w= arguments[1];
       var h= arguments[2];
       window.open(fich,"w" + Math.round(a),"width=" + w + ",height=" + h + ",scrollbars=yes,resizable=no,top=10,left=10");      
 }


// hacer grandes imagenes POPIMAGE
//
//
PositionX = 40;
PositionY = 40;

defaultHeight = 460;
defaultWidth  = 600;

var AutoClose = true;

if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=550,height=450,left='+PositionX+',top='+PositionY;

function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Cargando imagen ...</title><style>body  {margin:0px;} </style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["ELMS"].width;');writeln('window.innerHeight=document.images["ELMS"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()"  onClick="self.close()" >')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()" onClick="self.close()" >');
writeln('<img name="ELMS" src='+imageURL+' style="display:black"></body></html>');
close();		
}}
//////////////////////////////////////////////////////////// -->
function abreFoto(ruta)
{
i1 = new Image;
i1.src = ruta;
html = ' <html><head><title>Hotel Monteverde - Cangas de Onís</title></head>';
html += '<body leftmargin=0 marginwidth=0 topmargin=0 marginheight=0>';
html += '<center><img src="'+ruta+'" border=0 name="Foto" ';
html += 'onLoad="window.resizeTo(document.Foto.width,document.Foto.height + 50)">';
html += '<br><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><a href="#" onClick="window.close();"><B>CERRAR</a></font>'
html += '</center></body></html>';
popupImage = window.open('','_blank','scrollbars=0,resizable=0');
popupImage.document.open();
popupImage.document.write(html);
popupImage.document.close();
}

function cambia(td,color)
{
	td.bgColor=color;
}
/////////////////////////fecha y hora monteverde/////////////////////////////////// -->

var DDMMYY =0
var MMDDYY =1

function getFecha(mode)
{
   var now = new Date();
   var dayNr = ((now.getDate()<10) ? "0" : "")+ now.getDate();
   if (mode==DDMMYY)
      var MonthDayYear =(dayNr+"/"+(now.getMonth()+1)+"/"+now.getYear());
   else
      var MonthDayYear =((now.getMonth()+1)+"/"+dayNr+"/"+now.getYear());

   return MonthDayYear;
}

function getHora()
{
   var now = new Date();

   var ampm = (now.getHours() >= 12) ? " P.M." : " A.M."
   var hours = now.getHours();
       hours = ((hours > 12) ? hours - 12 : hours);

   var minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes();
   var TimeValue =(" " + hours + minutes+ " "  + ampm);

   return TimeValue;
}