Cufon.replace('.slider-holder ul li .slide-cnt h2, .banner h2, .cols .col h2, h1#logo a span, .cufon-replace, .intro .left h4, .sec-banner h2, #landing-banner h2, #landing-content h2, #landing-content h3, #landing-content h4, #intuit-main-banner h2, #intuit-main-banner .feature-box h3, #induit-tabs-body .tab-content h3, #induit-tabs-body .pleased-customer-content h4, .press-kit-widget h3, .press-kit-widget h4');
Cufon.replace('.yellow-gradient-box h2, .intro h2, .intro h3, .product h2, .cols .col .img h3, .join-banner h2, .dark-box p strong, .services .entry h2 a, a.more-industries, .contacts p.live-chat', { hover: true });

jQuery(function($){
	//Home slider configuration
	var slider_anim_speed = "slow";
	var slider_change_timeout = 6000;
	var slider_cont = $('#the-home-slider .slider-holder');
	var slider_nav = $('#the-home-slider .slider-navigation');
	
	//Home slider functions
	function change_slide(idx) {
		var current = slider_cont.find('li').index(slider_cont.find('li:visible'));
		if (idx == current) {
			return false;
		}
		slider_cont.find('li:eq(' + current + ')').fadeOut(slider_anim_speed);
		slider_cont.find('li:eq(' + idx + ')').fadeIn(slider_anim_speed);
		slider_nav.find('a.active').removeClass('active');
		slider_nav.find('a:eq(' + idx + ')').addClass('active');
	}
	
	function auto_change_slide() {
		var current = slider_cont.find('li').index(slider_cont.find('li:visible'));
		var total = slider_cont.find('li').length;
		if (current < total - 1) {
			current++;
		} else {
			current = 0;
		}
		change_slide(current);
		timeout = setTimeout(auto_change_slide, slider_change_timeout);
	}
	
	var timeout = setTimeout(auto_change_slide, slider_change_timeout);
	
	slider_nav.find('a').click(function() {
		if ($(this).hasClass('active') || slider_cont.find('li:animated').length > 0) {
			return false;
		}
		var idx = slider_nav.find('a').index($(this));
		clearTimeout(timeout);
		change_slide(idx);
		timeout = setTimeout(auto_change_slide, 5000);
		return false;
	});
		
	$('.top-navigation span:last').remove();
	$('#navigation > ul > li').each(function() {
		if($(this).find('ul').length < 1) {
			return true;
		}
		$(this).find('ul').wrap('<div class="dd"><div class="dd-c"></div></div>');
		$(this).find('ul').show();
		$('<div class="dd-b"></div>').insertAfter($(this).find('.dd-c'));
		$(this).find('.dd a').each(function() {
			$(this).html($(this).text());
		});
	});
	
	$("#navigation ul li").hover(function() {
		if(!($(this).find(".dd").is(':animated'))) {
    		$(this).find(".dd").show();
    		$(this).find("a:eq(0)").addClass('hover');
    	}	
	}, function(e) { 
			$(this).find(".dd").hide();
			$(this).find("a:eq(0)").removeClass('hover');
	});
	
    
    $(".tab").hide(); 
    $('.tab').each(function() {
    	$(this).find('li:last').addClass('last');
    });
	$("ul.tabs-navigation li:first").addClass("active").show(); 
	$(".tab:first").show(); 
	
	$("ul.tabs-navigation li").click(function() {
		$("ul.tabs-navigation li").removeClass("active");
		$(this).addClass("active");
		$(".tab").hide();
		var activeTab = $(this).find("a").attr("href");
		$(activeTab).fadeIn();
		return false;
	});
  
	$('select.custom-select').selectbox();  
	
	if($.browser.msie && $.browser.version==6) {
		DD_belatedPNG.fix('.certificate-box .img a img');
        DD_belatedPNG.fix('.destination img'); 
        DD_belatedPNG.fix('.sec-banner-cnt'); 
        DD_belatedPNG.fix('.eco-banner ul li, .sidebar .activity span.ico'); 
	}
	
	
	$('.blink').focus(function () {
		if ($(this).val() == $(this).attr('title')) {
			$(this).val('');
		}
	});
	
	$('.blink').blur(function () {
		if ($(this).val() == '') {
			$(this).val($(this).attr('title'));
		}
	});
	
	$('.the-blog .entry:last').addClass('last-entry');
	$('#blog-sidebar .box:last').addClass('last-box');

	$('.the-blog .jquery-selectbox-item').click(function() {
		var classes = $(this).attr('class').split(' ');
		for(var i = 0; i < classes.length; i++) {
			if (classes[i].indexOf('value-') > -1) {
				var loc = classes[i].replace('value-', '');
				window.location.href = loc;
			}
		}
	});
	$('.subscribe p').click(function(){ 
		$('.subscribe span.custom-checkbox').click();
	}); 
	 
	$('.subscribe span.custom-checkbox').click(function(){ 
	     
	    if($(this).hasClass('checked')){ 
	        $(this).removeClass('checked'); 
	        $('input.custom-check').val('0'); 
	    } else { 
	        $(this).toggleClass('checked'); 
	        $('input.custom-check').val('1'); 
	    } 
	}); 

	$('.vertical-partners a img').each(function() {
		var img = new Image();
		img.src = $(this).attr('src');
		if (img.width > 124) {
			$(this).css('width', 124);
		}
	});
	
	$('.default-content p img').each(function() {
		if ($(this).is(':only-child')) {
			$(this).parent().css('margin-bottom', -15);
		}
	});
	
	$('.latest-reviews-for-this-business').each(function() {
		$(this).find('.event:last').addClass('last-event');
	});
	$('.the-upcoming-events').each(function() {
		$(this).find('.event:first').addClass('last-event');
		if ($(this).find('.event').length < 2) {
			$(this).find('.view-all-link').remove();
		}
	});

	$('#show-all-cats').click(function() {
		$(this).parents('.cats:eq(0)').find('ul li').show();
		$(this).remove();
		return false;
	});

	$('.the-upcoming-events .view-all-link').click(function() {
		var cnt = $(this).parents('.the-upcoming-events:eq(0)');
		cnt.find('.event').show();
		cnt.find('.event').removeClass('last-event');
		cnt.find('.event:last').addClass('last-event');
		$(this).remove();
		return false;
	});

	$(window).load(function() {
		var h = 66;
		$('.clients-min a img').each(function() {
			if ($(this).height() > h) {
				$(this).height(h);
			} else {
				var target = (h-$(this).height()) / 2;
				$(this).css({
					'padding-top': target,
					'padding-bottom': target
				});
			}
		});
	});
	
	$('.entry-row').each(function() {
		var rel = $(this).attr('rel');
		var h = 0;
		$('.entry-row[rel="' + rel + '"] .entry-bottom').each(function() {
			if ($(this).height() > h) {
				h = $(this).height();
			}
		});
		
		$('.entry-row[rel="' + rel + '"] .entry-bottom').each(function() {
			$(this).height(h);
		});
		
	});
	
	$('p.live-chat a').live('click', function() {
		var href = $('#live_chat_status').find('a:eq(0)').attr('href');
		if (href) {
			window.location.href = href;
		};
		return false;
	});
	
	$('#intuit-main-banner .feature-box').each(function() {
		var h3 = $(this).find('h3');
		h3.css('padding-top', (75-h3.height()) / 2 );
	});
	
	$('.pleased-customers-nav a').click(function() {
		var cont = $(this).parents('.pleased-customers:eq(0)');
		var idx = cont.find('.pleased-customers-nav a').index($(this));
		cont.find('.pleased-customer-content').hide();
		cont.find('.pleased-customer-content:eq(' + idx + ')').show();
		cont.find('.pleased-customers-nav a.active').removeClass('active');
		$(this).addClass('active');
		return false;
	});
	
	$('#intuit-tabs-head a').click(function() {
		var cont = $('#intuit-tabs');
		var idx = $('#intuit-tabs-head a').index($(this));
		cont.find('.tab-content').hide();
		cont.find('.tab-content:eq(' + idx + ')').show();
		$('#intuit-tabs-head a.active').removeClass('active');
		$(this).addClass('active');
		return false;
	});

    $('.commenting label').click(function(){ 
        if($(this).find('input').is(':checked')){ 
            $(this).find('input').attr('checked', false); 
            $(this).removeClass('checked'); 
        } else { 
            $(this).find('input').attr('checked', true); 
            $(this).addClass('checked'); 
        } 
    }); 
     
    $('.sidebar ul.posts-list, .widget_recent_entries ul').each(function(){ 
        $(this).find('li:last').addClass('last'); 
    }) 

    $('.product-box .img object').each(function() {
    	var url = $(this).find('param[name="movie"]').attr('value');
    	$(this).wrap('<div class="video-container"></div>');
    	$('<div class="video-trigger"></div>').insertAfter($(this));
    	$(this).wrap('<div class="video-wrapper"></div>');
    	$(this).parents('.video-container').find('.video-trigger:eq(0)').bind('click', function() {
    		$.fancybox({
    			'href':  url,
    			'type': 'iframe'
    		});
    	});
    });

    $('.related-posts ul li:last').addClass('last'); 

    $('.page-template-signup-step-1-php .f-step-right .partner-logos img:last').addClass('last');

    $(window).load(function() {
	   	$('.default-content iframe[src*="youtube.com"]').each(function(i) {
	    	setTimeout(function () {
	    		$('.default-content iframe[src*="youtube.com"]:eq(' + i + ')').css('display', 'inline');
	    	}, (i+1)*300);
	    });
    });
    
});
