

function hideEmpty(id){
if( $('f#'  + id + ':empty' ).length==1 )
{
  $("div.policy h2[fid=" + id + "]" ).parent().hide();
  $('#field' +id +' a').replaceWith($('#field'+id+' a').text() );
}
else
{
  $('li:odd' ).find('#field' +id ).removeClass('policy-odd-no' ).addClass('policy-odd-yes' ).addClass('selected');
  $('li:even').find('#field' +id ).removeClass('policy-even-no').addClass('policy-even-yes').addClass('selected');

}

//$('.policy-odd-no .selected')

} // hideEmpty

function profile_loader(){



var ids = [ 93,94,95,123,124,125,126 ];

$.each(ids, function(ndx, val) {

  $("div.policy h2[fid=" + val + "]" )
   .next() 
   .append(
        qdb_data[0][ndx].replace(/o\t/g,'<li>').replace(/\n/g,'<p>')
    );

    if(qdb_data[0][ndx].length==0) {
          $("div.policy h2[fid=" + val + "]" ).parent().hide();
          $('#field' +val +' a').replaceWith($('#field'+val+' a').text() );
    } else {
          $('#field' +val).addClass('selected');
    } 

} );




$('div.policyframework ul:eq(0) a').each(function() { 

var selector =  $(this).attr('href').replace('#','#sectionAnchor');

if ( $(selector).length == 0 ) {

$(this).replaceWith($(this).text());

} else {

  var p = $(this).parent().addClass('selected');
 
}

 } ); //each




$('.tworightalt table').find('tr:even').addClass('odd');
$('.tworightalt table').find('tr:odd').addClass('even');

$('.tworightalt table').find('tr:last').removeClass('even').removeClass('odd');
$('.tworightalt table').find('tr:last').attr('class','none').find('td').attr('class','none').css('font-weight','bold');

var equalMsg = $("#equalPartsMessage:last");
$(".twoleftalt:has(span.estimated_dollars)")
  .each(
     function(){
       equalMsg.clone()
         .addClass('shown')
         .insertAfter( $(this).next().find("table") );

} );




//TODO: Make sure load caches XML, otherwise revert to $.get

//reset in-page defaults
$('div.policyframework ul').find('li').removeClass('policy-odd-no').removeClass('policy-even-no');

$('div.policyframework ul').find('li:odd.selected').addClass('policy-odd-yes');
$('div.policyframework ul').find('li:even.selected').addClass('policy-even-yes');
$('div.policyframework ul').find('li:even:not(.selected)').addClass('policy-even-no');
$('div.policyframework ul').find('li:odd:not(.selected)').addClass('policy-odd-no');


$('#allPolicy').attr('class','policy-last');

$('body').attr('id','tabtwo');


$('body.UT #equalPartsMessage').text('Dollars spent by Utah State Parks were not provided.'); 


} //domready

