
function getURLparam(name) {
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var tmpURL = window.location.href;
	var results = regex.exec( tmpURL );
	if( results == null ){
		return "";
	}else{
		return results[1];
	}
}


var getURL = new Class({
	Implements: [Options, Events],
	options: {},
	initialize: function(options){
		 this.setOptions(options);
		var rst = window.location.search.split(/[?&]/);
		this.explode(rst);
	},
	resultsAssoc: {},
	resultsIndexed: [],
	explode: function(arr){
		for(var i = 0; i < arr.length; i++){
			var kv = arr[i].split(/=/);
			this.resultsAssoc[kv[0]] =  kv[1];
			this.resultsIndexed.push(kv[1]);
		}
	},
	param: function(key){
		return ( (isFinite(parseInt(key, 10))) ? this.resultsIndexed[key] : this.resultsAssoc[key] );
	},
	find: function(str){
		return ((window.location.search.indexOf(str) !== -1) ? true : false);
	},
	length: function(){
		return this.resultsIndexed.length;
	}
});


var toEntity = function(character){
	var aa = character, bb = '';
		for(i=0; i < aa.length; i++){
			bb += '&#' + aa.charCodeAt(i) + '; ';
		}
	return bb;
}

var toEntityB = function(){
	var aa = document.form.utf.value, bb = '';
	for(i=0; i < aa.length; i++){
		if(aa.charCodeAt(i)>127){
			bb += '&#' + aa.charCodeAt(i) + ';';
		}else{
			bb += aa.charAt(i);
		}
	}
	document.form.entity.value = bb;
}
