// Copyright 2009 Billeo, Inc
// Rev 1.0
// Written By Timothy Ferland

// js-kit control variable jsLockDown="off" allows write to FAQ pages

var jsLockDown = "off";

function getPathJSK () {
	return "";
}

function getScriptsJSK () {
	if (jsLockDown == "off"){
		return "<script src=\"https://js-kit.com/ratings.js\" type=\"text/javascript\"></script>";
	}else{
		return "";
	}
}

function getratingJSK () {
	if (jsLockDown == "off"){
		return "<div class=\"faqRateHolder\"><div class=\"js-kit-rating\" path=\"faq\" permalink=\"" + window.location.href + "\" standalone=\"yes\" title=\"" + window.location.href + "\"></div></div>";
	}else{
		return "";
	}
}


// protect email addresses

function emlHide(intended,subject,nocorp) {
	var bdom = "corp.billeo.com";
	if (nocorp == "y") {
		bdom = "billeo.com";
	}
	document.write("<a href=\"mail"+"to:"+intended+"@"+bdom+"?subject="+subject+"\">"+intended+"@"+bdom+"</a>");
}


// Set the quote for the homepage

var quotes = ['Thanks so much for your services. They are the best in the web, &hellip; Congratulations!','Monica - Hollywood, FL','I particularly love that I can save personal and company credit card information on Billeo since I order for work, too.','Josetta - Indianapolis, IN','I love Billeo. By far the best password manager I have used.','Beechy - Dayton, OH','I love Billeo. Don\'t know how I lived without it.','Anonymous - Chicago, IL','I have been a long-time user of Billeo. Great software!','Alandris - Bessemer, AL','I have been trying Billeo for one month now. So far, so good. Works perfect for tracking payments, reminders for upcoming bills, filling passwords.','Ross - Sau Paulo, Brazil','Overall, Billeo is a great service&hellip;my compliments.','Tom - Raleigh, NC','You guys are GREAT!! I love Billeo, Thank you so much for this amazing software. It makes my life much easier.','Lester - Bunch Park, FL'];
var qnum=(Math.floor(Math.random()*8)*2);
var quote=quotes[qnum];
var quoter=quotes[qnum+1];


// Get client date

var today=new Date();
var year=today.getFullYear();
var month=today.getMonth();


// Navigation variable

var mainnav='<div id=\"moonmenu\" class=\"halfmoon\">\n  <ul>\n    <li><a href=\"\/page\/homepage.jsp?sitename=billeo\">HOME<\/a><\/li>\n    <li><a href=\"\/for_users\/users.html\" rel=\"dropmenu1_e\">DESKTOP APP<\/a><\/li>\n    <li><a href=\"\/mobile\/overview.html\">MOBILE APP<\/a><\/li>\n    <li><a href=\"\/for_companies\/companies.html\" rel=\"dropmenu3_e\">FOR COMPANIES<\/a><\/li>\n    <li><a href=\"\/about\/about.html\" rel=\"dropmenu4_e\">ABOUT<\/a><\/li>\n    <li><a href=\"\/faq\/\">SUPPORT<\/a><\/li>\n  <\/ul>\n<\/div>\n\n<div id=\"dropmenu1_e\" class=\"dropmenudiv_e\">\n<a href=\"\/for_users\/users.html\">Overview<\/a>\n<a href=\"\/tour\/tour_landing_sh.html \">Take the Tour<\/a><a href=\"\/for_users\/features.html\">Features<\/a> \n<a href=\"\/for_users\/testimonials.html\">Testimonials<\/a>\n<a href=\"\/faq\/\">Support<\/a>\n<a href="/for_users/billeoplus.html">Billeo+</a>\n<\/div>\n\n<div id=\"dropmenu3_e\" class=\"dropmenudiv_e\">\n<a href=\"\/for_companies\/billpay.html\">Bill Pay<\/a>\n<a href=\"\/for_companies\/shopping.html\">Shopping<\/a>\n<\/div>\n\n<div id=\"dropmenu4_e\" class=\"dropmenudiv_e\">\n<a href=\"\/about\/about.html\">Company<\/a>\n<a href=\"\/about\/management.html\">Management<\/a>\n<a href=\"\/about\/awards.html\">Awards<\/a>\n<a href=\"\/about\/press.html\">Press<\/a>\n<a href=\"\/about\/partners.html\">Our Partners<\/a>\n<a href=\"http:\/\/blog.billeo.com\/\" target=\"_blank\">Blog<\/a>\n<a href=\"\/about\/careers.html\">Careers<\/a>\n<a href=\"\/about\/contact.html\">Contact Us<\/a>\n<\/div>';


// Footer variable

var footer="<div class=\"lineGrey\"></div><div id=\"btmNav\"><div id=\"btmNav-menu\"><ul><li><a href=\"/corporate/privacy.html\">Privacy</a></li><li><a href=\"/corporate/tandc.html\">Terms and Conditions</a></li><li><a rel=\"shadowbox[Mixed];height=450;width=550;\" class=\"option\" title=\"Let us know...\" href=\"/overlays/overlay_form.html?type=feedback\">Feedback</a></li><li><a href=\"/about/contact.html\">Contact Us</a></li></ul></div><div id=\"footerImages\"><a href=\"http://www.truste.org/ivalidate.php?url=www.billeo.com&amp;sealid=101\" target=\"_blank\"><img src=\"/images/corp/truste_logo.gif\" width=\"139\" height=\"48\" alt=\"TRUSTe Privacy Certification\" title=\"TRUSTe Privacy Certification\" /></a><a href=\"https://seal.verisign.com/splash?form_file=fdf/splash.fdf&amp;dn=WWW.BILLEO.COM&amp;lang=en\" target=\"_blank\"><img src=\"/images/corp/verisign_logo.gif\" width=\"98\" height=\"48\" alt=\"Verisign Secured Verification\" title=\"Verisign Secured Verification\" /></a></div></div><p class=\"copyright\">Copyright &copy; "+year+" Billeo, Inc.</p><div id=\"pageBottom\"></div>";


// Hide and show content functions

function HideContent(d) {
	if(d.length < 1) { 
		return;
	}
	document.getElementById(d).style.display = "none";
}

function ShowContent(d) {
	if(d.length < 1) {
		return;
	}
	document.getElementById(d).style.display = "block";
}

function ReverseContentDisplay(d) {
	if(d.length < 1) {
		return;
	}
	if(document.getElementById(d).style.display == "none") {
		document.getElementById(d).style.display = "block";
	}else{ 
		document.getElementById(d).style.display = "none"; 
	}
}

function swapImage(imgName, imgPath) {
	document[imgName].src = imgPath;
}


// Change press release div

function press(n) {
	for (var ct=1;ct<=7;ct++) {
		eval("document.getElementById(\"press"+ct+"\").style.display = \"none\"");
		eval("document.getElementById(\"p"+ct+"\").className = \"linked\""); 
	}
	eval("document.getElementById(\"press"+n+"\").style.display = \"block\"");
	eval("document.getElementById(\"p"+n+"\").className = \"selected\""); 
}

// Change in the news div

function news(n) {
	for (var ct=1;ct<=4;ct++) {
		eval("document.getElementById(\"news"+ct+"\").style.display = \"none\"");
		eval("document.getElementById(\"n"+ct+"\").className = \"linked\""); 
	}
	eval("document.getElementById(\"news"+n+"\").style.display = \"block\"");
	eval("document.getElementById(\"n"+n+"\").className = \"selected\""); 
}



// Onclick URL function

function jumpURL (getURL) {
	window.location=getURL;
}


// Get location for log in action

function actionFormFill () {
	var myUrl2 = window.location.toString();
	myUrl2 = myUrl2.split('.com');
	myUrl2 = (myUrl2[0]+'.com/page/login.do');
	var myLoginLocation2 = myUrl2.replace(/http:/, 'https:');
	document.write('<form action="'+ myLoginLocation2 +'" method="post">');
}

function actionFill () {
	var myUrl = window.location.toString();
	myUrl = myUrl.split(".com");
	myUrl = (myUrl[0]+".com/page/myDashboardMain.do?selected=1&amp;sitename=Billeo&amp;TBAR_AutoLogin=1");
	var myLoginLocation = myUrl.replace(/http:/, "https:");
	document.write('<input type="hidden" name="gotoPage" value="'+ myLoginLocation +'" />');
}

// Download detect

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
		this.cpu = "32bit";
		var userAgent64bit = /Win64/gi;
		if (navigator.userAgent.match(userAgent64bit)) {
       			this.cpu = "64bit";
		}
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.userAgent,
			subString: "iPhone",
			identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
var macType = "N/A";
if ((navigator.userAgent.toLowerCase().indexOf("intel mac") != -1)) {
		macType = "Intel";									   
}

BrowserDetect.init();

function doneFn(b,a){
}

function getBilleoTB() {
	//pageTracker._trackPageview("/clickGetBilleoButton");  // Google tracking for button
	_gaq.push(['_setAccount', 'UA-440621-1']);
	//_gaq.push(['_EVENT','/clickGetBilleoButton']);
	_gaq.push(['_trackEvent', 'ToolBarDownLoad ', 'clicked']);
	var macvar = "";
	var execname="billeo-home-setup.exe";
	var loc = window.location+"";
	var referrer = readCookie("PAGE_REFERRAL"); //  check for referrer cookie
	if (referrer.indexOf("_LPOA")!=-1) {
		execname = "2103/billeo-home-setup.exe";
		var macvar = "?ref="+referrer;
	}
	if(loc.indexOf("upside")!=-1) {
		execname = "upside-setup.exe";
		if (BrowserDetect.cpu == "64bit") {
			execname="64bit/" + execname;
		}
	}
	else if(loc.indexOf("netspend")!=-1) {
		execname = "netspend-setup.exe";
		if (BrowserDetect.cpu == "64bit") {
			execname="64bit/" + execname;
		}
	}
	else if (BrowserDetect.cpu == "64bit") {
		execname="64bit/" + execname;
	}

	if(BrowserDetect.OS=="Windows") {
		window.location="/getbilleo/setup/winxp/" + execname;
	}else{
		if (BrowserDetect.browser == "Firefox" && (BrowserDetect.version == "7" || BrowserDetect.version == "8" || BrowserDetect.version == "9" || BrowserDetect.version == "10") && BrowserDetect.OS == "Mac" && macType == "Intel") {
			window.location="/help/eula.jsp"+macvar;
		}
		else if(BrowserDetect.browser == "Firefox" && BrowserDetect.version == "3" && BrowserDetect.OS == "Mac" && macType == "Intel") {
			window.location="/help/eula.jsp"+macvar;
		}else{
			window.location="/help/incompatibleClient.jsp";
		}
	}
}

function installMac() {
  if (BrowserDetect.browser == "Firefox" && BrowserDetect.version == "3.5" && BrowserDetect.OS == "Mac" && macType == "Intel") {
    window.location="https://addons.mozilla.org/en-US/firefox/addon/11210";
  }
  else if (BrowserDetect.browser == "Firefox" && (BrowserDetect.version == "3" || BrowserDetect.version == "4")&& BrowserDetect.OS == "Mac" && macType == "Intel") {
	var xpi = new Object();
	xpi["Billeo"] = "/getbilleo/mac/beta/billeo.xpi";
	InstallTrigger.install(xpi, doneFn);
  } else {
	alert ("This install page is for Intel based Mac users with Firefox 3.x only.");
  }
}

// Get Variables from URL function

function gup(name){
	name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS="[\\?&]"+name+"=([^&#]*)";
	var regex=new RegExp(regexS);
	var results=regex.exec(window.location.href);
	if(results===null){
		return "";
	}else{
		return results[1];
	}
}


// For Searching FAQs

function trim(str) {
	return str.replace(/^\s+/,'').replace(/\s+$/,''); 
}
function validate() {
	if(trim(document.search.query.value)=="") {
		document.getElementById("faqErrorMsg").style.display = "block"; 
		document.search.query.focus();
		return false;
	} else {
		document.getElementById("faqErrorMsg").style.display = "none"; 
		return true;
	}
}

// Read cookie

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return "";
}

