﻿/// Utility.js
(function ($) {
	Type.registerNamespace("Utilis");

	$.extend(Utilis, {
		// Get url info(search & hash values)
		parseLocation: function () {
			var parseQuery = function (str) {
				var result = {}, queryString = str.substring(1), re = /([^&=]+)=([^&]*)/g, m;
				while (m = re.exec(queryString)) {
					result[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
				}
				result.toString = function () {
					var ar = [];
					$.each(result, $.fun(this, function (i, item) {
						if (typeof (item) == 'string' && !!item)
							Array.add(ar, String.format('{0}={1}', i, item));
					}));
					return ar.join('&');
				}
				return result;
			}
			return { Search: parseQuery(window.location.search), Hash: parseQuery(window.location.hash) };
		}
	});

	// Function delegate
	$.fun = function (instance, func) {
		return Function.createDelegate(instance, func);
	};

	jQuery(function ($) {
		$('.ps_send').fancybox({
			width: 430,
			height: 350,
			'type': 'iframe',
			'autoScale': false
		});
	});

})(jQuery);
