var id = -1;

function InizializeShadow() 
{	
	var width = document.getElementById('Container').offsetWidth+document.getElementById('Content').offsetWidth+450;
	var screenwidth = document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
	var left = Math.round((screenwidth - width)/2) + 'px';
 	
 	$('#Container').css('top',50);
	$('#Container').css('left',left);
	}

	
function InizializeGallery() {
	$('#gallery a').lightBox(
	{
	overlayOpacity: 0.3,
	//fixedNavigation:true,
	//activeImage : 2,
	overlayBgColor: '#703631',
	containerBorderSize:10,
	containerResizeSpeed:670,
	imageLoading:			'img/gallery/lightbox-ico-loading.gif',		
	imageBtnPrev:			'img/gallery/lightbox-btn-prev.gif',			
	imageBtnNext:			'img/gallery/lightbox-btn-next.gif',			
	imageBtnClose:			'img/gallery/lightbox-btn-close.gif',		
	imageBlank:				'img/gallery/lightbox-blank.gif'
	});
							}	
	
function ShowConfirm()
{
ShowShadow();
}

function HideShadow()
{		
		$("#Container").animate({opacity: "hide"},700);
}
	
function ShowShadow(WhatToLoad)
{
		$("#Content").load(WhatToLoad, function (){InizializeShadow();$("#Container").animate({opacity: "show"},800);});
}

function DeletePictureFromGallery(id,tableName)
{
if (confirm("Удалить изображение?")==true)
$.post("ajax/deletePicture.php",{id:id,table:tableName},function () {$('#Photo'+id).remove()});
}



function Highlight(obj)
{
$("#"+obj.id).css({"background-color":"#d6bd94"});
}

function UNHighlight(obj)
{
$("#"+obj.id).css({"background-color":"#f4d9a6"});
}

function SavePageText(page)
{	
	var text = CKEDITOR.instances.text.getData();
	$.post('ajax/saveText.php',{pageName:page, text:text},function (data) {showShadowAND_Hide('<h2>Сохранено!</h2>');});
}

function InizializeEditor()
	{
		var text = CKEDITOR.replace('text',
		{
			toolbar:
				[
					['Cut','Copy','Paste','-','Print','SpellChecker','Scayt','-','Undo','Redo','-','Find','Replace'],
					['Bold','Italic','Underline','Strike','-','Subscript','Superscript','-','NumberedList','BulletedList'],
					['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','Link','Unlink','Anchor'],
					['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
					['Format','Font','FontSize','-','TextColor','BGColor']
				],
			width: '100%'
		});
		
		AjexFileManager.init({
	returnTo: 'ckeditor', 
	path: 'js/AjexFileManager/',
	editor: text });
		
	}

	function ShowPartContent(namePart)
		{
			
			$("div[id$=Button][background!=url(img/Button_check.png)]").css({background:"url('')"});
			
			$("#"+namePart+"Button").css({background:"url(img/Button.png)"});
			$("#"+namePart+"Button").css({background:"url(img/Button.png)"});
			//animate({backgroundColor: originalBg},700);
			$("#PartsTD div").hide();
			$("#"+namePart+"Content").show();
		}
