
/*
# $LastChangedDate: 2010-03-03 10:20:36 +0200 (Wed, 03 Mar 2010) $
*/
// Create layer
/*
var width = "220px";
var height = "230px";
document.write("<div id=\"ts_layer_webinfo\" style=\"display:none; position: absolute; top: 10;  width:" + width + ";height:" + height + ";background-color:white;border-radius:8px; -moz-border-radius: 8px; -webkit-border-radius: 8px;\" onmouseover=\"thumb.showLayer();\" onmouseout=\"thumb.hide();\">" +
					"<div style=\"position: absolute; left: 10px; top: 10px; width: " + width + "; height: " + height + "; background-color: black; filter: alpha(opacity=30); -moz-opacity: 0.3; opacity: 0.3; border-radius:8px; -moz-border-radius: 8px; -webkit-border-radius: 8px;\"></div>" +
					"<div style=\"position: relative; width: " + width + "; height: " + height + "; background-color: #ffffff;border:black solid 1px; border-radius:8px; -moz-border-radius: 8px; -webkit-border-radius: 8px;\"><iframe id=\"ts_frame_webinfo\" src=\"http://open.thumbshots.org/WebInfo/WebInfo.aspx\" frameBorder=\"0\" width=\"100%\" height=\"100%\" scrolling=\"no\"></iframe></div>" +
				"</div>");
*/

/*
var width = "220px";
var height = "160px";
document.write("<div id=\"ts_layer_webinfo\" style=\"display:none; position: absolute; top: 10;  width:" + width + ";height:" + height + ";background-color:white;border-radius:8px; -moz-border-radius: 8px; -webkit-border-radius: 8px;\" onmouseover=\"thumb.showLayer();\" onmouseout=\"thumb.hide();\">" +
			"<div style=\"position: absolute; left: 10px; top: 10px; width: " + width + "; height: " + height + "; background-color: black; filter: alpha(opacity=30); -moz-opacity: 0.3; opacity: 0.3; border-radius:8px; -moz-border-radius: 8px; -webkit-border-radius: 8px;\"></div>" +
			"<div style=\"position: relative; width: " + width + "; height: " + height + "; background-color: #ffffff;border:black solid 1px; border-radius:8px; -moz-border-radius: 8px; -webkit-border-radius: 8px;\"><iframe id=\"ts_frame_webinfo\" src=\""+ldr_site_url_linkdr_path+"thumbshot.html\" frameBorder=\"0\" width=\"100%\" height=\"100%\" scrolling=\"no\"></iframe></div>" +
		"</div>");
*/

function TsWebInfoIframe()
{
	// Init
	this.url = "";
	this.timer;
	this.layer = document.getElementById("ts_layer_webinfo");
	this.frame = document.getElementById("ts_frame_webinfo");
	this.layerWidth = parseInt(this.layer.style.width);
	this.layerHeight = parseInt(this.layer.style.height);
	
	this.setUrl = function(url)
	{
		this.url = url;
		this.frame.src = "about:blank";
		this.frame.src = "http://open.thumbshots.org/webinfo/webinfo.aspx?url=" + escape(url);
	}				
	
	this.getAbsolutePosition = function(element) 
	{
		var r = { x: element.offsetLeft, y: element.offsetTop };
		if (element.offsetParent) 
		{
			var tmp = this.getAbsolutePosition(element.offsetParent);
			r.x += tmp.x;
			r.y += tmp.y;
		}
		return r;
	}

	
	// Show layer at mouse coordinate
	this.show = function(obj, e) 
	{			
		var x = 0;
		var y = 0;	
		var mouseX = 0;
		var mouseY = 0;
		var offsetX = 10;
		var offsetY = 10;

		if (typeof event != 'undefined' && event.clientX) 
		{
			// IE browsers
			mouseX = event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft :  document.body.scrollLeft);
			mouseY = event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop :  document.body.scrollTop);
		} 
		else if (typeof e != 'undefined' && e.pageX)
		{
			// Other browsers
			mouseX = e.pageX;
			mouseY = e.pageY;						
		}
		
		// Check if window is large enough. Refer to
		// http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
		var clientMaxX = 0;
		var clientMaxY = 0;
		
		if (typeof(window.innerWidth) == 'number')
		{
			clientMaxX = window.innerWidth;
			clientMaxY = window.innerHeight;
		}
		else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
		{
			//IE 6+ in 'standards compliant mode'
			clientMaxX = document.documentElement.clientWidth;
			clientMaxY = document.documentElement.clientHeight;
		}
		else if (document.body && (document.body.clientWidth || document.body.clientHeight))
		{
			clientMaxX = document.body.clientWidth;
			clientMaxY = document.body.clientHeight;
		}
		
		// Swap left/right half depending on available space
		if (mouseX + this.layerWidth > clientMaxX) 
			x = mouseX - this.layerWidth - offsetX;
		else
			x = mouseX;
		
		// Swap upper/lower half depending on available space
		if (mouseY + this.layerHeight > clientMaxY) 
			y = mouseY - this.layerHeight - offsetY;
		else
			y = mouseY;

		// Tell layer to position at those coordinates
		this.layer.style.left = (x + offsetX) + 'px';
		this.layer.style.top  = (y + offsetY) + 'px';
		this.showLayer();
		
	}
				
	// Show layer	
	this.showLayer = function(url)
	{				
		// Cancel any pending hide
		this.cancelHide(); 
			
		this.layer.style.zIndex = 100;
		this.layer.style.display = "block";
	}
				
	// Hide immediately
	this.hideLayer = function() 
	{
		this.layer.style.display = "none";
	}
	
	// Hide with delay
	this.hide = function(delay) 
	{
		if (typeof delay == "undefined")
			delay = 1000;

		var thisObj = this;
		this.timer = setTimeout(function() {thisObj.hideLayer();}, delay);
	}
				
	// Cancel Hide
	this.cancelHide = function() {clearTimeout(this.timer);}
}

function TsWebInfoImg()
{
	// Init
	this.url = "";
	this.timer;
	this.layer = document.getElementById("ts_layer_webinfo");
	this.frame = document.getElementById("ts_frame_webinfo");
	this.layerWidth = parseInt(this.layer.style.width);
	this.layerHeight = parseInt(this.layer.style.height);
	
	this.setUrl = function(url)
	{
		this.url = url;
		this.frame.src = "about:blank";
//		this.frame.src = "http://open.thumbshots.org/webinfo/webinfo.aspx?url=" + escape(url);
//		this.frame.src = "http://linkdr.net/linkdr/thumbshot.html?url=" + escape(url);
		this.frame.src = ldr_site_url_linkdr_path+"thumbshot.html?url=" + escape(url);
	}				
	
	this.getAbsolutePosition = function(element) 
	{
		var r = { x: element.offsetLeft, y: element.offsetTop };
		if (element.offsetParent) 
		{
			var tmp = this.getAbsolutePosition(element.offsetParent);
			r.x += tmp.x;
			r.y += tmp.y;
		}
		return r;
	}

	
	// Show layer at mouse coordinate
	this.show = function(obj, e) 
	{			
		var x = 0;
		var y = 0;	
		var mouseX = 0;
		var mouseY = 0;
		var offsetX = 10;
		var offsetY = 10;

		if (typeof event != 'undefined' && event.clientX) 
		{
			// IE browsers
			mouseX = event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft :  document.body.scrollLeft);
			mouseY = event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop :  document.body.scrollTop);
		} 
		else if (typeof e != 'undefined' && e.pageX)
		{
			// Other browsers
			mouseX = e.pageX;
			mouseY = e.pageY;						
		}
		
		// Check if window is large enough. Refer to
		// http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
		var clientMaxX = 0;
		var clientMaxY = 0;
		
		if (typeof(window.innerWidth) == 'number')
		{
			clientMaxX = window.innerWidth;
			clientMaxY = window.innerHeight;
		}
		else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
		{
			//IE 6+ in 'standards compliant mode'
			clientMaxX = document.documentElement.clientWidth;
			clientMaxY = document.documentElement.clientHeight;
		}
		else if (document.body && (document.body.clientWidth || document.body.clientHeight))
		{
			clientMaxX = document.body.clientWidth;
			clientMaxY = document.body.clientHeight;
		}
		
		// Swap left/right half depending on available space
		if (mouseX + this.layerWidth > clientMaxX) 
			x = mouseX - this.layerWidth - offsetX;
		else
			x = mouseX;
		
		// Swap upper/lower half depending on available space
		if (mouseY + this.layerHeight > clientMaxY) 
			y = mouseY - this.layerHeight - offsetY;
		else
			y = mouseY;

		// Tell layer to position at those coordinates
		this.layer.style.left = (x + offsetX) + 'px';
		this.layer.style.top  = (y + offsetY) + 'px';
		this.showLayer();
		
	}
				
	// Show layer	
	this.showLayer = function(url)
	{				
		// Cancel any pending hide
		this.cancelHide(); 
			
		this.layer.style.zIndex = 100;
		this.layer.style.display = "block";
	}
				
	// Hide immediately
	this.hideLayer = function() 
	{
		this.layer.style.display = "none";
	}
	
	// Hide with delay
	this.hide = function(delay) 
	{
		if (typeof delay == "undefined")
			delay = 1000;

		var thisObj = this;
		this.timer = setTimeout(function() {thisObj.hideLayer();}, delay);
	}
				
	// Cancel Hide
	this.cancelHide = function() {clearTimeout(this.timer);}
}

var thumb = new TsWebInfoImg();
