_$Ajex = function() {};

_$Ajex.prototype = {
	_set : function(attr, obj) {
		this[attr] = obj;
	},

	_merge : function(attr, obj) {
		if (this.empty(this[attr])) {
			this._set(attr, obj);
			return;
		}

		for (var i in obj) {
			this[attr][i] = obj[i];
		}
	},

	refresh: function() {
		var link = location.href;
		this.redirect(link);
	},
	redirect: function(link) {
		try {
			location.replace(link);
		} catch(e) {
			try{ location.href = link; } catch(e2) {}
		}
		return;
	},

	openWindow: function(link, options) {
		var args = '';

		if (typeof(options) == 'undefined') {
			var options = new Object();
		}

		if (typeof(options.name) == 'undefined') { options.name = 'win' + Math.round(Math.random()*100000); }

		if (typeof(options.height) != 'undefined' && typeof(options.fullscreen) == 'undefined') {
			args += "height=" + options.height + ",";
		}

		if (typeof(options.width) != 'undefined' && typeof(options.fullscreen) == 'undefined') {
			args += "width=" + options.width + ",";
		}

		if (typeof(options.fullscreen) != 'undefined') {
			args += "width=" + screen.availWidth + ",";
			args += "height=" + screen.availHeight + ",";
		}

		if (typeof(options.center) == 'undefined') {
			options.x = 0;
			options.y = 0;
			args += "screenx=" + options.x + ",";
			args += "screeny=" + options.y + ",";
			args += "left=" + options.x + ",";
			args += "top=" + options.y + ",";
		}

		if (typeof(options.center) != 'undefined' && typeof(options.fullscreen) == 'undefined') {
			options.y=Math.floor((screen.availHeight-(options.height || screen.height))/2)-(screen.height-screen.availHeight);
			options.x=Math.floor((screen.availWidth-(options.width || screen.width))/2)-(screen.width-screen.availWidth);
			args += "screenx=" + options.x + ",";
			args += "screeny=" + options.y + ",";
			args += "left=" + options.x + ",";
			args += "top=" + options.y + ",";
		}

		if (typeof(options.scrollbars) != 'undefined') { args += "scrollbars=1,"; }
		if (typeof(options.menubar) != 'undefined') { args += "menubar=1,"; }
		if (typeof(options.locationbar) != 'undefined') { args += "location=1,"; }
		if (typeof(options.resizable) != 'undefined') { args += "resizable=1,"; }

		var win = window.open(anchor, options.name, args);
		return false;

	},

	empty : function(o, p) {
		if ('undefined' === typeof (o) || null === o || false === o || '' === o || o instanceof Object && 0 == o.length) {
			return true;
		}
		return false;
	},

	isset: function() {	/* http://kevin.vanzonneveld.net */
		var a=arguments, count=a.length, i=-1;
		if (0 === count) {
			throw new Error('Empty isset');
		}
		while (++i !== count) {
			if ('undefined' == typeof(a[i]) || null === a[i]) {
				return false;
			}
		}
		return true;
	},



/*
	* @version	1.2;
	* @link	http://design-noir.de/webdev/JS/parseStr/
	* @return	Object
*/
	parseStr : function(s) {
		var rv = {}, decode = window.decodeURIComponent || window.unescape;
		(null == s? location.search : s).replace(/^[?#]/, "").replace(/([^=&]*?)((?:\[\])?)(?:=([^&]*))?(?=&|$)/g,
				function($, n, arr, v) {
					if ('' == n) {
						return;
					}
					n = decode(n);
					v = decode(v);
					if (arr) {
						if (typeof rv[n] == "object")
							rv[n].push(v);
						else
							rv[n] = [v];
					} else {
						rv[n] = v;
					}
				});
		return rv;
	},

	is_email: function(email) {
		var emailReg = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
		return emailReg.test(email);
	}

}

$Ajex = new _$Ajex();

/*
var trim = function(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function strpos(haystack, needle, offset) {
	var i = haystack.indexOf(needle, offset);
	return i >= 0? i : false;
}
*/

var cssFix = function() {
	var u = navigator.userAgent.toLowerCase(),
	is = function(t) {
		return (u.indexOf(t) != -1);
	};
	$("html").addClass([(!(/opera|webtv/i.test(u)) && /msie (\d)/.test(u)) ? ('ie ie' + RegExp.$1)
		: is('firefox/2') ? 'gecko ff2'	: is('firefox/3') ? 'gecko ff3'	: is('gecko/') ? 'gecko'
		: is('chrome/') ? 'chrome'
		: is('opera/9') ? 'opera opera9'	: /opera (\d)/.test(u) ? 'opera opera' + RegExp.$1
		: is('konqueror') ? 'konqueror'
		: is('applewebkit/') ? 'webkit safari'
		: is('mozilla/') ? 'gecko'
		: '',
		(is('x11') || is('linux')) ? ' linux' : is('mac') ? ' mac' : is('win') ? ' win'
	: ''].join(''));
}();
