
var banArray = new Array(3); //for banners, increase size as necessary
var counter = 1;

if(document.images) //pre-load all banner images
{
  for(i = 0; i < 3; i++)
  {
    banArray[i] = new Image(468, 60);
    banArray[i].src = "images/In" + (i+1) + ".gif";
  }
}


function changeBanner() //banner changer function
{
  if(counter > 2)
   counter = 0;

  document.banner.src = banArray[counter].src; //sets a new banner

  counter++; //increase the counter for the next banner
}

//calls the changeBanner() function every 3 seconds
//change the timer as necessary (minutes * 60000) or (seconds * 1000)
var timer = window.setInterval("changeBanner()", 3000);


  
function windowOpen(id) {
	var myWindow=window.open('http://www.dirnam.com/cat.php?id='+id,'primeraventana','width=540,height=340,left=120,top=40,scrollbars=yes');
	myWindow.location.href = 'http://www.dirnam.com/cat.php?id='+id;
	if (!myWindow.opener)
		myWindow.opener = self;
}

	
function placeFocus() {
if (document.forms.length > 0) {
var field = document.forms[0];
for (i = 0; i < field.length; i++) {
if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
document.forms[0].elements[i].focus();
break;
         }
      }
   }
}

function over(src,clrOver) {
	if (!src.contains(event.fromElement)) {
		src.style.cursor = 'hand';
		src.bgColor = clrOver;
	}
}

function out(src,clrIn) {
	if (!src.contains(event.toElement)) {
		src.style.cursor = 'default';
		src.bgColor = clrIn;
	}
}

function statusmsg(msg) { window.status = msg ; return true }

function inicio()
{
	document.formulario.comunidad.options[0].selected=true;
	document.formulario.provincia.options[0].selected=true;
	formar(0);
}

function checkdata()
{ 
    
     if ((document.formulario.tipo_establecimiento.value=="") && (document.formulario.empresa.value=="")) {
        alert ("Es necesario que introduzca una actividad a buscar o un nombre de empresa.");
        return false;
     }
	 if ((document.formulario.tipo_establecimiento.value.length<3) && (document.formulario.tipo_establecimiento.value!="")) {
        alert ("Debe concretar un poco más la búsqueda. Inserte más letras en la actividad");
        return false;
     }
     if ((document.formulario.empresa.value.length<3) && (document.formulario.empresa.value!="")) {
        alert ("Debe concretar un poco más la búsqueda. Inserte más letras en el nombre del comercio");
        return false;
     }
	 document.formulario.submit(); 
	 
}
