jQuery.noConflict();
var $j = jQuery;

var Application = {
	init: [],
	Ui: {},

	eventDocumentReady: function(event) {
		for(var i = 0, j = Application.init.length; i < j; ++i)
			if(jQuery.isFunction(Application.init[i])) Application.init[i]();
	}
};

$j(document).one('ready', Application.eventDocumentReady);

if(!Application.Ui._) Application.Ui._ = {};
Application.Ui._.HelpToolTip = {
	eventDOMReady: function(event) {
		var elm = $j('span.HelpToolTip');
		for(var i = 0, j = elm.size(); i < j; ++i) {
			var helpTitle = $j('span.HelpToolTip_Title', elm.get(i)).html();
			var helpContents = $j('span.HelpToolTip_Contents', elm.get(i)).html();

			$j(elm.get(i)).bind('mouseover', {'title':helpTitle, 'contents':helpContents}, Application.Ui._.HelpToolTip.eventOnMouseOver);
			$j(elm.get(i)).mouseout(Application.Ui._.HelpToolTip.eventOnMouseOut);
		}
	},

	eventOnMouseOver: function(event) {
		$j('<div class="HelpToolTip_Placeholder" style="display:inline;position:absolute;width:220px;background-color:#FFF6CF;border:solid 1px #DFD5A7;padding:10px;">'
			+ '<span class="helpTip"><b>' + event.data.title + '</b></span>'
			+ '<br /><img src="/elements/images/design/1x1.gif" width="1" height="5" />'
			+ '<br /><div style="padding-left:10px;padding-right:5px;font-size:11px;line-height:1.2em;">' + event.data.contents + '</div>'
			+ '</div>').appendTo(this);
	},

	eventOnMouseOut: function(event) { $j('div.HelpToolTip_Placeholder', this).remove(); }
};

Application.Ui.HelpToolTip = function(selector, title, contents) {
	$j(selector).bind('mouseover', {'title':title, 'contents':contents}, Application.Ui._.HelpToolTip.eventOnMouseOver);
	$j(selector).mouseout(Application.Ui._.HelpToolTip.eventOnMouseOut);
};

Application.init.push(Application.Ui._.HelpToolTip.eventDOMReady);




function enterCurrency(A){
  var B;
  B=addCommas(keepNumbers(A.value,"$., "));
  if(B.length){
    B="$"+B;
  }
  A.value=B;
}

function addCommas(A){
  var D;
  var C;
  var B="";
  for(D=0;D<A.length;++D){
    B+=A.substring(D,D+1);
    if(D<A.length-1&&!((A.length-D-1)%3)){
      B+=",";
    }
  }
  return B;
}

function keepNumbers(A){
  return keepChars(A,"0123456789");
}

function keepChars(B,A){
  var E;
  var D;
  var C="";
  for(E=0;E<B.length;++E){
    D=B.substring(E,E+1);
    if(A.indexOf(D)>=0){C+=D;
    }
  }
  return C;
}

var newwindow;
function popradarup(url)
{
  newwindow=window.open(url,'name','height=421,width=616');
  if (window.focus) {newwindow.focus()}
}

function textCounter(field, countfield, maxlimit)
{
	if (field.value.length > maxlimit)
	{field.value = field.value.substring(0, maxlimit);}
	else
	{countfield.value = maxlimit - field.value.length;}
}



