// JavaScript Document

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

$(document).ready(function (){
	var status= gup( 's' );
	if(status=='')
		status=1;
	  $('#menu_b').load("menu.html");
	  $('#redes_sociales').load("redes_sociales.html");
	    $('#eventos').load("eventos.php");
		$('#banner_p').load("banner.php?status="+status);
		$('#notas_c').load("notas.php");
		$('#clima').load("clima.html");
	  });



 function cargarContenido(url){
	$('#content_center_1').load(url); 
	 }	  
 
  $(function() {
    
    var images = $("#logo img");
    var title = $("title").text() || document.title;
    
    images.draggable({
      helper: function() {
        return $("<div>").attr("id", "helper").html("<span>Gracias por Compartirnos</span>").appendTo("body");
      },
      cursor: "pointer",
      cursorAt: { left: -10, top: 20 },
      zIndex: 99999,
      start: function() {
        $("<div>").attr("id", "overlay").css("opacity", 0.5).appendTo("body");
        $("#tip").remove();
        $(this).unbind("mouseenter");
		var a=$("body").width()/2;
		var b=$("#targets").width()/2;
		$("#targets").css("top",90);
        $("#targets").css("left", (a-b)).slideDown();
		$("#targets").appendTo("body");
      },
      stop: function() {
        $("#targets").slideUp();
        $(".share", "#targets").remove();
        $("#overlay").remove();
        $(this).bind("mouseenter", createTip);
      }
    });
    
    $("#targets li").droppable({
      tolerance: "pointer",    
      over: function() {
        $(".share", "#targets").remove();
        $("<span>").addClass("share").text("Compartir en " + $(this).attr("id")).addClass("active").appendTo($(this)).fadeIn();
      },	  
      drop: function() {
        var id = $(this).attr("id"),
          url = window.location.href;
          base = $(this).find("a").attr("href");

        if (id.indexOf("twitter") != -1) {
			window.open(base + "/home?status=" + title + ": " + url, '_blank');
        } else if (id.indexOf("delicious") != -1) {
			window.open(base + "/save?url=" + url + "&title=" + title, '_blank');
        } else if (id.indexOf("facebook") != -1) {
			window.open(base + "/sharer.php?u=" + url + "&t=" + title, '_blank');          
        }
      }		  
    });
  
    var createTip = function(e) {
      //create tool tip if it doesn't exist
      ($("#tip").length === 0) ? $("<div>").html("<span>Arrastra el Logo para Compartir la página<\/span><span class='arrow'><\/span>").attr("id", "tip").css({ left:-300, top: -500 }).appendTo("body").fadeIn(500) : null;
    };
    
    images.bind("mouseenter", createTip);
    
    images.mousemove(function(e) {
    
      //move tooltip
      $("#tip").css({ left:e.pageX + 30, top:e.pageY - 16 });
    });
  
    images.mouseleave(function() {
    
      //remove tooltip
      $("#tip").remove();
    });
  });

 function detalles(id){
		  $(document).scrollTop(100);
		 $('#pelicula').animate({ opacity: 'show' }, 'slow'); 
		 $('#contenedor').load("containner_small.php?id="+id);
 		 $('#contenedor').css('top','-1300px');
		 $('#contenedor').show();
	 
	 }
	 
 function ocultar_detalles(){
		 $('#contenedor').hide();
		 $('#pelicula').animate({ opacity: 'hide' }, 'slow'); 
	 
	 }
	 
	  function vermas(file){
		  $(document).scrollTop(100);
		 $('#movie').animate({ opacity: 'show' }, 'slow'); 
		 $('#popwindow').load("containner_large.php?file="+file);
 		 $('#popwindow').css('top','-1300px');
		 $('#popwindow').show();
	 
	 }

 function vermas2(file,parameter){
		  $(document).scrollTop(100);
		 $('#movie').animate({ opacity: 'show' }, 'slow'); 
		 $('#popwindow2').load("containner_large2.php?file="+file+"&parameter="+parameter);
 		 $('#popwindow2').css('top','-1300px');
		 $('#popwindow2').show();
	 
	 }

 

	 
 function ocultar_vermas(){
		 $('#movie').hide();
		 $('#popwindow').animate({ opacity: 'hide' }, 'slow'); 
		  $('#popwindow2').animate({ opacity: 'hide' }, 'slow'); 
	 
	 }
