if (document.location.protocol != "https:"){
	document.location = document.location.toString().replace(/^http:/, 'https:');
};

Cufon.replace('#navigation a', { hover: true });
Cufon.replace('#footer a, #footer p', { hover: true });

jQuery(function($) {	
	$('#navigation li').each(function() {
		$(this).find('ul').each(function() {
			$(this).children('li:last').addClass('last');
		});
	});
	$('ul.menu .sep:last').addClass('last');
	$('.newsletter-entries .dlist-content:first').addClass('dlist-content-first');
	
	
	$('#navigation li').hover(function() {
		$(this).find('ul:eq(0)').show();
		$(this).addClass('hover');
	}, function() {
		$(this).find('ul:eq(0)').hide();
		$(this).removeClass('hover');
	});
	
	$('#menu-main-navigation > li.menu-item a').click(function() {
		return !$(this).parent().is('.about-us, .medical-information');
	});
	
	
	$('.dlist-item a').hover(function() {
		$(this).toggleClass('hover');
	});
	
	$('.dlist-item a.dlist-item-open').click(function() {
		if( $(this).find('span').html() == '-' ) {
			$(this).find('span').html('+');
			$(this).parent().parent().find('.dlist-content').slideUp('fast');
		}
		else {
			$(this).find('span').html('-');
			$(this).parent().parent().find('.dlist-content').slideDown('fast');
		}
		return false;
	});
	
    $('.dlist-item form').live('submit', function () {
        var self = $(this);
        var data = $(this).serialize();
        $(this).html('Loading ... Please wait');
        $.ajax({
                type: "POST",
                data: data,
                complete: function (msg) {
                	if ( $(msg.responseText).find('#' + self.attr('id') + '').length < 1 ) {
                    	self.html($(msg.responseText).find('#gforms_confirmation_message'));
                	} else {
                    	self.html($(msg.responseText).find('#' + self.attr('id') + '').html());
                	}
                }
        });
        return false;
    });
    
	tpxOffset = 10;
	tpyOffset = 20;		
	
    $("#immunization_schedule ul a").hover(
		function(e) { 
			var tooltip = $($(this).attr('href'));
			$('#immunization_tooltips .tooltip').hide();
			tooltip.css("top",(e.pageY + tpyOffset) + "px").css("left",(e.pageX + tpxOffset) + "px").fadeIn("fast");
		}, 
	    function() { 
			$('#immunization_tooltips .tooltip').hide();
	    }
	);
	
    $("#immunization_schedule ul a").mousemove(function(e) {
		var tooltip = $($(this).attr('href'));
		tooltip.css("top",(e.pageY + tpyOffset) + "px").css("left",(e.pageX + tpxOffset) + "px");
	});
	
	$('.gform_fields label').each(function() {
		if ( $(this).text().match(/^child #[23]/i) ) {
			var cli = $(this).closest('li');
			var cli_data = $(this).next().add(cli.nextUntil('.gsection'));
			cli_data.hide();
			$(this).click(function() {
				cli_data.slideToggle();
			}).addClass('expandable');
		};
	});
});
