function isEmail(str)
{
 	var supported = 0;
 	if (window.RegExp)
	{
   		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) supported = 1;
  	}

	if (!supported) 
		return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);

	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,5}|[0-9]{1,3})(\\]?)$");
	
	var valid = (!r1.test(str) && r2.test(str));
	
	if (valid == false)
		alert("'"+str+"'" + " is not a valid Email address");

	return valid;

}

function addbookmark()
{ 
	general="First click OK and then hit CTRL+D to bookmark this page.";
	opera="First click OK and then hit CTRL+T to bookmark this page.";
	if ((navigator.userAgent).indexOf("Opera")!=-1)
		alert(opera); 
	else
		alert(general); 
}

function popup(w, h, url) {
	window.open(url,"_blank",'width='+w+',height='+h+',scrollbars=yes,status=no,menubar=no,location=no,resizable=no');
}

function revealanswer(question) {
	p = question.getElementsByTagName('P');
	
	if (p[1].style.display == 'none' || p[1].style.display == '')
		p[1].style.display = 'block';
	else
		p[1].style.display = 'none';
		
	return false;
}

function hideanswer(answer) {
	answer.style.display = 'none'; 
	return false;
}

function changetab(tabcontent, tab) {

	document.getElementById('entrepreneurscontent').style.display = 'none';
	document.getElementById('entrepreneurstab').className = '';
	document.getElementById('innovatorscontent').style.display = 'none';
	document.getElementById('innovatorstab').className = '';
	document.getElementById('communitycontent').style.display = 'none';
	document.getElementById('communitytab').className = '';
	document.getElementById('smartbankcontent').style.display = 'none';
	document.getElementById('smartbanktab').className = '';
	
	document.getElementById(tab).className = 'selected';
		
	document.getElementById(tabcontent).style.display = 'block';
	return false;
}


function requestInfoPopup(){
	var url = $(this).attr("href") != undefined ? $(this).attr("href") : '/webforms/solar-request-more-information.php';
	if(typeof(request_amount) != "undefined")
	url += "&request_amount="+request_amount+"&loan_balance="+loan_balance+"&stateabbr="+stateabbr+"&estimated_value="+estimated_value+"&credit="+credit;
	window.open(url,"requestinfo",'width=470,height=540,scrollbars=yes,status=no,menubar=no,location=no,resizable=no');
}


$(function(){
	$('#custcontent').cycle({
	    fx:    'fade',
	    timeout: 1000,
		speed: 'slow',
	    next:   '#custcontrols .next',
	    prev:   '#custcontrols .back',
		height: 160,
		cleartype: false
});
	$('#custcontent').cycle('pause'); 
	
	
	if(typeof($.fn.lightBox) == "function")
	$('a[@rel*=lightbox]').lightBox();
	
	
	$('#solartabs').before('<ul id="tabnav">').cycle({
	    fx:    'fade',
	    timeout: 4000,
		speed: 'slow',	    
		height: 250,
		cleartype: false,
		pager: '#tabnav',
		pagerAnchorBuilder: function(idx, slide) { 
        	return '<li><a href="#"><span>'+$(slide).attr("title")+'</span></a></li>'; 
    	} 
	});	
	$('#solartabs').cycle('pause');
	
	$("table.finance thead th>div").bind("mouseover mouseout", function(){
		$(this).toggleClass("hover");
	})
	
	$("p.printresults a").bind("click", function(){
		window.print();
		return false;
	})

	
	$("a").each(function(i){
		if($(this).attr("rel")=="external")
			$(this).attr("target","_blank");
		else if($(this).attr("rel")=="popup")
			$(this).click(function(){
				window.open($(this).attr("href"),"_blank",'width=540,height=475,scrollbars=yes,status=no,menubar=no,location=no,resizable=no');
				return false;
			});
		else if($(this).attr("rel")=="popupalt")
			$(this).click(function(){
				window.open($(this).attr("href"),"_blank",'width=360,height=380,scrollbars=no,status=no,menubar=no,location=no,resizable=no');
				return false;
			});
		else if($(this).attr("rel")=="howtoapply")
			$(this).click(function(){
				window.open($(this).attr("href"),"_blank",'width=470,height=540,scrollbars=yes,status=no,menubar=no,location=no,resizable=no');
				return false;
			});
			else if($(this).attr("rel")=="requestinfo")
			$(this).bind("click", requestInfoPopup)
	});

	

	$("#mainnav li").bind("mouseover mouseout", function(){
		$(this).toggleClass("hover");
	})
	
	$("#atmloccont").bind("mouseover mouseout", function(){
		$(this).toggleClass("hover");
	})

	if ((navigator.userAgent).indexOf("Safari")!=-1){document.getElementById('navthirdlevel').style.top = '-23px';} 
	
	if ((navigator.userAgent).indexOf("Safari")!=-1)
	{
		if(document.createStyleSheet) {

			document.createStyleSheet('css/safari.css');

		}

		else {

			var styles = "@import url('css/safari.css');";

			var newSS=document.createElement('link');

			newSS.rel='stylesheet';

			newSS.href='data:text/css,'+escape(styles);

			document.getElementsByTagName("head")[0].appendChild(newSS);

		}
	}
	
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
	  {
		anchor.target = "_blank";
		anchor.onclick = openInNewWindow;
	}
		
 }

})
//window.onload=startList;
var iPhone = new RegExp("Mozilla/5.0 \\((.*)\\) AppleWebKit/(.*) \\(KHTML, like Gecko\\) Version/.* Mobile/(.*) Safari/(.*)").exec(navigator.userAgent) ? true : false;



/* Create the new window */
function openInNewWindow() {
	var ie7 = (document.all && !window.opera && window.XMLHttpRequest) ? true : false;
	
	if (this.getAttribute('title') == 'This link will open a new browser window.')
		if(!confirm('You are now leaving New Resource Bank\'s website.  Click OK to proceed.'))
			return false;
}

function switchEmail(emailClient)
{
	tables = document.getElementsByTagName('table');
	
	for (var i = 0; i < tables.length; i++)
	{
		if (tables[i].id != '')
		{
			
			tables[i].style.display = 'none';
		}
	}
	document.getElementById(emailClient).style.display = "block";
}

function secNotice() {
	if (confirm("Enhanced Online Security Notice:  As part of our Enhanced Online Security upgrade, those of you who have chosen the Challenge Questions for the Forgotten Password feature will be prompted to select new questions.  These questions are designed to be more user-friendly and provide greater security.  After you have updated the questions, you will have the option of enrolling in the Enhanced Online Security or continuing into Online Banking."))
		return true;
	else
		return false;
}
