// JavaScript Document

var core = 1;
var delay = 3000;
var undefined;
var today = new Date();

img_list = new Array();
img_list[0] = new Array("/images/ApplyNow-msg2.gif",null);
img_list[1] = new Array("/images/ApplyNow-msg2b.gif",null);
//img_list[2] = new Array("/images/ApplyNow-msg2c.gif",null);
img_list[2] = new Array("/images/ApplyNow-msg2d.gif",null);
img_list[3] = new Array("/images/ApplyNow-msg2e.gif",null);

function RandomImage() 
	{
	seed = img_list.length-1;
	core = Math.floor(Math.random()*seed);
	document.msg.src = img_list[core][0];
	//setTimeout('RandomImage()',delay);
	}

img_list3 = new Array();
img_list3.push({source: "/images/banners/article-sluggish-economy-al.jpg", URL: "/blog/business-general/why-smart-operators-invest-in-their-businesses-during-a-sluggish-economy.html"});
img_list3.push({source: "/images/banners/article-creative-ways.jpg", URL: "/blog/business-general/creative-ways-some-restaurants-are-attracting-diners.html"});
img_list3.push({source: "/images/banners/article-enhance-customer-ex.jpg", URL: "/blog/business-general/enhancing-the-customer-experience-while-holding-the-bottom-line.html"});
img_list3.push({source: "/images/banners/article-more-evidence.jpg", URL: "/blog/business-general/more-evidence-the-recession-may-be-ending.html"});

var footer_position = 0;
var delay3 = 5000;

function RotateImage() {
	footer_position++;
	if (footer_position==img_list3.length) footer_position = 0;
	document.footer_ad.src = img_list3[footer_position].source;
	setTimeout('RotateImage()',delay3);
	}

function random_link() {
	window.open(img_list3[footer_position].URL,'_self');
	}

quote_list = new Array();
quote_list[0] = new Array("Doing Business with ARF was a great experience. I never expected to see the funds in our bank so quickly, and the paperwork process was very simple.","<b>Owner, Fine Dining Restaurant</b><br>Hollywood, Florida");
quote_list[1] = new Array("I liked the fact that I was dealing with an employee of ARF, not just a contractor. The difference in level of service was apparent throughout the entire process.", "<b>Owner, Convenience Store</b><br>Monroe, Louisiana");
quote_list[2] = new Array("Cheaper, Simpler, More Flexible...I found those all to be true. The best rates, an easy application process and options other cash providers couldn't offer. I'll use ARF again.","<b>Owner, Upscale Tex-Mex Restaurant</b><br>Houston, Texas");
quote_list[3] = new Array("Honesty and integrity are particularly important in this business.  From the beginning, ARF gave us a very strong comfort level that continues through today.  From our executives to our agents, we know we can trust ARF.","<b>President, Large National ISO</b><br>New York, New York");

function RandomQuote(pos) 
	{
	seed = quote_list.length-1;
	core = (pos!="" && pos!=undefined) ? core : Math.floor(Math.random()*seed);
	
	quote_contents = document.getElementById('testimonial-text');
	quote_contents.firstChild.nodeValue = quote_list[core][0];
	document.getElementById('testimonial-text').innerHTML = quote_list[core][0];
	
	by_contents = document.getElementById('by-line');
	by_contents.firstChild.nodeValue = quote_list[core][1];
	document.getElementById('by-line').innerHTML = quote_list[core][1];
	//alert(by_contents.innerHTML);
	//setTimeout('RandomQuote()',delay);
	}

var undefined;

var args = new Array();

function GetQuery()
	{
	query = location.search.substring(1);
	pairs = query.split("&");
	for (i=0;i<pairs.length;i++) {
		args[i] = pairs[i].split('=');
		}
	}

GetQuery();
		
function Request(myVariable)
	{
	for (i=0;i<args.length;i++) {
		if (args[i][0]==myVariable) return args[i][1];
		}
	}


function getName(spanId) {
	window.alert(document.getElementById(spanId).getAttribute('id'));
}

function getContent(spanId) {
	window.alert(document.getElementById(spanId).innerHTML);
}

img_list2 = new Array();
//img_list2.push(Array("/images/masthead.jpg",null));
img_list2.push(Array("/images/masthead6.jpg",null));
//img_list2.push(Array("/images/masthead3.jpg",null));
img_list2.push(Array("/images/masthead5.jpg",null));
img_list2.push(Array("/images/masthead7.jpg",null));
img_list2.push(Array("/images/masthead8.jpg",null));
img_list2.push(Array("/images/masthead9.jpg",null));

function RandomImage2(list,target) 
	{
	if (list == undefined) list = img_list2;
	obj = (target == undefined) ? document.getElementById("header") : document.getElementById(target);
	seed = list.length;
	core = Math.floor(Math.random()*seed);
	obj.style.backgroundImage = "url("+list[core][0]+")";
	//setTimeout('RandomImage()',delay);
	}

function TimeStamp()
	{
	var clock=new Date();
	var hr = clock.getHours();
	var minute = clock.getMinutes();
	var sec = clock.getSeconds();
	if (hr<12) 
		{
		if (hr<10) hr="0"+hr;
		Suffix = "AM";
		}
	else
		{
		hr = Math.abs(hr-12);
		if (hr<10) hr="0"+hr;
		Suffix = "PM";
		}
	if (minute<10) minute="0"+minute;
	if (sec<10) sec="0"+sec;
	// Time Zone test code
	var d=new Date()
	var s = d.toString();
	
	// In case we aren't able to parse from string
	var offset=d.getTimezoneOffset();
	inx = s.indexOf("GMT");
	if(inx==-1)
		{
		inx=s.indexOf("UTC");    
		}
	if(inx>=0 && s.length >=8)
		{ 
		s=s.substring(inx+3)
		s=s.substring(0,5);
		// to make offset the same as getTimezoneOffset return
		// we need to invert sign;
		sig=-1;
		if(s.charAt(0)=='+') sig=-1;
		var tz_minute=parseInt(s.substring(3));        
		var tz_hour=parseInt(s.substring(1,3));
		offset = sig* tz_hour*60 + tz_minute;
		}
	myTZ = d.toString();
	
	myEnd = myTZ.length -5
	myStart = myEnd-3
	TimeZone = myTZ.slice(myStart,myEnd);
	myTimeZone = TimeZone

	//document.writeln(Settings());
	//End TestCode

	myTime = (hr+":"+minute+":"+sec);
	myFullTime = (hr+":"+minute+":"+sec+" "+Suffix);
	}

function getexpirydate( nodays){
	var UTCstring;
	Today = new Date();
	nomilli=Date.parse(Today);
	Today.setTime(nomilli+nodays*24*60*60*1000);
	UTCstring = Today.toUTCString();
	return UTCstring;
	}

//function getcookie(cookiename) {
// 	var cookiestring=""+document.cookie;
// 	var index1=cookiestring.indexOf(cookiename);
// 	if (index1==-1 || cookiename=="") return ""; 
// 	var index2=cookiestring.indexOf(';',index1);
// 	if (index2==-1) index2=cookiestring.length; 
// 	return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
//	}

function getcookie(cookiename) {
	var cookiestring = "" + document.cookie;
	args = Array();
	args = cookiestring.split(";");
	for (i=0;i<args.length;i++) {
		args[i] = args[i].split("=");
		if (trimAll(args[i][0])==cookiename) return args[i][1];
		}
	}

function setcookie(name,value,duration){
	cookiestring=name+"="+escape(value)+"; path=/"; //+";EXPIRES="+getexpirydate(duration); // uncomment this to add tell the cookie whent to expire
	document.cookie=cookiestring;
	if(!getcookie(name)){
		return false;
		}
	else {
		return true;
		}
	}

function trimAll(sString) 	{
	while (sString.substring(0,1) == ' ') {
		sString = sString.substring(1, sString.length);
		}
	while (sString.substring(sString.length-1, sString.length) == ' ') {
		sString = sString.substring(0,sString.length-1);
		}
	return sString;
	}

function HREF(URL, target, attributes) {
	if (URL!="" && URL!=undefined) window.open(URL, target, attributes);
	}

if (Request("source")!="" && Request("source")!=undefined) setcookie("source",Request("source"));
