// <meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />

//учим firefox outerHTML
if (typeof(HTMLElement) != "undefined") {
    var _emptyTags = {
       "IMG": true,
       "BR": true,
       "INPUT": true,
       "META": true,
       "LINK": true,
       "PARAM": true,
       "HR": true
    };
    
    HTMLElement.prototype.__defineGetter__("outerHTML", function () {
       var attrs = this.attributes;
       var str = "<" + this.tagName;
       for (var i = 0; i < attrs.length; i++)
          str += " " + attrs[ i ].name + "=\"" + attrs[ i ].value + "\"";
    
       if (_emptyTags[this.tagName])
          return str + ">";
    
       return str + ">" + this.innerHTML + "</" + this.tagName + ">";
    });
    
    HTMLElement.prototype.__defineSetter__("outerHTML", function (sHTML) {
       var r = this.ownerDocument.createRange();
       r.setStartBefore(this);
       var df = r.createContextualFragment(sHTML);
       this.parentNode.replaceChild(df, this);
    });
}
//конец обучения



		accordion_1=false;
		accordion_11=false;

$(function() {
		onload_resize();
		locate=window.location.href;
		locate=locate.substring(7,1000);
		locate=locate.substring(locate.indexOf('/'),1000);

		while (1-$("a[href='"+locate+"']").length) {
			 locate=locate.split('/');
			 locate.length--;
			 locate=implode('/',locate);
			 if (locate.length<1) {break;}
		}
		
		if (locate.substring(0,13)=='/swimingpools'){
				$("a[href='"+locate+"']").css("color", "black");
				$("a[href='"+locate+"']").css("background-color", "#ccc");
		
				x=new Array();
				a=($("a[href='"+locate+"']").parents('div').parents('div').attr('id'));
				b=$("a[href='"+locate+"']").parents('div').attr('value');


				accordion_1=false;
				accordion_11=false;
				accordion_12=false;
				if (a=='accordion1') accordion_1=1*b;
				if (a=='accordion11') {
					accordion_11=1*b;
					accordion_1=0;
				}
				if (a=='accordion12') {
					accordion_12=1*b;
					accordion_1=0;
					accordion_11=6;
				}
		
				// Алюминиевые конструкции и натяжные потолки
				$( "#accordion0" ).accordion({collapsible: true,autoHeight:false,active: false});
				//$( "#accordion1" ).css("border","1px solid red");
				// Оборудование и почитать
				$( "#accordion1" ).accordion({collapsible: true,autoHeight:false, active: accordion_1});
				// Вложение оборудования
				$( "#accordion11" ).accordion({collapsible: true,autoHeight:false, active: accordion_11});
				//Наши возможности в алюминии
				$( "#accordion01" ).accordion({collapsible: true,autoHeight:false, active: false});
				$( "#accordion12" ).accordion({collapsible: true,autoHeight:false, active: accordion_12});

		}

		 $("#tabs").tabs();
		 $("#tabs2").tabs();


});


//=====================================================
// Функция аккордеона
// При вызове свёртует все менюшки кроме текущей
function accord(item) {
	if (document.getElementById('a_'+item).style.display=='') {
		document.getElementById('a_'+item).style.display='none';
		document.getElementById('b_'+item).className='right';
	}else{
		document.getElementById('a_'+item).style.display='';
		document.getElementById('b_'+item).className='right_sel';
	}
	var v=accord_value.split(',');
	for (f=0;f<v.length;f++ ) if (v[f]!=item)
	if (document.getElementById('a_'+v[f]).style.display==''){
		document.getElementById('a_'+v[f]).style.display='none';
		document.getElementById('b_'+v[f]).className='right';
	}
}
//=====================================================
// Функция замены всех тумбочек

function onload_resize() {
	var l=document.images.length;
	//alert(l);
	for (ff=0;ff<l ;ff++ )	{
		ii=document.images[ff];
		//alert(ii.className);
		if ((ii.className=='resize')||(ii.className=='resize2')) {
			ii.title='Кликните мышкой для увеличения';
			var new_src=str_replace('.jpeg', '.jpg', ii.src);
			new_src=str_replace('_.png', '.png', new_src)

			ii.outerHTML='<a onclick="return hs.expand(this)" href="'+new_src+'">'+ii.outerHTML+'</a>';
		} // if
	}//for f
}
//=====================================================
function str_replace(search, replace, subject) {return subject.split(search).join(replace);} 
//=====================================================
// Функция бегущая строка
var line=new Array("Натяжные потолки: до конца марта всем скидка 18% и 18лет гарантии.","Бассейны из полимера - технологии будущего");
line=line[Math.floor(Math.random()*line.length)];
var i, timer, speed=50;
//alert (line);
//var line=new Array("");



function start(){
	//x=location.href.split('/');if (x[3]==undefined) razdel='none';	else razdel=x[3];
    document.cit.forum.value="";
    i=0;
    timer = setInterval('m_line()',speed);
}


function m_line() {
	if (line==undefined) return;
    if(i++<line.length) document.cit.forum.value=line.substring(0,i);
	else{
		clearInterval(timer);
	    setTimeout('start()',5000);
    }
}

//=====================================================
// Модуль стандартной галерейки 
hs.graphicsDir = '/highslide/graphics/';

hs.loadingText = 'Загрузка. Пожалуйста, подождите...';
hs.fullExpandTitle = 'Развернуть до полного размера';
hs.restoreTitle = 'Кликните для закрытия картинки, нажмите и удерживайте для перемещения';
hs.focusTitle = 'Сфокусировать';
hs.loadingTitle = 'Нажмите для отмены';

//<![CDATA[
hs.showCredits = 0;
hs.padToMinWidth = true;

if (hs.registerOverlay) {
	hs.registerOverlay(
	    {
    		overlayId: 'controlbar',
    		position: 'top right',
    		hideOnMouseOut: true
		}
	);
	 hs.registerOverlay(
	    {
    		slideshowGroup: 'minigallery',
    		overlayId: 'controlbar',
    		position: 'top right',
    		hideOnMouseOut: true
		}
	);
}
if (hs.addEventListener) hs.addEventListener(window, 'load', function () {
		try { new hs.Outline('rounded-white'); } catch (e) {}
		try { new hs.Outline('glossy-dark'); } catch (e) {}
	}
);
//]]>




// Функции прелоада и замены картинок (взято из бьюти)
// Использование:
// <body onload="MM_preloadImages('/design/topMenu/btnIndexHover.png','/design/topMenu/btnAboutHover.png','/design/topMenu/btnProductsHover.png','/design/topMenu/btnPartnershipHover.png','/design/topMenu/btnDocumentsHover.png')">

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// аналог функици php
function implode( glue, pieces ) {return ( ( pieces instanceof Array ) ? pieces.join ( glue ) : pieces );}

