// stuff inside here will run when the DOM is ready
// onload replacement
$(function(){
	// Uncomment and Optimize the selector below for rollover images. 
	// Should select the ID of the element containing the nav w/ rollover images.
	// HINT: You can add more image containers by separating IDs with a space, just like in CSS: $('#navBar1 #navBar2')
	// $('#navBar').rollovers();
	
	// Uncomment the following to make a search box automagically add and remove the default value of that field
	//    on focus and blur.
	// $('#searchBox').searchField();
	
	if( document.location.href.indexOf('dept') != -1 ) {
		$('#formImage').css('display','none');
		alert('hidden');
	}
	
});

var newsite = "";

//hide the dropdown menus on locations.html (IE6 hack)
function hideIE6DropDowns() {
	$('.ie6Obstructor').show();
}
function showIE6DropDowns() {
	$('.ie6Obstructor').hide();
}



//place header image on correct form
function placeHeader( thisURL ) {
	if( thisURL.indexOf( 'retail' ) != -1 )
		document.write( '<img src="../images/header_deposits.jpg" alt="Hudson City - Bank on better values." />' );
	else if( thisURL.indexOf( 'mortgage' ) != -1 )
		document.write( '<img src="../images/header_mortgages.jpg" alt="Hudson City - Bank on better values." />' );
	else if( thisURL.indexOf( 'consloan' ) != -1 )
		document.write( '<img src="../images/header_consumer.jpg" alt="Hudson City - Bank on better values." />' );
	else if( thisURL.indexOf( 'hr' ) != -1 )
		document.write( '<img src="../images/header_career.jpg" alt="Hudson City - Bank on better values." />' );
	else
		document.write( '<img src="../images/header_contact.jpg" alt="Hudson City - Bank on better values." />' );
	
}



//usage: flash file name, width, height, relative path to the file
function placeFlash( swfName, width, height, path ) {
	if (typeof(AC_FL_RunContent) == 'undefined') {
		alert("This page requires AC_RunActiveContent.js.");
	} else {
		AC_FL_RunContent(
			'codebase', 'https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', width,
			'height', height,
			'src', path + swfName,
			'quality', 'high',
			'pluginspage', 'https://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'transparent',
			'devicefont', 'false',
			'id', path + swfName,
			'bgcolor', '#ffffff',
			'name', path + swfName,
			'menu', 'true',
			'allowFullScreen', 'false',
			'allowScriptAccess','sameDomain',
			'movie', path + swfName,
			'salign', ''
			); //end AC code
	}
	//document.write('<noscript><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'width'" height="'height'" id="'path + swfName'" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="movie" value="'path + swfName'.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" />	<embed src="'path + swfName'.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="'width'" height="'height'" name="'path + swfName'" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object></noscript>');
} //end function placeFlash()




//####### GLOBAL VARIABLES ########
var fiDomainName = "www.hcsbonline.com";
var fiName="Hudson City Savings Bank";
//###################################



var uri = document.location.href;
var redir = false;
if (window.secure)
{
	if(/^http:/.test(uri))
	{
		uri = uri.replace(/^http/,'https');
		redir = true;
	}
	/* make sure the 'www' is there */
	if(!/^https:\/\/www\./.test(uri))
	{
		uri = uri.replace(/^https:\/\//,'https://www.');
		redir = true;
	}
}
else
{
	if(/^https:/.test(uri))
	{
		uri = uri.replace(/^https/,'http');
		redir = true;
	}
	/* make sure the 'www' is there */
	if(!/^http:\/\/www\./.test(uri))
	{
		uri = uri.replace(/^http:\/\//,'https://www.');
		redir = true;
	}
};

// ## DOMAIN NAME SCRUBBER (NOT ALWAYS NEEDED) ##
/*
if (/www.hudsoncitysavingsbank.com/.test(uri) || /www.hcbk.com/.test(uri) || /www.hcsbnj.com/.test(uri) || /www.hudsoncitysavings.com/.test(uri) )
{
	uri = uri.replace(/www.hudsoncitysavingsbank.com/,'www.hcsbonline.com');
	uri = uri.replace(/www.hcbk.com/,'www.hcsbonline.com');
	uri = uri.replace(/www.hcsbnj.com/,'www.hcsbonline.com');
	uri = uri.replace(/www.hudsoncitysavings.com/,'www.hcsbonline.com');
	redir = true;
};
*/

if( uri.indexOf("/Forms/") == -1 && uri.indexOf("hcsbonlinedocs") == -1 ) {
	if( document.location.href.indexOf(fiDomainName) == -1 ) {
		uri = 'https://' + fiDomainName;
		redir = true;
	}
	if (redir) document.location.replace(uri);
}

window.onresize=resize;
function resize(){
//self.location.href=self.location.href;
}


// CALL TO CORRECT DIRECTORY BELOW
var imgdir = "../images/";
var sitedir = "";
var securedir = "";
var homedir = "../";
var localsitedir = "../../site/";

if( window.location.href.indexOf( '/Forms/' ) != -1 ) {
	sitedir = "https://www.hcsbonline.com/site/";
	imgdir = "https://www.hcsbonline.com/images/";
}

if(window.homepage)
{
	imgdir="images/";
	sitedir="site/";
	securedir="site/";
	homedir="";
}
else if(window.localpage)
{
	imgdir = "../images/";
	sitedir = "../site/";
	securedir = "../site/";
	homedir = "../";
}
else if(window.businesspage)
{
	imgdir = "../busimages/";
	sitedir = "../bussite/";
	securedir = "../bussite/";
	homedir = "../../";
}
else if(window.formpage)
{
	imgdir = "../images/";
	sitedir = "../site/";
	securedir = "../site/";
	homedir = "../";
}
else if(window.absolutepage)
{
	imgdir = "http://"+fiDomainName+"/images/";
	sitedir = "http://"+fiDomainName+"/site/";
	securedir = "http://"+fiDomainName+"/site/";
	homedir = "http://"+fiDomainName+"/";
}
else if(window.securepage)
{
	imgdir = "https://"+fiDomainName+"/images/";
	sitedir = "http://"+fiDomainName+"/site/";
	securedir = "https://"+fiDomainName+"/site/";
	homedir = "http://"+fiDomainName+"/";
}
// CALL TO CORRECT DIRECTORY ABOVE

// for Cool Menus
if(window.event + "" == "undefined") event = null;
function showMenu(){return false};
oM = {mout:function(){return false;}};

function target_blank(url){
    tmp = window.open(url);
    tmp = null;
}

function openPDF(name)
{
	internalPopup(sitedir + '../documents/' + name, 600, 800);
}

function internalPopup(url, height, width, opts){
	var wide = parseInt(width);
	var tall = parseInt(height);
    var halfwide = (wide/2);
    var halftall = (tall/2);
    var pWidth = (((parseInt(screen.width) / 2)) - halfwide);
    var pHeight = (((parseInt(screen.height) / 2)) - halftall);
    var features = opts || 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1';
	features += ',width='+wide+',height='+tall+',top='+pHeight+',left='+pWidth;
    window.open(url,'internalpopup',features);
}

function popup(url, height, width, disclaimer){
	var disclaimer = parseInt(disclaimer);
	var wide = parseInt(width);
	var tall = parseInt(height);
	var halfwide = (wide/2);
	var halftall = (tall/2);
	var pWidth = (((parseInt(screen.width) / 2)) - halfwide);
	var pHeight = (((parseInt(screen.height) / 2)) - halftall);
	var features = 'toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1,width='+wide+',height='+tall+',top='+pHeight+',left='+pWidth;
	if (disclaimer)
		showWarning("javascript:void(window.open('"+url+"','externalpopup','"+features+"'))", url, false, disclaimer)
	else
		window.open(url,'externalpopup',features);
}

function openDisc(page){
	var pWidth = (((parseInt(screen.width) / 2)) - 300)
	var pHeight = (((parseInt(screen.height) / 2)) - 400)
	bWindow = window.open(page,'discwin',"scrollbars=1,toolbar=0,location=0,directories=0,status=0,menubar=0,width=600,height=600,top=" + pHeight + ",left=" + pWidth);
	bWindow = null;
}


/************************************************************************************************************
* This function is used in the onclick of the a tag to display the external site warning. 
* @param msg - Integer specifying the which message to display.
* @param lk - The a link object
* Usage: <a href="http://wwww.mysite.com" onclick="return displayThirdPartyAlert(1,this);">My Site</a>
**************************************************************************************************************/
function displayThirdPartyAlert(msg,lk){
	var description = lk.innerHTML;
	if(description.indexOf('alt="') != -1){
		var x = description.indexOf('alt="')+5;
		var temp = description.substring(x);
		description = temp.substring(0,temp.indexOf("\""));
	}
	showWarning(lk.href, description, lk.target, msg)
	return false;
}

/************************************************************************************************************
* This function is used in the href of the a tag to display the external site warning. 
* @param lk - The url of the site to be opened
* @param desc - The description of the site to be opened, i.e. the name of the site.
* @param target - Allows for the window to opened in a new window
* @param msg - Integer specifying the which message to display.
* Usage: <a href="javascript:showWarning('http://wwww.mysite.com');">My Site</a>
**************************************************************************************************************/

function showWarning(lk, desc, target, msg){
	desc = (desc) ? desc : "Third Party Site";
//	target = (target) ? target : "_blank";
	msg = (msg) ? msg : 0;
	
	var messages = new Array(6);
	// Standard 3rd Party Warning
	messages[0] = messages[1] = '<h2 style="text-align:center">Third Party Site Disclaimer</h2><p>You are leaving Hudson City Savings Bank\'s website. Information you subsequently view has not been prepared by and does not belong to Hudson City Savings Bank. Any information, products, and services accessed through third party sites are not provided or guaranteed by Hudson City Savings Bank . The site you are about to visit may have a privacy policy that is different than Hudson City Savings Bank\'s. Please review their privacy policy. Hudson City Savings Bank does not endorse the content contained in these sites, nor the organizations publishing those sites, and disclaims any responsibility for such content.</p>';
	// Standard Partner Warning
	messages[2] = '<h2 style="text-align:center">Partner Site Disclaimer</h2><p>By accessing the noted link you will be leaving our website and entering a partner site which is hosted by another party. Please be advised that you will no longer be subject to, or under the protection of, the privacy and security policies of our website. We encourage you to read and evaluate the privacy and security policies of the site which you are entering, which may be different than those of ours.</p>';
	// Standard Affiliate Warning
	messages[3] = '<h2 style="text-align:center">Affiliate Site Disclaimer</h2><p>By accessing the noted link you will be leaving our website and entering an affiliate site located which is hosted by another party. Please be advised that you will no longer be subject to, or under the protection of, the privacy and security policies of our website. We encourage you to read and evaluate the privacy and security policies of the site which you are entering, which may be different than those of ours.</p>';
	// Customize if requested
	messages[4] = messages[0];
	// Standard mailto: Insecure Warning
	messages[5] = '<h2 style="text-align:center">Email Disclaimer</h2><p>This is <strong>NOT</strong> a secured e-mail transmission. Please <strong>do not send personal/financial information</strong> via this method.</p>';

	var content = new Array();
	var index = 0;
	content[index++] = messages[msg];
	content[index++] = '<div style="margin-top:1em;text-align:center"><a href="'+lk+'"'+(target?' target="'+target+'"':'')+' onclick="$(\'#ex_dis\').hide()">Continue</a>&#160;&#160;<a href="#" onclick="$(\'#ex_dis\').hide();return false;">Decline</a></div></div>';	
	$("#ex_dis").html(content.join("")).show();
	scrollTo(0,0);
}

function getUrl(){
	var url = document.location.href;
	var urlstart = url.indexOf("newUrl=") + 7;
	var urlToReturn = url.substring(urlstart);
	return urlToReturn;
}

document.write('<div id=\"ex_dis\" style=\"background-color: #ffffff; font-family: Arial, Helvetica, sans-serif; font-size: 8pt; font-weight: normal; color: #000000; text-align: left; position:absolute; top:125px; left:300px; border: thin solid #000000; padding: 15px; display: none; z-index: 3000; width:350px;\"></div>');


function browserTest() {
	window.open("https://www.hcsbonline.com/onlineserv/HB/BrowserTest.cgi","btwin","width=800,height=600,resizable,scrollbars");
}
