  var sMainDiv="maino";

  $(document).ready(function(){
$.log (".ready ice_script.js ice_avail:"+ice_avail);
    if (ice_avail) {
      /* init by hiding stuff */    
      $('.no_jQuery').hide();
      $('#eic, .btn_ice_preview').hide();
      
      /* hide divs specific to this web page: #maino */
      $('.btn_ice_preview').click(function() {
  
  alert("btn_ice_preview");
          srl_copy();
          ice_mode=true;
        $('.btn_ice_preview, #'+sMainDiv).fadeOut(150,
          function() {
            $('#eic').fadeIn(150);
          });
      });
  
  var iWantTxt;
  var sTitle;
  var oSpan; // the span we will edit
  
      // admin wants to edit
      $('.btn_iceXX').click(function() {
          ice_mode=true;
          $(this).next().removeClass("ice_hilite");
          
          var x=$(this).attr("lang");
$.log("btn_ice clicked: "+x);
          ice_work=x.split("#");
          ice_id=ice_work[0];
          sMainDiv=ice_work[1];
          sTitle=ice_work[2];
          iWantTxt=(ice_work[3]=="txt")?true:false;
          
          cmsIDfield="id";
          img_clean=0; //don't clean up image paths
  
          if (iWantTxt) {
            oSpan = $(this).next(); //.find(".daText");
            sTheTxt=oSpan.html();

            $('#eicTxt legend').text(" "+sTitle+" ");
            $('#eicTxt #title').val(sTheTxt);

$.log (ice_work+" << "+sTheTxt+" >> ");
            
            oSpan.hide();
            $('.btn_ice').hide();
            $('#eicTxt').insertAfter(this);
            $('#eicTxt').fadeIn(150);  
            
          } else {
             $.log ("ice_script.js: "+cmsIDfield+" = "+ice_id);
          r5EditRow (cmsIDfield,ice_id,img_clean);
  $.log ("post editrow");
  
            $('#eic')
              .insertAfter($('#'+sMainDiv));              
                           /*
              .data("alias",oName)
              .data("category",oSection)
              .data("title",oTitle)
              .data("content",oMain) 
                           ); // position works for all
                           */
  
            $('.btn_ice, #'+sMainDiv).fadeOut(150,
              function() {
                 $('#eic').fadeIn(150);  
            });
 
          }         
          return false;
      });
  
    }
  });
  
  
    /* return to normal view */
    function srl_exit (iPreview) {
      if (ice_mode) {
        $('#eic').fadeOut(150,
        function() {
          $('#'+sMainDiv).fadeIn(150);
          
          if (iPreview) {
            $('.btn_ice_preview').show();
          } else {
            $('.btn_ice').show();
          }
          ice_mode=false;
        });
      } else {
        $('#btnSRLcancel').trigger('click');
      }
    }
    
    /* copy fields */
    function srl_copy () {
  
alert("srl_copy");
  
      $('.headL').html($("#section").val());
      $('.headR').html($("#title").val());
      
      if (ice_div=="ContentRight") {
        $('#'+sMainDiv).html($("#content").val( ));
      } else {
        $('#linko').html($("#content").val( ));
      }
    }
  
   /* restore fields */
    function srl_restore () {
      $('.headL').html($("#eic").data("section"));
      $('.headR').html($("#eic").data("title"));
      $("#eic").data("live",false);
  
      if (ice_div=="ContentRight") {
        $('#'+sMainDiv).html($("#eic").data("content"));
      } else {
        $('#linko').html($("#eic").data("content"));
      }
    }
