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 IMÁGENES DE LAS ACCIONES
  * EN GESTOR
  */
function actionDeleteImage (action_ID, IDarchivo, actionField, ac, IDidioma, MOD_LINK, win_target) {
		if (confirm("La imagen se eliminará de forma definitiva.\n\n¿Desea continuar?\n ")) {
			carga_url ('ajax.php?action_ID=' + action_ID + '&IDarchivo=' + IDarchivo + '&ac=actionImgDelete&mod=' + MOD_LINK + '&target=' + win_target + '&actionField=' + actionField, win_target); 
			return true
		}
		else {
			return true;
		}
	}
/******************************************************************************************
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";	
}
/******************************************************************************************
FUNCIÓN IMÁGENES MENU
******************************************************************************************/
function marcaMenu(idMenu){
	var totalMenus=7;
	var i=1;
	var numeroActual = 1;
	for(i=1;i<=totalMenus;i++){
		eval('img_off_'+i+'.src = img_off_'+i+'_ant.src');
		eval('img_on_'+i+'.src = img_on_'+i+'_ant.src');
		document.getElementById('punto'+i).src = eval('img_off_'+i+'.src');
		if(idMenu == "punto"+i){
			numeroActual = i;
		}
	}
	document.getElementById(idMenu).src = eval('img_'+idMenu+'.src');
	eval('img_off_'+numeroActual+'.src = img_'+idMenu+'.src');
	eval('img_on_'+numeroActual+'.src = img_'+idMenu+'.src');
}
/******************************************************************************************
FUNCIÓN IMÁGENES GALERIA
******************************************************************************************/
function marcaGaleria(idMenu){
	var totalMenus=10;
	var i;
	var numeroActual = 8;
	for(i=8;i<=totalMenus;i++){
		eval('img_off_'+i+'.src = img_off_'+i+'_ant.src');
		eval('img_on_'+i+'.src = img_on_'+i+'_ant.src');
		document.getElementById('punto'+i).src = eval('img_off_'+i+'.src');
		if(idMenu == "punto"+i){
			numeroActual = i;
		}
	}
	document.getElementById(idMenu).src = eval('img_'+idMenu+'.src');
	eval('img_off_'+numeroActual+'.src = img_'+idMenu+'.src');
	eval('img_on_'+numeroActual+'.src = img_'+idMenu+'.src');
}