function Cookie(document, name, hours, path, domain, secure)
{
    this.$document = document;
    this.$name = name;
    if (hours) {
        this.$expiration = new Date((new Date()).getTime() + hours*3600000);
    }
    else this.$expiration = null;
    if (path) this.$path = path; else this.$path = null;
    if (domain) this.$domain = domain; else this.$domain = null;
    if (secure) this.$secure = true; else this.$secure = false;
}

// This function is the store() method of the Cookie object.
function _Cookie_store()
{
    var cookieval = "";
    for(var prop in this) {
        // Ignore properties with names that begin with '$' and also methods.
        if ((prop.charAt(0) == '$') || ((typeof this[prop]) == 'function')) 
            continue;
        if (cookieval != "") cookieval += '&';
        cookieval += prop + ':' + escape(this[prop]);
    }
    var cookie = this.$name + '=' + cookieval;
    if (this.$expiration) {
        //cookie += '; expires=' + this.$expiration.toGMTString();
        cookie += '; expires=' + this.$expiration;
    }
    if (this.$path) cookie += '; path=' + this.$path;
    if (this.$domain) cookie += '; domain=' + this.$domain;
    if (this.$secure) cookie += '; secure';
    this.$document.cookie = cookie;
}


function getParams() {
        var idx = window.location.href.indexOf('?');
        var params = new Array();
        if (idx != -1) {
                var pairs = window.location.href.substring(idx+1, window.location.href.length).split('&');
                for (var i=0; i<pairs.length; i++) {
                        nameVal = pairs[i].split('=');
                        params[nameVal[0]] = nameVal[1];
                }
        }
        return params;
}
params = getParams();
t = unescape(params["t"]);

if (t == 'PR') {
	// set cookie for PR
	new Cookie();
	Cookie.prototype.store = _Cookie_store;
	var visitordata = new Cookie(document, "terra", 0, "/","terra.com" );
	visitordata.country = "PR";
	visitordata.store();
}
