String.prototype.trim = function(){return this.replace(/^\s+|\s+$/, '');};

// Array Remove - By John Resig (MIT Licensed)
Array.prototype.remove = function(from, to) {
  var rest = this.slice((to || from) + 1 || this.length);
  this.length = from < 0 ? this.length + from : from;
  return this.push.apply(this, rest);
};

var showMessage=function( msg ){
	$("#messagePnl").html(msg).prepend(
		'<span class="ui-icon ui-icon-arrowthickstop-1-n" style="float: left; margin-right: .3em;" id="hideMsgBtn"></span>'
	).show("drop").effect("pulsate");//.effect('highlight', {color:'#FFB0B0'}, 3000);
	$('#showMsgBtn').hide('drop');
	$("#hideMsgBtn").css({cursor:'pointer'}).click(function(){
		$("#messagePnl").hide("drop")
		$('#showMsgBtn').show('drop');
	});
}

var initDatePicker=function( jqueryStr ){
	return $(jqueryStr).attr({size:10}).datepicker({
		dateFormat: 'yy-mm-dd'
		,changeMonth: true
		,changeYear: true
		,showOn: 'button'
		,buttonImage: 'images/calendar.gif'
	});
};

var submitWithValidation=function(){
	if(!$(this).valid())return false;
	return true;
};

var initBtn=function( jqueryStr ){
	return $(jqueryStr).css({cursor:'pointer','text-decoration':'underline'}).hover(
		function(){$(this).css({'text-decoration':'',color:'red'});}
		,function(){$(this).css({'text-decoration':'underline',color:''});}
	);
};

var initIconBtn=function( jqueryStr ){
	return $(jqueryStr).css({cursor:'pointer'}).hover(
		function(){$(this).addClass("ui-state-hover");}
		,function(){$(this).removeClass('ui-state-hover');}
	);
};