(function($) {
	$(document).ready(function(){
		// console.log($('img[src*="timthumb"]'));
		// $('img[src*="timthumb"]').data('has_loaded', false);
		$('img[src*="timthumb"]').load(function (a) {
			$(this).data('has_loaded', true);
		});

		$(window).load(function(){
			$('img[src*="timthumb"]').each(function(){
				if (! $(this).data('has_loaded')) {
					$(this).attr('src',$(this).attr('src'));
				};
			});
		})
		
		$('.post-faqs .post-head h3 a').click(function(){
			var div = $(this).parent().parent().parent().find('.post-content');
			div.slideToggle();
			return false;
		});

		$("a.service-fancy-image").fancybox(
			{
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
			}
		);

		$('#sidebar ul li.widget ul li:last').each(function(){
			$(this).addClass('last');
		});

		$( ".gform_wrapper .ginput_container input, .gform_wrapper .ginput_container textarea" ).each(function(){
			$(this).attr('title', $(this).val() );
		});

		$('.gform_wrapper .ginput_container input, .gform_wrapper .ginput_container textarea').focus(function() {
			if(this.title==this.value) {
				this.value = '';
			}
		}).blur(function(){
			if(this.value=='') {
				this.value = this.title;
			}
		});

		// $('.sub-menu .sub-menu').addClass('second-sub-menu');
		$("#navigation > ul > li").hover(function() {
			if(!($(this).find(">ul").is(':animated')) && $(this).find("ul").length){
				$(this).addClass('hovered');
				$(this).find(">ul").slideDown('fast');
			}
		}, function(e) {
			var dis = $(this);
			$(this).find(">ul").slideUp('fast', function(){
				dis.removeClass('hovered');
			});
		});

		$("#navigation > ul > li > .sub-menu > li").hover(function() {
			$(this).find('ul').show()
		}, function(e) {
			$(this).find('ul').hide();
		});

		$('.faqs-list ul li:last, #sidebar ul li.news-list ul li:last').addClass('last');

		$(".slider").jcarousel({
			scroll: 1,
			auto: 6000,
			wrap: 'circular',
			buttonNextHTML: null,
			buttonPrevHTML: null
		}); 


		slide_number = 0;
		$( ".clients ul li" ).each(function(){
			slide_number++;
		})
		$(".clients").jcarousel({
			animation: slide_number*2700,
			scroll: slide_number,
			auto: 1,
			wrap: 'circular',
			buttonNextHTML: null,
			buttonPrevHTML: null
		}); 
		
		// $('.clients .shell ul').animate('left');

	})
})(jQuery)
