// JavaScript Document
function hidden(ocultar){
var obj=document.getElementById(ocultar);
obj.style.display="none";
}
function show(ocultar){
var obj=document.getElementById(ocultar);
obj.style.display="block";
}
function mostrar(){
	$(".showHide").show();
}
function ocultar(){
    $(".showHide").hide();
}
//-----------------------------------------------------------------------------------------------------toolTip
this.tooltip = function(id){	
	/* CONFIG */		
	var clase= "a."+ id;
		xOffset = 30;
		yOffset = 10;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$(clase).hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='"+id+"'>"+ this.t +"</p>");
		$("#"+id)
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#"+id).remove();
    });	
	$(clase).mousemove(function(e){
		$("#"+id)
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};
//-----------------------------------------------------------------------------------------------------imagePreview
this.imagePreview = function(id){	
	/* CONFIG */
	var	clase1= "a."+ id;
		xOffset1 = -10;
		yOffset1 = 10;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$(clase1).hover(function(ep){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='"+id+"'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");								 
		$("#"+id)
			.css("top",(ep.pageY - xOffset1) + "px")
			.css("left",(ep.pageX + yOffset1) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#"+id).remove();
    });	
	$(clase1).mousemove(function(ep){
		$("#"+id)
			.css("top",(ep.pageY - xOffset1) + "px")
			.css("left",(ep.pageX + yOffset1) + "px");
	});			
};
//---------------------------------------------------------------------------------------------------direcctorioSujetos
this.sitemapstyler = function(directorio){
	var sitemap = document.getElementById(directorio)
	if(sitemap){
		
		this.listItem = function(li){
			if(li.getElementsByTagName("ul").length > 0){
				var ul = li.getElementsByTagName("ul")[0];
				ul.style.display = "block";
				var span = document.createElement("div");
				span.className = "expanded";
				span.onclick = function(){
					ul.style.display = (ul.style.display == "none") ? "block" : "none";
					this.className = (ul.style.display == "none") ? "collapsed" : "expanded";
				};
				li.appendChild(span);
			};
		};
		
		var items = sitemap.getElementsByTagName("li");
		for(var i=0;i<items.length;i++){
			listItem(items[i]);
		};
		
	};	
};
//---------------------------------------------------------------------------------------------------llamado
$(document).ready(function(){
	tooltip("tooltip");
	tooltip("tooltip1");
	tooltip("tooltip2");
	tooltip("tooltip3");
	imagePreview("preview");
	imagePreview("previewCroquis");
	sitemapstyler("sitemap");
	sitemapstyler("direcctorioSujetos");
});
