if (window.navigator.userAgent.indexOf ("MSIE") > 0) ie4=true;
else ie4=false;
var IE='\v'=='v';
var version;
if (IE)
{
	var nv = navigator.appVersion;
	var s = nv.indexOf("MSIE")+5;
	version = nv.substring(s,s+1);
}

var news_id, news_id_a, pr=0; var pr_a=0;
var pr_levels=0; var pr_levels_a=0; 
var level_light, level_light_a, active_news=1;
var active_news_a=1;
var nid = new Array()
var http = createRequestObject();
var blog_parent_id;
re = /^\s*$/;
re1 = /^[a-zA-Z0-9]+$/;
re2 = /^\d+$/;
re3= /([^<)\s]+@\S+\.[^>(\s]+)/;
re4 = /^[\d \-\+\(\),]+$/;
re5 = /^\d{2}\.\d{2}\.\d{4}$/;
///////////////////////////////////////////////////////////////////////////////// 
///////////////////////////          Ajax        ////////////////////////////////
///////////////////////////////////////////////////////////////////////////////// 
function createRequestObject()
{
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer") ro = new ActiveXObject("Microsoft.XMLHTTP");
    else ro = new XMLHttpRequest();
    return ro;
}
function handleResponse()
{
    if(http.readyState == 4)
	{
        var response = http.responseText;
        var update = new Array();
        if(response.indexOf('|' != -1))
		{
            update = response.split('|');
			re = /DOCTYPE/i;
			re2 = /reg=([0-9]{1,2})/i;
//			if (re.test(update[0])) location.href="http://nevesta.ua/";
			if (re2.test(update[0]))
			{
				var s = update[0];
				var re2 = /.*?reg=([0-9]{1,2}).*/i;
				reg=s.replace(re2, "$1");
				location.href="http://nevesta.ua/registration/?reg="+reg;
			}
			length_=update.length;
			for (i=0; i<=length_; i=i+2)
			{
//				alert(update[i]+"--"+update[i+1])
				if (document.getElementById(update[i])) document.getElementById(update[i]).innerHTML = update[i+1];
				if (update[i]=="popuptxt") Hidden("popup", "inline");
				if (update[i]=="favorites_body") Hidden("favorites", "inline");
			}
        }
    }
}
function goAjax(url)
{
//	alert(url);
    http.open("get", url);
   	http.onreadystatechange = handleResponse;
    http.send(null);
}

///////////////////////////////////////////////////////////////////////////////// 
///////////////////////////         \/Ajax        ///////////////////////////////
///////////////////////////////////////////////////////////////////////////////// 

///////////////////////////////////////////////////////////////////////////////// 
///////////////////////////			Меню		 ////////////////////////////////
///////////////////////////////////////////////////////////////////////////////// 
function OVER(num, level)
{
	clearTimeout(pr);
	for (i=0; i<b.length; i++)
	{
		if (document.getElementById("m"+b[i])) document.getElementById("m"+b[i]).style.visibility="hidden";
	}

	if (version<=6)
	{
		if (num==34 || num==81)
		{
			if (document.getElementById("hide1")) document.getElementById("hide1").style.visibility="hidden";
		}
		if (num==33)
		{
			if (document.getElementById("hide2")) document.getElementById("hide2").style.visibility="hidden";
		}
	}

	if (document.getElementById("m"+num)) document.getElementById("m"+num).style.visibility="visible";
}
function OUT()
{
	for (i=0; i<b.length; i++)
	document.getElementById("m"+b[i]).style.visibility="hidden";

	if (IE)
	{
		if (document.getElementById("hide1")) document.getElementById("hide1").style.visibility="visible";
		if (document.getElementById("hide2")) document.getElementById("hide2").style.visibility="visible";
	}

	clearTimeout(pr);
}
function DELAYS()
{
	pr=setTimeout("OUT()", 100);
}
///////////////////////////////////////////////////////////////////////////////// 
///////////////////////////			/Меню		 ////////////////////////////////
///////////////////////////////////////////////////////////////////////////////// 

///////////////////////////////////////////////////////////////////////////////// 
/////////////////////////// Новости на стартовой ////////////////////////////////
///////////////////////////////////////////////////////////////////////////////// 
if (window.navigator.userAgent.indexOf ("MSIE") > 0) ie4=true;
else ie4=false;
var flag_auto, news_id=1;
var news_auto=1;
var level_light, active_news=1;
var pr_levels=0;
var pr=0;
var pr2=0;

function Hide2news() // функция запускается по время загрузки страницы
{
	for(i=2; i<6; i++)
	{
		if (ie4) document.getElementById("newi"+i).style.filter = "alpha(opacity=0)";
		else document.getElementById("newi"+i).style.opacity=0;
		Hidden("newi"+i, "none");
	}
}
function ShowNews(mode)
{
	if (news_auto==0) news_auto=1;
	if (news_auto==6) news_auto=5;
	if (!mode) {id=news_auto+1; flag_auto=1;}
	else
	{
		if (mode==1) {id=news_auto-1; news_auto--;}
		if (mode==2) {id=news_auto+1; news_auto++;}
		flag_auto=0;
		clearInterval(pr2);
	}
	if (id>5) {news_auto=0; id=news_auto+1;}
	if (id<1) {news_auto=6; id=news_auto-1;}

	if (id!=active_news)
	{
		news_id=id;
		n=5;
		while(n>0)
		{
			if (ie4)
			{
				level_light=100;
				document.getElementById("newi"+n).style.filter = "alpha(opacity=0)";
				document.getElementById("newi"+active_news).style.filter = "alpha(opacity=100)";
			}
			else
			{
				level_light=1.0;
				document.getElementById("newi"+n).style.opacity=0;
				document.getElementById("newi"+active_news).style.opacity=1.0;
			}
			n--;
		}
//		alert(active_news);
		document.getElementById("n_i_r_"+active_news).src="/img/ru/r2.gif";
		document.getElementById("n_i_r_"+id).src="img/ru/r1.gif";
		clearInterval(pr_levels);
		clearTimeout(pr);
		pr=setTimeout("ChangeNews()", 100);
	}
}
function ChangeNews()
{
	clearTimeout(pr);
	if (flag_auto)	speed=30;
	else			speed=30;
	Hidden("newi"+news_id, "inline");
	pr_levels=setInterval("Levels()", speed);
}
function Levels()
{
	if (ie4)
	{
		document.getElementById("newi"+active_news).style.filter = "alpha(opacity="+level_light+")";
		level_light-=10;
		level_light2=100-level_light;
		document.getElementById("newi"+news_id).style.filter = "alpha(opacity="+level_light2+")";
	}
	else
	{
		document.getElementById("newi"+active_news).style.opacity = level_light;
		level_light-=0.1;
		level_light2=1.0-level_light;
		document.getElementById("newi"+news_id).style.opacity = level_light2;
	}
	if (level_light<=0)
	{
		if (ie4) document.getElementById("newi"+active_news).style.filter = "alpha(opacity=0)";
		document.getElementById("newi"+active_news).style.opacity=0;
		Hidden("newi"+news_id, "inline");
		Hidden("newi"+active_news, "none");
		clearInterval(pr_levels);
		active_news=news_id;
		if (flag_auto) news_auto++;
	}
}
///////////
///////////

function Hide2news_a() // функция запускается по время загрузки страницы
{
	if (ie4) document.getElementById("newi2_a").style.filter = "alpha(opacity=0)";
	else document.getElementById("newi2_a").style.opacity=0;
}
function ShowNews_a(id)
{
	if (id!=active_news_a)
	{
		news_id_a=id;
		n=3;
		while(n>0)
		{
			if (ie4)
			{
				level_light_a=100;
				document.getElementById("newi"+n+"_a").style.filter = "alpha(opacity=0)";
				document.getElementById("newi"+active_news_a+"_a").style.filter = "alpha(opacity=100)";
			}
			else
			{
				level_light_a=1.0;
				document.getElementById("newi"+n+"_a").style.opacity=0;
				document.getElementById("newi"+active_news_a+"_a").style.opacity=1.0;
			}
			n--;
		}
		clearInterval(pr_levels_a);
		clearTimeout(pr_a);
		pr_a=setTimeout("ChangeNews_a()", 100);
	}
}
function ChangeNews_a()
{
	clearTimeout(pr_a);
	pr_levels_a=setInterval("Levels_a()", 30);
}
function Levels_a()
{
	if (ie4)
	{
		document.getElementById("newi"+active_news_a+"_a").style.filter = "alpha(opacity="+level_light_a+")";
		level_light_a-=10;
		level_light2=100-level_light_a;
		document.getElementById("newi"+news_id_a+"_a").style.filter = "alpha(opacity="+level_light2+")";
	}
	else
	{
		document.getElementById("newi"+active_news_a+"_a").style.opacity = level_light_a;
		level_light_a-=0.1;
		level_light2=1.0-level_light_a;
		document.getElementById("newi"+news_id_a+"_a").style.opacity = level_light2;
	}
	if (level_light_a<=0)
	{
		if (ie4) document.getElementById("newi"+active_news_a+"_a").style.filter = "alpha(opacity=0)";
		document.getElementById("newi"+active_news_a+"_a").style.opacity=0;
		clearInterval(pr_levels_a);
		active_news_a=news_id_a;
	}
}

///////////////////////////////////////////////////////////////////////////////// 
/////////////////////////// \Новости на стартовой ///////////////////////////////
///////////////////////////////////////////////////////////////////////////////// 
function Hidden(id, style)
{
	if (document.getElementById(id))
	{
		if (style == "table-row")
		{
				if (ie4) document.getElementById(id).style.display="inline";
				else document.getElementById(id).style.display=style;
		}
		else
		document.getElementById(id).style.display=style;
	}
}

function OnFocus(always, object, mode)
{
	if (mode==1)
	{
		if (object.value==always) object.value="";
	}
	else
	{
		if (object.value=="")
		{
			object.value=always;
			 if (always=="Искать") document.SearchForm.is_keyword.value=0; // только для поиска присваиваем переменную
		}
		else if (always=="Искать") document.SearchForm.is_keyword.value=1; // только для поиска присваиваем переменную
	}
}
///////////////////////////////////////////////////////////////////////////////// 
///////////////////////////\\Новости на стартовой////////////////////////////////
///////////////////////////////////////////////////////////////////////////////// 

function Participate()
{
	re = /^\s*$/;
	flag=true;
	with (document.DownloadPhoto)
	{
		if (re.test(photo.value))
		{
			if (document.getElementById("typecompetition").value!=591)
			{
				alert("Загрузите фотографию");
				photo.focus();
				return;
			}
		}
		if (re.test(name.value))
		{
			alert("Введите имя/имена участников");
			name.focus();
			return;
		}
		if (re.test(datewedding.value))
		{
			alert("Выберите дату свадьбы");
			datewedding.focus();
			return;
		}
		submit();
	}
}
function Vote(id, cat_id, event)
{
	for(key in nid)
	Hidden("vote"+key, "none");
	if (!event) event=window.event;
	coorY=event.clientY-350;
	document.getElementById("popup").style.top=document.documentElement.scrollTop+coorY+"px";
	url="/misc/vote.php?id="+id+"&cat_id="+cat_id;
	goAjax(url);
//	Hidden("vote", "none");
}
function hideDhtmlPop(num)
{
	Hidden("popup", "none");
}
function Horo()
{
	document.Horo.submit();
}
//////////////////// For registration /////////////////////////
function save(mode)
{
	re2 = /^\d+$/;
	flag=true;
	if (document.Form.blog_parent_id) document.Form.blog_parent_id.value=blog_parent_id; // для комментария статей блога
	with (document.Form)
	{
		if (document.getElementById("registrant_type"))
		{
			if (document.getElementById("registrant_type").value==0)
			{
				alert("Выберите тип регистрации");
				return;
			}
		}
/*		if (document.getElementById("company"))
		{
			if (re.test(company.value) && document.getElementById("registrant_type").value==2)
			{
				alert("Введите название компании");
				company.focus();
				return;
			}
		}*/
		if (document.getElementById("name"))
		{
			if (re.test(name.value))
			{
				alert("Введите имя");
				name.focus();
				return;
			}
		}
		if (document.getElementById("secondname"))
		{
			if (re.test(secondname.value))
			{
				alert("Введите фамилию");
				secondname.focus();
				return;
			}
		}
		if (document.getElementById("city"))
		{
			if (city.value==0)
			{ 
				alert("Выберите город");
				return;
			}
		}
		if (document.getElementById("email"))
		{
			if (!re3.test(email.value))
			{ 
				alert("Введите email");
				email.focus();
				return;
			}
		}
		if (document.getElementById("content"))
		{
			if (re.test(content.value))
			{
				alert("Введите текст сообщения");
				content.focus();
				return;
			}
		}
		if (document.getElementById("question"))
		{
			if (re.test(question.value))
			{
				alert("Введите вопрос");
				question.focus();
				return;
			}
		}
		if (document.getElementById("comment"))
		{
			if (re.test(comment.value))
			{
				alert("Введите комментарий");
				comment.focus();
				return;
			}
		}
		if (document.getElementById("music_title"))
		{
			if (re.test(music_title.value))
			{
				alert("Введите название музыкального произведения");
				music_title.focus();
				return;
			}
		}
		if (document.getElementById("music_performer"))
		{
			if (re.test(music_performer.value))
			{
				alert("Введите имя исполнителя");
				music_performer.focus();
				return;
			}
		}
		if (document.getElementById("login"))
		{
			if (!re1.test(login.value))
			{
				alert("Логин - может содержать латинские буквы и цифры");
				login.focus();
				return;
			}
			if ((login.value.length<4)||(login.value.length>15))
			{
				alert("Логин должен быть более 4 и менее 15 символов!");
				login.focus();
				return;
			}
		}
		if (document.getElementById("pass"))
		{
			if (re.test(pass.value) || (pass.value=="******")) 
			{
				alert("Введите пароль");
				pass.focus();
				return;
			}
			if ((pass.value.length<6)||(pass.value.length>15)) 
			{
				alert("Пароль должен быть более 6 и менее 15 символов!");
				pass.focus();
				return;
			}
			if (pass.value!=re_passwd.value)
			{
				alert("Несовпадение паролей");
				re_passwd.focus();
				return;
			}
		}
		if (document.getElementById("question"))
		{
			if (re.test(question.value) || question.value=="")
			{
				alert("Вопрос отсутствует");
				question.focus();
				return;
			}
		}
		if (document.getElementById("checknum"))
		{
			if (!re2.test(checknum.value) || checknum.value=="")
			{
				alert("Введите проверочный текст");
				checknum.focus();
				return;
			}
		}
		if (document.getElementById("sent")) document.getElementById("sent").value=1;
		submit();
	}
}
////////////////////////////////////////////////////////////////

/////////////////////// Autorissation //////////////////////////
function GO(mode, type)
{
	if (type==2)
	{
		if (mode!="sendpass") document.formlogin2.mode.value=mode;
		if (mode=="reg")  document.formlogin2.action="/registration/";
		if (mode=="send") document.formlogin2.action="/registration/?mode="+mode;
		if (mode=="sendpass") document.SendPasswd.submit();
		else document.formlogin2.submit();
	}
	else
	{
		if (mode=="exit")
		{
			document.formlogin.mode.value=mode;
			document.formlogin.action="/registration/?reg=11";
			document.formlogin.submit();
		}
		else
		{
			if (mode!="sendpass") document.formlogin.mode.value=mode;
			if (mode=="reg")  document.formlogin.action="/registration/";
			if (mode=="send") document.formlogin.action="/registration/?mode="+mode;
			if (mode=="sendpass") document.SendPasswd.submit();
			else document.formlogin.submit();
		}
	}
}
////////////////////////////////////////////////////////////////
function SUBMITT3(num, mode) // используется в регистрации
{
	if (mode==3 || mode==2) // страны в регистрации
	{
		if (document.getElementById("sel_id_"+num).options[document.getElementById("sel_id_"+num).selectedIndex].value==0)
		num--;
		if (num==0) num++;
		local_city=document.getElementById("sel_id_"+num).options[document.getElementById("sel_id_"+num).selectedIndex].value;
		document.Form.city.value=local_city
		url="/misc/edit_change_s.php?cat_id="+local_city+"&mode="+mode;
	}
	goAjax(url);
}
function SUBMITT3a(city) // используется в регистрации
{
	url="/misc/edit_change_s.php?cat_id="+city+"&mode=3";
	goAjax(url);
}
function Search(mode)
{
	switch(mode)
	{
		case 1:
			document.Form.submit();
		break;
	}
}
function GoToPage(type, id)
{
	location.href="/"+type+"/"+id+"/";
}
function GoGoro()
{
	if (document.getElementById("he_goro").value && document.getElementById("she_goro").value) document.Goro.submit();
}
function Forum(mode, id)
{
	flag=false;
	if (mode=="delete" && confirm("Хотите удалить сообщение?")) flag=true;
	if (mode=="edit") flag=true;
	if (mode=="newtopic") // создание тем на форуме
	{
		flag=1;
		if (re.test(document.Forum.title.value))
		{
			alert("Введите тему форума");
			title.focus();
			flag=0;
			return;
		}
		if (re.test(document.Forum.message.value)) // Сообщение
		{
			alert("Введите сообщение");
			message.focus();
			flag=0;
			return;
		}
	}
	if (mode=="send_message")
	{
		flag=1;
		if (re.test(document.Forum.title.value))
		{
			alert("Введите тему письма");
			title.focus();
			flag=0;
			return;
		}
		if (re.test(document.Forum.message.value)) // Сообщение
		{
			alert("Введите сообщение");
			message.focus();
			flag=0;
			return;
		}
	}
	
	if (flag)
	{
		document.Forum.mode.value=mode;
		document.Forum.id.value=id;
		document.Forum.submit();
	}
}
function CalendarDate(day, month, year, event)
{
	overl=setTimeout("Overlay()", 0);
	if (!event) event=window.event;
	if (document.body.clientWidth<1000)
	coorX=193;
	else 
	coorX=document.body.clientWidth/2-307;
	coorX=-coorX;
	coorY=event.clientY+document.documentElement.scrollTop-250;
//	alert(coorY)
	
	document.getElementById("window_content").style.top=coorY+"px";
	document.getElementById("overlay").style.left=coorX+"px";
	document.getElementById("wintxt").innerHTML="Информация загружается";
	Hidden("window_content", "inline");
	url="/misc/calendar.php?day="+day+"&month="+month+"&year="+year;
	goAjax(url);
}

function Wedding(num)
{
	Hidden("lovestory", "none"); Hidden("story_wedding", "none"); Hidden("story_journey", "none"); Hidden("budget_wedding", "none");
	switch(num)
	{
		case 1: Hidden("lovestory", "inline"); break;
		case 2: Hidden("story_wedding", "inline"); break;
		case 3: Hidden("story_journey", "inline"); break;
		case 4: Hidden("budget_wedding", "inline"); break;
	}
	location.href="#buts1";
}

function Wedding2(num, login)
{
	location.href="/wedding/"+login+"&buts="+num;
}
////// Опросы //////
var check;
var q_id;
function Opros(curr_question_id, question_id)
{
	url="/misc/opros.php?curr_question_id="+curr_question_id+"&question_id="+question_id+"&check="+check;
	check=0;
//	alert(url);
	goAjax(url);
}

function OprosCheckSet(id)
{
	check=id;
}

function CloseOpros(opros_id)
{
	Hidden("OprosMain", "none");
	url="/misc/opros_done.php?opros_id="+opros_id;
	goAjax(url);
}
////////////////////

//#############################################################
//##########          Бюджетный калькулятор          ##########
//#############################################################
var FlagCalc=0;
function AddToCalculator(cat_id)
{
	url="/misc/addcalc.php?cat_id="+cat_id+"&flag_calc="+FlagCalc;
	FlagCalc++;
	goAjax(url);
}
function Calculate(num)
{
	window.open("", "calcs"+num, "width=450, height=630, top=100, left=200, location=no, titlebar=no, toolbar=no, status=no, scrollbars=yes, menubar=yes, directories=no");
	//document.Calculator.submit();
}
//#############################################################
//#############################################################

function AddToFavorites(id, mode)
{
	if (mode=="delete" || mode=="deletepresent") Hidden("t_fav_"+id, "none");
	url="/misc/addtofavorites.php?id="+id+"&modes="+mode;
	goAjax(url);
}
function ChangeCity()
{
/*	city=document.getElementById("gen_city").options[document.getElementById("gen_city").selectedIndex].value;
	if (city>0)
	{
		url="/misc/changecity.php?city="+city;
		goAjax(url);
		pr_city=setTimeout("RefreshForCity()", 100);
	}
	*/
	document.Cities.submit();
}
function RefreshForCity()
{
//	location.href=document.getElementById("url_city").value;
	clearTimeout(pr_city);
	document.Cities.submit();
}
function SetStart(id, mode)
{
	if (mode==1) Hidden("err_lamp", "none");
//	else Hidden("err_lamp", "inline");
	url="/misc/setstart.php?id="+id+"&mode="+mode;
	goAjax(url);
}
function Sign(forum_id)
{
	url="/misc/sign_forum.php?forum_id="+forum_id;
	goAjax(url);
}
function SendInvitings()
{
	if (document.Data.email.value=="")
	{
		alert("Необходимо ввести электронные адреса");
		return;
	}
	else document.Data.submit();
}
function ShowForm(xfaq_id, mode)
{
	if (mode=="guest") // Вход для гостей
	{
		Hidden("form_guests", "inline");
		Hidden("form_guests_link", "none");
	}
	else // отзывы в статье блога
	{
		document.getElementById("op"+xfaq_id).innerHTML=form;
		if (faq_id!=xfaq_id) document.getElementById("op"+faq_id).innerHTML="";
		faq_id=xfaq_id;
		blog_parent_id=faq_id;
	}
}
function GuestEnter()
{
	if (document.FormGuest.password.value=="")
	{
		alert("Введите пароль");
		return;
	}
	else document.FormGuest.submit();
}
function Guest(cat_id, pass, mode)
{
	if (mode==1)
	{
		checked=document.getElementById("r"+cat_id).checked;
		if (checked) document.getElementById("txt"+cat_id).innerHTML="Подарок забронирован <strong>Вами</strong>";
		else document.getElementById("txt"+cat_id).innerHTML="";
	}
	else if (mode==2)
	{
		checked=document.getElementById("ro2"+cat_id).checked;
		if (checked) document.getElementById("txt2"+cat_id).innerHTML="Подарок забронирован <strong>Вами</strong>";
		else document.getElementById("txt2"+cat_id).innerHTML="";
	}
	url="/misc/guest.php?cat_id="+cat_id+"&pass="+pass+"&checked="+checked+"&mode="+mode;
	goAjax(url);
}

function Overlay()
{
	clearTimeout(overl);
	pW = getPageSize();
	x = document.body.clientWidth;
	y = document.body.scrollTop;

	if (document.body.clientWidth<1000) x=1000;
	document.getElementById("overlay").style.width = x+"px";
	document.getElementById("overlay").style.height = pW[1]+"px";
	Hidden("overlay", "inline");
}

function getPageSize()
{
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY)
	{
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if (document.body.scrollHeight > document.body.offsetHeight) // all but Explorer Mac
	{
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	}
	else // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
	{
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight)// all except Explorer
	{
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
	{
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight) pageHeight = windowHeight;
	else pageHeight = yScroll;

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth) pageWidth = windowWidth;
	else pageWidth = xScroll;

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
}
///////////////////////////////////////////////////////
//////////               Форум               //////////
///////////////////////////////////////////////////////
function TOADD(open, close, spot)
{
    msgfield = document.forms["Forum"].elements["message"];
    if (document.selection && document.selection.createRange)
	{
        msgfield.focus();
        sel = document.selection.createRange();
        sel.text = open + sel.text + close;
        msgfield.focus();
    }
    else if (msgfield.selectionStart || msgfield.selectionStart == '0')
	{
        var startPos = msgfield.selectionStart;
        var endPos = msgfield.selectionEnd;
        msgfield.value = msgfield.value.substring(0, startPos) + open + msgfield.value.substring(startPos, endPos) + close + msgfield.value.substring(endPos, msgfield.value.length);
        msgfield.selectionStart = msgfield.selectionEnd = endPos + open.length + close.length;
        msgfield.focus();
    }
    else 
	{
        msgfield.value += open + close;
        msgfield.focus();
    }
    return;
}
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////

function DelPhotoF(num, id)
{
	url="/misc/save.php?mode=remove_image&num="+num+"&id="+id;
	goAjax(url);
}
function ShowMap(id, event)
{
	overl=setTimeout("Overlay()", 0);
	if (!event) event=window.event;
	if (document.body.clientWidth<1000)
	coorX=193;
	else 
	coorX=document.body.clientWidth/2-307;
	coorX=-coorX;
	coorY=event.clientY+document.documentElement.scrollTop-350;
	coorX2=-193;
	document.getElementById("window_content").style.top="70px";
	document.getElementById("overlay").style.left=coorX+"px";
	document.getElementById("overlay").style.top=coorX2+"px";
//	document.getElementById("wintxt").innerHTML="Информация загружается";
	Hidden("window_content", "inline");
//	url="/misc/map.php?id="+id;
//	goAjax(url);
}
