//---------------------------------------------------------------------
function load_img(id, h, w)
{
	var l = (screen.width  - w)/2;
 	var t = (screen.height - h)/2;
	window.open('/img.php?img='+id, '', 'resizable=yes,scrollbars=yes,height='+h+',width='+w+',top='+t+',left='+l);
}
//---------------------------------------------------------------------
//

var OrdersImpColor = '#FF0000';
var OrdersColor = '#000000';
var ExtraImp = new Number();
var MyElementType = new Array();
ExtraImp["zathitnyj_kod"] = 0 ;
MyElementType["zathitnyj_kod"] = 'text' ;
/*EXTRA PARAMS*/

function assocCount(Assoc)
{
	c=0;
	for (MyElement in Assoc) c++;
	return c;
}
function assocTrueCount(Assoc)
{
	c=0;
	for (MyElement in Assoc) if (Assoc[MyElement]) c++;
	return c;
}
function Clear ()
{
	for (MyElement in ExtraImp) 
	{
		ExtraImp[MyElement] = 0;
		document.getElementById('div_'+MyElement).style.color=OrdersImpColor;
	}
	CheckFields();

}
function CheckGroup(id)
{
	bool = false;
	for (i = 0; ; i++)
	{
		if (!(obj = document.getElementById('extra['+id+']['+i+']')))
			break;
		if (obj.checked)
		{	bool = true; break;	}
	}
	divobj = document.getElementById('div_'+id);
	if (bool)
	{
		ExtraImp[id] = 1;
		divobj.style.color=OrdersColor;
	}
	else
	{
		ExtraImp[id] = 0;
		divobj.style.color=OrdersImpColor;
	}
	CheckFields();
}
function CheckTextField (id, bool)
{
	res = 0;
	if (document.getElementById(id).value.length > 3)
	{
		document.getElementById('div_'+id).style.color= OrdersColor;
		res = 1;
	}
	else document.getElementById('div_'+id).style.color=OrdersImpColor;
	if (bool)
		return res;
	else
	{
		ExtraImp[id] = res;
		CheckFields();
	}
	
}
function CheckSelectField (id)
{
	if (document.getElementById(id).selectedIndex > -1)
	{
		document.getElementById('div_'+id).style.color= OrdersColor;
		ExtraImp[id] = 1;
	}
	else 
	{
		document.getElementById('div_'+id).style.color=OrdersImpColor;
		ExtraImp[id] = 1;
	}
	CheckFields();
}

function CheckFields()
{
	names = new Array('name', 'phone');
	var empt = 0;
	for (i = 0; i < names.length; i++)
		empt+=CheckTextField(names[i], true);
	Count = names.length+assocCount(ExtraImp);
	res = empt + assocTrueCount(ExtraImp);
	if (res == Count)
		document.getElementById('button').disabled = false;
	else
		document.getElementById('button').disabled = true;
}
function ChangeColors(objID, next) 
{
	colors = new Array("#135CAE",  "#AF1407"); 
	next = next % colors.length;
	headcolor = colors[next];
	document.getElementById(objID).style.color = headcolor;
	setTimeout("ChangeColors('"+objID+"', "+(next+1)+")",400);
}

