  /***** 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');
}

  /***** Web Standard Popups *****/
function strictNewWindow() {
  if (!document.getElementsByTagName('a')) return false;
  $('a.newwindow').click(function() {
		window.open($(this).attr('href'));
    return false;
	});
}

  /***** Extend the Footer *****/
function extendFooter() {
 $('#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('auto');
 }
}

  /***** Toggle FAQs *****/
function toggleFAQs() {
	$('.toggle').hide();
	$('h4.reveal').addClass('inactive');
	$('.revealQuestionsWrap h4').click(function () {
		$(this).toggleClass('inactive');
		$(this).toggleClass('active');
	  $(this).parent().find('.toggle').slideToggle();
  });
}

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