jQuery.noConflict();

//<![CDATA[
Cufon.replace('h1, h2, h3, h4, #buttonBoxes p, p.header');
Cufon.replace('ul#top-menu > li > a');
Cufon.replace('ul.sub-menu > li > a');
//]]>

var et_theme_folder = jQuery("meta[name=et_theme_folder]").attr('content'),
	$et_top_menu = jQuery('ul#top-menu > li > ul'),
	et_disable_toptier = jQuery("meta[name=et_disable_toptier]").attr('content');

jQuery('ul.nav').superfish({ 
	delay:       200,                            // one second delay on mouseout 
	animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
	speed:       'fast',                          // faster animation speed 
	autoArrows:  true,                           // disable generation of arrow mark-up 
	dropShadows: true                            // disable drop shadows 
});

jQuery('#top-menu > li').hover(
	function () {
		jQuery(this).css("background-image", "url(http://jeremypenrod.com/PenrodDentalNew/wp-content/themes/Chameleon/images/menuHoverBackground.png)");
	},
	function () {
		jQuery(this).css('background-image', 'none');
	}
);


	
var $footer_widget = jQuery("#footer-widgets .footer-widget");
if ( $footer_widget.length ) {
	$footer_widget.each(function (index, domEle) {
		if ((index+1)%3 == 0) jQuery(domEle).addClass("last").after("<div class='clear'></div>");
	});
}

et_search_bar();

function et_search_bar(){
	var $searchform = jQuery('#additional-info div#search-form'),
		$searchinput = $searchform.find("input#searchinput"),
		searchvalue = $searchinput.val();
		
	$searchinput.focus(function(){
		if (jQuery(this).val() === searchvalue) jQuery(this).val("");
	}).blur(function(){
		if (jQuery(this).val() === "") jQuery(this).val(searchvalue);
	});
}

if ( et_disable_toptier == 1 ) jQuery("ul.nav > li > ul").prev("a").attr("href","#");

var $comment_form = jQuery('form#commentform');
$comment_form.find('input, textarea').focus(function(){
	if (jQuery(this).val() === jQuery(this).next('label').text()) jQuery(this).val("");
}).blur(function(){
	if (jQuery(this).val() === "") jQuery(this).val( jQuery(this).next('label').text() );
});

$comment_form.find('input#submit').click(function(){
	if (jQuery("input#url").val() === jQuery("input#url").next('label').text()) jQuery("input#url").val("");
});


jQuery('.service .thumb a').hover(function(){
	jQuery(this).find('img').stop(true,true).fadeTo('fast',0.8).end().find('span').fadeTo('fast',1);
},function(){
	jQuery(this).find('img').stop(true,true).fadeTo('fast',1).end().find('span').fadeTo('fast',0);
});

$multi_media_bar = jQuery('#et-multi-media #media-slides');
if ( $multi_media_bar.length ) {
	$multi_media_bar.cycle({
		fx: 'fade',
		timeout: 0,
		speed: 500,
		cleartypeNoBg: true,
		prev:   'a#left-multi-media',
		next:   'a#right-multi-media'
	});
}

$multi_media_bar.find('.thumb a').hover(function(){
	jQuery(this).find('img').stop(true,true).fadeTo(400,0.7).end().find('span').fadeTo(400,1);
	jQuery(this).parent('.thumb').find('.media-description').stop(true,true).css({'display':'block','opacity':0}).animate({opacity:1, bottom:'53px'},400);
},function(){
	jQuery(this).find('img').stop(true,true).fadeTo(400,1).end().find('span').fadeTo(400,0);
	jQuery(this).parent('.thumb').find('.media-description').stop(true,true).animate({opacity:0, bottom:'63px'},400);
});

jQuery('.btn').append(jQuery('<span />').addClass('helper'));



jQuery.fn.preload = function() {
    this.each(function(){
        jQuery('<img/>')[0].src = this;
    });
}

jQuery('.buttonImage').find("img").css('opacity',.5);

jQuery('.buttonImage').hover(function() {
    jQuery("img", this).stop().animate({"opacity": 1}); 
},function() { 
    jQuery("img", this).stop().animate({"opacity": .5}); 
});

jQuery('.hoverImage').css('opacity',.65);

jQuery('.hoverImage').hover(function() {
    jQuery(this).stop().animate({"opacity": 1}); 
},function() { 
    jQuery(this).stop().animate({"opacity": .65}); 
});

jQuery("img.a").hover(
function() {
jQuery(this).stop().animate({"opacity": "0"}, 250); /*200*/
},
function() {
jQuery(this).stop().animate({"opacity": "1"}, 250);
});
 
 
//image rotator - Blue Lime Solutions - http://jeremypenrod.com
function cycleImages(){
      var $active = jQuery('#slider .active');
      var $next = (jQuery('#slider .active').next("img").length > 0) ? jQuery('#slider .active').next("img") : jQuery('#slider img:first');
      $next.css('z-index',2);//move the next image up the pile
	  $active.fadeOut(1500,function(){//fade out the top image
	  $active.css('z-index',1).show().removeClass('active');//reset the z-index and unhide the image
      $next.css('z-index',3).addClass('active');//make the next image the top one
      });
    }

jQuery(document).ready(function(){
	setInterval('cycleImages()', 3000);
})

jQuery('#footerSearch').bind('focus blur', function() {
	jQuery('#footerSearch').toggleClass('searchFocus');
});
