
// main_init function

main_init = function(mc){

 subs_done = true;
 wms = deg90 * water_motion_speed / 100;
 c1 = water_color1; a1 = water_alpha1;
 c2 = water_color2; a2 = water_alpha2;

 createEmptyMovieClip('water',6);
 mc.duplicateMovieClip('mask',7);
 water.setMask(mask);

 a = 0; b = mc.getBounds(mc);
 w = b.xMax - b.xMin;
 h = b.yMax - b.yMin;
 end_y = b.yMin-10;
 if (solid_color_end) end_y-=h;

 var colors = new Array();
 var alphas = new Array();
 var ratios = new Array();

 for(i=0; i<water_levels; i++){
  colors[i*2] = c1;
  colors[i*2+1] = c2;
  alphas[i*2] = a1;
  alphas[i*2+1] = a2;
  ratios[i*2] = (i*2)/(water_levels*2-1) * 255;
  ratios[i*2+1] = (i*2+1)/(water_levels*2-1) * 255;
 }
 var matrix = {matrixType:'box',w:+w,h:+h,x:b.xMin-150,y:0,r:+deg90};

 water._y = b.yMax+3;

 water.lineStyle(1,water_line_color,water_line_alpha);
 water.beginGradientFill('linear',colors,alphas,ratios,matrix);
 water.moveTo(b.xMin-150,0);

 for (x=b.xMin-150; x<b.xMax+150; x+=water_wave_length){
  water.lineTo(x,Math.sin(a)*(2+Math.random()));
  a += deg45;
 }

 water.lineTo(x+water_wave_length,2*h+20);
 water.lineTo(b.xMin-150,2*h+20);
 water.endFill();

 mc._alpha = original_alpha;

}

// main_effect function

main_effect = function(mc,frame){
 if (water._y > end_y && !rocking){
  water._x = Math.sin(a) * 100;
  water._y -= water_fill_speed;
 } else {
  if (!rocking){
   a = 0;
   rocking = true;
   water.__y = water._y;
   if (solid_color_end) end_effect = true;
  }
  water._y = water.__y+Math.sin(a)*3;
 }
 a += wms;
}

// sub_init function

sub_init = function(mc){
}

// sub_effect function

sub_effect = function(mc,frame){
}

