// JavaScript Document
<!--
addLoadListener(init);

function init()
{
  document.forms[0].onsubmit = validateFields;
  return true;
}

function validateFields()
{
  var elements = document.forms["form1"].elements;
  var emailPattern = /^[\w\.\-]+@([\w\-]+\.)+[a-zA-Z]+$/;
  var fouten=0;

  for (var i = 0; i < elements.length; i++)
  {
    if (/(^| )checkRequired( |$)/.test(elements[i].className) && elements[i].value == "")
    {
	elements[i].className = "checkRequired error";
	fouten++;
    }

    if (/(^| )checkEmail( |$)/.test(elements[i].className) && !emailPattern.test(elements[i].value))
    {
	elements[i].className = "checkRequired checkEmail error";
	fouten++;
    }
  }
if (fouten>0) {
	return false;
	}
  return true;
}

function addLoadListener(fn)
{
  if (typeof window.addEventListener != 'undefined')
  {
    window.addEventListener('load', fn, false);
  }
  else if (typeof document.addEventListener != 'undefined')
  {
    document.addEventListener('load', fn, false);
  }
  else if (typeof window.attachEvent != 'undefined')
  {
    window.attachEvent('onload', fn);
  }
  else
  {
    var oldfn = window.onload;
    if (typeof window.onload != 'function')
    {
      window.onload = fn;
    }
    else
    {
      window.onload = function()
      {
        oldfn();
        fn();
      };
    }
  }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function obreFoto(ruta)
{
   i1 = new Image;
   i1.src = ruta;
   html = '<html><head><title>Villas Costa Brava</title></head>';
   html += '<body leftmargin=0 marginwidth=0 topmargin=0 marginheight=0>';
   html += '<center><a href="javascript:self.close()"><img src="../graphics/fotos/pic/'+ruta+'" border=0 name="Foto" ';
   html += 'onLoad="window.resizeTo(document.Foto.width+10,document.Foto.height+35);window.moveTo((window.screen.width+10-document.Foto.width)/2,(window.screen.height-document.Foto.height+35)/2);self.focus();" alt="Close Window" galleryimg="no">';
   html += '</a></center></body></html>';
   popupImage = window.open('','_blank','scrollbars=0,resizable=0');
   popupImage.document.open();
   popupImage.document.write(html);
   popupImage.document.close();
}

//-->