// JavaScript Document
function objetoAjax(){
        var xmlhttp=false;
        try {
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
                try {
                   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (E) {
                        xmlhttp = false;
                }
        }

        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest();
        }
        return xmlhttp;
}
//Comentarios Funcion para Expandir y Contraer
function ExpandirComent(Elemento){
	foto=Elemento.src.split('/');
 	foto=foto[foto.length-1];	
	if(foto == "substract.png")
	{
		document.getElementById('ActionExpand').src = "Imagenes/expand.png";
		document.getElementById('Comentarios').innerHTML = ""; 
	}
	if(foto == "expand.png")
	{
		MostrarComentarios();
	}
}
function MostrarComentarios(){
	document.getElementById('ActionExpand').src = "Imagenes/substract.png";
	divResultado = document.getElementById('Comentarios');
	ajax=objetoAjax();
	ajax.open("GET", "include/Comentarios/comentarios.php?Tipo="+document.getElementById('Oculto_Tipo').value+"&Id="+document.getElementById('Oculto_Id').value);
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText;
	   }
	}
	ajax.send(null)
}
//Insertar  comentarios con Ajax...
function InsertComent(){
		var B = document.getElementById('divloading');
		ajax=objetoAjax();
		ajax.open("GET", "include/Comentarios/InsertComent.php?Mensaje="+document.getElementById('txtMsj').value+"&Tipo="+document.getElementById('Oculto_Tipo').value+"&Id="+document.getElementById('Oculto_Id').value);
		ajax.onreadystatechange=function()
		{
			if(ajax.readyState==1){
				B.innerHTML = "<img src='include/Comentarios/loading.gif' alg='Loading...'>";
			}
			if(ajax.readyState==4){
				document.getElementById('NumComent').innerHTML = "Hay "+ajax.responseText+" comentarios...";
				MostrarComentarios();
				document.getElementById('txtMsj').value = "";
				B.innerHTML = "Espere que su comentario sea autorizado por el administrador de la pagina...";
			}
		}
		ajax.send(null)
}
$(document).ready(function(){

$(function() {
        $('#gallery a').lightBox();
    });

//PARA LA REVISTA LA LUZ BAUTISTA
$("ul.thumb li").hover(function() {
	$(this).css({'z-index' : '10'});
	$(this).find('img').addClass("hover").stop()
		.animate({
			marginTop: '-110px', 
			marginLeft: '-90px', 
			top: '50%', 
			left: '50%', 
			width: '130px', 
			height: '170px',
			padding: '20px' 
		}, 300);
	
	} , function() {
	$(this).css({'z-index' : '0'});
	$(this).find('img').removeClass("hover").stop()
		.animate({
			marginTop: '0', 
			marginLeft: '0',
			top: '0', 
			left: '0', 
			width: '100px', 
			height: '130px', 
			padding: '5px'
		}, 300);
	});

//PARA LOS TUMS DE LOS VIDEOS
$("ul.video_thumb li").hover(function() {
	$(this).css({'z-index' : '10'});
	$(this).find('img').addClass("hover").stop()
		.animate({
			marginTop: '-100px', 
			marginLeft: '-105px', 
			top: '50%', 
			left: '50%', 
			width: '170px', 
			height: '120px',
			padding: '20px' 
		}, 300);
	
	} , function() {
	$(this).css({'z-index' : '0'});
	$(this).find('img').removeClass("hover").stop()
		.animate({
			marginTop: '0', 
			marginLeft: '0',
			top: '0', 
			left: '0', 
			width: '150px', 
			height: '100px', 
			padding: '5px'
		}, 300);
	});

//When you click on a link with class of poplight and the href starts with a # 
$('a.poplight[href^=#]').click(function() {
    var popID = $(this).attr('rel'); //Get Popup Name
    var popURL = $(this).attr('href'); //Get Popup href to define size

    //Pull Query & Variables from href URL
    var query= popURL.split('?');
    var dim= query[1].split('&');
    var popWidth = dim[0].split('=')[1]; //Gets the first query string value

    //Fade in the Popup and add close button
    $('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="Imagenes/close_pop.png" class="btn_close" title="Close Window" alt="Close" /></a>');

    //Define margin for center alignment (vertical   horizontal) - we add 80px to the height/width to accomodate for the padding  and border width defined in the css
    var popMargTop = ($('#' + popID).height() + 80) / 2;
    var popMargLeft = ($('#' + popID).width() + 80) / 2;

    //Apply Margin to Popup
    $('#' + popID).css({
        'margin-top' : -popMargTop,
        'margin-left' : -popMargLeft
    });

    //Fade in Background
    $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
    $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies 

    return false;
});

//Close Popups and Fade Layer
$('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
    $('#fade , .popup_block').fadeOut(function() {
        $('#fade, a.close').remove();  //fade them both out
    });
    return false;
});
});


