(function(){
    if ( typeof(window.shttr) == "undefined" ) {
	window.shttr={};
    }

    var util;

    util = {
	query : function( key ){
	    if ( typeof(util._queryString) == "undefined" ) {
		util._query = {};
		util._queryString = window.location.href.replace(/https?:\/\/[^?]+\?*/,"");
		util._query._q = {};
		util._queryString.split("&").each(function(el){
			var arr = el.split("=");
			arr[1] ? util._query._q[ arr[0] ] = arr[1] : util._query._q["query"] = arr[0];
		    });
	    }
	    if ( typeof(key) == "string" ) {
		return util._query._q[key];
	    }
	    else {
		return util._query._q;
	    }
	},

	pager : function(){}
    };

    util.pager.prototype = {
	init: function(opt){
	    if ( typeof(opt) == "undefined" ) {
		opt = {};
	    }
	    this.perPage = opt.perPage || 9;
	    this.currentPage = opt.currentPage || 1;

	    this.offset = (this.perPage * (this.currentPage - 1) );
	}
    }

    window.shttr.util = util;
})();

