var is_ie = navigator.appName == 'Microsoft Internet Explorer';
function change_ozon_img(href_obj, pict_url)
{
	var img_id = href_obj.id.replace('href', 'img');
	var img_obj = $(img_id);
	var t =null;
	if(img_obj.width > 190)
	{
		img_obj.width = 60;
		if(is_ie)
			img_obj.height = 89;
	}
	else if(img_obj.width < 80)
	{
		img_obj.width = 200;
		if(is_ie)
			img_obj.height = 300;
	}
}

function show_hide_ozon_annotation(href_obj)
{
	var id = href_obj.id.replace('s_h', 'annot');
	var full_obj = $(id + '_full');
	var short_obj = $(id + '_short');
	if (short_obj.style.display == 'block')
	{
		short_obj.style.display = 'none';
		full_obj.style.display = 'block';
		href_obj.innerHTML = 'свернуть';
	}
	else if (short_obj.style.display == 'none')
	{
		short_obj.style.display = 'block';
		full_obj.style.display = 'none';
		href_obj.innerHTML = 'развернуть';
	}
}

function edit_rating(status, cid)
{
	var data=[];
	data['action'] = 'edit_rating';
	data['edit_rating'] = status;
	A.Post('/compas/' + cid, data, {onComplete:check_edit_rating});
	return false;
}

function check_edit_rating(s_string)
{
	var s = Eval('(' + s_string + ')');
	if (typeof(s.voted) != 'undefined')
	{
		W.OpenSimple('/msg/e/rate_time', 'Ошибка');
	}
	else if (typeof(s.succeed) != 'undefined')
	{
		if (s.succeed == 1)
		{
			//W.OpenSimple('/msg/i/rate_succeed', 'Инфо', null, 300, 100);
			$('voting').style.display = 'none';
			$('voted').style.display = 'block';
		}
		else
		{
			;
		}

	}
}

function rss_ch_page(cid, mod_num, start_news, show_mod_header)
{
	var data=[];
	data['mod_num'] = mod_num;
	data['start_news'] = start_news;
	data['show_mod_header'] = show_mod_header;
	A.Post('/mod/rss_ch_page/' + cid, data, {onComplete:check_rss_ch_page});
}

function check_rss_ch_page(resp)
{
	var ray = Eval('(' + resp + ')');
	var status = ray.s;
	if(status > 0)
	{
		$(ray.el_id).innerHTML = ray.txt;
	}
}

function renew_rss(cid, mod_num, show_mod_header)
{
	var data=[];
	//alert(url2check);
	data['cid'] = cid;
	data['mod_num'] = mod_num;
	data['show_mod_header'] = show_mod_header;
	A.Post('/mod/renew_rss/' + cid, data, {onComplete:check_renew_rss});
}

function check_renew_rss(resp)
{
	var ray = Eval('(' + resp + ')');
	if(ray.e)
	{
		W.OpenSimple('/msg/e/' + ray.e, 'Ошибка');
	}
	else
	{
		$(ray.el_id).innerHTML = ray.txt;
	}
}

function set_type(obj, cid)
{
	var type, mode;
	type = obj.name;
	if (obj.checked == true)
		mode = 'on';
	else
		mode = 'off';
	var data=[];
	data['cid'] = cid;
	data['action'] = 'set_type';
	data['mode'] = mode;
	data['type'] = type;
	A.Post('/compas/' + cid, data, {onComplete:check_set_type});
	//alert(type + mode);
}

function check_set_type(res)
{
	var ray = Eval('(' + res + ')');
	if (ray.e)
	{
		W.OpenSimple('/msg/e/' + ray.e, 'Ошибка');
	}
	else
		W.OpenSimple('/msg/i/flag_set', 'Сообщение', '', 300, 50);
}

function check_add_rec_link(res)
{
	var ray = Eval('(' + res + ')');
	if (ray.e)
	{
		W.OpenSimple('/msg/e/' + ray.e, 'Ошибка');
	}
	else
	{
		A.Get('/compas/' + ray.cid + '/renew_rec_links', 'rec_links');
		W.Close();
		W.OpenSimple('/msg/i/rec_link_added', 'Сообщение', '', 300, 50);
	}
}

function del_rec_link(cid, num)
{
	var data=[];
	data['cid'] = cid;
	data['action'] = 'del_rec_link';
	data['num'] = num;
	A.Post('/compas/' + cid, data, {onComplete:function(){A.Get('/compas/' + cid + '/renew_rec_links', 'rec_links');}});
}

//разворачивание-сворачивание большой картинки в модуле при наведении
function expand_module_image(obj)
{
	var thumb_max_width = 500;
	if (obj.width >= thumb_max_width || obj.height >= thumb_max_width)
	{
		obj.src = obj.src.replace(/\.jpg$/, '_orig.jpg');
		//obj.style.zIndex = 1;
	}
}

function shrink_module_image(obj)
{
	var thumb_max_width = 500;
	if (obj.width >= thumb_max_width || obj.height >= thumb_max_width)
	{
		obj.src = obj.src.replace(/_orig\.jpg$/, '.jpg');
		//obj.style.zIndex = 0;
	}
}
