var IqStatic = {
	adler32:function(data) {
		var a = 1;
		var b = 0;
		var len = data.length;
		for (index = 0; index < len; ++index) {
			a = (a + data.charCodeAt(index)) % 65521;
			b = (b + a) % 65521;
		}
		var hex='0000';
		b=b.toString(16); //JS does not have unsigned ints so we use
		a=a.toString(16); //string concatination instead to avoid -ve values
		a=hex.substr(0,4-a.length)+a;
		b=hex.substr(0,4-b.length)+b;
		return '0x'+b+a;
	}
	,
	
	once_per : function(millisec,func) {
		if(this.timer){
			clearTimeout(this.timer);
		}
		this.timer=func.delay(millisec);
	}
	,
	tags_to_text: function(str) {
		var out = 
		str.replace(/&/g,"&amp;$1")
		.replace(/>/g,'&gt;')
		.replace(/</g,'&lt;');	
		return out;
	}
}

// https://github.com/marceloOrigoni/Element.unselectable/blob/master/Source/Element.unselectable.js
// may help in chrome to stop areas hightlightin on double click but needs further testing
// adding:
// document.getElement('body').unselectable()
// seems to be a good way to stop all text selection on a page in chrome

Element.implement({
	unselectable: function(){
		if (typeof $(this).onselectstart != 'undefined') {
			$(this).addEvent('selectstart',function() { return false; });
		} else if (typeof $(this).style.MozUserSelect != 'undefined') {
			$(this).setStyle('MozUserSelect', 'none');
		} else if (typeof $(this).style.WebkitUserSelect != 'undefined') {
			$(this).setStyle('WebkitUserSelect', 'none');
		} else if (typeof $(this).unselectable  != 'undefined') {
			$(this).setProperty('unselectable','on');
		}		
	}
});
