function createPurr (heading,msg,sticky) {
	var notice = purrContainer(heading,msg);
	$(notice).purr(
		{
			usingTransparentPNG: true,
			fadeInSpeed: 300,
			isSticky: sticky==1?true:false
		}
	);
}

function purrContainer (heading,msg) {
	var notice = '<div class="notice">'
			  + '<div class="notice-body">' 
				  + '<h3>'+heading+'</h3>'
				  + '<p>'+msg+'</p>'
			  + '</div>'
			  + '<div class="notice-bottom">'
			  + '</div>'
		  + '</div>';
		
	return notice;
}

function string_subtract(str1, str2)
{
  var pos = str1.indexOf(str2);
  if( pos == -1 ) return str1;
  return str1.substr(0, pos) + str1.substr(pos + str2.length);
}

function urlencode(str) {
	return escape(str).replace('+', '%2B').replace('%20', '+').replace('*', '%2A').replace('/', '%2F').replace('@', '%40');
}

function urldecode(str) {
//	return unescape(str.replace('+', ' '));
	return unescape(str.replace(/\+/g," "));
}

function utfdecode(utftext) {
	var string = "";
	var i = 0;
	var c = c1 = c2 = 0;

	while ( i < utftext.length ) {

		c = utftext.charCodeAt(i);

		if (c < 128) {
			string += String.fromCharCode(c);
			i++;
		}
		else if((c > 191) && (c < 224)) {
			c2 = utftext.charCodeAt(i+1);
			string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
			i += 2;
		}
		else {
			c2 = utftext.charCodeAt(i+1);
			c3 = utftext.charCodeAt(i+2);
			string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
			i += 3;
		}

	}
	return string;
}
