( function( $ ) {
	jQuery.cookie = {
		get : function( obj, pre ) {
			var test = "";
			obj = $( obj );
			if ( document.cookie && document.cookie != "" ) {
				var cookies = document.cookie.split( ";" );
				var name = obj.attr("name");
				for ( var i = 0; i < cookies.length; i++ ) {
						var cookie = jQuery.trim( cookies[ i ] );
						if ( cookie.substring( 0, name.length + 1 ) == ( name + "=" ) ) {
						test = decodeURIComponent( cookie.substring( name.length + 1 ) );
						break;
					}
				}
			}
			var val = ( test !== "" ) ? test : ( pre && pre !== "" ) ? pre : "";
			obj.val( val );
		},
		set : function( obj, options ) {
			obj = $( obj );
			var name = obj.attr( "name" );
			var val = obj.val();
			options = options || {};
			var expires = "";
			if ( typeof options.expires === "date" ) {
				date = options.expires;
			}
			else if ( options.expires && typeof options.expires === "number" ) {
				var date = new Date();
				date.setTime( date.getTime() + ( options.expires * 24 * 60 * 60 * 1000 ) );
			}
			else {
				var date = new Date();
				date.setTime( date.getTime() + ( 300 * 24 * 60 * 60 * 1000 ) );
			}
			expires = '; expires=' + date.toUTCString();
			var path = options.path ? '; path=' + ( options.path ) : '';
			var domain = options.domain ? '; domain=' + ( options.domain ) : '';
			var secure = options.secure ? '; secure' : '';
			document.cookie = [ name, '=', encodeURIComponent( val ), expires, path, domain, secure ].join( "" );
			return obj;
		},
		allowed : function() {
			return ( document.cookie ) ? true : false;
		}
	};
})(jQuery);
( function( $ ) {
	$.extFocus = function( obj, select ) {
		window.setTimeout( function() {
			obj.focus();
			if ( select && select == true ) { 
				obj.select(); 
			}
		}, 300);
	};
})(jQuery);
( function( $ ) {
	jQuery.date = {
		_intDate: null,
		_init: function( d ){ this._intDate = ( d ) ? d : new Date(); },
		_toString : function( v ){ return ( v < 10 ) ? "0" + v : "" + v; },
		day : function( i ){ if ( i && i === true ) { this._init(); } return this._intDate.getDate(); },
		month : function( i ){ if ( i && i === true ) { this._init(); } return this._intDate.getMonth() + 1; },
		year : function( i ){ if ( i && i === true ) { this._init(); } return this._intDate.getFullYear(); },
		today: function() { this._init(); return this._intDate; },
		time: function() { this._init(); return this._intDate.getTime(); },
		dayS : function(){ return this._toString( this.day() ); },
		monthS : function(){ return this._toString( this.month() ); },
		yearS : function(){ return this._toString( this.year() ); },
		_dateString: function() { return this.dayS() + "." + this.monthS() + "." + this.yearS(); },
		todayS: function() { this._init(); return this._dateString(); },
		dateToString : function( date ){ this._init( date ); return this._dateString(); },
		stringToDate : function( date ){ this._init(); this._intDate.setDate( parseInt( date.substr( 0, 2 ), 10 ) ); this._intDate.setMonth( parseInt( date.substr(3 , 2 ), 10 ) - 1 ); this._intDate.setFullYear( parseInt( date.substr( 6, 4 ), 10) ); return this._intDate; }, 
		valuesToString : function( d, m, y ){ return this._toString( d ) + "." + this._toString( m ) + "." + this._toString( y ); },
		valuesToDate : function( d, m, y ){ return new Date( y, ( m - 1 ), d ); },
		minDate : function( d1, d2 ){ return ( d1.getTime() < d2.getTime() ) ? d1 : d2; },
		maxDate : function( d1, d2 ){ return ( d1.getTime() > d2.getTime() ) ? d1 : d2; }
	};
})(jQuery);
( function( $ ) {
	$.sleep = function( ms ){ var now = $.date.time(); var end = now + ms; while ( now < end ) { now = $.date.time(); } }
})(jQuery);
( function( $ ) {
	$.isIE = function() { return navigator.userAgent.search( /MSIE/) > - 1; };
	$.isIE6 = function() { return navigator.userAgent.search( /MSIE/) > - 1 && navigator.appVersion.search( /6./) > - 1; };
	$.isIE8 = function() { return navigator.userAgent.search( /MSIE/) > - 1 && navigator.appVersion.search( /8./) > - 1; };
	$.isSafari = function() { return navigator.userAgent.search( /Safari/) > - 1; };
	$.isOpera = function() { return navigator.userAgent.search( /Opera/) > - 1; };
	$.isWebKit = function() { return navigator.userAgent.search( /WebKit/) > - 1; };
})(jQuery);

