function showImage(img,x,y)
{
	var left = Math.floor((screen.availWidth - x -30) / 2);
	var top = Math.floor((screen.availHeight - y -30) / 2);
	window.open('popup/show_img.php?img=' + img + '&x=' + x + '&y=' + y, 'screenshot', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=' + (x + 30) + ', height=' + (y + 30) + ',left=' + left + ',top=' + top).focus();
}
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   showLabel('EmailErr','Formatul adresei de email nu este corect')
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   showLabel('EmailErr','Formatul adresei de email nu este corect')
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    showLabel('EmailErr','Formatul adresei de email nu este corect')
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    showLabel('EmailErr','Formatul adresei de email nu este corect')
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    showLabel('EmailErr','Formatul adresei de email nu este corect')
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    showLabel('EmailErr','Formatul adresei de email nu este corect')
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    showLabel('EmailErr','Formatul adresei de email nu este corect')
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	

	//validare email
	var emailID=document.contnou.email
	
	if ((emailID.value==null)||(emailID.value=="")){
		showLabel('EmailErr','Informatie obligatorie lipsa: Adresa de email')
		emailID.focus()
		return false
	}
	else
	{
		hideLabel('EmailErr')
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	else
	{
		hideLabel('EmailErr')
	}

	//validare parola

	var parolaID = document.contnou.parola
	var parolaID2 = document.contnou.parola2

	if ((parolaID.value==null)||(parolaID.value=="")){
		showLabel('ParolaErr','Informatie obligatorie lipsa: Parola')
		parolaID.focus()
		return false
	}
	else
	{
		hideLabel('ParolaErr')
	}

	if ((parolaID2.value==null)||(parolaID2.value=="")){
		showLabel('Parola2Err','Informatie obligatorie lipsa: Verificare Parola')
		parolaID2.focus()
		return false
	}
	else
	{
		hideLabel('Parola2Err')
	}

	if (parolaID2.value != parolaID.value)
	{
		showLabel('Parola2Err','Parole distincte!')
		parolaID2.focus()
		return false	
	}
	else
	{
		hideLabel('Parola2Err')
	}

	var numeID = document.contnou.nume
	if ((numeID.value==null)||(numeID.value=="")){
		showLabel('NumeErr','Informatie obligatorie lipsa: Nume')
		numeID.focus()
		return false
	}
	else
	{
		hideLabel('NumeErr')
	}

	var prenumeID = document.contnou.prenume
	if ((prenumeID.value==null)||(prenumeID.value=="")){
		showLabel('PrenumeErr','Informatie obligatorie lipsa: Prenume')
		prenumeID.focus()
		return false
	}
	else
	{
		hideLabel('PrenumeErr')
	}

	var adresaID = document.contnou.adresa
	if ((adresaID.value==null)||(adresaID.value=="")){
		showLabel('AdresaErr','Informatie obligatorie lipsa: Adresa')
		adresaID.focus()
		return false
	}
	else
	{
		hideLabel('AdresaErr')
	}
	
	var localitateID = document.contnou.localitate
	if ((localitateID.value==null)||(localitateID.value=="")){
		showLabel('LocalitateErr','Informatie obligatorie lipsa: Localitate')
		localitateID.focus()
		return false
	}
	else
	{
		hideLabel('LocalitateErr')
	}

	return true
 }

//check email address
function CheckEmail(e)
{
	//validare email
	var emailID=document.contnou.email
	
	if ((emailID.value==null)||(emailID.value=="")){
		showLabel('EmailErr','Informatie obligatorie lipsa: Adresa de email')
		emailID.focus()
		return false
	}
	else
	{
		hideLabel('EmailErr')
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	else
	{
		hideLabel('EmailErr')
	}

}

//show label with text
function showLabel(lab, message)
{
    
    document.getElementById(lab).innerHTML = message;
    document.getElementById(lab).style.display='';
    
    var row = "Row"+lab;
    document.getElementById(row).style.display='';
   
}

function showLabelSimple(lab)
{
  	
    var row = "Row"+lab;
    document.getElementById(row).style.display="";
   
}

function hideLabelSimple(lab)
{
    
     var row = "Row"+lab
     document.getElementById(row).style.display='none';
    
}
//hide label
function hideLabel(lab)
{
    
     document.getElementById(lab).style.display='none';
     var row = "Row"+lab
     document.getElementById(row).style.display='none';
    
}
function termeni_conditii(){
	var tc = document.comanda.acord;
	if(tc.checked == false){
		alert('Trebuie sa fiti de acord cu termenii si conditiile');
		return false;
	}
}

function ValidareFormularComanda()
{
	var altaAdr = document.comanda.acord;
	if( altaAdr.checked == false)
	{
		alert('Trebuie sa fiti de acord cu Termenii si Conditiile!');
		return false;
	}
	
	
	var altaAdr = document.comanda.optiune;
	if( altaAdr.checked)
	{
		var adresaID = document.comanda.Adresa
	if ((adresaID.value==null)||(adresaID.value=="")){
		showLabel('AdresaErr','Informatie obligatorie lipsa: Adresa')
		adresaID.focus()
		return false
	}
	else
	{
		hideLabel('AdresaErr')
	}
	
	var localitateID = document.comanda.Localitate
	if ((localitateID.value==null)||(localitateID.value=="")){
		showLabel('LocalitateErr','Informatie obligatorie lipsa: Localitate')
		localitateID.focus()
		return false
	}
	else
	{
		hideLabel('LocalitateErr')
	}
	


	var JudetID = document.comanda.Judet
	if ((JudetID.value==null)||(JudetID.value=="")){
		showLabel('JudetErr','Informatie obligatorie lipsa: Judet')
		JudetID.focus()
		return false
	}
	else
	{
		hideLabel('JudetErr')
	}
	}
	

return true;
}

//arata sau ascunde adresa noua
function clickCheckBox()
{
	var altaAdr = document.comanda.optiune;
	if( altaAdr.checked)
	{		
		showLabelSimple('Companie')	
		showLabelSimple('CifCui')
	}
	else
	{
		hideLabelSimple('Companie')
		hideLabelSimple('CifCui')
	}
}


function dual_submit(){
   var f = document.forms[0];
   f.setAttribute('target','_myHidFrame');
   f.setAttribute('action', 'your url');
   f.submit();

   f.setAttribute('target','_self');
   f.setAttribute('action','secure url');
   f.submit();

}

function showlinie(event)
		{
			if(document.getElementById('linie1').style.display == 'none')
			{
				document.getElementById('linie1').style.display = '';
			}
			else
			{
				document.getElementById('linie1').style.display = 'none';
			}
		}
function showlinie2(event)
		{
			if(document.getElementById('linie2').style.display == 'none')
			{
				document.getElementById('linie2').style.display = '';
			}
			else
			{
				document.getElementById('linie2').style.display = 'none';
			}
		}
function showlinie3(event)
		{
			if(document.getElementById('linie3').style.display == 'none')
			{
				document.getElementById('linie3').style.display = '';
			}
			else
			{
				document.getElementById('linie3').style.display = 'none';
			}
		}
function showlinie4(event)
		{
			if(document.getElementById('linie4').style.display == 'none')
			{
				document.getElementById('linie4').style.display = '';
			}
			else
			{
				document.getElementById('linie4').style.display = 'none';
			}
		}
function sbt(event)
{
	document.client.submit();

}