var img=Array(20);
var alpha_val=50;

function absPosition(obj)
{ 
      var x = y = 0;
      while(obj) 
	  {
            x += obj.offsetLeft;
            y += obj.offsetTop;
            obj = obj.offsetParent;
      }
      return {x:x, y:y};
}

function hv(id,h,z)
{
	if (document.getElementById(id))
	{
		var e=document.getElementById(id).style.display;
		if (h==null)
		{
		if (e=="none")
			document.getElementById(id).style.display="inline"; else document.getElementById(id).style.display="none";
		} else
		{
			if (h)
				document.getElementById(id).style.display="inline"; else
				document.getElementById(id).style.display="none";
		}

		var p=absPosition(document.getElementById("im1"));
		document.getElementById(id).style.left=p.x+"px";

		if (document.getElementById(id).style.display=="none"&&!z)
			{
				setalpha("img1",100); 
				setalpha("img2",100); 
				setalpha("img3",100); 
				setalpha("img4",100); 
				setalpha("img5",100); 
				setalpha("img6",100); 
				setalpha("img7",100); 
				setalpha("img81",100); 
				setalpha("img91",100); 
				update_el(true);
			}else
			{
				setalpha("img1",alpha_val);
				setalpha("img2",alpha_val);
				setalpha("img3",alpha_val);
				setalpha("img4",alpha_val);
				setalpha("img5",alpha_val);
				setalpha("img6",alpha_val);
				setalpha("img7",alpha_val);
				setalpha("img81",alpha_val);
				setalpha("img91",alpha_val);
				update_el(false);
			}
	}
	
	if (document.getElementById("fdate")&&!h)
		document.getElementById("fdate").style.display="none";
	if (document.getElementById("ftime")&&!h)
		document.getElementById("ftime").style.display="none";
}

function setalpha(id,p)
{
	if (document.getElementById(id))
	{

	var e=document.getElementById(id);
	e.style.filter="alpha(opacity="+p+")";
		
	}
}

function onload(q)
{
	img[0]=new Image;
	img[0].src="img/red_01.jpg";
	
	img[1]=new Image;
	img[1].src="img/red_02.jpg";
	
	img[2]=new Image;
	img[2].src="img/red_03.jpg";
	
	img[3]=new Image;
	img[3].src="img/red_04.jpg";
	
	img[4]=new Image;
	img[4].src="img/red_05.jpg";
	
	img[5]=new Image;
	img[5].src="img/red_06.jpg";
	
	img[6]=new Image;
	img[6].src="img/red_07.jpg";
	
	img[7]=new Image;
	img[7].src="img/red_08.jpg";
	
	img[8]=new Image;
	img[8].src="img/red_09.jpg";
	
	img[9]=new Image;
	img[9].src="img/red_10.jpg";
	
	img[10]=new Image;
	img[10].src="img/black_01.jpg";
	
	img[11]=new Image;
	img[11].src="img/black_02.jpg";
	
	img[12]=new Image;
	img[12].src="img/black_05.jpg";


	img[14]=new Image;
	img[14].src="img/up.jpg";
	
	img[15]=new Image;
	img[15].src="img/down.jpg";
	
	
	if (q==1) hv('winp',true);
//	window.setTimeout("hv('winp',true)",1000);
//	window.setTimeout("hv('winp',true)",1000);
}

function moo(o,d)
{
	o.src=img[d].src;
}

function moc(n)
{
	switch (n) 
	{
		case 0:
			window.open("online-speak.html","_self");
			break;
		case 1:
			window.open("online-write.html","_self");
			break;
		case 2:
			window.open("online-callback.html","_self");
			break;
		default:
			window.open("pnx","_self");
			break;
	}
}



//
function update_el(z,e)
{
	if (!e) 
		var e=document.body.childNodes;
	
	for (var i=0;i<e.length;i++)
	{
		if (e[i].nodeType==1)
		{
			if (e[i].className!=""&&e[i].className.substr(e[i].className.length-2,2)!="_x")
			{			
				if (e[i].className.substr(e[i].className.length-2,2)!="_1")
					{
					if (z==false)
						e[i].className=e[i].className+"_1"; 
					}
					else
					{
					if (z==true)
						e[i].className=e[i].className.substr(0,e[i].className.length-2);				
					}
			}
			
			update_el(z,e[i].childNodes);
		}
	}
}

<!-- скритпт для подмены кнопки отправки -->

function checkform(v)
{
	if (v==0)
	{
		var r=0;
		if (document.getElementById("form_p1").value!="") r++;
		if (document.getElementById("form_p2").value!="") r++;
		if (document.getElementById("form_p3").value!="") r++;
		if (document.getElementById("form_p4").value!="") r++;

		if (r==4) 
		{
			document.getElementById("img4").disabled=false;
			document.getElementById("img4").src="img/button_red.jpg";
		}
			else
		{
			document.getElementById("img4").disabled=true;
			document.getElementById("img4").src="img/button.jpg";
		}
	}
if (v==1)
	{
		var r=0;
		if (document.getElementById("p2").value!="") r++;
		if (document.getElementById("p3").value!="") r++;
		if (document.getElementById("p7").value!="") r++;
		if (document.getElementById("form_cod").value!="") r++;


		if (r==4) 
		{
			document.getElementById("img4").disabled=false;
			document.getElementById("img4").src="img/button_red.jpg";
		}
			else
		{
			document.getElementById("img4").disabled=true;
			document.getElementById("img4").src="img/button.jpg";
		}
	}
if (v==2)
	{
		var r=0;
		if (document.getElementById("q1").value!="") r++;
		if (document.getElementById("q2").value!="") r++;
		if (document.getElementById("q8").value!="") r++;
		if (document.getElementById("form_cod").value!="") r++;

		if (r==4) 
		{
			document.getElementById("img4").disabled=false;
			document.getElementById("img4").src="img/button_red.jpg";
		}
			else
		{
			document.getElementById("img4").disabled=true;
			document.getElementById("img4").src="img/button.jpg";
		}
	}
}


<!-- скритпт поиска по сайту -->
	
	function vsearch()
	{
	var r=prompt('Введите искомую строку','');
	if (r)	
		{
			window.open("http://yandex.ru/yandsearch?text="+r+"&site=www.ffwd.ru","_blank");
		}
	}
	
<!-- разворот картинки и инверсия слоев-->
	
function invdiv(w1,w2,i)
{
	hv(w1,null,true);
	hv(w2,null,true);
	
	if (i)
	{
	if (document.getElementById(i).src==img[14].src)
		document.getElementById(i).src=img[15].src; else
		document.getElementById(i).src=img[14].src;
	}
	document.body.scrollTop=0;	
}

function invdivm(prefix,count,n)
{
	for (var i=0;i<count;i++)
	{
		if (n!=i)
			hv(prefix+"_"+i,false,true); else
			hv(prefix+"_"+i,true,true);
	}
	document.body.scrollTop=0;	
}

function absPosition(obj) //функция определения координат элемента
{ 
      var x = y = 0;
      while(obj) 
	  {
            x += obj.offsetLeft;
            y += obj.offsetTop;
            obj = obj.offsetParent;
      }
      return {x:x, y:y};
}

function panel_hv(id,ide)
{
el=document.getElementById(id).style.display;
if (el=="none")
	{
		
	c=absPosition(document.getElementById(ide));
		
	mouse_x=event.x;
	mouse_y=event.y;
	body_scrolltop=document.body.scrollTop;
	body_width=document.body.clientWidth;
	body_height=document.body.clientHeight;
		
	
	document.getElementById(id).style.left=c.x;
	document.getElementById(id).style.top=c.y+document.getElementById(ide).offsetHeight;
	document.getElementById(id).style.display="inline"; 
	} else
	{
	document.getElementById(id).style.display="none";
	}
}

function dview(id,ide)
{
if (document.getElementById(id).style.display!="none")
	document.getElementById(id).style.display="none"; else
	{
	c=absPosition(document.getElementById(ide));
	document.getElementById(id).style.left=c.x;
	document.getElementById(id).style.top=c.y+document.getElementById(ide).offsetHeight;
	document.getElementById(id).src="calend.php?data="+document.getElementById("form_p4").value;
	document.getElementById(id).style.display="inline";	
	}
}

function tview(id,ide)
{
if (document.getElementById(id).style.display!="none")
	document.getElementById(id).style.display="none"; else
	{
	c=absPosition(document.getElementById(ide));
	document.getElementById(id).style.left=c.x;
	document.getElementById(id).style.top=c.y+document.getElementById(ide).offsetHeight;
	document.getElementById(id).style.width=document.getElementById(ide).offsetWidth;
	document.getElementById(id).src="times.php?data="+document.getElementById("form_p4").value;
	document.getElementById(id).style.display="inline";	
	}
}

function dset(m,d)
{
	mnames=Array("Января","Февраля","Марта","Апреля","Мая","Июня","Июля","Августа","Сентября","Октября","Ноября","Декабря");
	window.parent.document.getElementById("form_p4").value=d+" "+mnames[m];
	window.parent.document.getElementById("fdate").style.display="none";
	window.parent.checkCBform();
}
function tset(t,e)
{
	window.parent.document.getElementById("form_p5").value=t;
	window.parent.document.getElementById("ftime").style.display="none";
	window.parent.checkCBform();
}

function tsel(e,s)
{
	for (var i=0;i<40;i++)
	{
		if (document.getElementById("in_"+i))
		{
			document.getElementById("in_"+i).style.backgroundColor="";
			document.getElementById("in_"+i).style.border="1 solid White";
		}
	}
	if (document.getElementById("in_sr"))
	{
	document.getElementById("in_sr").style.backgroundColor="";
	document.getElementById("in_sr").style.border="1 solid White";
	}

	if (!s) return null;
	
	e.style.backgroundColor="#A0C8DB";
	e.style.border="1 solid #A0C8DB";
	
	var s=parseInt(e.id.substring(3,5));
	if (document.getElementById("in_"+(s+1)))
	{
		document.getElementById("in_"+(1+s)).style.backgroundColor="#A0C8DB";
		document.getElementById("in_"+(1+s)).style.border="1 solid #A0C8DB";
		
	}
}//	background-color : #D0E8FB;

function checkCBform()
{
	r=0;
	if (document.getElementById("form_p1").value!="") r++;
	if (document.getElementById("form_p2").value!="") r++;
	if (document.getElementById("form_p4").value!="") r++;
	if (document.getElementById("form_cod").value!="") r++;
	if (document.getElementById("form_p5").value!=""&&document.getElementById("form_p5").value!="Выбрать интервал") r++;

		if (r==5) 
		{
			document.getElementById("img4").disabled=false;
			document.getElementById("img4").src="img/button_red.jpg";
		}
			else
		{
			document.getElementById("img4").disabled=true;
			document.getElementById("img4").src="img/button.jpg";
		}
	
	return true;
}