//Определение координат мыши
var mouseX; var mouseY;

function imouse(e)
{
  var x = 0, y = 0;
  if (!e) e = window.event;

  if (e.pageX || e.pageY){
    x = e.pageX;
    y = e.pageY;
  } else if (e.clientX || e.clientY) {
    x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
    y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
  }

  mouseX=x; mouseY=y;
}

document.onmousemove=imouse;


function bc(name,namesrc)
{
	var a = document.getElementById(name);
	a.src=namesrc;
}


function show_hide(id)
{
	var win = document.getElementById(id);
	if(win.style.display=='block')
	{
		win.style.display='none';
	}
	else
	{
		win.style.display='block';
	}
}


//open window
var Opened = false;
function ow(PageSrc,Width,Height, Params)
{
	if(!Params) Params="toolbar=no,menubar=no,location=no,directories=no,scrollbars=auto,resizable=yes";
	Features="top=118,left=255,width="+Width+",height="+Height+","+Params;
	if ((!Opened) || (NewWin.closed))
	{
		Opened = true;
		NewWin = window.open(PageSrc,null,Features);
		NewWin.focus();
		var w = (window.document.body.offsetWidth)?window.document.body.offsetWidth - 4:window.document.innerWidth;
		var h = (window.document.body.offsetHeight)?window.document.body.offsetHeight - 4:window.document.innerHeight;
		if ((w != Width) || (h != Height)) {NewWin.resizeTo(Width + 10, Height + 29);}
	}
	else
	{
		if ((Opened) || (!NewWin.closed))
		{
			NewWin.location=PageSrc;
			NewWin.focus();
		}
	}
}

function hideMsg(div)
{
document.getElementById(div).style.display='none';
}

function showMsg(div)
{
document.getElementById(div).style.display='block';
var timeout_id;
timeout_id = setTimeout("hideMsg('"+div+"');",2000);
}

function showVid(vid){
	block=document.getElementById('video_popup');
	block.innerHTML='<div align=right><a href="#" onclick="hideVid(); return false;">закрыть</a></div><embed src="'+vid+'" width=384 height=288 hspace=0 vspace=0 autostart=true></embed>';
	block.style.cssText='display: block; top: '+(document.body.scrollTop+getClientHeight()/2-153)+'px; left: '+(getClientWidth()/2-192)+'px;';
}

function hideVid(){
	block=document.getElementById('video_popup');
	block.style.cssText='display: none;';
	block.innerHTML='';
}



function getClientWidth()
{
 return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight()
{
 return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}


function toggleMenu(m){
	f=document.getElementById('feer_menu');
	fb=document.getElementById('feer_btn');
	k=document.getElementById('karn_menu');
	kb=document.getElementById('karn_btn');

	if(m=='feer'){
		f.style.cssText='display: block;';
		fb.className='bcm1a';
	}else{
		f.style.cssText='display: none;';
		fb.className='';
	}
	if(m=='karn'){
		k.style.cssText='display: block;';
		kb.className='bcm1a';
	}else{
		k.style.cssText='display: none;';
		kb.className='';
	}
}


function toggleCmm(s){
	var cmm=document.getElementById('cmm');
	var vid=document.getElementById('vid');

	if(s){
		cmm.style.cssText='display: block;';
		if(vid){
			vid_html=vid.innerHTML;
			vid.innerHTML='';
			vid.style.cssText='display: none;';
		}
	}else{
		cmm.style.cssText='display: none;';
		if(vid){
			vid.innerHTML=vid_html;
			vid.style.cssText='display: block;';
		}
	}
}

function checkCmmForm(){
	f=document.getElementById('cmm_form');

	if(!f.cmm_name.value || !f.cmm_text.value){
		alert('Обязательно введите имя и текст отзыва!');
	}else{
		f.submit();
	}
}



function showPrdPopup(id){
	b=document.getElementById('prd_popup');
	b.innerHTML='<iframe src="/product_popup/'+id+'/" width=100%% height=100%% scrolling="no" frameborder="no"></iframe>';
	b.style.display='block';
	b.style.top=mouseY-30;
	b.style.left=mouseX-300;
}

function hidePrdPopup(){
	b=document.getElementById('prd_popup');
	b.innerHTML='';
	b.style.display='none';
}