function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
	var sw = screen.width;
	var sh = screen.height;
	var remote =  window.open(theURL,winName,features);
	remote.moveTo(0,0);
	remote.resizeTo(sw,sh);
}
/*Animaciones comunes*/
var navStartPos = -100;
var navDropInterval = 80;
var navDropSpeed = 800;
var navOverSpeed = 200;
var navOverWith = 150;
var navNormalWith = 200;
var navOverPadding = 10;
var navNormalPadding = 20;
var navTocolor = 'FFFFFF';
var navFromcolor = 'FF0000';
var Animaciones ={
	start: function(){
		//Animaciones.appearNav();
		//AnimacionLogo.toggle();
		//AnimacionBannerLateral.toggle();
	},
	appearNav: function(){
		var timer = 0;
		var sideblocks = $$('#bot_princ li');
		var slidefxs = [];
		sideblocks.each(function(el, i){
			timer += navDropInterval;
			slidefxs[i] = new Fx.Style(el, 'top', {
				duration: navDropSpeed,
				transition: Fx.Transitions.backOut,
				wait: false,
				//create a rollover animation for each link
				onComplete: Animaciones.createOver.pass([el, i])
			});
			slidefxs[i].start.delay(timer, slidefxs[i], 0);
		}, this);
	},
	createOver: function(el, i){
		var first = el.getFirst();
		if (!first || first.getTag() != 'a') return;
		var overfxs = new Fx.Styles(first, {'duration': navOverSpeed, 'wait': false});
		el.addEvent('mouseover', function(){
			overfxs.start({
				'with':navOverWith,
				'padding-left': navOverPadding
			});
		});
		el.addEvent('mouseout', function(){
			overfxs.start({
				'with':navNormalWith,
				'padding-left': navNormalPadding
			});
		});
	}
}
var prepararAnimaciones = {
	start: function(){
		//AnimacionLogo = new Fx.Slide('logo', {duration: 600});
		//AnimacionLogo.hide();
		//AnimacionBannerLateral = new Fx.Slide('BannerLateral', {mode:'horizontal', duration: 600});
		//AnimacionBannerLateral.hide();
		Animaciones.start();
	}
}
/*Para calendario*/
function cambiarFecha(mes, anio){
	document.getElementById('mes').value = mes;
	document.getElementById('anio').value = anio;
	getCalendario();
}
function getCalendario(){
	url2go = 'partes/calendario.php?mes='+document.getElementById('mes').value+'&anio='+document.getElementById('anio').value;
	showHide.start(1, 0).addEvent('onComplete', function() {
	   new Ajax(url2go, {
	        method: 'get',
	        update: 'contenidoCalendario',
	        onComplete: showHide2.start(0, 1)
	      }).request();
	});
}
function cambiarFecha(mes, anio){
	document.getElementById('mes').value = mes;
	document.getElementById('anio').value = anio;
	getCalendario();
}
/*AbrirPop-up*/
function view(theURL, Name, popW, popH, scroll) {
	var winleft = (screen.width - popW) / 2;
	var winUp = (screen.height - popH) / 2;
	winProp = 'width='+popW+',height='+popH+',left='+winleft+',top='+winUp+', resizable=yes,scrollbars='+scroll
	Win = window.open(theURL, Name, winProp)
	if (parseInt(navigator.appVersion) >= 4) { Win.window.focus(); }
}
function abrirPlayer(theURL){
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(theURL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=350,height=30');");
	//wo = window.open(theURL,'af','width=350,height=30');
	//setTimeout("if(wo)wo.focus()",200);
}
function enviarForm(url2go, formName, divLoading){
	var formulario = eval("document."+formName);
	var variabledeForm = "";
	for(x=0; x<formulario.elements.length; x++){
		variabledeForm += ((variabledeForm)?"&":"")+formulario.elements[x].name+"="+formulario.elements[x].value;
	}
	document.getElementById('Loading').style.display = 'block';
	var AnimacionLoading = new Fx.Style(divLoading, 'opacity', {duration: 600}).addEvent('onComplete', 
	function(){
	   new Ajax(url2go, {
				postBody: variabledeForm,
				update: divLoading
				}).request();
	});
	AnimacionLoading.set(0);
	AnimacionLoading.start(0, 1);
	return false;
}
function cerrarLogin(divLoading, HTML){
	var divUpdate = eval("document.getElementById('"+divLoading+"')");
	var AnimacionLoading = new Fx.Style(divLoading, 'opacity', {duration: 600}).addEvent('onComplete',
	function(){
		divUpdate.innerHTML = HTML;
	});
	AnimacionLoading.start(1, 0);
}
/*decodificar Urls*/
function decodificarUrl(utftext) {
	var string = "";
	var i = 0;
	var c = c1 = c2 = 0;
	while ( i < utftext.length ) {
		c = utftext.charCodeAt(i);
		if (c < 128) {
			string += String.fromCharCode(c);
			i++;
		}else if((c > 191) && (c < 224)) {
			c2 = utftext.charCodeAt(i+1);
			string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
			i += 2;
		}else {
			c2 = utftext.charCodeAt(i+1);
			c3 = utftext.charCodeAt(i+2);
			string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
			i += 3;
		}
	}
	return string;
}