function Centrar() {
      iz=(screen.width-document.body.clientWidth) / 2;
      de=(screen.height-document.body.clientHeight) / 2;
      moveTo(iz,de);
} 


function agregar(){
   if ((navigator.appName=="Microsoft Internet Explorer") && 
         (parseInt(navigator.appVersion)>=4)) {
      var url="http://www.vikcars.com/"; 
      var titulo="Vikcars";
      window.external.AddFavorite(url,titulo);
   } else { 
      if(navigator.appName == "Netscape") 
         alert('Presione Crtl+D para agregar este sitio en sus Bookmarks'); 
   }
} 

function borrar() {
		document.forms[0].reset();
}

function ismaxlength(obj){
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}

function link(link_to) {
	window.open("http://"+link_to);
}

function validarEmail(valor) {
 if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
   return (true)
  } else {
   return (false);
  }
}




function submitForm() {
	document.forms['formulari'].submit();
}


function poblacions()
{

	var select= document.formulari.provincias;
	//var select= document.getElementByName('provincias');
	provincia = select.options[select.selectedIndex].value

	document.formulari.poblaciones.length = 1;

	if(select.options[select.selectedIndex].value == 0)
	{
		document.formulari.poblaciones.length = 1;
	}
	else
	{
	//	document.formulari.length = 0;
		
		document.formulari.poblaciones.options[0] = new Option("Todas", '0', true, true);
		eval ("poblaciones = poblacion_" + provincia + ".length")
		for (a = 0; a < poblaciones; ++a)
		{
			eval ("texto = poblacion_" + provincia + "[" + a + "]")
			eval ("value= poblacion_" + provincia + "[" + a + "]")
			document.formulari.poblaciones.options[a + 1] = new Option (texto.split("|")[1], texto.split("|")[0])
		}
		
		//document.formulari.poblaciones.options[a+1] = new Option("", '');
		//document.formulari.poblaciones.options[a+2] = new Option("Todas", '0',true,true);
		
		
		//document.formulari.poblaciones.options[0] = new Option("Todas", '0', true, true);
		//document.forms['formulari'].Provincia.value = select.options[select.selectedIndex].text;
		document.getElementById('proviid').value = select.options[select.selectedIndex].value;
		
	}
}

function seleccionaPob() {

	var select= document.formulari.poblaciones;
	document.getElementById('localid').value = select.options[select.selectedIndex].value;

	
	//document.forms['formulari'].Poblacion.value = select.options[select.selectedIndex].text;


}



function nuevaVentana( aURL )
{
   var wOpen;
   var sOptions;

   aWinName='Detalle residencia';
   
   sOptions = 'status=no,menubar=no,scrollbars=yes,resizable=yes,toolbar=no';
//width=120,height=300
   sOptions = sOptions + ',width=800';
   sOptions = sOptions + ',height=700';
   //sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0';

   wOpen = window.open( '', '', sOptions );
   wOpen.location = aURL;
   wOpen.focus();

   //wOpen.moveTo( 0, 0 );
  // wOpen.resizeTo( screen.availWidth, screen.availHeight );

   return wOpen;
}




function isEmailAddress(theElement ) {
var s = theElement.value;
var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
if (s.length == 0 ) return true;
if (filter.test(s))
return true;
else
theElement.focus();
return false;
}


function cambia1(e) {

e.style.fontWeight = 'bold';
e.style.color = '#87A21F'; 

}
function cambia2(e) {
e.style.fontWeight = 'normal';
e.style.color= '#084B8A'; 

}
