function BrowserCheck() {
  var b = navigator.appName;
  if (b=="Netscape") this.b = "ns";
  else if (b=="Microsoft Internet Explorer") this.b = "ie";
  else this.b = b;
  this.version = navigator.appVersion;
  this.v = parseInt(this.version);
  this.ns = (this.b=="ns" && this.v>=4);
  this.ns4 = (this.b=="ns" && this.v==4);
  this.ns6 = (this.b=="ns" && this.v==5);
  this.ie = (this.b=="ie" && this.v>=4);
  this.ie4 = (this.version.indexOf('MSIE 4')>0);
  this.ie5 = (this.version.indexOf('MSIE 5')>0);
  this.ie7 = (this.version.indexOf('MSIE 7')>0);
  this.min = (this.ns||this.ie);
}
is = new BrowserCheck();

function carga_url (URL,capa) {
	$(document.getElementById(capa)).html('');
	  $(document.getElementById(capa)).load(URL,function(){
		$(document.getElementById(capa)).slideDown("slow");
	  });
}
function carga_urlOpener (URL,capa,atthened) {
	$(window.opener.document.getElementById(capa)).html('');
	  $(window.opener.document.getElementById(capa)).load(URL,function(){
		$(window.opener.document.getElementById(capa)).slideDown("slow");
		eval(atthened);
	  });
}

function msg_change (capa,htmltext) {
	$(document.getElementById(capa)).html(htmltext);
}

function displayCapa (capa,status) {	
	if (status!=undefined && status!='') {
		document.getElementById(capa).style.display=status;
	} else {
		if (document.getElementById(capa).style.display=="block") {
			document.getElementById(capa).style.display="none";
		} else {
			document.getElementById(capa).style.display="block";
		}
	}
}

function giveCSS (capa,clase) {
	$(document.getElementById(capa)).addClass(clase);
}
function removeCSS (capa,clase) {
	$(document.getElementById(capa)).removeClass(clase);
}

function locateGPS (direccion_tipo,direccion_field,municipio_field,provincia_field, latitud, longitud, formularioNombre) {
	var formulario=document.forms[formularioNombre];
	var tipovia=formulario[direccion_tipo].value;
	var direccion=formulario[direccion_field].value;
	var municipio=formulario[municipio_field].value;
	var provincia=formulario[provincia_field].value;
	var url="popup.php?ac=geolocate&tipovia="+tipovia+"&direccion="+direccion+"&municipio="+municipio+"&provincia="+provincia+"&formulario="+formularioNombre+"&latitud="+latitud+"&longitud="+longitud;
	popUp (url,800,600,'geolocate')	;
}
function locateGPS2Form (latitud, longitud, formularioNombre, lat_value, long_value, formularioNombre2) {
	var formulario=document.forms[formularioNombre2];	
	var latitud_value=formulario[lat_value].value;
	var longitud_value=formulario[long_value].value;
	
	var formulario2=window.opener.document.forms[formularioNombre];	
	formulario2[latitud].value=latitud_value;
	formulario2[longitud].value=longitud_value;
	window.close();
}

function noticiasGestImgs (noticia, accion, id) {
	var url="popup.php?ac=gestImgs&noticia="+noticia+"&acc="+accion+"&rid="+id;
	popup_w = popUp (url,800,600,'gestnoticias');
}
/******************************************************************************************
PREDICTIVO DE CIUDADES
******************************************************************************************/
function locCityPredictive (string, predDiv, cityField, stateField, countryField) {
	if (string.length>3) {
		carga_url ('ajax.php?ac=locCityPredictive&string='+string+'&predDiv='+predDiv+'&cityField='+cityField+'&stateField='+stateField+'&countryField='+countryField,predDiv);
	}
	return true;
}
function locCityAutocomplete (predDiv, cityField, stateField, countryField, city, cityID, state, stateID, country, countryID) {
	var predictiveDiv = document.getElementById (predDiv);
	var ciudad = document.getElementById (cityField);
	var provincia = document.getElementById (stateField);
	var pais = document.getElementById (countryField);
	ciudad.value=city;
	provincia.value=state;
	pais.value=country;
	predictiveDiv.style.display="none";	
}
