//scripturi care tin de autentificare
function showLogin(location, status)
{
	if(status == 1 || status == 4)
	{
		var SID = getSID();
		document.location = location + "?" + SID;
	}
	var div = document.getElementById('popup');
	
	div.style.margin = 'auto';
	div.style.padding = '2%';	
	div.style.display = 'block';
	div.style.top = '25%';
	div.style.left = '40%';
	
	refreshContentGET(div, 'login.php', 'loc='+escape(location));
	
}

function doLogin(location)
{
	var div = document.getElementById('popup');
	
	refreshContentPOST(div, 'login.php', 'log=1&loc='+escape(location),'flogin');
		
	/*div.style.display = 'block';
	div.style.top = '30%';
	div.style.left = '30%';*/
}

//functie care incarca continutul unui element prin metoda GET
function refreshIFrameGET(elemNume, pagina, param)
{
	var elem;

	if(typeof(elemNume) == 'string')
		elem = document.getElementById(elemNume);
	else
		elem = elemNume;
	
	//dechidem conexiuniea	
	elem.src=pagina + '?' + param;	
}


function goParcare()
{
	var SID = getSID();
	document.location = "parcare.php?" + SID;
}

function tipContribuabil( tip )
{
	//tine de autentificare
	var text = "";
	if ( tip == "F" )
		text = "Cod numeric personal: ";
	else
		text = "Cod fiscal: ";
	
	if (document.all["User"].innerText)
		document.all["User"].innerText = text; 
	else
		document.all["User"].textContent = text;
}

function getSID()
{
	var SID;
	
	//initializam obiectul
	var xmlHttp = initAjax();
			
	//daca initializarea a esuat terminam
	if(xmlHttp == undefined)
		return;
			
	//atasam functia care interpreteaza rezultatele
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			if(xmlHttp.status == 200)
			{
				SID = xmlHttp.responseText;								
			}
		}		
	}
			
	//deschidem conexiuniea	
	xmlHttp.open('GET','login.php?gsid=1',false);
	xmlHttp.send(null);
	
	return SID;
}

function toggleParola(disp)
{
	if(disp == 1)
	{
		//show
		document.getElementById('tdToggle').innerHTML = "<a href='' onClick='toggleParola(0); return false;'><img src='img/minus.gif' border='none'></a>";
		document.getElementById('tpass').style.display = "block";
	}
	else
	{
		//hide
		document.getElementById('tdToggle').innerHTML = "<a href='' onClick='toggleParola(1); return false;'><img src='img/plus.gif' border='none'></a>";
		document.getElementById('Parola').value='';
		document.getElementById('tpass').style.display = "none";
	}
}

function subOnEnter(e, location)
{
	var keynum;
	var keychar;
	var numcheck;
	
	if(window.event) // IE
	{
		keynum = e.keyCode;
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
	  keynum = e.which;
	}
	
	if(keynum == 13)
		doLogin(location);	
	
	return true;
}

//functie care valideaza o valoare numerica intreaga
function intreg(evt)
{	
	var charCode = (evt.which) ? evt.which : event.keyCode;							
		
	if(charCode == 13)
		return true;
	
	if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;
			
	return true;			
}

//end functii pentru autentificare

//functii care tin de informatiile din index
ppWnd = null;
function popWindow( source )
{
	if(ppWnd != null )
		ppWnd.close();
	ppWnd = window.open( source, "InfoPlus", "width=680, height=400, menubar=YES, scrollbars=YES, resizable=YES");
//	ppWnd.focus();
}

function loadDocs( source )
{
	/*document.all["informatii"].bgColor = "#006496";
	document.all["Legislatie"].bgColor = "#006496";
	document.all["Program"].bgColor = "#006496";*/
	
	switch( source )
	{
		case 'I':
			//document.all["informatii"].bgColor = "#000000";
			document.docs.document.location = "docs/informatii.htm" ;
		break;
		case 'L':
			//document.all["Legislatie"].bgColor = "#000000";
			document.docs.document.location = "docs/legislatie.php" ;
		break;
		case 'P':
			//document.all["Program"].bgColor = "#000000";
			document.docs.document.location = "docs/program.php" ;
		break;
		case 'D':
			//document.all["Program"].bgColor = "#000000";
			document.docs.document.location = "docs/datornici.htm" ;
		break;	
		case 'F':
			//document.all["Program"].bgColor = "#000000";
			document.docs.document.location = "docs/formular.htm" ;
		break;			
	}
}
//end functii care tin de informatii din index
