$(document).ready( function () {
	var navData = [
		["http://www.ggp.com/", "GGP.com"],
		["http://www.clubestrellas.com/index.html", "Inicio"],
		["http://www.ggp.com/about-ggp/contact-us", "Contactenos"],
		["http://www.ggp.com/terms-conditions", "Politica de Privacidad"],
		["http://www.ggp.com/terms-conditions", "Terminos de Uso"]
	];
	
	assignStyleRule("text-transform", "uppercase" , "#footer_links");
	createNavArea(navData, "#footer_links")
});

// Build the bottom nav area via for loop.
// If we're on the last element, omit the pipe separator.
function createNavArea(navArray, target)
{
	var copyright = 'Derechos Reservados &#169; ' + new Date().getFullYear(),
		seperator = ' | ';
	
	$(target).html('<p></p>');
	
	for (var i = 0, j = navArray.length; i < j; i++)
	{
		$(target + " p").append(
			createLinkItem( navArray[i][0], navArray[i][1], "_self" )
		);
		
		if (i + 1 == j) {
			$(target + " p").append( seperator + copyright );
		} else { 
			$(target + " p").append( seperator );
		}
	}	
}

// Helper Function to set styles dynamically.
// Could just use jQuery's $.css() method.
function assignStyleRule(prop, val, target)
{
	$(target).css(prop, val);
}

// Build a string for a link.
// If the destination is a hash or empty string, it won't be a link.
// Return the string after we're done building.
function createLinkItem(href, text, target)
{
	var temp;
	
	if (href !== "" ) {
		temp = "<a href='" + href + "' target='" + target + "'>" + text + "</a>";
	} else {
		temp = text;
	}
	return temp;
}
