// stuff inside here will run when the DOM is ready
// onload replacement
$(function(){
	// Optimize the selector below. I.E. "ul.rollover" or even better "#navContainer".
	// It will be much faster!
	$('.rollover').rollovers();
});

/*
//Disable right mouse click Script
//By Maximus (maximus@nsimail.com)
//For full source code, visit http://www.dynamicdrive.com

var message="Copyright Sun National Bank";
///////////////////////////////////
function clickIE() {if (document.all) {alert(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {alert(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")
*/

// 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;
}

/************************************************************************************************************
* 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: &lt;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: &lt;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);
    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>';
    messages[2] = '<h2 style="text-align:center">Partner Site Disclaimer</h2><p>You are now leaving Sun National Bank and are being transferred to a trusted partner site.  Please review their security and privacy policy as they may differ from Sun National Bank\'s.</p>';
    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>';
    messages[4] = '<h2 style="text-align:center">Custom</h2><p>Please contact Digital Insight to have this message modified.</p>';
    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++] = '<br /><br /><br />';
	content[index++] = '<div 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 navAppIFrame(){

    if(!document.getElementById)return;
    url = document.location.href;
    formName = url.match(/type=([^#&]+)/);
    if(!formName || !formName[1]){
        fName = 'Loan';
    }
    else
        fName = formName[1];
    
    objFrame = document.getElementById("formFrame");
    objFrame.src = objFrame.src + "&type=" + fName;
}

// Rollovers jQuery Plugin

// privatize context and provide $ shortcut 
(function($){
	
	/**
	 * Will cause all image tags or input[@type="image"] elements inside of the selected
	 * elements to be made into rollovers if their source contains the string "_off" just
	 * before the image extension.
	 *
	 * @example $('div.rollovers').rollover();
	 * @before &lt;div class="rollover">&lt;img src="products_off.gif"/>&lt;/div>
	 * @after //when cursor is hovering over the image
	 *        &lt;div class="rollover">&lt;img src="products_on.gif"/>&lt;/div>
	 * @desc Will cause all &lt;img/> or &lt;input type="image"/> tags with an src attrib which contains
	 *       "_off" to have mouseover and mouseout handlers added that will change the image to
	 *       replace "_off" with "_on" in the image name. The "_off" has to be right before the
	 *       image extension.
	 *
	 * @param Object containing values to override defaults
	 *
	 * @type jQuery
	 * @cat Plugins/Rollovers
	 * @author Paul McLanahan <paul dot mclanahan at diginsite>
	 */
	$.fn.rollovers = function(opts){
		// default options
		var settings = $.extend({
				off : '_off', // string to look for in the src attrib
				on : '_on' // string to replace the off setting with in the src attrib
			},opts);
		return this.each(function(){
			var root = this;
			root.opts = settings;
			$('img,input[@type="image"]',this).filter('[@src*="'+root.opts.off+'."]').each(function(){
				el = this;
				// using Image objects for both so IE will preload correctly.
				el.overObj = new Image();
				el.outObj = new Image();
				el.outObj.src = el.src;
				el.overObj.src = el.src.replace(new RegExp(root.opts.off+"\.([a-z]{3,4})$",'i'),root.opts.on+".$1");
			}).hover(
				function(){ // mouseover
					this.src = this.overObj.src;
				},
				function(){ // mouseout
					this.src = this.outObj.src;
				}
			);
		});
	};

})(jQuery);

//end of file