function popup(adresa, latime, inaltime, is_scroll)
{
	if (is_scroll=="scroll")
		completare=", SCROLLBARS=YES"
	else
		completare="";
	var newWin=window.open(adresa+"", "_blank", "WIDTH="+latime+", HEIGHT="+inaltime+completare);
}

function js_confirm(lnk, text)
{
	if (confirm(""+text))
		document.location=lnk;
}

function js_confirm_opener(lnk, text)
{
	if (confirm(""+text))
	{
		opener.document.location=lnk;
		window.close();
	}
}

function getMenu(theDiv)
{
	var divuri=document.getElementsByTagName('div');
	for(i=0; i<divuri.length; i++)
	{
		if(divuri[i].id.substr(0, 3)=="cat")
			divuri[i].style.display='none';
	}
	document.getElementById(theDiv).style.display='block';
}

function centreazaFereastra(win)
{
	var winW=0;
	if (parseInt(navigator.appVersion)>3)
	{
		if (navigator.appName=="Netscape")
		{
			winW=window.innerWidth;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1)
		{
			winW=document.body.offsetWidth;
		}
	}
	win.moveTo((screen.width-winW)/2, 120);
}

var Interval;
var popUpDiv;
var deplasareDiv=50;
var intervalDetectScroll=200;

function centreazaDiv(divId, divWidth, divHeight)
{
	popUpDiv=document.getElementById(divId);
	Interval = window.setInterval("checkScroll()", intervalDetectScroll);
}

function checkScroll()
{
	newX=(document.documentElement.clientWidth/2)-(parseFloat(popUpDiv.style.width)/2);
	newY=(document.documentElement.clientHeight/2)-(parseFloat(popUpDiv.style.height)/2)
	if (window.pageYOffset)
	{
		newY+=window.pageYOffset;
	}
	else
	{
		newY+=document.documentElement.scrollTop;
	}
	newX=Math.round(newX);
	newY=Math.round(newY);
	popUpDiv.style.top = (newY - deplasareDiv)+"px";
	popUpDiv.style.left = newX+"px";
}


function deschide_galerie(data)
{
	newWindow=window.open("galerie_open.php?galerie="+escape(data), "galerie", "width=640, height=480");
	newWindow.moveTo((screen.width-640)/2, 120);
	newWindow.focus();
}

function toggle(id)
{
	theDiv=document.getElementById(id);
	if (theDiv.style.display=="none")
		theDiv.style.display="block"
	else
		theDiv.style.display="none"
}

function toggle_and_focus(id1, id2)
{
	theDiv=document.getElementById(id1);
	theField=document.getElementById(id2);
	if (theDiv.style.display=="none")
	{
		theDiv.style.display="block"
		theField.focus();
		//theField.select();
	}
	else
		theDiv.style.display="none"
}

function deschideFereastra(lnk, width, height)
{
	var newWindow=window.open(lnk, "fereastraParinte", "width="+width+", height="+height);
	newWindow.moveTo((screen.width-width)/2, 200);
	newWindow.focus();
}

function openerRefresh()
{
	window.opener.location.reload();
}

function closeAndFocusOpener(flagRefreshOpener)
{
	window.close();
	opener.focus();
	if(flagRefreshOpener) openerRefresh();
}

// detect daca exista o fereastra AJAX de editare (apelabila numai daca exista variabila GET de editare)
function detectAjaxEditWindow()
{
	var divuri=document.getElementsByTagName('div');
	for(i=0; i<divuri.length; i++)
	{
		if(divuri[i].id.substr(0, 11)=="modificare_" && divuri[i].id.substr(divuri[i].id.length-6, divuri[i].id.length-1)=="_frame")
			divuri[i].style.display='block';
	}
}

function goodchars(e, goods)
{
	var key, keychar;
	key = getkey(e);
	if (key == null)
		return true;
	
	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	goods = goods.toLowerCase();
	
	if (goods.indexOf(keychar) != -1)
		return true;
	
	if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
	   return true;
	
	return false;
}
