		function spiProductHelpful(cid, response) {
		var url = '/products/comment_vote_ajax?vote=' + cid + "&voted=" + response;
		new Ajax.Request(url, {
		method: 'get',
		onSuccess: function(transport) {

			var notice = $('helpful_message-'+cid);
			if (transport.responseText.match('login')) {
				parts = parseUri(window.location);
				url = parts['protocol'] + "://";
				url += parts['host'];
				url += parts['path'];
				url += parts['query'] == '' ? '?' : ('?' + parts['query'] + '&');
				url += 'vote=' + cid + '&voted=' + response;
				url += "#comment-" + cid;
				window.location = url;
			} else {
			  notice.update('Thanks for your feedback.');
			}
		}
	});   			
	
	}

function parseUri (str) {
	var	o   = parseUri.options,
		m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
		uri = {},
		i   = 14;

	while (i--) uri[o.key[i]] = m[i] || "";

	uri[o.q.name] = {};
	uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
		if ($1) uri[o.q.name][$1] = $2;
	});

	return uri;
};

parseUri.options = {
	strictMode: false,
	key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
	q:   {
		name:   "queryKey",
		parser: /(?:^|&)([^&=]*)=?([^&]*)/g
	},
	parser: {
		strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
		loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
	}
};

function spiProductsCookieBack(pid) {
  setCookie('products_listing_uri', window.location.href);
  setCookie('products_listing_pid', pid);
}


