if (typeof console == 'undefined'){
	window.console = {
		log:function(){},
		info:function(){},
		error:function(){},
		warn:function(){}
	}
}


function myload(div, url)
{
	$(div).css("opacity", 0.3);
	$(div).load(url, null, function(){
		$(div).css("opacity", 1.0);
	});
}

function open_message(url, title, width, height, scroll)
{
	$.akModalRemove();
	window.__url = url;
	window.__title = title;
	window.__width = width;
	window.__height = height;
	window.__scroll = scroll;
	window.__open = setInterval(open_message_, 800);
}


function open_message_()
{
	clearInterval(window.__open);
	$.showAkModal(__url, __title, __width, __height, __scroll);
	clearInterval(window.__open);
}


function onkeypress_search(div, url, input)
{
	clearInterval(window.__copen);
	window.__cdiv = div;
	window.__curl = url;
	window.__cinput = input;
	window.__copen = setInterval(onkeypress_search_, 500);
}

function onkeypress_search_()
{
	myload(__cdiv, __curl+$('#'+window.__cinput).val());
	clearInterval(window.__copen);
}

function checkAll(sender,pattern)
{
	if (sender.checked)  $("input[@name='"+pattern+"[]']").attr('checked','1');
	else $("input[@name='"+pattern+"[]']").removeAttr('checked');

//$('#'+pattern+'*');
}

function submitFormUsers()
{
	var error = 0;
	if ($("input[@name='cb_u[]']:checked").length == 0) {
		error = 1;
	}
	if ($("#email_temat").val() == '') {
		error = 2;
	}
	if ($("#email_tresc").val() == '') {
		error = 3;
	}
	switch(error)
	{
		case 1:
			alert('Zaznacz użytkowników');
			break;
		case 2:
			alert('Podaj temat');
			break;
		case 3:
			alert('Wypełnij treść');
			break;
		case 0:
			$('#users').submit();
			break;
	}
}

function endisPlik(elem)
{
	if(elem.value == '2') $("#plik").attr('disabled','1');
	else $("#plik").removeAttr('disabled');
}

/*
$(".loading")
.ajaxStart(function(){
    alert('start');
    
    m_l = ($(this).parent().width() - 32) / 2;
    m_t = ($(this).parent().height() - 32) / 2;
    $(this).css({"margin" : marg_t+"px "+marg_l+"px "+marg_t+"px "+marg_l+"px"})

    $(this).show();
})
.ajaxComplete(function(){
    $(this).hide();
});
*/

window.window_nr = 0;
window.__div_backup = new Array();
window.window_index = 0;
window.window_list = new Array();

$(document).ready(function()
{
	//$("#loading")
	$("#l2").bind("ajaxStart", function(event,request, settings){
		//alert('start\nevent: '+event.toSource()+'\nrequest: '+request+'\nsettings: '+settings);
		//alert("t:"+$(window).scrollTop());
		//alert('jkhjk');

		var t = $(window).height() / 2 - $("#ll").height() / 2 + $(window).scrollTop();
		var l_ll = $(window).width() / 2 - $("#ll").width() / 2;
		//alert('top:'+t);
		$("#ll").css('padding-left',l_ll);
		$(this).css('padding-top',t);
		//$("#ll").css('top',t);
		$(this).width($(window).width());
		$(this).height($(document).height());
		//$(this).css('top',$(window).scrollTop());
		$(this).css("opacity", 0.3);
		$(this).show();

	})
	.bind("ajaxComplete", function(event,request, settings){
		//alert('complete\nevent: '+event+'\nrequest: '+request+'\nsettings: '+settings);

		//$(this).css("opacity", 1.0);
		$(this).hide();
	});

	tipsReload();
	//alert(window.location.hash);
	//if (window.location.hash.substr(1))
	//aLoad(window.location.hash.substr(1));
	openMessages(ajaxMessages);
	$('a').attr('onfocus', 'blur()');
//$('embed').attr('wmode', 'transparent');
//$('embed').css('z-index', '1');
//alert('aaa');
} );

function loader_show(){

}

function loader_hide(){

}

function aLoad(url, data, div, change_hash)
{
    
 
	//url = '?';
	if (change_hash == true) window.location.hash = data;
	data += '&ajax=1';

	// spowoduje dodanie loadera w divy
	// ich zawartość zostanie zachowana. Funkcja restoreDivs() przywróci ich zawartość jeśli operacja jest przerwana
	if (typeof(div)!='object' || !(div instanceof Array) && div != '') div = new Array(div);
	if (div != ''){
		for(i = 0; i < div.length; i++)
		{
			marg_l = ($(div[i]).width() - 32) / 2;
			marg_t = ($(div[i]).height() - 32) / 2;
			window.__div_backup[i] = new Array(div[i], $(div[i]).html());
			$(div[i]).html("<img style='margin: "+marg_t+"px "+marg_l+"px "+marg_t+"px "+marg_l+"px' src='images/loading.gif' />");
		//alert(div[i]);
		}
	}

	window.__url = url;
	window.__data = data;
	window.__div = div;

	document.body.style.cursor = 'wait';
	$.ajax(
	{
		type: "POST",
		//url: url+"&ajax=1",
		url: url,
		data: data,
		async: true,
		dataType: "json",
		//global: false,
		success: function(values)
		{
			//restoreDivs();
			//alert(typeof values+' | '+values);
			//console.log(values);
			openMessages(values);
			document.body.style.cursor = 'default';
		},
		error: function()
		{
			restoreDivs();
			document.body.style.cursor = 'default';
		}
	});

	return false;
}

function openMessages(values)
{
	if(values)
	{
		//alert(values.toSource());
		//alert(values.toString());
		$.each(values, function(key, value)
		{
			//alert(value['html']);
			//alert(key.toSource());
			//alert(value.toSource());
			/* max 600 okien lub to samo okno */
			if (value['message'] == 'window_open' && ( value['same_window'] || window.window_nr < 600 ) )
			{
				if (!value['same_window'])
				{
					window.window_nr++;
					if (value['window_id']) okno = 'message_html_id_'+value['window_id'];
					else okno = 'message_html'+window.window_nr;
					

					$("<div></div>").attr('id', okno).appendTo("#message_hidden");

					okno = '#'+okno;
					$(okno).attr('title', value['title']);
					if (window.window_list.length == window.window_index)
					{
						window.window_list.push(okno);
						window.window_index++;
					} else
{
						window.window_list[window.window_index] = okno;
						window.window_index++;
					}
				//
				} else
{
					//okno = '#message_html'+window.window_nr;

					if (value['window_id']) okno = '#message_html_id_'+value['window_id'];
					else okno = window.window_list[window.window_index - 1];
					//$(okno).css('display', 'none');
					$(okno).dialog('option', 'title', value['title']);
				}
				if (value['div_hide']) $(okno).css('display', 'none');
				$(okno).html(value['html']);

				//alert(value['title']+' = window_id: '+okno);

				if (!value['width']) value['width'] = 500;
				if (!value['height']) value['height'] = 'auto';
				if (!value['modal']) value['modal'] = true;
				$(okno).dialog({
					autoOpen: false,
					beforeclose: function(event, ui) {
						closeWindow();
						return false;
					}
				});
				$(okno).dialog('option', 'width', value['width']);
				$(okno).dialog('option', 'minwidth', value['width']);
				$(okno).dialog('option', 'maxwidth', value['width']);
				$(okno).dialog('option', 'height', value['height']);
				$(okno).dialog('option', 'modal', value['modal']);
		
				$(okno).dialog('open');
				tipsReload();
			} else
			if (value['message'] == 'go_to_location')
			{
				window.location = value['location'];
			} else
			if (value['message'] == 'close_window')
			{
				closeWindow();
			} else
			if (value['message'] == 'restore_window')
			{
				restoreWindow();
			} else
			if (value['message'] == 'restore_divs')
			{
				restoreDivs();
			} else
			if (value['message'] == 'callback'){
				var f = value['callback'];
				if(typeof window[f] == 'function') {
					//console.log(value['params']);
					if (typeof value['params'] == 'undefined')
						window[f]();
					else
						window[f](value['params']);
				}
			} else
			if (value['message'] == 'aLoad_callback'){
				var p = value['params'];
				aLoad(p['url'],p['data']);
			} else
			if (value['message'] == 'refresh'){
				setTimeout("location.reload(true);",value['timeout']+1);
			//window.location.reload(true);
			} else
			if (value['message'] == undefined && value['html'] == undefined)
			{
			} else
{
				//alert(value['div']+"\n\n"+value['html']);
				$(value['div']).html(value['html']);
				$(value['div']).css("opacity", 1.0);
				tipsReload();
			}
		});
	}
	return true;
}

function go_to_location(location){
	window.location = location;
}

function closeWindow(after_close_callback, after_close_callback_params)
{
	if (window.window_nr > 0)
	{
		window.window_index--;
		window.window_nr--;
		//alert(window.window_list[window.window_index]);
		$(window.window_list[window.window_index]).dialog('destroy');
		$(window.window_list[window.window_index]).remove();

		if (typeof after_close_callback != 'undefined'){
			if(typeof window[after_close_callback] == 'function') {
				if (typeof after_close_callback_params == 'undefined')
					window[after_close_callback]();
				else
					window[after_close_callback](after_close_callback_params);
			}
		}
	}
}

function restoreWindow()
{
}

function restoreDivs()
{
	$.each(window.__div_backup, function(key, value) {
		$(value[0]).html(value[1])
	});
	window.__div_backup = new Array();
}

function aloadRepeat(key, value, close)
{
	if (close) $.fn.colorbox.close();
	if (key == '__cancel') {
		cancelOperation();
	} else
	if (key == '__close_message') { }
	else
		aLoad(window.__data+'&'+key+'='+value, window.__div, -1);
}

function tipsReload()
{
	$(function(){
		$("*[tip]").jHelperTip({
			trigger: "hover",
			source: "attribute",
			attrName: "tip",
			opacity: 0.9,
			autoClose:true
		});
	});
}

// zapisuje zmiany zrobione w FCK do textarea
// wywołać trzeba przed wystłaniem AJAXem formularza
function saveFckData()
{
	for (i = 0; i < fck_editors.length; i++) fck_editors[i].UpdateLinkedField();
}

/*
// called when FCKeditor is done starting..
function FCKeditor_OnComplete( editorInstance ){
	//editorInstance.LinkedField.style.display = 'inline';
	fck_editors[fck_editors.length] = editorInstance;
}
*/
function handleEnter(e, action)
{
	var characterCode;
	if(e && e.which)
	{
		e = e;
		characterCode = e.which;
	}
	else
	{
		e = event;
		characterCode = e.keyCode;
	}

	if(characterCode == 13)
	{
		eval(action);
		return false;
	}
	else
	{
		return true;
	}
}

function myalert(title, message, width)
{
	v = new Array();
	v['title'] = title;
	if (width) v['width'] = width; else v['width'] = 390;
	v['height'] = 150;
	v['message'] = 'window_open';
	v['html'] = message+"<ul class='buttons'><li class='button' onclick='closeWindow()'>Ok</li></ul>";
	b = new Array();
	b[0] = v;
	openMessages(b);
	return false;
}

function myconfirm(title, message, on_yes)
{
	v = new Array();
	v['title'] = title;
	v['width'] = 390;
	v['message'] = 'window_open';
	v['html'] = message+"<ul class='buttons'><li class='button' onclick='closeWindow(); aLoad(\""+on_yes+"\")'>Tak</li><li class='button' onclick='closeWindow()'>Nie</li></ul>";
	b = new Array();
	b[0] = v;
	openMessages(b);
	return false;
}

jQuery.fn.extend({
	select: function()
	{
		nr = 0;
		return this.each(function() {

			id = $(this).attr('id')+'_sel';
			if ($('#'+id).attr('id') == id) $('#'+id).remove();

			$(this).removeClass('hide');
			width = $(this).width();
			pos = $(this).offset();
			$(this).addClass('hide');

			id_opts = id+'_opts';
			if ($('#'+id_opts+"cont").attr("id") == id_opts+"cont") $('#'+id_opts+"cont").remove();

			sel = $(this).attr('id');
			$(this).parent().append("<div id='"+id+"' style='width: "+width+"px' class='my_select'><div style='width: "+(width-20)+"px'></div></div>");
			$(this).parent().append("<div class='my_select_options_cont hide' id='"+id_opts+"cont' style='width: "+$('body').width()+"px; height: "+$('body').height()+"px'><div id='"+id_opts+"' class='my_select_options' style='left: "+pos.left+"px; top: "+(pos.top+25)+"px;'></div></div>"); //  style='width: "+width+"px'

			$('#'+$(this).attr('id')+' > *').each(function(i, el) {
				id_opt = id_opts+'_i'+i;
				$(el).attr('id', id_opt+'op');

				if ($(el).attr('selected'))
				{
					s = "selected='1' class='selected'";
					$('#'+id+' > div').html($(el).val());
				} else s = "selected='0'";

				if ($(el).html()) value = $(el).html(); else value = '&nbsp;';
				$('#'+id_opts).append("<div id='"+id_opt+"' "+s+" sel='"+sel+"' seldiv='"+id+"' multiple='"+$('#'+sel).attr('multiple')+"' optsdiv='"+id_opts+"' nr='"+i+"' key='"+$(el).attr('key')+"'>"+value+"</div>");
				$('#'+id_opt).hover(
					function () {
						if (!$(this).attr('selected')) $(this).toggleClass('selected');
					},
					function () {
						if (!$(this).attr('selected')) $(this).toggleClass('selected');
					} );

				$('#'+id_opt).click(
					function () {

						$('#'+$(this).attr('optsdiv')+'cont').fadeOut("fast");

						if ($(this).attr('multiple') == 'false')
						{
							// trigger onchange
							if ($(this).attr('nr') != $('#'+$(this).attr('sel')).attr('selectedIndex'))
							{
								$('#'+$(this).attr('sel')).attr('selectedIndex', ($(this).attr('nr')));
								$('#'+$(this).attr('sel')).change();
							}


							$('#'+$(this).attr('optsdiv')+" > *").removeClass('selected');
							$('#'+$(this).attr('optsdiv')+" > *").attr('selected', 0);

							$(this).attr('selected', 0);
							$(this).toggleClass('selected');
							$('#'+$(this).attr('seldiv')+' > div').html($(this).html());
						} else
{
							if ($(this).attr('selected') == 1)
							{
								$('#'+$(this).attr('id')+'op').attr('selected', 0)
								$(this).attr('selected', 0);
								$(this).toggleClass('selected');
							} else
{
								$('#'+$(this).attr('id')+'op').attr('selected', 1);
								$(this).attr('selected', 1);
								$(this).addClass('selected');
							}

							lista = '';
							$('#'+$(this).attr('optsdiv')+" > *[selected=1]").each(function(i, el) {
								if (lista != '') lista = lista + ", ";
								lista = lista + $(el).html();
							} );
							$('#'+$(this).attr('seldiv')+' > div').html(lista);
						}
					}
					);
			}
			);

			$('#'+id).click(function() {
				id_opts = $(this).attr('id')+'_optscont';
				id_ = $(this).attr('id')+'_opts';
				pos = $(this).offset();
				$('#'+id_).css('left', pos.left);
				$('#'+id_).css('top', pos.top + 25);
				$('#'+id_opts).fadeIn("fast");
			} );

			$('#'+id_opts+'cont').click(function() {
				$(this).fadeOut("fast");
			} );
			nr++;
		});
	}
});
jQuery.fn.extend({
	selectCountry: function(file_extension)
	{
		nr = 0;
		return this.each(function() {

			id = $(this).attr('id')+'_sel';
			if ($('#'+id).attr('id') == id) $('#'+id).remove();

			$(this).removeClass('hide');
			width = $(this).width();
			pos = $(this).offset();
			$(this).addClass('hide');

			id_opts = id+'_opts';
			if ($('#'+id_opts+"cont").attr("id") == id_opts+"cont") $('#'+id_opts+"cont").remove();

			sel = $(this).attr('id');
			$(this).parent().append("<div id='"+id+"' style='width: "+width+"px' class='my_select'><div style='width: "+(width-20)+"px'></div></div>");
			$(this).parent().append("<div class='my_select_options_cont hide' id='"+id_opts+"cont' style='width: "+$('body').width()+"px; height: "+$('body').height()+"px'><div id='"+id_opts+"' class='my_select_options' style='left: "+pos.left+"px; top: "+(pos.top+25)+"px;'></div></div>"); //  style='width: "+width+"px'

			$('#'+$(this).attr('id')+' > *').each(function(i, el) {
				id_opt = id_opts+'_i'+i;
				$(el).attr('id', id_opt+'op');

				if ($(el).attr('selected'))
				{
					s = "selected='1' class='selected'";
					$('#'+id+' > div').html($(el).val());
				} else s = "selected='0'";

				if ($(el).html()) value = $(el).html(); else value = '&nbsp;';
				$('#'+id_opts).append("<div id='"+id_opt+"' "+s+" sel='"+sel+"' seldiv='"+id+"' multiple='"+$('#'+sel).attr('multiple')+"' optsdiv='"+id_opts+"' nr='"+i+"' key='"+$(el).attr('key')+"'><img src='images/country/"+$(el).val()+"."+file_extension+"' alt='"+$(el).val()+"'/>&nbsp;"+value+"</div>");
				$('#'+id_opt).hover(
					function () {
						if (!$(this).attr('selected')) $(this).toggleClass('selected');
					},
					function () {
						if (!$(this).attr('selected')) $(this).toggleClass('selected');
					} );

				$('#'+id_opt).click(
					function () {

						$('#'+$(this).attr('optsdiv')+'cont').fadeOut("fast");

						if ($(this).attr('multiple') == 'false')
						{
							// trigger onchange
							if ($(this).attr('nr') != $('#'+$(this).attr('sel')).attr('selectedIndex'))
							{
								$('#'+$(this).attr('sel')).attr('selectedIndex', ($(this).attr('nr')));
								$('#'+$(this).attr('sel')).change();
							}


							$('#'+$(this).attr('optsdiv')+" > *").removeClass('selected');
							$('#'+$(this).attr('optsdiv')+" > *").attr('selected', 0);

							$(this).attr('selected', 0);
							$(this).toggleClass('selected');
							$('#'+$(this).attr('seldiv')+' > div').html($(this).html());
						} else
{
							if ($(this).attr('selected') == 1)
							{
								$('#'+$(this).attr('id')+'op').attr('selected', 0)
								$(this).attr('selected', 0);
								$(this).toggleClass('selected');
							} else
{
								$('#'+$(this).attr('id')+'op').attr('selected', 1);
								$(this).attr('selected', 1);
								$(this).addClass('selected');
							}

							lista = '';
							$('#'+$(this).attr('optsdiv')+" > *[selected=1]").each(function(i, el) {
								if (lista != '') lista = lista + ", ";
								lista = lista + $(el).html();
							} );
							$('#'+$(this).attr('seldiv')+' > div').html(lista);
						}
					}
					);
			}
			);

			$('#'+id).click(function() {
				id_opts = $(this).attr('id')+'_optscont';
				id_ = $(this).attr('id')+'_opts';
				pos = $(this).offset();
				$('#'+id_).css('left', pos.left);
				$('#'+id_).css('top', pos.top + 25);
				$('#'+id_opts).fadeIn("fast");
			} );

			$('#'+id_opts+'cont').click(function() {
				$(this).fadeOut("fast");
			} );
			nr++;
		});
	}
});
/*
jQuery.fn.extend({
	multiselect: function()
	{
		nr = 0;
		return this.each(function() {
			width = $(this).width();
			id = $(this).attr('id')+'_sel';
			id_opts = id+'_opts';

			$(this).addClass('hide'); sel = $(this).attr('id');
			$(this).parent().append("<div id='"+id+"' style='width: "+width+"px' class='my_select'>SEL</div>");
			$(this).parent().append("<div id='"+id_opts+"' class='my_select_options hide'></div>"); //  style='width: "+width+"px'


			$('#'+$(this).attr('id')+' > *').each(function(i, el) {
					id_opt = id_opts+'_i'+i;

					if ($(el).attr('selected'))
					{
						s = "selected='1' class='selected'";
						$('#'+id).html($(el).val());
					} else s = '';

					$('#'+id_opts).append("<div id='"+id_opt+"' "+s+" sel='"+sel+"' seldiv='"+id+"' optsdiv='"+id_opts+"' key='"+$(el).attr('key')+"'>"+$(el).html()+"</div>");
					$('#'+id_opt).hover(
						function () {
							if (!$(this).attr('selected')) $(this).toggleClass('selected');
						},
						function () {
							if (!$(this).attr('selected')) $(this).toggleClass('selected');
						} );
					$('#'+id_opt).click(
						function () {
							$('#'+$(this).attr('sel')).val($(this).attr('key'));
							$('#'+$(this).attr('seldiv')).html($(this).html());
							$('#'+$(this).attr('optsdiv')).fadeOut("fast");
							$('#'+$(this).attr('optsdiv')+" > *").removeClass('selected');
							$('#'+$(this).attr('optsdiv')+" > *").attr('selected', 0);
							$(this).attr('selected', 1);
							$(this).toggleClass('selected');
						}
					);
				}
			);

			$('#'+id).click(function() {
				id_opts = $(this).attr('id')+'_opts';
				$('#'+id_opts).fadeIn("fast");
			} );
			nr++;
		});
	}
});
*/
jQuery.fn.extend({
	checkbox: function()
	{
		nr = 0;
		return this.each(function() {
			// nadanie automatycznie id

			if ($(this).attr('name').substr($(this).attr('name').length - 2, 2) == '[]')
				name = $(this).attr('name').substr(0,$(this).attr('name').length - 2);
			else name = $(this).attr('name');

			$(this).attr('id', name+nr);

			// dodanie odpowiadającego checkbox-a
			chid = $(this).attr('name')+nr+"checkbox";
			id_div = name+nr+"div";
			$(this).after("<div checked='1' id='"+id_div+"' rel='"+name+nr+"' name='"+$(this).attr('name')+"' class='my_checkbox'>");
			$(this).addClass('hide');

			// ustawienie zaznaczenia
			if ($(this).attr('checked')) {
				$('#'+id_div).addClass('checked');
				$('#'+id_div).attr('checked', 1);
			}

			// obsługa kliknięcia
			$('#'+id_div).click(function() {
				window.___checkboxid = this;
				chid = $(this).attr('rel');
				//alert($('#'+$(this).attr('rel')).attr('type'));
				if ($('#'+$(this).attr('rel')).attr('type') == 'radio')
				{
					$("*[name='"+$(this).attr('name')+"']").removeClass('checked');
					document.getElementById(chid).checked = !document.getElementById(chid).checked;
				} else
{
					document.getElementById(chid).selected = !document.getElementById(chid).selected;
				}
				$('#'+chid).click();

				$(this).fadeOut("fast", show_checkbox);
			});
			nr++;
		});
	}
});

jQuery.fn.extend({
	selectChildren: function(target_element, source_key, result_key, order, not_selected_index)
	{

		$(this).change(function() {
			not_selected_index = (typeof not_selected_index == "undefined") ? "" : "&not_selected_index="+not_selected_index;
			$.ajax(
			{
				type: "POST",
				url: "?c=dictionary&m=getChildren",
				data: "value="+$(this).val()+"&source_key="+source_key+"&result_key="+result_key+"&order="+order+not_selected_index+"&ajax=1",
				async: true,
				dataType: "json",
				global: false,
				success: function (data, status)
				{
					$("#"+target_element).html(data[0]['html']);
					$("#"+target_element).focus();
				//alert(data.toSource());
				//alert(data[0]['html']);
				},
				error: function (data, status, e)
				{
					alert(e);
				}
			});
		});

	}
});

function show_checkbox()
{
	$(window.___checkboxid).fadeIn("fast");
	$(window.___checkboxid).toggleClass("checked");
}

function translateText(sender, input, output, to)
{
	var text = $(input).val();
	if(text == '')
	{
		return false;
	}

	$.translate(text, {
		from: 'pl',
		to:	to,
		stripWhitespace: true,
		start:  function(translation){
			$(sender).removeClass("ico_redo");
			$(sender).addClass("ico_cancel");
		},
		error:  function(translation){
			$(sender).removeClass("ico_redo");
			$(sender).removeClass("ico_cancel");
			$(sender).addClass("ico_checkmark");
		},
		complete: function(translation){
			$(output).val(
				$.trim(translation)
				);

			$(sender).removeClass("ico_cancel");
			$(sender).removeClass("ico_redo");
			$(sender).addClass("ico_checkmark");
		}
	});

	return true;
}

function toMyAlerts(form_id){
	var a = $("#"+form_id+" > [name^='params']").serialize();
	//if ($("#"+form_id+" > [name='submit_save']").val()) a += "&submit_save=1";
	a += "&submit_save=1&params[method]=email";
	//var a = location.search.replace(/^\?/,'');
	//alert(a);
	$.ajax(
	{
		type: "POST",
		url: "?c=user&m=toMyAlerts",
		data: a+"&ajax=1",
		async: true,
		dataType: "json",
		global: false,
		success: function (data, status)
		{
			openMessages(data);
		//alert(data.toSource());
		//alert(data[0]['html']);
		},
		error: function (data, status, e)
		{
			alert(e);
		}
	});
     
}

function setRadioChecked(params){
	if (params.checked) $("#"+params.id).attr('checked','1');
	else $("#"+params.id).removeAttr('checked');
}

//function changePhoto(ob,mini,normal){
function changePhoto(ob){
	/*
	$("[id^='item_big_photo_']").hide();
	$("#item_big_photo_"+id).show();
	*/
	//$("[id^='item_big_photo_']").removeClass('item_photo_big');
	/*
	$("[id^='item_big_photo_']").addClass('item_photo_big_hidden');
	$("#item_big_photo_"+id).removeClass('item_photo_big_hidden');
	*/
	//$("[id^='item_big_photo_']").attr('class','item_photo_big_hidden');
	var id = $(ob).parent().attr('id').replace('item_photo_thumb_','');
	//alert(id);
	if ( $.browser.opera ) {
		$(".item_photo_holder").hide();
		$("[id^='item_big_photo_']").attr('class','item_photo_big_hidden');
		$("#item_big_photo_"+id).attr('class','item_photo_big');

		$("[id^='item_photo_thumb_']").attr('class','item_photo_thumb');
		$(ob).parent().attr('class','item_photo_thumb_current');
		setTimeout(function(){
			$(".item_photo_holder").show();
		},1);
	} else {
		$("[id^='item_big_photo_']").attr('class','item_photo_big_hidden');
		$("#item_big_photo_"+id).attr('class','item_photo_big');

		$("[id^='item_photo_thumb_']").attr('class','item_photo_thumb');
		$(ob).parent().attr('class','item_photo_thumb_current');
	}

}

function setItemRowInactive(params){
	$("#report_row_"+params.id).remove();
}

/**
 * params array {title, key|text}
 */
function showMessage(params){

	tmp = new Array();
	for (i in params){
		tmp.push(i+'='+params[i]);
	}
	params = tmp.join('&');

	aLoad("./?c=content&m=showMessage",params);
}
