var red_val = 0;
var green_val = 0;
var blue_val = 0;
var text_color = 0;

function dc_cms_show_tab(tab_id)
{
	for(i = 1; document.getElementById('dc_cms_tab_' + i) ; i++)
	{
		document.getElementById('dc_cms_tab_' + i).style.display = 'none';
		document.getElementById('dc_cms_tab_sel_' + i).style.backgroundColor = '#c4d3db';
		document.getElementById('dc_cms_tab_sel_' + i).style.color = "#888888";
	}
	document.getElementById('dc_cms_tab_' + tab_id).style.display = 'block';
	document.getElementById('dc_cms_tab_sel_' + tab_id).style.backgroundColor = '#EAEAEA';
	document.getElementById('dc_cms_tab_sel_' + tab_id).style.color = "#000000";
	
	dc_cms_get_category_list();
}


function dc_show_status(text, type, dont_close)
{
	if(type == 'error')
	{
		document.getElementById('dc_status_type').innerHTML = 'Błąd: ';
		$(function()
		{
			$('#dc_status_content').html(text);
			if (dont_close) 
			{
				$('#dc_status_line').css('background-color', 'rgb(255, 30, 30)').show();
			}
			else
			{
				$('#dc_status_line').css('background-color', 'rgb(255, 30, 30)').show().fadeOut(5000);
			}
		});

	}
	else if(type == 'warning')
	{
		document.getElementById('dc_status_type').innerHTML = 'Ostrzeżenie: ';
		$(function()
		{
			$('#dc_status_content').html(text);
			if (dont_close) 
			{
				$('#dc_status_line').css('background-color', 'rgb(255, 204, 0)').show();
			}
			else
			{
				$('#dc_status_line').css('background-color', 'rgb(255, 204, 0)').show().fadeOut(5000);
			}
		});

	}
	else
	{
		document.getElementById('dc_status_type').innerHTML = 'Informacja: ';
		$(function()
		{
			$('#dc_status_content').html(text);
			if (dont_close) 
			{
				$('#dc_status_line').css('background-color', 'rgb(255, 204, 0)').show();
			}
			else
			{
				$('#dc_status_line').css('background-color', 'rgb(255, 204, 0)').show().fadeOut(5000);
			}
		});

	}


	
}



function dc_status_color(type)
{
	document.getElementById('dc_status_line').style.backgroundColor='rgb(' + red_val + ', ' + green_val + ', ' + blue_val +')';
	document.getElementById('dc_status_line').style.color='rgb(' + text_color + ', ' + text_color + ', ' + text_color +')';
	next = false;
	if(red_val > 234)
	{
		red_val--;
		next = true;
	}
	if(green_val < 234)
	{
		if(type == 'error' || type == 'warning')
		{
			green_val += 4;
		}
		else
		{
			green_val++;
		}
		next = true;
	}
	if(blue_val < 234)
	{
		if(type == 'error' || type == 'warning')
		{
			blue_val += 4;
		}
		else
		{
			blue_val += 2;
		}
		next = true;
	}
	
	if(text_color < 234)
	{
		text_color += 2;
		if(type == 'error' || type == 'warning')
		{
			text_color += 3;
		}
		else
		{
			text_color += 2;
		}
		next = true;
	}
	
	if(next)
	{
		setTimeout('dc_status_color("' + type + '")', 1);
	}
}





function dc_show_tooltip(name)
{
	if (name == 'fixed_dose') 
	{
		dc_show_status('Jest to ustalona porcja produktu jaką użytkownik może jednorazowo wybrać (np. produkt w saszetkach o ustalonej porcji 30 g). <span onclick="dc_hide_tooltip()" class="dc_tooltip_link">[ukryj]</span> ', 'Info', true);
	}
	else if (name == 'quantity') 
	{
		dc_show_status('Jest to podstawowa ilość produktu (najczęściej 100 g lub 100 ml), dla której określamy wartości odżywcze. <span onclick="dc_hide_tooltip()" class="dc_tooltip_link">[ukryj]</span> ', 'Info', true);
	}
}

function dc_hide_tooltip()
{
	$('#dc_status_line').hide();
}


