//*****Extend the footer to the bottom of the page**************************************************//
function extendFooter() {
  // remove DNN's form height
  $('#Form').removeAttr("style");
  var footerHeight = $('#footer').height();
  var pageHeight = $('#wrap').height();
  var windowHeight = $(window).height();
  var difference = windowHeight - pageHeight;
  if (pageHeight < windowHeight) {
    $('#footer').height(footerHeight + difference);
  } else {
    $('#footer').height('124px');
  }
}
//*****Replace align attribute with class**************************************************//
function replaceAlign() {
  if (!document.getElementsByTagName('img')) return false;
  $('img[align="left"]').addClass('left').removeAttr('align');
	$('img[align="right"]').addClass('right').removeAttr('align');
	$('img[align="middle"]').addClass('middle').removeAttr('align');
}
//*****Replace target attribute with class**************************************************//
function replaceTarget() {
  if (!document.getElementsByTagName('a')) return false;
  $('a[target]').addClass('newwindow').removeAttr('target');
}
//*****The following function make it possible to have web standard popups**************************************************//
function strictNewWindow() {
  if (!document.getElementsByTagName('a')) return false;
  $('a.newwindow').click(function() {
		window.open($(this).attr('href'));
    return false;
	});
}
//*****Add swfobject flash call**************************************************//
function initializeFlash() {
	if (!document.getElementById('flash-content')) return false;
	var flashvars = {};
	var params = {wmode: 'transparent'};
	var attributes = {};
	attributes.id = "flash";
	swfobject.embedSWF("/Portals/1/Skins/Homepage/swf/home-banner.swf", "flash-content", "960", "215", "8.0.0", "/Portals/1/Skins/Homepage/swf/expressInstall.swf", flashvars, params, attributes);
}
//**************************************************Toggle Bios************************************************************//
function toggleBios() {
	$('.toggle').hide();
	$('h5.reveal').addClass('inactive');
	$('.revealBioWrap h5').click(function () {
		$(this).toggleClass('inactive');
		$(this).toggleClass('active');
	  $(this).parent().find('.toggle').slideToggle();
  });
}
//**************************************************Scroll To************************************************************//
function initializeScrollTo() {
  //Target examples bindings
	$('ol#salesAgentLinks li:eq(0)').click(function(){
	  $.scrollTo( '#agent1', 800 )
	});
	$('ol#salesAgentLinks li:eq(1)').click(function(){
	  $.scrollTo( '#agent2', 800 )
	});
	$('ol#salesAgentLinks li:eq(2)').click(function(){
	  $.scrollTo( '#agent3', 800 )
	});
	$('ol#salesAgentLinks li:eq(3)').click(function(){
	  $.scrollTo( '#agent4', 800 )
	});
	$('ol#salesAgentLinks li:eq(4)').click(function(){
	  $.scrollTo( '#agent5', 800 )
	});
	$('ol#salesAgentLinks li:eq(5)').click(function(){
	  $.scrollTo( '#agent6', 800 )
	});
	$('ol#salesAgentLinks li:eq(6)').click(function(){
	  $.scrollTo( '#agent7', 800 )
	});
	$('ol#salesAgentLinks li:eq(7)').click(function(){
	  $.scrollTo( '#agent8', 800 )
	});
	$('ol#salesAgentLinks li:eq(8)').click(function(){
	  $.scrollTo( '#agent9', 800 )
	});
	$('ol#salesAgentLinks li:eq(9)').click(function(){
	  $.scrollTo( '#agent10', 800 )
	});
	$('ol#salesAgentLinks li:eq(10)').click(function(){
	  $.scrollTo( '#agent11', 800 )
	});
	$('ol#salesAgentLinks li:eq(11)').click(function(){
	  $.scrollTo( '#agent12', 800 )
	});
	$('ol#salesAgentLinks li:eq(12)').click(function(){
	  $.scrollTo( '#agent13', 800 )
	});
	$('ol#salesAgentLinks li:eq(13)').click(function(){
	  $.scrollTo( '#agent14', 800 )
	});
	$('ol#salesAgentLinks li:eq(14)').click(function(){
	  $.scrollTo( '#agent15', 800 )
	});
	$('ol#salesAgentLinks li:eq(15)').click(function(){
	  $.scrollTo( '#agent16', 800 )
	});
}

//*****Load all functions**************************************************//
$(document).ready(function(){
	extendFooter();
  replaceAlign();
  replaceTarget();
  strictNewWindow();
  initializeFlash();
	toggleBios();
	initializeScrollTo();
});