
/**
 * Fotos admin
 **/
var flag_campo = 1;
function add_foto_campo (legenda){
	var num_fotos = jQuery('#qtd_fotos').val();
	num_fotos = (parseInt(num_fotos)+1);
	
	jQuery('#qtd_fotos').val(num_fotos);
	
	var tmp = [];
	
	tmp.push('<div id="fotos_'+num_fotos+'" >');
	tmp.push('<label class="type_01" for="foto_'+num_fotos+'">Foto:</label>');
	tmp.push('<input type="file" name="foto_'+num_fotos+'" id="foto_'+num_fotos+'"/><br/>');
	if(legenda==true)
	{
		tmp.push('<label class="type_01" for="legenda_'+num_fotos+'">Legenda: </label>');
		tmp.push('<textarea name="legenda_'+num_fotos+'" id="legenda_'+num_fotos+'" onkeyup="conta_limite(this,255,\'#conta_legenda_'+num_fotos+'\');" style="width:200px; height: 60px;"></textarea>');
		tmp.push('<span id="conta_legenda_'+num_fotos+'" class="exemplos">0 / 255</span>');
	}
	//tmp.push('<a href="javascript:void(0)" onClick="$(this).parent().remove();">remover</a>');
	tmp.push('</div><br/>');
	
	jQuery('#fotos_campos').append(tmp.join(''));
	
	//alert($('#qtd_fotos').val());
}

function conta_limite(campo,max,div_limit)
{
	var total = max;
	//alert(campo.value.length);
	if(campo.value.length > max)
	{
		alert('Limite de caracteres foi atingido.');
		campo.value = campo.value.substr(0,max);
	}

	if(div_limit=='')	
		jQuery('#limite_maximo').html(campo.value.length+' / '+max);
	else
		jQuery(div_limit).html(campo.value.length+' / '+max);
}


