/*
 * Thumbshot Preview script for Thumbshots.RU
 * Powered by jQuery (http://www.jquery.com)
 * 
 * Author: Sonorth Corp. - {@link http://www.sonorth.com/}
 * License: Creative Commons Attribution-ShareAlike 3.0 Unported
 * License info: {@link http://creativecommons.org/licenses/by-sa/3.0/}
 *
 * Version: 1.0
 * Date: 7/18/2010
 *
 * Скрипт добавляет всплывающую картинку к тамбшотам
 * Адрес картинки берется из атрибута alt
 *
 */
function ThumbshotPreview(tclass, target) {
	if (!target) {
		target = jQuery("img.thumbshots_plugin[alt^=\'http:\']");
		//alert(target.length);
	}
	if (target.length < 1) return;
	
	jQuery('<style type="text/css"> .' + tclass + ' {position:absolute;left:-20000px;display:none;z-index:10;border:1px solid #ccc; background:#333; padding:2px;color:#fff} .' + tclass + ' img {margin:0;padding:0;border:none} </style>').appendTo('head');
	
	jQuery(target).each(function (i) {
		jQuery(this).hover(function () {
			jQuery("body").append("<div class='" + tclass + "' id='" + tclass + i + "'><img src='" + jQuery(this).attr('alt') + "' alt='Loading preview' /><br />" + jQuery(this).attr('title') + "</div>");
			jQuery(this).attr('title','');
			jQuery("#" + tclass + i).css({
				opacity: 1,
				display: "none"
			}).fadeIn(50)
		}, function () {
			jQuery("#" + tclass + i).fadeOut(50)
		}).mousemove(function (kmouse) {
			jQuery("#" + tclass + i).css({
				left: kmouse.pageX + 25,
				top: kmouse.pageY - 55
			})
		})
	})
}

jQuery(document).ready(function () {
	ThumbshotPreview('ThumbshotPreview');
});
