
// main_init function

main_init = function(mc){

 tmpstr = "0," + ( $vspacing ? $linebreak + "," : "" ) + $sub_cnt;
 line_br = tmpstr.split(",");
 line_cnt = line_br.length-1;
 subs_done = true;

 // box function

 box = function ( tl_x, tl_y, br_x, br_y ){
  mask.clear();
  mask.lineStyle();
  mask.beginFill(0);
  mask.moveTo (tl_x,tl_y);
  mask.lineTo (br_x,tl_y);
  mask.lineTo (br_x,br_y);
  mask.lineTo (tl_x,br_y);
  mask.endFill();
  wline.clear();
  wline.lineStyle(0,line_color,line_alpha);
  wline.moveTo (tl_x,br_y);
  wline.lineTo (tl_x,tl_y);
  wline.moveTo (br_x,tl_y);
  wline.lineTo (br_x,br_y);
 }

 // function to set a line

 line_set = function(line){
  line = line % line_cnt;
  line_fc = line_br[line];
  line_lc = line_br[line+1];
  mc = $mmc;
  mc._y = -line * $vspacing;
  b = mc.getBounds(mc);
  xMin = b.xMin;
  xMax = b.xMax;
  yMin = Number.POSITIVE_INFINITY;
  yMax = Number.NEGATIVE_INFINITY;
  for($c=0;$c<$sub_cnt;$c++){
   smc = $smc[$c];
   if ($c >= line_fc && $c < line_lc){
    smc._visible = true;
    b = smc.getBounds(mc);
    yMin = Math.min(yMin,b.yMin + mc._y) ;
    yMax = Math.max(yMax,b.yMax + mc._y);
   } else smc._visible = false;
  }
 }

 // effect specific code

 createEmptyMovieClip("mask",6);
 createEmptyMovieClip("wline",7);
 mc.setMask(mask);
 lframes = max_wide_frames + 2 * wipe_frames;

}



// main_effect function

main_effect = function(mc,frame){

 sf = frame % lframes;
 if (sf == 0 || frame == 1) line_set(Math.floor(frame/lframes));
 if (sf <= wipe_frames){
  p = sf / wipe_frames;
  if (wipe_in < 1){
   box(xMin,yMin,xMin + (xMax-xMin) * p,yMax);
  } else if (wipe_in > 1){
   box(xMax + (xMin-xMax) * p,yMin,xMax,yMax);
  } else {
   box(xMin * p,yMin,xMax * p,yMax);
  }
 } else if (sf >= lframes - wipe_frames){
  p = (lframes - sf) / wipe_frames;
  if (wipe_out < 1){
   box(xMin,yMin,xMin + (xMax-xMin) * p,yMax);
  } else if (wipe_out > 1){
   box(xMax + (xMin-xMax) * p,yMin,xMax,yMax);
  } else {
   box(xMin * p,yMin,xMax * p,yMax);
  }
 }
 if (frame == line_cnt * lframes){
  wline.clear();
  end_effect = true;
 }
}
