$(function() {


	$('#file').change(function()
	{

		$('#file').each(function() {
			var name = this.value;
			reWin = /.*\\(.*)/;
			var fileTitle = name.replace(reWin, "$1");
			reUnix = /.*\/(.*)/;
			fileTitle = fileTitle.replace(reUnix, "$1");
		$('#name_file').html(fileTitle);
		});

	});


	// Инициализация prettyPhoto
	// $("a[rel^='prettyPhoto']").prettyPhoto({
		// theme: 'facebook',
		// overlay_gallery: false
	// });

	// Эмуляция атрибутов vspace, hspace и border у картинок в зоне визуального редактора
	$('div.wysiwyg img[vspace]').each(function() {
		$(this).css('margin-top',parseInt($(this).attr('vspace'))+'px').css('margin-bottom',parseInt($(this).attr('vspace'))+'px');
	});
	$('div.wysiwyg img[hspace]').each(function() {
		$(this).css('margin-left',parseInt($(this).attr('hspace'))+'px').css('margin-right',parseInt($(this).attr('hspace'))+'px');
	});
	$('div.wysiwyg img[border]').each(function() {
		$(this).css('border',parseInt($(this).attr('border'))+'px solid #4C4C4C');
	});
	
	// Emulation target_blank
	$("._blank a").click(function(){
		window.open(this.href);
		return false;
	});
	
	// First h1, h2, h3, h4, h5, h6 without top-margin
	$(".content-page :header:first-child").addClass("h-first-child");
	
	// раскрывающиеся блоки	
	$('div.more').append('<p><a href="#" onclick="return closeMore(this);">Закрыть описание</a></p>');
	$('a.more').click(function(){
		var index = $('a.more').index(this);
		$('div.more').eq(index).slideToggle('fast');
		return false;
		
	});
	$('.object-block').one('click', function(){
		var href =$(this).find('a:first').attr('href');
		window.location = href;
		
	})
	
})
