// JavaScript Document
function newWindow(url,name,attributes) {
	if(attributes == undefined || attributes == "") attributes = "WIDTH=390,HEIGHT=425,LEFT=200,TOP=125,SCROLLBARS";
	if(name == undefined || name == "") name = "Federal Reserve Consumer Help";
	if(url == undefined || url == "") 
		location.reload(true);
	else
		window.open(url,name,attributes);
}
function textCounter(field, maxlimit)
{
	if (field.value.length > maxlimit)
	{
		field.value = field.value.substring(0, maxlimit);
		alert("\nYou have exceeded the limit.  Please ensure your message is less than "+maxlimit+" characters.  If you have questions, call us toll-free at 888-851-1920.\n");
	}	
}
function showDiv()  {
	for(var i = 0;i < arguments.length;i++) {
		$('#'+arguments[i]).toggle();
	}
}
function ajaxRequest(url,functionName) {
	if (window.XMLHttpRequest) { httpObj = new XMLHttpRequest(); } 
	else if (window.ActiveXObject) { httpObj = new ActiveXObject("Microsoft.XMLHTTP"); }
	
	httpObj.open("GET",url,true);
	httpObj.send(null);
	
	httpObj.onreadystatechange = function() {
		if ((httpObj.readyState == 4) && (httpObj.status == 200)) {
			if (typeof(functionName) == "function") functionName(httpObj.responseText);
		}
	}
}
function countHit(type,itemName) {
	type = (type == "")?"Undefined":escape(type);
	itemName = (itemName == "")?"Undefined":escape(itemName);
	//trim spaces
	type = type.replace(/^\s+|\s+$/g,"");
	itemName = itemName.replace(/^\s+|\s+$/g,"");
	
	ajaxRequest('/updateHitCount.cfm?'+type+"="+itemName);
}
function openCloseFAAs(thisId) {
	//var thisId = $(this).attr('id');
	idNumber = thisId.replace('titleFaa','');
	
	$('[id^=faa]:not(#faa'+idNumber+')').addClass('invisible');
	$('[id^=titleFaa]:not(#titleFaa'+idNumber+')').css('background-image','url(/assets/images/arrow1.gif)'); 
	
	if($('#'+thisId).css('background-image').indexOf('arrow1') > 0) {
		$('#'+thisId).css('background-image','url(/assets/images/arrow.gif)');
	}
	else {
		$('#'+thisId).css('background-image','url(/assets/images/arrow1.gif)');
	}
	
	if ($('#faa'+idNumber).hasClass('invisible')){
		countHit('FAA',$("#categoryName").html()+'...'+$('#'+thisId).html());
		$('#faa'+idNumber).removeClass('invisible');
	}
	else {
		$('#faa'+idNumber).addClass('invisible');	
	}
}
function openPageInParent(page) {
  if (window.opener && !window.opener.closed)
	window.opener.location.href=page; 
	//window.close();
}
