function calcul_produse(){
	situatie = document.getElementById('situatie').value;
	
	cantitate = document.getElementById('cantitate').value;
	proc_tva = document.getElementById('proc_tva').value;
	total = document.getElementById('total').value;
	pret_fara_tva = document.getElementById('pret_fara_tva').value;
	pret_cu_tva = document.getElementById('pret_cu_tva').value;
	
	set_proc_tva = (proc_tva/100)+1;
	
	if(situatie == 3){
		set_pret_fara_tva_1 = (total/cantitate);
	
		//Pret fara TVA
 		set_pret_fara_tva = roundNumber(set_pret_fara_tva_1/set_proc_tva,4);
		document.getElementById('pret_fara_tva').value = set_pret_fara_tva;
	
		//Pret cu TVA
		set_pret_cu_tva = roundNumber(set_pret_fara_tva*set_proc_tva,4);
		document.getElementById('pret_cu_tva').value = set_pret_cu_tva;
		
		//Valoarea 
		set_valoarea = roundNumber(set_pret_fara_tva*cantitate,4)
		document.getElementById('valoarea').value = set_valoarea;
		document.getElementById('valoarea_div').innerHTML = set_valoarea;
	
		//TVA
		set_tva_1 = proc_tva/100;
		set_tva = roundNumber(set_valoarea*set_tva_1,4)
		document.getElementById('tva').value = set_tva;
		document.getElementById('tva_div').innerHTML = set_tva;
		
	}else if(situatie == 2){
		total = (pret_cu_tva*cantitate);
		document.getElementById('total').value = total;
		
		set_pret_fara_tva_1 = (total/cantitate);
	
		//Pret fara TVA
 		set_pret_fara_tva = roundNumber(set_pret_fara_tva_1/set_proc_tva,4);
		document.getElementById('pret_fara_tva').value = set_pret_fara_tva;
	
		//Pret cu TVA
		set_pret_cu_tva = pret_cu_tva;
		document.getElementById('pret_cu_tva').value = set_pret_cu_tva;
		
		//Valoarea 
		set_valoarea = roundNumber(set_pret_fara_tva*cantitate,4)
		document.getElementById('valoarea').value = set_valoarea;
		document.getElementById('valoarea_div').innerHTML = set_valoarea;
	
		//TVA
		set_tva_1 = proc_tva/100;
		set_tva = roundNumber(set_valoarea*set_tva_1,4)
		document.getElementById('tva').value = set_tva;
		document.getElementById('tva_div').innerHTML = set_tva;
		
		
	}else if(situatie == 1){
		
		set_pret_cu_tva = pret_fara_tva*set_proc_tva;
		
		total = (pret_cu_tva*cantitate);
		document.getElementById('total').value = total;
		
		
		
		
		set_pret_fara_tva_1 = (total/cantitate);
	
		//Pret fara TVA
 		set_pret_fara_tva = pret_fara_tva;
		document.getElementById('pret_fara_tva').value = set_pret_fara_tva;
	
		//Pret cu TVA
		
		document.getElementById('pret_cu_tva').value = set_pret_cu_tva;
		
		//Valoarea 
		set_valoarea = roundNumber(set_pret_fara_tva*cantitate,4)
		document.getElementById('valoarea').value = set_valoarea;
		document.getElementById('valoarea_div').innerHTML = set_valoarea;
	
		//TVA
		set_tva_1 = proc_tva/100;
		set_tva = roundNumber(set_valoarea*set_tva_1,4)
		document.getElementById('tva').value = set_tva;
		document.getElementById('tva_div').innerHTML = set_tva;
		
		
	}

}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval("self"+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}



function roundNumber2(num, dec) {
	var result = Math.round( Math.round( num * Math.pow( 10, dec + 1) ) / Math.pow( 10, 1 ) ) / Math.pow(10,dec);
	return result;
}


function roundNumber(num,dec){
	var result = Math.round(num*100)/100;
	return result;
}


function calcul_grup_orange(total_pret,comision_fix,comision_variabil,tva,tva_set,div_tva,div_variabil,div_tva_comisioane,div_final){
		
		
		
		total_pret = total_pret-0;
		comision_fix = roundNumber(comision_fix,2);
		
		/*TVA*/
		pret_tva = roundNumber(total_pret*(tva/100),2);
		pret_tva_total = pret_tva-total_pret;
		document.getElementById(div_tva).innerHTML = roundNumber(pret_tva_total,2);
		
		
		/*COMISION VARIABIl*/
		pret_comision_variabil = (pret_tva/100)*comision_variabil;
		pret_comision_variabil_final = roundNumber(pret_comision_variabil,2);
		document.getElementById(div_variabil).innerHTML =  pret_comision_variabil_final+" ("+comision_variabil+"%)";
		
		/*TVA COMISIOANE*/
		pret_total_comisoane = comision_fix+pret_comision_variabil_final;
		pret_tva_comisoane = pret_total_comisoane*(tva/100);
		pret_tva_comisoane_final = pret_tva_comisoane-pret_total_comisoane;
		if(tva_set == '0'){
			pret_tva_comisoane_final = 0;
		}
		document.getElementById(div_tva_comisioane).innerHTML = roundNumber(pret_tva_comisoane_final,2);
		
                /*TOTAL FINAL*/
		total_final = (total_pret+pret_tva_total+comision_fix+pret_comision_variabil_final+pret_tva_comisoane_final);
		document.getElementById(div_final).value = roundNumber(total_final,2);
		
}


function calcul_grup_nou(total_pret,servicii_interiror,comision_fix,comision_variabil,tva,tva_set,div_tva,div_variabil,div_tva_comisioane,div_final){
		
		
		
		total_pret = total_pret-0;
		comision_fix = roundNumber(comision_fix,2);
		
		/*TVA*/
		pret_tva = roundNumber(total_pret*(tva/100),2);
		pret_tva_total = pret_tva-total_pret;
		document.getElementById(div_tva).innerHTML = roundNumber(pret_tva_total,2);
		
		
		/*COMISION VARIABIl*/
		pret_comision_variabil = (pret_tva/100)*comision_variabil;
		pret_comision_variabil_final = roundNumber(pret_comision_variabil,2);
		document.getElementById(div_variabil).innerHTML =  pret_comision_variabil_final+" ("+comision_variabil+"%)";
		
		/*TVA COMISIOANE*/
		pret_total_comisoane = comision_fix+pret_comision_variabil_final;
		pret_tva_comisoane = pret_total_comisoane*(tva/100);
		pret_tva_comisoane_final = pret_tva_comisoane-pret_total_comisoane;
		if(tva_set == '0'){
			pret_tva_comisoane_final = 0;
		}
		document.getElementById(div_tva_comisioane).innerHTML = roundNumber(pret_tva_comisoane_final,2);
		
		
		/*TOTAL FINAL*/
		total_final = (total_pret+pret_tva_total+comision_fix+pret_comision_variabil_final+pret_tva_comisoane_final)-servicii_interiror;
		document.getElementById(div_final).value = roundNumber(total_final,2);
		
}

function calcul_grup_vechi(total_pret,servicii_interiror,comision_fix,comision_variabil,tva,tva_set,div_tva,div_variabil,div_tva_comisioane,div_final){
		
		
		
		
		total_pret = total_pret-0;
		
		comision_fix = roundNumber(comision_fix,2);
		
		/*TVA*/
		pret_tva = roundNumber(total_pret*(tva/100),2);
		pret_tva_total = pret_tva-total_pret;
		document.getElementById(div_tva).innerHTML = roundNumber(pret_tva_total,2);
		
		
		
		/*COMISION VARIABIl*/
		pret_comision_variabil = (pret_tva/100)*comision_variabil;
		pret_comision_variabil_final = roundNumber(pret_comision_variabil,2);
		document.getElementById(div_variabil).innerHTML =  pret_comision_variabil_final+" ("+comision_variabil+"%)";
		
		
		
		
		/*TVA COMISIOANE*/
		pret_total_comisoane = comision_fix+pret_comision_variabil_final;
		pret_tva_comisoane = pret_total_comisoane*(tva/100);
		pret_tva_comisoane_final = pret_tva_comisoane-pret_total_comisoane;
		if(tva_set == '0'){
			pret_tva_comisoane_final = 0;
		}
		document.getElementById(div_tva_comisioane).innerHTML = roundNumber(pret_tva_comisoane_final,2);
		
		
		/*TOTAL FINAL*/
		total_final = (total_pret+pret_tva_total+comision_fix+pret_comision_variabil_final+pret_tva_comisoane_final)-servicii_interiror;
		document.getElementById(div_final).value = roundNumber(total_final,2);
		
}


function ask_url(ask,url){
	var detStatus=confirm(ask);
	if (detStatus){
		    location.href = url;
	}else{
		return false;
	}
}

function ask_form(ask,form_name){
	var detStatus=confirm(ask);
	if (detStatus){
		return true;
	}else{
		return false;
	}
}


function copiaza_adresa(){
	document.getElementById('ac_tara').value = document.getElementById('as_tara').value;
	document.getElementById('ac_judet').value = document.getElementById('as_judet').value;
	document.getElementById('ac_localitate').value = document.getElementById('as_localitate').value;
	document.getElementById('ac_sector').value = document.getElementById('as_sector').value;
	document.getElementById('ac_strada').value = document.getElementById('as_strada').value;
	document.getElementById('ac_nr').value = document.getElementById('as_nr').value;
	document.getElementById('ac_bl').value = document.getElementById('as_bl').value;
	document.getElementById('ac_et').value = document.getElementById('as_et').value;
	document.getElementById('ac_ap').value = document.getElementById('as_ap').value;

}

function fn_show(element,element_div){
	if(document.getElementById(element).checked == true){
		document.getElementById(element_div).style.display='block';
	}else{
		document.getElementById(element_div).style.display='none';
		
	}
}

function fnv_show(element,element_div,val){
	if(document.getElementById(element).value == val){
		document.getElementById(element_div).style.display='block';
	}else{
		document.getElementById(element_div).style.display='none';
		
	}
}

function disable_fna(){
	if(document.getElementById('impozit_micro').checked == true){
		document.getElementById('impozit_profit').disabled = true;
	}else{
		document.getElementById('impozit_profit').disabled = false;
	}
}

function disable_fnb(){
	if(document.getElementById('impozit_profit').checked == true){
		document.getElementById('impozit_micro').disabled = true;
	}else{
		document.getElementById('impozit_micro').disabled = false;
	}
}

function myF(targ,selObj,restore,url){
  eval(targ+".location='"+url+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function CheckAll(form,field)
{
var t=0;
var c=form[field];
for(var i=0;i<c.length;i++){
c[i].checked = true;
}
}

function UnCheckAll(form,field)
{
var t=0;
var c=form[field];
for(var i=0;i<c.length;i++){
c[i].checked = false;
}
}

function cCheck(form,field,rID,text,deleteid) {
var t=0;
var c=form[field];
for(var i=0;i<c.length;i++){
c[i].checked?t++:null;
}

if(t > 0){
	document.getElementById('masive_delete').value = 1;
	document.getElementById(rID).disabled = false;
}else{
document.getElementById('masive_delete').value = 0;
	document.getElementById(rID).disabled = true;
}
if(text){
	document.getElementById(rID).value=  text+" ("+t+")";
}else{
	document.getElementById(rID).value= "Sterge Selectate ("+t+")";
}

}



function Set_Cookie( name, value, expires, path, domain, secure )
{

var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}


