var mouse_big_photo=0;
function schoolReportsSelect(id,text)
{
	//alert(text);
	$('#flat').html(text);
	//alert(id);
	$.post("/ajaxReport.php", 
			{    o : "SelectChange",
		         id: id			
			}, function(data){
				//alert(data)
				$('#news_list_container').html(data);
				checkedImgBorder();
			});
	$.post("/ajaxReport.php", 
			{    o : "SelectChange_navLine",
		         id: id			
			}, function(data2){
				$('#nav_line_container').html(data2);
				
			});
	
} 
function reports_photos_next(id,page)
{
$.post(
		"/ajaxReport.php",
		{
			o:'reports_photos_list',
			id:id,
			page:page
		}
		,
		function(data)
		{
	$('#photo_in_album'+id).html(data);
	}
	);
}
function reports_photos_all(id)
{
$.post(
		"/ajaxReport.php",
		{
			o:'reports_photos_all',
			id:id
		}
		,
		function(data)
		{
	$('#reports'+id).html(data);
	}
	);
}
function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}
function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.documentElement.clientHeight;//document.body.clientHeight;
}
function reports_big_photo_resize()
{
var a,b,z;
a=getClientWidth();
if($('.album_big_photos').html())
	b=getClientHeight()-200;
else
	b=getClientHeight()-100;
//c=getClientHeight()-200;
//z=b>a?a:b;
//document.getElementById('album_big_photo_photo').width=z;
$('#album_big_photo_photo').css('max-width',a);
$('#album_big_photo_photo').css('max-height',b);
$('#album_big_photo_height').css('height',b);
}
function big_reports_width_arr()
{
	w=getClientWidth();
	h=getClientHeight();
	ex=w/h;
	h=h-400;
	w=ex*h;
	return w;
}
function reports_big_photo_next(id,page)
{
	reports_big_photo_slideshow_stop();
	$.post(
		"/ajaxReport.php",
		{
			o:'reports_big_photo_list',
			id:id,
			page:page
		}
		,
		function(data)
		{
	$('#big_photo_in_album'+id).html(data);
	}
	);
}
function visible_arr(num)
{
	if(num)
	{
		$('#big_prev').css('display','');
		$('#big_next').css('display','');
	}
	else
	{
		$('#big_prev').css('display','none');
		$('#big_next').css('display','none');
	}
}
function reports_open_big_photo(id)
{
	visible_arr(0);
	$('#album_big_photo').html("<img src='http://www.spicylogic.com/allenday/blog/wp-content/uploads/2008/09/ajax_activity_indicators_download_animated_indicator_circle_ball.gif'>");
	$('.album_big_photos').each(function(){$(this).css('border','');});
	$('#album_photo'+id).css('border','2px double white');
	$('#big_photo_slideshow_link').attr('onclick',"reports_big_photo_slideshow_start('"+id+"')");
	album_big_photo_slideshow_stop();
	$.post(
		"/ajaxReport.php",
		{
			o:'reports_open_big_photo',
			id:id
		}
		,
		function(data)
		{
		$('#album_big_photo').html(data);
		reports_big_photo_resize();
		visible_arr(1);
	}
	);
}
function reports_open_part1_big_photo(id)
{
	visible_arr(0);
	$('#album_big_photo').html("<img src='http://www.spicylogic.com/allenday/blog/wp-content/uploads/2008/09/ajax_activity_indicators_download_animated_indicator_circle_ball.gif'>");
	$('.album_big_photos').each(function(){$(this).css('border','');});
	$('#album_photo'+id).css('border','2px double white');
	$('#big_photo_slideshow_link').attr('onclick',"reports_big_photo_slideshow_start('"+id+"')");
	reports_big_photo_slideshow_stop();
	$.post(
		"/ajaxReport.php",
		{
			o:'reports_open_part1_big_photo',
			id:id
		}
		,
		function(data)
		{
		
		$('#album_big_photo_part').html(data);
		reports_big_photo_resize();
		visible_arr(1);
	}
	);
}
function reports_big_photo(id)
{
	visible_arr(0);
	$('#album_big_photo').html("<img src='http://www.spicylogic.com/allenday/blog/wp-content/uploads/2008/09/ajax_activity_indicators_download_animated_indicator_circle_ball.gif'>");
	$.post(
		"/ajaxReport.php",
		{
			o:'reports_big_photo',
			id:id,
			interval:big_photo_slideshow_interval
		}
		,
		function(data)
		{
		img = $('#img_con');
		img.hide();
		$('#big_extra_area').html(data);
		visible_arr(1);
	});
}
function set_big_photo_slideshow_interval()
{
	big_photo_slideshow_interval=$('#interval').val();
}
function reports_big_photo_slideshow(id)
{
	var next_id;
	clearTimeout(big_photo_slideshow);
	$.post(
		"/ajaxReport.php",
		{
			o:'reports_big_photo_next_photo_id',
			id:id
		}
		,
		function(next_id)
		{
			if(next_id!='0')
			{
				big_photo_slideshow=window.setTimeout(function(){reports_big_photo_slideshow(next_id);},big_photo_slideshow_interval);
				reports_big_photo(next_id);
			}
	});
	//$('#album_big_photo_next_link').attr('onclick'));
	//album_big_photo(next_id)
}
function reports_big_photo_slideshow_start(id)
{
	clearTimeout(big_photo_slideshow);
	big_photo_slideshow=window.setTimeout(function(){reports_big_photo_slideshow(id);},big_photo_slideshow_interval);
	//alert(1);
}
function reports_big_photo_slideshow_stop()
{
	clearTimeout(big_photo_slideshow);
}
function reports_big_photo_cansel()
{
	reports_big_photo_slideshow_stop();
	//$('#big_extra_area').html('');
	id=$('#current_big_photo_id').val();
	str=window.location.toString();
	if(str.indexOf(id)>0)
	{
		$('#big_extra_area').html('');
		img = $('#img_con');
		img.show();
	}
	else
		window.location='photo'+id+'.html#reports_photo';
		
	
}
function media_count_up(id,step)
{
	if(!step)
	$.post(
			"/ajaxReport.php",
			{
			'o':'count_up',
			'id':id
			},
			function(data){
				$('#album_count_block').html(data);
				}
			);
	else
		alert('Вы уже голосовали');
}
function media_count_down(id,step)
{
	if(!step)
	$.post(
			"/ajaxReport.php",
			{
			'o':'count_down',
			'id':id
			},
			function(data){
				$('#album_count_block').html(data);
				}
			);
	else
		alert('Вы уже голосовали');
}

function delete_report_photo(photo_id)
{
	
	$.post(
			"/ajaxReport.php",
			{
			'o':'delete_report_photo',
			'photo_id':photo_id
			},
			function(data){
				$('#report_photo_'+photo_id).hide();
				$('#report_photo_notice_'+photo_id).html('<a href="" onclick="restore_report_photo('+photo_id+');return false">Восстановить</a>')
			});
}

function restore_report_photo(photo_id)
{
	
	$.post(
			"/ajaxReport.php",
			{
			'o':'restore_report_photo',
			'photo_id':photo_id
			},
			function(data){
				$('#report_photo_'+photo_id).show();
				$('#report_photo_notice_'+photo_id).html('');
			});
}

function save_media_alt_title(photo_id, mode)
{
	var value = $('#photo_'+mode+'_'+photo_id).val();
	  $.post(
		"/ajaxReport.php", { 
			o : 'save_media_alt_title',
			mode: mode, 
			photo_id : photo_id,
			value : value
			}, 
    		function(data){
				if(data==1)
				{
					
					$('#photo_'+mode+'_'+photo_id).css('color','green');
					$('#photo_'+mode+'_'+photo_id).val('Сохранено')
					//$('#photo_'+mode+'_'+photo_id).css('color','black');
					setTimeout(function() {$('#photo_'+mode+'_'+photo_id).css('color','black');$('#photo_'+mode+'_'+photo_id).val(value)}, 500)
				}$('#clubFoto_'+photo_num+'_'+mode)
			});
}
