// JavaScript Document

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

function bobtInternalPopup(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 bobtPopup(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 openWindow(url,name,stuff) {
	window.open(url,name,stuff);
}

/*****
* Used in the onclick of the a tag to display the external site warning. 
* @param msg - Specifies message to display.
* @param lk - Link object
* Usage: <a href="http://wwww.website.com" onclick="return displayThirdPartyAlert(1,this);">Website</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;
}

/*****
* Used in the href of the a tag to display the external site warning. 
* @param lk - Url of the site to be opened
* @param desc - Description of the site to be opened, (name of site).
* @param target - Allows for the window to opened in a new window
* @param msg - Specifies which message to display.
* Usage: <a href="javascript:showWarning('http://wwww.website.com');">website</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 Third Party Warning from secured page - refer 1
	messages[0] = messages[1] = '<p align="center"><img src="'+fiDir+'/logoSmall.png" /></p><p style="text-align:center">You are leaving the BankofBirchTree.com secured site<br />to visit a 3<sup>rd</sup> party resource site.</p>';
	// Standard Third Party Warning - refer 2
	messages[2] = '<p align="center"><img src="'+fiDir+'/logoSmall.png" /></p><h3 style="margin-bottom:6px;">Third Party Site Disclaimer</h3><p style="margin-top:0px;">If you continue, you will be connected to a third-party website that may be of interest to you. Bank of Birch Tree does not own or operate the linked sites. These sites may not adhere to the same privacy policies and standards as Bank of Birch Tree. Please review the privacy policy at each site. Bank of Birch Tree is not responsible for the content on this third party site. Bank of Birch Tree does not warrant linked sites under any circumstance.<br /></p>';
	// Standard Affiliate Warning - refer 3
	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 - refer 5
	messages[5] = '<p align="center"><img src="'+fiDir+'/logoSmall.png" /></p><h3 style="text-align:center">Email Disclaimer</h3><p>This is <strong>NOT</strong> a secured e-mail transmission. Please <strong>do not send personal, confidential, or financial information</strong> via this method.</p>';

	var content = new Array();
	var index = 0;
	content[index++] = messages[msg];
	if(msg < 3 ){ // After the last <br /> can add "when you are ready to return to us...
				content[index++] = '<div style="margin-top:1em;text-align:center"><a href="'+lk+'"'+(target?' target="'+target+'"':'')+' onclick="$(\'#ex_dis\').hide()">Continue</a>&nbsp;&nbsp;<a href="#" onclick="$(\'#ex_dis\').hide();return false;">Decline</a><br />';
	}else{
			content[index++] = '<div style="margin-top:1em;text-align:center"><a href="'+lk+'"'+(target?' target="'+target+'"':'')+' onclick="$(\'#ex_dis\').hide()">Continue</a>&nbsp;&nbsp;<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 sReplace(str)
{
	var result = (str == "") ? " " : str;
	
	while (result.indexOf("(br)") > -1) result = result.replace(/\(br\)/, "<br />");
	while (result.indexOf("(sup)") > -1) result = result.replace(/\(sup\)/, "<sup>");
	while (result.indexOf("(/sup)") > -1) result = result.replace(/\(\/sup\)/, "</sup>");
	while (result.indexOf("(bold)") > -1) result = result.replace(/\(bold\)/, "<strong>");
	while (result.indexOf("(/bold)") > -1) result = result.replace(/\(\/bold\)/, "</strong>");
	
	return result;
}

//end of file
