// JavaScript Document
//Function for external links
function external(address)
{
	var answer = confirm("You are now leaving The State Bank's Web site." + 
	"\n____________________________________________________________\n\n" + 
	"The site you are going to is not owned or controlled by us.\n" + 
	"We do not guarantee the products, information, or recommendations provided by the site.\n" + 
	"We are not liable for any failure of products or services advertised on the site.\n" +
	"It may have a different Privacy policy, cookie control, and security standards.\n" + 
	"To remain at our site, click Cancel.\n" +
	"To leave our site for the link you selected, click OK.\n" +
	"____________________________________________________________\n\n" + 
	"Thank you for visiting our site.");
	if (answer)
	{
		//window.location.href= address;
		window.open(address,"","location,menubar,resizable,scrollbars,status,toolbar");
	}
}
//Function to validate contact form
function validate()
{
	if (document.forms.contact.name.value == "" || document.forms.contact.comments.value == "") 
	{
		alert("Please fill in the \"Name\" and \"Comments\" fields before sending the form.");
	}
	else
	if (document.forms.contact.email.value != "")
	{
		if (document.forms.contact.email.value.indexOf("@") == -1)
		{
			email_error("No \"@\" in address");	
		}
		else
		if (document.forms.contact.email.value.indexOf(".") == -1)
		{
			email_error("No \".\" in address");
		}
		else
		{
			document.forms.contact.submit();
		}
	}
	else
	{
		document.forms.contact.submit();
	}	
}
//Function to display error message for invalid email addresses
function email_error(msg)
{
	alert("Email Address Error:\n" + msg + 
	"\n-----------------------------------------------------" + 
	"\nEmail Address should be in the following format:  \nusername@domain.com");
}
//Function to check the clients resolution
function check_resolution()
{
	var width = window.screen.width;
    var height = window.screen.height;
    if (width < 1024 && height < 768)
    {
		alert("This site is best viewed with a screen resolution of at least 1024x768\n" + 
		"Your current resolution appears to be " + width + "x" + height + "\n" + 
		"Some of the pages on this site may not appear correctly with this resolution");
	}
} 
//Function for forms background color on Focus
function doFocus(x,y)
{
	var oDiv = x.parentNode.parentNode;
	oDiv.style.background = (y) ? '#E8F0F9' : '#FFFFFF';
	x.className = (y) ? 'color' : '';				
}