//add thickbox to href elements that have a class of .thickbox
$(document).ready(function(){//when the document is loaded
$("a.thickbox").click(function(){
  var t = this.title || this.innerHTML || this.href;
  TB_show(t,this.href);
  this.blur();
  return false;
});
});

var TB_WIDTH = 200;
var TB_HEIGHT = 50;


function TB_show(Mensaje) {
	if (Mensaje != ''){
		try {
			$("body").append("<div id='TB_overlay'></div><div id='TB_window' style='padding-left:20px;padding-top:20px;'></div>");
			$("#TB_overlay").click(TB_remove);	
			$(window).resize(TB_position);
			$("#TB_window").append("<p>" + Mensaje + "</p>" + "<div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton'>Cerrar</a></div>"); 			
			$("#TB_overlay").show();					
			
			$("#TB_closeWindowButton").click(TB_remove);	
			TB_position();	
			$("#TB_load").remove();
			$("#TB_window").slideDown("normal");		  			
		} catch(e) {
			alert( e );
		}
	}
}

//helper functions below

function TB_remove() {
	$("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay').remove();});
	return false;
}

function TB_position() {
	var de = document.documentElement;
	var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
  
  	if (window.innerHeight && window.scrollMaxY) {	
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		yScroll = document.body.offsetHeight;
  	}
	
	$("#TB_window").css({width:TB_WIDTH+"px",height:TB_HEIGHT+"px",
	left: ((w - TB_WIDTH)/2)+"px", top: ((h - TB_HEIGHT)/2)+"px" });
	$("#TB_overlay").css("height",yScroll +"px");
}

