// JavaScript Document

function del_confirm(lnk)
{
	if (confirm("Esti sigur ca vrei sa stergi?"))
		document.location=lnk;
}

function js_confirm(lnk, text)
{
	if (confirm(""+text))
		document.location=lnk;
}

function getkey(e)
{
	if (window.event)
	   return window.event.keyCode;
	else if (e)
	   return e.which;
	else
	   return null;
}


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;
}

function repair_flash()
{
	theObjects=document.getElementsByTagName("object");
	for (var i=0; i<theObjects.length; i++)
	{
		theObjects[i].outerHTML = theObjects[i].outerHTML;
	}
}

function toggle(control)
{
	obj=document.getElementById(control);
	if (obj.style.display=="none")
		obj.style.display="block";
	else
		obj.style.display="none";
}

function genereaza_campuri()
{
	theNr=document.getElementById('nr_optiuni');
	theDiv=document.getElementById('fieldset');
	
	numar=parseInt(theNr.value);
	codHTML="";
	for (var i=1; i<=numar; i++)
	{
		codHTML+="<b>Raspuns "+i+"</b> <input type='text' name='raspuns[]' />";
		if (i!=numar) codHTML+="<br />";
	}
	theDiv.innerHTML=codHTML;
}

marimeFontDefault = 12;
marimeFontMinim = 8;
marimeFontMaxim = 16;

function maresteFont()
{
	theDiv=document.getElementById('enunt_articol');
	marimeFontDefault = marimeFontDefault+1;
	if (marimeFontDefault > marimeFontMaxim) {marimeFontDefault = marimeFontMaxim;}
	theDiv.style.fontSize=marimeFontDefault+"px";
}

function micsoreazaFont()
{
	theDiv=document.getElementById('enunt_articol');
	marimeFontDefault = marimeFontDefault-1;
	if (marimeFontDefault < marimeFontMinim) {marimeFontDefault = marimeFontMinim;}
	theDiv.style.fontSize=marimeFontDefault+"px";
}

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);
}
