function isValidHost(s) {
  var regexp = /^([a-zA-Z0-9]+(-|\.[a-zA-Z0-9]+)+.*)$/i
	return regexp.test(s);
}

function trim(str) {
  str=str.replace(/^\s+|\,|\s+$/g,'');
  str=str.replace(/^\//, '');
  str=str.replace(/^\#/, '');
  str=str.replace(/\/$/, '');
  str=str.replace(/^\s+/, '');
  str=str.replace(/\s+$/, '');
  str=str.replace(/^\s+|\s+$/g, '');
  str=str.replace('http://', '');
  return str;
}

function addCommas(nStr){
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}


$("#dialog:ui-dialog").dialog( "destroy" );

$("#dialog-message-terms,#dialog-message-privacy" ).dialog({
  resizable:false,
  height:400,
  width:800,
  modal: true,
  autoOpen:false
});

$.ajaxSetup ({cache: false});

var ajax_load = "<img src='../img/ajax-loader.gif' alt='loading...' style='text-align:center; padding:20px' />";
$("a#terms").click(function(){
   $("#dialog-message-terms").html(ajax_load).load("../terms.php").dialog('open');
});

$("a#privacy").click(function(){
   $("#dialog-message-privacy").html(ajax_load).load("../privacy.php").dialog('open');
});
