// stuff inside here will run when the DOM is ready
// onload replacement
$(function(){
	// Uncomment and Optimize the selector below. I.E. "ul.rollover" or even better "#navContainer".
	// It will be much faster!
	// $('.rollover').rollovers();
});

// 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 wcInternalPopup(url, height, width){
	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=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width='+wide+',height='+tall+',top='+pHeight+',left='+pWidth;
    window.open(url,'internalpopup',features);
}

function wcPopup(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;
}


function openPDF(page){
	bWindow = window.open('fiFiles/static/documents/'+page);
	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>By accessing the noted link, you will be leaving Heartland Bank Direct\'s Web site and entering a website hosted by another party. <br /><br />Please be advised that by continuing to this party\'s site, you will no longer be subject to, or under the protection of, the privacy and security policies of Heartland Bank Direct\'s Web site. We encourage you to read and evaluate the privacy and security policies of the site you are entering, which may be different than those of Heartland Bank Direct.</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 Web site and entering a partner site hosted by another party. <br /><br />Please be advised that by continuining to this partner site, you will no longer be subject to, or under the protection of, the privacy and security policies of our Web site. 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 Heartland Bank Direct.</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 Web site and entering an affiliate site hosted by another party.<br /><br />Please be advised that you will no longer be subject to, or under the protection of, the privacy and security policies of our Web site. 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 Heartland Bank Direct.</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. For your own protection, please do <strong>NOT</strong> send personal or financial information 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;
}


function switch_div(source_id,target_id)
{
    var content = document.getElementById(source_id).innerHTML
	   
    document.getElementById(target_id).innerHTML = content;
    document.getElementById(target_id).style.display = "block";
	
}


/*****************************************************************************\
 * FAQ/Help section functions
 * The following two functions were written to function based on the DOM 
 * hierarchy, not using IDs,  so it's easier to add new sections and questions 
 *(no renumbering of IDs, etc.)
 * 
 * IMPORTANT:  If you mess with the hierarchy of elements in the XHTML snippet,
 * you will likely break the functionality.  Follow the pattern below.
 *
 * The format in faq.xhtml and help.xhtml is as follows: 
 *
 * <h3> <a onclick="toggle_div(this);">Section Name</a> </h3>
 * <div>
 *     <p> <a onclick="toggle_div(this);"> Question </a> </p>
 *     <div> Answer </div>
 *     .
 *     .
 *     .
 *     <p class="expand"><a onclick="toggle_all(this);">Expand All</a></p>
 *  </div>
 *  
 *  <h3> <a onclick="toggle_div(this);">Section Name</a> </h3>
 *  <div>
 *     <p> <a onclick="toggle_div(this);"> Question </a> </p>
 *     <div> Answer </div>
  *    .
 *     .
 *     .
 *     <p class="expand"><a onclick="toggle_all(this);">Expand All</a></p>
 *  </div>
 *
 \****************************************************************************/


/** 
 * This function is used to hide or display a particular <div>.
 * If it is currently hidden, it will display.  If it is currently showing, it will be hidden.
 *
 * @param elem - The anchor element that was clicked
 */
function toggle_div(elem)
{
    /* 
     * --- Example question/answer pair taken from faq.xhtml ---
     * 
     * <p class="q" onclick="toggle_div(this);"><a href="javascript:void(0);">Are There Any Fees or Minimum Balances?</a></p>
     * <div class="answer">
     *     <p>While there is a $500 minimum opening balance requirement, there are no fees on normal transactions or deposits and no charge if your account balance falls below $500 after opening.</p>
     * </div>
     * 
     * --- end Example ---
     * 
     * elem is the <p> which called this function
     * next() returns the <div class="answer">
     */

    var answerDiv = $(elem).next();
    var p = $(elem);
    
    if (answerDiv.css("display") == "block") {
        p.css('background', 'url(diFiles/skins/default/images/bg_arrow.gif) no-repeat 0 4px;');
    } else {
        p.css('background', 'url(diFiles/skins/default/images/bg_arrow_down.gif) no-repeat 0 4px;');
    }
    
    // if hidden, slideDown and display the answer <div>... if showing, slideUp and disappear
    answerDiv.slideToggle("slow");
}


/** 
 * This function is used to hide or display all answers in the same section as 
 * the clicked "Expand All" or "Collapse All" link
 *
 * @param elem - The anchor element that was clicked
 */
function toggle_all(elem)
{
    // The link with text "Expand All" or "Collapse All" ... first child element of 'elem' (<p>) that was clicked 
    var link = $(elem).children().eq(0);
    
    // If the link text was "Expand All", then display all subsections (answers) for the section
    if (link.text() == "Expand All") {
        /* The <a> that was clicked is within either a <p> or <h3>, which are on
           the same level as the <div>s we want to hide.  So get the "div"
           siblings of the parent, call slideDown() on each, and change the 
           background image to the DOWN arrow. 
         */
        $(elem).siblings("div").each( function(n) {
            $(this).prev().css('background', 'url(diFiles/skins/default/images/bg_arrow_down.gif) no-repeat 0 4px;');
            $(this).slideDown("slow");
        });
        /* Since we just expanded all the divs, change the text to Collapse All */
        link.text("Collapse All");
    } else { // If the link text was "Collapse All", then hide all subsections (answers) for the section
        /* The <a> that was clicked is within either a <p> or <h3>, which are on
           the same level as the <div>s we want to hide.  So get the "div"
           siblings of the parent, call slideUp() on each, and change the
           background image to the HORIZONTAL arrow.
         */
        $(elem).siblings("div").each( function(n) {
            $(this).prev().css('background', 'url(diFiles/skins/default/images/bg_arrow.gif) no-repeat 0 4px;');
            $(this).slideUp("slow");
        });
        /* Since we just collapsed all the divs, change the text to Expand All */
        link.text("Expand All");
    }
}
  

// ofcourse while this does work , assoc. arrays are not very kosher in js; instead one could use objects - cs
// btw - this is for the graphic SD trix , hehehe.

var numbers_array_big = new Array(10);
numbers_array_big[0] = "rates_0.gif";
numbers_array_big[1] = "rates_1.gif";
numbers_array_big[2] = "rates_2.gif";
numbers_array_big[3] = "rates_3.gif";
numbers_array_big[4] = "rates_4.gif";
numbers_array_big[5] = "rates_5.gif";
numbers_array_big[6] = "rates_6.gif";
numbers_array_big[7] = "rates_7.gif";
numbers_array_big[8] = "rates_8.gif";
numbers_array_big[9] = "rates_9.gif";
numbers_array_big["."] = "rates_decimal.gif";



var numbers_array_small = new Array(10);
numbers_array_small[0] = "rates_small_0.gif";
numbers_array_small[1] = "rates_small_1.gif";
numbers_array_small[2] = "rates_small_2.gif";
numbers_array_small[3] = "rates_small_3.gif";
numbers_array_small[4] = "rates_small_4.gif";
numbers_array_small[5] = "rates_small_5.gif";
numbers_array_small[6] = "rates_small_6.gif";
numbers_array_small[7] = "rates_small_7.gif";
numbers_array_small[8] = "rates_small_8.gif";
numbers_array_small[9] = "rates_small_9.gif";
numbers_array_small["."] = "rates_small_decimal.gif";



//end of file