function pageLoaded() {
	Cufon.replace('#navigation a', { fontFamily: 'MyriadPro', hover: true} );

	Cufon.now();
};

jQuery(document).ready(function($) {
	
	$('.blink').live('focus', function () {
		if ($(this).val() == $(this).attr('title')) {
			$(this).val('');
		}
	})
	$('.blink').live('blur',function () {
		if ($(this).val() == '') {
			$(this).val($(this).attr('title'));
		}
	});
	
	$('#navigation li').hover(
		function() {
			$(this).find('ul:eq(0)').show();
		},
		function() {
			$(this).find('ul:eq(0)').hide();
		}
	);
	$('#featured .menu li').hover(
		function() {
			$(this).find('ul:eq(0)').show();
		},
		function() {
			$(this).find('ul:eq(0)').hide();
		}
	);
	
	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
		DD_belatedPNG.fix('.emp-box .arrow, #featured .info .box , .bullet-list li, #featured .menu li a');
	};
	
	$('#featured .btn-video').click(function() {
		$.fancybox({
			  'padding'             : 0,
	          'autoScale'   		: false,
	          'transitionIn'        : 'none',
	          'transitionOut'       : 'none',
	          'title'               : this.title,
	          'width'               : 480,
	          'height'              : 385,
	          'href'                : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/')  + '&autoplay=1',
	          'type'                : 'swf',    // <--add a comma here
	          'swf'                 : {'allowfullscreen':'true', 'wmode':'transparent'} // <-- flashvars here
		});
		return false;
	});
	
	$('.featured-products-box .tabs li a').click(function() {
		$('.featured-products-box .tabs li a').removeClass('active');
		$(this).addClass('active');
		
		var href = $(this).attr('href');
		$('.featured-products-box .body a').fadeOut(800);
		$(href).fadeIn(800);
		return false;
	});
	
	if ($('.tab-slider').length) {
		$(".tab-slider > ul").jcarousel({
			scroll: 1,
			wrap: 'both',
			initCallback: mycarousel_initCallback,
			itemVisibleInCallback: mycarousel_itemVisibleInCallback,
			buttonNextHTML: null,
			buttonPrevHTML: null
	    });
	};
	
	if ($('.help-center li .link-call').length) {
		$('.help-center li .link-call').tipsy({
			fade: true, 
			gravity: 'e'
		});	
	};
	
	$('.highlights a, .help-center li .link-ask').fancybox();	
	
	$('#ask-expert form').live('submit', function() {
		var th = $(this);
		var email_regex = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?";
		
		if (!th.find('input[name="to_email"]').val().match(email_regex)) {
			alert('Please input a correct email of an expert.');
			th.find('input[name="to_email"]').focus();
			return false;
		}
		
		if (th.find('textarea[name="question"]').val() == '' || th.find('textarea[name="question"]').val() == undefined) {
			alert('Please input a correct question.');
			th.find('textarea[name="question"]').focus();
			return false;
		}
		
		if (!th.find('input[name="from_email"]').val().match(email_regex)) {
			alert('Please input your correct email.');
			th.find('input[name="from_email"]').focus();
			return false;
		}
		
		$.ajax({  
			type: "POST",  
			url: $(this).attr('action'),
			data: "send_form=yes&to_email=" + $(this).find('input[name="to_email"]').val() + "&question=" + $(this).find('input[name="question"]').val() + "&from_email=" + $(this).find('input[name="from_email"]').val(),
			success: function(response) { 
				th.html('<p style="text-align: center;">' + response + '</p>');
				setTimeout(function() {
					$.fancybox.close();
				}, 1500);
			}
		});
		
		return false;
		
	});
	
	// custom checkboxes
	if ($('#assessments .checklist .checkbox').length) {
		$('#assessments .checklist .checkbox').prettyCheckboxes();
	};
	
	$('.descr table').css('height', '');
	
});
function mycarousel_initCallback(carousel) {
	$(".tab-slider .slider-navigation a").click(function(){
    	var x = parseInt($(this).text());
    	carousel.scroll(x);
    	return false;
    });
    
	$('.tab-slider .slider-controls a.next').click(function() {
		carousel.next();
		return false;
	});
	
	$('.tab-slider .slider-controls a.prev').click(function() {
		carousel.prev();
		return false;
	});
};

function mycarousel_itemVisibleInCallback(carousel, li, pos, state) {
	$(".tab-slider .slider-navigation a").removeClass('active');
	$(".tab-slider .slider-navigation a").eq(pos-1).addClass('active');
};

