/*************************************
 *
 * Redirect Script
 *
 */
 /*
var uri = document.location.href;
var newUri = false;

if (window.secure)
{
	//make sure we're at https:
	if(/^http:/.test(uri)){
		uri = uri.replace(/^http/,'https');
		newUri = true;
	}
	// make sure the 'www' is there 
	// The line below works for Staging but breaks Live
	//if(!/^http:\/\/www\./.test(uri)&&!/staging/.test(uri)){
	if(!/^http:\/\/www\./.test(uri)){
	   //uri = uri.replace(/^https:\/\//,'https://www.');
	   //newUri = true;
	}
}
else
{
	// make sure we're at http:
	if(/^https:/.test(uri)){
		uri = uri.replace(/^https/,'http');
		newUri = true;
	}
	// make sure the 'www' is there
	// The line below works for Staging but breaks Live
	//if(!/^http:\/\/www\./.test(uri)&&!/staging/.test(uri)){
	if(!/^http:\/\/www\./.test(uri)){
	   //uri = uri.replace(/^http:\/\//,'http://www.');
	   //newUri = true;
	}
}

// redirect
if(newUri) document.location.replace(uri);
*/
var uri = document.location.href;
var redir = false;

if (uri.indexOf('staging') < 0)
{
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.YOURFIDOMAIN.com/.test(uri))
{
	uri = uri.replace(/www.YOURFIDOMAIN.com/,'www.YOURFIDOMAIN.com');
	redir = true;
};
*/

if (redir) document.location.replace(uri);

/***************************************/



function wc_testForDemo(URL)
 {
    if(document.cookie.indexOf('demo') != -1)
    {
        var exit_demo = confirm("In order to proceed, you must first exit the demo.  Would you like to exit the demo?");
        if (exit_demo)
        {
            expireDate = new Date("January 1, 1970");
            var kill_string1 = "cookie_check=invalid;expires=" + expireDate.toGMTString() + "; path=/";
            document.cookie = kill_string1;
            var kill_string2 = "demo=stub;expires=" + expireDate.toGMTString() + "; path=/";
            document.cookie = kill_string2;
            window.location.href="index.html";
        }
        else
        {
            window.location.href="index.html?demo";
        }
    }
    else
    {
            window.open(URL);
    }
 }
 
 
 
 
 function target_blank(url){
    tmp = window.open(url);
    tmp = null;
}

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

/************************************************************************************************************
* 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>
**************************************************************************************************************/
var content2;
function showWarning(lk, desc, target, msg){
	
	fiName = "The Nekoma State Bank";
	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 '+fiName+'\'s website and entering a website hosted by another party. '+fiName+' has not approved this as a reliable partner site. Please be advised that you will no longer be subject to, or under the protection of, the privacy and security policies of '+fiName+'\'s website. 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 '+fiName+'.</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>';	
	
	$("#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 isBusiness(sharedName) {
	if (location.href.indexOf( 'business' ) > -1)
		return true;
}
 
 /**
  *
  * This function displays a specific header image or back page image on a shared page.
  * Currently the only shared pages are personal and business.
  *
  */
 function writeSharedContent( sharedName, contentType ) {
 	var hedName;
	var hedAlt;
	var backName;
	if( isBusiness() ) {
		hedName = 'bus';
		hedAlt = 'Business';
		backName= 'business';
	}
	else {
		hedName = 'pers';
		hedAlt = 'Personal';
		backName= 'pers';
	}
 	if( contentType == 'hed' )
		document.write('<img src="../images/hed_'+hedName+'.gif" width="715" height="63" alt="'+hedAlt+'" />');
	if( contentType == 'backImg' )
		document.write('<img width="206" height="216" alt="" src="../images/img_'+backName+'.jpg"/>');
 }
 
 
/** 
 *
 * This function displays a DHTML nav image as on or off
 *
 */
function writeNavImage( contentType ) {
	if( contentType == 'pers' ) {
		if( isBusiness() )
			document.write('<img src="../images/nav_pers_off.gif" width="96" height="28" alt="Personal" name="personal" />');
		else
			document.write('<img src="../images/nav_pers_on.gif" width="96" height="28" alt="Personal" name="personal" />');
	}
	else {
		if( isBusiness() )
			document.write('<img src="../images/nav_bus_on.gif" width="98" height="28" alt="Business" name="business" />');
		else
			document.write('<img src="../images/nav_bus_off.gif" width="98" height="28" alt="Business" name="business" />');
	}
}

  
function writeMMSection() {
 	if ( isBusiness() ) {
		document.write( '<ul><li><a href="business_checking.html">Business Checking</a></li><li><a href="personal_moneymarket.html?business" id="on">Preferred Money Market Account</a></li><li><a href="personal_savings.html?business">Savings Account</a></li><li><a href="personal_certificate.html?business">Certificate of Deposit</a></li><li><a href="personal_cardservices.html?business">Card Services</a></li></ul>' );
	}
	else {
		document.write( '<ul><li><a href="personal_checking.html">Personal Checking</a><ul><li><a href="personal_checking_regular.html">Regular Checking</a></li><li><a href="personal_checking_select.html">Select Checking</a></li><li><a href="personal_checking_now.html">NOW Account</a></li></ul></li><li><a href="personal_savings.html">Savings Account</a></li><li><a href="personal_certificate.html">Certificate of Deposit</a></li><li><a href="personal_moneymarket.html" id="on">Preferred Money Market Account</a></li><li><a href="personal_ira.html">IRAs</a></li><li><a href="personal_cardservices.html">Card Services</a></li><li><a href="http://www.nekomasb.com/bridge/GRP/mvbpp_flash_demo/" target="_blank">Bill Pay</a></li><li><a href="personal_other.html">Other Services</a><ul><li><a href="personal_other_visa.html">Visa Gift Card</a></li><li><a href="personal_other_safedeposit.html">Safe Deposit Box</a></li></ul></li></ul>' );
	}
}

function writeSavingsSection() {
 	if ( isBusiness() ) {
		document.write( '<ul><li><a href="business_checking.html">Business Checking</a></li><li><a href="personal_moneymarket.html?business">Preferred Money Market Account</a></li><li><a href="personal_savings.html?business" id="on">Savings Account</a></li><li><a href="personal_certificate.html?business">Certificate of Deposit</a></li><li><a href="personal_cardservices.html?business">Card Services</a></li></ul>' );
	}
	else {
		document.write( '<ul><li><a href="personal_checking.html">Personal Checking</a><ul><li><a href="personal_checking_regular.html">Regular Checking</a></li><li><a href="personal_checking_select.html">Select Checking</a></li><li><a href="personal_checking_now.html">NOW Account</a></li></ul></li><li><a href="personal_savings.html" id="on">Savings Account</a></li><li><a href="personal_certificate.html">Certificate of Deposit</a></li><li><a href="personal_moneymarket.html">Preferred Money Market Account</a></li><li><a href="personal_ira.html">IRAs</a></li><li><a href="personal_cardservices.html">Card Services</a></li><li><a href="http://www.nekomasb.com/bridge/GRP/mvbpp_flash_demo/" target="_blank">Bill Pay</a></li><li><a href="personal_other.html">Other Services</a><ul><li><a href="personal_other_visa.html">Visa Gift Card</a></li><li><a href="personal_other_safedeposit.html">Safe Deposit Box</a></li></ul></li></ul>' );
	}
}

function writeCDSection() {
 	if ( isBusiness() ) {
		document.write( '<ul><li><a href="business_checking.html">Business Checking</a></li><li><a href="personal_moneymarket.html?business">Preferred Money Market Account</a></li><li><a href="personal_savings.html?business">Savings Account</a></li><li><a href="personal_certificate.html?business" id="on">Certificate of Deposit</a></li><li><a href="personal_cardservices.html?business">Card Services</a></li></ul>' );
	}
	else {
		document.write( '<ul><li><a href="personal_checking.html">Personal Checking</a><ul><li><a href="personal_checking_regular.html">Regular Checking</a></li><li><a href="personal_checking_select.html">Select Checking</a></li><li><a href="personal_checking_now.html">NOW Account</a></li></ul></li><li><a href="personal_savings.html">Savings Account</a></li><li><a href="personal_certificate.html" id="on">Certificate of Deposit</a></li><li><a href="personal_moneymarket.html">Preferred Money Market Account</a></li><li><a href="personal_ira.html">IRAs</a></li><li><a href="personal_cardservices.html">Card Services</a></li><li><a href="http://www.nekomasb.com/bridge/GRP/mvbpp_flash_demo/" target="_blank">Bill Pay</a></li><li><a href="personal_other.html">Other Services</a><ul><li><a href="personal_other_visa.html">Visa Gift Card</a></li><li><a href="personal_other_safedeposit.html">Safe Deposit Box</a></li></ul></li></ul>' );
	}
}

function writeCSSection() {
 	if ( isBusiness() ) {
		document.write( '<ul><li><a href="business_checking.html">Business Checking</a></li><li><a href="personal_moneymarket.html?business">Preferred Money Market Account</a></li><li><a href="personal_savings.html?business">Savings Account</a></li><li><a href="personal_certificate.html?business">Certificate of Deposit</a></li><li><a href="personal_cardservices.html?business" id="on">Card Services</a></li></ul>' );
	}
	else {
		document.write( '<ul><li><a href="personal_checking.html">Personal Checking</a><ul><li><a href="personal_checking_regular.html">Regular Checking</a></li><li><a href="personal_checking_select.html">Select Checking</a></li><li><a href="personal_checking_now.html">NOW Account</a></li></ul></li><li><a href="personal_savings.html">Savings Account</a></li><li><a href="personal_certificate.html">Certificate of Deposit</a></li><li><a href="personal_moneymarket.html">Preferred Money Market Account</a></li><li><a href="personal_ira.html">IRAs</a></li><li><a href="personal_cardservices.html" id="on">Card Services</a></li><li><a href="http://www.nekomasb.com/bridge/GRP/mvbpp_flash_demo/" target="_blank">Bill Pay</a></li><li><a href="personal_other.html">Other Services</a><ul><li><a href="personal_other_visa.html">Visa Gift Card</a></li><li><a href="personal_other_safedeposit.html">Safe Deposit Box</a></li></ul></li></ul>' );
	}
}
