//----------------------------------------------------
var name="";
var mX,mY =0; var movem2=1;
var topmenu;
//topmenu { 1-homepage 2-inner}
function show_m2(event,topmenu){
	if(!event)event=window.event;
	mX = event.clientX;
	mY = event.clientY;
	var w=document.body.clientWidth;
	if((mY>200)||(w-mX>300)){
		hide('m2'); hide('topmenu'+topmenu);
	}
}
//-----------------------------------------------------
function show_zoom(event){
	if(!event)event=window.event;
 	if (event.pageX || event.pageY) {
		mX = event.pageX;
		mY = event.pageY;
  	}
 	else if (event.clientX || event.clientY) {
		mX = event.clientX + document.body.scrollLeft;
		mY = event.clientY + document.body.scrollTop;
    }
	document.images['zoom_in'].style.left=mX+'px';
	document.images['zoom_in'].style.top=mY+20+'px';
}

//------------------------------------------------------
function show(name) {
	document.getElementById(name).style.display="block";
}
function hide(name) {
	document.getElementById(name).style.display="none";
}
function change(name){
 exchange2('w_ball'); exchange2('o_ball');
 change2(name);
}
function exchange(name){
 change2('w_ball'); change2('o_ball');
 exchange2(name);
}
function change2(name){
	document.images[name].src=document.images[name].src.replace('p.gif','a.gif');
}
function exchange2(name){
	document.images[name].src=document.images[name].src.replace('a.gif','p.gif');
}

//---------dmenu-----------------------------------------

var menu='dm'; //vspomog perem dla dmenu
var flag=0; //only for o_ball, if flag==0 to dmenu casper
var nomove=0;
//var kol_dm=7;
var vis_dmenu=2; //visible dmenu;
var br2=0; //
var j='';
var white_flag; //=)
//var name2="";

function move(name) {
	show('ws_'+name);
	j = name.replace(/dm/i,'');
	j = Number(j); //j-0;
	new_spisok(j);
//	for(i=0; i<kol_dm; i++){                         //kol_dm - kol-vo dmenu
//		show_m('dm'+i); //show dm0...dm5
//	}
	var a=document.getElementById(name);
	var b=document.getElementById('dmenu');
//	new_spisok();
	if(vis_dmenu==0){

		menu='dm';	//poboroli gluk sdviga vlevo
	}
	vis_dmenu=1;
//	if(menu==name){
//		flag=0;
//	}
//	else{
		menu=name;
		var a=document.getElementById(name);
		var b=document.getElementById('dmenu');
		b.style.left=a.offsetLeft + 3;
		for(i=0; i<kol_dm; i++){                         //kol_dm - kol-vo dmenu
			show_m('dm'+i); //show dm0...dm5
			}
			//alert(kol_dm);
		hide_m(menu); //hide dmX
		b.style.display="block"; flag=1;
//	}
}
function hide2(){
	if(flag==0){
		show_m(menu); //menu - global
		hide('dmenu');
	}
}
function hide_dmenu(){ //if flag=0 то скрывать.
	setTimeout("hide2()",200); //------------------------------------------
//	setTimeout("show(menu)",50);
}
function hide_dmenu2(){
	setTimeout("hide2()",50);
}

function hide3(){
	//show_m(menu);
	setTimeout("hide2()",200); //скрытие если покинули хлебные крошки
}
function hide_m(menu){
//	if(document.images[menu])
// 	document.getElementById(menu).src='/i/blank.gif';
	show('ws_'+menu);

}
function show_m(menu){
	//if(document.images[menu])
	//document.getElementById(menu).src='/i/arrowright_s.gif';
	hide('ws_'+menu);
}


function new_spisok(j){
var a1="";
for(i=0;i<mas[j].length;i++) //
	a1 = a1 +'<a href="'+mas[j][i][1]+'">'+'<p>'+mas[j][i][0]+'</p>'+'</a>';
document.getElementById('spisok').innerHTML = a1;
}
//---------------------------------------------------------------------------------------------------------------------
//new blick for :--------------------------------------O O O-----------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------

function change3(name){
	exchange2('w_ball'); exchange2('o_ball'); exchange2('g_ball');
	change2(name);
}

//использовать при событии онМоуОвер, показывает шарики и заголовк и прячет Хлебные крошки если эт оне активный раздел
function blick(ball1,ball2,ball3,ball4,active){  //ф-я красит шарики.  её надо ставить в онлоад с нужными параметрами

	if(ball1==1) {
		if(active!=1) hide('bred');
		else show('bred');
		change3('w_ball');
		hide('d_poli'); hide('q_poli'); show('work'); hide('m_poli');
	}
	if(ball2==1) {
		if(active!=2) hide('bred');
		else show('bred');
		change3('g_ball');
		hide('work'); hide('q_poli'); show('d_poli'); hide('m_poli');
	}
	if(ball3==1) {
		if(active!=3) hide('bred');
		else show('bred');
		change3('o_ball');
		hide('work'); hide('d_poli'); show('q_poli'); hide('m_poli');
	}
	if(ball4==1) {
		if(active!=4) hide('bred');
		else show('bred');
		change3('m_ball');
		hide('work'); hide('d_poli'); hide('q_poli'); show('m_poli');
	}

}

//active - сейчас активный шарик(раздела в котором мы находимся)
//использовать при событии онМаусАут, и всё возвращается на круги своя...
function active_ball2(active){ //1,2,3
	if(fl_ball==0){
	if(active==1) blick(1,0,0);
	if(active==2) blick(0,1,0);
	if(active==3) blick(0,0,1);
	if(active==4) blick(0,0,0,1);
	show('bred');
	}
}

function active_ball(active){ //1,2,3
	fl_ball=0;
	setTimeout("active_ball2(active)", 150);
}

//---------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------

var out_map = 0; //out map
var br=0; //break

//over o_ball
function over_ball(name,_br) {
	br2=1;
	hide('d_poli'); hide('q_poli'); hide('work');
	if(_br==1)br=_br;//_br=1
	out_map = 1; //flag in map
	if(name=='q_poli')change('o_ball');
	if(name=='work')change('w_ball');
	exchange2('g_ball');
	show(name);
	hide('dmenu');
	hide('bred');
}
//out o_ball
var put_ball_status=0;
function out_ball(name,br,br2) {
//	if(put_ball_status==1) return false; //break
	out_map = 0; //flag out map
	if(br!=1){
		if(br2!=1){
			if(name=='q_poli')exchange('o_ball');
			if(name=='work')exchange('w_ball');
			change('g_ball');
			hide(name);
			show('d_poli');
			if(flag==1) show('dmenu'); //если флаг =1 показываем dmenu
			show('bred');
		}
	}
	br=0;
	br2=0;
}
//br2 - if 1 zna4it my uspeli za 150 ms navesti na W ili O
//br1 - if 1 to zna4it my uspeli navesti za 150 ms na Tekst
function out_ball2(name,br) {
	//	name='q_poli';
		out_map = 0; //flag out map
		if(br!=1){
			hide(name);
			if(name=='q_poli')exchange('o_ball');
			if(name=='work')exchange('w_ball');
			if(br2!=1){ //if my ne naveli na W ili O bystree 150ms
			change('g_ball');
			hide('q_poli'); hide('work'); show('d_poli');
			if(flag==1) show('dmenu');
			show('bred');
			}
		}
		br2=0;
}
//out o_ball
function out_ball3() {
	br=0;
	br2=0;
	setTimeout("out_ball2('q_poli',br,br2)", 150);
	}
//out w_ball
function out_ball4() {
	br=0;
	br2=0;
	setTimeout("out_ball2('work',br,br2)", 150);
}
//out q_poli
function out_ball5() {
	br=0;
	br2=0;
	setTimeout("out_ball('q_poli',br,br2)", 150);
	}
//out work
function out_ball6() {
	br=0;
	br2=0;
	setTimeout("out_ball('work',br,br2)", 150);
}


//---------------ZOOM-------------------
//small image tol'ko gif ili jpg!!!

mas_img_rash = new Array();
mas_img_rash[0]  = 0;
mas_img_rash[1]  = 0; //0 - gif || jpg
mas_img_rash[2]  = 1; //1 - png
var kol_img = mas_img_rash.length;
var name2='';

function ramka(name){
	var img_left = document.images[name].offsetLeft; //img1
	document.images['ramochka'].style.left=img_left-19+'px';
}
	//30px sverhu - otstup.
function loading(){
	var loading_img = document.images['z_img'];
	loading_img.src = '/i/loading.gif';
	loading_img.style.width="250px";
	loading_img.style.height="45px";
	var h=400;
	var h=h/2-50;
	loading_img.style.margin=h+'px '+'0px '+h+'px '+'362px';
}

//var i=0;
//mas_img = new Array();
//mas_img[0] = new Array();
//mas_img[0][0]  = new Array (3008,1768,'/p/portfolio/bigtst.jpg');
//mas_img[0][1]  = new Array (1280,500,'/p/portfolio/test_gor.jpg');
//mas_img[0][2]  = new Array (2824,1996,'/p/portfolio/dsc_3665.jpg');
//mas_img[0][3]  = new Array (700,522,'/p/portfolio/testn.jpg');
//mas_img[0][4]  = new Array (1000,1000,'/p/portfolio/test_2x1000.jpg');
//var big_image=mas_img[0][i][2];

function zoom(name){
	document.getElementById('z_img').style.visibility='hidden';// visibility:hidden
	var a = document.images['z_img'];
	a.src='/i/blank.gif';
	show('loading_img');
	name2=name;
	ramka(name);
//	var a = document.images['z_img'];
	var c = document.images['z_frame_bg'];
	i = name.replace('img','');
	i=Number(i)-1; //i--;

	document.images['help'].src = mas_img[0][i][2];
	a.style.width = mas_img[0][i][0]*1+'px';
	a.style.height = mas_img[0][i][1]*1+'px';
	var b = (980-mas_img[0][i][0])/2-3;
	a.style.marginLeft=b+'px';
	var d = 39+mas_img[0][i][1]*1;
	c.style.height=d*1+'px';
	if(navigator.appName.indexOf("Explorer")!=-1)document.getElementById('z_frame').style.height=mas_img[0][i][1]+'px';
	if(mas_img[0][i][0]<900){
		a.style.marginTop='5px'; //+5
		c.style.height = d*1 + 25 + 'px'; //+5
		a.style.marginBottom = '0px';
		if(mas_img[0][i][1]<338){
			c.style.height = '413px'; //458-> 408 ->413
			a.style.marginTop =	(338-mas_img[0][i][1]*1)/2 +5+'px';  //min-razmer 388 stal 338 + 15
			a.style.marginBottom = (338-mas_img[0][i][1]*1)/2 + 11 + 'px'; //-58px +1px
		}
	}
	else{
		a.style.marginTop=-31+'px';
		a.style.marginBottom = 0 + 'px';
		c.style.height=d*1-11+'px';
	}
	if(i==kol_img-1)document.getElementById('z_img').style.cursor='default';
	else document.getElementById('z_img').style.cursor='pointer';
	document.getElementById('z_img').style.visibility='visible';
}


function zoom2(number_pic){
		document.getElementById('z_img').style.visibility='hidden';// visibility:hidden
//	hide('z_img');//new
	name2='img'+number_pic;
	number_pic=Number(number_pic)-1;
	big_image=mas_img[0][number_pic][2];
	var a = document.images['z_img'];
	a.src='/i/blank.gif';
	show('loading_img');


//	ramka('img1');top:-6px; left:-7px; /left:-19px;
 //img1
		if(navigator.appName.indexOf("Explorer")!=-1)document.images['ramochka'].style.left=document.images['img1'].offsetLeft-19+'px';
		else document.images['ramochka'].style.left=document.images['img1'].offsetLeft-7+'px';
	show('z_wrap');
//	alert(1);
//	document.images['z_img'].style.height="368px";
//	show('loading_img');//alert(1);
//	hide('z_img');
//	var a = document.images['z_img'];
	var c = document.images['z_frame_bg'];
//	if(mas_img_rash[0]==1){ //proverka na sushetvovanue b.png
//	var s_img = document.images['img1'].src.replace('s.jpg','b.png').replace('s.gif','b.png');
//	}
//	else{
//	var s_img = document.images['img1'].src.replace('s.jpg','b.jpg').replace('s.gif','b.gif');
//	}
	//alert (mas_img);
	a.src = mas_img[0][number_pic][2];
//	a.src = s_img;
	a.style.width = mas_img[0][number_pic][0]+'px';
	a.style.height = mas_img[0][number_pic][1]+'px';
	var b = (980-mas_img[0][number_pic][0])/2-3;
	a.style.marginLeft = b + 'px';
	var d = 39+mas_img[0][number_pic][1];
	c.style.height=d+'px';
	if(navigator.appName.indexOf("Explorer")!=-1)document.getElementById('z_frame').style.height=mas_img[0][number_pic][1]+'px';
	if(mas_img[0][number_pic][0]<900){
		a.style.marginTop='5px';
		c.style.height = d + 25 + 'px';
		a.style.marginBottom = '0px';
		if(mas_img[0][number_pic][1]<338){
			c.style.height = '413px';
			a.style.marginTop =	(338-mas_img[0][number_pic][1])/2 + 5 + 'px';
			a.style.marginBottom = (338-mas_img[0][number_pic][1])/2 + 11 + 'px';
		}
	}
	else{
		a.style.marginTop= '-31px';
		a.style.marginBottom = '0px';
		c.style.height=d-11+'px';
	}
	hide('loading_img');
	document.getElementById('z_img').style.visibility='visible';
	ramka(name2);
}

function next(){
	var i =  name2.replace('img','');
	//i--;i=i+2;
	i=Number(i)+1;
	if(i<=kol_img){
		loading();
		name2 = 'img'+i;
		zoom(name2);
		//document.getElementById('z_img').style.visibility='visible';
	}
}

//----------ZOOM-END-------------

//-------quetion--form---------

//--------INNER_WORK_LIST-------------

var cat; var kat; var flag_info=0; var active_sub='sub0'; var active_sub1='sub0';
var bg_sub='url(/i/leftmenu_border.gif) no-repeat -2px -4px';

//var m_cat_lenght = m_cat.length;
//korotkoe nazvanie, dlinnoe nazvanie, nazvanie proekta, razmery, ssylka.
function move2(name){
//	document.getElementById(active_sub).style.background="none"; //ove5aet za podsvetku activnogo sub-a pri peremeshenii
	document.getElementById(name).style.background=bg_sub;
}

function move2_out(name){
	document.getElementById(name).style.background="none";
//	alert(active_sub);
/*	for(i=0;i<m_cat.length;i++)
	{
		if (document.getElementById('sub'+i)!=undefined);
		{
			alert ("OK");
			if (document.getElementById('sub'+i) != 'null')
			{
				document.getElementById('sub'+i).style.background="none";
			}
		}
	}*/
	document.getElementById(active_sub).style.background=bg_sub;
}

function move_sp_out(name){
	document.getElementById(name).style.background="none";
//	alert(active_sub);
//	for(i=0;i<m_cat.length;i++)
//	document.getElementById('sub'+i).style.background="none";
	document.getElementById(active_sub1).style.background=bg_sub;
}

function show_all_cat(){
	for(i=1;i<m_cat.length+1;i++){cat='cat'+i;  kat='kat'+i; show(cat); show(kat);} //m_cat.length=2
	document.getElementById(active_sub).style.background="none";
	document.getElementById(active_sub).style.fontWeight='normal';
	active_sub='sub0';
	document.getElementById(active_sub).style.fontWeight='bold';
	document.getElementById(active_sub).style.background=bg_sub;
}

function show_cat(name){
	document.getElementById(active_sub).style.fontWeight='normal';
	document.getElementById(active_sub).style.background="none";
	active_sub = name.replace('cat','sub');
	document.getElementById(active_sub).style.fontWeight='bold';
	document.getElementById(active_sub).style.background=bg_sub;
	var k_name=name.replace('c','k');
	for(i=1;i<m_cat.length+1;i++){cat='cat'+i; kat='kat'+i; hide(cat); hide(kat);}
	show(name); show(k_name);
}

function switch_cat(name){
	document.getElementById('kartinkami').style.fontWeight='normal';
	document.getElementById('spiskami').style.fontWeight='normal';
	document.getElementById(name).style.fontWeight='bold';
}

var i1; var i2;
var i3=0; var i4=0;

//*************************************************************************
//<p><b>Авто Поинт</b> Дисконтная карта</p>
function write_list_catalog(){
	if (typeof(document.getElementById('list_catalog')) == 'undefined') return false;

	if (document.getElementById('list_catalog') == null) return false;

	var list_catalogElement=document.getElementById('list_catalog');
	if(list_catalogElement.hasChildNodes()){
		i3=0;
		for (i1=0; i1<list_catalogElement.childNodes.length; i1++) {
          	var currentNode = list_catalogElement.childNodes[i1];
         	if (currentNode.nodeName.toLowerCase() == "div") {
				i3++;
            //		currentNode.innerHTML='yes!!!';//nodeValue
				if(currentNode.hasChildNodes()){ //potomki cat1, cat2 i t.d.
					for (i2=0; i2<currentNode.childNodes.length; i2++) {
					var currentNode2 = currentNode.childNodes[i2];
						if (currentNode2.nodeName.toLowerCase() == "div"){
							currentNode2.innerHTML='';
							for(i4=1;i4<m_cat[i3-1].length+1; i4++)
							currentNode2.innerHTML=currentNode2.innerHTML+'<a href="'+m_cat[i3-1][i4-1][4]+'"><p><b>'+m_cat[i3-1][i4-1][1]+'</b> '+m_cat[i3-1][i4-1][2]+'</p></a>';
						}
					}
				}
          	}
       }
	}
}
//*************************************************************************


function show_info(name){ //vychisl'aem coordinaty kartinki
	var catx_y = name; //berem id = catx_x
	catx = catx_y.replace(/cat(.+)_.+/i,'$1'); //nomer cataloga (ot 1)
	caty = catx_y.replace(/cat.+_(.+)/i,'$1'); //nomer kartinki (ot 1)
//	alert(catx);alert(caty); alert(m_cat[catx-1][caty-1]);
	var href='<a href="'+m_cat[catx-1][caty-1][4]+'">';
	document.getElementById('cat_info_inner').innerHTML=''+href+'<p><b>'+m_cat[catx-1][caty-1][0]+'</b></p></a>'+href+'<p>'+m_cat[catx-1][caty-1][2]+'</p></a>'+href+'<p>'+m_cat[catx-1][caty-1][3]+'</p></a>'+href+'<div style="width:16px; height:20px;" id="info_arrow"></div></a>';

	var _left = document.getElementById(name).offsetLeft;
	var _top = document.getElementById(name).offsetTop;
	var _width = document.getElementById(name).width;
	var _height = document.getElementById(name).height;
	document.getElementById('cat_info').style.left = _left +  + _width * 0.5 + 10 + 290 + 'px';
	document.getElementById('cat_info').style.top = _top + _height * 0.5 + 270 + 'px';
	show('cat_info');
}

function hide2_info(){
	if(flag_info==0)
	hide('cat_info');
}

function hide_info(){
	flag_info=0;	//if flag=0 то скрывать.
	setTimeout("hide2_info()",50);
}


//ф-ия клика по кнопкам
function chk(form,what,mod)
{
	//------------------------------
	//разбиваем строчку на значения которые нам нужно получить
	//arr[0] = privView 	//идентификатор колоники чекбоксов
	//arr[1] = 193 		//id раздела из sitedir
	//arr[2] = 1			//pid раздела из sitedir
	//-------------------------------
	var this_arr = what.split("-");

	var all_arr = new Array();
	var tmp_arr;

	//пробегаемся циклом по всем элиментам формы, собираем массив с которым будем работать
	var p = 0;
	for ( i=0; i < form.elements.length; i++ )
	{

		//наличие у элимента параметра id
		if (form.elements[i].id)
		{

			var tmp_arr = form.elements[i].id.split("-");

			//если нужная нам колонка checkbox-ов
			if (tmp_arr[0] == this_arr[0])
			{

				all_arr[tmp_arr[1]] = [tmp_arr[2]];
				p++;

			}//if (tmp_arr[0] == this_arr[0])

		}//if (form.elements[i].id)

	}//for ( i=0; i < form.elements.lenght; i++ )

	//запускаем чекалку
	if (document.getElementById(what).checked)
	{
		//alert (document.getElementById('tr-'+this_arr[1]).style);
		price = price+Number(scarr[this_arr[1]][2]);
		if (mod) document.getElementById('tr-'+this_arr[1]).className = 'selected_last';
		else document.getElementById('tr-'+this_arr[1]).className = 'selected';
		checKids(this_arr[1],this_arr[0],all_arr,true,mod);//ставим
	}
	else {
		price = price-Number(scarr[this_arr[1]][2]);
		if (mod) document.getElementById('tr-'+this_arr[1]).className = 'last_calc';
		else document.getElementById('tr-'+this_arr[1]).className = '';
		checKids(this_arr[1],this_arr[0],all_arr,false,mod);//снимаем
	}

//	document.getElementById('price').innerHTML = 	"Цена: " + price + " руб";

	if (price > 0) document.getElementById('calc_order_form').style.display="block";
	else document.getElementById('calc_order_form').style.display="none";
	var priceEX = 	showCalcCost(numberFormat(price),true);
	document.getElementById('price').innerHTML = priceEX;

}//function chk(what)

//===========================
//ВНИМАНИЕ: ДЛЯ КОРРЕКТНОЙ РАБОТЫ Ф-ИИ checKids()
//НЕОБХОДИМО ОБЪЯВИТЬ ГЛОБАЛЬНУЮ ПЕРЕМЕННУЮ price
//===========================
var price = 0;

//===========================
//ВНИМАНИЕ: ДЛЯ КОРРЕКТНОЙ РАБОТЫ Ф-ИИ checKids()
//НЕОБХОДИМО ОБЪЯВИТЬ ГЛОБАЛЬНЫЙ МАССИВ recurs_bug
//===========================
var recurs_bug = 	new Array();

//ф-ия ставит или снимает галочки на всех потомках элимента

function checKids(ths,pref,arr,mod,mmd)
{

	//снимаем или ставим галочки
	if (mod)//ставим
	{
		//if(ie) document.all(pref+'-'+ths+'-'+arr[ths]).checked = true;//ставим
		//else

		//price = 	price+Number(scarr[ths][2]);

		if(document.getElementById)
		{
			if (document.getElementById(pref+'-'+ths+'-'+arr[ths]).checked == false)
			{
				price = 	price+Number(scarr[ths][2]);
			}//if (document.getElementById(pref+'-'+ths+'-'+arr[ths]).checked != true)
			document.getElementById(pref+'-'+ths+'-'+arr[ths]).checked = true;//ставим
		}//if(document.getElementById)
		else {
			if (document.all(pref+'-'+ths+'-'+arr[ths]).checked == false)
			{
				price = 	price+Number(scarr[ths][2]);
			}//if (document.all(pref+'-'+ths+'-'+arr[ths]).checked == false)
			document.all(pref+'-'+ths+'-'+arr[ths]).checked = true;//ставим
		}//else {

		//document.getElementById('tr-'+ths).style.class = 'select';

		if (mmd) document.getElementById('tr-'+ths).className = 'selected_last';
		else document.getElementById('tr-'+ths).className = 'selected';

		if (arr[ths] > 0) checKids(arr[ths],pref,arr,mod);//запускаем рекурсию

	}//if (mod)//ставим
	else {//снимаем

		//пробегаемся по массиву
		for ( recurs_bug[ths]=0; recurs_bug[ths] < arr.length; recurs_bug[ths]++)
		{

			//элимент подходит
			if (arr[recurs_bug[ths]] == ths)
			{
			//	if(ie)

				if(document.getElementById)
				{
					if (document.getElementById(pref+'-'+recurs_bug[ths]+'-'+arr[recurs_bug[ths]]).checked == true)
					{
						price = price-Number(scarr[recurs_bug[ths]][2]);
						if (mmd) document.getElementById('tr-'+recurs_bug[ths]).className = 'last_calc';
						else document.getElementById('tr-'+recurs_bug[ths]).className = '';
					}//if (document.getElementById(pref+'-'+recurs_bug[ths]+'-'+arr[recurs_bug[ths]]).checked == true)
					document.getElementById(pref+'-'+recurs_bug[ths]+'-'+arr[recurs_bug[ths]]).checked = false;//убираем галочку

				}//if(document.getElementById)
				else
				{
					if (document.all(pref+'-'+recurs_bug[ths]+'-'+arr[recurs_bug[ths]]).checked == true )
					{
						//alert (price);
						price = price-Number(scarr[recurs_bug[ths]][2]);
						//alert (price);
						document.getElementById('tr-'+recurs_bug[ths]).className = '';
					}//if (document.all(pref+'-'+recurs_bug[ths]+'-'+arr[recurs_bug[ths]]).checked == true )
					document.all(pref+'-'+recurs_bug[ths]+'-'+arr[recurs_bug[ths]]).checked = false;//убираем галочку

				}//else

				checKids(recurs_bug[ths],pref,arr,mod);//запускаем рекурсию по этому элименту

			}//if (all[i] == ths)


		}//for ( i=0; i < all.length; i++)

	}//else {//снимаем

return true;

}
//function checKids(ths,all,mod)


var flash = 	true;

//show cost in calc
function showCalcCost(cost,mod) {
	if (flash) {
		var flsh = showCostFlash (cost);
		if (mod) return flsh;
		else document.writeln(flsh);
		}
	else {
		var nonflash = '<div id=cost>' + cost + '</div>';
		if (mod) return nonflash;
		return document.writeln(nonflash);
	}
}


//show cost flash
function showCostFlash (cost) {
	coststr = 'cost=' + cost;
	return showFlash ('cost', 120, 25, coststr);
}

//standard func for showing flash
function showFlash (file, w, h, param) {
	var flashrep='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + w + '" height="' + h + '" id="" align="right"><param name="allowScriptAccess" value="sameDomain" /><param name="scale" value="noscale" /><param name="salign" value="lt" /><param name="flashvars" value="' + param + '" /><param name="movie" value="/swf/' + file + '.swf" /><param name="quality" value="high" /><PARAM NAME=wmode VALUE=transparent><embed src="/swf/' + file + '.swf" quality="high" scale="noscale" wmode=transparent  width="' + w + '" height="' + h + '" flashvars="' + param + '" name="" align="middle" salign="lt" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	return flashrep;
}

//открывает и скрывает элимент id которого передан
function open_descr(id)
{
	if (document.getElementById(id).style.display == 'block') document.getElementById(id).style.display = 'none';
	else document.getElementById(id).style.display = 'block';
}//function open_descr(id)

function close_descr(id)
{
	id.style.display = 'none';
}//function close_descr(id)

function numberFormat(num)
{
	var res = '';
	var ot;
	var doo;
	var copy = 	String(num);
	for(i=0;i<copy.length;i=i+3)
	{
		ot = 	copy.length-i;
		doo = 	ot-3;
		res = 	' ' + copy.substring(ot,doo) + res;
		//alert (copy.substring(4,3));
	}//for(i=1;i<pc;i++)
	return (res);
}//function numberFormat(num)

function changestyle(id,mod)
{
	switch (mod)
	{
		case "under":
			id.style.textDecoration = 	'underline';
		break;
		case "nounder":
			id.style.textDecoration = 	'none';
		break;
		case "black":
			id.style.color = '#000';
		break;
		case "555":
			id.style.color = '#555';
		break;
	}//case (mod)
}//function changestyle(id,mod)


//отправка формы предварительного заказа
function send_order()
{

	var error = "";

	if (typeof(document.getElementById('calcord')) != "object")
	{
		error = "Error: Form not found";
	}//if (typeof(document.getElementById(calc_order_form)) != "object")
	else {
		//проверка имени
		if (document.getElementById('calc_name').length == 0 || document.getElementById('calc_name').value == 'Ваше имя')
		{
			error = 	"Заполнены не все поля формы";
		}//if (document.getElementById('calc_name').len

		//проверка компании
		if (document.getElementById('calc_comp').length = 0 || document.getElementById('calc_comp').value == 'Название компании')
		{
			error = 	"Заполнены не все поля формы";
		}//if (document.getElementById('calc_name').lenа

		//проверка e-mail адреса или телефона
		if (document.getElementById('calc_email').length = 0 || document.getElementById('calc_email').value == 'Ваш e-mail или телефон')
		{
			error = 	"Заполнены не все поля формы";
		}//if (document.getElementById('calc_name').lenа
	}//else {

	//проверка на наличие ошибок
	if (error.length)
	{
		alert (error);
		return false;
	}//if (error.length)
	else {
		document.getElementById('calcord').submit();
		return true;
	}//else {

}//function send_order()

//seo
function seoformsubmit(id)
{
	document.getElementById('srh').value = 	id;
	document.getElementById('seoform').submit();
}

//показ портфолио
function show_portpolio(dir_id)
{

	show_portfolio_menu(dir_id);

	show_portfilio_content();

}//show_portpolio()

//показ меню
function show_portfolio_menu(selected)
{

	var menu = 	"";//сборка меню
	var select = 	' style="font-weight:bold; background:url(/i/leftmenu_border.gif) no-repeat -2px -4px;"';//выбранный пункт
	var selected_in_array = false;//переключатель, находиться ли выбранный объект в массиве, если нет - все
	var now_style = "";//нынешний стиль любого элимента, для подмены

	//alert (typeof('window.sp_js_menu'));

	//проверяем на наличие массив
	if (typeof('window.sp_js_menu') != 'undefined')
	{

		//alert ("OK");

		//проверяем на наличие нужного нам дива
		if (typeof(document.getElementById('leftmenu')) != 'undefined')
		{

			//поскакали по циклу
			for(i=0;i<sp_js_menu.length;i++)
			{

				now_style = "";

				if (sp_js_menu[i][0] == selected)
				{
					selected_in_array = 	true;
					now_menu_selected = 	selected;
					now_style = 			select;
				}

				menu = 	menu+'<p id="sub'+sp_js_menu[i][0]+'" onMouseDown="show_portfilio_content('+sp_js_menu[i][0]+')" onMouseOver="show_port_over_menu('+sp_js_menu[i][0]+');" onMouseOut="show_port_out_menu('+sp_js_menu[i][0]+');"'+now_style+'>'+sp_js_menu[i][1]+'</p>';

			}//for(i=0;i<sp_js_menu.length;i++)


			now_style = "";

			if (selected_in_array == false)
			{
				now_menu_selected = 	0;
				now_style = 			select;
			}

			menu = 	'<p id="sub0" onMouseDown="show_portfilio_content(0);" onMouseOver="show_port_over_menu(0);" onMouseOut="show_port_out_menu(0);" '+now_style+'>Все</p>'+menu;


			document.getElementById('leftmenu').innerHTML = menu;

		}//if (typeof(document.getElementById('leftmenu')) != 'undefined')

	}//if (typeof(eval('window.' + field)) == 'object')

}//function show_portfolio_menu()

//показ портфолио с разделами
function show_portfilio_content(selected)
{




	var selected_in_array = false;//переключатель, находиться ли выбранный объект в массиве, если нет - все
	var content = 			""; // переменная куда будет происходить сборка

	if (typeof('window.sp_js_menu') != 'undefined' && typeof('window.jscnt') != 'undefined')
	{

		//начальная пробежка по массиву, на предмет элимента, либо показываем все
		for(i=0;i<sp_js_menu.length;i++)
		{

			if (sp_js_menu[i][0] == selected)
			{
				selected_in_array = 	true;
			}

		}//for(i=0;i<sp_js_menu.length;i++)

		//выделение
		if (selected_in_array)
		{

			selected_this_menu_part(selected);

		}//if (selected_in_array)
		else {

			selected_this_menu_part(0);

		}//else {

		//начинаем основную сборку
		for(j=0;j<sp_js_menu.length;j++)
		{

			if ( (selected_in_array == true && sp_js_menu[j][0] == selected) || (selected_in_array == false) )
			{

				content = 	content+'<div class="h2_hidden" id="cat'+sp_js_menu[j][0]+'"><img class="img_header" src="/i/h_'+sp_js_menu[j][3]+'.gif" alt="'+sp_js_menu[j][2]+'" onMouseDown="show_portfilio_content('+sp_js_menu[j][0]+');" /><h2 onMouseDown="show_portfilio_content('+sp_js_menu[j][0]+');">'+sp_js_menu[j][2]+'</h2><div><div class="clearing"></div>';


				content = 	content+show_portfolio_images(sp_js_menu[j][0])+'</div></div>';

			}

		}//for(i=0;i<sp_js_menu.length;i++)

//<a href="/polygraphy/logo/logo/id205/"><img id="cat1_1" onMouseOver="flag_info=1; show_info('cat1_1');" onMouseOut="hide_info();" class="img_first" src="/p/portfolio/20090128110201819.jpg" /></a>

	document.getElementById('pic_catalog').innerHTML = 	content;

	}//if (typeof('window.sp_js_menu')...

}//function show_portfilio_content()

//показ подсветки
function show_port_over_menu(id)
{

	if (now_menu_selected == id) return false;

	document.getElementById('sub'+id).style.background = bg_sub;

}//function show_port_over_menu(id)

//скрытие подсветки
function show_port_out_menu(id)
{

	if (now_menu_selected == id) return false;

	document.getElementById('sub'+id).style.background = 'none';

}

//строит картинки из портфолио по id
function show_portfolio_images(id)
{

var res = 	'';
var dop_class = '';

	if (typeof('window.jscnt') != 'undefined')
	{

		for(i=0;i<jscnt.length;i++)
		{

			if (jscnt[i][1] == id)
			{

				dop_class = 		'';
				if (i == 0)
				{
					dop_class = 	' class="img_first"';
				}

				res = 	res+'<a onClick="show_this_photo('+i+')"><img id="cat_'+jscnt[i][0]+'" '+dop_class+' src="'+jscnt[i][6]+'" /></a>';

			}

		}//for(i=0;i<sp_js_menu.length;i++)

	}//if (typeof('window.jscnt') != 'undefined')

return res;

}//function show_portfolio_images()

//ф-ия выделения раздела меню на который нажали
function selected_this_menu_part(selected)
{

	document.getElementById('sub'+now_menu_selected).style.background="none";
	document.getElementById('sub'+now_menu_selected).style.fontWeight='normal';
	now_menu_selected = 	selected;
	document.getElementById('sub'+selected).style.fontWeight='bold';
	document.getElementById('sub'+selected).style.background=bg_sub;


}//function selected_this_menu_part()

//ф-ия показа фото
function show_this_photo(id)
{

	mas_img[0] = 	new Array();
	//var first_image = 	addprefx(jscnt[id][7][0][2]);
	var image_other;


	kol_img = 		jscnt[id][7].length;

	var res1 = 		'';

	for(i=0;i<jscnt[id][7].length;i++)
	{

		image_other = 	addprefx(jscnt[id][7][i][2]);

		if (image_other)
		{

			var j = i+1;

			mas_img[0][i] = 	new Array(jscnt[id][7][i][0],jscnt[id][7][i][1],jscnt[id][7][i][3]);

			res1 = 	res1+'<img id="img'+j+'" onClick="zoom(\'img'+j+'\');" src="'+image_other.s+'" width="50" height="50" />';

		}//if (image_other)


	}//for(i=0;i<jscnt[id][7].length;i++)

	var res = 	'<div id="z_wrap" style="display: none;"><div id="z_frame"><img id="z_close" onClick="zoom_close(\'z_wrap\');" src="/i/z_close.png" width="19" height="19" /><img id="z_frame_top" src="/i/z_frame_top.png" width="980" height="70" /><img id="z_frame_bg" style="height:466px;" src="/i/z_frame_bg.png" width="980" height="1" /><img id="z_img" onClick="next();" src="/i/loading.gif"/><img id="help" onLoad="hide(\'loading_img\'); if (typeof(document.images[\'z_img\']) != \'undefined\' && typeof(mas_img[0][i]) != \'undefined\') { document.images[\'z_img\'].src=mas_img[0][i][2]; }" src="/i/blank.gif" width="1" height="1"/><img style="display:none;" id="loading_img" src="/i/loading.gif"/><img id="hr_grey" src="/i/hr-grey.gif" width="900" height="1" /><img id="z_frame_bot" src="/i/z_frame_bot.png" width="980" height="70" /><div id="z_text"><p>'+jscnt[id][4]+'. '+jscnt[id][2]+'</p><p>'+jscnt[id][3]+'</p></div><div id="z_img-s"><img id="ramochka" src="/i/ramochka.gif" width="63" height="63" />'+res1;

	res1 = 	'';

	res = 	res+'</div></div>';

	document.getElementById('zoom').innerHTML = 	res;
	jQuery('#z_wrap').css("top",(getBodyScrollTop()+50)+"px");
	jQuery('#z_wrap').css("left",(getBodyScrollLeft()+10)+"px");
	zoom2(1);

}//function show_this_photo()

function getBodyScrollTop()
{
  return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function getBodyScrollLeft()
{
  return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
}

//ф-ия добавления префиксов
function addprefx(img)
{

	var prefix_chablon = /^(\S+)\.(\S+)$/

	var exp_array = prefix_chablon.exec(img);

	if (exp_array == null)
	{
		return false;
	}
	else {
		return {"s":exp_array[1]+'s.'+exp_array[2], "m":exp_array[1]+'m.'+exp_array[2], "f":exp_array[1]+'f.'+exp_array[2]};
	}

}//function addprefx(img)

function zoom_close(pic)
{

	document.getElementById('zoom').innerHTML = 	'';

}//function show_image_zoom(pic)