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";
		}
	}
}

/* End Efecto Links */


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();
}
/**
  * FUNCIONES PARA
  * GESTIÓN DE NOTICIAS
  * EN GESTOR
  */
function noticiasGestImgs (noticia, accion, id, mod, filter, target, lang) {
	var url="popup.php?ac=gestImgs&noticia="+noticia+"&acc="+accion+"&rid="+id;
	if (mod != "" && mod != null) {
		url += "&mod="+mod;
	}
	if (filter != "" && filter != null) {
		url += "&filter="+filter;
	}
	if (target != "" && target != null) {
		url += "&target="+target;
	}
	if (lang != "" && lang != null) {
		url += "&lang="+lang;
	}
	popup_w = popUp (url,800,600,'gestnoticias');
}
function noticiasGestDownloads (noticia, accion, id, mod, filter, target, lang) {
	var url="popup.php?ac=gestDownloads&noticia="+noticia+"&acc="+accion+"&rid="+id;
	if (mod != "" && mod != null) {
		url += "&mod="+mod;
	}
	if (filter != "" && filter != null) {
		url += "&filter="+filter;
	}
	if (target != "" && target != null) {
		url += "&target="+target;
	}
	if (lang != "" && lang != null) {
		url += "&lang="+lang;
	}
	popup_w = popUp (url,800,600,'gestnoticias');
}
function noticiasGestLinks (noticia, accion, id, mod, filter, target, lang) {
	var url="popup.php?ac=gestLinks&noticia="+noticia+"&acc="+accion+"&rid="+id;
	if (mod != "" && mod != null) {
		url += "&mod="+mod;
	}
	if (filter != "" && filter != null) {
		url += "&filter="+filter;
	}
	if (target != "" && target != null) {
		url += "&target="+target;
	}
	if (lang != "" && lang != null) {
		url += "&lang="+lang;
	}
	popup_w = popUp (url,800,600,'gestnoticias');
}
/**
  * FUNCIONES PARA
  * GESTIÓN DE ILUSTRADORES
  * EN GESTOR
  */
function ilustradoresGestIlustraciones (il_ID, accion, mod, target) {
	var url="popup.php?ac=gestIlustraciones&ilustracion="+il_ID+"&acc="+accion;
	if (mod != "" && mod != null) {
		url += "&mod="+mod;
	}
	if (target != "" && target != null) {
		url += "&target="+target;
	}
	popup_w = popUp (url,800,600,'gestilustraciones');
}
function ilustradoresGestNoticias (noticia_ID, accion, mod, target) {
	var url="popup.php?ac=gestNoticias&noticia="+noticia_ID+"&acc="+accion;
	if (mod != "" && mod != null) {
		url += "&mod="+mod;
	}
	if (target != "" && target != null) {
		url += "&target="+target;
	}
	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";	
}
