// JavaScript Document
$(document).ready(function() {
		theRotator();			
	$("#email3").fancybox({
				'width'				: 440,
				'height'			: 390,
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'		
	});		
	
	//Menu desplegable
	$("#menu ul li ul").hide();	
	$("#menu ul li span.current").addClass("open").next("ul").show();
	$("#menu ul li span").click(function(){	
		$(this).next("ul").slideToggle("slow").parent("li").siblings("li").find("ul:visible").slideUp("slow");
		$("#menu ul li").find("span").removeClass("open");
		$(this).addClass("open");
	});
			$("#flash").hide();	

});


$(function() {
	$(".love").click(function() 
	{
	var id = $(this).attr("id");
	var dataString = 'id='+ id ;
	var parent = $(this);
	$(this).fadeOut(300);
	$.ajax({
		type: "POST",
		url: "votov.php",
		data: dataString,
		cache: false,
		success: function(html)
		{
			parent.html(html);
			parent.fadeIn(300);
		} 
	});
	return false;
 	});
});

function agregar2(url, title){
	//IE
	if((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)){
		window.external.AddFavorite(url,title);
	}else{//Firefox
		if(navigator.appName == "Netscape")
		window.sidebar.addPanel(title, url,"");
	}
}


function theRotator() {
	$('div#rotatorder ul li').css({opacity: 0.0});
	$('div#rotatorder ul li:first').css({opacity: 1.0});
	setInterval('rotate()',10000);
}
function rotate() {	
	var current = ($('div#rotatorder ul li.show')?  $('div#rotatorder ul li.show') : $('div#rotatorer ul li:first'));
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotatorder ul li:first') :current.next()) : $('div#rotatorder ul li:first'));	
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
};

$(function(){
	$(".button").click(function() {
		var nid=$(this).attr("id");
		var id =nid.substr(1,10);
		var fmen = $(this).attr("name");
		if (id==0){
			document.getElementById('parent_id').value='0';
			$("#flash").fadeOut(1000);			
		}else{					
			$("#parent_id").attr("value", id);
			$("#flash").show();
			$(".freply").html('Responder a: '+fmen);		
		}
		$("#comment_body").focus();
	});
});


/*************************************/

$(function() {

$(".submit").click(function() {
var parent_id = $("#parent_id").val();
var noticia = $("#noticia").val();
	var comment_body = $("#comment_body").val();
    var dataString = 'noticia='+ noticia + '&parent_id=' + parent_id + '&comment_body=' + comment_body;
	
	if(comment_body=='')
     {
	$("#flash2").addClass("error");
	$("#flash2").removeClass("user_ok");	
	$("#flash2").html("Por Favor aņade algun comentario");
	$("#flash2").show();
	
     }
	else
	{
	$("#flash2").removeClass("error");	
	$("#flash2").addClass("user_ok");
	$("#flash2").show();
	$("#flash2").fadeIn(400).html('Aņadiendo Comentario...');
	$.ajax({
		type: "POST",
		url: "con_imtv/post_com_vd.php",
	    data: dataString,
		cache: false,
		success: function(html){
	    document.getElementById('comment_body').value='';
		document.getElementById('parent_id').value='0';
		$("#flash2").show();
		$("#flash2").html(html);
		$("#flash").fadeOut(2000);
		$("#flash2").fadeOut(5000);
		}
 	});
	}
return false;
	});

});