$(document).ready(function(){					
	//Create Quick Menu: 
	//(ID,Is Vertical,Show Timer,Hide Timer,On Click(options: 'all' * 'all-always-open' * 'main' * 'lev2'),Right to Left,Horizontal Subs,Flush Left,Flush Top)
	qm_create(0,false,0,0,false,false,false,false,false);
	
	//Function to toggle dt's by clicking on dd's
	ddExpand('#faq');
	
	//Causes all links to external domains to open in a new window
	//$("a[href^='http:']").not("[href*='homecare.brunelleinteractive.com']").attr('target','_blank').addClass('external');
	
	imageControl();
	
});

Cufon.replace('#qm0 a.qmparent', {
	hover: true
 });
 
Cufon.replace('#qm0 a.qmparent, .avenir,.more, h2.title, h2.title-small, h2.title-solution');

function imageControl() {
	
	var imageCount = 1;
	
	var images = $('.image-container').find('img');
	images.each( function(){
		$(this).attr("id","image-"+imageCount);
		imageCount ++;
		}	
	);
	imageCount = 1;
	images.hide();
	
	$("#image-"+imageCount).show();
	
	$("#next-image").bind('click', function () {
		$("#image-"+imageCount).fadeOut(1000);
		if (imageCount == images.length) {
			imageCount = 1;
		}
		else {
			imageCount ++;
		}
		$("#image-"+imageCount).fadeIn(1000);		
	});
	
	$("#prev-image").bind('click', function () {
		$("#image-"+imageCount).fadeOut(1000);
		if (imageCount == 1) {
			imageCount = images.length;
		}
		else {
			imageCount --;
		}
		$("#image-"+imageCount).fadeIn(1000);		
	});	
}

function ddExpand(e) {
	$(e).find('dd').hide();
	$(e).find('dt').css('cursor','pointer');
	$(e).find('dt').bind('click', function(){
		if ($(this).hasClass('opened')) {
			$(this).next('dd').slideUp('normal').end().removeClass('opened');
			return;
		};
		
		if($(e).find('dd').is(':animated') || $(this).next('dd').is(':visible')) {
			return false;			
		};
		$(this).next('dd').slideDown('normal').end().addClass('opened');		
	});
	$(e).find('.active').trigger('click');
};