var winWidth;
var winHeight;
var IsIe = false;
var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;

function Init()
{
	GetWindowSize();
	SetContent();
	changeImage();
    
	
	//Set handlers for window/mouse events
	window.onblur = register;
	window.oncontextmenu = register;
	window.onerror = register;
	window.onfocus = register;
	window.onscroll = register;
	window.onresize = register;
	window.onclick = register;
	window.onmousedown = register;
	window.onmouseup = register;
}

function register(e) {
	if(!e) e = window.event;
	if(e.type=='resize') {
		Resized();
	}
}

function Resized() {
	GetWindowSize();
	SetContent();
}

function GetWindowSize() {
 	var myWidth = 0, myHeight = 0;
 	
 	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
 	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
		IsIe = true;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
		IsIe = true;
	}
	//window.alert( 'Width = ' + myWidth );
	//window.alert( 'Height = ' + myHeight );
	winWidth = myWidth;
	winHeight = myHeight;
}


///////////////////////////////////////////////////////////////////////////////////////
//This function is used to adjust the height of the window
//and extend the left and right borders based on content height

function SetContent()
{
	oContent = document.getElementById("centercontent");
    
	//oContentMain = document.getElementById("center");
	//oLeft = document.getElementById("left");
	//oContent = document.getElementById("wrapper");
	
	
	oRightS = document.getElementById("rightShadow");
	oLeftS = document.getElementById("leftShadow");
	
	if (parseInt(oContent.offsetHeight) < 589) {
	    //oContent.style.height = "513px";
	    oContent.style.height = "589px";
		oRightS.style.height = oContent.offsetHeight + "px";
		oLeftS.style.height = oContent.offsetHeight + "px";
	}
	
    //	if (parseInt(oContent.offsetHeight) > oContentMain.offsetHeight)
    //	{
    //		oContentMain.style.height = oContent.offsetHeight + "px";
    //		oLeft.style.height = oContent.offsetHeight + "px";
    //		oLeftS.style.height = oContent.offsetHeight + "px";
    //		oRightS.style.height = oContent.offsetHeight + "px";
    //	}

	//if (oContentMain.offsetHeight > 589)
	if(oContent.offsetHeight > 589)
	{
		//oLeft.style.height = oContentMain.offsetHeight + "px";
		//oLeftS.style.height = (parseInt(oContentMain.offsetHeight) + 76) + "px";
	    //oRightS.style.height = (parseInt(oContentMain.offsetHeight) + 76) + "px";
	    oLeftS.style.height = (parseInt(oContent.offsetHeight) + 76) + "px";
	    oRightS.style.height = (parseInt(oContent.offsetHeight) + 76) + "px";
	}
}
///////////////////////////////////////////////////////////////////////////////////////////

function SearchFocus(obj, searchDefault) {
    if (obj.value == searchDefault)
    {
        obj.value='';
        obj.style.fontStyle='normal';
        obj.style.color='#000';
    }
    else
    {
        obj.select();
    }
}

function SearchBlur(obj, searchDefault) {
    if (obj.value == '')
    {
        obj.value=searchDefault;
        obj.style.fontStyle='italic';
        obj.style.color = 'gray';
    }
}


function showLang() {
    if (document.getElementById("currentLang").value = 'es') {
        document.getElementById("InSpanish").style.display = 'none';
        document.getElementById("InEnglish").style.display = 'block';
    } else if (document.getElementById("currentLang").value = 'en') {
        document.getElementById("InEnglish").style.display = 'none';
        document.getElementById("InSpanish").style.display = 'block';
    }

}


function getSpanish() {
    window.location.replace(document.URL.replace(/LangType=\d\d\d\d/g, '') + (document.URL.indexOf('?') > -1 ? '' : '?') + '&LangType=1034');
}

function getEnglish() {
    
    window.location.replace(document.URL.replace(/LangType=\d\d\d\d/g, '') + (document.URL.indexOf('?') > -1 ? '' : '?') + '&LangType=1033');
}



function imgSearch_onclick() {
    var redirectPage = "search.aspx?search=" + document.getElementById("txtSearch").value
	
    if (document.getElementById("txtSearch").value.length > 0 && document.getElementById("txtSearch").value != "Search BankPlus") { 
        document.location.href = redirectPage;
        //window.location.href = redirectPage;
    }
    
}

function SearchKey(e) {
    var keyNum;
    
    if (window.event)
        keyNum = e.keyCode;
    else if (e.which)
        keyNum = e.which;

    if (keyNum == 13) {
        //__doPostBack('imgSearch','');
        if (document.getElementById("txtSearch").focus) {
            return imgSearch_onclick();
		
        }
    }


//else{//alert(window.ifFAQ.document.getElementById("txtQuestion").value);
	//window.ifFAQ.document.getElementById("txtQuestion").value =  document.getElementById("txtSearch").value
	//}
	
}

function LocationKey(e) {
    var keyNum;
    if (window.event)
        keyNum = e.keyCode;
    else if (e.which)
        keyNum = e.which;

    if (keyNum == 13) {
        
        if (document.getElementById("txtLocations").focus) {
        	var redirectPage = "Locations.aspx?id=301&Zipcode=" + document.getElementById("txtLocations").value
            window.location.href = redirectPage;
        } else {
            alert('outside ')
        }
    }
}

function GoToMap() {
    var redirectPage = "Locations.aspx?id=301&Zipcode=" + document.getElementById("txtLocations").value + ",MS"
    window.location.href = redirectPage;
}

if (document.images) { 
img1on = new Image();
img1on.src = "images/orange_arrow.jpg"; 
img1off = new Image(); 
img1off.src = "images/spacer.gif"; 
img2on = new Image();
img2on.src = "images/orange_arrow.jpg"; 
img2off = new Image(); 
img2off.src = "images/spacer.gif"; 
img3on = new Image();
img3on.src = "images/orange_arrow.jpg"; 
img3off = new Image(); 
img3off.src = "images/spacer.gif"; 
}
function imgOn(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + "on.src");}
}
function imgOff(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + "off.src");}
}

function AssignIndex(val) {
    document.getElementById("ctl00_rightContent_ContentBlock5").innerHTML = " ";
    document.getElementById("ctl00_rightContent_hdnSelectedPaneID").value = val;
    var s = val
    
}
function showDiv() {
    
    //var accHost = $get("Myacc").AccordionBehavior;
    //alert($get("Myacc").AccordionBehavior);
    //document.getElementById("hdnSelectedPaneID").value = accHost.get_SelectedIndex();
    
    //document.getElementById("Benefitspopup").innerHTML = document.getElementById("ctl00_rightContent_ContentBlock5").innerHTML;
    //document.getElementById("Benefitspopup").style.visibility = "visible"
}

///////////////////////////////////////////////
//used in content in workarea under Financial tools onClick events of links  
//to pass the calculator link from FinTools.aspx to BpTimeValue.aspx
function getCal(x) {
    document.getElementById("txtCalSrc").value = x
    document.formCal.submit();

}
///////////////////////////////////////////////

function show_text(text,ele) {
	var xp, yp, op
	xp = ele.offsetLeft; // Element's offset x in pixels
	
	yp = ele.offsetTop; // Element's offset y in pixels

	// Now loop through all parent containers, adding offsets as we do so
	
	while (ele.offsetParent) {
	    //alert(ele.offsetLeft);
	    op = ele.offsetParent; // Get container parent
		xp = xp + op.offsetLeft;	// Add this element's offset x in pixels
		yp = yp + op.offsetTop;		// Add this element's offset y in pixels
		ele = ele.offsetParent; // Update current container
	}
	ent = document.getElementById("ent")	// Get the main element
	if (ent) {
		// Change these to customise your popup window
		//ent.style.color = "#000000";
		ent.style.padding = "5px 5px 5px 5px";
		ent.style.background = "#eee";
	    ent.style.border = "1px solid #007662";
		
		
		// Don't, however, change these
		ent.style.position = 'absolute';
		ent.style.left = (xp-10)+"px";
		ent.style.top = (yp-25)+"px";
		ent.innerHTML = text;
		ent.style.display = "block";
	}
}
// This clears the pop up element
function clear_text(ele) {
	ent = document.getElementById("ent")
	if (ent) {
		ent.style.display = "none";
		ent.innerHTML = "";
	}
}

function showDate() {
    alert(document.getElementById("ctl00_rightContent_hdnDate").value);
}

//**************************************************************************
//used in content in workarea under Financial tools onClick events of links  
//to pass the calculator link from FinTools.aspx to BpTimeValue.aspx
//value of txtCalSrc from formCal on BankPlus.master.aspx is passed to BpTimeValue.aspx.vb as the iframe src

function getCal(x) {
    document.getElementById("txtCalSrc").value = x
    document.formCal.submit();

}

//*****************************************************************************
//used to change the open close image on home page  
//hdnSes is set in BankPlus.Master.vb
function changeImage() {
    var ses = document.getElementById("ctl00_hdnSes").value //<%=Session('OpenClosedBrnch')%>;
    //alert(ses);
    if (ses == "Closed")
        document.getElementById("imgOpenClose").setAttribute("src", "images/Closed.jpg");

}



///*****************************************************************************
//this function is used on the imgOpenClose on home page

function redirectToLocations(){
	location.href='/locations.aspx?id=301&show7='
}

function showWarning(url){
var content = new Array();
var index = 0;
content[index++] = "<span style=\"font-size: 9pt; font-weight: bold;\">Third Party Site Disclaimer</span><br /><br />By clicking the continue button, you will be leaving the BankPlus website and entering a website hosted by another party. BankPlus 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 th";
content[index++] = "e privacy and security policies of the BankPlus website. We encourage you to read and evaluate the privacy and security policies of the site";
content[index++] = " you are entering, which may be differen";
content[index++] = "t from those of BankPlus.";

content[index++] = "<br /><br />";
content[index++] = "<div align=\"center\"><a href=\"javascript:void('0');\" onclick=\"window.open('"+url+"');document.getElementById('ex_dis').style.display = 'none'\">[ Continue ]</a> &nbsp;<a href=\"javascript:void('0');\" onclick=\"document.getElementById('ex_dis').style.display = 'none'\">[ Cancel ]</a></div></div>";
document.getElementById("ex_dis").innerHTML = content.join("");
document.getElementById("ex_dis").style.display = "block";
scrollTo(0, 0);
}

function showEmailWarning(mailtotag){
var content = new Array();
var index = 0;
content[index++] = "<h3 style='margin-bottom:3px; margin-top:3px;'>Email Warning</h3>Email over the internet is not a secure means of communication.  Please do not email any sensitive information, including, but not limited to, Social Security Numbers and Account Numbers.";
content[index++] = "<br />";
content[index++] = "<div align=\"center\"><a href=\"mailto:"+mailtotag+"\"      onclick=\"document.getElementById('ex_dis').style.display = 'none'\">Continue</a> &nbsp;<a href=\"javascript:void('0');\" onclick=\"document.getElementById('ex_dis').style.display = 'none'\">Decline</a></div></div>";	
document.getElementById("ex_dis").innerHTML = content.join("");
document.getElementById("ex_dis").style.display = "block";
scrollTo(0, 0);
}

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:2px; left:75px; border: thin solid #000000; padding: 10px; display: none; z-index: 3000; width:500px; height: 125px;"></div>');

