$(document).ready(function() {
	$().ajaxStart(function(){
		$("#loader").fadeIn("fast");
	}).ajaxStop(function() {
		$("#loader").fadeOut("fast");		
	}).ajaxError(function() {
		$("#loader").fadeIn("fast").html("ERROR FATAL...!");
	});	
	$(".publicidad1").animate({ bottom:'35px' }, 1000);//div de anuncia aqui		
	$(".eliminar").live("click",function(){//eliminar div
		$(this).parent().animate({ opacity: 'hide' }, "slow");
	});	
	$(".vermas").mouseenter(function(){
		$("#mapa-sitio").toggle("slow");//efecto aparece de la arriba hacia abajo
	});
	$("#mapa-sitio").mouseleave(function(){
	   $("#mapa-sitio").animate({ opacity: 'hide' }, "slow");//desaparece al no estar en el divs
	});
	$('.modulado3').live("click",function(){
		return false;
	});
	$(".campouser").hover(entraMouse,saleMouse);
	function entraMouse(){
		$(this).children(".eliminar").fadeIn("fast");
	}
	function saleMouse(){
		$(this).children(".eliminar").fadeOut("fast");
	}
});
function fondo(estilo){
var documento = $(document.body);
documento.css("background", "url(/imag_contenido/fondoimg.png) center top no-repeat,  url(/imag_contenido/fondopie.png) bottom center repeat-x, url(/imag_contenido/fondo"+estilo+".png) top center repeat-x");	
}
var classe="menu2";
function desplegar(div,classe){
	$(div).toggleClass(classe);
	$(div).slideToggle("slow");//efecto aparece de la arriba hacia abajo
}
var cargador=0;
function carga(divmodulo,archivo,cargador){
	//$(divmodulo).fadeIn("slow");
	if (cargador==1){
		$(divmodulo).html('<div align="center"><img src="/images/loading1.gif"><br />Cargando</div>');		
	}
	$(divmodulo).load(archivo);	
}
function abrir(archivo,ancho,ancla){
	//si no se especifica un ancho se da un ancho segun al contenido
	centrado=(100-((ancho+30)*100/screen.width))/2;
	$("#g_fondo").css("left",centrado+"%");
	$("#g_fondo").css("width",ancho+"px");
	if(ancla==1){
		$("#g_fondo").css("position","absolute");
	}
	$("#g_fondo").fadeIn("slow");
	$("#g_abrir").html('<div align="center"><img src="/images/loading1.gif"><br />Cargando</div>');	
	$("#g_abrir").load(archivo);
	return false;
}
function mostrar(div){
	$(div).fadeIn("slow");
}
function ocultar(div){
	$(div).fadeOut("slow");
}
var hover="";
function activo(thisis){
	if(hover==''){
		hover=thisis;
		hover.style.backgroundColor='#fff';
		
	}else{
	if(hover!=thisis){//cambiar
		hover.style.backgroundColor='';
		hover=thisis;
		hover.style.backgroundColor='#fff';
	}
	}
}
function mensajes(tipo,texto){
	var x=$("#respuesta");
	switch(tipo){
	case "1":
		x.addClass("menu5");
		texto='<strong>Hey!</strong> '+ texto;
	break;
	case "0":
		x.addClass("menu3");
		texto='<strong>Alert:</strong> '+ texto;
	break;	
	}
	x.html(texto);	
	x.fadeIn("fast",function(){
		setTimeout(function(){x.fadeOut("fast");},4000);						
	});
}
function contar(area,tamano,result) {
		var valuearea=$.trim($(area).attr("value"));
		var tactual=valuearea.length;
		var tamanoes=tamano-tactual;
		$(result).attr("value",tamanoes);
		if (tactual>tamano){
			alert("Listo!");
		}
}
function vinculo (pagina){
	window.location.href=pagina;
}
function alerta (texto){
	window.alert(texto);
}
function abrirtraducido(sis,tipo,pag,des,ant,nomidiomaant){
window.location='/language.php?sis='+sis+'&tipopagina='+tipo+'&pagina='+pag+"&idiomades="+des+"&idiomaant="+ant+"&nomidiomaant="+nomidiomaant;
}
/*--------------- formularios --------------------*/
function cancelar(forms){
	$(forms).resetForm();
}
/*--------------- calendario anterior --------------------*/
function  nuevaventana(pagina,al,an) {
if(al == undefined){
al = 400;// alto del popup a lanzar
}
if(an == undefined){
an = 350;// ancho del popup a lanzar 
}
xtop=(screen.height-al)/2;
xleft=(screen.width-an)/2;
ventana=window.open(pagina ,'pop1','width='+an+',height='+al+',toolbar=No,location=No,scrollbars=Yes,status=No,resizable=No,top='+xtop+',left='+xleft);
ventana.focus();
}
/*--------------- reservas ------------------
-- este esun codigo similar al de facebbok ---
---       no esta en us0 ---------------------*/
function reserva_click() {
	u=location.href;
	t=document.title;
	ventana=window.open('http://sisgaleria/forms.php?var1=es&name=reservar&u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'reservar','scrollbars=Yes,status=0,width=660,height=550');
	ventana.focus();
	return false;
}
/*-------- masregistros --------------------*/
function masregistros(xdiv,dirarchi,numresult,consulta){
	var xseldiv=$(xdiv);
	var divmas=xseldiv.children(".divmas");
	var numpag=divmas.children(".modulado3").attr("page");
	//xseldiv.html('<div align="center"><img src="/images/loading1.gif" alt="cargando.." /></div>');//al finalizar muestra uncargador inadecuado si con formula los registros han llegado a su fin no mostrar este div
	if(numpag){
		$.get(dirarchi,{carga:1,numpag:numpag,numresult:numresult,consulta:consulta},
		function(data){
			xseldiv.before(data);//after despues, before antes	
			xseldiv.remove();
		});
	}
}
/*------- inclusion flash en el sistema inutiliza flobject.js----------------*/
function objetofla (objetofla,wmodef, anchof, altof){
	var fla='';
	fla+='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,47,0" width="'+anchof+'" height="'+altof+'">';
	fla+='<param name="movie" value="'+objetofla+'">';
	fla+='<param name="quality" value="high">';
	if (wmodef==true){
		fla+='<param name="wmode" value="transparent">';
	}
	fla+='<embed src="'+objetofla+'" width="'+anchof+'" height="'+altof+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"';
	if (wmodef==true){
		fla+=' wmode="transparent"';
	}
	fla+='></embed>';
	fla+='</object>';
	document.write(fla);
}
/*--------------- repro musica ----------------------*/
function repromusic(idmusic){
	var fla='<object width="350" height="48"><param name="movie" value="/mp3s/minmp3.swf?grepetir=0&grepro=1&gvolumen=50&arraymp3='+idmusic+'" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="scale" value="noscale" /><param name="bgcolor" value="#0099CC" /><embed src="/mp3s/minmp3.swf?grepetir=0&grepro=1&gvolumen=50&arraymp3='+idmusic+'" quality="high" wmode="transparent" bgcolor="#0099CC" width="350" height="48" scale="noscale" align="middle"></embed></object>';	
	divvide=document.getElementById("music"+idmusic);
	divvide.innerHTML=fla;
}
/*------- inclusion de video youtube en cualquier parte del sistema ----------------*/
function reprovid(idvideo){
	var fla='<object width="470" height="380"><param name="movie" value="http://www.youtube.com/v/'+idvideo+'&hl=es&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/'+idvideo+'&hl=es&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="470" height="380" wmode="transparent"></embed></object>';	
	divvide=document.getElementById(idvideo);
	divvide.innerHTML=fla;
}
function vaciar(divmodulo){
	$(divmodulo).html('');	
}
