/*****************************************************
*	Open Window Function
*****************************************************/


var imgdir = "../images/";
var sitedir = "";
var securedir = "";
var homedir = "../";

if(window.homepage)
{
imgdir="images/";
sitedir="site/";
securedir="site/";
homedir="";
}
else if(window.absolutepage)
{
imgdir="http://www.lafcu.org/images/"
sitedir="http://www.lafcu.org/site/"
securedir="http://www.lafcu.org/site/"
homedir="http://www.lafcu.org/"
}
else if(window.securepage)
{
imgdir="https://www.lafcu.org/images/"
sitedir="http://www.lafcu.org/site/"
securedir="https://www.lafcu.org/site/"
homedir="http://www.lafcu.org/"
}


function openApp(appName) {
	
	document.location.href = "https://www.lafcu.org/Forms/OnlineForm.cgi?form=" + appName + "&onweb=true";
	
}




function openWin (url,width,height,extras) {
	if (window.open) {
		if (width < 0 || height < 0) {
			newWin = window.open(url,"new_win",extras);
		} else {
			newWin = window.open(url,"new_win","width="+ width +",height="+ height +","+ extras);
		}
	} else {
		return false;
	}
}


/**
 * sets up the links for the apply now dropdown
 * if you need to change a link for the dropdown, just do it here instead of in all the pages
 */
function goTo (selection) {

	//check to see if the blank was selected
	if(selection == "")
		return;

	var links = new Array();      // array to store the links. change here if link change is requested
	
	//links["Business Loan"] = "https://www.newtekreferrals.com/auto_cu/nsbf.php?company_id=601";
	links["Business Loan"] = "http://www.newtekreferrals.com/site/201/2/lend_en";
	links["Consumer Loan"] = "https://www.lafcu.org/site/online_app.html";
	links["Real Estate Loan"] = "http://lafcu.mortgagewebcenter.com/Default.asp?bhcp=1";
	links["Visa Card"] = "https://www.loanliner.com/LoanRequest/CLPPresenter/GettingStarted.aspx?CUID=10402067&LoanFormId=6202657609292164434&ChannelId=2941122005140152812&LocationId=9488722005140152728&IsFramed=F";
	
	//the visa card link needs to open in a new window. 
	//if this changes in the future, this is where you make the change
	if(selection == "Visa Card") 
		window.open(links[selection],"new_window");
	else	
		self.location.href = links[selection];
	
	
}

function ext_link(url)
{
	var x=window.confirm("You are now leaving the secure website of Los Angeles Federal Credit Union (LAFCU). The website you are about to access is not owned or operated by LAFCU and we are not responsible for its content. Be aware that the privacy and security policies of third-party websites may differ from those practiced by LAFCU. If you did not mean to leave our website, please click 'Cancel' now.  If you wish to continue to the next website, click 'OK'. Thank you for visiting LAFCU's website.");
	if (x) window.open(url);
}


function externalLinks() {
 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("href").indexOf("lafcu.org") == -1 &&
(anchor.getAttribute("href").substr(0,7) == "http://" || anchor.getAttribute("href").substr(0,8) == "https://" ))
   anchor.href = 'javascript:ext_link(\''+anchor.href+'\');';
   anchor.target = '';
 
 }
}

window.onload = externalLinks;


var mydate = new Date();
var year = mydate.getFullYear();
if (year < 2000)
	year += 1900;


var day = mydate.getDay();   //day of week
var month = mydate.getMonth();
var daym = mydate.getDate(); //day of month

if (daym < 10)
	daym = "" + daym;
var dayarray = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var montharray = new Array("January","February","March","April","May","June","July","August","September","October","November","December");


var todaysDate = ""+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"";


/** 
 * Scrolling marquee code for the homepage,
 * see #welcome, #marquee, and #innerText styles in lafcu.css
 */

var marqueeTimeout = 0; 

var marqueePosition = 775;
 
function marqueeScroll() {
	var it = document.getElementById('innerText');
	
	// if the marquee is off the screen to the left, then start over
	// by moving it back to the right
	if(marqueePosition < -240)
		marqueePosition = 775;
	else {
		marqueePosition -= 3; 
		
		it.style.left = marqueePosition + "px";
	}	
	
	
	marqueeTimeout = setTimeout("marqueeScroll()", 100);
	
	
}   