function hide_menu(i) 
{
	for(n=1;n<=40;n++) 
	{
		var mn = document.getElementById('menu' + n)

		if (mn)	
		{
			mn.style.visibility = 'hidden'
			document.getElementById('TdMenu' + n).className = 'Menu';
			document.getElementById('Img' + n).src = './img/pointOut.gif';
		}
	}
}

function show_menu(i) 
{
	for(n=0;n<=40;n++) 
	{
		var mn = document.getElementById('menu' + n)

		if (mn)
			if (n == i)
			{
				document.getElementById('TdMenu' + n).className = 'MenuHover';
				document.getElementById('Img' + n).src = './img/point.gif';
				mn.style.visibility = 'visible'
			}
			else 
			{
				document.getElementById('TdMenu' + n).className = 'Menu';
				document.getElementById('Img' + n).src = './img/pointOut.gif';
				mn.style.visibility = 'hidden'
			}
	}
}

function divShowHide(div)
{
	if (document.getElementById(div).style.display == 'none')	
		document.getElementById(div).style.display = ''
	else
		document.getElementById(div).style.display = 'none';
}

function readCookie(name) {
	var namearg = name + "=";
	var nlen = namearg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + nlen;
		if (document.cookie.substring(i, j) == namearg) {
			var endpos = document.cookie.indexOf (";", j);
			if (endpos == -1) endpos = document.cookie.length;
			return unescape(document.cookie.substring(j, endpos));
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return 0;
}

function deleteCookie(name) {
   if (readCookie(name)) {
     document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
   }
}

function writeCookie(name, value, expiry) {
	var expdate = new Date();	
	if(expiry) { //horas
		expdate.setTime(expdate.getTime() + 1000 * 60 * 60 * expiry);
		document.cookie = name + "=" + value + "; expires=" + expdate.toGMTString();
	}
	else {
		document.cookie = name + "=" + value;
	}
}

function Go(GoTo, Zone)
{
	if(GoTo.indexOf('http://') == -1)
	{
		deleteCookie('Zone');

		writeCookie('Zone', Zone, 90);
		writeCookie('Menu', 1, 90);

		window.location = GoTo;
	}
	else window.open(GoTo)
	
}

function Init()
{
	writeCookie('Menu', 0, 90);
	FixIt();
}


function updateData (id, cols, current, record_id, edit, url) {
	try {
		window.location = url + 'Id=' + record_id;
	}
	catch(e)
	{
		
	}
}	

function ShowFile(ImgId, Width, Height)
{
	var w = window.open('ShowFile.aspx?ImgId=' + ImgId + '&Width=' + Width + '&Height=' + Height,'','toolbar=0,status=0,menubar=0,fullscreen=no,width=200,height=200,resizable=0,top=100,left=100');
}

function ShowPluginsFile(Img, Width, Height)
{
	var w = window.open(Img);
}

function PrintIt(Url)
{
	var w = window.open(Url,'','toolbar=0,status=0,menubar=0,fullscreen=no,width=550,height=600,resizable=0,top=100,left=100,scrollbars=1');
}


function AddToChart(QtName, ProductId, AlwaysOpen)
{
	var Qt;
	Qt = document.getElementById(QtName).value;
	
	if((Qt != '' && Qt > "0") || AlwaysOpen == 'True')
		var w = window.open('AddToChart.aspx?ProductId=' + ProductId + "&Qt=" + Qt,'AddToChartWindow','toolbar=0,status=0,menubar=0,fullscreen=no,width=300,height=150,resizable=0,top=100,left=100,scrollbars=0').focus();
}
