/*
jQuery Url Plugin
 * Version 1.0
 * 2009-03-22 19:30:05
 * URL: http://ajaxcssblog.com/jquery/url-read-get-variables/
 * Description: jQuery Url Plugin gives the ability to read GET parameters from the actual URL
 * Author: Matthias Jäggli
 * IMPROVED: jQuery Url Plugin gives the ability to read GET parameters from the ALL URL's		* 
 * MODIFIED: Domenico Lupinetti
 * Copyright: Copyright (c) 2009 Matthias Jäggli under dual MIT/GPL license.
 */

(function($) {
	$.url = {};
	$.extend($.url, {
		_params : {},
		init : function(path) {
			var paramsRaw = "";
			try {
				paramsRaw = (path.split("?", 2)[1] || "").split("#")[0]
						.split("&")
						|| [];
				for ( var i = 0; i < paramsRaw.length; i++) {
					var single = paramsRaw[i].split("=");
					if (single[0])
						this._params[single[0]] = unescape(single[1]);
				}
			} catch (e) {
				// alert(e);
			}
		},
		param : function(real_image, name) {
			this.init(real_image);
			return this._params[name] || "";
		},
		paramAll : function(real_image) {
			this.init(real_image);
			return this._params;
		}
	});

})(jQuery);
// parse Params of a GET STRING

/*
 * Image preview script powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com) MODIFIED by Domenico Lupinetti
 * 
 * for more info visit
 * http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 * 
 */

$(document).ready(
		function() {

			$("a.preview").hover(function(e) {

				xOffset = 125;// 280;
					yOffset = 15;// 15;

					this.t = this.title;
					this.title = "";

					var real_image = $(e.target).attr("src");
					// jQuery Bug????
					if (real_image == undefined || real_image == null
							|| real_image == "") {
						return;
					}
					// jQuery Bug????
					var obj = $.url.param(real_image, "src");

					var loc = window.location.href;

					try {
						var location = "http://" + loc.split("http://")[1].split("?")[0];
					} catch (e) {
						var location = loc;
					}

					var image_magnified = location + "images/thumb.php?src="
							+ obj + "&width=250&height=250&f=0&q=100";
					var c = (this.t != "") ? "<br/>" + this.t : "";
					$("body").append(
							"<p id='preview'><img class='m_image' src='"
									+ image_magnified
									+ "' alt='Image Preview' />" + c + "</p>");
					$("#preview").css("top", (e.pageY - xOffset) + "px").css(
							"left", (e.pageX + yOffset) + "px").fadeIn("fast");
				}, function() {
					this.title = this.t;
					$("#preview").remove();
				});

			$("a.preview").mousemove(
					function(e) {
						$("#preview").css("top", (e.pageY - xOffset) + "px")
								.css("left", (e.pageX + yOffset) + "px");
					});

		});
