function check_text_shadow (checkbox) {
	parentObj = $(checkbox).parent();
	if (checkbox.checked) parentObj.addClass("text_shadow");
	else parentObj.removeClass("text_shadow");
}

function check_subgroups (obj) {
	$(obj).parent().parent().next().find("input[type=checkbox]").attr("checked", (obj.checked ? "checked" : "")).change();
}

function check_subgroups_method_1 (obj) {
	$(obj).parent().parent().parent().find("td.for_check").find("input[type=checkbox]").attr("checked", (obj.checked ? "checked" : "")).change();
}

function check_input_by_id (id, check) {
	var obj = $("#" + id);
	obj.attr("checked", (check ? "checked" : ""));
	if (obj[0] != undefined) check_text_shadow(obj[0]);
}

$(document).ready(function() {
	
	$('#demo-tip-darkgray1').poshytip({
		className: 'tip-darkgray',
		bgImageFrameSize: 11,
		offsetX: -25
	});
	$('#demo-tip-darkgray2').poshytip({
		className: 'tip-darkgray',
		bgImageFrameSize: 11,
		offsetX: -25
	});
	$('#demo-tip-darkgray3').poshytip({
		className: 'tip-darkgray',
		bgImageFrameSize: 11,
		offsetX: -25
	});

	$(window).scroll(function () { 
		
		topHeight = $('#wrapp_for_slide_panel').height();
		offset = $(document).scrollTop() - topHeight;
		
		if (offset > 0) $("#stat_numbs > .images_panel,#stat_filter > .images_panel").animate({top:(offset+"px")},{duration:500,queue:false});
		else $("#stat_numbs > .images_panel,#stat_filter > .images_panel").animate({top:0},{duration:500,queue:false});
	});


	$('#stat_numbs .images_panel').click(function(){
		
		$('#stat_numbs .slider_item').toggle("slow");
		$(this).toggleClass("open");
	});		

	$('#stat_filter .images_panel').click(function(){
		
		$('#stat_filter .slider_item').toggle("slow");
		$(this).toggleClass("open");
	});		
		
	$('.content_slider .images_panel').click(function(){
		
		$('.content_slider .slider_item').toggle("slow");
		$(this).toggleClass("close");
	});
	
	$('input[type=checkbox]').change(function() {	
		check_text_shadow(this);
	});
	
});

$(window).load(function () {

	// fix catalog item height
	$('#sliders > #stat_numbs, #sliders > #stat_filter').each(function() {
		$this = $(this);
		var maxContentHeight = $this.parent().height();
		$(this).height(maxContentHeight);
	});
	
	$('input[type=checkbox]:checked').each(function(){
		check_text_shadow(this);
	});
	
	$('input.no_use_filter_checkbox').click(function(){
		$(this).parent().parent().next().find('input').attr('disabled', (this.checked ? 'disabled' : ''));
	});
	
	$('input.no_use_filter_checkbox:checked').each(function(){
		$(this).parent().parent().next().find('input').attr('disabled', 'disabled');
	});
});
