// JavaScript Document

Cufon.replace('.ask_dr_dave .calendar q', {fontFamily: 'BMWTypeCondensedRegular'});
Cufon.replace('.dds, .right_imgs span, .email span, .img_three .c_bg q, .img_four .c_bg q, .bottom_img', {fontFamily: 'Myriad Pro'});
Cufon.replace('.topmenu a, .c_bg span, .bg_center h3', {fontFamily: 'Myriad Pro', textShadow: "1px 1px #2c2111"});
Cufon.replace('h1, .img_two > h4, .img_five strong', {fontFamily: 'Myriad Pro', textShadow: "1px 1px #f0f0ec"});
Cufon.replace('.center_bg h3 ', {fontFamily: 'Humanst531 BT', textShadow: "1px 1px #FFFFFF"});


Cufon.now();

jQuery(document).ready(function()
{
	jQuery('a.targetBlank').attr('target', '_blank');
	
	jQuery('a .hint').parent().css('position', 'relative');
	jQuery('a .hint').append('<img src="/wp-content/themes/kirklanddentistry/img/hint-top-bg.png" />');
	
	jQuery('blockquote').append('<div class="topLeft"></div>').append('<div class="topRight"></div>').append('<div class="bottomLeft"></div>').append('<div class="bottomRight"></div>');
	
	//jCarousel Plugin
	jQuery('#carousel').jcarousel({
		vertical: true,
		scroll: 1,
		auto: 2,
		wrap: 'last',
		initCallback: mycarousel_initCallback
   	});
    
    //Front page Carousel - Initial Setup
	//jQuery('div#slideshow-carousel a img').css({'opacity': '0.5'});
	jQuery('div#slideshow-carousel a img:first').css({'opacity': '1.0'});
	//jQuery('div#slideshow-carousel li a:first').append('<span class="arrow"></span>')

  
  	//Combine jCarousel with Image Display
    jQuery('div#slideshow-carousel li a').hover(
       	function () {
        		
       		/*if (!jQuery(this).has('span').length) {
       			jQuery('div#slideshow-carousel li a img').stop(true, true).css({'opacity': '0.5'});
       			jQuery(this).stop(true, true).children('img').css({'opacity': '1.0'});
       		}*/		
       	},
       	function () {
        		
       		/*jQuery('div#slideshow-carousel li a img').stop(true, true).css({'opacity': '0.5'});
       		jQuery('div#slideshow-carousel li a').each(function () {
       			if (jQuery(this).has('span').length) jQuery(this).children('img').css({'opacity': '1.0'});
       		});*/
        		
       	}
	).click(function () {
		jQuery('div#slideshow-carousel li a.active').removeClass('active');
		jQuery(this).addClass('active');
		//jQuery('span.arrow').remove();        
		//jQuery(this).append('<span class="arrow"></span>');
		jQuery('div#slideshow-main li').removeClass('active');        
		jQuery('div#slideshow-main li.' + jQuery(this).attr('rel')).addClass('active');	
        	
       	return false;
	});
	
	// mailchimp form customization
	jQuery('#mc_signup').find('label, br').remove();
	jQuery('#mc-indicates-required').remove();
	
	jQuery('#mc_mv_EMAIL').val('Please enter your email address...');
	jQuery("#mc_mv_EMAIL").focus( function() { if(this.value == 'Please enter your email address...') this.value = ''; } );
	jQuery("#mc_mv_EMAIL").blur( function() { if(this.value == '') this.value = 'Please enter your email address...'; } );
	
	jQuery('#mc_mv_FNAME').val('Your name...');
	jQuery("#mc_mv_FNAME").focus( function() { if(this.value == 'Your name...') this.value = ''; } );
	jQuery("#mc_mv_FNAME").blur( function() { if(this.value == '') this.value = 'Your name...'; } );
});

//Carousel Tweaking

function mycarousel_initCallback(carousel) 
{	
	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
}

// Testimonials
var current=1;
var currentTestim = 0;
function autoAdvance()
{
	var testimonials = jQuery('.testimonials li'); 
	currentTestim = (currentTestim + 1 == testimonials.length ? 0 : currentTestim + 1);
	testimonials.hide();
	//testimonials.fadeTo('slow', 0);
	jQuery(testimonials[currentTestim]).show();
	//jQuery(testimonials[currentTestim]).fadeTo('slow', 1);

	if(current==-1) return false;

	//$('#menu ul li a').eq(current%$('#menu ul li a').length).trigger('click',[true]);	// [true] will be passed as the keepScroll parameter of the click function on line 28
	current++;
}

// The number of seconds that the slider will auto-advance in:

var changeEvery = 10;

var itvl = setInterval(function(){autoAdvance()},changeEvery*1000);

//jQuery('.testimonials li:first').css('opacity', 1);
jQuery('.testimonials li:first').show();

function printImage(imgSrc)
{
	popup = window.open('','popup','toolbar=no,menubar=no,width=200,height=150');
	popup.document.open();
	popup.document.write("<html><head></head><body onload='print()'>");
	popup.document.write('<img src="' + imgSrc + '" />');
	popup.document.write("</body></html>");
	popup.document.close(); 
}
