//divDisplay Function
//This function has two variables 'divName' which is a string name of 
//a div elements id name. 'displayContent is a string name of a div element
//id name nested within 'divName'. 
//This function will search within a page for a div element with id "divName"
//once the "divName" is found the function will then loop through all the 
//div elements nested within "divName". Within the element "divName" every
//nested div will be hidden except for the div with id equal to 'displayContent" 
function divDisplay(divName, displayContent)
	{
	 
	 if( document.getElementById )//check if the browers understands 'getElementById'
	 {
	 	 if( document.getElementById(divName) ) //check if there is a element with id 'divName'
		 {
		 	var displayDiv = document.getElementById(divName); //get the div element with the name 'divName'
		 	
			if( displayDiv.getElementsByTagName('div') ) // check if valid getElementsByTagName  
		 	{
				
				var divCollection = displayDiv.getElementsByTagName('div'); //get the collection of div's inside 'displayDiv'
				
				 for(var x=0; x < divCollection.length; x++)//loop through the 'divCollection' 
				 {
					if(divCollection[x].getAttribute("id") == displayContent)//check if the 'div' element has id equal to 'displayContent' 
						{
							divCollection[x].style.display = "block"; //display the div equal to 'displayContent'
							divCollection[x].style.visibility = "visible";
						}//end if
						else
						{	
							divCollection[x].style.display = "none"; //hide all div's not equal to 'displayContent'
							divCollection[x].style.visibility = "hidden";
						}//end else
				 }// end for loop
			
			
			}// end check if valid getElementsByTagName 
		
		 }// end check if there is a element with id 'divName'
	 }// end check if the browers understands 'getElementById'
	 
	}//end divDisplay

function goToAutoArm(url) {
 if (confirm("You are now leaving El Dorado Savings Bank’s (EDSB) web site and are being redirected to "+url+"\n\nThe web site you have selected is external to our site. EDSB has no responsibility for external web sites."))
 {
 AutoArm = window.open(url, "AutoArm", "toolbar=yes,menubar=yes,location=yes,status=yes,scrollbars=yes,resizable=yes,width=950,height=500,left=25,top=25");

 }
}
function leaveSite(url) {
 if (confirm("You are now leaving El Dorado Savings Bank’s (EDSB) web site and are being redirected to "+url+"\n\nThe web site you have selected is external to our site. EDSB has no responsibility for external web sites."))
 {
 newwindow = window.open(url,"_blank", "toolbar=yes,menubar=yes,location=yes,status=yes,scrollbars=yes,resizable=yes,width=950,height=500,left=25,top=25");

 }
}	
	function openPDF(pdf)
	{
		var windowName = "DefinitionWindow";
	    var params  = "";
	    params += "toolbar=0,";
	    params += "location=0,";
	    params += "directories=0,";
	    params += "status=0,";
	    params += "menubar=0,";
	    params += "scrollbars=0,";
	    params += "resizable=1,";
	    params += "width=800,";
	    params += "height=600";

	   window.open(pdf, windowName, params);	
	}
	
	function openContactUs(contact)
	{
		var windowName = "DefinitionWindow";
	    var params  = "";
	    params += "toolbar=0,";
	    params += "location=0,";
	    params += "directories=0,";
	    params += "status=0,";
	    params += "menubar=0,";
	    params += "scrollbars=0,";
	    params += "resizable=1,";
	    params += "width=505,";
	    params += "height=595";

	   window.open(contact, windowName, params);	
	}
	
// **********************************************
// **********************************************
// **********************************************
// **********************************************
// **********************************************
// **********************************************
//CONTACT US FORM SECTION//
	

/**************************************************************/
/**************************************************************/
/*   THIS SECTION SHOULD BE THE ONLY AREA THAT NEEDS EDITING  */
/**************************************************************/
/**************************************************************/
	//Requirements
	//1. The form that is submitted must be called "frmMain"
	//2. The span tag that will be used to display error message must be named
	//exactly the same as its corresponding input box's name preceeded by "error_"
	//for example the required input box's name is "address" the span that will be used
	//to display the error message must have the ID value "error_address".
	
	
	function getRequiredArray()
	{
		order = ["email"]
				
		return order;
	}
	
	function getWriteError()
	{
		var error = "*Enter Email Address";
		return error;
	}
	function getInvalidError()
	{
		var error = "*Invalid Email Address";
		return error;
	}
	function getClearRequired()
	{
		var clear = "";
		return clear;
	}
	function getClearReset()
	{
		var required = "*Required";
		return required;
	}



	function writeApplet(writeWhat)
	{
		
		switch (writeWhat) {
			case "mortgageInner":
				writeMortgage('mortgageInner');
				break;
			case "loanInner":
				writeLoan('loanInner');
				break;
			case "investInner":
				writeInvest('investInner');
				break;
			case "retireInner":
				writeRetire('retireInner');
				break;
			case "savingsInner":
				writeSavings('savingsInner');
				break;
		}
		
	}//end writeApplet
		
		
	function writeMortgage(writeWhat)
	{
		if(document.getElementById(writeWhat)){
			document.getElementById(writeWhat).innerHTML = 
			'<iframe src="calculators\/Applet_MortgageCompare.html" height="475" width="550" frameborder="0"><\/iframe>' ;   
		}//then
	}//writeMortgage
	
	function writeLoan(writeWhat)
	{
		if(document.getElementById(writeWhat)){
			document.getElementById(writeWhat).innerHTML = 
			'<iframe src="calculators\/Applet_CompareLoan.html" height="475" width="550" frameborder="0"><\/iframe>' ;   
		}//then
	}//writeLoan
		
	function writeInvest(writeWhat)
	{
		if(document.getElementById(writeWhat)){
			document.getElementById(writeWhat).innerHTML = 
			'<iframe src="calculators\/Applet_InvestmentReturn.html" height="475" width="550" frameborder="0"><\/iframe>' ;   
		}//then
	}//writeInvest
	
	function writeRetire(writeWhat)
	{
		if(document.getElementById(writeWhat)){
			document.getElementById(writeWhat).innerHTML = 
			'<iframe src="calculators\/Applet_RetirementPlan.html" height="475" width="550" frameborder="0"><\/iframe>' ;   
		}//then
	}//writeRetire
	
	function writeSavings(writeWhat)
	{
		if(document.getElementById(writeWhat)){
			document.getElementById(writeWhat).innerHTML = 
			'<iframe src="calculators\/Applet_CompareSavings.html" height="475" width="550" frameborder="0"><\/iframe>' ;   
		}//then
	}//writeSavings
	
	function openSA(url)
	{
		
		var windowName = "DefinitionWindow";
	    var params  = "";
	    params += "toolbar=0,";
	    params += "location=0,";
	    params += "directories=0,";
	    params += "status=0,";
	    params += "menubar=0,";
	    params += "scrollbars=0,";
	    params += "resizable=1,";
	    params += "width=895,";
	    params += "height=525";

	   window.open(url, windowName, params);	
	}//end openVideo


//<a rel="external"></a> functionality (replaces target="_blank" for xhtml strict)
//better than window.open because window.open does not send reffering URL
externalLinks = function() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchorObj = anchors[i];
   if (anchorObj.getAttribute("href") &&
       anchorObj.getAttribute("rel") == "external")
     anchorObj.target = "_blank";
 }
}


//DROP DOWN MENU ACTIVATION
	activateMenu = function(nav) {
		/* currentStyle restricts the Javascript to IE only */
		if (document.all && document.getElementById(nav)) {  
        	var navroot = document.getElementById(nav);
        
        	/* Get all the list items within the menu */
			var lis=navroot.getElementsByTagName("LI");  
        	for (i=0; i<lis.length; i++) {
        		/* If the LI has another menu level */
            	if(lis[i].lastChild.tagName=="UL"){
                	/* assign the function to the LI */
             		lis[i].onmouseover=function() {	
                		/* display the inner menu */
                		this.lastChild.style.display="block";
                	}//end function
                	lis[i].onmouseout=function() {   
                		this.lastChild.style.display="none";
            		}//end function					
       			}//end if
        	}//end for
    	}//end outer if	
		}//end function
		
		
//ON LOAD FUNCTIONS
window.onload = function() {
//	startList(); 		//start drop down menu
	externalLinks();	//<a rel="external"></a> functionality (replaces target="_blank" for xhtml strict)	
	activateMenu('nav');
	//activateMenu('subnav');
}

//EMERGENCY MESSAGE POPUP FUNCTION
  function openPopup(url)
	{
	
	popUp = window.open(url, "Disclaimer","width=530,height=400,left=50,top=50,status=no,resizable=yes,toolbar=no,scrollbars=yes,menubar=no,location=no");
	popUp.focus();
	}
