$(document).ready(function(){
	$(".consult-content .dt,.consult-content .dd").live('click', function(){
		if($(".hellip",$(this)).is(":visible")) {
				$(".hellip",$(this)).addClass("hide")
				$(".full",$(this)).fadeIn()
				$(".short",$(this)).addClass("expanded")
		}else {
				$(".hellip",$(this)).removeClass("hide")
				$(".full",$(this)).hide()
				$(".short",$(this)).removeClass("expanded")
		};
	});
	$(".consult-content .dt,.consult-content .dd").each(function() {
		if ($(".full",$(this)).length>0) {
			$(".full",$(this)).parent().find(".short").addClass("has-full")
		};
	});
	
	$(".agent-consults .question").click(function() {$(this).parent("dt").next("dd").slideToggle("fast");return false});
	$(".agent-consults .answer").click(function() {$(this).parent("dd").slideUp("fast"); return false});
});

(function($) {
    $.fn.toggleDisabled = function() {
		return this.each(function() {
            var $this = $(this);
            if ($this.attr('disabled')) $this.removeAttr('disabled');
            else $this.attr('disabled', 'disabled');
				});
	};
})(jQuery);
$(function() {
    $('input:button').click(function() {
        $('input:text').toggleDisabled();
	});
});

var z = 999;
/*
	***** Carousels *****
*/
function f_initCallback (carousel) {
	/*$('.featured-offers-control .next').bind('click', function() {
		carousel.next();
		return false;
	});
	$('.featured-offers-control .prev').bind('click', function() {
		carousel.prev();
		return false;
	});*/
};

function mycarousel_initCallback(carousel, state) {
    var b = $(".consult-bubble").width()
	var li = $(".consult-carousel li")
	li.css("width",b-36);
};
$(document).ready(function() {
	$(".consult-bubble li .consultant-name").each(function(i) {
		$(this).appendTo("#consultant").attr("id","cons-"+i+"").addClass("hide");
		$("#cons-0").show();
	});
});
function mycarousel_itemVisibleInCallbackBeforeAnimation(carousel, item, idx, state) {
    if (state == 'init')
        return;
};
function mycarousel_itemVisibleInCallbackAfterAnimation(carousel, item, idx, state) {
	i = idx-1;
	$("#cons-"+i+"").show().nextAll().hide();
	$("#cons-"+i+"").show().prevAll().hide();
};
function mycarousel_reloadCallback(carousel,state) {
	var b  = $(".consult-bubble").width();
	var li = $(".consult-carousel li");
	li.each(function(i) {
		$(this).css({
			"width":b-36
		})
	});
};
function place_fadeout (carousel) {
	$(".tabs-carousel").parents(".jcarousel-clip-horizontal").after('<div class="fadeout"></div>')
}
function consult_loadajax (carousel, state){
		if(state=='next'){
				$.ajax({
					url:'/cons/conswidget_ajax.php',
					data:{cat:0},
					dataType: 'json',
					success:function(m){
							var size = carousel.last+1;
							carousel.add(size, m[0].answ);
					
					  }
				});

		}
}

$(document).ready(function() {
					
	
	if ($('.consult-carousel').length>0) {
		$('.consult-carousel').jcarousel({
			scroll:1,
			visible:1,
			reloadCallback: mycarousel_reloadCallback,
			initCallback:   mycarousel_initCallback,
			itemVisibleInCallback: {
				onBeforeAnimation: mycarousel_itemVisibleInCallbackBeforeAnimation,
				onAfterAnimation:  mycarousel_itemVisibleInCallbackAfterAnimation
			}
			//itemLoadCallback: consult_loadajax
		});	
	};
	$(".consult-bubble .jcarousel-prev,.consult-bubble .jcarousel-next").click(function() {
		$(".consult-bubble .hellip").removeClass("hide");
		$(".consult-bubble .full").hide();
		$(".consult-bubble .short").removeClass("expanded");
	});
	
});

function dummyObject()
{
	
}
