var t;
var q = 5;
var x = 10;
var y = 10;
var z = 200;
var z_increment = 30;
function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function makebox() {
  var depto = document.form1.SelectDepto.options[document.form1.SelectDepto.options.selectedIndex].value;
  var v_depto = "V_" + depto;
  var arraydepto = eval(depto);
  var v_arraydepto = eval(v_depto);
  document.form1.SelectLocal.options.length=0;
  for (i=0; i < arraydepto.length; i++) {
  	document.form1.SelectLocal.options[i] = new Option(arraydepto[i],v_arraydepto[i]);
  } 
}

function makebox2() {
  var depto = document.form2.SelectDepto2.options[document.form2.SelectDepto2.options.selectedIndex].value;
  var v_depto = "V_" + depto;
  var arraydepto = eval(depto);
  var v_arraydepto = eval(v_depto);
  document.form2.SelectLocal2.options.length=0;
  for (i=0; i < arraydepto.length; i++) {
  	document.form2.SelectLocal2.options[i] = new Option(arraydepto[i],v_arraydepto[i]);
  } 
}

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 $(x){return document.getElementById(x);}

function transicion(curva,ms,callback){
	this.ant=0.01;
	this.done_=false;
	var _this=this;
	this.start=new Date().getTime();
	this.init=function(){
		setTimeout(function(){
				if(!_this.next()){
					callback(1);
					_this.done_=true;
					window.globalIntervalo=0;
					return;
				}
				callback(_this.next());
				_this.init();
			},13);
	}
	this.next=function(){
		var now=new Date().getTime();
		if((now-this.start)>ms)
			return false;
		return this.ant=curva((now-this.start+.001)/ms,this.ant);
	}
}

function desacelerado(p,ant){
	var maxValue=1, minValue=.001, totalP=1, k=.25;
	var delta = maxValue - minValue; 
    var stepp = minValue+(Math.pow(((1 / totalP) * p), k) * delta); 
    return stepp; 
}

function fx(obj,efectos,ms,cola,curva){
	if(!window.globalIntervalo)
		window.globalIntervalo=1;
	else {
		if(cola)
			return setTimeout(function(){fx(obj,efectos,ms,cola,curva)},30);
		else
			return;
	}	
	var t=new transicion(
	curva,ms,function(p){
		for (var i=0;efectos[i];i++){
			if(efectos[i].fin<efectos[i].inicio){
				var delta=efectos[i].inicio-efectos[i].fin;
    			obj.style[efectos[i].propCSS]=(efectos[i].inicio-(p*delta))+efectos[i].u;
				if(efectos[i].propCSS=='opacity'){
					obj.style.zoom=1;
					obj.style.MozOpacity = (efectos[i].inicio-(p*delta));
    				obj.style.KhtmlOpacity = (efectos[i].inicio-(p*delta));
					obj.style.filter='alpha(opacity='+100*(efectos[i].inicio-(p*delta))+')';
				}
			}
			else{
				var delta=efectos[i].fin-efectos[i].inicio;
				obj.style[efectos[i].propCSS]=(efectos[i].inicio+(p*delta))+efectos[i].u;
				if(efectos[i].propCSS=='opacity'){
					obj.style.zoom=1;
					obj.style.MozOpacity = (efectos[i].inicio+(p*delta));
    				obj.style.KhtmlOpacity = (efectos[i].inicio+(p*delta));
					obj.style.filter='alpha(opacity='+100*(efectos[i].inicio+(p*delta))+')';
				}
			}
		}
		
	});
	t.init();
	t=null;
}

function senoidal(p,ant){ 
    return (1 - Math.cos(p * Math.PI)) / 2; 
} 

function delay(milisegundos) {
	for(i=0;i<=milisegundos;i++) {
		setTimeout('return 0',1);
	}
}


function arrancar() {
    var t;
	IniciarSecuencia();
	fx($('content'),[
	{'inicio':10,'fin':552,'u':'px','propCSS':'width'},
	{'inicio':0,'fin':-290,'u':'px','propCSS':'marginLeft'}, 
	],1000,true,senoidal);
/*	fx($('content'),[
	{'inicio':10,'fin':1500,'u':'px','propCSS':'height'}]
	,1000,true,senoidal); */
	setTimeout("bajar();",1000); 
}

function bajar() {
	fx($('content'),[
	{'inicio':200,'fin':510,'u':'px','propCSS':'marginTop'}]
	,1200,true,senoidal);
	setTimeout("disponermapa();",1000); 
}

function disponermapa() {
	fx($('mapa'),[
	{'inicio':-210,'fin':-190,'u':'px','propCSS':'marginTop'},
	{'inicio':-190,'fin':-200,'u':'px','propCSS':'marginTop'}]
	,1200,true,senoidal);
}

function unwrapmapa() {
	e=document.getElementById("mapa");
	if (e.style.marginTop == '-200px') {
		fx($('mapa'),[
		{'inicio':-200,'fin':112,'u':'px','propCSS':'marginTop'}]
		,1200,true,senoidal);
	}
}

function wrapmapa() {
	fx($('mapa'),[
	{'inicio':112,'fin':-200,'u':'px','propCSS':'marginTop'}]
	,1200,true,senoidal);
}

/* Javascript para secuencia de cambio de fotos; */

var SecuenciaEjecutandose = false
var SecuenciaID = null
var imagen = 0
var duracion = 10000

if (CompruebaVersion()) {	
	imagenes = new CreaArray(8)
	//carga las imagenes: especificar aqui las URLs de las imagenes o ruta fisica y nombre
	imagenes[1].src = "css/foto1.jpg"
	imagenes[2].src = "css/foto2.jpg"
	imagenes[3].src = "css/foto3.jpg"
	imagenes[4].src = "css/foto4.jpg"
	imagenes[5].src = "css/foto5.jpg"
	imagenes[6].src = "css/foto6.jpg"
	imagenes[7].src = "css/foto7.jpg"
	imagenes[8].src = "css/foto8.jpg"
}

function CompruebaVersion() {
	if (navigator.appVersion.charAt(0) >= 3  && document.images) return true
	else return false
}

function CreaArray(n) {
	this.length = n
	for (var i = 1; i<=n; i++) {
		this[i] = new Image()
	}
	return this
}

function DetenerSecuencia (){
   	if(SecuenciaEjecutandose)
   		clearTimeout(SecuenciaID)
   	SecuenciaEjecutandose = false
        imagen = 0
}

function MostrarSecuencia () {
	if (CompruebaVersion()) {
            document.images["secuencia"].src = imagenes[imagen].src
            imagen++
            if ( imagen == 9 )
                imagen = 1
	}
  	SecuenciaID = setTimeout("MostrarSecuencia()", duracion)
   	SecuenciaEjecutandose = true
}

function IniciarSecuencia () {
 	DetenerSecuencia()
        imagen = 1
 	MostrarSecuencia()
}

window.onload = IniciarSecuencia;
if (document.captureEvents) {			//N4 requiere invocar la funcion captureEvents
	document.captureEvents(Event.LOAD)
}
