// JavaScript Document


var cleared_booleans = {};
var oldtext = {};


function setOldText(thisItem){

	//if the textbox is empty
	if(jQuery.trim($(thisItem).val()) == ""){
		//fill with the original text
		$(thisItem).val(oldtext[$(thisItem).attr('id')]);
		cleared_booleans[$(thisItem).attr('id')] = false;
		
	}
	
}

function cleartext(thisItem) {
	//only clears text once
	if(cleared_booleans[$(thisItem).attr('id')] == false){
		
		oldtext[$(thisItem).attr('id')] = $(thisItem).val();
		$(thisItem).val("");
		cleared_booleans[$(thisItem).attr('id')] = true;
	}
		
}


$(window).load(function () {
	

	$('.clr').each(function() {

		cleared_booleans[$(this).attr('id')] = false;
		oldtext[$(this).attr('id')] = $(this).val();
		
		$(this).focus(function() {cleartext(this);});
		$(this).blur(function() {setOldText(this);});

  	});
	
	$('.cont-input').each(function() {

		cleared_booleans[$(this).attr('id')] = false;
		oldtext[$(this).attr('id')] = $(this).val();
		
		$(this).focus(function() {cleartext(this);});
		$(this).blur(function() {setOldText(this);});

  	});

})
