function checkUser(cosa,uscita,valore) {
  if (uscita) {
    if (cosa.value=="") {
      cosa.value=valore

    }
  } else {
    cosa.select()
  }
}

function submitRicercaUsato(formId, urlfor)
{
	myLoading();
	var ilForm = $('#'+formId);
	$.ajax({
		type: "POST",
		url: ilForm.attr('action'),
		data: ilForm.serialize(),
		success: function(data){
			$('#ricercaUsatoElenco').html(data);
			$.unblockUI();
		}
	});
	$.ajax({
		type: "GET",
		url: urlfor,
		data: ilForm.serialize(),
		success: function(data){
		}
	});

}

function ordinaRicercaUsato(formId, campo, tipo, a, urlfor)
{
  $("img[src$='Yellow.png']").attr('src', $("img[src$='Yellow.png']").attr('src').replace('Yellow', ''));
  $(a).children().attr('src', $(a).children().attr('src').replace('.png', 'Yellow.png'))
	$('#ricercaUsato_ordina_campo').val(campo);
	$('#ricercaUsato_ordina_tipo').val(tipo);
	submitRicercaUsato(formId, urlfor);
}

function changeUsato(tabOn,tabOff){
  $('#schedaUsato'+tabOn).show();
  $('#schedaUsato'+tabOff).hide();
  $('#tabUsato'+tabOff).attr('class','');
  $('#tabUsato'+tabOn).attr('class','sel');
}

function apriChiudiAlbero(idLi, urlfor, qualeDiv){
  myLoading();
	$('div.exploraDownload a').removeClass('sel');
	$('a#aLiDownload_'+idLi).addClass('sel');
  var ulFiglio = $('#liDownload_'+idLi+' > ul');
  if(ulFiglio.css('display') == 'none'){
    ulFiglio.slideDown();
  }else{
    ulFiglio.slideUp();
  }
  $.ajax({
    type: "GET",
    url: urlfor,
    success: function(data){
      $('#'+qualeDiv).html(data);
     $.unblockUI();
    }
  });
}

function videoGallerySelezioneVideo(urlfor, reload){
	$('#videoGalleryVideo').html('');
	if(reload == undefined){
		myLoading();
	}
  $.ajax({
    type: "GET",
    url: urlfor,
    success: function(data){
      $('#videoGallerySx').html(data);
			if(reload == undefined){
				$.unblockUI();
			}
    }
  });
}

function photoGallerySelezione(urlfor, reload){
	$('#photoGalleryPhoto').html('');
	if(reload == undefined){
		myLoading();
	}
  $.ajax({
    type: "GET",
    url: urlfor,
    success: function(data){
      $('#photoGallerySx').html(data);
			if(reload == undefined){
				$.unblockUI();
			}
    }
  });
}

