
jQuery.cookie = function (key, value, options) {

    // key and value given, set cookie...
    if (arguments.length > 1 && (value === null || typeof value !== "object")) {
        options = jQuery.extend({}, options);

        if (value === null) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }

        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? String(value) : encodeURIComponent(String(value)),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};

function setCookie (name, value, lifespan, access_path) {
	var cookietext = name + "=" + escape(value) 
	if (lifespan != null) { 
	  var today=new Date() 
	  var expiredate = new Date() 
	  expiredate.setTime(today.getTime() + 1000*60*60*24*lifespan)
	  cookietext += "; expires=" + expiredate.toGMTString()
	}
	if (access_path != null) { 
	  cookietext += "; PATH="+access_path 
	}
	document.cookie = cookietext 
	return null 
}
function _uGC(l,n,s) {
	// used to obtain a value form a string of key=value pairs
	if (!l || l=="" || !n || n=="" || !s || s=="") return "-";
	var i,i2,i3,c="-";
	i=l.indexOf(n);
	i3=n.indexOf("=")+1;
	if (i > -1) {
	i2=l.indexOf(s,i); if (i2 < 0) { i2=l.length; }
	c=l.substring((i+i3),i2);
	}
	return c;
}

var z = _uGC(document.cookie, "__utmz=", ";");
analytics_source = _uGC(z,"utmcsr=", "|");
analytics_medium = _uGC(z,"utmcmd=", "|");
analytics_term = _uGC(z,"utmctr=", "|");
analytics_content = _uGC(z,"utmcct=", "|");
analytics_campaign = _uGC(z,"utmccn=", "|");


