function ViewForgotDiv()
{
	el = document.getElementById('divforgot');
	if (el.style.display == 'none')
		el.style.display  = "block";
	else	
		el.style.display  = "none";

}

function ChangeLang()
{
	document.changeLang.submit();
}

function MakeOn(url)
{
//	var expand = document.getElementById('expand');
//	url = url+"&expand="+expand.value;
	location.href=url;
}

function DopImg()
{
	targetId="dopimg";
	targetElement = document.getElementById(targetId);
	if (targetElement.style.display == "none")
		targetElement.style.display= "";
	else
		targetElement.style.display = "none";
	location.href = "#dopimg";
}

function open_window(url)
{
	cwin = window.open(url,"attach","width=350,height=400,toolbar=no,resizable=yes");
}

function ViewResume(id)
{
	var targetId = "res"+id;
	var buf = document.getElementById(targetId);
	if (buf.style.visibility == "")
	{
		buf.style.visibility = "hidden";
		buf.style.display = "none";		
	}
	else 
	{
		buf.style.visibility = "";
		buf.style.display = "";		
	}
}

function set_visible(id,visible)
{
	var buf = document.getElementById(id);
	if (visible)
	{
		buf.style.visibility	= "";
		buf.style.display	= "";		
	}
	else 
	{
		buf.style.visibility	= "hidden";
		buf.style.display	= "none";		
	}
}

function select_menu(id,pic)
{
	var buf = document.getElementById('menu'+id);
	if (pic)
		pic = document.getElementById('pic'+id);
	if (buf.style.display)
	{
		buf.style.visibility = "";
		buf.style.display = "";
		if (pic)
		{
			pic.src = "/images/out.gif";
			pic.alt	= "Свернуть";
			pic.title	= "Свернуть";
		}
	}
	else
	{
		buf.style.visibility = "hidden";
		buf.style.display = "none";
		if (pic)
		{
			pic.src	= "/images/in.gif";
			pic.alt	= "Развернуть";
			pic.title	= "Развернуть";
		}
	}
}

function update_shop(result)
{
	if (result)
	{
		document.getElementById('buy_'+result['id']).src = '/images/cart.png';
		document.getElementById('allshop').innerHTML = result['data'];
	}
}

function update_basket(result)
{
	if (result)
	{
		document.getElementById('buy_'+result['id']).src = '/images/del.png';
		document.getElementById('allshop').innerHTML = result['data'];
		document.getElementById('shopsumma').innerHTML = result['summa'];
		document.getElementById('pic_order').innerHTML = result['order'];
		set_visible('sendorder',false);
	}
}

function add_tovar(id)
{
	var pic	= document.getElementById('buy_'+id);
	pic.src = '/images/loading.gif';
//	alert(pic.src);
	JsHttpRequest.query(
		'/include/core/ajax_shop.php',
		{id:id,count:1,action:'insert'},
		function(result, errors) {update_shop(result);},
		true);		
}

function change_order(id)
{
	count	= document.getElementById('count_'+id).value;
	var pic	= document.getElementById('buy_'+id);
	pic.src = '/images/loading.gif';
//	alert(pic.src);
	JsHttpRequest.query(
		'/include/core/ajax_shop.php',
		{id:id,count:count,action:'change'},
		function(result, errors) {update_basket(result);},
		true);		
}

function delete_order(id)
{
	formshop.action.value	= 'delete';
	formshop.tovar.value	= id;
	formshop.submit();
}

var oldUrl = false;

function IE5opener(url,w,h)
{
	w	= Math.abs(w)+7;
	h	= Math.abs(h)+27;
	scrollYes = ( w > screen.availWidth || h > screen.availHeight ) ? 1 : 0;
	SBWidth	= (scrollYes) ? 17 : 0;
	w	= (w > screen.availWidth) ? screen.availWidth - 40 : w + SBWidth;
	h	= (h > screen.availHeight) ? screen.availHeight - 40 : h + SBWidth;
	var ver	= navigator.appVersion;
	ver	= ver.substring(ver.indexOf("MSIE")+5, ver.length);
	ver	= parseFloat(ver.substring(0, ver.indexOf(";")));
	if (ver >=5)
	{
		if ((url != oldUrl) || (WinObj && WinObj.closed))
		{
			WinObj = showModelessDialog(url, window, "help: no; status: no; scroll:"+scrollYes+"; resizable: on; dialogWidth:"+w+"px; dialogHeight:"+h+"px; margin: 0");
			oldUrl = url;
		}
		else
			if (WinObj && !WinObj.closed)
				WinObj.focus();
	}
	else
		OtherOpener(url,w,h);
}

function OtherOpener(url,w,h)
{
	w	= w + 18;
	h	= h +26;
	if (w>600)
		w = 600;
	if (h>500)
		h = 500;
	d	= new Date();
	t	= d.getTime();
	WinObj	= window.open(url, t,"width="+w+",height="+h+",scrollbars=yes,resizable=yes");
}

function PopUp(url,w,h)
{
	if (document.all)
		IE5opener(url,w,h);
	else
		if (document.images)
			OtherOpener(url,w,h);
	return
		false;
}

function show_sendorder()
{
	set_visible('sendorder',true);
}

function hide_sendorder()
{
	set_visible('sendorder',false);
	set_visible('error',false);
}
