// JavaScript Document
function desvanece(){
	if(parseInt(this.actual) <= parseInt(this.max_opacity)){
		if(this.element.style.visibility == "hidden"){
			this.element.style.visibility = "visible";			
		}
	this.element.style.opacity = "."+this.actual+"";
	this.element.style.filter = "Alpha(Opacity="+this.ie+")";
	this.actual+=0.5;
	this.ie+=5;
	}
}

function obj_desv(DivID){
	this.element = document.getElementById(DivID);
	var width = this.element.scrollWidth;
	this.element.style.visibility = "hidden";
	this.element.style.width = "300px";
	this.max_opacity = 9;
	this.tope = 9;
	this.min_opacity = 1;
	this.actual = 0;
	this.ie = 0;
	this.desvanece = desvanece;
	this.status = false;
}

function start_desva(DivId, timer){
	var a = new obj_desv(DivId);
	setInterval(function() {a.desvanece()}, timer);
}

var milisec=0
var seconds=0
var i = 0;
                        
function display(){
	if (milisec>=9){
	milisec=0
	seconds+=1
	}else{
	milisec+=1
	}
	setTimeout("display()",100);
                                            
	if(seconds == (5*i)){
	if(i == 3){
	 seconds = 0;
	i = 0;
	}else{
	var botonAc = "boton"+(i+1);
	cambioNoticia(botonAc, i)
	i = i+1;
	}
	}
}
						
function cambioNoticia(noticia, nroNoticia){
    document.getElementById("boton1").className='segui';
    document.getElementById("boton2").className='segui';
    document.getElementById("boton3").className='segui';
                            document.getElementById(noticia).className = 'visto';
                            var contenidos = [document.getElementById('noticia_1').innerHTML,document.getElementById('noticia_2').innerHTML,document.getElementById('noticia_3').innerHTML];
                            document.getElementById("contenido_noticia").innerHTML = contenidos[nroNoticia];
							start_desva('contenido_noticia',40);
                                if(nroNoticia == 0){
                                    seconds = 0;
                                    i = 0;
                                }else if(nroNoticia == 1){
                                    seconds = 2;
                                    i = 1;
                                }else if(nroNoticia == 2){
                                    seconds = 4;
                                    i = 2;
                                }
}
function favoritos() {
	if (window.sidebar&&window.sidebar.addPanel){
	window.sidebar.addPanel("Instituto Pastoral Andina","http://ipandina.org/","");
	}else{
	window.external.AddFavorite("http://ipandina.org/","Instituto Pastoral Andina")
	}
}

function cambiarVideo(DivID, nroVideo, actual){
	for(var i = 1; i <=2; i++){
		document.getElementById("video"+i).className = "segui";
		document.getElementById(DivID+i).style.display = "none";
		
	}
	document.getElementById("video"+actual).className = "visto";

	document.getElementById(DivID+actual).style.display = "";
}
function CheckMessage(form){
	var errores = [form.autor, form.asunto];
	var status = true;
	for(var i = 0; i < errores.length; i++){
		if(errores[i].value == ""){
			errores[i].className  = "inputTextRed";
			status = false;
		}else{
			errores[i].className  = "inputTextBlank";
		}
	}
	
	if(!status){
		alert("Dejaste campos en blanco, corrige tus errores por favor");
	}
	return status;
	
}

function changeLang(lang,option,itm,id){
	if(option && itm && id){
	window.location = "?lang="+lang+"&option="+option+"&item="+itm+"&id="+id+"";
	}else{
	window.location = "?lang="+lang+"";	
	}
}
function getIframe(url){
	content.location = url;
}
