/* String */
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,'');
}

String.prototype.rtrim = function() {
	return this.replace(/\s+$/,'');
}

/* Add custom events to mootools */
Element.NativeEvents.push('propertychange','input');

function closeLightbox(){
	obj = parent.document.getElementById('lbCloseLink');
	if(obj){
	parent.Lightbox.close();
	}
	else{
		b = getQSParam('b');
		b = parseInt(b);
		if( !isNaN(b)){
			new_location = 'http://'+location.hostname+"/index.php?a=2&b="+b;
			location.href=new_location;
		}
	}
	
}

function getQSParam(param){
	query_string = document.location.search.substring(1);
	param_name_arr = query_string.split("&");
	for (i=0;i<param_name_arr.length;i++) {
		param_value = param_name_arr[i].split("=");
		if (param_value[0] == param) {
			return param_value[1];
		}
	}
	
}