var photo_index = 0;
var product_index = 0;

function Getwindow()  //для кнопки "Увеличить" в Галерее
{window.open('big_photo.php', 'big_photo', config='height=768,width=1024,toolbar=0,scrollbar=1,menubar=0,location=0,resizable=1')
}

function if_del() {
        if (confirm("Вы действительно хотите удалить данный файл?")) { return true}
        else{ return false}
}function if_del_albom() {        if (confirm("Вы действительно хотите удалить альбом? (фотографии, находящиеся в нём не удалятся из Галереи)")) { return true}        else{ return false}}

function if_sale() {
        if (confirm("Для того чтобы приобрести товар, вам необходимо написать пиcьмо на e-mail info@fotoclub31.ru с указанием необходимого товара, вашего номера телефона и ФИО")) { return true}
        else{ return false}
}

function upd_price() {
        if (confirm("После нажатия на кнопку 'Ok' появится новое окно. Не закрывайте появившееся окно, пока не увидите там сообщение о том, что его можно закрыть (5-15 сек.)")) { return true}
        else{ return false}
}

function enlarge(name, pologenie)
{
	if (document.getElementById("photo_big") != null)
		if (pologenie!='1')
			document.getElementById("photo_big").innerHTML = "<a href='javascript:load_description_photo(\""+name+"\");'><img  src='photos/small/photo_small_"+name+"' alt=''></a>";
		else 
			document.getElementById("photo_big").innerHTML = "<a href='javascript:load_description_photo(\""+name+"\");'><img src='photos/small/photo_small_"+name+"' alt=''></a>";
	load_description_photo(name);
}

function load_description_photo(photo_name)
{
	http_request = create_http_request();
	
	http_request.open("get", "core.php?photo_name="+photo_name+"&get_photo_description", true);
	http_request.onreadystatechange = get_description_photo;
	http_request.send(null);
}

function get_description_photo()
{
	if (http_request.readyState == 4)
		if (document.getElementById("information") != null)
			document.getElementById("information").innerHTML = http_request.responseText;
}

function enlarge_concours(name, pologenie)
{
	if (document.getElementById("photo_big") != null)
		if (pologenie!='1')
			document.getElementById("photo_big").innerHTML = "<a href='javascript:load_description_photo_concours( \""+name+"\");'><img src='photos/small/photo_small_"+name+"' alt=''></a>";
		else 
			document.getElementById("photo_big").innerHTML = "<a href='javascript:load_description_photo_concours( \""+name+"\");'><img src='photos/small/photo_small_"+name+"' alt=''></a>";
	load_description_photo_concours(name);
}

function load_description_photo_concours(photo_name)
{
	http_request = create_http_request();	
	http_request.open("get", "core.php?photo_name="+photo_name+"&get_photo_description_concours", true);
	http_request.onreadystatechange = get_description_photo;
	http_request.send(null);
}

function enlarge_old_photo(name, pologenie)
{
	if (document.getElementById("photo_big") != null)
		if (pologenie!='1')
			document.getElementById("photo_big").innerHTML = "<a href='javascript:load_description_photo_old_photo( \""+name+"\");'><img src='photos/small/photo_small_"+name+"' alt=''></a>";
		else 
			document.getElementById("photo_big").innerHTML = "<a href='javascript:load_description_photo_old_photo( \""+name+"\");'><img src='photos/small/photo_small_"+name+"' alt=''></a>";
	load_description_photo_old_photo(name);
}

function load_description_photo_old_photo(photo_name)
{
	http_request = create_http_request();	
	http_request.open("get", "core.php?photo_name="+photo_name+"&get_photo_description_old_photo", true);
	http_request.onreadystatechange = get_description_photo;
	http_request.send(null);
}

function enlarge_new_photo(name, pologenie)
{
	if (document.getElementById("photo_big") != null)
		if (pologenie!='1')
			document.getElementById("photo_big").innerHTML = "<a href='javascript:load_description_photo_new_photo( \""+name+"\");'><img src='photos/small/photo_small_"+name+"' alt=''></a>";
		else 
			document.getElementById("photo_big").innerHTML = "<a href='javascript:load_description_photo_new_photo( \""+name+"\");'><img src='photos/small/photo_small_"+name+"' alt=''></a>";
	load_description_photo_new_photo(name);
}

function load_description_photo_new_photo(photo_name)
{
	http_request = create_http_request();	
	http_request.open("get", "core.php?photo_name="+photo_name+"&get_photo_description_new_photo", true);
	http_request.onreadystatechange = get_description_photo;
	http_request.send(null);
}

function enlarge_product(name)
{
	document.getElementById("photo_big").innerHTML = "<img src='cameras/"+name+"' alt=''>";
	if (!first)
		load_description_product_by_photo_name('"'+name+'"');
}

/*
function enlarge_news(name)
{
	document.getElementById("photo_big").innerHTML = "<img width=398 height=265 src='local_news_photo/small/photo_small_"+name+"' alt=''>";
	if (!first)
		load_news_by_photo_name('"'+name+'"');
}*/



function enlarge_industry_news(name)
{
	document.getElementById("photo_big").innerHTML = "<img width=398 height=265 src='industry_news_photo/small/photo_small_"+name+"' alt=''>";
	if (!first)
		load_industry_news_by_photo_name('"'+name+'"');
}

var http_request;
var browser = navigator.appName;

first = 1;

function create_http_request()
{
	if (browser == "Microsoft Internet Explorer")
		http_request = new ActiveXObject("Microsoft.XMLHTTP");
	else
		http_request = new XMLHttpRequest();
	return http_request;
}

function preview()
{
	http_request = create_http_request();
	
	http_request.open("get", "preview.php?photo_index="+photo_index, true);
	http_request.onreadystatechange = get_preview;
	http_request.send(null);
}

function get_preview()
{
	if (http_request.readyState == 4)
	{
		document.getElementById("photo_preview").innerHTML = http_request.responseText;
		if (first)
		{
			eval(document.getElementById("photo_preview").firstChild.nextSibling.getAttribute("href"));
			first = 0;
		}
	}
}

//===== для отображения фотки первой новости в новостях вместо фотки из галереи

function preview_1()
{
	http_request = create_http_request();
	
	http_request.open("get", "preview.php?photo_index="+photo_index, true);
	http_request.onreadystatechange = get_preview_1;
	http_request.send(null);
}

function get_preview_1()
{
	if (http_request.readyState == 4)
	{
		document.getElementById("photo_preview").innerHTML = http_request.responseText;
		if (first)
		{
			eval(document.getElementById("photo_preview").firstChild.nextSibling.getAttribute("href"));
			enlarge_industry_news("23.jpg");
			load_industry_news_by_photo_name('%2223.jpg%22');
			first = 0;
		}
	}
}

//=====

//===== для отображения фотки первой новости в новостях вместо фотки из галереи

function preview_3(num)
{
	enlarge_product(num);
	load_description_product_by_photo_name('"'+num+'"');
	first = 0;
}


//=====


//===== для отображения фотки первого товара В ФОТОТЕХНИКЕ

function preview_2()
{
	enlarge_product("806.jpg");
	load_description_product_by_photo_name('%22806.jpg%22');
	first = 0;
}

//=====


function preview_product()
{
	http_request = create_http_request();
	
	http_request.open("get", "preview.php?product_index="+product_index, true);
	http_request.onreadystatechange = get_preview_product;
	http_request.send(null);
}

function get_preview_product(f)
{
	if (http_request.readyState == 4)
	{
		document.getElementById("photo_preview").innerHTML = http_request.responseText;
		if (first)
		{
			href = document.getElementById("photo_preview").firstChild.nextSibling.getAttribute("href");
			eval(href);
			photo_name = /\".*\"/g.exec(href);
			load_description_product_by_photo_name(photo_name);
			first = 0;
		}
	}
}

function preview_product_only_photo()
{
	http_request = create_http_request();
	
	http_request.open("get", "preview.php?product_index="+product_index, true);
	http_request.onreadystatechange = get_preview_product_only_photo;
	http_request.send(null);
}

function get_preview_product_only_photo(f)
{
	if (http_request.readyState == 4)
	{
		document.getElementById("photo_preview").innerHTML = http_request.responseText;
		if (first)
		{
			href = document.getElementById("photo_preview").firstChild.nextSibling.getAttribute("href");
			eval(href);
			photo_name = /\".*\"/g.exec(href);
			//load_description_product_by_photo_name(photo_name);
			first = 0;
		}
	}
}

function previous()
{
	photo_index=photo_index+4;
	preview();
}

function next()
{
	photo_index=photo_index-4;
	preview();
}

function previous_product()
{
	product_index++;
	preview_product();
}

function next_product()
{
	product_index--;
	preview_product();
}

function preview_first()
{
	preview();
}

function load_description(id)
{
	http_request = create_http_request();
	
	http_request.open("get", "core.php?product_id="+id+"&get_product_description", true);
	http_request.onreadystatechange = get_description;
	http_request.send(null);
}

function load_description_product_by_photo_name(photo_name)
{
	http_request = create_http_request();
	
	http_request.open("get", "core.php?photo_name="+photo_name+"&get_product_description", true);
	http_request.onreadystatechange = get_description;
	http_request.send(null);
}

function get_description()
{
	if (http_request.readyState == 4)
		document.getElementById("information2").innerHTML = http_request.responseText;
}

function load_news_by_photo_name(photo_name)
{
	http_request = create_http_request();
	
	http_request.open("get", "core.php?photo_name="+photo_name+"&get_news", true);
	http_request.onreadystatechange = get_news;
	http_request.send(null);
}

function get_news()
{
	if (http_request.readyState == 4)
		document.getElementById("information2").innerHTML = http_request.responseText;
}

function load_local_news(id_news)
{
	http_request = create_http_request();
	
	http_request.open("get", "core.php?id_news="+id_news+"&get_local_news", true);
	http_request.onreadystatechange = get_local_news;
	http_request.send(null);
}

function get_local_news()
{
	if (http_request.readyState == 4)
		document.getElementById("information2").innerHTML = http_request.responseText;
}

function load_industry_news_by_photo_name(photo_name)
{
	http_request = create_http_request();
	
	http_request.open("get", "core.php?photo_name="+photo_name+"&get_industry_news", true);
	http_request.onreadystatechange = get_industry_news;
	http_request.send(null);
}

function get_industry_news()
{
	if (http_request.readyState == 4)
		document.getElementById("information2").innerHTML = http_request.responseText;
}

function Search_And_Show_product_small()
{
	http_request = create_http_request();
	
	http_request.open("post", "core.php?action=Search_And_Show_product_small", true);
	http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	http_request.onreadystatechange = Search_And_Show_product_small_done;
	http_request.send("vendor="+encodeURIComponent(document.forms["Search_And_Show_product_small"].vendor.value)+"&"+
	                  "group_name=0");
}

function Search_And_Show_product_small_for_phototechic(id)
{
	http_request = create_http_request();
	
	http_request.open("post", "core.php?action=Search_And_Show_product_small", true);
	http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	http_request.onreadystatechange = Search_And_Show_product_small_done;
	http_request.send("vendor="+encodeURIComponent(document.forms["Search_And_Show_product_small"].vendor.value)+"&"+
	                  "group_name="+id);
}function Search_And_Show_product_small_for_phototechic2(){	http_request = create_http_request();	http_request.open("post", "core.php?action=Search_And_Show_product_small_for3_colomn", true);	http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");	http_request.onreadystatechange = Search_And_Show_product_small_done;	http_request.send("vendor="+encodeURIComponent(document.forms["Search_And_Show_product_small"].vendor.value)+"&"+	                  "group_name="+encodeURIComponent(document.forms["Search_And_Show_product_small"].group_name.value));}



function Search_And_Show_photo_small_for_janr_author()
{
	http_request = create_http_request();
	
	http_request.open("post", "core.php?action=Search_And_Show_photo_small_for_janr_author", true); 
	http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	http_request.onreadystatechange = Search_And_Show_product_small_done;
	http_request.send("janr="+encodeURIComponent(document.forms["Search_And_Show_photo_small_for_janr_author"].janr.value)+"&"+
		"author="+encodeURIComponent(document.forms["Search_And_Show_photo_small_for_janr_author"].author.value)+"&"+
		"col_day="+encodeURIComponent(document.forms["Search_And_Show_photo_small_for_janr_author"].col_day.value));
}

function Search_And_Show_photo_small_for_mesto_god()
{
	http_request = create_http_request();
	
	http_request.open("post", "core.php?action=Search_And_Show_photo_small_for_mesto_god", true); 
	http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	http_request.onreadystatechange = Search_And_Show_product_small_done;
	http_request.send("raion="+encodeURIComponent(document.forms["Search_And_Show_photo_small_for_mesto_god"].raion.value)+"&"+
		"god="+encodeURIComponent(document.forms["Search_And_Show_photo_small_for_mesto_god"].god.value)+"&"+
		"col_day="+encodeURIComponent(document.forms["Search_And_Show_photo_small_for_mesto_god"].col_day.value));
}

function Search_And_Show_photo_small_for_mesto()
{
	http_request = create_http_request();
	//alert (encodeURIComponent(document.forms["Search_And_Show_photo_small_for_mesto"].raion.value) );
	http_request.open("post", "core.php?action=Search_And_Show_photo_small_for_mesto", true); 
	http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	http_request.onreadystatechange = Search_And_Show_product_small_done;
	http_request.send("raion="+encodeURIComponent(document.forms["Search_And_Show_photo_small_for_mesto"].raion.value)+"&"+
		"col_day="+encodeURIComponent(document.forms["Search_And_Show_photo_small_for_mesto"].col_day.value));
	
}

function Search_And_Show_product_small_done()
{
	if (http_request.readyState == 4)
	{
		document.getElementById("search_result").innerHTML = http_request.responseText;
	}
}

function Search_And_Show_photo_small_for_author (id_author)
{
	http_request = create_http_request();
	
	http_request.open("post", "core.php?action=Search_And_Show_photo_small_for_author", true);
	http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	http_request.onreadystatechange = Search_And_Show_photo_small_for_author_done;
	http_request.send("id_author="+id_author);
}

function Search_And_Show_photo_small_for_author_done()
{
	if (http_request.readyState == 4)
	{
		document.getElementById("search_result").innerHTML = http_request.responseText;
	}
}




function get_info()
{
	http_request = create_http_request();
	
	id = document.forms["product_list"].product.value;
	http_request.open("get", "change_product.php?get_info&id="+id, true);
	http_request.onreadystatechange = get_info_done;
	http_request.send(null);
}

function get_info_done()
{
	if (http_request.readyState == 4)
		document.getElementById("product_form").innerHTML = http_request.responseText;
}

function del_product(id)
{
	http_request = create_http_request();
	
	http_request.open("get", "change_product.php?del_product&id="+id, true);
	http_request.onreadystatechange = del_product_done;
	http_request.send(null);	
}

function del_product_done()
{
	if (http_request.readyState == 4)
	{
		window.location = 'change_product.php';
	}
}

function check_all_click()
{
	form = document.forms["form_news"];
	
//	alert(form.innerHTML);
}
// bbCode control by
// subBlue design
// www.subBlue.com

// Startup variables
var imageTag = false;
var theSelection = false;

// Check for Browser & Platform for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version

var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
                && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
                && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
var is_moz = 0;

var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
var is_mac = (clientPC.indexOf("mac")!=-1);

// Helpline messages
b_help = "Жирный текст: [b]текст[/b]  ";
i_help = "Наклонный текст: [i]текст[/i]  ";
u_help = "Подчёркнутый текст: [u]текст[/u]  ";
q_help = "Цитата: [quote]текст[/quote]  ";
c_help = "Код (программа): [code]код[/code]  ";
l_help = "Список: [list][*]элемент1   [*] элемент2  [/list] ";
o_help = "элемент списка: [*] ";
p_help = "Вставить картинку: [img]http://image_url[/img]  ";
w_help = "Вставить ссылку: [url]http://url[/url] или [url=http://url]текст ссылки[/url]  ";
a_help = "Закрыть все открытые теги bbCode";
s_help = "Цвет шрифта: [color=red]текст[/color]  Подсказка: можно использовать color=#FF0000";

f_help = "Размер шрифта: [size=x-small]маленький текст[/size]";

// Define the bbCode tags
bbcode = new Array();
bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[quote]','[/quote]','[code]','[/code]','[list][*]','[/list]','[*]',' ','[img height=130 ]','[/img]','[url]','[/url]');
imageTag = false;

// Shows the help messages in the helpline window
function helpline(help) {
        document.post.helpbox.value = eval(help + "_help");
}


// Replacement for arrayname.length property
function getarraysize(thearray) {
        for (i = 0; i < thearray.length; i++) {
                if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
                        return i;
                }
        return thearray.length;
}

// Replacement for arrayname.push(value) not implemented in IE until version 5.5
// Appends element to the array
function arraypush(thearray,value) {
        thearray[ getarraysize(thearray) ] = value;
}

// Replacement for arrayname.pop() not implemented in IE until version 5.5
// Removes and returns the last element of an array
function arraypop(thearray) {
        thearraysize = getarraysize(thearray);
        retval = thearray[thearraysize - 1];
        delete thearray[thearraysize - 1];
        return retval;
}
function checkForm() {

        formErrors = false;

        if (document.post.message.value.length < 2) {
                formErrorsText = "Vvedite text soobshenia"; //Этому невдалому браузеру ИЕ6 не нравятся здесь русские буквы************************************************************************
				formErrors = true;
        }
        if (formErrors) {
                alert(formErrors);
                return false;
        } else {
                bbstyle(-1);
                //formObj.preview.disabled = true;
                //formObj.submit.disabled = true;
                return true;
        }
}
function emoticon(text) {
   text = ' ' + text + ' ';
   if (document.forms['post'].message.createTextRange && document.forms['post'].message.caretPos) {
      var caretPos = document.forms['post'].message.caretPos;
      caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
      document.forms['post'].message.focus();
   } else {
   posttextarea = document.forms['post'].message;
   selected=(posttextarea.value).substring(posttextarea.selectionStart,posttextarea.selectionEnd);
   str=' ' + text + ' ';
   posttextarea.focus();
   start=posttextarea.selectionStart;
   end=posttextarea.textLength;
   endtext=posttextarea.value.substring(posttextarea.selectionEnd,end);
   starttext=posttextarea.value.substring(0,start);
   posttextarea.value=starttext + str + endtext;
   posttextarea.selectionStart=start;
   posttextarea.selectionEnd=start;
   return;
   }
}
function emoticon_old(text) {
        var txtarea = document.post.message;
        text = ' ' + text + ' ';
        if (txtarea.createTextRange && txtarea.caretPos) {
                var caretPos = txtarea.caretPos;
                caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
                txtarea.focus();
        } else {
                txtarea.value  += text;
                txtarea.focus();
        }
}
function bbfontstyle(bbopen, bbclose) {
        var txtarea = document.post.message;

        if ((clientVer >= 4) && is_ie && is_win) {
                theSelection = document.selection.createRange().text;
                if (!theSelection) {
                        txtarea.value += bbopen + bbclose;
                        txtarea.focus();
                        return;
                }
                document.selection.createRange().text = bbopen + theSelection + bbclose;
                txtarea.focus();
                return;
        }
        else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
        {
                mozWrap(txtarea, bbopen, bbclose);
                return;
        }
        else
        {
                txtarea.value += bbopen + bbclose;
                txtarea.focus();
        }
        storeCaret(txtarea);
}
function bbstyle(bbnumber) {
        var txtarea = document.post.message;

        txtarea.focus();
        donotinsert = false;
        theSelection = false;
        bblast = 0;

        if (bbnumber == -1) { // Close all open tags & default button names
                while (bbcode[0]) {
                        butnumber = arraypop(bbcode) - 1;
                        txtarea.value += bbtags[butnumber + 1];
                        buttext = eval('document.post.addbbcode' + butnumber + '.value');
                        eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
                }
                imageTag = false; // All tags are closed including image tags :D
                txtarea.focus();
                return;
        }

        if ((clientVer >= 4) && is_ie && is_win)
        {
                theSelection = document.selection.createRange().text; // Get text selection
                if (theSelection) {
                        // Add tags around selection
                        document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
                        txtarea.focus();
                        theSelection = '';
                        return;
                }
        }
        else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
        {
                mozWrap(txtarea, bbtags[bbnumber], bbtags[bbnumber+1]);
                return;
        }

        // Find last occurance of an open tag the same as the one just clicked
        for (i = 0; i < bbcode.length; i++) {
                if (bbcode[i] == bbnumber+1) {
                        bblast = i;
                        donotinsert = true;
                }
        }

        if (donotinsert) {                // Close all open tags up to the one just clicked & default button names
                while (bbcode[bblast]) {
                                butnumber = arraypop(bbcode) - 1;
                                txtarea.value += bbtags[butnumber + 1];
                                buttext = eval('document.post.addbbcode' + butnumber + '.value');
                                eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
                                imageTag = false;
                        }
                        txtarea.focus();
                        return;
        } else { // Open tags

                if (imageTag && (bbnumber != 14)) {                // Close image tag before adding another
                        txtarea.value += bbtags[15];
                        lastValue = arraypop(bbcode) - 1;        // Remove the close image tag from the list
                        document.post.addbbcode14.value = "Img";        // Return button back to normal state
                        imageTag = false;
                }

                // Open tag
                txtarea.value += bbtags[bbnumber];
                if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
                arraypush(bbcode,bbnumber+1);
                eval('document.post.addbbcode'+bbnumber+'.value += "*"');
                txtarea.focus();
                return;
        }
        storeCaret(txtarea);
}
// From http://www.massless.org/mozedit/
function mozWrap(txtarea, open, close)
{
        var selLength = txtarea.textLength;
        var selStart = txtarea.selectionStart;
        var selEnd = txtarea.selectionEnd;
        if (selEnd == 1 || selEnd == 2)
                selEnd = selLength;

        var s1 = (txtarea.value).substring(0,selStart);
        var s2 = (txtarea.value).substring(selStart, selEnd)
        var s3 = (txtarea.value).substring(selEnd, selLength);
        txtarea.value = s1 + open + s2 + close + s3;
        return;
}
// Insert at Claret position. Code from
// http://www.faqts.com/knowledge_SoftBlue/view.phtml/aid/1052/fid/130
function storeCaret(textEl) {
        if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}
function Gofindit()
{
     http_request = create_http_request();
     text = document.post.message.value;
	 
     http_request.open("get", "core_redact_text.php?text="+text+"&get_text", true);
     http_request.onreadystatechange = get_preview_text;
     http_request.send(null);
	 
	 http_request.open("post", "core_redact_text.php?action=get_text", true);
	http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	http_request.onreadystatechange = get_preview_text;
	http_request.send("text="+text);
}
function get_preview_text()
{
	if (http_request.readyState == 4)
	{
		document.getElementById("text_result").innerHTML = http_request.responseText;
	}
}
function emoticon_img(text,field) {
 if (opener && !opener.closed) {
   switch (field) {
   case 'backgroundimage':
   opener.document.getElementById(field).value=text;
   opener.changedBackgroundImage();
   break;

   case 'logo':
   opener.document.getElementById(field).value=text;
   opener.logo(text);
   break;

   case 'src':
   opener.document.getElementById(field).value=text;
   opener.ImageDialog.showPreviewImage(text);
   window.close();
   break;

   case '':
   text = ' [url=http://fotoclub31.ru/'+text+'][img height=130 ]' + text + '[/img] [/url]'; 
    if (opener.document.forms['post'].message.createTextRange && opener.document.forms['post'].message.caretPos) {
    var caretPos = opener.document.forms['post'].message.caretPos;
    caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
    opener.document.forms['post'].message.focus();
    } else {
    posttextarea = opener.document.forms['post'].message;
    selected=(posttextarea.value).substring(posttextarea.selectionStart,posttextarea.selectionEnd);
    str=' ' + text + ' ';
    posttextarea.focus();
    start=posttextarea.selectionStart;
    end=posttextarea.textLength;
    endtext=posttextarea.value.substring(posttextarea.selectionEnd,end);
    starttext=posttextarea.value.substring(0,start);
    posttextarea.value=starttext + str + endtext;
    posttextarea.selectionStart=start;
    posttextarea.selectionEnd=start;
    return;
    }
   }
  } else {
  alert ('Nevozmojno proizvesti vstavku, tak kak roditelskoe okno zakrito');//alert ('Невозможно произвести вставку, так как родительское окно было закрыто');
  window.close();
  }
}
function setImage(string) {
 document.getElementById('prevImage').src = 'File:\/\/' + string;
}
function del() {
        if (confirm("Вы действительно хотите удалить данный файл?")) { return true}
        else{ return false}
}
