function contorizare_descriere(text)
{
	var ramas;
	var text;
	lungime = text.length;
	ramas  = 1000 - lungime;
	document.getElementById('contorizare-caractere').innerHTML = ramas + ' caractere ramase';
	if(ramas <= 0)
	{
		document.getElementById('descriere').value = text.substring(0,999);
	}
}

function getOrase(initiale)
{
		$('#anunt-oras').html('');
		if(!initiale)
		{
			
			$('#oras').attr("disabled","disabled");
		}
		else
		{
			$('#anunt-oras').html('');
			$('#anunt-oras').attr("disabled","");
			$('#anunt-oras').attr("enabled","enabled");
			//$('#anunt-oras').append('<option value="">-Alege Localitatea-</option>');
			$.post(siteUrl+"user/getOras/"+initiale,function(orase){
													 $('#anunt-oras').append(orase);
													 });
				
		}
}
function getLocalitate(judet)
{
		$('#anunt-oras').html('');
		if(!judet)
		{
			
			$('#oras').attr("disabled","disabled");
		}
		else
		{
			$('#anunt-oras').html('');
			$('#anunt-oras').attr("disabled","");
			$('#anunt-oras').attr("enabled","enabled");
			//$('#anunt-oras').append('<option value="">-Alege Localitatea-</option>');
			$.post(siteUrl+"user/getLocalitate/"+judet,function(orase){
													 $('#anunt-oras').append(orase);
													 });
				
		}
}
/*function add_more()
{	
	nr_poz++;
	var txt = '';
	if(nr_poz<=15)
	{		
		txt += '<input type="file" name="photo'+nr_poz+'" id="photo'+nr_poz+'" onchange="return testImg();" class="input-content-anunt" ><br>';
		document.getElementById('add-foto').innerHTML += '<div class="content-content-anunt-titlu">Poza: '+nr_poz+'</div>'+txt ;
	}
	else
	{
		alert('Nu poti adauga mai mult de 15 poze!');
		stop();
	}
}
function Reset()
{
	nr_poz = 1;
	document.getElementById('photo1').value = '';
	document.getElementById('add-foto').innerHTML = '';
}*/


function getModele(marca)
{
	//alert(marca);
	//marca = parseInt(marca);
	 $('#anunt-model').html('');
	if(!marca)
	{
	   //$('#anunt-model').html('');
	   $('#anunt-model').attr("disabled","disabled");
	}
	else
	{
		//$('#anunt-model').html('');	
		$('#anunt-model').attr("disabled","");
		$('#anunt-model').attr("enabled","enabled");
		//$('#anunt-model').append('<option value="">-Alege Localitatea-</option>');
		$.post(siteUrl+"user/getModel/"+marca,function(modele){
													  $('#anunt-model').append(modele);
													  });
	}
}


function getSubCateg(categoria)
{
	$('#subcategoria').html('');
	if(!categoria)
	{
		$('#subcategoria').attr("disabled","disabled");
	}
	else
	{
		$('#subcategoria').attr("disabled","");
		$('#subcategoria').attr("enabled","enabled");
		$.post(siteUrl+"user/getSubcateg/"+categoria,function(subcategoria){
															  	$('#subcategoria').append(subcategoria);
															  });
	}
}




























/*function getModele(marca)
{
 $('#anunt-model').html('');
 marca = parseInt(marca);
 if (marca > 0) {

 $('#anunt-model').attr('enabled', true);
 $('#anunt-model').removeAttr('disabled');
 $.post(siteUrl+"user/getModel/"+marca,
 function (data)
 {
 jQuery.each(data, function(key, value)
 {
 $('#anunt-model').append($("<option></option>").attr("value",key).text(value));
 });

 }
 , "json");
 } else {
 $("#anunt-model").attr('disabled', true);
 $('#anunt-model').removeAttr('enabled');
 }
 return false;
}*/
/*function getModelee(marcaa)
{
	//alert(marca);
	//marca = parseInt(marca);
	if(!marca)
	{
	   $('#anunt-modele').html('');
	   $('#anunt-modele').attr("disabled","disabled");
	}
	else
	{
		$('#anunt-modele').html('');	
		$('#anunt-modele').attr("disabled","");
		$('#anunt-modele').attr("enabled","enabled");
		//$('#anunt-model').append('<option value="">-Alege Localitatea-</option>');
		$.get(siteUrl+"user/getModele/"+marcaa,function(modelee){
													  $('#anunt-modele').append(modelee);
													  });
	}
}*/

// marca
	//val = $('#anunt-marca').val();
	/*if( $('#anunt-marca').val())
	{
		$('#marca').attr('class','form-image-anunt-ok');
	}
	else
	{
		$('#marca').attr('class','form-image-anunt-x');
	}*/
	//var valAnunt = document.getElementById('anunt-marca').value;
	/*if(document.getElementById('anunt-marca').value != 'alege')
	{
		var dval = document.getElementById('marca');
		dval.setAttribute('class','form-image-anunt-ok');
	}
	else
	{
		var dval = document.getElementById('marca');
		dval.setAttribute('class','form-image-anunt-x')
	}*/

//---------------------------------------------------------------------------------------------------

/*function fillModele(idBrand){
	idBrand = parseInt(idBrand);
	if(!idBrand){
		$('#addanunt-Anunt-model_id').html('');
		$('#addanunt-Anunt-model_id').attr("disabled","disabled");
	}
	
	if (idBrand > 0) {
		$('#addanunt-Anunt-model_id').html('');
		$('#addanunt-Anunt-model_id').attr("disabled","");
		$('#addanunt-Anunt-model_id').attr("enabled","enabled");
		$('#addanunt-Anunt-model_id').append('<option value="">alege Modelul</option>');
			$.get("/default/default/id-modele-by-brand/brandID/" + idBrand, function(modele){
		  			$('#addanunt-Anunt-model_id').append(modele);
		});	
	}
}

function fillModele2(idBrand){
	idBrand = parseInt(idBrand);
	if(!idBrand){
		$('#Anunt-model_id').html('');
		$('#Anunt-model_id').attr("disabled","disabled");
	}
	
	if (idBrand > 0) {
		$('#Anunt-model_id').html('');
		$('#Anunt-model_id').attr("disabled","");
		$('#Anunt-model_id').attr("enabled","enabled");
		$('#Anunt-model_id').append('<option value="">alege Modelul</option>');
			$.get("/default/default/id-modele-by-brand/brandID/" + idBrand, function(modele){
		  			$('#Anunt-model_id').append(modele);
		});	
	}
}


function fillModele3(idBrand, modelID){
	idBrand = parseInt(idBrand);
	if(!idBrand){
		$('#Anunt-model_id').html('');
		$('#Anunt-model_id').attr("disabled","disabled");
	}
	
	if (idBrand > 0) {
		$('#Anunt-model_id').html('');
		$('#Anunt-model_id').attr("disabled","");
		$('#Anunt-model_id').attr("enabled","enabled");
		$('#Anunt-model_id').append('<option value="">alege Modelul</option>');
			$.get("/default/default/id-modele-by-brand/brandID/" + idBrand, function(modele){
		  			$('#Anunt-model_id').append(modele);
		  			$('#Anunt-model_id').children('option').each(function(){
		  				id = $(this).val().split('-')[1];
		  				if(id == modelID) $(this).attr('selected', 'selected');
		  			});
		  			
		});	
	}
}


function enable_inmatriculare(val){
	
	if(val=='DA'){
			$('#addanunt-Anunt-luna_inmatriculare').attr("disabled","");
			$('#addanunt-Anunt-luna_inmatriculare').attr("enabled","enabled");
			$('#addanunt-Anunt-an_inmatriculare').attr("disabled","");
			$('#addanunt-Anunt-an_inmatriculare').attr("enabled","enabled");
	} else {
			$('#addanunt-Anunt-luna_inmatriculare').attr("enabled","");
			$('#addanunt-Anunt-luna_inmatriculare').attr("disabled","disabled");
			$('#addanunt-Anunt-luna_inmatriculare').val("");
			$('#addanunt-Anunt-an_inmatriculare').attr("enabled","");
			$('#addanunt-Anunt-an_inmatriculare').attr("disabled","disabled");
			$('#addanunt-Anunt-an_inmatriculare').val("");
	}
}

function enable_inmatriculare2(val){
	
	if(val=='DA'){
			$('#Anunt-luna_inmatriculare').attr("disabled","");
			$('#Anunt-luna_inmatriculare').attr("enabled","enabled");
			$('#Anunt-an_inmatriculare').attr("disabled","");
			$('#Anunt-an_inmatriculare').attr("enabled","enabled");
	} else {
			$('#Anunt-luna_inmatriculare').attr("enabled","");
			$('#Anunt-luna_inmatriculare').attr("disabled","disabled");
			$('#Anunt-luna_inmatriculare').val("");
			$('#Anunt-an_inmatriculare').attr("enabled","");
			$('#Anunt-an_inmatriculare').attr("disabled","disabled");
			$('#Anunt-an_inmatriculare').val("");
	}
}
function enable_inmatriculare3(val){
	
	if(val=='DA'){
			$('#Anunt-luna_inmatriculare').attr("disabled","");
			$('#Anunt-luna_inmatriculare').attr("enabled","enabled");
			$('#Anunt-an_inmatriculare').attr("disabled","");
			$('#Anunt-an_inmatriculare').attr("enabled","enabled");
	} else {
			$('#Anunt-luna_inmatriculare').attr("enabled","");
			$('#Anunt-luna_inmatriculare').attr("disabled","disabled");
			$('#Anunt-luna_inmatriculare').val("");
			$('#Anunt-an_inmatriculare').attr("enabled","");
			$('#Anunt-an_inmatriculare').attr("disabled","disabled");
			$('#Anunt-an_inmatriculare').val("");
	}
}*/

/*
function createNewFotoDiv()
{
	elem = document.getElementById('add-foto');
	var newdiv = document.createElement('div');
	var x = elem.getElementsByTagName('div').length+3;
	var child = x/3;
     child++;
	
	 	document.getElementById('nr_foto1').innerHTML = child;

	//document.getElementById('idfoto').innerHTML = i;
	//alert(child);
	if(child<=15)
	{
		newdiv.setAttribute('id','f'+child);
		newdiv.setAttribute('class','content-content-anunt');
		newdiv.innerHTML = document.getElementById('f1').innerHTML;
		myfoto = newdiv.getElementsByTagName('input');
		myfoto.namedItem('foto').setAttribute('id','foto'+child);
		elem.appendChild(newdiv);
	}
	else
	{
		alert('Puteti adauga maxim 15 poze!');
	}
	//return child;
	//return i;
}*/
