// JavaScript Document

function businessCardInit(){
	var count = 1;
	while(document.getElementById('business-card'+count)){
			var businessCard = document.getElementById('business-card'+count);
			var r = businessCard.getElementsByTagName('a');
			for(var i = 0; i < r.length; i++){
				r[i].onclick = displayBusinessCard;
			}
		count++;
		}
		
	if(document.getElementById('business-card-close-button') ){
		document.getElementById('business-card-close-button').onclick = hideBusinessCard;
		
	}
}

function displayBusinessCard(){
	if(document.getElementById('business-card-popup')){
		document.getElementById('business-card-popup').style.display = 'block';
	}
	return false;
}
function hideBusinessCard(){
	tb_remove();
}
/* Sets the visibility of the divs inside the tellus pop-up */
function divVisibility(divName, visibility) {
	document.getElementById( divName ).style.display =  visibility  ;

}
function faqInit(){

	if(document.getElementById('faq')){

		var faq = document.getElementById('faq');
		var dd = faq.getElementsByTagName('dd');
		var dt = faq.getElementsByTagName('dt');
		for(var i = 0; i < dd.length; i++){
			dt[i].getElementsByTagName('a')[0].onclick = toggleFAQ;
			dt[i].numID = i;
			dt[i].status = false;
		}

		if(document.getElementById('expand-all')){
			document.getElementById('expand-all').getElementsByTagName('a')[0].onclick = expandAllFAQ;
		}
	}
}
 $(document).ready(function() {
							
	$.ajax({
    	type: "GET",
        url: "/business/business-card/xml/rates.xml",
        dataType: "xml",
        success: function(xml) {
        	$(xml).find('type').each(function(){
            	var id = $(this).attr('id');
            	var schumer = $(this).attr('schumer');
				if (id == 'excellent' && schumer == 'A'){
					var intro_apr = $(this).find('purchases').find('intro').find('rate').text();
					if(intro_apr != ""){$("#business-intro-apr").html(intro_apr);}
					var intro_end = $(this).find('purchases').find('desc').text();
					if(intro_end != ""){$("#business-intro-desc").html(intro_end);}
				}
            }); //close each(
		}
	});

 });

addLoadEvent(businessCardInit);


