var box_class = ["refinance","purchase","poor_credit"],i;

function getElementsByClassName(className, node)
{
	var children = null, returnArr = [], i;
	
	if (node == undefined) node = document.body;
	else if (typeof node != "object") return([]);
	else if (node.className == className)
		returnArr[returnArr.length] = node;
	
	children = (node.children) ? node.children : node.childNodes;
	for (i = 0; i < children.length; i++)
	{
		returnArr = returnArr.concat(
				getElementsByClassName( className, children[i] )
		);
	}
	
	return(returnArr);
}

function genLink()
{
	if (this.className == "refinance")
		window.location = "https://www.iwillfundyou.com/refinance.php";
	else if (this.className == "purchase")
		window.location = "https://www.iwillfundyou.com/purchase.php";
	else if (this.className == "poor_credit")
		window.location = "https://www.iwillfundyou.com/poor_credit.php";
}

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("rel") == "external")
		anchor.target = "_blank";
 }
}

window.onload = function()
{
	for(i=0; i<box_class.length; i++)
	{
		var a = getElementsByClassName(box_class[i]);
		a[0].style.cursor = "pointer";
		a[0].onclick = genLink;
	}
}

window.onload = externalLinks;