if( document.all ) {
/*document.captureEvents( Event.MOUSEMOVE );
document.onmousemove = getCoordIe;*/
} else if( document.getElementById ) {
document.captureEvents( Event.MOUSEMOVE );
document.onmousemove = getCoord;
}
var mouseX;
var mouseY;
function getCoord( event ) {
mouseX = event.pageX;
mouseY = event.pageY;
}
function enterPanel(st){
	el = GetEl("enter_form_div");
	if(1 == st){
		el.style.display = 'inline';
	}
	else
		el.style.display = 'none';
}
function voidf(){}

function GetEl(idel){
 	el = document.getElementById(idel);
 	return el;
 	//return getElementByName(nm);
}
function showHlp(hn,numel){
	if(numel){
		for(i=1; i<=numel; i++){
			helm = GetEl('hlp'+i);
			if(helm)
				helm.style.display = 'none';
		}
	}
	GetEl('hlp'+hn).style.display = 'inline';
}

//-------------------------- com
function ShowCom()
{
	document.getElementById('com_form').style.display = 'block';
	document.getElementById('com_text').style.display = 'none';
	
}

//--------------- prosmotr soobsenii

function lok_mes(id)
{
//	var pos = getPosition(obj);
//alert(id);	
	var pos = getElementPosition("coment_"+id); 
	var left = pos.left; 
	var top = pos.top - 100;
//alert(left);
//alert(top);
//	window.scrollTo(0, top);
	return top;
//	alert(top);
}

function getElementPosition(elemId)
{
    var elem = document.getElementById(elemId);
//alert(elem);  
    var w = elem.offsetWidth;
    var h = elem.offsetHeight;
    
    var l = 0;
    var t = 0;
    
    while (elem)
    {
        l += elem.offsetLeft;
        t += elem.offsetTop;
        elem = elem.offsetParent;
    }

    return {"left":l, "top":t, "width": w, "height":h};
}

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

//-------------- vivod soosenii
function sasa(text)
{
	var mCur = mousePageXY(window.event);
//alert("fffff"+text);
	if(text != '')
	{
//	alert("fffff"+text);
	document.getElementById('err_all').innerHTML = text;

	document.getElementById("err_all").style.top = mCur.y+'px';
//	document.getElementById("err_all").style.left = mCur.x+'px';

	document.getElementById('err_all').style.display = 'block';
	setTimeout("document.getElementById('err_all').style.display = 'none'",3000);
	}
}
//----------------formirov zakaza
function sum_price(id)
{
	if(document.getElementById('ch_'+id).checked)
	{
		sum = document.getElementById('price_'+id).value;
		col = document.getElementById('col_'+id).value;
//alert(sum+"----"+col);		
		summa = document.getElementById('cost').value;
		
		document.getElementById('cost').value = (summa*1)+(sum*col);
		
	}
	else
	{
		sum = document.getElementById('price_'+id).value;
		col = document.getElementById('col_'+id).value;
		
		summa = document.getElementById('cost').value;
		if(summa != '' )//AND summa != '0')
		{
		if((summa*1) < (sum*col))
			document.getElementById('cost').value = 0;
		else
			document.getElementById('cost').value = (summa*1)-(sum*col);
		}
	}
}

function summa_total()
{
	if(document.getElementById('cost').value != '')
	{
		summa = document.getElementById('cost').value;
		rate = document.getElementById('rate').value;

		document.getElementById('summa').value = (summa*1)+(rate*1);

	}
}

function valuta(ind,el)
{
	var mCur = mousePageXY(window.event);
//	alert("x---"+mCur.x+"----y"+mCur.y);
//		alert(window.event.clientY);
//	alert(document.body.scrollTop);
	if(ind == 1)
	{
		document.getElementById("curs_val_"+el).style.display="block";
		document.getElementById("curs_val_"+el).style.top = mCur.y+'px';
		document.getElementById("curs_val_"+el).style.left = mCur.x+'px';
	}else{
		document.getElementById("curs_val_"+el).style.display="none";
	}
}

function valuta_all(sum,val)
{
	var el = "all";
	var mCur = mousePageXY(window.event);
	var ind = 1;
//	alert("x---"+mCur.x+"----y"+mCur.y);
//		alert(window.event.clientY);
//	alert(document.body.scrollTop);
	x = val.replace(String.fromCharCode(0x0026),"");
	x = val.replace(";","");
//alert("dddddddddddddd--"+val+"---"+x);
	if(ind == 1)
	{
		xajax_getMultiVal(sum,x,0);
//		document.getElementById("curs_val_"+el).style.display="block";
		document.getElementById("curs_val_"+el).style.top = mCur.y+'px';
		document.getElementById("curs_val_"+el).style.left = mCur.x+'px';
	}else{
		document.getElementById("curs_val_"+el).style.display="none";
	}
}

function mousePageXY(e)
{
	var x = 0, y = 0;
	if (!e) e = window.event;
	
	if (mouseX || mouseY)
	{
		x = mouseX;
		y = mouseY;
//alert(x+'--1111---'+y);
	}else if (e.clientX || e.clientY)
	{
		x = e.clientX;
		y = e.clientY + document.body.scrollTop;
	}
	return {"x":x, "y":y};
}

function mouseFromWindows(el)
{
	var mCur = mousePageXY(window.event);
	
	document.getElementById(el).style.top = mCur.y+'px';
	document.getElementById(el).style.left = mCur.x+'px';
}

