function browserMeetsRequirements()
{
	if (window.XMLHttpRequest) {
    // IE 7, mozilla, safari, opera 9
    return true;
  } else {
    // IE6, older browsers
    return false;
  }
}


function SendXMLHttpRequest(sUrl, callback_handler)
{
	var client = new XMLHttpRequest();
	client.onreadystatechange = callback_handler;
	client.open("GET", sUrl, true);
	client.send(null);
}


function display_class_message(sClass, msg)
{
	document.getElementById("status").innerHTML = '<h4 class="' + sClass + '">' + msg + '</h4>';
}

function hardLineWrap(string, line_length)
{
	wrapped_string = '';

	if( line_length < 1 )
	return;

	for( i=0; i < string.length; i = i+line_length) {
		wrapped_string += string.slice(i, i+line_length) + "<br/>";
	}

	return wrapped_string;
}


function getRandomHex(size)
{
	now = new Date();
  seed = now.getSeconds();

	var hex = "0123456789abcdef";
	var result = '';

	for(i=0; i < size; i++ ) {
		var letter = Math.floor(Math.random(seed) * 16)
		result += hex.charAt(letter);
	}

	return result;
}


function storeAndMask(input, code)
{
	// do nothing on SELECT-ALL (224=firefox, 91=safari)
	//   doesn't work perfect in all browsers but better than nothing
	if( code == 224 || code == 91) {
		return;
	}

	ivl = input.value.length;
	storage = document.getElementById(input.id+"_storage");
	count = document.getElementById(input.id+"_storage_count");


  // did they backspace? 
	if( ivl < count.value ) {
		storage.value = storage.value.slice(0, ivl);
	} else {
    storage.value += input.value.slice(count.value, ivl);
	}

	// then zero out all except last
	input.value = storage.value.replace(/./g, '•')
	if( ivl > 0 ) {
		input.value = input.value.substring(0, ivl-1) + storage.value.charAt(ivl-1);
	}

	count.value = ivl;
}


function mask(input)
{
	input.value = input.value.replace(/./g, '•')
}

