var com = com || {};
	
com.nudge = {
	VERSION : 'jQuery v1.5.1',
	INSTANCENAME : 'com.codenudge.',
	net : {},
	util : {}
};

com.nudge.browser = {
	isMobile : (navigator.userAgent.toUpperCase().indexOf("MOBILE")==-1)?false:true,
	isIPad : (navigator.userAgent.toUpperCase().indexOf("IPAD")==-1)?false:true,
	isGalaxyTab : (navigator.userAgent.toUpperCase().indexOf("SHW-M180")==-1)?false:true,
	isIE : ($.browser.msie)?true:false,
	isIE6 : ($.browser.msie&&$.browser.version=="6.0")?true:false,
	isStrict : function() {
		var docRoot = document.documentElement;
		return (docRoot!=undefined);
	},
	screenW : function() {
		var w = window.innerWidth ||
			(this.isStrict() && document.documentElement.clientWidth) ||
			document.body.clientWidth || 0;
		if (!this.isIE&&!this.isMobile) {w-=20;}
		return w;
	},
	screenH : function() {
		return window.innerHeight ||
			(this.isStrict() && document.documentElement.clientHeight) ||
			document.body.clientHeight || 0;
	},
	scrollW : function() {
		return (this.isStrict() && document.documentElement.scrollWidth) ||
			document.body.scrollWidth || 0;
	},
	scrollH : function() {
		return (this.isStrict() && document.documentElement.scrollHeight) ||
			document.body.scrollHeight || 0;
	},
	bodyW : function() {
		return document.body.scrollWidth || 0;
	},
	bodyH : function() {
		return document.body.scrollHeight || 0;
	},
	scrollX : function() {
		return window.pageXOffset ||
			(this.isStrict() && document.documentElement.scrollLeft) ||
			document.body.scrollLeft || 0;
	},
	scrollY : function() {
		return window.pageYOffset ||
			(this.isStrict() && document.documentElement.scrollTop) ||
			document.body.scrollTop || 0;
	},
	maxW : function() {
		return Math.max(this.screenW(), this.scrollW());
	},
	maxH : function() {
		return Math.max(this.screenH(), this.scrollH());
	}
};

com.nudge.net.StrLoading = function(_config){
	_config = _config || {};
	_config.target = _config.target || $('body'),
	_config.id = _config.id || 'setloading',
	_config.opt = _config.opt || { opacity : 0.5 },
	_config.css = _config.css || { opacity : 0.75 },
	_config.speed = _config.speed || 750;
	_config.func = _config.func || function(){
		$(this).remove();
		if(_config.flag) _config.target.css({position:_config.oldPosition});
	};
	
	var strDiv = '<div id="'+_config.id+'" class="loading" />';
	
	this.set = function(){
		_config.parent = _config.target.parent();
		_config.parentPosition = _config.parent.css('position'),
		_config.setPosition = (_config.parentPosition == 'static') ? 'relative' : _config.parentPosition;
		_config.oldPosition = _config.parentPosition;
		_config.flag = (_config.target.selector != 'body');
		
		if(_config.flag){
			_config.target.css({position:_config.setPosition}).append(strDiv);
		}else{
			$(strDiv).css(_config.css).appendTo(_config.target);
		}
	};
	
	this.remove = function(){
		$('#'+_config.id).animate(_config.opt,_config.speed,_config.func);
	};
};


/* Cookies Util */
com.nudge.util.cookie = {
	get : function(_name) {
		var list = document.cookie.split(";");
		var value = "";
		for (i = 0; i < list.length; i++) {
			if (list[i].indexOf(_name+"=") > -1) {
				if (list[i].split("=")[0].replace(/\s/g,"") == _name) {
					value = decodeURIComponent(list[i].split("=")[1]);
					break;
				}
			}
		}
		return value;
	},
	set : function(_name, _value, _days, _path, _domain) {
		if (_name!=undefined&&_name.trim()!="") {
			if (_value==undefined) _value = "";
			if (_days==undefined) _days = 365;
			if (_path==undefined) _path = "/";
			/* try { if (_domain==undefined) _domain = location.hostname; } catch(e) { } */
			var d = new Date();
			d.setDate(d.getDate()+_days);
			var s = "";
			s += _name+"="+encodeURIComponent(_value) + ";";
			s += "expires=" + d.toGMTString() + ";";
			s += "path=" + _path + ";";
			if (_domain!=undefined) {
				s += "domain=" + _domain + ";";
			}
			document.cookie = s;
		}
	}
};


var _code = com.nudge;

/**
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 */
jQuery.extend( jQuery.easing, {
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	}
});

/**
 * Use BackgroundImageCache For IE
 */
try {
	document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}
