//DO ON LOAN
$(document).ready(function() {

	leftNav();
	sectionNav();
	sectionNavCorp();
	sectionNavProp();
	internalWidgets();
	sectionFooter();
	
});

/*
 * This function adds a css class to highlight
 * the particular href that was clicked.
 */
function getALinksFromDiv() {
	
	var url = window.location.href;
	
	$(".internal-nav a").each(function (i) {
		if (this == url) {
			$("#" + i).addClass("active");
		}
		else {
			$("#" + i).removeClass("active");
		}
	});
}


//Main Navigation - Left hand side. Include class on DIV to determin what internal navigation to include	
function leftNav() {
	
	var navDivId = $('#left-column').attr('class');
	
	$('#left-column').load('includes/nav-internal.html #' + navDivId, function() {
		//Highlight the href that was clicked.
		getALinksFromDiv();
	});
	
	

}

function getPageName() {

	var pageName = window.location.pathname;
	pageName = pageName.replace("/", "");
	pageName = pageName.replace(".html", "");
	return pageName;

}

//Section - Navigation - Top section navigation
function sectionNav() {

	$('#section-nav').load('includes/nav-section.html');

}


//Section - Navigation - Top section navigation
function sectionNavCorp() {

	$('#section-nav-corporate').load('includes/nav-section-corporate.html');

}

// Internal right column
function internalWidgets() {

	$('#right-column').load('includes/internal-widgets.html', function() {
		
		//Cycle plugin for Why Use AFG text
		sliderWidget();
	
	});
	
}
   
function sliderWidget() {
   $('.slideshow').cycle({
		fx: 'fade',
	    timeout:  10000
   }); 
} 

//end - Internal right column

//Internal Sections - Property etc 
function sectionFooter() {

	$('.section-footer').load('includes/internal-section-footer.html');	
	
}

//Section - Navigation - Top section navigation
function sectionNavProp() {

	$('#section-nav-property').load('includes/nav-section-property.html');

}

//Internal Sections - Property etc 
function sectionFooter() {

	$('.section-footer').load('includes/internal-section-footer.html');	
	
}


//end 

