/* display year */
var date = new Date();
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;

/* centered pop up window */
function centeredPopUpWindow(mypage, myname, w, h, scroll){
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

/* linking to an external site */
function fdicLink(){
	alert("You are about to leave the Piscataqua Savings Bank website and go to the FDIC website. Piscataqua Savings Bank is not responsible for any information, products and/or services available through the FDIC website.");
	window.open("http://www.fdic.gov/");
}
function hudLink(){
	alert("You are about to leave the Piscataqua Savings Bank website and go to the U.S. Department of Housing and Urban Development website. Piscataqua Savings Bank is not responsible for any information, products and/or services available through the U.S. Department of Housing and Urban Development website.");
	window.open("http://www.hud.gov/");
}
function externalLinkAlert(websiteURL){
	alert("You are about to leave the Piscataqua Savings Bank website. Piscataqua Savings Bank is not responsible for any information, products and/or services available through any other website.");
	window.open(websiteURL);
}

function makeDrags()
{
	$("ul.sortableList").sortable({update:recordElementOrder})
}

function recordElementOrder(e, ui)
{
	var ordering = "";
	var ids = "";
	$("input[id$=hfProductId]").each(
		function ()
		{
			// have to track ids because jQuery is sending the most recently dragged element 2x
			if (ids.indexOf(this.id) == -1)
			{
				ordering += this.value + " ";
				ids += this.id;
			}
		}
	)
	$("input[id$=hfProductOrder]").val(ordering);
}


$(document).ready(function(){

	// rates disclosures popup boxses
	setRatesDisclosures();

});

function setRatesDisclosures()
{
	$("a.productDisclosureLink").hover(
		function()
		{
			$(this).next("div.disclosureContent").show();
		},
		function()
		{
			$(this).next("div.disclosureContent").hide();
		}
	);
}