function regScript(id, name) {
	var doc = document;
	var head = doc.getElementsByTagName("head")[0];
	var elem = doc.createElement("script");
	var oScript = head.appendChild(elem);
	oScript.setAttribute("src", name);
	oScript.setAttribute("language", "javascript");
	oScript.setAttribute("type", "text/javascript");
	oScript.setAttribute("id", id);

}

hideHrefTimeout = 0;
function showHref(par, id) {

	// alert(document.getElementById("href"+par).style.visibility);
	if (document.getElementById("href" + par).style.visibility == 'hidden') {
		document.getElementById("href" + par).style.visibility = 'visible';
		if (document.getElementById('gallery' + par))
			document.getElementById('gallery' + par).style.visibility = 'visible';
		if (!document.all && !window.ActiveXObject)
			document.getElementById("picIns" + par).style.background = "url('/pic/saunacell_over.png') repeat";
		if (document.getElementById("recomended" + par)) {
			document.getElementById("recomended" + par).style.visibility = 'hidden';
		}
		if (document.getElementById("showBlockTelText" + par)) {
			document.getElementById("showBlockTelText" + par).style.color = '#eaff38';
			document.getElementById("showBlockTelText" + par).style.textDecoration = 'underline';
		}

	}
}
function hideHref(par, id) {

	document.getElementById("href" + par).style.visibility = 'hidden';
	if (document.getElementById('gallery' + par))
		document.getElementById('gallery' + par).style.visibility = 'hidden';
	if (!document.all && !window.ActiveXObject)
		document.getElementById("picIns" + par).style.backgroundImage = "";
	if (document.getElementById("recomended" + par))
		document.getElementById("recomended" + par).style.visibility = 'visible';
	if (document.getElementById("showBlockTelText" + par)) {
		document.getElementById("showBlockTelText" + par).style.color = '#fff';
		document.getElementById("showBlockTelText" + par).style.textDecoration = 'none';
	}
}

function showHrefY(par, id) {

	if (!document.all && !window.ActiveXObject)
		document.getElementById('galleryY' + par).style.visibility = 'visible';

}

function hideHrefY(par, id) {

	document.getElementById('galleryY' + par).style.visibility = 'hidden';

}

// НОВЫЕ ФУНКЦИИ ---------------------------------------------------------------

function showPic(numb, id, name, pics, text) {// alert("pic"+id.innerHTML);
	numb.style.color = "#eaff38";
	showPicTimeout = setTimeout(
			function() {
				document.getElementById("pic" + id).style.backgroundImage = 'url(/'
						+ name + '/pic/' + (numb.innerHTML) + '.jpg)';
				for (i = 0; i < pics; i++) {
					document.getElementById('gallery' + id)
							.getElementsByTagName('div')[i].style.color = "#fff"
				}
				numb.style.color = "#eaff38";
				// alert(numb.style.color);
			}, 300)
}
function showPicY(numb, id, name, pics, text) {
	numb.style.color = "#eaff38";
	if (name != '')
		dopUrl = '/' + name + '/';
	else
		dopUrl = '';
	// alert('url('+dopUrl+'pic/'+(numb.innerHTML)+'.jpg)');
	showPicTimeoutY = setTimeout(function() {
		document.getElementById("picY" + id).style.backgroundImage = 'url('
				+ dopUrl + 'pic/' + (numb.innerHTML) + '.jpg)';
		for (i = 0; i < pics; i++) {
			document.getElementById('galleryY' + id)
					.getElementsByTagName('div')[i].style.color = "#fff"

			// numb.style.backgroundColor="#e3dfd3";

		}
		numb.style.color = "#eaff38";
	}, 300)
}
function hidePic(numb, id, name) {
	/*
	 * alert(document.getElementById("pic"+id).style.backgroundImage);
	 * if(name!='') dopUrl='/'+name+'/'; else dopUrl='';
	 */
	if (document.getElementById("pic" + id).style.backgroundImage != 'url(/'
			+ name + '/pic/' + (numb.innerHTML) + '.jpg)'
			&& document.getElementById("pic" + id).style.backgroundImage != 'url("/'
					+ name + '/pic/' + (numb.innerHTML) + '.jpg")') {
		numb.style.color = "#fff";
	}

	else {
		numb.style.color = "#eaff38";
	}
	clearTimeout(showPicTimeout);
}
function hidePicY(numb, id, name) {// alert(document.getElementById("picY"+id).style.backgroundImage);
	if (document.getElementById("picY" + id).style.backgroundImage != 'url(/'
			+ name + '/pic/' + (numb.innerHTML) + '.jpg)'
			&& document.getElementById("picY" + id).style.backgroundImage != 'url("/'
					+ name + '/pic/' + (numb.innerHTML) + '.jpg")') {
		numb.style.color = "#fff";

	}

	else {

		numb.style.color = "#eaff38";

	}

	clearTimeout(showPicTimeoutY);

}
function showPanel(par) {

	if (document.getElementById("gallery" + par).style.visibility != 'visible') {

		showPanelTimeout = setTimeout(
				function() {

					document.getElementById("gallery" + par).style.visibility = 'visible';

				}, 300)

	}

	else {

		document.getElementById("gallery" + par).style.visibility = 'visible';

		clearTimeout(hidePanelTimeout);

	}

}

function hidePanel(par) {

	hidePanelTimeout = setTimeout(
			function() {

				if (document.getElementById("gallery" + par).style.visibility != 'hidden') {

					document.getElementById("gallery" + par).style.visibility = 'hidden';

					// document.getElementById('text'+par).style.visibility="hidden";

				}

			}, 100)

	clearTimeout(showPanelTimeout);

}

// КОНЕЦ НОВЫЕ ФУНКЦИИ
// ---------------------------------------------------------------


function changeGroup() {
	if (document.getElementById("typegroup").value != "DESC") {
		document.getElementById("typegroup").value = "DESC";
	} else {
		document.getElementById("typegroup").value = " ";
	}
	document.getElementById("free").submit();
}
function submitForm() {
	// Зануление направления упорядочивания
	if (document.getElementById("typegroup")
			&& document.getElementById("typegroup").value != "")
		document.getElementById("typegroup").value = "";
	
	document.getElementById("free").submit();
}
/*function submitFormT() {
	// Зануление направления упорядочивания
	document.getElementById("freeZT").submit();
}*/
function wl(name) {
	window.location = name;
}
function correct(page) {// alert('1');
	// Правим размер нашей галереи при загрузки, если ширина меньше 1200
	/*if (document.body.clientWidth < 1200) {// alert(document.body.clientWidth);
		var elem = document.getElementsByTagName("div");
		var arr = new Array();
		for (i = 0, iarr = 0; i < elem.length; i++) {

			att = elem[i].getAttribute("name");

			if (att == "horizontal_viewport") {
				// alert(elem.length);
				arr[iarr] = elem[i];
				arr[iarr].style.width = document.body.clientWidth / 2 - 74
						+ 'px';
				iarr++;
			}
		}
	}*/
/*
	if (self.innerHeight)
		screenHeight = self.innerHeight;
	else if (document.body.clientHeight)
		screenHeight = document.body.clientHeight;
	if (screenHeight > 700) {
		// alert(document.getElementById("flashconteiner").style.height);
		if (screenHeight < 900)
			height = (screenHeight - 170);
		else
			height = 700;

		document.getElementById("flashconteiner").style.height = (height + 21)
				+ "px";
		document.getElementById("flashprecont2").style.height = height + "px";
		// alert(document.getElementById("flashconteiner").style.height);
	}*/
}

function correctMainPage() {
	/*
	 * if(document.body.clientWidth>1300 && document.all) {
	 * document.getElementById("nTopBack").style.width =
	 * document.getElementById("ddd").style.width=
	 * document.getElementById("scrollMenuDiv").style.width =
	 * document.getElementById("sdss").style.width = "1200px";
	 * //document.getElementById("bottCintCont").style.width = "1050px"; }
	 */
}
function insertOtziv() {//больше не используется
	if (document.getElementById("scrollOtziv")) {
		document.getElementById("scrollOtziv").innerHTML = '<div class="frby"><table height="100%"><tbody><tr><td valign="middle"><a href="javascript:MyOtziv.mo_show_box();"><img class="tdsh" style="border: 0;" alt="" src="http://panorama66.ru/pic/label.png"></a></td></tr></tbody></table></div>';
	}

}
function showFlash(type, name, debug) {
	document.getElementById('frameflash').src = '/base/other/flash/flash.php?type='
			+ type + '&name=' + name + '&debug=' + debug;
	/* alert('/base/other/flash/flash.php?type='+type+'&name='+name+'&debug='+debug); */
	document.getElementById('frameflash').style.width = '100%';
	document.getElementById('frameflash').style.height = '100%';
	document.getElementById('flashprecont2').style.display = 'none';
}

function opimg(part, picsNames1, picsNames0, colZal, objname) {
	window.open('http://www.panorama66.ru/base/other/php/index_big.php?part='
			+ part + '&imgname=' + picsNames1 + '&name=' + picsNames0 + '&otd='
			+ colZal + '&objname=' + objname, "",
			"scrollbars=1, location=0, menubar=0, resizable");
}
function block() {
	if (document.getElementById('err').style.width == '285px') {
		document.getElementById('err').style.width = '820px';
		document.getElementById('doptext').style.display = 'block';
	} else {
		document.getElementById('doptext').style.display = 'none';
		document.getElementById('err').style.width = '285px';
	}
}/*
function showHTMLtopmenu(showHidePanel, typegroupType, sortM, typegroup,
		infoSauns) {
	switch (sortM) {
	case "porT":
		por = 0;
		break;
	case "index_price_intT":
		por = 1;
		break;
	case "name_rusT":
		por = 2;
		break;
	case "vmestT":
		por = 3;
		break;
	}
	text = '<div class="scrollBlock" id="scrollBlock" style="'
			+ showHidePanel
			+ '">		</div>		<table border="0" cellpadding="0" cellspacing="0" class="scrollBlockMenu" id="scrollBlockMenu" style="'
			+ showHidePanel
			+ '">			<tr>				<td align="center">					<div class="scrollBlockMenu2" id="scrollBlockMenu2">					<table border="0" cellpadding="0" cellspacing="0" align="right" width="0" class="scrollt2">						<tr>							<td><script type="text/javascript">insertPng("catalogballoon_ugol1", "", "", 13, 55);</script></td>							<td class="dcd1">								<div class="sdss">								<table border="0" cellpadding="0" cellspacing="0" width="100%">									<tr>										<td nowrap style="position: relative;">											<form method="GET" name="freeT" id="freeT">											<table border="0" cellpadding="0" cellspacing="0" class="sdssTable" height="50">												<tr>													<td nowrap align="right" class="tabl1">														Упорядочить по:													</td>													<td nowrap align="right" class="tabl2">													<select name="sortT" id="sortT" onchange="submitForm(\'T\')" class="sortT">														<option value="por" id="porT">рейтингу</option>														<option value="index_price_int" id="index_price_intT">стоимости</option>														<option value="name_rus" id="name_rusT">названию</option>						 								<option value="vmest" id="vmestT">вместительности</option>													</select>													</td>													<td nowrap align="left" class="sdss12" valign="top" width="300">														<table border="0" cellpadding="0" cellspacing="0" class="sdsd">															<tr>																<td><img src="/pic/sortdirection2.gif" hspace="10"></td>																<td onclick="changeGroup(\'T\')" class="sdss2" align="center">														'
			+ typegroupType
			+ '</td></tr></table></td><td width="100%" align="center" class="finded">'
			+ infoSauns
			+ '</td>	</tr></table>																								 <script type="text/javascript">									setTimeout( function(){ document.getElementById("sortT").options['
			+ por
			+ '].selected=true;}, 1 );								</script> 																												<input type="hidden" id="showHidePanelT" name="showHidePanelT" value="'
			+ showHidePanel
			+ '">								<input type="hidden" id="typegroupT" name="typegroupT" value="'
			+ typegroup
			+ '"></form>																   </td>						    <td class="closess" align="right" style="position: relative;" valign="middle"><div onclick="showTopMenu()" class="closb1">Закрыть</div>								</td>								</tr>								</table>							   </div>							  							</td>							<td><script type="text/javascript">insertPng("catalogballoon_ugol2", "", "", 13, 55);</script></td>						</tr>						<tr>							<td class="dcd2"></td>							<td align="left" class="dcd3">							  								<div class="content2" id="sodMenu"><!--noindex-->								<!--/noindex-->										</div>																<div class="tail"></div>							</td>							<td class="dcd4"></td>						</tr>						<tr>							<td><script type="text/javascript">insertPng("mapballoon2_ugol3", "", "", 13, 14);</script></td>							<td class="dcd5"></td>							<td><script type="text/javascript">insertPng("mapballoon2_ugol4", "", "", 13, 14);</script></td>						</tr>					</table>					</div>				</td>			</tr>		</table>';
	// alert(text);
	document.write(text);
}
function top_menu() {
	document
			.write('<div class="scrollMenu">	<div class="scrollMenuDiv">		<table border="0" cellpadding="0" cellspacing="0" width="100%">			<tr>				<td class="tim1"><script type="text/javascript">insertPng("panel2_left", "", "", 22, 38);</script></td>				<td width="100%" class="tim3" valign="top" align="right">				<a href="http://www.panorama66.ru/"><script type="text/javascript">insertPng("panellogo", "", " class=\'cim\' align=\'left\'", 161, 19);</script></a>				<table border="0" cellpadding="0" cellspacing="0" height="35">					<tr>						<td class="cim1" valign="middle" nowrap>							  <a href="/">Главная</a>							  <script type="text/javascript">insertPng("panel2_orangedivider", "", "align=\'absbottom\'", 1, 21);</script>							  <a href="/page/about/">О проекте</a>							  <script type="text/javascript">insertPng("panel2_orangedivider", "", "align=\'absbottom\'", 1, 21);</script>							  <a href="/page/contacts/">Регистрация</a>						</td>						<td class="cim2c"><a></a></td>						<td class="cim1c" onclick="showTopMenu()" nowrap><a href="" onclick="return false">Каталог</a></td>					</tr>				</table>				</td>				<td class="tim2"><script type="text/javascript">insertPng("panel2_right", "", "", 23, 38);</script></td>			</tr>		</table>		<img src="/pic/blank.gif" width="700" height="0"/>	</div></div>');
}*/
function moduleYandStart() {
	document
			.write('<div class="nTopBack">	  	<div class="cim2"><a href="http://www.panorama66.ru/"><script type="text/javascript">insertPng("slogan", "", "", 237, 19);</script></a></div>			    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="nTopBack1">              <tr>                <td valign="top">                  <table border="0" cellpadding="0" cellspacing="0" class="nTop1fonT">                    <tr>                      <td><script type="text/javascript">insertPng("frameugol", "", " class=\'corners\'", 27, 27);</script></td>                    </tr>                    <tr>                      <td class="nTop1fon1" style="height:310px"></td>                    </tr>                    <tr>                      <td><script type="text/javascript">insertPng("frameugol-03", "", " class=\'corners\'", 27, 27);</script></td>                    </tr>                  </table>                </td>                <td class="nTop1fon2">                  <table height="100%" width="100%" border="0" cellpadding="0" cellspacing="0">                    <tr>                      <td>                        <table height="100%" width="100%" border="0" cellpadding="0" cellspacing="0">                          <tr>                            <td class="nTop1fon2Top1">                            <td>                            <td class="nTop1fon2Top2">                            <td>                            <td class="nTop1fon2Top1">                            <td>                          </tr>                        </table>                      </td>                    </tr>                    <tr>                      <td class="nTop1fonBanner">					  	<div id="YMapsID" style="width:100%;height:345px;background-color:#FFF;"></div>                      </td>                    </tr>                    <tr>                      <td>                        <table width="100%" border="0" cellpadding="0" cellspacing="0">                          <tr>                            <td class="nTop1fon2Top1">                            <td>                            <td class="nTop1fon2Top3">                            <td>                            <td class="nTop1fon2Top1">                            <td>                          </tr>                        </table>                      </td>                    </tr>                  </table>                </td>                <td>                  <table border="0" cellpadding="0" cellspacing="0" class="nTop1fonT2">                    <tr>                      <td><script type="text/javascript">insertPng("frameugol-02", "", " class=\'corners\'", 27, 27);</script></td>                    </tr>                    <tr>                      <td class="nTop1fon1_1" style="height:310px">                      </td>                    </tr>                    <tr>                      <td><script type="text/javascript">insertPng("frameugol-04", "", " class=\'corners\'", 27, 27);</script></td>                    </tr>                  </table>                </td>              </tr>            </table>');
}
function getOffset(elem) {
	if (elem.getBoundingClientRect) {
		// "правильный" вариант
		return getOffsetRect(elem)
	} else {
		// пусть работает хоть как-то
		return getOffsetSum(elem)
	}
}

function getOffsetSum(elem) {
	var top = 0, left = 0
	while (elem) {
		top = top + parseInt(elem.offsetTop)
		left = left + parseInt(elem.offsetLeft)
		elem = elem.offsetParent
	}
	return {
		top : top,
		left : left
	}
}

function getOffsetRect(elem) {
	// (1)
	var box = elem.getBoundingClientRect()

	// (2)
	var body = document.body
	var docElem = document.documentElement

	// (3)
	var scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop
	var scrollLeft = window.pageXOffset || docElem.scrollLeft
			|| body.scrollLeft

	// (4)
	var clientTop = docElem.clientTop || body.clientTop || 0
	var clientLeft = docElem.clientLeft || body.clientLeft || 0

	// (5)
	var top = box.top + scrollTop - clientTop
	var left = box.left + scrollLeft - clientLeft
	return {
		top : Math.round(top),
		left : Math.round(left)
	}
}

function getOffset(elem) {
	if (elem.getBoundingClientRect) {
		// "правильный" вариант

		return getOffsetRect(elem)
		alert(top);
	} else {
		// пусть работает хоть как-то
		return getOffsetSum(elem)
	}
}
function show_stat(id, name, cat, name_rus) {
    if (document.getElementById("stat_block").style.visibility == "hidden") {
//        document.location.hash = 'frameStat';
        document.getElementById("stat_block").style.top = (getOffset(id).top - 500)
                + "px";
        document.getElementById("stat_block").style.left = (getOffset(id).left - 600)
                + "px";
        document.getElementById("stat_block").style.visibility = "visible";
        
        document.getElementById("stat_iframe").setAttribute(
                "src",
                "/base/other/statistic/statistic2.php?name_eng=" + name
                        + "&cat=" + cat + "&name_rus=" + name_rus);
    } else {
        document.getElementById("stat_block").style.visibility = "hidden";
        
        document.getElementById("stat_iframe").setAttribute("src", "");
    }
}

function anyNull() {
	document.podbor.sauna_any.checked = false;
	/* document.podbor.sauna_change.value=1; */
}
function allNull() {// alert('1');
	document.podbor.sauna_fin.checked = false;
	document.podbor.sauna_tur.checked = false;
	document.podbor.sauna_rus.checked = false;
	document.podbor.sauna_infr.checked = false;
	/* document.podbor.sauna_change.value=0; */
}
function dopNull() {
	document.podbor.bass.checked = false;
	document.podbor.bill.checked = false;
	/* document.podbor.dop_change.value=0; */
}
function alldopNull() {
	document.podbor.dop_any.checked = false;
	/* document.podbor.dop_change.value=1; */
}
function showBlue(thisA) {
	if (thisA.style.backgroundColor != '#F0F8FA')
		thisA.style.backgroundColor = '#F0F8FA';
}
function hide_showBlue(thisA, bg) {
	if (bg == 0)
		thisA.style.backgroundColor = '#FFFFFF';
	else
		thisA.style.backgroundColor = "#F9EBC8";
}
function otzivBlock() {
	document.write('<iframe height="385" frameborder="0" width="713" scrolling="no" src="http://reformal.ru/wdg4.php?w=713&amp;h=460&amp;domain=panorama66&amp;bcolor=FFFFFF&amp;glcolor=3abecd&amp;cmline=E0E0E0&amp;vcolor=9FCE54&amp;tcolor_aw4=3F4543" id="thrwdgfr">Frame error</iframe>');

}
function mU(id, mode) {
	/* id.style.textDecoration= mode ? "underline" : "none"; */
	id.style.color = mode ? "#ffffff" : "#eaff38";
}
function und(id) {
	id.style.textDecoration = "underline";
	// alert(id.style.textDecoration);
}
function undn(id) {
	id.style.textDecoration = "none";
	// alert(id.style.textDecoration);
}
function searchStart() {
	if (document.getElementById("search"))
		document.getElementById("search").value = "1";
	document.getElementById("podbor").submit();
	// podbor.submit();
}
function showBlockPhone(id, div, name_eng, cat_name) {
	document.getElementById(id).style.display = "block";
	div.style.display = "none";
	document.getElementById("iframeHidden").src = "/page/frame/update.php?name_eng="
			+ name_eng + "&cat_name=" + cat_name;
}
function showObjectPhone(id, name_eng, cat_name) {
	document.getElementById(id).style.display = "block";
	document.getElementById("objectShowPhone").style.display = "none";
	document.getElementById("iframeHidden").src = "/page/frame/update.php?name_eng="
			+ name_eng + "&cat_name=" + cat_name;
}
//function timer(time, serial) {//для статистики	
//	window.onscroll = function(){window.onscroll = null;scroller(serial)};
//	document.getElementById("iframeHidden").src = "/page/frame/update.php?time="+time+"&serial="+serial;
//}
//function scroller(serial) {//для статистики
//	document.getElementById("iframeHidden").src = "/page/frame/update.php?scroll=1&serial="+serial;
//}


function showBlock(id) {	
	if(document.getElementById("saunsblock"+id).style.display != "block") {		
		document.getElementById("saunsblockPic"+id).setAttribute("src", "/pic/tree_minus.gif");
		document.getElementById("saunsblock"+id).style.display = "block";
	} else {
		document.getElementById("saunsblockPic"+id).setAttribute("src", "/pic/tree_plus.gif");
		document.getElementById("saunsblock"+id).style.display = "none";
	}
}
