var CurrentPageNumber = 0;
var CurrentPage = 'my_albums';
mySettings = {
	previewParserPath:	'index.php?service=bbcode',
	previewParserVar: 'BBCode',
	markupSet: [
		{name:'Bold', key:'B', openWith:'[b]', closeWith:'[/b]'},
		{name:'Italic', key:'I', openWith:'[i]', closeWith:'[/i]'},
		{name:'Underline', key:'U', openWith:'[u]', closeWith:'[/u]'},
		{name:'Size', key:'S', openWith:'[size=[![Font size]!]]', closeWith:'[/size]'},		
		{separator:'---------------' },
		{name:'Image from URL', key:'P', replaceWith:'[img][![Url]!][/img]'},
		{name:'URL', key:'L', openWith:'[url=[![Url]!]]', closeWith:'[/url]', placeHolder:'Your text to link here...'},
		{separator:'---------------' },
		{name:'List', openWith:'[list]\n', closeWith:'\n[/list]', placeHolder:'[*]'},
		{name:'Numeric list', openWith:'[list=1]\n', closeWith:'\n[/list]', placeHolder:'[*]'}, 
		{name:'List item', openWith:'[*] '},
		{separator:'---------------' },
		{name:'Blockquote', key:'N', openWith:'[blockquote]', closeWith:'[/blockquote]'},
		{separator:'---------------' },
		{name:'Code', className:"clean", replaceWith:function(markitup) { return markitup.selection.replace(/\[(.*?)\]/g, "") } },
		{name:'Preview', className:"preview", call:'preview' },
		{separator:'---------------' },
		{name:'Insert image from gallery', key:'B1', openWith: function(markitup) { 	ShowGallery(); /*return ":-)"*/ }}		
	]}

	function ServiceGallery_ShowImage(id)
	{
//		var url = document.location.href;
//		url = url.split('?');
		
		CloseChoosePictureDialog();

		$.getJSON(url[0] + '?service=service_gallery&saction=get_info&image_id='+id,
		//запрос завершен, получаем данные
		function (data) 
		{
			$.markItUp({ openWith:'[img]', closeWith:'[/img]', placeHolder: data.src_2});
		});
	}
	function ShowGallery()
	{
		ShowChoosePictureDialog($("#gallery_add_photo_name").attr('name'), function(id) {
		var url = document.location.href;
		url = url.split('?');
			
		CloseChoosePictureDialog();
		$.getJSON(url[0] + '?service=service_gallery&saction=get_info&image_id='+id,
		//запрос завершен, получаем данные
		function (data) 
		{
			$.markItUp({ openWith:'[img]', closeWith:'[/img]', placeHolder: data.src_2});
		});

/*			$.markItUp({ openWith:'[img]', closeWith:'[/img]', placeHolder: url[0] + '?service=show_image&thumbnail=2&id=' + id } );
			});
*/
// 'ServiceGallery_ShowImage');
		});
	}

	
	function newsthumb_ShowImage(id)
	{
		$("#news_thumb").attr("value",id);
		$("#news_thumb_img").attr("src","?service=show_image&thumbnail=1&id="+id);
		CloseChoosePictureDialog();
	}	

	function newsmain_ShowImage(id)
	{
		$("#news_main").attr("value",id);
		$("#news_main_img").attr("src","?service=show_image&id="+id);
		CloseChoosePictureDialog();
	}
	
	function newsthumb_ShowGallery()
	{
//		ShowChoosePictureDialog($("#gallery_add_photo_name").attr('name'), 'newsthumb_ShowImage');
	
		ShowChoosePictureDialog($("#gallery_add_photo_name").attr('name'), function(id)
		{
			$("#news_thumb").attr("value",id);
			$("#news_thumb_img").attr("src","?service=show_image&thumbnail=1&id="+id);
			CloseChoosePictureDialog();
		});

	}

	function newsmain_ShowGallery()
	{
//		ShowChoosePictureDialog($("#gallery_add_photo_name").attr('name'), 'newsmain_ShowImage');

		ShowChoosePictureDialog($("#gallery_add_photo_name").attr('name'), function(id)
		{
			$("#news_main").attr("value",id);
			$("#news_main_img").attr("src","?service=show_image&id="+id);
			CloseChoosePictureDialog();
		});
	}	
	
	function newsmain_Clear()
	{
			$("#news_main").attr("value",0);
			$("#news_main_img").attr("src","/template/akado_news/gfx/avatar_208x118.png");	
	}

	function newsthumb_Clear()
	{
			$("#news_thumb").attr("value",0);
			$("#news_thumb_img").attr("src","/template/akado_news/gfx/avatar_208x118.png");	
	}


	///////////////////////////////////////////////////////////////////////////////////////////////////
	// [ Функции перенесены в common.js  ] ////////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////////////////////////////
	$(document).ready(function()
	{	
//		$("#contentEdit").markItUp(mySettings);
	});
