// JavaScript Document
$(document).ready(function(){
    //Aqui tu codigo
	$(".logo").click(function(){
		window.location = "/";
		return false;
	});
	
	$("#sexyNotas").click(function(){
		//cambiar CSS de #sexyNotas y #masTVideos
		$(this).css('background','url(../img/sprites_header.png) 0px -238px no-repeat');
		$("#masTVideos").css('background','url(../img/sprites_header.png) -250px -238px no-repeat');	
		$("#tvContainer").empty();
		//llamar funcion ajax para poner videos sexy notas
		$.ajax({
			   url: "sexyNotas.php",
			   cache: false,
			   success: function(html){
				   $("#tvContainer").append(html);
				}
		});
	});
	$("#masTVideos").click(function(){
		//cambiar CSS de #sexyNotas y #masTVideos
		$(this).css('background','url(../img/sprites_header.png) -250px -287px no-repeat');
		$("#sexyNotas").css('background','url(../img/sprites_header.png) 0px -287px no-repeat');	

		$("#tvContainer").empty();
		//llamar funcion ajax para poner videos sexy notas
		$.ajax({
			   url: "masTV.php",
			   cache: false,
			   success: function(html){
				   $("#tvContainer").append(html);
				}
		});

	});	
	
	$("#twitter").click(function(){
		window.open("http://twitter.com/#!/masmedio", "_blank");
	});
	$("#facebook").click(function(){
		window.open("http://www.facebook.com/MasMedio", "_blank");
	});
	$("#youtube").click(function(){
		window.open("http://www.youtube.com/user/masMedioMexico", "_blank");
	});
	
	/*$(".tvThumb0").click(function(){
alert("click 0 ");
		$("#masTv").empty();
		//llamar funcion ajax para poner videos sexy notas
		$.ajax({
			   type: "GET",
			   url: "sexyNotas.php",
			   data: "video=0",
			   cache: false,
			   success: function(html){
				   $("#masTv").append(html);
				}
		});
	});
	
	$(".tvThumb1").click(function(){
		alert("click 1 ");
		$("#masTv").empty();
		//llamar funcion ajax para poner videos sexy notas
		$.ajax({
			   type: "GET",
			   url: "sexyNotas.php",			   
			   data: "video=1",
			   cache: false,
			   success: function(html){
				   $("#masTv").append(html);
				}
		});
	});
	$(".tvThumb2").click(function(){
		alert("click 2 ");
		$("#masTv").empty();
		//llamar funcion ajax para poner videos sexy notas
		$.ajax({
			   type: "GET",
			   url: "sexyNotas.php",
			   data: "video=2",
			   cache: false,
			   success: function(html){
				   $("#masTv").append(html);
				}
		});
	});*/
	
	//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="/img/close_pop.png" border="0" 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;
	});
	
	//When you click on a link with class of poplight and the href starts with a # 
	$('a.poplight_tuFoto[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="/img/close_pop.png" border="0" 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;
	});
	
	$('#laEncuestaSubmit').click(function() {
		var op = $("input[name='opRepuesta']:checked").val();
		var eid = $("#encuestaID").val();
		$.ajax({
			   type: "GET",
			   url: "votaEncuesta.php",
			   data: "op="+op+"&eid="+eid,
			   cache: false,
			   success: function(html){
				   $("#encuesta").fadeOut('slow', function(){
						$("#encuesta").empty().append(html).fadeIn('slow');
					});
					//$("#encuesta").;
			   }
		});
	});
		
	$("#colRodrigoHeader").click(function(){
		window.location = "/columnas_masmedio/";
		return false;
	});
	
	$("#enResumenHeader").click(function(){
		window.location = "/resumen/";
		return false;
	});
	
	//masTwitteado
	/*
	$(function() {  
	$("#mtContenido").jCarouselLite({  
			vertical: true,  
			visible: 3,  
			auto:500,  
			speed:1000  
		});  
	});  */

});

