var id;

image1 = new Image();
image1.src = 'menu_fon_over.gif';
//---------------------------------------------------------------------
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);
}
//---------------------------------------------------------------------
function load_photo(url, h, w)
{
	if (w < 720)
		w = 720;
	else
		w = w + 50;
	if (h < 700)
		h = 700;
	else
		h = h + 80;
	var l = (screen.width  - w)/2;
 	var t = (screen.height - h)/2;
	window.open(url, '', 'resizable=yes,scrollbars=yes,height='+h+',width='+w+',top='+t+',left='+l);
}
//---------------------------------------------------------------------
function load_imgs(id, type, img,  h, w)
{
	if (w < 800)
		w = 900;
	else
		w = w + 50;
	if (h < 450)
		h = 450;
	else
		h = h + 80;
	var l = (screen.width  - w)/2;
 	var t = (screen.height - h)/2;
	window.open('/imgs.php?type='+type+'&id='+id+'&img='+img, '', 'resizable=yes,scrollbars=yes,height='+h+',width='+w+',top='+t+',left='+l);
}
//--------------------------------------------------------
function doLoad(url)
{
  document.body.style.cursor = 'wait';
  var req = new JsHttpRequest();
  req.caching = false;
  req.open(null, url, true);
  req.send(  );
}
//--------------------------------------------------------
function doo(txt)
{
	if (id == 'secure')
	{
		if (txt == 'true')
		{
			document.getElementById(id).style.color='#000000';
			document.getElementById('secure_key').value='1';
		}
		else
		{
			document.getElementById(id).style.color='#E93C00';
			document.getElementById('secure_key').value='0';
		}
		enable_button();
	}
	document.body.style.cursor = 'default';
}
//--------------------------------------------------------

function set_month_obj(obj)
{
for (i = 0; i < obj.options.length; i++)
{
  if (obj.options[i].value == datetime[1])
  {obj.selectedIndex = i;break;}
}}

//--------Для-работы-с-датой------------------------------
function put_date(day)
{
	putdate[0] = day;
	putdate[1] = datetime[1];
	putdate[2] = datetime[2];
	fill_kalendar('kalendar');
	document.getElementById('ddate').value = putdate[0]+'.'+putdate[1]+'.'+putdate[2];
}
//--------------------------------------------------------
function fill_kalendar(kalendar, _month, _year, link)
{
	obj = document.getElementById(kalendar);
	if (_month)
		datetime[1] = _month;
	if (_year)
		datetime[2] = _year;
	if (!link)
		link = 'false';
	obj.innerHTML = get_days_of_month(datetime[0], datetime[1], datetime[2], link);
}

//--------------------------------------------------------
function get_days_of_month(_day, _month, _year, link)
{
	var cur_date = new Date ();
	var obj_date = new Date (_year, _month-1, '01');
	var lday = new Date (_year, _month, '00');
	wday = obj_date.getDay();
	lday = lday.getDate();
	month_days = '';
	if (wday == 0) wday = 7;
	for (i=1; i < wday; i++)
		month_days+='<div>&nbsp;</div>';
	for (i=0; i < lday; i++)
	{
		month_days+='<div>';
		if (putdate[2] == _year && putdate[1] == _month && putdate[0]== i+1)
			month_days+= '<span class="selected">'+(i+1)+'</span></a>';
		else
		{
			href = '#';
			if (link)
				href='orders.html?y='+_year+'&m='+_month+'&d='+(i+1);
			month_days+='<a href="'+href+'"';
			if ((cur_date.getFullYear()) == _year && cur_date.getMonth() == (_month-1) && cur_date.getDate() == i+1)
				month_days+=' class="tek"';
			if (link)
				month_days+= ' onClick="put_date('+(i+1)+'); return false;"';
			month_days+='>'+(i+1)+'</a>';
		}
		month_days+='</div>';
	}
	return month_days;
}
//--------------------------------------------------------
