//**********************************************/
//
//   Copyright 2008-2010, Flea Circus Games
//
//   All rights reserved
//
//   This code may not be used, in whole or
//   in part, without permission.
//
//
//**********************************************/
var RELEASE_DIR = "";
var ie = (document.all) ? true : false;
var ie7 = (ie && window.XMLHttpRequest) ? true : false;
var ie6 = (ie && ! ie7) ? true : false;
var ns6 = document.getElementById && ! ie;
var webkit = navigator.userAgent.indexOf("AppleWebKit") > -1;
var isChrome = navigator.userAgent.indexOf("Chrome") > -1;
var EDITOR_VERSION = "1.42";
var IS_DEMO = false;
var MODE_VIEW = 0;
var MODE_EDIT = 1;
var THROTTLE_SPACE_BAR = false;
var FIELD_SIZE_X = 876;
var FIELD_SIZE_Y = 450;
var MARCHER_SIZE_X = 18;
var MARCHER_SIZE_Y = 36;
var SET_BLOCK_SIZE_X = 19;
var MAX_SETS = 32;
var MIN_SETS = 8;
var MAX_SETS_PREMIUM = 40;
var SET_BLOCK_SIZE_X_PREMIUM = 15;
var FRAME_MILLISECS = 1000;
var FRAME_MIN_MILLISECS = 275;
var FRAME_STEP_MILLISECS = 275;
var MAX_TWEEN_GAP_MS = 100;
var MAX_ANIM_GAP_MS = 150;
var FPS_DEFAULT = 30;
var FPS_IE = 40;
var PIXELS_PER_SEC = 100;
var MIN_TOSS_MILLISECS = 2000;
var MAX_GUARD_PER_SHOW = 36;
var BORDER_COLOR = "#3C8C3C";
var BORDER_COLOR_DARKER = "#398939";
var HASH_NONE = 0;
var HASH_HORIZONTAL = 1;
var HASH_VERTICAL = 2;
var DEFAULT_GRID = 1;
var NUM_GRIDS = 2;
var GRID_X_NAME = [ "<span style=\"color: #543\">OFF</span>", "ON"  ];
var GRID_X = [1, 9 ];
var GRID_X_NUDGE = [0, 1];
var SAVE_HEARTBEAT_MINS = 0.5;
var SAVE_HEARTBEATS = 10;
var AJAX_TIMEOUT_SECS = 16;
var MOUSE_DOWN = false;
var SET_CONFIG_PAUSE = 0;
var SET_CONFIG_PACE = 1;
var NUM_STEPS_PACE = 3;
var NUM_STEPS_PAUSE = 4;
var MARCHER_X = 0;
var MARCHER_Y = 1;
var NUM_GUARD_UNIFORMS = 6;
var NUM_IMG_FRAMES_GENERAL = 8;
var NUM_HORN_TYPES = 4;
var NUM_HORN_TYPES_PREMIUM = 8;
var MARCHER_STATE_SET = 0;
var MARCHER_STATE_PLAYING = 1;
var FRAME_BRASS_SET = 0;
var FRAME_BRASS_PLAY = 1;
var FRAME_SNARE_SET = 0;
var FRAME_SNARE_PLAY1 = 1;
var FRAME_SNARE_PLAY2 = 2;
var FRAME_TENOR_SET = 3;
var FRAME_TENOR_PLAY1 = 4;
var FRAME_TENOR_PLAY2 = 5;
var FRAME_PLATES_SET = 6;
var FRAME_PLATES_PLAY1 = 6;
var FRAME_PLATES_PLAY2 = 7;
var FRAME_BASS_LEFT = 0;
var FRAME_BASS_RIGHT = 1;
var FRAME_BASS_FRONT = 2;
var FRAME_GUARD_SET = 0;
var FRAME_GUARD_WORK = 1;
var SECTION_BRASS = 0;
var SECTION_SNARE = 1;
var SECTION_TENOR = 2;
var SECTION_BASS = 3;
var SECTION_GUARD = 4;
var SECTION_PLATES = 5;
var SECTION_PROP = 6;
var ANIM_SPEED_MS = [];
ANIM_SPEED_MS[SECTION_GUARD] = 50;
ANIM_SPEED_MS[SECTION_SNARE] = 150;
ANIM_SPEED_MS[SECTION_TENOR] = 300;
ANIM_SPEED_MS[SECTION_PLATES] = 250;
ANIM_SPEED_MS[SECTION_BASS] = 0;
ANIM_SPEED_MS[SECTION_BRASS] = 0;
ANIM_SPEED_MS[SECTION_PROP] = 0;
var MARCHER_STATE_NAME = ["ATTENTION", "PLAYING"];
var HORN_NAME = [ "MELLOPHONE", "SOPRANO", "CONTRABASS", "BARITONE", "TROMBONE", "SAXOPHONE", "CLARINET", "FLUTE" ];
var CAPTION_LABEL = {};
CAPTION_LABEL[SECTION_BRASS] = 'Horns';
CAPTION_LABEL[SECTION_SNARE] = 'Snares';
CAPTION_LABEL[SECTION_TENOR] = 'Tenors';
CAPTION_LABEL[SECTION_BASS] = 'Basses';
CAPTION_LABEL[SECTION_GUARD] = 'Guard';
CAPTION_LABEL[SECTION_PLATES] = 'Cymbals';
var EQUIPMENT_FLAG = 0;
var EQUIPMENT_RIFLE = 1;
var EQUIPMENT_SABRE = 2;
var ANIM = [];
ANIM[EQUIPMENT_FLAG] =
[
{  name : 'Pose', pose : 1, frames : [ 0 ], offset : [0,-6, 0], animSpeedMS : 50, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0 },
{  name : 'Pose', pose : 1, frames : [ 8 ], offset : [0,-6, 0], animSpeedMS : 50, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0 },
{  name : 'Pose', pose : 0, frames : [ 6 ], offset : [-2, 2, 0], animSpeedMS : 50, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0 },
{  name : 'Pose', pose : 0, frames : [ 14 ], offset : [ 2, 2, 0], animSpeedMS : 50, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0 },
{  name : 'Pose', pose : 3, frames : [ 16 ], offset : [0,-6, 0], animSpeedMS : 50, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0 },
{  name : 'Pose', pose : 0, frames : [ 17 ], offset : [0, 0, 0], animSpeedMS : 50, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0 },
{  name : 'Pose', pose : 2, frames : [ 7 ], offset : [-4, -5, 0], animSpeedMS : 50, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0 },
{  name : 'Pose', pose : 1, frames : [ 15 ], offset : [4, -5, 0], animSpeedMS : 50, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0 },
{  name : 'Pose', pose : 0, frames : [ 5 ], offset : [-10, 5, 0], animSpeedMS : 50, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0 },
{  name : 'Pose', pose : 0, frames : [ 13 ], offset : [ 10, 5, 0], animSpeedMS : 50, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0 },
{  name : 'Spin R', pose : 1, frames : [ 7,0,1,2,3,4,5,6, 7,0,1,2,3,4,5,6 ], animSpeedMS : 80, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, syncOffset : +1 },
{  name : 'Spin L', pose : 1, frames : [ 15,8,9,10,11,12,13,14, 15,8,9,10,11,12,13,14 ], animSpeedMS : 80, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, syncOffset : -1 },
{  name : 'Sweep R', pose : 1, frames : [ 3,4,5,6, 11,12,13,14, 3,4,5,6, 7,0,1,2,3,4,5,6, 11,12,13,14, 3,4,5,6, 11,12,13,14, 15,8,9,10,11,12,13,14 ], animSpeedMS : 100, loopSpeedMS : 0, subloopFrame : 19, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, syncOffset : +1 },
{  name : 'Sweep L', pose : 1, frames : [ 11,12,13,14, 3,4,5,6, 11,12,13,14, 15,8,9,10,11,12,13,14, 3,4,5,6, 11,12,13,14, 3,4,5,6, 7,0,1,2,3,4,5,6  ], animSpeedMS : 100, loopSpeedMS : 0, subloopFrame : 19, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, syncOffset : -1 },
{  name : 'Wave R', pose : 1, frames : [ 6,7,0,1,2,15, 8,9,10, 7,0,1,2, 14,14, 15,8,9,10, 6,7,0,1,15,8,9,10, 6 ], animSpeedMS : 100, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, syncOffset : +1 },
{  name : 'Wave L', pose : 1, frames : [ 14,15,8,9,10, 6,7,0,1,15,8,9,10, 6,6, 7,0,1,2,15, 8,9,10, 7,0,1,2, 14 ], animSpeedMS : 100, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, syncOffset : -1 },
{  name : 'Wave Once R', pose : 1, frames : [ 6,7,0,1,2,3, 13  ], animSpeedMS : 80, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, fnf : true, FFRXHX : 0, loopNum : 0, syncOffset : +1 },
{  name : 'Wave Once L', pose : 1, frames : [ 14,15,8,9,10,11,5  ], animSpeedMS : 80, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, fnf : true, FFRXHX : 0, loopNum : 0, syncOffset : -1 },
{  name : 'Toss - Low', pose : 1, frames : [ 7,0,1,2,3,4,5,6, 7,0,1,2,3,4,5,6 ], animSpeedMS : 80, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, doToss : true, tossAnimNum : 1, tossDelayMS :  100, smoothToss : true, tossRight : true },
{  name : 'Toss - Med', pose : 1, frames : [ 7,0,1,2,3,4,5,6, 7,0,1,2,3,4,5,6 ], animSpeedMS : 80, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, doToss : true, tossAnimNum : 2, tossDelayMS :  0, smoothToss : true, tossRight : true },
{  name : 'Toss - High', pose : 1, frames : [ 7,0,1,2,3,4,5,6, 7,0,1,2,3,4,5,6 ], animSpeedMS : 80, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, doToss : true, tossAnimNum : 3, tossDelayMS :  -200, smoothToss : true, tossRight : true },
{  name : 'Toss - Float', pose : 1, frames : [ 7,0,1,2,3,4,5,6, 7,0,1,2,3,4,5,6 ], animSpeedMS : 80, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, doToss : true, tossAnimNum : 4, tossDelayMS :  -200, smoothToss : true, tossRight : true }
];
ANIM[EQUIPMENT_RIFLE] =
[
{  name : 'Pose', pose : 0, frames : [ 0 ], offset : [0,1, 0], animSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0 },
{  name : 'Pose', pose : 1, frames : [ 1 ], offset : [0,-2, 0], animSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0 },
{  name : 'Pose', pose : 2, frames : [ 9 ], offset : [0,-2, 0], animSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0 },
{  name : 'Pose', pose : 7, frames : [ 10 ], offset : [3, -4, 0], animSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0 },
{  name : 'Pose', pose : 6, frames : [ 2 ], offset : [-3, -4, 0], animSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0 },
{  name : 'Pose', pose : 7, frames : [ 2 ], offset : [-4, 5, 0], animSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0 },
{  name : 'Pose', pose : 6, frames : [ 10 ], offset : [4, 5, 0], animSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0 },
{  name : 'Pose', pose : 0, frames : [ 15 ], offset : [-9, 4, 0], animSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0 },
{  name : 'Pose', pose : 0, frames : [ 7 ], offset : [9,4, 0], animSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0 },
{  name : 'Spin R', pose : 7, frames : [ 5,6,7,0,1,2,3,4 ], offset : [4, 0, 0], animSpeedMS : 75, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, syncOffset : -1 },
{  name : 'Spin L', pose : 6, frames : [ 7,6,5,4,3,2,1,0 ], offset : [-4, 0, 0], animSpeedMS : 75, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, syncOffset : +1 },
{  name : 'Spin R - Faster', pose : 7, frames : [ 5,6,7,0,1,2,3,4 ], offset : [4, 0, 0], animSpeedMS : 50, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, syncOffset : -1 },
{  name : 'Spin L - Faster', pose : 6, frames : [ 7,6,5,4,3,2,1,0 ], offset : [-4, 0, 0], animSpeedMS : 50, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, syncOffset : +1 },
{  name : 'Work R', pose : 7, frames : [ 1,2,3,4,5,5,5, 4,3,2,1,0,7,6,5,4,3,2,1,0,7,6,5, 6,7,0   ], offset : [4, 0, 0], animSpeedMS : 75, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, syncOffset : -1 },
{  name : 'Work L', pose : 6, frames : [ 3,2,1,0,7,7,7, 0,1,2,3,4,5,6,7, 0,1,2,3,4,5,6,7, 6,5,4  ], offset : [-4, 0, 0], animSpeedMS : 75, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, syncOffset : +1 },
{  name : 'Work R - Faster', pose : 7, frames : [ 1,2,3,4,5,5,5, 4,3,2,1,0,7,6,5,4,3,2,1,0,7,6,5, 6,7,0   ], offset : [4, 0, 0], animSpeedMS : 50, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, syncOffset : -1 },
{  name : 'Work L - Faster', pose : 6, frames : [ 3,2,1,0,7,7,7, 0,1,2,3,4,5,6,7, 0,1,2,3,4,5,6,7, 6,5,4  ], offset : [-4, 0, 0], animSpeedMS : 50, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, syncOffset : +1 },
{  name : 'Toss - Double', pose : 6, frames : [ 7,6,5,4,3,2,1,0 ], offset : [-4, 0, 0], animSpeedMS : 75, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, doToss : true, tossAnimNum : 1, tossDelayMS : 200 },
{  name : 'Toss - Triple', pose : 6, frames : [ 7,6,5,4,3,2,1,0 ], offset : [-4, 0, 0], animSpeedMS : 75, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, doToss : true, tossAnimNum : 2, tossDelayMS :  0 },
{  name : 'Toss - Quad', pose : 6, frames : [ 7,6,5,4,3,2,1,0 ], offset : [-4, 0, 0], animSpeedMS : 75, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, doToss : true, tossAnimNum : 3, tossDelayMS : -200 },
{  name : 'Toss - Float', pose : 6, frames : [ 7,6,5,4,3,2,1,0 ], offset : [-4, 0, 0], animSpeedMS : 75, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, doToss : true, tossAnimNum : 4, tossDelayMS : -100 }
];
ANIM[EQUIPMENT_SABRE] = deepObjCopy( ANIM[EQUIPMENT_RIFLE] );
var TOSS_ANIM = [];
TOSS_ANIM[EQUIPMENT_RIFLE] =
[
{  name : 'Catch', pose : 6, frames : [ 0 ], offset : [0, 2, 0], animSpeedMS : 30, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0 },
{  name : 'Double', pose : 5, frames : [ 0,1,2,3,4,5,6,7 ], offset : [0, 0, 0], animSpeedMS : 30, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, tossSpeed : 4.5 },
{  name : 'Triple', pose : 5, frames : [ 0,1,2,3,4,5,6,7 ], offset : [0, 0, 0], animSpeedMS : 30, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, tossSpeed : 5.75 },
{  name : 'Quad', pose : 5, frames : [ 0,1,2,3,4,5,6,7 ], offset : [0, 0, 0], animSpeedMS : 30, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, tossSpeed : 7.5 },
{  name : 'Float', pose : 5, frames : [ 0,1,2,3,4,5,6,7 ], offset : [0, 0, 0], animSpeedMS : 60, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, tossSpeed : 7.25 }
];
TOSS_ANIM[EQUIPMENT_SABRE] = deepObjCopy( TOSS_ANIM[EQUIPMENT_RIFLE] );
TOSS_ANIM[EQUIPMENT_FLAG] =
[
{  name : 'Catch', pose : 3, frames : [ 4 ], offset : [0, 2, 0], animSpeedMS : 30, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0 },
{  name : 'Toss - Low', pose : 3, frames : [ 0,1,2,3,4,5,6,7 ], offset : [0, 0, 0], animSpeedMS : 40, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, tossSpeed : 4.5, catchFrame : -1 },
{  name : 'Toss - Med', pose : 3, frames : [ 0,1,2,3,4,5,6,7 ], offset : [0, 0, 0], animSpeedMS : 40, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, tossSpeed : 5.5, catchFrame : -1 },
{  name : 'Toss - High', pose : 3, frames : [ 0,1,2,3,4,5,6,7 ], offset : [0, 0, 0], animSpeedMS : 40, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, tossSpeed : 6.5, catchFrame : 4 },
{  name : 'Toss - Float', pose : 3, frames : [ 0,1,2,3,4,5,6,7 ], offset : [0, 0, 0], animSpeedMS : 80, loopSpeedMS : 0, lastAnimTime : 0, frameNum : 0, FFRXHX : 0, loopNum : 0, tossSpeed : 7.25, catchFrame : -1 }
];
var NUM_ANIMS = [];
NUM_ANIMS[EQUIPMENT_FLAG] = ANIM[EQUIPMENT_FLAG].length;
NUM_ANIMS[EQUIPMENT_RIFLE] = ANIM[EQUIPMENT_RIFLE].length;
NUM_ANIMS[EQUIPMENT_SABRE] = NUM_ANIMS[EQUIPMENT_RIFLE];
var ANIM_HANDS = [];
ANIM_HANDS[EQUIPMENT_FLAG] = [3,2,1,1,3,2,3,1,3,1,3,1,3,2,3,1,3,2,3,0];
ANIM_HANDS[EQUIPMENT_RIFLE] = [3,2,1,1,3,2,3,1,3,1,3,1,3,2,3,1,3,2,3,0];
ANIM_HANDS[EQUIPMENT_SABRE] = ANIM_HANDS[EQUIPMENT_RIFLE].slice();
var NUM_DEFAULT_FLAG_ANIMS = 6;
var TOSS_GRAVITY = 0.35;
var CATCH_POSE = [];
CATCH_POSE[EQUIPMENT_FLAG] = 3;
CATCH_POSE[EQUIPMENT_RIFLE] = 0;
CATCH_POSE[EQUIPMENT_SABRE] = 0;
var NUM_FLAG_POSES = 10;
var FLAG_IMG_SIZE_X = 648;
var FLAG_IMG_SIZE_Y = 216;
function reset_anims (resetAll)
{
for (var i = 0; i < ANIM[EQUIPMENT_FLAG].length; i ++)
{
if (resetAll || ANIM[EQUIPMENT_FLAG].fnf || ANIM[EQUIPMENT_FLAG].FFRXHX < EDITOR.show.FFRXHX - 1)
{
ANIM[EQUIPMENT_FLAG][i].frameNum = 0;
ANIM[EQUIPMENT_FLAG][i].lastAnimTime = 0;
ANIM[EQUIPMENT_FLAG][i].FFRXHX = 0;
}
}
for (var i = 0; i < ANIM[EQUIPMENT_RIFLE].length; i ++)
{
if (resetAll || ANIM[EQUIPMENT_RIFLE].fnf || ANIM[EQUIPMENT_RIFLE].FFRXHX < EDITOR.show.FFRXHX - 1)
{
ANIM[EQUIPMENT_RIFLE][i].frameNum = 0;
ANIM[EQUIPMENT_RIFLE][i].lastAnimTime = 0;
ANIM[EQUIPMENT_RIFLE][i].FFRXHX = 0;
}
}
}
var NUM_UNIFORMS = 6;
var NUM_DEFAULT_FLAG_COLORS = 6;
var NUM_PREMIUM_FLAG_COLORS = 4;
var SHOW_UNIFORM = 0;
var SHOW_FLAG1 = 1;
var SHOW_GUARD_UNIFORM = 2;
var SHOW_TOOL_MENU = false;
var EDITOR;
var LOADED;
var sets = [];
var setConfig = [];
var showConfig = [];
var mouseMoveTick = 0;
var MAX_UNDO_STATES = 128;
var GROUP_TYPE_CORPS = 0;
var GROUP_TYPE_BRASS = 1;
var GROUP_TYPE_GUARD = 2;
var GROUP_TYPE_DRUMLINE = 3;
var GROUP_SIZE_DEMO = 0;
var GROUP_SIZE_FAN = 1;
var GROUP_SIZE_NORMAL = 2;
var GROUP_SIZE_PREMIUM = 3;
var LINE_DELIM = "//"
var GROUP_SHOW_DATA = [];
GROUP_SHOW_DATA[GROUP_TYPE_CORPS] = [];
GROUP_SHOW_DATA[GROUP_TYPE_BRASS] = [];
GROUP_SHOW_DATA[GROUP_TYPE_DRUMLINE] = [];
GROUP_SHOW_DATA[GROUP_TYPE_GUARD] = [];
GROUP_SHOW_DATA[GROUP_TYPE_CORPS][GROUP_SIZE_FAN] = "[begin]" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_CORPS][GROUP_SIZE_FAN] += "show=0|0|0" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_CORPS][GROUP_SIZE_FAN] += "marcher=00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|10|10|10|10|10|20|20|20|30|30|30|30|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_CORPS][GROUP_SIZE_FAN] += "set=00|xbx71|xbxA1|xby31|xbyv1|xbyY1|xbzr1|xDx71|xDxA1|xDy31|xDyv1|xDyY1|xDzr1|y6x71|y6xA1|y6y31|y6yv1|y6yY1|y6zr1|yzx71|yzxA1|yzy31|yzyv1|yzyY1|yzzr1|z2x71|z2xA1|z2y31|z2yv1|z2yY1|z2zr1|zvx71|zvxA1|zvy31|zvyv1|zvyY1|zvzr1|AFwa1|Bfwa1|BPwa1|Cpwa1|CZwa1|ylwa1|yVwa1|zvwa1|E9wa0|EJwa0|Fjwa0|FTwa0|E9zq1|EVzq1|FHzq1|Gtzq1|E9yE1|EVyE1|FHyE1|GtyE1|E9x61|FHx61|E9xS1|FHxS1|EVx61|Gtx61|EVxS1|GtxS1" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_CORPS][GROUP_SIZE_FAN] += "[end]";
GROUP_SHOW_DATA[GROUP_TYPE_CORPS][GROUP_SIZE_NORMAL] = "[begin]" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_CORPS][GROUP_SIZE_NORMAL] += "show=0|0|0" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_CORPS][GROUP_SIZE_NORMAL] += "marcher=02|02|00|00|00|01|01|02|02|00|00|00|01|01|02|02|00|00|00|01|01|02|00|00|00|00|01|01|02|00|00|00|00|01|01|02|00|00|00|01|01|01|02|00|00|00|01|01|01|10|10|10|10|10|10|10|20|20|20|20|30|30|30|30|30|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_CORPS][GROUP_SIZE_NORMAL] += "set=00|xax21|xaxo1|xaxL1|xay71|xayu1|xayQ1|xazd1|xyx21|xyxo1|xyxL1|xyy71|xyyu1|xyyQ1|xyzd1|xWx21|xWxo1|xWxL1|xWy71|xWyu1|xWyQ1|xWzd1|ykx21|ykxo1|ykxL1|yky71|ykyu1|ykyQ1|ykzd1|yIx21|yIxo1|yIxL1|yIy71|yIyu1|yIyQ1|yIzd1|z6x21|z6xo1|z6xL1|z6y71|z6yu1|z6yQ1|z6zd1|zux21|zuxo1|zuxL1|zuy71|zuyu1|zuyQ1|zuzd1|AEx21|B2x21|Bqx21|BOx21|Ccx21|CAx21|CYx21|AEwj1|Bqwj1|Ccwj1|CYwj1|AEvA0|BevA0|BOvA0|CovA0|CYvA0|E8x20|EUx20|FGx20|Gsx20|E8yu0|EUyu0|FGyu0|Gsyu0|E8xL0|EUxL0|FGxL0|GsxL0|E8zd0|EUzd0|FGzd0|Gszd0" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_CORPS][GROUP_SIZE_NORMAL] += "[end]";
GROUP_SHOW_DATA[GROUP_TYPE_CORPS][GROUP_SIZE_PREMIUM] = "[begin]" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_CORPS][GROUP_SIZE_PREMIUM] += "show=0|0|0" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_CORPS][GROUP_SIZE_PREMIUM] += "marcher=00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|00|10|10|10|10|10|10|10|10|10|20|20|20|20|20|30|30|30|30|30|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_CORPS][GROUP_SIZE_PREMIUM] += "set=00|xawo1|xawJ1|xax41|xaxp1|xaxK1|xay51|xayq1|xayL1|xuwo1|xuwJ1|xux41|xuxp1|xuxK1|xuy51|xuyq1|xuyL1|xPwo1|xPwJ1|xPx41|xPxp1|xPxK1|xPy51|xPyq1|xPyL1|y9wo1|y9wJ1|y9x41|y9xp1|y9xK1|y9y51|y9yq1|y9yL1|yuwo1|yuwJ1|yux41|yuxp1|yuxK1|yuy51|yuyq1|yuyL1|yOwo1|yOwJ1|yOx41|yOxp1|yOxK1|yOy51|yOyq1|yOyL1|z9wo1|z9wJ1|z9x41|z9xp1|z9xK1|z9y51|z9yq1|z9yL1|zuwo1|zuwJ1|zux41|zuxp1|zuxK1|zuy51|zuyq1|zuyL1|AExb1|AWxb1|Bexb1|Bwxb1|BOxb1|C6xb1|Coxb1|CGxb1|CYxb1|AEws1|Bews1|BOws1|Cows1|CYws1|AEvJ0|BevJ0|BOvJ0|CovJ0|CYvJ0|E8yM1|E8ya1|EIya1|Fiya1|FSya1|Gsya1|GsyM1|E8xy1|EIxy1|Fixy1|FSxy1|Gsxy1|FSyM1|E8wW1|EIwW1|FiwW1|FSwW1|GswW1|FiyM1|E8wl1|EIwl1|Fiwl1|FSwl1|Gswl1|EIyM1" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_CORPS][GROUP_SIZE_PREMIUM] += "[end]";
GROUP_SHOW_DATA[GROUP_TYPE_BRASS][GROUP_SIZE_NORMAL] = "[begin]" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_BRASS][GROUP_SIZE_NORMAL] += "show=0|0|0" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_BRASS][GROUP_SIZE_NORMAL] += "marcher=03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03|03" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_BRASS][GROUP_SIZE_NORMAL] += "set=00|A5wl1|C4wQ1|C4yO1|A5zj1|A5wQ1|A5xP1|C4xk1|C4xP1|AAwl1|CywQ1|CyyO1|AAzj1|AAwQ1|AAxP1|Cyxk1|CyxP1|B5wl1|D3wQ1|D3yO1|B5zj1|B5wQ1|B5xP1|D3xk1|D3xP1|Bzwl1|DywQ1|DyyO1|Bzzj1|BzwQ1|BzxP1|Dyxk1|DyxP1|C4wl1|B5xk1|A5xk1|A5yk1|A5yO1|A5zN1|C4yk1|C4zj1|Cywl1|Bzxk1|AAxk1|AAyk1|AAyO1|AAzN1|Cyyk1|Cyzj1|D3wl1|B5yk1|C4zN1|DyzN1|B5yO1|B5zN1|D3yk1|D3zj1|Dywl1|Bzyk1|CyzN1|D3zN1|BzyO1|BzzN1|Dyyk1|Dyzj1" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_BRASS][GROUP_SIZE_NORMAL] += "[end]";
GROUP_SHOW_DATA[GROUP_TYPE_GUARD][GROUP_SIZE_NORMAL] = "[begin]" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_GUARD][GROUP_SIZE_NORMAL] += "show=0|0|0" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_GUARD][GROUP_SIZE_NORMAL] += "marcher=40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_GUARD][GROUP_SIZE_NORMAL] += "set=00|Cgy32|CgwB2|zuzv2|Cgzv2|CgyM2|Dcy32|DcwB2|Apzv2|Dczv2|DcyM2|E8y32|E8wB2|Blzv2|E8zv2|E8yM2|zuwB2|zuxk2|Cgxk2|zuyM2|zuy32|ApwB2|Apxk2|Dcxk2|ApyM2|Apy32|BlwB2|Blxk2|E8xk2|BlyM2|Bly32" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_GUARD][GROUP_SIZE_NORMAL] += "[end]";
GROUP_SHOW_DATA[GROUP_TYPE_GUARD][GROUP_SIZE_PREMIUM] = "[begin]" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_GUARD][GROUP_SIZE_PREMIUM] += "show=0|0|0" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_GUARD][GROUP_SIZE_PREMIUM] += "marcher=40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40|40" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_GUARD][GROUP_SIZE_PREMIUM] += "set=00|Beyo2|Dywj2|yUzN2|CozN2|Coyo2|Dyyo2|EIwj2|A4zN2|DyzN2|Dyz52|EIyo2|EIx02|BezN2|EIzN2|EIz52|yUwj2|yUx02|Dyx02|yUz52|yUxH2|A4wj2|A4x02|CoxH2|A4z52|A4xH2|Bewj2|Bex02|DyxH2|Bez52|BexH2|yUyo2|Cowj2|Cox02|EIxH2|Coz52|A4yo2" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_GUARD][GROUP_SIZE_PREMIUM] += "[end]";
GROUP_SHOW_DATA[GROUP_TYPE_DRUMLINE][GROUP_SIZE_NORMAL] = "[begin]" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_DRUMLINE][GROUP_SIZE_NORMAL] += "show=0|0|0" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_DRUMLINE][GROUP_SIZE_NORMAL] += "marcher=10|10|10|10|10|10|10|10|10|20|20|20|20|20|30|30|30|30|30|50|50|50|50|50" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_DRUMLINE][GROUP_SIZE_NORMAL] += "set=00|AEz41|AWz41|Bez41|Bwz41|BOz41|C6z41|Coz41|CGz41|CYz41|AEyl1|Beyl1|BOyl1|Cnyl1|CXyl1|AExC0|BexC0|BOxC0|CnxC0|CXxC0|AEwT1|BewT1|BOwT1|CnwT1|CXwT1//[end]" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_DRUMLINE][GROUP_SIZE_NORMAL] += "[end]";
GROUP_SHOW_DATA[GROUP_TYPE_DRUMLINE][GROUP_SIZE_PREMIUM] = "[begin]" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_DRUMLINE][GROUP_SIZE_PREMIUM] += "show=0|0|0" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_DRUMLINE][GROUP_SIZE_PREMIUM] += "marcher=10|10|10|10|10|10|10|10|10|10|20|20|20|20|20|30|30|30|30|30|50|50|50|50|50|50|50|50|50|50" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_DRUMLINE][GROUP_SIZE_PREMIUM] += "set=00|A2yV1|AyyV1|B4yV1|BAyV1|C6yV1|D8yV1|EayV1|CCyV1|DEyV1|zwyV1|A0xU1|B2xU1|ByxU1|AwxU1|zuxU1|C4xU0|CAxU0|D6xU0|DCxU0|E8xU0|zuwT1|A0wT1|B2wT1|C4wT1|AwwT1|BywT1|CAwT1|D6wT1|DCwT1|E8wT1" + LINE_DELIM;
GROUP_SHOW_DATA[GROUP_TYPE_DRUMLINE][GROUP_SIZE_PREMIUM] += "[end]";
var USE_DEFAULT_SHOW_DATA = true;
function oEditor ()
{
var self = this;
this.isPlaying = false;
this.mode = MODE_VIEW;
this.authorID = 0;
this.wipID = 0;
this.is3D = false;
this.trialGroup = 0;
this.showTitle = "";
this.div = $('editor');
this.dragOriginX = 0;
this.dragOriginY = 0;
this.selectBox = $('selectbox');
this.selectBoxX = 0;
this.selectBoxY = 0;
this.selectBoxActive = false;
this.FFNWUB = [];
this.FFAFDR = [];
this.marcherById = [];
this.FFFESA = null;
this.cursorInEditor = false;
this.show = new oShow();
this.showID = 0;
this.snapX = DEFAULT_GRID;
this.isPostEdit = false;
this.doShowHelp = true;
this.helpLevel = 0;
this.snapLevel = 0;
this.isRestored = false;
this.isJudge = false;
this.isPreview = false;
this.didVote = false;
this.setIsChanged = false;
this.stateIsChanged = false;
this.showIsChanged = false;
this.lastActionID = "";
this.FFAUEL = "";
this.isAddingSet = false;
this.FFPPKC = null;
this.leader = null;
this.isDragging = false;
this.didDrag = false;
this.isFineSelect = false;
this.lastMouseMove = 0;
this.scaleOffsetsSet = false;
this.saveIntervalID = 0;
this.isSaving = false;
this.isPublished = false;
this.hasVoted = false;
this.showPins = true;
this.doAutoSave = true;
this.lastSaveTime = 0;
this.lockAutoSave = false;
this.postSaveAction = "";
this.statusHidden = false;
this.FFNJLO = [[]];
this.FFROVE = [[]];
this.pauseKeyListener = false;
this.fakeCtrl = false;
this.quickSelect = false;
this.isWandSelect = false;
this.isSlowPlay = false;
this.isFastPlay = false;
this.isAnalyze = false;
this.animScroll = false;
this.numSaveAttempts = 0;
this.numSaveHeartbeats = 0;
this.doPublishAfterSave = false;
this.isIndoor = false;
this.groupType = GROUP_TYPE_CORPS;
this.hashState = 0;
this.mouseX = 0;
this.mouseY = 0;
this.numSelected = 0;
this.prevSetBlock = false;
this.saveBlockedByStudio = false;
this.cheats = {};
this.numFlags = NUM_DEFAULT_FLAG_COLORS;
this.flagImg = null;
this.weaponImg = null;
this.spriteURL =
{
musician    : null,
flag        : imageUrl("sprites/flag.png"),
guard       : imageUrl("sprites/guard.png"),
weapon      : imageUrl("sprites/weapon.png"),
prop        : null
};
this.spriteImg = {};
this.newSprite = function (type)
{
if (! this.spriteImg[type])
{
var s = new Image ();
s.src = this.spriteURL[type];
this.spriteImg[type] = s;
return s.cloneNode(true);
}
else
{
return this.spriteImg[type].cloneNode(true);
}
};
this.newBlip = function (elid, color)
{
var blip = document.createElement('DIV');
blip.style.height = "3px";
blip.style.width = "3px";
blip.style.zIndex = "2000";
blip.style.position = "absolute";
blip.style.backgroundColor = color;
blip.id = elid;
$('editor').appendChild(blip);
};
this.moveBlip = function (elid, x, y)
{
$(elid).style.top = y;
$(elid).style.left = x;
};
this.initEditMode = function (authorID)
{
this.authorID = authorID;
this.mode = MODE_EDIT;
this.initEvents();
this.redrawSetPanel();
$('editorcontrolsets').style.display = "block";
if (! IS_DEMO)
this.saveIntervalID = setInterval('EDITOR.show.ajaxSave(true)', SAVE_HEARTBEAT_MINS * 60 * 1000);
addCSSRule(".marcher", "cursor:move");
addCSSRule(".equipment", "cursor:move");
if (EDITOR.groupType >= 2)
{
addCSSRule(".setpin", "background-color: #7EAA84");
}
if (this.spriteURL['flag'])
{
var flagImg = new Image();
flagImg.src = this.spriteURL['flag'];
EDITOR.numFlags = (EDITOR.isPremium) ? NUM_PREMIUM_FLAG_COLORS : NUM_DEFAULT_FLAG_COLORS;
EDITOR.spriteImg['flag'] = flagImg;
}
var wand = new Image();
wand.src = imageUrl('show/wand.cur');
if (EDITOR.snapLevel > 0)
{
this.snapX = 0;
}
};
this.initViewMode = function ()
{
listenForKeyPressView();
};
this.reload_sprite = function (spriteType, url)
{
this.spriteURL[spriteType] = url;
for (var i=0,m; m = this.show.marchers[i]; i++)
{
if (m.section == SECTION_PROP)
{
if (spriteType == 'prop')
{
m.loadCustomProp(url);
}
}
else if (spriteType == 'musician' && m.section != SECTION_GUARD)
{
m.loadCustomUniform(url);
}
else if (m.section == SECTION_GUARD)
{
if (spriteType == 'guard')
{
m.loadCustomUniform(url);
}
else if (spriteType == 'flag')
{
m.loadCustomFlag(url);
}
}
}
};
this.updateSpriteSizes = function ()
{
if (! ie) { return false; }
for (var i=0, m; m = this.show.marchers[i]; i++)
{
if (m.section == SECTION_GUARD)
{
m.img.width = 144;
m.equipment.img.width = FLAG_IMG_SIZE_X;
m.equipment.img.height = FLAG_IMG_SIZE_Y;
}
}
};
this.addExtraSets = function ()
{
if (this.isPremium)
{
MAX_SETS = MAX_SETS_PREMIUM;
SET_BLOCK_SIZE_X = SET_BLOCK_SIZE_X_PREMIUM;
}
else if (this.groupType == GROUP_TYPE_GUARD)
{
MAX_SETS = 36;
SET_BLOCK_SIZE_X -= 2;
}
};
this.redrawSetPanel = function ()
{
if (this.mode == MODE_EDIT)
{
$('setgraph').innerHTML = '';
for (i=0; i <= this.show.maxSet; i++)
{
this.addSetToGraph(i);
}
updateAddSetLink();
for (i=0; i <= this.show.maxSet; i++)
{
this.redrawSetBlock(i);
}
this.show.redrawSetConfig();
}
};
this.addSetToGraph = function (setNum)
{
var setWidth = SET_BLOCK_SIZE_X;
var add = '<a href="#" id="setblock'+setNum+'" class="setblock" onClick="EDITOR.show.forceJumpToSet(' + setNum + '); return false">';
add += '<img src="' + imageUrl('show/pixel.gif') + '" style="width:'+setWidth+'px;" id="setblockimg'+setNum+'" title="Set '+setNum+'">';
add += '</a>';
$('setgraph').innerHTML += add;
this.redrawSetBlock(setNum);
};
this.toggleHashes = function (isCtrl)
{
var newHashState = 0;
if (this.hashState > 0)
{
newHashState = HASH_NONE;
}
else if (isCtrl)
{
newHashState = HASH_VERTICAL;
}
else
{
newHashState = HASH_HORIZONTAL;
}
if (newHashState == 0)
{
this.hashState = 0;
$('hashX').style.display = 'none';
$('hashY').style.display = 'none';
}
else if (newHashState == HASH_VERTICAL)
{
var doShow = false;
if (this.FFFESA)
{
doShow = true;
var markerX = this.FFFESA.x + ((this.FFFESA.imgSizeX / 2) >> 0) - 1;
markerX += (this.FFFESA.section == SECTION_BASS) ? -9 : 0;
$('hashY').style.left = markerX + 'px';
}
else if (this.cursorInEditor)
{
var editorX = (document.body.clientWidth - FIELD_SIZE_X) / 2;
var markerX = this.mouseX - editorX - 5;
$('hashY').style.left = markerX + 'px';
doShow = true;
}
if (doShow)
{
this.hashState = newHashState;
$('hashX').style.display = 'none';
$('hashY').style.display = 'block';
}
}
else if (newHashState == HASH_HORIZONTAL)
{
var doShow = false;
if (this.FFFESA)
{
doShow = true;
var markerY = this.FFFESA.y + this.FFFESA.imgSizeY - 3;
$('hashX').style.top = markerY + 'px';
}
else if (this.cursorInEditor && ! isCtrl)
{
var editorY = 70;
var markerY = this.mouseY - editorY;
$('hashX').style.top = markerY + 'px';
doShow = true;
}
else if (isCtrl)
{
doShow = true;
}
if (doShow)
{
this.hashState = newHashState;
$('hashY').style.display = 'none';
$('hashX').style.display = 'block';
}
}
};
this.highlightSetBlock = function (setNum)
{
var block = $('setblock'+setNum);
if (block)
{
if (this.prevSetBlock)
{
this.prevSetBlock.style.backgroundColor = '#97D2A2';
}
block.style.backgroundColor = '#fff';
this.prevSetBlock = block;
this.setGraphNumber(setNum);
}
};
this.redrawSetBlock = function (setNum)
{
var block = $('setblock'+setNum);
if (block)
{
if (this.show.setConfig[setNum])
{
bwidth = 1 + this.show.setConfig[setNum][SET_CONFIG_PAUSE];
block.style.borderLeft = "solid " + bwidth + "px #40854F";
block.style.width = px((SET_BLOCK_SIZE_X + 1) - bwidth);
$('setblockimg'+setNum).style.width = px((SET_BLOCK_SIZE_X + 1) - bwidth);
}
else
{
block.style.width = px(SET_BLOCK_SIZE_X);
}
this.setGraphNumber(this.show.FFRXHX);
}
};
this.updateStatus = function (msg)
{
$('editstatus').innerHTML = msg;
$('editstatus').style.display = 'block';
};
this.hideStatus = function (msg)
{
$('editstatus').style.display = 'none';
};
this.updateSelectedStatus = function ()
{
if (this.FFNWUB.length < 2)
{
this.hideStatus();
}
else
{
if (this.numSelected != this.FFNWUB.length)
{
this.updateStatus(this.FFNWUB.length + " selected");
this.numSelected = this.FFNWUB.length;
}
}
};
this.setGraphNumber = function (setNum)
{
$('setsvalue').innerHTML = this.show.FFRXHX;
};
this.showOverlay = function (op)
{
if (this.mode == MODE_EDIT) {  return false; }
if (! defined(op))
{
op = 0;
$('editoroverlay').style.visibility = "visible";
setAlpha('editoroverlay', 0);
if (this.isJudge)
{
$('author').style.visibility = 'hidden';
$('authordrop').style.visibility = 'hidden';
}
}
if (op > 100) {  op = 100; }
setAlpha('editoroverlay', op);
if (op < 100)
{
setTimeout("EDITOR.showOverlay("+ (op + 20) +")", 10);
}
};
this.hideOverlay = function (op)
{
if (this.mode == MODE_EDIT) {  return false; }
if (! defined(op))
{
EDITOR.overlayFadeStart = get_now();
}
op = (100 - (get_now() - EDITOR.overlayFadeStart) / 1.5) >> 0;
setAlpha('editoroverlay', op);
if ($('showdesc'))
setAlpha('showdesc', op);
if (op > 0)
{
setTimeout("EDITOR.hideOverlay("+ op +")", 10);
}
else
{
$('editoroverlay').style.visibility = "hidden";
if ($('showdesc'))
$('showdesc').style.display = "none";
}
};
this.resetSelectBox = function ()
{
this.selectBoxX = 0;
this.selectBoxY = 0;
this.selectBox.style.left = "0px";
this.selectBox.style.top = "0px";
this.selectBox.style.height = "1px";
this.selectBox.style.width = "1px";
this.selectBox.style.visibility = "hidden";
this.selectBoxActive = false;
};
this.initEvents = function ()
{
document.ondblclick = doubleClick;
document.onmousedown = mouseDown;
document.onmousemove = this.mouseMove;
document.onmouseup = mouseUp;
document.onmouseover = mouseOver;
document.onmouseout = mouseOut;
this.div.onmouseover = function () {  EDITOR.cursorInEditor = true; };
this.div.onmouseout = function () {  EDITOR.cursorInEditor = false; };
if (window.addEventListener)
{
window.addEventListener('DOMMouseScroll', wheel, false);
}
window.onmousewheel = document.onmousewheel = wheel;
window.onbeforeunload = function ()
{
if (EDITOR.showIsChanged && ! IS_DEMO && ! EDITOR.isPostEdit)
{
return 'There are unsaved changes to your show.';
}
else
{
return;
}
};
listenForKeyPress();
};
this.pauseEvents = function ()
{
document.onmousedown = function () {  return true; };
this.pauseKeyListener = true;
};
this.FFVHTC = function (actionID, selectOnly)
{
if (actionID != 'arc')
{
EDITOR.resetArc();
}
this.stateIsChanged = true;
this.showIsChanged = true;
if (this.show.FFRXHX == this.show.maxSet)
{
this.setIsChanged = true;
updateAddSetLink();
}
if (EDITOR.show.FFRXHX == 0 || EDITOR.show.FFRXHX == 1)
{
hide('help');
hide('groupselect');
}
else if (EDITOR.isRestored && EDITOR.helpLevel < 1)
{
hide('help');
}
this.addToHistory(actionID, selectOnly);
EDITOR.show.FFGTHE(EDITOR.FFNWUB);
};
this.FFEQGC = function (addToHistory)
{
if (addToHistory && this.FFNWUB.length > 1)
{
EDITOR.FFVHTC('clearselection', true);
}
this.FFPPKC = null;
for (i=0; i < this.FFNWUB.length; i++)
{
this.FFNWUB[i].deselect();
}
this.FFNWUB = [];
this.updateSelectedStatus();
EDITOR.scaleOffsetIsSet = false;
EDITOR.resetArc();
EDITOR.disableWandSelect();
EDITOR.prevFineSelect = false;
EDITOR.isFineSelect = false;
EDITOR.FFAUEL = "";
};
this.enableWandSelect = function ()
{
if (! this.isWandSelect)
{
this.isWandSelect = true;
var cstyle = "nw-resize";
addCSSRule(".marcher", "cursor: " + cstyle);
addCSSRule(".equipment", "cursor: " + cstyle);
document.body.style.cursor = cstyle;
EDITOR.enableWandCursor();
if (EDITOR.FFFESA)
{
EDITOR.FFQLNH(EDITOR.FFFESA);
}
}
};
this.enableWandCursor = function ()
{
if (this.isWandSelect)
{
var url = imageUrl('show/wand.cur');
var cstyle = "url("+url+"), nw-resize";
addCSSRule(".marcher", "cursor: " + cstyle);
addCSSRule(".equipment", "cursor: " + cstyle);
document.body.style.cursor = cstyle;
}
};
this.disableWandSelect = function ()
{
if (this.isWandSelect)
{
this.isWandSelect = false;
addCSSRule(".marcher", "cursor:move");
addCSSRule(".equipment", "cursor:move");
document.body.style.cursor = "default";
}
};
this.resetArc = function ()
{
EDITOR.show.arcFocus = [];
EDITOR.show.FFIOIL = 0;
EDITOR.show.arcFocusAngle = 0;
EDITOR.show.FFOKAO = [];
EDITOR.show.arcDirection = 0;
EDITOR.show.reverseArcKey = false;
EDITOR.show.FFKJUR = 0;
};
this.FFQLNH = function (m, isOrdered)
{
if (! m.FFUIXO)
{
isDark = false;
m.select(false, isDark);
if (m.FFUIXO)
{
this.FFNWUB.push(m);
this.updateSelectedStatus();
}
EDITOR.resetArc();
}
}
this.FFSTJQ = function (m)
{
if (m.FFUIXO)
{
m.deselect();
if (! ie)
{
this.FFNWUB.splice(this.FFNWUB.indexOf(m), 1);
}
else
{
for (i=0; i < this.FFNWUB.length; i++)
{
if (this.FFNWUB[i].id == m.id)
{
this.FFNWUB.splice(i, 1);
}
}
}
this.updateSelectedStatus();
EDITOR.resetArc();
}
}
this.setDragOrigin = function (dx, dy)
{
this.dragOriginX = dx;
this.dragOriginY = dy;
for (m=0; m < this.FFNWUB.length; m++)
{
this.FFNWUB[m].setDragOrigin();
}
}
this.spawnSetPins = function ()
{
for (i=0; i < this.show.marchers.length; i++)
{
this.show.marchers[i].spawnSetPin();
}
this.updateSetPins();
}
this.toggleSetPins = function ()
{
this.showPins = 1 - this.showPins;
action_message("Set dots turned " + (this.showPins ? 'ON' : 'OFF'));
for (i=0; i < this.show.marchers.length; i++)
{
if (this.showPins)
{
this.show.marchers[i].showPin();
}
else
{
this.show.marchers[i].hidePin();
}
}
}
this.updateSetPins = function ()
{
if (EDITOR.mode != MODE_EDIT)
return false;
var pinOffX = -1  // + ((ie) ? 1 : 0)
if (EDITOR.isPlaying)
{
for (var i=0, m; m = this.show.marchers[i]; i++)
{
var offX = (m.section == SECTION_BASS) ? -8 : 0;
var pin = $(m.id + "pin");
pin.style.left = m.x + m.imgSizeX / 2 + pinOffX + offX;
pin.style.top = m.y + m.imgSizeY - 3;
}
}
else if (this.show.FFRXHX == 0)
{
for (var i=0, m; m = this.show.marchers[i]; i++)
{
if (m.section != SECTION_PROP)
{
var pin = $(m.id + "pin");
pin.style.left = px(-10);
pin.style.top = px(-10);
}
}
}
else
{
var prevSet = this.show.FFRXHX - 1;
for (var i=0, m; m = this.show.marchers[i]; i++)
{
if (m.section == SECTION_PROP) {  continue; }
var offX = (m.section == SECTION_BASS) ? -8 : 0;
var pin = $(m.id + "pin");
pin.style.left = m.sets[prevSet][0] + m.imgSizeX / 2 + pinOffX + offX;
pin.style.top = m.sets[prevSet][1] + m.imgSizeY - 3;
}
}
}
this.setLeader = function (marcher)
{
if (this.leader)
{
this.leader.isLeader = false;
}
this.leader = marcher;
marcher.isLeader = true;
marcher.setBorder("solid 1px orange");
}
this.toggleSnap = function ()
{
this.snapX = (this.snapX + 1) % NUM_GRIDS;
var onOff = GRID_X_NAME[this.snapX];
if (! SHOW_TOOL_MENU)
{
action_message("Yardline Snap is &nbsp;" + onOff);
}
}
this.addToHistory = function (actionID, selectOnly)
{
if (actionID && actionID == this.lastActionID)
{
return false;
}
this.lastActionID = actionID;
var history = this.FFNJLO[ this.show.FFRXHX ];
if (! history)
{
history = [];
this.FFNJLO[ this.show.FFRXHX ] = history;
}
if (history.length >= MAX_UNDO_STATES)
{
history.shift();
}
var state = this.getHistoryState(selectOnly);
this.FFROVE[ this.show.FFRXHX ] = [];
history.push(state);
this.stateIsChanged = false;
}
this.getHistoryState = function (selectOnly)
{
var pos = [];
if (! selectOnly)
{
for(i=0; i < this.show.marchers.length; i++)
{
var m = this.show.marchers[i];
pos[m.id] = [ m.x, m.y ];
}
}
if (! this.show.FFNHHT[ this.show.FFRXHX ])
{
this.show.FFNHHT[ this.show.FFRXHX ] = [];
}
var group = (selectOnly) ? [] : this.show.FFNHHT[ this.show.FFRXHX ].slice();
var state =
{
'pos' : pos,
'sel' : this.FFNWUB.slice(),
'group' : group
};
return state;
};
this.undo = function ()
{
var history = this.FFNJLO[ this.show.FFRXHX ];
if (! history.length)
return false;
var currState = this.getHistoryState();
this.FFROVE[ this.show.FFRXHX ].push(currState);
var lastState = history.pop()
if (lastState.pos.length)
{
for (i=0; i < this.show.marchers.length; i++)
{
var m = this.show.marchers[i];
m.move(lastState.pos[m.id][0], lastState.pos[m.id][1]);
}
}
this.restoreSelection(lastState.sel, lastState.group);
this.stateIsChanged = false;
this.lastActionID = "";
EDITOR.resetArc();
}
this.redo = function ()
{
var rhistory = this.FFROVE[ this.show.FFRXHX ];
if (! rhistory.length)
return false;
var currState = this.getHistoryState();
this.FFNJLO[ this.show.FFRXHX ].push(currState);
var lastState = rhistory.pop();
if (lastState.pos.length)
{
for(i=0; i < this.show.marchers.length; i++)
{
var m = this.show.marchers[i];
m.move(lastState.pos[m.id][0], lastState.pos[m.id][1]);
}
}
this.restoreSelection(lastState.sel, lastState.group);
this.stateIsChanged = false;
EDITOR.resetArc();
}
this.restoreSelection = function (marchers, groups)
{
EDITOR.FFEQGC();
for (i=0; i < marchers.length; i++)
{
var m = marchers[i];
EDITOR.FFQLNH(m);
}
if (groups.length)
{
this.show.FFNHHT[ this.show.FFRXHX ] = groups.slice();
}
};
this.clearHistory = function ()
{
this.stateIsChanged = false;
this.FFNJLO = [[]];
this.FFROVE = [[]];
this.undoSetNum = this.show.FFRXHX;
}
this.recoverLostMarchers = function ()
{
if (EDITOR.isPlaying)
return false;
this.FFEQGC(true);
for(i=0; i < this.show.marchers.length; i++)
{
var marcher = this.show.marchers[i];
if (marcher.x > FIELD_SIZE_X)
{
this.FFQLNH(marcher);
}
else if (marcher.x < -18)
{
this.FFQLNH(marcher);
}
else if (marcher.y > FIELD_SIZE_Y)
{
this.FFQLNH(marcher);
}
else if (marcher.y < -36)
{
this.FFQLNH(marcher);
}
}
if (EDITOR.FFNWUB.length == 0)
{
alert("No lost marchers found.");
return false;
}
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
EDITOR.FFNWUB[m].FFQFGQ([FIELD_SIZE_X / 2, FIELD_SIZE_Y / 2]);
}
EDITOR.FFNWUB.sort(function (a,b) { return a.FFLOJC - b.FFLOJC })
var offX = 0;
var offY = 0;
if (EDITOR.FFNWUB[0].x < 0)
offX = EDITOR.FFNWUB[0].x + 60 - EDITOR.FFNWUB[0].x;
if (EDITOR.FFNWUB[0].x > FIELD_SIZE_X)
offX = FIELD_SIZE_X - 60 - EDITOR.FFNWUB[0].x;
if (EDITOR.FFNWUB[0].y < 0)
offY = EDITOR.FFNWUB[0].y + 60 - EDITOR.FFNWUB[0].y;
if (EDITOR.FFNWUB[0].y > FIELD_SIZE_Y)
offY = FIELD_SIZE_Y - 60 - EDITOR.FFNWUB[0].y;
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
EDITOR.FFNWUB[m].move(EDITOR.FFNWUB[m].x + offX, EDITOR.FFNWUB[m].y + offY);
}
if (EDITOR.FFNWUB.length > 1)
{
alert("Drag the selected marcher to pull the rest onto the field.");
}
else if (EDITOR.FFNWUB.length == 0)
{
alert("There are no marchers outside the field.");
}
}
this.mouseUp = function (e)
{
if (this.isDragging && this.FFPPKC)
{
if (this.FFPPKC.isLeader)
{
this.FFPPKC.setBorder("solid 1px orange");
}
else
{
this.FFPPKC.setBorder("solid 1px " + BORDER_COLOR);
}
}
this.didDrag = false;
this.isFineSelect = false;
this.isDragging = false;
this.resetSelectBox();
}
this.mouseOut = function (e)
{
if (! this.isDragging)
{
this.unhighlightMarcher();
}
if (this.FFAFDR.length)
{
this.quickUnhighlight();
}
}
this.mouseOver = function (ev)
{
if (this.isPlaying || this.mode != MODE_EDIT)
return false;
var over = ns6 ? ev.target : ev.srcElement;
if (! this.isDragging)
{
if (over.className == "marcher" || over.className == "equipment")
{
var marcher = this.marcherById[ getnum(over.id) ];
if (this.isWandSelect || this.isFineSelect)
{
if (marcher.section == SECTION_PROP && this.show.maxSet > 0)
{
}
else
{
EDITOR.FFAUEL = "wand";
this.FFQLNH(marcher, true);
}
}
if (EDITOR.quickSelect)
{
this.quickHighlightGroup(marcher);
}
else
{
this.highlightMarcher(marcher);
}
}
}
}
this.quickUnhighlight = function ()
{
for (var i=0,m; m = EDITOR.FFAFDR[i]; i++)
{
m.quickUnhighlight();
}
EDITOR.FFAFDR = [];
};
this.quickHighlightGroup = function (marcher)
{
this.quickUnhighlight();
if (!marcher)
{
marcher = EDITOR.FFFESA;
if (! marcher) {  return false; }
this.unhighlightMarcher(marcher);
}
var group = EDITOR.show.FFOGRL(marcher);
if (group)
{
for (var i=0,m; m = group[i]; i++)
{
m.FFAXBS();
}
this.FFAFDR = group.slice();
}
};
this.highlightMarcher = function (marcher)
{
if (this.FFFESA)
{
this.FFFESA.unhighlight();
}
marcher.highlight();
this.FFFESA = marcher;
}
this.unhighlightMarcher = function ()
{
if (this.FFFESA)
{
this.FFFESA.unhighlight();
this.FFFESA = null;
}
}
this.doubleClick = function (ev)
{
if (self.isPlaying || ! self.mode == MODE_EDIT)
return false;
var clickedObj = ns6 ? ev.target : ev.srcElement;
var topElement = ns6 ? "HTML" : "BODY";
while (clickedObj.tagName != topElement && clickedObj.className != "marcher" && clickedObj.className != "equipment")
{
clickedObj = ns6 ? clickedObj.parentNode : clickedObj.parentElement;
}
if (EDITOR.quickSelect)
{
return false;
}
if (clickedObj.className == "marcher" || clickedObj.className == "equipment")
{
var isCtrl = (ev.ctrlKey || EDITOR.fakeCtrl) ? true : false;
var marcher = self.marcherById[ getnum(clickedObj.id) ];
if (marcher.isGhost)
{
return false;
}
var FFUIXO = marcher.FFUIXO;
if (ie)
{
FFUIXO = ! marcher.FFUIXO;
}
if (FFUIXO && isCtrl)
{
self.show.FFGLND(marcher);
}
else
{
self.show.FFTCHQ(marcher, isCtrl);
}
}
}
this.mouseDown = function (ev)
{
if (self.isPlaying && self.cursorInEditor)
{
self.FFEQGC();
return false;
}
if (self.isPlaying || self.mode != MODE_EDIT)
return false;
var clickedObj = ns6 ? ev.target : ev.srcElement;
var topElement = ns6 ? "HTML" : "BODY";
while (clickedObj.tagName != topElement && clickedObj.className != "marcher" && clickedObj.id != "soundprog"  && clickedObj.className != "equipment")
{
clickedObj = ns6 ? clickedObj.parentNode : clickedObj.parentElement;
}
var marcher = null;
if (clickedObj.className == "marcher" || clickedObj.className == "equipment")
{
marcher = self.marcherById[ getnum(clickedObj.id) ];
if (marcher.isGhost)
{
marcher = null;
}
}
if (marcher)
{
if (marcher.section == SECTION_PROP && EDITOR.show.propsHidden)
{
}
var isCtrl = (ev.ctrlKey || EDITOR.fakeCtrl);
if (isCtrl)
{
if (marcher.FFUIXO)
{
self.FFSTJQ(marcher);
return true;
}
else
{
EDITOR.FFAUEL = "marcher";
self.FFQLNH(marcher);
self.isFineSelect = true;
}
}
else if (this.isWandSelect && marcher.FFUIXO)
{
self.FFSTJQ(marcher);
}
else if (this.quickSelect)
{
self.show.FFAHTE(marcher, isCtrl);
}
else if (ev.shiftKey)
{
if (EDITOR.FFAUEL == "line" || EDITOR.FFAUEL == "marcher")
{
self.show.selectMarchersByLine(marcher);
EDITOR.FFAUEL = "line";
return false;
}
}
else
{
self.isDragging = true;
if (! marcher.FFUIXO)
{
self.FFEQGC(true);
self.FFQLNH(marcher);
EDITOR.FFAUEL = "marcher";
}
}
self.FFPPKC = marcher;
if (self.FFNWUB.length > 0)
{
for(i=0; i < self.FFNWUB.length; i++)
{
if (! self.FFNWUB[i].isLeader)
{
self.FFNWUB[i].setBorder("solid 1px " + BORDER_COLOR);
}
}
if (marcher.FFUIXO && ! throttle('quick_select'))
{
marcher.setSpecialBorder();
}
}
self.setDragOrigin(ev.clientX, ev.clientY);
return false;
}
else if (self.cursorInEditor)
{
if (ev.shiftKey)
{
}
else if (! this.isWandSelect)
{
self.setDragOrigin(ev.clientX, ev.clientY);
if (! ev.ctrlKey && ! EDITOR.fakeCtrl) {  self.FFEQGC(true) }
var editorX = (document.body.clientWidth - FIELD_SIZE_X) / 2;
var editorY = $('editor').offsetTop - document.body.scrollTop;
self.resetSelectBox();
self.selectBoxX = self.dragOriginX - editorX - 5;
self.selectBoxY = self.dragOriginY - editorY - 9;
self.selectBoxActive = true;
self.selectBox.style.visibility = "visible";
self.selectBox.style.top = px(-100);
self.selectBox.style.left = px(-100);
return false;
}
}
}
this.mouseMove = function (e)
{
if (self.isPlaying || ! self.mode == MODE_EDIT)
return false;
mouseMoveTick ++;
if (mouseMoveTick % 2 == 1)
return false;
var ev = ns6 ? e : event;
self.mouseX = ev.clientX;
self.mouseY = ev.clientY;
if (self.FFNWUB.length)
{
var editorX = (document.body.clientWidth - FIELD_SIZE_X) / 2;
var editorY = $('editor').offsetTop - document.body.scrollTop;
if (self.mouseX - editorX > FIELD_SIZE_X - 164 && self.mouseY - editorY > FIELD_SIZE_Y - 70)
{
if (! self.statusHidden)
{
self.hideStatus();
self.statusHidden = true;
}
}
else if (self.statusHidden)
{
self.updateStatus(self.FFNWUB.length + " selected");
self.statusHidden = false;
}
}
if (self.isDragging)
{
if (! self.didDrag)
{
self.FFVHTC();
self.didDrag = true;
}
var offX =  ev.clientX - self.dragOriginX;
var offY =  ev.clientY - self.dragOriginY;
var cOffX = self.show.FFBREV[0] - self.FFPPKC.x;
var cOffY = self.show.FFBREV[1] - self.FFPPKC.y;
var acOffX = self.show.FFOKAO[0] - self.FFPPKC.x;
var acOffY = self.show.FFOKAO[1] - self.FFPPKC.y;
for(i=0; i < self.FFNWUB.length; i++)
{
self.FFNWUB[i].FFHJFN(self.FFPPKC);
}
self.FFPPKC.drag(offX, offY);
self.show.FFBREV[0] = self.FFPPKC.x + cOffX;
self.show.FFBREV[1] = self.FFPPKC.y + cOffY;
self.show.FFOKAO[0] = self.FFPPKC.x + acOffX;
self.show.FFOKAO[1] = self.FFPPKC.y + acOffY;
if (! self.FFPPKC.isLeader)
{
for(i=0; i < self.FFNWUB.length; i++)
{
self.FFNWUB[i].moveRelativeToHandle();
}
}
return false;
}
else if (self.selectBoxActive)
{
var cx = ev.clientX;
var cy = ev.clientY;
var boxSizeX = cx - self.dragOriginX;
var boxSizeY = cy - self.dragOriginY;
var boxLeft = self.selectBoxX;
var boxTop = self.selectBoxY;
var marcherOffsetX = 0;
var marcherOffsetY = 0;
if (boxSizeX < 0)
{
boxLeft = boxLeft + boxSizeX;
boxSizeX = Math.abs(boxSizeX);
marcherOffsetX = MARCHER_SIZE_X;
}
if (boxSizeY < 0)
{
boxTop = boxTop + boxSizeY;
boxSizeY = Math.abs(boxSizeY);
marcherOffsetY = MARCHER_SIZE_Y;
}
if (boxTop + boxSizeY > FIELD_SIZE_Y - 2)
{
boxSizeY = (FIELD_SIZE_Y - 2) - boxTop;
}
self.selectBox.style.top = px(boxTop);
self.selectBox.style.left = px(boxLeft);
self.selectBox.style.width = px(boxSizeX);
self.selectBox.style.height = px(boxSizeY);
if (cx % 2 == 0 && cy % 2 == 0)
{
return;
}
for (i=0; i < self.show.marchers.length; i++)
{
var isInBox = false;
var marcher = self.show.marchers[i];
if (marcher.section == SECTION_PROP && self.show.maxSet > 0)
{
continue;
}
var mx = marcher.x + marcherOffsetX;
var my = marcher.y + marcherOffsetY;
if (mx > boxLeft && mx < boxLeft + boxSizeX && my > boxTop && my < boxTop + boxSizeY)
{
isInBox = true;
}
else if (self.selectBoxX > marcher.x && self.selectBoxX < marcher.x + marcher.imgSizeX && my > boxTop && my < boxTop + boxSizeY)
{
isInBox = true;
}
else if (self.selectBoxY > marcher.y && self.selectBoxY < marcher.y + marcher.imgSizeY && mx > boxLeft && mx < boxLeft + boxSizeX)
{
isInBox = true;
}
if (! isInBox && ! ev.ctrlKey && ! EDITOR.fakeCtrl && marcher.FFUIXO)
{
self.FFSTJQ(marcher);
}
else if (! marcher.FFUIXO && isInBox)
{
EDITOR.FFAUEL = "box";
self.FFQLNH(marcher);
}
}
}
}
}
function doubleClick (e)
{
var ev = ns6 ? e : event;
return EDITOR.doubleClick(ev);
}
function mouseDown (e)
{
MOUSE_DOWN = true;
var ev = ns6 ? e : event;
return EDITOR.mouseDown(ev);
}
function mouseUp (e)
{
MOUSE_DOWN = false;
var ev = ns6 ? e : event;
EDITOR.mouseUp(ev);
}
function mouseOver (e)
{
var ev = ns6 ? e : event;
EDITOR.mouseOver(ev);
}
function mouseOut (e)
{
var ev = ns6 ? e : event;
EDITOR.mouseOut(ev);
}
function oShow ()
{
this.title = "Untitled";
this.authorName = "Anon";
this.authorID = 0;
this.hasDescription = false;
this.editorVersion = EDITOR_VERSION;
this.marchers = [];
this.FFRXHX = 0;
this.maxSet = 0;
this.startTime = 0;
this.lastTweenTime = 0;
this.lastAnimTime = [];
this.longestPath = 0;
this.timeInterval = 0;
this.intervalID = 0;
this.FFBREV = [0,0];
this.arcFocus = [0,0];
this.FFIOIL = 0;
this.arcDirection = 0;
this.FFOKAO = [0,0];
this.numBasses = 0;
this.showConfig = [];
this.marcherConfig = [];
this.setConfig = [];
this.ripples = [];
this.ftlTrains = [];
this.rotations = [];
this.marcherIsDeleted = [];
this.setTime = [];
this.isSetup = false;
this.propsHidden = false;
this.frameCount = 0;
this.showStartTime = 0;
this.FFNHHT = [];
this.FFTKRF = 300;
this.addSet = function ()
{
if (EDITOR.isPlaying)
return false;
if (EDITOR.isAddingSet)
return false;
EDITOR.isAddingSet = true;
if (! EDITOR.setIsChanged)
{
}
if (this.maxSet == MAX_SETS)
{
if (IS_DEMO)
{
alert("You have reached the max number of sets for the demo.\n\nSign up now to create a complete show. (It's free.)");
}
else
{
alert("You have reached the max number of sets.");
}
setTimeout("EDITOR.isAddingSet = false;", 200);
return false;
}
if (this.FFRXHX != this.maxSet)
{
this.insertSet();
setTimeout("EDITOR.isAddingSet = false;", 200);
return false;
}
if (! this.FFNHHT[ this.FFRXHX ])
{
this.FFNHHT[ this.FFRXHX ] = [];
}
this.FFNHHT[ this.FFRXHX + 1 ] = this.FFNHHT[ this.FFRXHX ].slice();
newSetNumber(this.FFRXHX + 1);
this.saveSet();
this.maxSet += 1;
this.FFRXHX = this.maxSet;
EDITOR.FFNJLO[ this.FFRXHX  ] = [];
this.setConfig[this.FFRXHX] = [];
this.resetPace();
for (i=0; i < this.marchers.length; i++)
{
this.marchers[i].addSet(this.FFRXHX);
}
this.saveSet();
EDITOR.setIsChanged = false;
EDITOR.addSetToGraph(this.FFRXHX);
EDITOR.highlightSetBlock(this.FFRXHX);
$('setblock'+(this.FFRXHX-1)).style.backgroundColor = '#97D2A2';
if (EDITOR.show.FFRXHX == 1 && EDITOR.helpLevel < 1)
{
EDITOR.helpLevel = 1;
newHelp("Move them to their new spots, and click \"Play\"");
}
if (EDITOR.show.FFRXHX == 2)
{
hide('help');
}
if ($('studiosublinks'))
{
}
setTimeout("EDITOR.isAddingSet = false;", 200);
EDITOR.updateSetPins();
};
this.jumpToNextSet = function ()
{
if (EDITOR.isPlaying)
return false;
if (this.FFRXHX + 1 <= this.maxSet)
{
this.forceJumpToSet(this.FFRXHX + 1);
}
};
this.jumpToPrevSet = function ()
{
if (EDITOR.isPlaying)
return false;
if (this.FFRXHX > 0)
{
this.forceJumpToSet(this.FFRXHX - 1);
}
};
this.jumpToFirstSet = function ()
{
if (EDITOR.isPlaying)
return false;
if (this.FFRXHX > 0)
{
this.forceJumpToSet(0);
}
};
this.jumpToLastSet = function ()
{
if (EDITOR.isPlaying)
return false;
if (this.maxSet > 0)
{
this.forceJumpToSet(this.maxSet);
}
};
this.saveSet = function ()
{
if (! EDITOR.isPlaying)
{
for (i=0; i < this.marchers.length; i++)
{
this.marchers[i].saveSet(this.FFRXHX);
}
}
};
this.deleteSet = function ()
{
if (EDITOR.isPlaying || this.maxSet == 0)
return false;
if (confirm("Are you sure you want to delete Set #" + this.FFRXHX + "?"))
{
this.maxSet --;
for (i=0; i < this.marchers.length; i++)
{
this.marchers[i].deleteSet(this.FFRXHX);
}
this.setConfig.splice(this.FFRXHX, 1);
EDITOR.FFNJLO.splice(this.FFRXHX, 1);
EDITOR.FFROVE.splice(this.FFRXHX, 1);
this.FFNHHT.splice(this.FFRXHX, 1);
var newSet = this.FFRXHX - 1;
if (this.FFRXHX == 0)
newSet = 0;
this.jumpToSet(newSet);
EDITOR.redrawSetPanel();
EDITOR.redrawSetBlock(this.FFRXHX);
EDITOR.highlightSetBlock(this.FFRXHX);
action_message("Set Deleted.");
}
};
this.insertSet = function ()
{
if (EDITOR.isPlaying)
return false;
if (this.maxSet >= MAX_SETS)
{
alert("You already have the maximum number of sets.");
return false;
}
if (confirm("Insert a new copy of the current set?"))
{
this.saveSet();
for (i=0; i < this.marchers.length; i++)
{
this.marchers[i].insertSet(this.FFRXHX);
}
this.maxSet += 1;
this.setConfig.splice(this.FFRXHX+1, 0, [ this.setConfig[this.FFRXHX][0], this.setConfig[this.FFRXHX][1] ] );
EDITOR.FFNJLO.splice(this.FFRXHX + 1, 0, []);
EDITOR.FFROVE.splice(this.FFRXHX + 1, 0, []);
if (! this.FFNHHT[ this.FFRXHX ])
{
this.FFNHHT[ this.FFRXHX ] = [];
}
this.FFNHHT[ this.FFRXHX + 1 ] = this.FFNHHT[ this.FFRXHX ].slice();
EDITOR.redrawSetPanel();
this.jumpToSet(this.FFRXHX + 1);
action_message("New set inserted.");
EDITOR.setIsChanged = false;
EDITOR.updateSetPins();
this.saveSet();
}
};
this.resetSet = function ()
{
if (EDITOR.isPlaying)
return false;
if (this.FFRXHX == 0)
{
alert("You can't reset the first set.\n\nClick 'Start New Show' ");
return false;
}
if (confirm("Discard all changes and copy the preceding set?"))
{
EDITOR.FFVHTC();
for (i=0; i < this.marchers.length; i++)
{
this.marchers[i].resetSet(this.FFRXHX, this.FFRXHX - 1);
}
this.setConfig[this.FFRXHX][SET_CONFIG_PACE] = this.setConfig[this.FFRXHX - 1][SET_CONFIG_PACE];
this.setConfig[this.FFRXHX][SET_CONFIG_PAUSE] = this.setConfig[this.FFRXHX - 1][SET_CONFIG_PAUSE];
this.FFNHHT[ this.FFRXHX ] = [];
this.redrawSetConfig();
if (this.FFRXHX == this.maxSet)
EDITOR.setIsChanged = false;
this.saveSet();
}
};
this.FFGTHE = function (marchers)
{
if (marchers.length < 3 || EDITOR.FFAUEL == "supergroup" || EDITOR.FFAUEL == "section")
{
return false;
}
if (! this.FFNHHT[ this.FFRXHX ])
{
this.FFNHHT[ this.FFRXHX ] = [];
}
var gid = this.FFKSIE();
for (var i=0,m; m = marchers[i]; i++)
{
this.FFNHHT[ this.FFRXHX ][ m.id ] = gid;
}
this.FFNHHT[ this.FFRXHX ][ gid ] = marchers.slice();
};
this.FFKSIE = function ()
{
++ this.FFTKRF;
return this.FFTKRF;
};
this.FFRPCR = function (marchers)
{
if (! this.FFNHHT[ this.FFRXHX ])
{
this.FFNHHT[ this.FFRXHX ] = [];
}
for (var i=0,m; m = marchers[i]; i++)
{
this.FFRQPX(m);
}
};
this.FFRQPX = function (marcher)
{
if (! this.FFNHHT[ this.FFRXHX ])
{
return false;
}
var gid = this.FFNHHT[ this.FFRXHX ][ marcher.id ];
if (gid)
{
var group = this.FFNHHT[ this.FFRXHX ][ gid ];
for (var i=0,m; m = group[i]; i++)
{
this.FFNHHT[ this.FFRXHX ][ m.id ] = null;
}
this.FFNHHT[ this.FFRXHX ][ gid ] = null;
}
};
this.FFOGRL = function (marcher)
{
var thisSet = this.FFNHHT[ this.FFRXHX ] || [  ];
var groupID = thisSet[ marcher.id ];
var group = [];
if (! groupID)
{
var group1 = this.FFNMAR(marcher);
for (var i=0,m; m = group1[i]; i++)
{
if (thisSet && thisSet[ m.id ])
{
continue;
}
else
{
group.push(m);
}
}
}
else
{
var group1 = thisSet[ groupID ];
for (var i=0,m; m = group1[i]; i++)
{
if (thisSet[ m.id ] && thisSet[ m.id ] != groupID)
{
continue;
}
else
{
group.push(m);
}
}
}
return group;
};
this.FFAHTE = function (marcher, isCtrl)
{
throttle('quick_select', 50);
EDITOR.FFAUEL = "group";
var group = this.FFOGRL(marcher);
var allSelected = true;
for (var i=0,m; m = group[i]; i++)
{
if (! m.FFUIXO) { allSelected = false; break; }
}
if (allSelected)
{
EDITOR.FFAUEL = "supergroup";
for (var i=0,m; m = group[i]; i++)
{
EDITOR.FFSTJQ(m);
}
EDITOR.quickHighlightGroup(marcher);
return true;
}
else
{
EDITOR.FFAUEL = "supergroup";
EDITOR.quickUnhighlight();
for (var i=0,m; m = group[i]; i++)
{
EDITOR.FFQLNH(m);
}
return true;
}
};
this.resetMarchers = function (isCtrl)
{
if (EDITOR.isPlaying)
return false;
if (this.FFRXHX == 0 && ! isCtrl)
{
alert("You can't Reset the first set.");
return false;
}
else if (this.FFRXHX == this.maxSet && isCtrl)
{
alert("You can't Reverse Reset the last set.");
return false;
}
var action = "Reset";
var fromSet = this.FFRXHX - 1;
if (isCtrl)
{
action = "Reverse Reset";
fromSet = this.FFRXHX + 1;
}
if (confirm(action + " the selected marchers?"))
{
EDITOR.FFVHTC();
for (i=0; i < EDITOR.FFNWUB.length; i++)
{
EDITOR.FFNWUB[i].resetSet(this.FFRXHX, fromSet);
}
}
};
this.deleteMarchers = function (isCtrl)
{
if (EDITOR.isPlaying)
return false;
if (isCtrl)
{
if (confirm("Un-Delete all deleted marchers?"))
{
EDITOR.FFEQGC();
var numRestored = 0;
for (i=0; i < this.marchers.length; i++)
{
if (this.marchers[i].isDeleted)
{
this.marchers[i].undelete();
++ numRestored;
EDITOR.FFQLNH(this.marchers[i]);
EDITOR.FFAUEL = "restore";
}
}
action_message(numRestored + " marchers un-deleted.");
}
}
else
{
if (EDITOR.FFNWUB.length == 0)
{
alert("No marchers are selected.");
return false;
}
if (confirm("Delete the selected marchers?\n\n(You can press Ctrl-Delete to bring them back.)"))
{
var numDeleted = 0;
for (i=0; i < EDITOR.FFNWUB.length; i++)
{
EDITOR.FFNWUB[i].dodelete();
++ numDeleted;
}
var isOk = false;
for (i=0; i < this.marchers.length; i++)
{
if (! this.marchers[i].isDeleted)
{
isOk = true;
break;
}
}
if (! isOk)
{
for (i=0; i < EDITOR.FFNWUB.length; i++)
{
EDITOR.FFNWUB[i].undelete();
}
alert('You must have at least one marcher on the field.');
return false;
}
else
{
EDITOR.FFEQGC();
}
action_message(numDeleted + " marchers deleted.", numDeleted * 2);
}
}
};
this.tradeSets = function ()
{
if (EDITOR.isPlaying)
return false
if (EDITOR.FFNWUB.length != 2)
{
alert("Select the two marchers that will trade spots with each other.");
return false;
}
var m0 = EDITOR.FFNWUB[0];
var m1 = EDITOR.FFNWUB[1];
if (m0.section != m1.section)
{
}
if (confirm("Have the selected marchers trade spots?\n\nThis will affect all of their future sets."))
{
action_message("Sets traded.")
this.saveSet();
EDITOR.FFVHTC();
for (var s = this.FFRXHX; s <= this.maxSet; s++)
{
var tmp = [ m0.sets[s][0], m0.sets[s][1] ];
m0.sets[s][0] = m1.sets[s][0];   m0.sets[s][1] = m1.sets[s][1];
m1.sets[s][0] = tmp[0];          m1.sets[s][1] = tmp[1];
}
m0.jumpToSet(this.FFRXHX);
m1.jumpToSet(this.FFRXHX);
}
};
this.selectAllMarchers = function ()
{
EDITOR.FFEQGC(true);
for (m=0; m < this.marchers.length; m++)
{
EDITOR.FFQLNH(this.marchers[m]);
EDITOR.FFAUEL = "all";
}
};
this.selectMarchersByLine = function (endMarcher)
{
var first = EDITOR.FFNWUB[ EDITOR.FFNWUB.length - 1 ];
var angle = endMarcher.angleToMarcher(first);
if (first.id == endMarcher.id)
{
return false;
}
EDITOR.FFVHTC('selectline', true);
var checkX = first.x;
var checkY = first.y;
var numMisses = 0;
var isDone = false;
while (! isDone && checkX > 0 && checkX < FIELD_SIZE_X && checkY > 0 && checkY < FIELD_SIZE_Y)
{
var checkX = checkX + Math.sin(angle * Math.PI / 180) * 12;
var checkY = checkY + Math.cos(angle * Math.PI / 180) * 12 * -1.0;
var boxSizeX = 18;
var boxSizeY = 18;
var boxLeft = checkX - 9;
var boxTop = checkY - 9;
var isFound = false;
for (i=0; i < EDITOR.show.marchers.length; i++)
{
var marcher = EDITOR.show.marchers[i];
if (marcher.section == SECTION_PROP || marcher.isGhost)
{
continue;
}
var mx = marcher.x;
var my = marcher.y;
if (mx > boxLeft && mx < boxLeft + boxSizeX && my > boxTop && my < boxTop + boxSizeY)
{
if (marcher.FFUIXO)
{
EDITOR.FFSTJQ(marcher);
}
EDITOR.FFQLNH(marcher);
isFound = true;
if (marcher.id == endMarcher.id)
{
isDone = true;
}
break;
}
}
if (! isFound)
{
++ numMisses;
}
}
};
this.FFTCHQ = function (mainMarcher, isCtrl)
{
if (! isCtrl)
{
EDITOR.FFEQGC(true);
}
EDITOR.FFAUEL = "section";
var selMarchers = this.FFNMAR(mainMarcher);
var selByFlagColor = (mainMarcher.section == SECTION_GUARD && EDITOR.isPremium) ? true : false;
for (m=0; m < selMarchers.length; m++)
{
EDITOR.FFQLNH( selMarchers[m] );
}
};
this.FFNMAR = function (mainMarcher)
{
var smarchers = [];
var selByFlagColor = (mainMarcher.section == SECTION_GUARD && EDITOR.isPremium) ? true : false;
for (m=0; m < this.marchers.length; m++)
{
var marcher = this.marchers[m];
if (selByFlagColor)
{
if (marcher.section == mainMarcher.section && marcher.flagNum == mainMarcher.flagNum)
{
smarchers.push(marcher);
}
}
else
{
if (marcher.section == mainMarcher.section && marcher.hornType == mainMarcher.hornType && marcher.state == mainMarcher.state)
{
smarchers.push(marcher);
}
}
}
return smarchers;
};
this.FFGLND = function (baseMarcher)
{
var selMarchers = this.FFNMAR(baseMarcher);
for (m=0; m < selMarchers.length; m++)
{
var marcher = selMarchers[m];
if (marcher.FFUIXO)
{
EDITOR.FFSTJQ(marcher);
}
}
};
this.selectEveryOtherMarcher = function (isCtrl)
{
if (! this.requireOrderSelect())  {  return false; }
var start = (isCtrl) ? 0 : 1;
EDITOR.FFVHTC('splitselect', true);
var deselect = [];
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
if (m % 2 == start)
{
deselect.push(EDITOR.FFNWUB[m]);
}
}
for (m=0; m < deselect.length; m++)
{
EDITOR.FFSTJQ(deselect[m]);
}
EDITOR.show.FFGTHE(EDITOR.FFNWUB);
};
this.selectLongestMarcher = function ()
{
if (this.FFRXHX == 0)
{
return false;
}
this.saveSet();
var longest = this.getLongestPath(this.FFRXHX - 1);
if (longest['marcher'])
{
EDITOR.FFEQGC(true);
EDITOR.FFQLNH(longest['marcher']);
action_message("Longest Path to this Set");
}
};
this.FFWRHU = function (useHighlighted)
{
this.FFBREV = this.FFCBQQ(useHighlighted);
};
this.FFCBQQ = function (useHighlighted)
{
if (useHighlighted && EDITOR.FFFESA && MOUSE_DOWN)
{
return [EDITOR.FFFESA.x, EDITOR.FFFESA.y];
}
stop =  9999;
sleft =  9999;
sright = -9999;
sbot = -9999;
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
var marcher = EDITOR.FFNWUB[m];
if (marcher.x < sleft)
sleft = marcher.x;
if (marcher.x > sright)
sright = marcher.x;
if (marcher.y < stop)
stop = marcher.y;
if (marcher.y > sbot)
sbot = marcher.y;
}
return [sleft + ((sright - sleft) / 2), stop + ((sbot - stop) / 2)];
};
this.rotateMarchers = function (direction, isFine)
{
if (EDITOR.FFFESA && MOUSE_DOWN)
{
isFine = true;
}
if (EDITOR.FFNWUB.length > 1)
{
EDITOR.FFVHTC('rotate');
this.FFWRHU(true);
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
EDITOR.FFNWUB[m].rotate(this.FFBREV, direction, isFine);
}
}
};
this.scaleMarchers = function (directionX, directionY, isFine, skipChange)
{
if (EDITOR.FFFESA && MOUSE_DOWN)
{
isFine = true;
}
if (EDITOR.FFNWUB.length > 1)
{
if (! skipChange) {  EDITOR.FFVHTC('scale'); }
this.FFWRHU(true);
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
EDITOR.FFNWUB[m].scale(this.FFBREV, directionX, directionY, isFine);
}
}
};
this.toggleMarcherState = function (isReverse)
{
if (EDITOR.FFNWUB.length > 0)
{
var baseState = EDITOR.FFNWUB[0].state >> 0;
var baseSection = EDITOR.FFNWUB[0].section >> 0;
var baseEquipment = 0;
if (baseSection == SECTION_GUARD)
{
baseEquipment = EDITOR.FFNWUB[0].equipment.equipmentType;
}
var skipUpdate = false;
if (baseSection == SECTION_SNARE || baseSection == SECTION_TENOR || baseSection == SECTION_PLATES)
{
action_message(MARCHER_STATE_NAME[1 - baseState]);
}
else if (baseSection == SECTION_GUARD)
{
if (EDITOR.isPremium)
{
var diff = (isReverse) ? -1 : 1;
if (! EDITOR.animScroll)
{
diff = 0;
skipUpdate = true;
}
var nextState = baseState + diff;
if (nextState > NUM_ANIMS[baseEquipment] - 1)
{
nextState = 0;
}
else if (nextState < 0)
{
nextState = NUM_ANIMS[baseEquipment] - 1;
}
var animName = ANIM[baseEquipment][nextState].name;
if (animName)
{
var nextLabel = nextState + 1;
var anum = "<span style=\"font-size: 125%; position: relative; top: 3px; color: #FFBB4A; margin-right: 16px\">" + nextLabel + "</span>";
action_message(anum + animName, 0, 1500);
}
else
{
clear_action_message();
}
if (EDITOR.isPremium)
{
EDITOR.animScroll = true;
if (EDITOR.scrollID)
{
clearTimeout(EDITOR.scrollID);
EDITOR.scrollID = 0;
}
EDITOR.scrollID = setTimeout("EDITOR.animScroll = false;", 1500);
}
}
}
if (! skipUpdate)
{
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
var marcher = EDITOR.FFNWUB[m];
var sectionMatch = baseSection;
if (sectionMatch == SECTION_SNARE || sectionMatch == SECTION_TENOR)
{
if (marcher.section == SECTION_SNARE || marcher.section == SECTION_TENOR)
{
sectionMatch = marcher.section;
}
}
if (marcher.section == sectionMatch)
{
if (sectionMatch == SECTION_GUARD && marcher.equipment.equipmentType != baseEquipment)
{
}
else
{
marcher.togglePlayState(baseState, isReverse);
}
}
}
EDITOR.show.FFGTHE(EDITOR.FFNWUB);
}
}
};
this.ghostMarchers = function (isCtrl)
{
if (EDITOR.FFNWUB.length)
{
if (isCtrl)
{
for (m=0; m < EDITOR.show.marchers.length; m++)
{
if (! EDITOR.show.marchers[m].FFUIXO)
{
EDITOR.show.marchers[m].setGhost(true);
}
}
}
else
{
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
EDITOR.FFNWUB[m].setGhost(true);
}
EDITOR.FFEQGC();
}
action_message("Ghost is ON");
}
else
{
var gmarchers = [];
for (m=0; m < this.marchers.length; m++)
{
if (this.marchers[m].isGhost)
{
this.marchers[m].setGhost(false);
gmarchers.push(this.marchers[m]);
}
}
EDITOR.show.FFGTHE(gmarchers);
}
};
this.hideProps = function ()
{
if (! EDITOR.isPremium) { return false; }
EDITOR.show.propsHidden = (EDITOR.show.propsHidden + 1) % 2;
var numProps = 0;
for (m=0; m < this.marchers.length; m++)
{
if (this.marchers[m].section == SECTION_PROP)
{
this.marchers[m].deselect();
++ numProps;
}
}
if (! numProps)
{
alert('Sorry, no props found.\n\nUse the Studio below to add some to the show.');
return false;
}
if (EDITOR.show.propsHidden)
{
for (m=0; m < this.marchers.length; m++)
{
if (this.marchers[m].section == SECTION_PROP && ! this.marchers[m].isDeleted)
{
this.marchers[m].setGhost(true);
}
}
}
else
{
for (m=0; m < this.marchers.length; m++)
{
if (this.marchers[m].section == SECTION_PROP && ! this.marchers[m].isDeleted)
{
this.marchers[m].setGhost(false);
}
}
}
};
this.toggleMarcherEquipment = function ()
{
if (EDITOR.FFNWUB.length > 0)
{
var mainMarcher = EDITOR.FFNWUB[0];
if (mainMarcher.section == SECTION_GUARD)
{
EDITOR.show.changeFlags();
EDITOR.show.FFGTHE(EDITOR.FFNWUB);
}
else if (mainMarcher.section == SECTION_BRASS)
{
this.toggleHornType();
EDITOR.show.FFGTHE(EDITOR.FFNWUB);
}
else
{
alert("You can only change equipment for brass or guard members.");
return 0;
}
}
};
this.toggleHornType = function ()
{
if (this.maxSet != 0)
{
if (! throttle("equipment", 20 * 1000) )
{
if (! confirm("Change equipment for these marchers?"))
{
return 0;
}
}
}
var baseState = EDITOR.FFNWUB[0].hornType;
var newHorn = (baseState + 1) % NUM_HORN_TYPES;
action_message(HORN_NAME[newHorn]);
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
if (EDITOR.FFNWUB[m].section == SECTION_BRASS)
{
EDITOR.FFNWUB[m].toggleEquipment(newHorn);
}
}
};
this.addSixthBass = function ()
{
if (! EDITOR.isPremium)
{
return false;
}
if (this.maxSet != 0)
{
}
if (EDITOR.show.numBasses >= 6)
{
alert("Sorry, you already have a sixth bass.");
return 0;
}
if (! confirm("Add Bass #6 to this show?"))
{
return false;
}
var bass6 = this.addMarcher(EDITOR.show.marchers.length, [SECTION_BASS, 0], [snapX((6 * 72)) - 19, snapY(350), 0]);
bass6.spawnSetPin();
EDITOR.FFEQGC();
EDITOR.FFQLNH(bass6);
action_message("Added Sixth Bass");
for (m=0; m < this.marchers.length; m++)
{
if (this.marchers[m].section == SECTION_BASS)
{
bass6.setState( this.marchers[m].state );
break;
}
}
bass6.propagateSets();
this.saveSet();
return true;
};
this.toggleMarcherCaption = function ()
{
if (! EDITOR.isPremium)
{
return false;
}
if (! EDITOR.FFNWUB.length)
{
return 0;
}
if (this.maxSet != 0)
{
if (! throttle("caption", 20 * 1000) )
{
if (! confirm("Change caption for these marchers?"))
{
return 0;
}
}
}
if (EDITOR.FFNWUB.length > 0)
{
if (EDITOR.FFNWUB[0].section == SECTION_BASS)
{
alert("Sorry, you can't change the basses.");
return 0;
}
if (EDITOR.FFNWUB[0].section == SECTION_PROP)
{
return 0;
}
var baseSection = EDITOR.FFNWUB[0].section >> 0;
var newSection = (baseSection + 1) % 6;
if (newSection == SECTION_BASS) { newSection ++; }
if (newSection == SECTION_GUARD)
{
var selMarchers = this.getMarchersInSection(newSection);
if (selMarchers.length + EDITOR.FFNWUB.length > MAX_GUARD_PER_SHOW)
{
newSection ++;
}
}
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
if (EDITOR.FFNWUB[m].section != SECTION_BASS)
{
EDITOR.FFNWUB[m].toggleSection(newSection);
}
}
this.saveSet();
}
};
this.getMarchersInSection = function (section)
{
var sectionMarchers = []
for (var m=0, marcher; marcher = this.marchers[m]; m++)
{
if (marcher.section == section)
{
sectionMarchers.push(marcher);
}
}
return sectionMarchers;
};
this.followTheLeader = function (isCtrl)
{
if (EDITOR.FFNWUB.length > 2)
{
if (! this.requireOrderSelect())  {  return false; }
EDITOR.FFVHTC();
var train = EDITOR.FFNWUB.slice();
if (isCtrl)
{
train.reverse();
}
var prevSpot = [];
var numMarchers = train.length;
var leader = train[0];
EDITOR.setLeader(leader);
for (m=0; m < numMarchers; m++)
{
prevSpot[m] = [train[m].x, train[m].y];
}
var offX = train[0].x - train[1].x;
var offY = train[0].y - train[1].y;
leader.move(train[0].x + offX, leader.y + offY);
for (m=1; m < train.length; m++)
{
train[m].move(prevSpot[m-1][0], prevSpot[m-1][1]);
}
}
};
this.addRipple = function (isCtrl)
{
if (EDITOR.FFNWUB.length > 2)
{
var group = EDITOR.FFNWUB.slice();
if (! this.ripples[this.FFRXHX])
{
this.ripples[this.FFRXHX] = [];
}
this.ripples[this.FFRXHX].push(group);
action_message("Ripple Added");
}
};
this.requireOrderSelect = function ()
{
if (EDITOR.FFAUEL == "box")
{
alert("To use this shortcut, the marchers need to be selected in order.\n\nTip:  Hold down the  ! key and use the wand to select each marcher.");
EDITOR.FFEQGC(true);
return false;
}
return true;
};
this.cleanBlock = function (FFANNT)
{
if (EDITOR.FFNWUB.length < 4)
{
alert("You need at least 4 marchers to form a block.");
return false;
}
var FFJJKX = [999,-999,-999,999];
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
var marcher = EDITOR.FFNWUB[m];
if (marcher.y < FFJJKX[0])
FFJJKX[0] = marcher.y;
if (marcher.x > FFJJKX[1])
FFJJKX[1] = marcher.x;
if (marcher.y > FFJJKX[2])
FFJJKX[2] = marcher.y;
if (marcher.x < FFJJKX[3])
FFJJKX[3] = marcher.x;
}
if (FFANNT)
{
var FFHHXF = FFJJKX[1] - FFJJKX[3];
var FFPJVS = FFJJKX[2] - FFJJKX[0];
if (FFHHXF > FFPJVS)
{
FFJJKX[0] -= (FFHHXF - FFPJVS) / 2;
FFJJKX[2] += (FFHHXF - FFPJVS) / 2;
}
else
{
FFJJKX[1] += (FFPJVS - FFHHXF) / 2;
FFJJKX[3] -= (FFPJVS - FFHHXF) / 2;
}
}
var FFGIDI = [];
if (! FFANNT)
{
var FFBQQW = 0;
var FFVIUG = false;
var FFSXAG = false;
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
var marcher = EDITOR.FFNWUB[m];
if (Math.abs(marcher.x - FFJJKX[3]) < 12 )
{
++ FFBQQW;
if (Math.abs(marcher.y - FFJJKX[0]) < 12)
{
FFVIUG = true;
}
if (Math.abs(marcher.y - FFJJKX[2]) < 12)
{
FFSXAG = true;
}
}
}
if (FFBQQW > 1 && FFVIUG && FFSXAG)
{
if (EDITOR.FFNWUB.length % FFBQQW == 0)
{
var FFXWDH = EDITOR.FFNWUB.length / FFBQQW;
FFGIDI = [FFXWDH, FFBQQW];
}
}
}
if (! FFGIDI[0])
{
var FFVBNI = 99;
for (x=2; x <= EDITOR.FFNWUB.length / 2; x++)
{
if (EDITOR.FFNWUB.length % x == 0)
{
var y = EDITOR.FFNWUB.length / x;
if (x + y < FFVBNI)
{
FFVBNI = x + y;
FFGIDI = [x,y];
}
}
}
}
if (! FFGIDI[0])
{
alert("Sorry, you can't make an even block with " + EDITOR.FFNWUB.length + " marchers.");
return false;
}
EDITOR.FFVHTC();
var FFHHXF = FFJJKX[1] - FFJJKX[3];
var FFPJVS = FFJJKX[2] - FFJJKX[0];
if (FFHHXF > FFPJVS && FFGIDI[0] < FFGIDI[1])
{
tmp = FFGIDI[0];
FFGIDI[0] = FFGIDI[1];
FFGIDI[1] = tmp;
}
var blockIntX = FFHHXF / (FFGIDI[0] - 1);
var blockIntY = FFPJVS / (FFGIDI[1] - 1);
var FFILJA = [];
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
FFILJA.push(EDITOR.FFNWUB[m]);
}
FFILJA.sort(function (a,b) { return a.y - b.y })
for (y=0; y <= FFGIDI[1] - 1; y++)
{
row = [];
for (x=0; x <= FFGIDI[0] - 1; x++)
{
row.push(FFILJA.shift());
}
row.sort(function (a,b) { return a.x - b.x })
for (x=0; x <= FFGIDI[0] - 1; x++)
{
var pegX = FFJJKX[3] + x * blockIntX;
var pegY = FFJJKX[0] + y * blockIntY;
var marcher = row[x];
marcher.move(pegX, pegY);
}
}
};
this.cleanCurve = function (isCtrl)
{
if (EDITOR.FFNWUB.length < 3)
{
return false;
}
if (! this.requireOrderSelect())  {  return false; }
EDITOR.FFVHTC('curve');
for (var j = 0; j < 3; j ++)
{
var totalDist = 0;
var intervals = [];
for (var i=1,m; m = EDITOR.FFNWUB[i]; i++)
{
var prev = EDITOR.FFNWUB[i - 1];
var dist = m.FFKLXD([ prev.x, prev.y ]);
intervals[ m.id ] = dist;
totalDist += dist;
}
var avgInterval = totalDist / (EDITOR.FFNWUB.length - 1);
var prevAngle = 0;
for (var i=1,m; i < EDITOR.FFNWUB.length - 1; i++)
{
var m = EDITOR.FFNWUB[i];
var prev = EDITOR.FFNWUB[i - 1];
var newAngle = m.angleToMarcher(prev);
var currInterval = m.FFKLXD([ prev.x, prev.y ]);
var moveDist = avgInterval - currInterval;
var newX = m.x + Math.sin(newAngle * Math.PI / 180) * moveDist;
var newY = m.y + Math.cos(newAngle * Math.PI / 180) * moveDist * -1.0;
m.move(newX, newY);
}
}
};
this.cleanLine = function (isCtrl, skipHistory)
{
if (EDITOR.FFNWUB.length < 3)
{
return false;
}
if (! skipHistory)
{
EDITOR.FFVHTC();
}
this.FFWRHU();
EDITOR.FFNWUB.sort(function (a,b) { return a.id - b.id })
var marcher1 = null;
var FFSUVQ = 0;
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
var dist = EDITOR.FFNWUB[m].FFKLXD(this.FFBREV);
if (dist > FFSUVQ)
{
marcher1 = EDITOR.FFNWUB[m];
FFSUVQ = dist;
}
}
var marcher2 = null;
FFSUVQ = 0;
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
EDITOR.FFNWUB[m].FFQFGQ([marcher1.x, marcher1.y]);
var dist = EDITOR.FFNWUB[m].FFLOJC;
if (dist > FFSUVQ)
{
marcher2 = EDITOR.FFNWUB[m];
FFSUVQ = dist;
}
}
EDITOR.FFNWUB.sort(function (a,b) { return a.FFLOJC - b.FFLOJC })
var hastop = false;
var hasbot = false;
if (marcher1.x != marcher2.x && marcher1.y != marcher2.y)
{
for (m=1; m < EDITOR.FFNWUB.length-1; m++)
{
var marcher = EDITOR.FFNWUB[m];
if (marcher.x != marcher1.x && marcher.y == marcher1.y)
{
hastop = true;
}
else if (marcher.x != marcher2.x && marcher.y == marcher2.y)
{
hasbot = true;
}
}
}
if (hastop && hasbot)
{
if (Math.abs(marcher1.x - marcher2.x) > Math.abs(marcher1.y - marcher2.y))
{
var newY = marcher1.y - ((marcher1.y - marcher2.y) / 2);
marcher1.move(marcher1.x, newY);
marcher2.move(marcher2.x, newY);
}
else
{
var newX = marcher1.x - ((marcher1.x - marcher2.x) / 2);
marcher1.move(newX, marcher1.y);
marcher2.move(newX, marcher2.y);
}
}
if (! isCtrl)
{
if (Math.abs(marcher1.x - marcher2.x) < 16)
{
marcher2.move(marcher1.x, marcher2.y);
}
if (Math.abs(marcher1.y - marcher2.y) < 16)
{
marcher2.move(marcher2.x, marcher1.y);
}
}
var intX = (marcher2.x - marcher1.x) / (EDITOR.FFNWUB.length - 1);
var intY = (marcher2.y - marcher1.y) / (EDITOR.FFNWUB.length - 1);
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
var newX = marcher1.x + intX * m;
var newY = marcher1.y + intY * m;
EDITOR.FFNWUB[m].move(newX, newY);
}
if (! skipHistory)
{
}
};
this.FFQUAX = function ()
{
this.arcFocusAngle = (360 + this.FFKJUR - (90 * this.arcDirection)) % 360;
};
this.arcMarchers = function (direction, isFine)
{
if (EDITOR.FFNWUB.length < 3)
{
return false;
}
isFine = (isFine) ? true : false;
if (this.reverseArcKey)
{
}
var isInit = false;
if (! this.FFIOIL)
{
EDITOR.FFVHTC('arc');
this.FFIOIL = 100;
this.arcDirection = direction;
var prevAngles = [];
var center = this.FFCBQQ();
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
var marcher = EDITOR.FFNWUB[m];
prevAngles.push( FFHWGB([marcher.x, marcher.y], center ) );
}
this.cleanLine(true, true);
this.FFOKAO = this.FFCBQQ();
this.FFKJUR = EDITOR.FFNWUB[0].angleToMarcher(EDITOR.FFNWUB[EDITOR.FFNWUB.length-1]);
if (this.FFKJUR > 180) { this.FFKJUR -= 180; }
var totalOffset = 0;
for (var i = 0; i < prevAngles.length; i++)
{
totalOffset += angle_difference(360 + prevAngles[i], 360 + this.FFKJUR);
}
this.arcDirection = (totalOffset < 0) ? -1 : 1;
this.FFQUAX();
isInit = true;
}
else
{
var dist = this.FFIOIL * 0.2 * (direction * this.arcDirection);
if (isFine) {  dist *= 0.25; }
this.FFIOIL -= dist;
if (this.FFIOIL < 20)
{
this.FFIOIL = 20;
}
else if (this.FFIOIL > 350)
{
this.FFIOIL = 300;
this.arcDirection = (this.arcDirection > 0) ? -1 : 1;
this.reverseArcKey = (this.reverseArcKey) ? false : true;
this.FFQUAX();
}
}
this.moveArcFocus();
this.moveMarchersToArc();
};
this.moveArcFocus = function ()
{
this.arcFocus[0] = this.FFOKAO[0] + Math.sin(this.arcFocusAngle * Math.PI / 180) * this.FFIOIL;
this.arcFocus[1] = this.FFOKAO[1] + Math.cos(this.arcFocusAngle * Math.PI / 180) * this.FFIOIL * -1.0;
};
this.moveMarchersToArc = function ()
{
this.cleanLine(true, true);
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
EDITOR.FFNWUB[m].FFHHES(this.arcFocus, this.arcFocusAngle);
}
EDITOR.FFNWUB.sort(function (a,b) { return a.FFKTLE - b.FFKTLE });
if (this.arcDirection < 0)
{
}
var axisLen = EDITOR.FFNWUB[0].FFKLXD(this.FFOKAO);
var totalAngle = Math.atan2(axisLen * Math.PI / 180.0, this.FFIOIL * Math.PI / 180.0) * 180.0 / Math.PI;
totalAngle *= 2.0;
var startAngle = FFHWGB([EDITOR.FFNWUB[0].x, EDITOR.FFNWUB[0].y], this.arcFocus);
var angleInterval = totalAngle / (EDITOR.FFNWUB.length-1);
var rad = EDITOR.FFNWUB[0].FFKLXD(this.arcFocus);
for (m=1; m < EDITOR.FFNWUB.length-1; m++)
{
var newAngle = startAngle + angleInterval * m;
var newX = this.arcFocus[0] + Math.sin(newAngle * Math.PI / 180) * rad;
var newY = this.arcFocus[1] + Math.cos(newAngle * Math.PI / 180) * rad * -1.0;
EDITOR.FFNWUB[m].move(newX, newY);
}
};
this.circleMarchers = function (doAlign, isOval)
{
if (EDITOR.FFNWUB.length < 3)
{
return false;
}
EDITOR.FFVHTC();
this.FFWRHU();
var FFHHXF = 0;
var FFPJVS = 0;
if (isOval)
{
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
var marcher = EDITOR.FFNWUB[m];
var distX = Math.abs(this.FFBREV[0] - marcher.x);
var distY = Math.abs(this.FFBREV[1] - marcher.y);
if (distX > FFHHXF) {  FFHHXF = distX; }
if (distY > FFPJVS) {  FFPJVS = distY; }
}
}
else
{
var longestRadius = 0;
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
var radius = EDITOR.FFNWUB[m].FFKLXD(this.FFBREV);
longestRadius += radius;
EDITOR.FFNWUB[m].FFHHES(this.FFBREV);
}
longestRadius = longestRadius / EDITOR.FFNWUB.length;
FFHHXF = longestRadius;
FFPJVS = longestRadius;
}
EDITOR.FFNWUB.sort(function (a,b) { return a.FFKTLE - b.FFKTLE })
var startAngle = EDITOR.FFNWUB[0].FFKTLE;
if (doAlign) {  startAngle = 0; }
var angleInterval = 360 / EDITOR.FFNWUB.length;
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
var newAngle = startAngle + (angleInterval * m);
var newX = this.FFBREV[0] + Math.sin(newAngle * Math.PI / 180) * FFHHXF;
var newY = this.FFBREV[1] + Math.cos(newAngle * Math.PI / 180) * FFPJVS * -1.0;
EDITOR.FFNWUB[m].move(newX, newY);
}
};
this.scatterMarchers = function (isCtrl)
{
if (! isCtrl) {  this.scaleMarchers(1,1,true, true); }
EDITOR.FFVHTC('scatter');
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
var offX = 0;
var offY = 0;
if (isCtrl)
{
if (rand(0,1) == 1)
{
offX = rand(-4, 4);
}
}
else
{
var step = 4;
var angle = rand(0,90) * 4;
var offX = Math.sin(angle * Math.PI / 180) * step;
var offY = Math.cos(angle * Math.PI / 180) * step * -1.0;
}
EDITOR.FFNWUB[m].nudge(offX, offY);
}
};
this.nudgeMarchers = function (offX, offY)
{
if (! EDITOR.FFNWUB.length)
{
return false;
}
EDITOR.FFVHTC('nudge');
this.FFBREV[0] += offX;
this.FFBREV[1] += offY;
for (m=0; m < EDITOR.FFNWUB.length; m++)
{
EDITOR.FFNWUB[m].nudge(offX, offY);
}
};
this.addMarcher = function (aid, marcherConfig, startSet)
{
if (! marcherConfig)
{
marcherConfig = [0,0];
}
var section = marcherConfig[0];
var hornType = marcherConfig[1];
var uniformNum = marcherConfig[2];
if (! section)
{
section = SECTION_BRASS;
}
var bassNum;
if (section == SECTION_BASS)
{
this.numBasses ++;
bassNum = this.numBasses;
}
var m = new oMarcher(aid, [section, hornType, uniformNum], bassNum);
m.setSprite();
m.init(startSet);
this.marchers.push(m);
EDITOR.marcherById[aid] = m;
return m;
};
this.addProps = function ()
{
if (EDITOR.hasProps)
{
alert("Sorry, you already have props in this show.");
return false;
}
if (EDITOR.show.maxSet > 0)
{
}
if (! confirm("Add props to this show?"))
{
return false;
}
if (EDITOR.cheats['chairs'])
{
var slotX = 0;
var FFMBQG = 80;
var aid = this.marchers.length;
for (var i = 0; i < 64; i ++)
{
var m = this.addMarcher(aid, [SECTION_PROP, 0], [snapX((4 * 72)) + (slotX * 31), FFMBQG, 0]);
++ aid;
++ slotX;
if (slotX % 8 == 0)
{
slotX = 0;
FFMBQG += 31;
}
m.propagateSets();
}
}
else
{
var aid = this.marchers.length;
for (var i = 0; i < 10; i ++)
{
var m = this.addMarcher(aid, [SECTION_PROP, 0], [snapX((1 * 72) + i * 72 - 12 + 36), 48, 0]);
++ aid;
m.propagateSets();
}
}
this.saveSet();
action_message("Props Added");
};
this.setLongestPath = function ()
{
var hasToss = false;
this.longestPath = 0;
for (var i = 0, m; m = this.marchers[i]; i++)
{
if (m.isDeleted) continue;
var dist = m.comparitiveDistToNextSet(this.FFRXHX);
if (dist > this.longestPath)
{
this.longestPath = dist;
}
if (m.section == SECTION_GUARD)
{
if (m.equipment.currentAnim.doToss)
{
hasToss = true;
}
}
}
this.longestPath = Math.sqrt(this.longestPath);
var longest = this.getLongestPath(this.FFRXHX);
if (EDITOR.isSlowPlay)
{
longest['dist'] *= 3;
}
else if (EDITOR.isFastPlay)
{
longest['dist'] *= 0.4;
}
this.longestPath = longest['dist'];
this.timeInterval = (this.longestPath / PIXELS_PER_SEC) * FRAME_MILLISECS;
this.timeInterval = Math.ceil((this.timeInterval) / FRAME_STEP_MILLISECS) * FRAME_STEP_MILLISECS;
if (this.setConfig[this.FFRXHX] && ! EDITOR.isFastPlay)
{
this.timeInterval += this.setConfig[this.FFRXHX][SET_CONFIG_PACE] * FRAME_STEP_MILLISECS;
}
if (this.timeInterval < FRAME_MIN_MILLISECS)
this.timeInterval = FRAME_MIN_MILLISECS;
if (hasToss && this.timeInterval < MIN_TOSS_MILLISECS)
{
this.timeInterval = MIN_TOSS_MILLISECS;
}
};
this.getLongestPath = function (fromSet)
{
var FFSUVQ = 0;
var longestMarcher = 0;
for (var i = 0, m; m = this.marchers[i]; i++)
{
if (m.isDeleted) continue;
var dist = m.comparitiveDistToNextSet(fromSet);
if (dist > FFSUVQ)
{
FFSUVQ = dist;
longestMarcher = m;
}
}
FFSUVQ = Math.sqrt(FFSUVQ);
return {  dist : FFSUVQ, marcher : longestMarcher };
};
this.setShowLength = function ()
{
var total = 0;
for (s=0; s < this.maxSet; s++)
{
total += this.setTime[s];
}
this.totalTime = total;
};
this.processShowData = function (data)
{
if (data.substr(0,7) != "[begin]")
{
eval(data);
this.showConfig = showConfig;
this.loadedSets = sets;
this.setConfig = setConfig;
if (! defined(this.showConfig[SHOW_UNIFORM]))
{
this.showConfig[SHOW_UNIFORM] = 0;
this.showConfig[SHOW_FLAG1] = 0;
}
else
{
-- this.showConfig[SHOW_UNIFORM];
-- this.showConfig[SHOW_FLAG1];
}
this.showConfig[SHOW_GUARD_UNIFORM] = this.showConfig[SHOW_UNIFORM];
}
else
{
this.showConfig = [];
this.loadedSets = [];
this.setConfig = [];
var setNum = 0;
var lines = data.split(LINE_DELIM);
for (var l=0, line; line = lines[l]; l++)
{
if (lines[l].substr(0,1) == "[")  {  continue; }
var parts = lines[l].split("=");
if (parts[0] == "show")
{
var els = parts[1].split("|");
for (var e=0, el; el=els[e]; e++)
{
this.showConfig.push(el >> 0);
}
if (this.showConfig.length <= 2)
{
-- this.showConfig[SHOW_FLAG1];
-- this.showConfig[SHOW_UNIFORM];
this.showConfig[SHOW_GUARD_UNIFORM] = this.showConfig[SHOW_UNIFORM];
}
}
else if (parts[0] == "marcher")
{
var els = parts[1].split("|");
for (var e=0, el; el=els[e]; e++)
{
var section = el.charAt(0);
var hornType = el.charAt(1);
if (! hornType) {  hornType = 0; }
var uniformNum = el.charAt(2);
if (! uniformNum) {  uniformNum = this.showConfig[SHOW_GUARD_UNIFORM]; }
this.marcherConfig.push([section, hornType, uniformNum]);
}
}
else if (parts[0] == "deleted")
{
var els = parts[1].split("|");
for (var e=0, el; el=els[e]; e++)
{
var marcherID = el;
this.marcherIsDeleted[marcherID] = true;
}
}
else if (parts[0] == "set")
{
var els = parts[1].split("|");
var setConf = "" + els.shift();
this.setConfig.push([toInt(setConf.charAt(0)), toInt(setConf.charAt(1))]);
var set = [];
for (var e=0, el; el=els[e]; e++)
{
var spot1 = el.substr(0,2);
var spot2 = el.substr(2,2);
var state = el.substr(4,1);
var flagNum = el.substr(5,1);
if (! defined(flagNum)) {  flagNum = this.showConfig[SHOW_FLAG1]; }
set.push([ base62_to_dec(spot1), base62_to_dec(spot2), char_base62_to_dec(state), flagNum ]);
}
this.loadedSets.push(set);
}
}
}
};
this.loadSaved = function (showData)
{
if (EDITOR.mode == MODE_VIEW)
{
this.editorVersion = LOADED.editorVersion;
if (! this.editorVersion)
{
this.editorVersion = EDITOR_VERSION;
}
if (this.editorVersion <= 1.01)
{
FRAME_MIN_MILLISECS = 750;
}
}
else if (EDITOR.mode == MODE_EDIT && LOADED)
{
this.editorVersion = LOADED.editorVersion;
}
if (! showData)
{
showData = LOADED.showData;
}
this.processShowData( showData );
this.isSetup = true;
if (this.showConfig.length < 1)
{
this.showConfig[SHOW_UNIFORM] = 0;
this.showConfig[SHOW_FLAG1] = 0;
}
if (! defined(this.showConfig[SHOW_GUARD_UNIFORM]))
{
this.showConfig[SHOW_GUARD_UNIFORM] = this.showConfig[SHOW_UNIFORM];
}
if (EDITOR.isPremium)
{
this.showConfig[SHOW_GUARD_UNIFORM] = 0;
}
if (EDITOR.isPremium)
{
this.showConfig[SHOW_FLAG1] = 0;
}
this.maxSet = this.loadedSets.length - 1;
this.spawnMarchers();
for (s=0; s < this.loadedSets.length; s++)
{
for (m=0; m < this.loadedSets[s].length; m++)
{
if (this.loadedSets[s][m])
{
this.marchers[m].loadSet(this.loadedSets[s][m]);
}
}
if (! this.setConfig[s])
{
this.setConfig[s] = [0,0];
}
}
for (m=0; m < this.loadedSets[0].length; m++)
{
if (this.marcherIsDeleted[ this.marchers[m].id ])
{
this.marchers[m].dodelete();
}
}
for (m=0; m < this.loadedSets[0].length; m++)
{
this.marchers[m].move(this.marchers[m].sets[0][0], this.marchers[m].sets[0][1]);
this.marchers[m].setFlag(this.marchers[m].sets[0][3]);
this.marchers[m].setState(this.marchers[m].sets[0][2]);
}
if (EDITOR.mode == MODE_VIEW && this.editorVersion <= 1.26)
{
for (m=0; m < this.loadedSets[0].length; m++)
{
if (this.marchers[m].isOutOfBounds)
{
this.marchers[m].dodelete();
}
}
}
if (EDITOR.mode == MODE_EDIT)
{
EDITOR.addExtraSets();
if (EDITOR.isPremium)
{
NUM_HORN_TYPES = NUM_HORN_TYPES_PREMIUM;
}
EDITOR.redrawSetPanel();
EDITOR.show.redrawSetConfig();
EDITOR.clearHistory();
EDITOR.spawnSetPins();
EDITOR.redrawSetBlock(0);
EDITOR.highlightSetBlock(0);
EDITOR.setIsChanged = true;
}
if (EDITOR.mode == MODE_VIEW)
{
this.hornsDown();
this.title = LOADED.showTitle;
this.authorID = LOADED.authorID;
this.authorName = LOADED.authorName;
this.authorURL = LOADED.authorURL;
$('title').innerHTML = '' + LOADED.showTitle + '';
$('titledrop').innerHTML = '' + LOADED.showTitle + '';
if (this.authorID > 0)
{
$('author').innerHTML = 'by <a href="' + this.authorURL + '">' + this.authorName + "</a>";
}
else
{
$('author').innerHTML = 'by ' + this.authorName;
}
$('authordrop').innerHTML = 'by ' + this.authorName;
if (EDITOR.isJudge)
{
$('author').style.visibility = 'hidden';
$('authordrop').style.visibility = 'hidden';
}
$('editoroverlay').style.visibility = "visible";
}
$('showloading').style.display = 'none';
fix_png();
};
this.loadDefault = function (startingSize)
{
this.showConfig[SHOW_UNIFORM] = 0;
this.showConfig[SHOW_FLAG1] = 0;
this.showConfig[SHOW_GUARD_UNIFORM] = 0;
this.isSetup = true;
this.setConfig[0] = [];
if ($('bandsetup'))
{
$('bandsetup').style.display = "none";
hide('help');
}
this.resetPace();
if (! IS_DEMO) //  && startingSize >= GROUP_SIZE_NORMAL
{
show('groupselect');
}
this.marchers = [];
if (EDITOR.groupType == GROUP_TYPE_CORPS)
{
this.loadFullCorps(startingSize);
}
else if (EDITOR.groupType == GROUP_TYPE_BRASS)
{
this.loadBrass(startingSize);
}
else if (EDITOR.groupType == GROUP_TYPE_GUARD)
{
this.loadGuard(startingSize);
}
else if (EDITOR.groupType == GROUP_TYPE_DRUMLINE)
{
this.loadDrumline(startingSize);
}
fix_png();
newHelp("Drag marchers to their starting spot, then click \"New Set\"");
this.saveSet();
EDITOR.clearHistory();
EDITOR.spawnSetPins();
};
this.loadFullCorps = function (startingSize)
{
var aid = 0;
if (EDITOR.trialGroup > 0)
{
startingSize = GROUP_SIZE_FAN;
}
if (IS_DEMO)
{
for (cx=0; cx < 14; cx++)
{
for (cy=0; cy < 4; cy++)
{
if (cx != 5 && cx != 6 && cx != 7 && cx != 8)
{
this.addMarcher(aid, [SECTION_BRASS, 0], [snapX(180 + cx * 36), snapY(130 + cy * 44), FRAME_BRASS_PLAY]);
aid ++;
}
}
}
$('showloading').style.display = 'none';
MAX_SETS = 5;
}
else if (USE_DEFAULT_SHOW_DATA)
{
this.loadSaved(GROUP_SHOW_DATA[GROUP_TYPE_CORPS][startingSize]);
}
else if (false)
{
for (cx=0; cx < 8; cx++)
{
for (cy=0; cy < 8; cy++)
{
this.addMarcher(aid, [SECTION_BRASS, 0], [snapX(72 + cx * 18), snapY(100 + cy * 18), FRAME_BRASS_PLAY]);
aid ++;
}
}
}
else
{
this.loadRaw();
}
};
this.loadRaw = function ()
{
var aid = 0;
for (cx=0; cx < 8; cx++)
{
for (cy=0; cy < 8; cy++)
{
this.addMarcher(aid, [SECTION_BRASS, 0], [snapX(72 + cx * 18), snapY(100 + cy * 18), FRAME_BRASS_PLAY]);
aid ++;
}
}
for (cx=0; cx < 9; cx++)
{
this.addMarcher(aid, [SECTION_SNARE, 0], [snapX((6 * 72) + cx * 18 - 16), snapY(100), FRAME_SNARE_SET]);
aid ++;
}
for (cx=0; cx < 5; cx++)
{
this.addMarcher(aid, [SECTION_TENOR, 0], [snapX((7 * 72) + cx * 18 - 16), snapY(172), FRAME_TENOR_SET]);
aid ++;
}
for (cx=0; cx < 5; cx++)
{
this.addMarcher(aid, [SECTION_BASS, 0], [snapX((7 * 72) + cx * 18 - 16), snapY(230), FRAME_BASS_LEFT]);
aid ++;
}
for (cx=0; cx < 25; cx++)
{
this.addMarcher(aid, [SECTION_GUARD, 0], [snapX((2 * 72) + cx * 18 - 16), snapY(300), FRAME_GUARD_SET]);
aid ++;
}
};
this.loadBrass = function (startingSize)
{
var aid = 0;
if (USE_DEFAULT_SHOW_DATA)
{
this.loadSaved(GROUP_SHOW_DATA[GROUP_TYPE_BRASS][GROUP_SIZE_NORMAL]);
}
else
{
for (cx=0; cx < 8; cx++)
{
for (cy=0; cy < 8; cy++)
{
this.addMarcher(aid, [SECTION_BRASS, 0], [snapX(72 + cx * 18), snapY(100 + cy * 18), FRAME_BRASS_PLAY]);
aid ++;
}
}
}
};
this.loadGuard = function (startingSize)
{
var aid = 0;
if (USE_DEFAULT_SHOW_DATA)
{
this.loadSaved(GROUP_SHOW_DATA[GROUP_TYPE_GUARD][startingSize]);
}
else
{
for (cx=0; cx < 6; cx++)
{
for (cy=0; cy < 5; cy++)
{
this.addMarcher(aid, [SECTION_GUARD, 0], [snapX((3 * 72) + cx * 36 - 16), snapY(100 + cy * 36), FRAME_GUARD_SET]);
aid ++;
}
}
}
};
this.loadDrumline = function (startingSize)
{
var aid = 0;
if (USE_DEFAULT_SHOW_DATA)
{
this.loadSaved(GROUP_SHOW_DATA[GROUP_TYPE_DRUMLINE][startingSize]);
}
else
{
for (cx=0; cx < 9; cx++)
{
this.addMarcher(aid, [SECTION_SNARE, 0], [snapX((7 * 72) + cx * 18 - 16), snapY(100), FRAME_SNARE_SET]);
aid ++;
}
for (cx=0; cx < 5; cx++)
{
this.addMarcher(aid, [SECTION_TENOR, 0], [snapX((7 * 72) + cx * 18 - 16), snapY(172), FRAME_TENOR_SET]);
aid ++;
}
for (cx=0; cx < 5; cx++)
{
this.addMarcher(aid, [SECTION_BASS, 0], [snapX((7 * 72) + cx * 18 - 16), snapY(230), FRAME_BASS_LEFT]);
aid ++;
}
for (cx=0; cx < 5; cx++)
{
this.addMarcher(aid, [SECTION_PLATES, 0], [snapX((7 * 72) + cx * 18 - 16), snapY(160), FRAME_PLATES_SET]);
aid ++;
}
}
};
this.spawnMarchers = function ()
{
var aid = 0;
for (m=0; m < this.loadedSets[0].length; m++)
{
if (this.loadedSets[0][m])
{
var marcher = this.addMarcher(aid, this.marcherConfig[aid]) // this.loadedSets[0][m]
aid ++;
}
}
};
this.togglePace = function ()
{
this.setConfig[this.FFRXHX][SET_CONFIG_PACE] = (this.setConfig[this.FFRXHX][SET_CONFIG_PACE] + 1) % NUM_STEPS_PACE;
this.redrawSetConfig();
};
this.togglePause = function ()
{
this.setConfig[this.FFRXHX][SET_CONFIG_PAUSE] = (this.setConfig[this.FFRXHX][SET_CONFIG_PAUSE] + 1) % NUM_STEPS_PAUSE;
this.redrawSetConfig();
EDITOR.redrawSetBlock(this.FFRXHX);
};
this.resetPace = function ()
{
this.setConfig[this.FFRXHX] = [];
this.setConfig[this.FFRXHX][SET_CONFIG_PACE] = 0;
this.setConfig[this.FFRXHX][SET_CONFIG_PAUSE] = 0;
this.redrawSetConfig();
};
this.redrawSetConfig = function ()
{
if (EDITOR.mode == MODE_EDIT)
{
if (this.setConfig[this.FFRXHX])
{
var bar = this.setConfig[this.FFRXHX][SET_CONFIG_PACE] * (100 / (NUM_STEPS_PACE - 1));
$('pacebar').style.width = bar + "%";
bar = this.setConfig[this.FFRXHX][SET_CONFIG_PAUSE] * (100 / (NUM_STEPS_PAUSE - 1));
$('pausebar').style.width = bar + "%";
}
}
};
this.jumpToSet = function (num)
{
if (num > this.maxSet)
{
return false;
}
this.FFRXHX = num;
var delayHornsDown = false;
if (EDITOR.isPlaying && this.setConfig[this.FFRXHX][SET_CONFIG_PAUSE] > 0)
{
delayHornsDown = true;
}
for (i=0; i < this.marchers.length; i++)
{
this.marchers[i].jumpToSet(num, delayHornsDown);
}
this.setLongestPath();
if (EDITOR.mode == MODE_EDIT)
{
EDITOR.highlightSetBlock(num);
EDITOR.show.redrawSetConfig();
updateAddSetLink();
if (this.FFRXHX == 0 && EDITOR.isRestored)
{
hide('help');
}
}
else if (EDITOR.mode == MODE_VIEW && EDITOR.isAnalyze)
{
EDITOR.hideOverlay();
EDITOR.updateStatus('Set ' + this.FFRXHX);
}
};
this.forceJumpToSet = function (num, refresh)
{
if (EDITOR.show.FFRXHX == num && ! refresh)
return false;
if (EDITOR.mode == MODE_EDIT)
{
if (! EDITOR.isPlaying)
{
EDITOR.show.saveSet();
}
}
this.jumpToSet(num);
EDITOR.updateSetPins();
if (EDITOR.isPlaying)
{
this.stop();
return false;
}
if (EDITOR.mode == MODE_EDIT)
{
if (! EDITOR.FFNJLO[EDITOR.show.FFRXHX])
{
EDITOR.FFNJLO[ EDITOR.show.FFRXHX ] = [];
EDITOR.FFROVE[ EDITOR.show.FFRXHX ] = [];
}
}
};
this.play = function ()
{
if (this.hasDescription)
{
show('showdesc');
setAlpha('showdesc', 95);
this.hasDescription = false;
return false;
}
else
{
EDITOR.hideOverlay();
if (this.maxSet == 0)
return false;
if (EDITOR.isPlaying)
return false;
show('stoplink');
hide('playlink');
this.jumpToSet(0);
this.hornsDown();
setTimeout("EDITOR.show.hornsUp()", 750);
setTimeout("EDITOR.show.playSet()", 1500);
setAlpha('editorbuttons', 25);
EDITOR.isPlaying = true;
}
this.frameCount = 0;
this.showStartTime = new Date().getTime();
};
this.stop = function ()
{
if (! EDITOR.isPlaying)
return false;
EDITOR.isPlaying = false;
EDITOR.isSlowPlay = false;
EDITOR.isFastPlay = false;
EDITOR.lockAutoSave = true;
setTimeout("EDITOR.lockAutoSave = false", 3000);
this.jumpToSet(this.FFRXHX, true);
clearInterval(this.intervalID);
this.intervalID = 0;
setAlpha('editorbuttons', 100);
if (EDITOR.mode == MODE_VIEW)
{
setTimeout("EDITOR.showOverlay()", 1250);
setTimeout("EDITOR.show.hornsDown()", 750);
if (EDITOR.isJudge && ! EDITOR.hasVoted)
{
setTimeout("show('votepanel')", 1800);
setTimeout("hide('abortlink')", 1800);
}
}
if (this.maxSet == 1 && EDITOR.helpLevel < 2)
{
EDITOR.helpLevel = 2;
if (! IS_DEMO)
newHelp("When you're done adding sets, click \"Publish Show\" (Menu)");
}
hide('stoplink');
show('playlink');
reset_anims(true);
EDITOR.updateSetPins();
};
this.guardLastSetIsOK = function ()
{
for (var m=0, marcher; marcher = this.marchers[m]; m++)
{
if (marcher.section == SECTION_GUARD && ! marcher.isDeleted)
{
if (marcher.getStateForLastSet() > NUM_FLAG_POSES - 1)
{
return false;
}
}
}
return true;
};
this.stopAndVote = function ()
{
if (EDITOR.isPlaying)
{
this.stop();
}
else
{
show('votepanel');
}
hide('abortlink');
};
this.abortShow = function ()
{
if (EDITOR.isPlaying)
{
this.stop();
}
};
this.launchPreview = function (previewURL)
{
EDITOR.postSaveAction = "preview";
EDITOR.previewURL = previewURL;
this.ajaxSave(false, true);
};
this.freezeShow = function (freezerURL)
{
EDITOR.showTitle = prompt("Work-in-Progress Title", EDITOR.showTitle);
if (! EDITOR.showTitle)
{
return false;
}
EDITOR.postSaveAction = "freezer";
EDITOR.freezerURL = freezerURL;
EDITOR.freezerURL += "&showTitle=" + escape(EDITOR.showTitle);
this.ajaxSave(false, true);
};
this.pressPlay = function ()
{
if (EDITOR.isPlaying)
return false;
if (this.maxSet == 0)
{
alert('You need more than one set.');
return false;
}
this.saveSet();
EDITOR.isPlaying = true;
show('stoplink');
hide('playlink');
hide('help');
this.saveSet();
this.hornsUp();
if (this.FFRXHX == this.maxSet)
{
if (this.FFRXHX > 0)
{
-- this.FFRXHX;
this.jumpToSet(this.FFRXHX);
}
setTimeout('EDITOR.show.startPlaySet()', 500);
}
else
{
setTimeout('EDITOR.show.playSet()', 500);
}
};
this.playSet = function ()
{
if (this.setConfig[this.FFRXHX][SET_CONFIG_PAUSE] > 0)
{
var now = new Date().getTime();
var delayMS = this.setConfig[this.FFRXHX][SET_CONFIG_PAUSE] * 200;
var endHalt = now + delayMS;
setTimeout('EDITOR.show.startPlaySet()', delayMS);
this.playHalt(endHalt);
}
else
{
this.startPlaySet();
}
};
this.playHalt = function (endHalt)
{
var fps = (ie7) ? FPS_IE : FPS_DEFAULT;
var ms = 1000 / fps;
var now = new Date().getTime();
if (now < endHalt - ms)
{
this.animateMarchers(now);
setTimeout('EDITOR.show.playHalt(' + endHalt + ')', ms);
}
else
{
EDITOR.show.startPlaySet()
}
};
this.startPlaySet = function ()
{
if (! EDITOR.isPlaying)
return false;
if (this.intervalID)
{
return false;
}
var fps = (ie7) ? FPS_IE : FPS_DEFAULT;
var ms = 1000 / fps;
this.startTime = new Date().getTime();
this.lastTweenTime = this.startTime;
this.intervalID = setInterval('EDITOR.show.advanceFrame()', ms);
this.setLongestPath();
this.setDelayedAnims();
reset_anims(false);
};
this.setDelayedAnims = function ()
{
for (var m=0, marcher; marcher = this.marchers[m]; m++)
{
marcher.nextAnimMS = 0;
marcher.nextAnimState = [];
}
var ripples = this.ripples[this.FFRXHX];
var longestRipple = 0;
if (ripples)
{
for (var r=0, ripple; ripple = ripples[r]; r++)
{
if (ripple.length > longestRipple)
{
longestRipple = ripple.length;
}
}
var rippleTime = longestRipple * 50;
if (rippleTime > this.timeInterval)
{
this.timeInterval = rippleTime;
}
for (var r=0, ripple; ripple = ripples[r]; r++)
{
var numMarchers = ripple.length;
var interval = (this.timeInterval / numMarchers) >> 0;
for (var m=0, marcher; marcher = ripple[m]; m++)
{
marcher.nextAnimState = marcher.sets[this.FFRXHX + 1];
marcher.nextAnimMS = (m+1) * interval;
}
}
}
};
this.animateMarchers = function (now, elapsedMS, setDuration)
{
var animChecked = {};
var doAnimate = {};
var animExists = {};
for (var m=0, marcher; marcher = this.marchers[m]; m++)
{
if (marcher.section == SECTION_GUARD)
{
var anid = marcher.equipment.equipmentType + ":" + marcher.equipment.animNum;
animExists[anid] = true;
}
}
for (var m=0, marcher; marcher = this.marchers[m]; m++)
{
if (marcher.section == SECTION_PROP)
{
continue;
}
else if (marcher.section == SECTION_GUARD && ! marcher.nextAnimMS)
{
var ganim = marcher.equipment.currentAnim;
var anid = marcher.equipment.equipmentType + ":" + marcher.equipment.animNum;
if (ganim.frames.length < 2 && ! ganim.doToss)
{
continue;
}
if (ganim.doToss)
{
var tossMS = 1400 - ganim.tossDelayMS;
var timeLeft = setDuration - elapsedMS;
if (! marcher.equipment.isInAir && setDuration > tossMS)
{
if (timeLeft > tossMS-400 && timeLeft < tossMS)
{
marcher.tossEquipment();
ganim = marcher.equipment.currentAnim;
anid = marcher.equipment.equipmentType + ":" + marcher.equipment.animNum;
}
else if (timeLeft > tossMS && timeLeft < tossMS+300  && marcher.preTossFrame == 1)
{
marcher.pretoss(2);
}
else if (timeLeft > tossMS+300 && timeLeft < tossMS+600  && ! marcher.preTossFrame && ! ganim.smoothToss)
{
marcher.pretoss(1);
}
}
}
if (! animChecked[anid])
{
if (ganim.animSpeedMS > 0 && EDITOR.show.FFRXHX != ganim.FFRXHX)
{
if (ganim.fnf || EDITOR.show.FFRXHX - ganim.FFRXHX > 1)
{
ganim.frameNum = 0;
if (! ganim.fnf)
{
var matchFrame = marcher.equipment.currentFrame;
for (var i = 0; i < ganim.frames.length; i ++)
{
if (matchFrame == ganim.frames[i])
{
ganim.frameNum = i + 1;
}
}
}
else
{
ganim.lastAnimTime = 0;
}
ganim.FFRXHX = EDITOR.show.FFRXHX;
ganim.loopSpeedMS = ganim.animSpeedMS;
ganim.loopNum = 0;
}
}
if (! ganim.loopSpeedMS) {  ganim.loopSpeedMS = ganim.animSpeedMS; }
if (ganim.animSpeedMS > 0 && now - ganim.lastAnimTime > ganim.loopSpeedMS)
{
ganim.frameNum = ganim.frameNum + 1;
if (ganim.frameNum > ganim.frames.length - 1)
{
if (ganim.fnf)
{
ganim.frameNum = ganim.frames.length - 1;
}
else
{
ganim.frameNum = ganim.frameNum % ganim.frames.length;
}
}
if (ganim.frameNum == 0 || (ganim.subloopFrame && ganim.frameNum % ganim.subloopFrame == 0))
{
ganim.loopNum += 1;
var variation = 0;
if (! ganim.doToss && ! ganim.tossSpeed)
{
var variations = [0,2,-1];
variation = variations[(EDITOR.show.FFRXHX + ganim.loopNum) % variations.length];
variation = (variation * (ganim.animSpeedMS * 0.12)) >> 0;
}
ganim.loopSpeedMS = ganim.animSpeedMS + variation;
}
ganim.lastAnimTime = now;
doAnimate[anid] = true;
}
animChecked[anid] = true;
}
if (ganim.syncOffset)
{
var otherAnimNum = marcher.equipment.animNum + ganim.syncOffset;
var oanid = marcher.equipment.equipmentType + ":" + otherAnimNum;
var otherAnim = ANIM[marcher.equipment.equipmentType][otherAnimNum];
if (animExists[oanid] && animChecked[oanid])
{
ganim.frameNum = otherAnim.frameNum;
doAnimate[anid] = doAnimate[oanid];
}
}
if (doAnimate[anid] && ! marcher.preTossFrame)
{
if (marcher.equipment.equipmentType == EQUIPMENT_FLAG && ! marcher.isTossing)
{
marcher.gotoFrame(ANIM_HANDS[marcher.equipment.equipmentType][ ganim.frames[ganim.frameNum] ]);
}
marcher.equipment.gotoFrame(ganim.frameNum);
}
}
else
{
marcher.animate(now, elapsedMS, setDuration);
}
}
};
this.advanceFrame = function ()
{
var now = new Date().getTime();
if (now - this.lastTweenTime < 10)
{
return false;
}
if (now - this.lastTweenTime > MAX_TWEEN_GAP_MS)
{
this.startTime += ((now - this.lastTweenTime) - MAX_TWEEN_GAP_MS);
}
this.frameCount ++;
this.lastTweenTime = now;
var elapsedMS = (now - this.startTime);
var progress = elapsedMS / this.timeInterval;
this.animateMarchers(now, elapsedMS, this.timeInterval);
if (progress < 1.0)
{
for (var m=0, marcher; marcher = this.marchers[m]; m++)
{
marcher.tween(this.FFRXHX, progress);
}
}
else
{
if (this.FFRXHX < this.maxSet)
{
this.FFRXHX ++;
this.jumpToSet(this.FFRXHX);
}
clearInterval(this.intervalID);
this.intervalID = 0;
if (this.FFRXHX < this.maxSet)
{
this.playSet();
}
else
{
this.stop();
}
}
};
this.publish = function ()
{
if (EDITOR.isPublished)
{
alert("This show has already been published.");
return false;
}
else if ($('showTitle').value.match(/(bored|first show|1st show|my 1st|my first|untitled|idk)/i))
{
alert("Please try to think of a more imaginative title. =\)");
return false;
}
else if ($('showDescription').value.length < 24 && $('showDescription').value.match(/(comment)/i))
{
alert("Please don't ask for comments in your show description.");
return false;
}
else if ($('showDescription').value.match(/youtube\.com/i))
{
if (! confirm("IMPORTANT\n\nIf you used a timekeeper marcher to sync the show, it MUST be deleted before publishing.\n\nPublish the show now?"))
{
return false;
}
}
else if ($('showTitle').value.match(/\brandom/i))
{
alert("Please try to think of something without 'random' in it. =\)");
return false;
}
else if ($('showTitle').value.match(/premium|subscri/i))
{
alert("Please don't base your title on the topic of subcriptions.  Thanks!");
return false;
}
else if ($('exhibition') && $('exhibition').checked)
{
if (! confirm("Note:  As an exhibition show,\nyou will NOT be able to re-publish it for judging.\n\nIf you want others to preview this show,\nuse \"Menu > Preview Show\", instead.\n\nPublish this show as exhibition?"))
{
return false;
}
}
clearInterval(EDITOR.saveIntervalID);
hideSavebox();
if (EDITOR.isPostEdit)
{
this.finishPublish();
}
else
{
EDITOR.doPublishAfterSave = true;
this.ajaxSave();
}
};
this.finishPublish = function ()
{
if (EDITOR.isPostEdit)
{
$('saving').innerHTML = "Re-Publishing Updated Show...";
this.saveSet();
this.saveToForm('republish');
}
else if ($('exhibition') && $('exhibition').checked)
{
$('saving').innerHTML = "Publishing Show for Exhibition...";
}
else
{
$('saving').innerHTML = "Sending Show to Judging Queue...";
}
this.showIsChanged = false;
show('saving');
$('saveForm').submit();
EDITOR.isPublished = true;
};
this.toggleAutoSave = function ()
{
EDITOR.doAutoSave = (EDITOR.doAutoSave) ? false : true;
var onOff = (EDITOR.doAutoSave) ? "ON" : "OFF";
EDITOR.numSaveHeartbeats = 0;
action_message("Auto Save is " + onOff);
};
this.ajaxSave = function (heartbeat, fromPreview)
{
if (EDITOR.isSaving) return false;
if (EDITOR.isPublished) return false;
if (IS_DEMO) return false;
if (EDITOR.isPlaying) return false;
if (! this.isSetup) return false;
if (EDITOR.isPostEdit) return false;
if (heartbeat)
{
if (! EDITOR.doAutoSave) return false;
if (! EDITOR.showIsChanged)
return false;
++ EDITOR.numSaveHeartbeats;
if (EDITOR.numSaveHeartbeats < SAVE_HEARTBEATS)
return false;
if (EDITOR.lockAutoSave)
{
return false;
}
}
else if (! heartbeat && ! fromPreview)
{
var now = new Date().getTime();
if (EDITOR.lastSaveTime > 0 && now - EDITOR.lastSaveTime < 10000)
{
alert("Please wait at least 10 seconds between saves.");
EDITOR.postSaveAction = "";
return true;
}
}
else if ((fromPreview || EDITOR.doPublishAfterSave) && EDITOR.saveBlockedByStudio)
{
alert("Please click 'Update Designs' first, to upgrade\nyour show graphics to the latest version.");
EDITOR.postSaveAction = "";
return true;
}
EDITOR.isSaving = true;
show('saving');
var time0 = get_now();
this.saveSet();
this.saveToForm();
AJAX_TIMEOUT_ID = setTimeout('ajax_problem()', AJAX_TIMEOUT_SECS * 1000);
if (true)
{
try
{
var remoteDoc = get_rpc_doc();
var html = "<form id=\"remoteForm\" method=\"post\" action=\"/remote/save_show.php?ts=" +get_now() + "\">";
html += "<textarea name=\"showData\">";
html += $('showData').innerHTML;
html += "</textarea>";
html += "<input type=\"hidden\" name=\"wipID\" value=\"" + EDITOR.wipID + "\">";
html += "</form>";
remoteDoc.write(html);
remoteDoc.getElementById('remoteForm').submit();
}
catch (e)
{
spawn_rpc();
}
}
else
{
var ajax = get_ajax();
var params = "wipID=" + EDITOR.wipID;
params += "&showData=" + $('showData').innerHTML;
ajax.open("POST", "/remote/save_show.php", true);
ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
ajax.setRequestHeader("Content-length", params.length);
ajax.setRequestHeader("Connection", "close");
var ajaxTime = 0;
ajax.onreadystatechange = function ()
{
if (ajax.readyState == 4 && ajax.status == 200)
{
save_response('saved');
var response = ajax.responseText;
}
}
ajax.send(params);
ajaxTime = get_now();
}
EDITOR.lastSaveTime = new Date().getTime();
};
this.saveToForm = function (rm)
{
var dump = this.createShowData();
if (rm) {  $('rm').value = rm; }
$('numSets').value = this.maxSet + 1;
$('showData').innerHTML = dump;
};
this.createShowData = function ()
{
var dump = "[begin]" + LINE_DELIM;
dump += "show=" + this.showConfig.join("|") + LINE_DELIM;
var numMarchers = this.marchers.length;
dump += "marcher=";
for (m=0; m < numMarchers; m++)
{
dump += this.marchers[m].section + "" + this.marchers[m].hornType;
if (m < numMarchers - 1)  { dump += "|" }
}
dump += LINE_DELIM;
dump += "deleted=";
var deleted = [];
for (m=0; m < numMarchers; m++)
{
if (this.marchers[m].isDeleted)
{
deleted.push(this.marchers[m].id);
}
}
dump += deleted.join("|");
dump += LINE_DELIM;
for (s=0; s <= this.maxSet; s++)
{
var line = "set=";
var sc = this.setConfig[s].join("");
line += sc + "|";
for (var m=0, marcher; marcher = this.marchers[m]; m++)
{
var set = marcher.sets[s];
var lastByte = "";
if (EDITOR.isPremium && marcher.section == SECTION_GUARD)
{
lastByte = set[3];
}
line += dec_to_base62(set[0]) + "" + dec_to_base62(set[1]) + "" + char_dec_to_base62(set[2]) + "" + lastByte;
if (m < numMarchers - 1)  { line += "|" }
}
line += LINE_DELIM;
dump += line;
}
dump += "[end]";
return dump;
};
this.changeUniforms = function ()
{
var numUniforms = NUM_UNIFORMS;
if (EDITOR.trialGroup > 0) {  -- numUniforms; }
this.showConfig[SHOW_UNIFORM] = ((this.showConfig[SHOW_UNIFORM] >> 0) + 1) % numUniforms;
if (! EDITOR.isPremium)
{
this.showConfig[SHOW_GUARD_UNIFORM] = this.showConfig[SHOW_UNIFORM];
}
for (m=0; m < this.marchers.length; m++)
{
if (EDITOR.isPremium && this.marchers[m].section == SECTION_GUARD)
{
}
else
{
this.marchers[m].changeUniform(this.showConfig[SHOW_UNIFORM]);
}
}
};
this.changeGuardUniforms = function ()
{
this.showConfig[SHOW_GUARD_UNIFORM] = ((this.showConfig[SHOW_GUARD_UNIFORM] >>0) + 1) % NUM_GUARD_UNIFORMS;
for (var m=0; m < this.marchers.length; m++)
{
if (this.marchers[m].section == SECTION_GUARD)
{
this.marchers[m].changeGuardUniform(this.showConfig[SHOW_GUARD_UNIFORM]);
}
}
};
this.changeGuardUniformsMulti = function ()
{
var first = EDITOR.FFNWUB[0];
if (! first || first.section != SECTION_GUARD)
{
alert("Please select the guard members you wish to change.");
return false;
}
var uniformNum = first.uniformNum >> 0;
uniformNum = (uniformNum + 1) % NUM_GUARD_UNIFORMS;
for (var m=0; m < this.marchers[m].length; m++)
{
if (this.marchers[m].section == SECTION_GUARD)
{
this.marchers[m].changeGuardUniform(uniformNum);
}
}
};
this.changeFlags = function ()
{
if (EDITOR.isPremium)
{
var first = EDITOR.FFNWUB[0];
if (! first || first.section != SECTION_GUARD)
{
alert("Please select the guard members you wish to change.");
return false;
}
var flagNum = first.flagNum >> 0;
flagNum = (flagNum + 1) % (EDITOR.numFlags + 2);
for (var m=0; m < EDITOR.FFNWUB.length; m++)
{
if (EDITOR.FFNWUB[m].section == SECTION_GUARD)
{
EDITOR.FFNWUB[m].setFlag(flagNum, true);
}
}
}
else
{
this.showConfig[SHOW_FLAG1] = (this.showConfig[SHOW_FLAG1] + 1) % EDITOR.numFlags;
for (m=0; m < this.marchers.length; m++)
{
if (this.marchers[m].section == SECTION_GUARD)
{
this.marchers[m].setFlag(this.showConfig[SHOW_FLAG1], true);
}
}
}
};
this.hornsDown = function ()
{
for (m=0; m < this.marchers.length; m++)
{
this.marchers[m].hornDown();
}
};
this.hornsUp = function ()
{
for (m=0; m < this.marchers.length; m++)
{
this.marchers[m].hornUp();
}
};
}
function oMarcher (aid, marcherConfig, bassNum)
{
this.id = aid;
this.x = 0;
this.y = 0;
this.prevZ = 0;
this.section = marcherConfig[0];
this.hornType = marcherConfig[1];
this.uniformNum = marcherConfig[2];
this.bassNum = bassNum;
this.flagNum = 0;
this.isHighlighted = false;
this.isQHighlighted = false;
this.FFUIXO = false;
this.isDeleted = false;
this.sets = [];
this.flatSets = [];
this.prevSection = this.section;
this.imgSizeX = MARCHER_SIZE_X;
this.imgSizeY = MARCHER_SIZE_Y;
this.numImgFrames = NUM_IMG_FRAMES_GENERAL;
this.frameOffset = 0;
this.preTossFrame = 0;
this.isTossing = false;
var uniform = 0;
if (defined( EDITOR.show.showConfig[SHOW_UNIFORM] ))
uniform = EDITOR.show.showConfig[SHOW_UNIFORM];
this.animRow = 0;
this.frames = [];
this.framesPlaying = [];
this.equipment = false;
this.lastTossSet = 0;
this.lastAnimTime = 0;
this.nextAnimMS = 0;
this.nextAnimState = [];
this.state = MARCHER_STATE_SET;
this.playFrame = 0;
this.dragOriginX = 0;
this.dragOriginY = 0;
this.FFPPKC = null;
this.dragOffX = 0;
this.dragOffY = 0;
this.FFKTLE = 0;
this.FFLOJC = 0;
this.scaleOffsetIsSet = 0;
this.isOutOfBounds = true;
this.div = document.createElement('div');
this.div.setAttribute('id', aid + "d");
this.div.style.position = "absolute";
this.div.style.left = "0px";
this.div.style.top = "0px";
if (! ie6)
{
this.highlightDiv = document.createElement('div');
this.highlightDiv.className =  'marcherhighlight';
this.div.appendChild(this.highlightDiv);
}
$('editor').appendChild(this.div);
this.init = function (startSet)
{
if (this.section == SECTION_BRASS)
{
this.setHornType(this.hornType);
}
if (this.section == SECTION_GUARD)
{
this.changeGuardUniform(this.uniformNum);
}
if (defined(startSet))
{
this.move(startSet[0], startSet[1]);
this.setFlag(startSet[3]);
this.setState(MARCHER_STATE_PLAYING);
this.saveSet(0);
}
else
{
this.setFrame(this.frames[0]);
}
}
this.toggleSection = function (newSection)
{
this.section = newSection;
this.hornType = 0;
this.setSprite();
this.setFlag(0);
this.setState(MARCHER_STATE_PLAYING);
for (var i = 0; i <= EDITOR.show.maxSet; i ++)
{
this.sets[i][2] = MARCHER_STATE_PLAYING;
this.sets[i][3] = 0;
}
if (this.equipment)
{
this.move(this.x, this.y, true);
}
}
this.setSprite = function ()
{
if (this.img)
{
this.div.removeChild(this.img);
}
if (this.equipment)
{
this.equipment.destroySprite();
this.equipment = null;
}
if (this.section == SECTION_BRASS)
{
this.frames = [FRAME_BRASS_SET, FRAME_BRASS_PLAY];
this.framesPlaying = [FRAME_BRASS_PLAY];
this.frame = FRAME_BRASS_SET;
this.imgSizeX = 18;
this.imgSizeY = 36;
this.animRow = 0;
this.frameOffset = 0;
}
else if (this.section == SECTION_SNARE)
{
this.frames = [FRAME_SNARE_SET, FRAME_SNARE_PLAY1];
this.framesPlaying = [FRAME_SNARE_PLAY1, FRAME_SNARE_PLAY2];
this.frame = FRAME_SNARE_SET;
this.imgSizeX = 18;
this.imgSizeY = 36;
this.animRow = 1;
this.frameOffset = 0;
}
else if (this.section == SECTION_TENOR)
{
this.frames = [FRAME_TENOR_SET, FRAME_TENOR_PLAY1];
this.framesPlaying = [FRAME_TENOR_PLAY1, FRAME_TENOR_PLAY2];
this.frame = FRAME_TENOR_SET;
this.imgSizeX = 18;
this.imgSizeY = 36;
this.animRow = 1;
this.frameOffset = 0;
}
else if (this.section == SECTION_BASS)
{
this.frames = [FRAME_BASS_LEFT, FRAME_BASS_RIGHT];
this.framesPlaying = [FRAME_BASS_RIGHT];
this.frame = FRAME_BASS_LEFT;
this.imgSizeX = 36;
this.imgSizeY = 36;
this.numImgFrames = 10;
this.animRow = 2 + (((this.bassNum-1) / 2) >> 0);
this.frameOffset = ((this.bassNum-1) % 2) * 2;
}
else if (this.section == SECTION_PROP)
{
this.frames = [0];
this.framesPlaying = [0];
this.frame = 0;
this.imgSizeX = 52;
this.imgSizeY = 48;
this.numImgFrames = 1;
this.animRow = 0;
this.frameOffset = 0;
EDITOR.hasProps = true;
}
else if (this.section == SECTION_PLATES)
{
this.frames = [FRAME_PLATES_SET, FRAME_PLATES_PLAY2];
this.framesPlaying = [FRAME_PLATES_PLAY1, FRAME_PLATES_PLAY2];
this.frame = FRAME_PLATES_SET;
this.animRow = 1;
this.frameOffset = 0;
}
else if (this.section == SECTION_GUARD)
{
this.frames = [1, 1, 0, 0, 3, 0];
this.framesPlaying = [1];
this.frame = 0;
this.imgSizeX = 18;
this.imgSizeY = 36;
this.animRow = 1;
this.frameOffset = 0;
this.numImgFrames = 4;
this.equipment = new oEquipment(aid);
this.equipment.move(this.x, this.y, this.y+1);
}
if (this.section == SECTION_GUARD)
{
this.img = new Image();
this.img.src = EDITOR.spriteURL['guard'];
this.imgSizeX = 18;
this.imgSizeY = 36;
if (EDITOR.isPremium)
{
this.uniformNum = 0;
uniform = 0;
}
this.animRow = uniform;
}
else if (this.section == SECTION_PROP)
{
this.img = new Image();
this.img.src = EDITOR.spriteURL['prop'];
}
else
{
this.img = new Image();
var uniUrl = EDITOR.spriteURL['musician'];
if (! uniUrl)
{
uniUrl = imageUrl("sprites/m" + (uniform + 1) + "_uniform.png");
}
this.img.src = uniUrl;
}
this.img.style.top = (-1 * this.animRow * this.imgSizeY) - 1;
this.img.className = "marcher";
this.img.id = aid + "i";
if (this.img.attachEvent) {  this.img.attachEvent("ondragstart", function () { return false; }); }
this.div.style.width = this.imgSizeX + 0;
this.div.style.height = this.imgSizeY + 2;
this.div.style.clip = "rect(0px, " + (this.imgSizeX) + "px, " + (this.imgSizeY + 2) + "px, 0px)";
this.div.appendChild(this.img);
if (! ie6)
{
this.highlightDiv.style.width = this.imgSizeX;
this.highlightDiv.style.height = this.imgSizeY;
}
this.setState(MARCHER_STATE_PLAYING);
};
this.undelete = function ()
{
this.isDeleted = false;
this.unhide();
};
this.dodelete = function ()
{
this.isDeleted = true;
this.hide();
};
this.spawnSetPin = function ()
{
var pin = document.createElement('div');
pin.setAttribute('id', this.id + "pin");
pin.className = "setpin";
pin.height = px(2);
pin.width = px(2);
$('editor').appendChild(pin);
if (this.isDeleted)
{
this.hidePin();
}
};
this.showPin = function ()
{
if (! this.isDeleted)
{
var pinid = this.id + "pin";
show(pinid);
}
};
this.hidePin = function ()
{
var pinid = this.id + "pin";
hide(pinid);
}
this.setState = function (newState)
{
this.state = newState;
if (this.section == SECTION_GUARD)
{
if (this.equipment)
{
this.equipment.setAnim(newState);
}
var pose = 1;
if (this.equipment.currentAnim.pose != undefined)
{
pose = this.equipment.currentAnim.pose;
if (EDITOR.show.editorVersion <= 1.40 && pose > 3)
{
pose = 0;
}
}
this.setFrame(pose);
}
else
{
this.setFrame(this.frames[this.state]);
}
};
this.setGhost = function (isOn)
{
if (isOn)
{
setAlpha(this.div.id, 25);
this.isGhost = true;
this.div.style.zIndex = 5;
this.img.style.cursor = 'default';
}
else
{
setAlpha(this.div.id, 100);
this.isGhost = false;
this.move(this.x, this.y, true);
this.img.style.cursor = 'move';
}
if (this.equipment)
{
this.equipment.setGhost(isOn);
}
};
this.move = function (ax, ay, forceUpdate)
{
if (this.isDeleted && EDITOR.isPlaying) return false;
if (EDITOR.mode == MODE_EDIT)
{
if (ax > 864 + 400  || ax < -400) ax = FIELD_SIZE_X / 2
if (ay > 450 + 350  || ay < -350) ay = FIELD_SIZE_Y / 2
}
if (this.x != ax || forceUpdate)
{
this.x = ax;
var offX = 0;
if (this.section == SECTION_BASS)
{
offX = -9;
}
else if (this.section == SECTION_PROP)
{
offX = -17;
}
this.div.style.left = ax + offX;
}
var equipmentZ = 0;
if (this.y != ay || forceUpdate)
{
this.y = ay;
var offY = 0;
if (this.section == SECTION_PROP)
{
offY = -10;
}
this.div.style.top = ay + offY;
var z = 200 + this.y;
if (EDITOR.leader && EDITOR.leader.id == this.id)
z += 6;
checkZ = ((z / 6) >> 0) * 6;
if (this.section == SECTION_GUARD)
{
checkZ -= 2;
}
if (checkZ != this.prevZ || forceUpdate || this.section == SECTION_PROP)
{
this.div.style.zIndex = checkZ;
this.prevZ = checkZ;
equipmentZ = checkZ;
}
}
if (this.equipment)
{
this.equipment.move(ax, ay, equipmentZ, forceUpdate);
if (this.equipment.catchMe)
{
this.gotoFrame(CATCH_POSE[this.equipment.equipmentType]);
this.equipment.catchMe = false;
}
}
}
this.saveSet = function (setNum)
{
if (this.section == SECTION_PROP)
{
this.propagateSets();
}
this.sets[setNum] = [this.x >> 0, this.y >> 0, this.state, this.flagNum ];
};
this.propagateSets = function ()
{
for (var i = 0; i <= EDITOR.show.maxSet; i ++)
{
this.sets[i] = [toInt(this.x), toInt(this.y), this.state, this.flagNum ];
}
};
this.hide = function ()
{
this.div.style.display = 'none';
this.div.style.visibility = 'hidden';
if (this.equipment)
{
this.equipment.hide();
}
this.hidePin();
};
this.unhide = function ()
{
this.div.style.display = 'block';
this.div.style.visibility = 'visible';
if (this.equipment)
{
this.equipment.unhide();
}
this.showPin();
};
this.addSet = function (setNum)
{
var prevSet = this.sets[setNum-1].slice();
if (this.section == SECTION_GUARD && this.equipment.currentAnim.doToss)
{
prevSet[2] = 0;
}
this.sets[setNum] = prevSet;
this.setFlag(this.sets[setNum][3]);
this.setState(this.sets[setNum][2]);
};
this.insertSet = function (setNum)
{
this.sets.splice(setNum+1,0, [ this.sets[setNum][0], this.sets[setNum][1], this.sets[setNum][2], this.sets[setNum][3] ]);
};
this.resetSet = function (setNum, fromSet)
{
this.sets[setNum] = [ this.sets[fromSet][0], this.sets[fromSet][1], this.sets[fromSet][2], this.sets[setNum][3] ];
this.move(this.sets[setNum][0], this.sets[setNum][1]);
this.setFlag(this.sets[setNum][3]);
this.setState(this.sets[setNum][2]);
};
this.deleteSet = function (setNum)
{
this.sets.splice(setNum, 1);
};
this.getStateForLastSet = function ()
{
return this.sets[ this.sets.length - 1 ][2];
};
this.loadSet = function (set)
{
if (set.length < 3)
set[2] = MARCHER_STATE_PLAYING;
if (set.length < 4)
set[3] = 0;
if ((EDITOR.mode == MODE_VIEW && EDITOR.show.editorVersion <= 1.26) || EDITOR.fieldSizeOffsetFix)
{
set[0] += 72;
set[1] += 20;
}
if (EDITOR.is3D)
{
this.flatSets.push(set.slice());
var yOffset = -15;
var slopeX2 = 284.0;
var shrinkX = -0.011;
var slopeY = 35;
if (EDITOR.groupType == GROUP_TYPE_GUARD || EDITOR.groupType == GROUP_TYPE_DRUMLINE)
{
yOffset = 15;
slopeX2 = 300.0;
shrinkX = +0.03;
slopeY = 15;
}
if (this.isOutOfBounds && EDITOR.show.editorVersion <= 1.26)
{
if (! this.getOutOfBounds(set[0], set[1]))
{
this.isOutOfBounds = false;
}
}
var fieldCenterX = ((FIELD_SIZE_X - 12)/ 2 - this.imgSizeX / 2) + 6.0;
var slopeX = (246.0 / slopeX2);
distortX = 1.0 - ((1.0 - slopeX) * ((FIELD_SIZE_Y-set[1]) / FIELD_SIZE_Y));
distortX += shrinkX;
if (set[0] > fieldCenterX)
{
set[0] = fieldCenterX + (set[0] - fieldCenterX) * distortX;
}
else
{
set[0] = fieldCenterX - (fieldCenterX - set[0]) * distortX;
}
var distortY = (FIELD_SIZE_Y - set[1]) / FIELD_SIZE_Y * slopeY;
set[1] = (0.0 + (420.0 / FIELD_SIZE_Y) * set[1]) + distortY + yOffset;
}
this.sets.push(set);
};
this.getOutOfBounds = function (ax, ay)
{
if (ax > 72 && ax < 720 + 72 && ay > 20 && ay < 440)
{
return false;
}
else
{
return true;
}
};
this.jumpToSet = function (num, delayHornsDown)
{
var toSet = this.sets[num];
if (! this.isDeleted)
{
if (this.equipment)
{
this.catchEquipment();
}
this.move(toSet[0], toSet[1]);
this.setFlag(toSet[3]);
this.setState(toSet[2]);
}
};
this.comparitiveDistToNextSet = function (startSet)
{
var flatSets = this.sets;
if (EDITOR.is3D && EDITOR.show.editorVersion >= 1.41)
{
flatSets = this.flatSets;
}
if (! defined(flatSets[startSet+1]))
{
return 0;
}
var dx = Math.pow(flatSets[startSet+1][0] - flatSets[startSet][0], 2);
var dy = Math.pow(flatSets[startSet+1][1] - flatSets[startSet][1], 2);
var len = dx + dy;
return len;
};
this.tween = function (startSet, progress)
{
if (this.section == SECTION_PROP) {  return false; }
var from = this.sets[startSet];
var to = this.sets[startSet+1];
var tweenX = from[0] + (to[0] - from[0]) * progress;
var tweenY = from[1] + (to[1] - from[1]) * progress;
this.move(tweenX, tweenY);
};
this.setSpecialBorder = function ()
{
this.setBorder("solid 1px #ff0");
};
this.setBorder = function (astyle)
{
if (ie && ! ie6)
{
this.div.style.borderTop = astyle;
this.div.style.borderBottom = astyle;
}
else
{
this.div.style.border = astyle;
}
this.div.style.padding = "1px";
};
this.removeBorder = function ()
{
this.setBorder("solid 1px transparent");
if (ie6)
{
this.setBorder("solid 0px " + BORDER_COLOR);
this.div.style.padding = "1px";
}
};
this.deselect = function ()
{
this.removeBorder();
if (! ie6)
this.highlightDiv.style.backgroundColor = "transparent";
this.isLeader = false;
this.FFUIXO = false;
this.isDark = false;
if (this.isHighlighted)
{
this.unhighlight();
}
};
this.select = function (force, isDark)
{
if (this.isDeleted && ! force) return false;
if (this.section == SECTION_PROP && EDITOR.show.propsHidden)
{
}
if (this.isGhost)
{
return false;
}
if (! this.isHighlighted)
{
this.setBorder("solid 1px " + BORDER_COLOR);
if (! ie6)
{
this.isDark = isDark;
this.highlightDiv.style.backgroundColor = 'green';
}
}
this.FFUIXO = true;
};
this.highlight = function ()
{
if (this.section == SECTION_PROP && EDITOR.show.propsHidden)
{
}
if (this.isGhost || this.isQHighlighted)
{
return false;
}
this.setBorder("solid 1px #D82113");
if (! ie6)
{
this.highlightDiv.style.backgroundColor = "#D82113";
}
this.isHighlighted = true;
};
this.unhighlight = function ()
{
this.removeBorder();
if (! ie6)
this.highlightDiv.style.backgroundColor = "transparent";
this.isHighlighted = false;
if (this.FFUIXO)
{
this.select(false, this.isDark);
}
};
this.FFAXBS = function ()
{
if (this.isGhost || this.FFUIXO)
{
return false;
}
this.setBorder("solid 1px #91B672");
if (! ie6)
{
this.highlightDiv.style.backgroundColor = "#C5DCB3";
}
this.isQHighlighted = true;
};
this.quickUnhighlight = function ()
{
this.removeBorder();
if (! ie6)
{
this.highlightDiv.style.backgroundColor = "transparent";
}
this.isQHighlighted = false;
if (this.FFUIXO)
{
this.select(false, this.isDark);
}
};
this.drag = function (offX, offY)
{
var toX = this.dragOriginX + offX;
var toY = this.dragOriginY + offY;
if (EDITOR.hashState == HASH_HORIZONTAL)
{
var hashY = parseInt($('hashX').style.top) - this.imgSizeY + 3;
if (Math.abs(toY - hashY) < 20)
{
toY = hashY;
}
if (EDITOR.snapX > 0)
{
toX = snapX(toX);
}
}
else if (EDITOR.hashState == HASH_VERTICAL)
{
var hashX = parseInt($('hashY').style.left) - ((this.imgSizeX / 2) >> 0) + 1;
hashX += (this.section == SECTION_BASS) ? +9 : 0;
if (Math.abs(toX - hashX) < 20)
{
toX = hashX;
}
if (EDITOR.snapY > 0)
{
toY = snapY(toY);
}
}
else if (EDITOR.snapX > 0)
{
toX = snapX(toX);
toY = snapY(toY);
}
this.move(toX, toY);
};
this.setDragOrigin = function ()
{
this.dragOriginX = this.x;
this.dragOriginY = this.y;
};
this.FFKLXD = function (point)
{
var dx = Math.pow(point[0] - this.x, 2);
var dy = Math.pow(point[1] - this.y, 2);
var len = Math.sqrt(dx + dy);
return len;
};
this.distanceToMarcher = function (marcher)
{
return this.FFKLXD([marcher.x, marcher.y]);
};
this.angleToMarcher = function (marcher)
{
return FFHWGB([this.x, this.y], [marcher.x, marcher.y]);
};
this.rotate = function (centerPoint, direction, isFine)
{
var len = this.FFKLXD(centerPoint);
var angle = FFHWGB([this.x, this.y], centerPoint);
var step = 11.25;
if (isFine)
step = step / 8.0;
var newAngle = (angle + direction * step) % 360;
newX = centerPoint[0] + Math.sin(newAngle * Math.PI / 180) * len;
newY = centerPoint[1] + Math.cos(newAngle * Math.PI / 180) * len * -1.0;
this.move(newX, newY);
};
this.FFHHES = function (centerPoint, offsetAngle)
{
offsetAngle = (offsetAngle + 180) % 360;
this.FFKTLE = FFHWGB([this.x, this.y], centerPoint);
if (offsetAngle > 270 || offsetAngle < 90)
{
turn = (360 - offsetAngle) + 180;
offsetAngle = (offsetAngle + turn) % 360;
this.FFKTLE = (this.FFKTLE + turn) % 360;
}
};
this.FFQFGQ = function (endPoint)
{
this.FFLOJC = this.FFKLXD(endPoint);
};
this.scale = function (centerPoint, directionX, directionY, isFine)
{
var newX = this.x;
var newY = this.y;
var step = 0.05;
if (isFine)
step = 0.01;
if (directionX != 0)
{
var lenX = this.x - centerPoint[0];
var offX = lenX * step * directionX;
newX = centerPoint[0] + lenX + offX;
}
if (directionY != 0)
{
var lenY = this.y - centerPoint[1];
var offY = lenY * step * directionY;
newY = centerPoint[1] + lenY + offY;
}
this.move(newX, newY);
};
this.FFHJFN = function (dhm)
{
this.FFPPKC = dhm;
this.dragOffX = this.x - dhm.x;
this.dragOffY = this.y - dhm.y;
};
this.moveRelativeToHandle = function ()
{
newX = this.FFPPKC.x + this.dragOffX;
newY = this.FFPPKC.y + this.dragOffY;
this.move(newX, newY);
};
this.nudge = function (offX, offY)
{
this.move(this.x + offX, this.y + offY);
};
this.setFrame = function (num)
{
if (! num) {  num = 0; }
this.frame = num;
this.gotoFrame(num);
};
this.togglePlayState = function (num, isReverse)
{
if (! num) {  num = 0; }
if (this.section == SECTION_GUARD)
{
if (EDITOR.isPremium)
{
var diff = 1;
if (isReverse)
{
diff = -1;
}
num += diff;
var numAnims = NUM_ANIMS[this.equipment.equipmentType];
if (num > numAnims - 1)
{
num = 0;
}
else if (num < 0)
{
num = numAnims - 1;
}
}
else
{
num = (num + 1) % NUM_DEFAULT_FLAG_ANIMS;
}
}
else
{
num = 1 - num;
if (num > 1 || num < 0) { num = 0; }
}
this.setState(num);
};
this.toggleEquipment = function (num)
{
if (this.section == SECTION_BRASS)
{
this.toggleHornType(num);
}
};
this.toggleHornType = function (num)
{
if (this.section == SECTION_BRASS)
{
this.setHornType(num);
}
};
this.setHornType = function (hornType)
{
this.hornType = hornType;
var animRow = 0;
var animCol = hornType % 4;
if (hornType > 3)
{
animRow = 5;
}
if (animRow != this.animRow)
{
this.img.style.top = (-1 * animRow * this.imgSizeY) - 1;
}
this.animRow = animRow;
this.frames = [FRAME_BRASS_SET + animCol * 2, FRAME_BRASS_PLAY + animCol * 2];
this.framesPlaying = [FRAME_BRASS_PLAY + animCol * 2];
this.gotoFrame(this.frames[this.state]);
};
this.catchEquipment = function ()
{
this.preTossFrame = 0;
this.isTossing = false;
if (this.equipment.isInAir)
{
this.equipment.catchIt();
this.gotoFrame(this.equipment.currentAnim['pose']);
this.equipment.catchMe = false;
}
};
this.pretoss = function (num)
{
if (this.equipment)
{
this.preTossFrame = num;
this.gotoFrame(6);
this.equipment.pretoss(num);
}
};
this.tossEquipment = function ()
{
if (this.equipment)
{
this.isTossing = true;
this.preTossFrame = 0;
this.gotoFrame((this.equipment.currentAnim.tossRight) ? 4 : 5);
this.lastTossSet = EDITOR.FFRXHX + 1;
this.equipment.toss();
}
};
this.animate = function (now, elapsedMS, endSetTime)
{
if (this.nextAnimMS > 0)
{
if (elapsedMS > this.nextAnimMS)
{
if (this.section == SECTION_GUARD)
{
var ganim = ANIM[this.equipment.equipmentType][ this.nextAnimState[2] ];
this.gotoFrame(ANIM_HANDS[this.equipment.equipmentType][ ganim.frames[0] ]);
this.equipment.gotoFrame(0, ganim);
}
else
{
this.gotoFrame(this.frames[ this.nextAnimState[2] ]);
}
}
return true;
}
if (this.section == SECTION_GUARD)
{
}
else if (this.state == MARCHER_STATE_PLAYING)
{
if (ANIM_SPEED_MS[this.section] > 0)
{
if (now - this.lastAnimTime > ANIM_SPEED_MS[this.section])
{
if (this.framesPlaying.length > 1)
{
this.playFrame = (this.playFrame + 1) % this.framesPlaying.length;
this.gotoFrame(this.framesPlaying[this.playFrame]);
}
if (this.equipment)
{
this.equipment.nextFrame()
}
this.lastAnimTime = now;
}
}
}
};
this.loadCustomFlag = function (url)
{
EDITOR.numFlags = NUM_PREMIUM_FLAG_COLORS;
this.equipment.loadCustomFlag(url);
};
this.loadCustomProp = function (url)
{
this.img.src = url;
};
this.loadCustomUniform = function (url)
{
if (this.section == SECTION_GUARD)
{
this.img.src = url;
}
else
{
this.img.src = url;
}
};
this.changeUniform = function (uniform)
{
if (this.section == SECTION_GUARD)
{
this.changeGuardUniform(uniform);
}
else
{
uniUrl = imageUrl("sprites/m" + (uniform + 1) + "_uniform.png");
this.img.src = uniUrl;
}
};
this.changeGuardUniform = function (num)
{
if (! num) {  num = 0; }
this.animRow = num;
this.img.style.top = (-1 * this.animRow * this.imgSizeY) - 1;
this.uniformNum = num;
};
this.setFlag = function (num, isManualChange)
{
if (this.section == SECTION_GUARD)
{
if (! EDITOR.isPremium)
{
num = EDITOR.show.showConfig[SHOW_FLAG1];
}
this.flagNum = num;
var eqType = EQUIPMENT_FLAG
if (EDITOR.isPremium)
{
if (this.flagNum == 4)
{
eqType = EQUIPMENT_RIFLE;
}
else if (this.flagNum == 5)
{
eqType = EQUIPMENT_SABRE;
}
}
var newAnim = 0;
var resetAnim = false;
if (isManualChange && eqType != this.equipment.equipmentType)
{
var nextEqType = eqType;
var prevEqType = this.equipment.equipmentType;
if (nextEqType == EQUIPMENT_SABRE) {  nextEqType = EQUIPMENT_RIFLE; }
if (prevEqType == EQUIPMENT_SABRE) {  prevEqType = EQUIPMENT_RIFLE; }
this.equipment.prevAnim[prevEqType] = this.equipment.animNum;
if (this.equipment.prevAnim[nextEqType])
{
newAnim = this.equipment.prevAnim[nextEqType];
}
resetAnim = true;
}
this.equipment.setEquipmentType(eqType, this.flagNum);
if (resetAnim)
{
this.setState(newAnim);
}
}
};
this.hornDown = function ()
{
if (this.section != SECTION_BASS && this.section != SECTION_GUARD)
{
this.gotoFrame(this.frames[MARCHER_STATE_SET]);
}
};
this.hornUp = function ()
{
if (this.state == MARCHER_STATE_PLAYING && this.section != SECTION_GUARD)
{
this.gotoFrame(this.frames[MARCHER_STATE_PLAYING]);
}
};
this.gotoFrame = function (num)
{
if (this.section == SECTION_PROP)
{
return false;
}
var num1 = num + this.frameOffset;
var borderOffset = -1;
if (ie && ! ie6)
{
borderOffset = 0;
}
this.img.style.left = (-1 * num1 * this.imgSizeX) + borderOffset;
};
this.select();
this.deselect();
}
function oEquipment (aid)
{
this.img = new Image();
this.img.src = EDITOR.spriteURL['flag'];
this.img.className = "equipment";
this.img.id = aid + "eqi";
this.aid = aid;
this.equipmentType = EQUIPMENT_FLAG;
if (this.img.attachEvent)
this.img.attachEvent("ondragstart", function () { return false; });
this.animNum = 0;
this.currentAnim = {};
this.prevAnim = {};
this.imgSizeX = 36;
this.imgSizeY = 36;
this.x = -100;
this.y = -100;
this.baseZ = -100;
this.isInAir = false;
this.airHeight = 0;
this.airSpeed = 0;
this.catchMe = false;
this.isPretoss = false;
this.animOffset = [0,0,0];
this.frame = 0;
this.frameOffset = 0;
this.numSpinFrames = 8;
this.currentFrame = 0;
this.div = document.createElement('div');
this.div.setAttribute('id', aid + "eq");
this.div.style.position = "absolute";
this.div.style.left = "0px";
this.div.style.top = "0px";
this.div.style.zIndex = 1000;
this.div.style.width = this.imgSizeX + 1;
this.div.style.height = this.imgSizeY + 2;
this.div.style.clip = "rect(0px, " + (this.imgSizeX) + "px, " + (this.imgSizeY) + "px, 0px)";
this.div.appendChild(this.img);
$('editor').appendChild(this.div);
var self = this;
this.setEquipmentType = function (eqType, flagNum)
{
this.equipmentType = eqType;
this.changeFlagColor(flagNum);
this.currentAnim = ANIM[this.equipmentType][this.animNum];
};
this.loadCustomFlag = function (url)
{
if (ie)
{
this.img.width = FLAG_IMG_SIZE_X;
this.img.height = FLAG_IMG_SIZE_Y;
}
this.img.src = url;
};
this.destroySprite = function ()
{
this.div.removeChild(this.img);
$('editor').removeChild(this.div);
};
this.hide = function ()
{
this.div.style.display = 'none';
this.div.style.visibility = 'hidden';
};
this.unhide = function ()
{
this.div.style.display = 'block';
this.div.style.visibility = 'visible';
};
this.changeFlagColor = function (num)
{
this.img.style.top = (-1 * num * this.imgSizeY);
};
this.resetZ = function (az)
{
if (az > 0)
{
this.baseZ = az;
}
this.div.style.zIndex = (this.baseZ + 1) >> 0;
};
this.setAnim = function (newAnim)
{
this.animNum = newAnim;
this.isPretoss = false;
this.currentAnim = ANIM[this.equipmentType][newAnim];
if (this.currentAnim.offset && ! (EDITOR.show.editorVersion < 1.38 && EDITOR.isPremium))
{
this.animOffset[0] = this.currentAnim.offset[0];
this.animOffset[1] = this.currentAnim.offset[1];
this.animOffset[2] = this.currentAnim.offset[2];
}
else
{
this.resetOffset();
}
this.updatePos();
if (EDITOR.isPlaying && this.currentAnim.frames.length > 1) //  && this.animNum == newAnim
{
return false;
}
else
{
this.defaultFrame();
}
};
this.resetOffset = function ()
{
this.animOffset = [0,0,0];
};
this.defaultFrame = function ()
{
this.gotoFrame(0);
this.updatePos();
};
this.updatePos = function ()
{
this.move(this.x, this.y, 0, true);
};
this.nextFrame = function ()
{
var anim = this.animNum;
if (this.isInAir && this.equipmentType == EQUIPMENT_RIFLE)
{
anim = 5;
}
var frames = this.currentAnim.frames;
if (frames.length > 1)
{
this.frame = (this.frame + 1) % frames.length;
this.gotoFrame(this.frame);
}
};
this.gotoFrame = function (num, ganim)
{
var anim = this.animNum;
if (this.isInAir)
{
anim = 5;
}
if (! ganim)
{
ganim = this.currentAnim;
}
var spriteFrame = ganim.frames[num];
var frameRow = 0;
var frameCol = spriteFrame;
this.currentFrame = frameCol;
if (EDITOR.show.editorVersion < 1.38 && EDITOR.isPremium)
{
var oldToNew = { 0:0, 8:1, 6:2, 14:3, 17:5, 16:4 };
frameCol = oldToNew[spriteFrame];
if (! frameCol) { frameCol = 0; }
}
this.img.style.left = px(-1 * frameCol * this.imgSizeX);
};
this.forceFrame = function (frameCol)
{
this.img.style.left = px(-1 * frameCol * this.imgSizeX);
};
this.pretoss = function (num)
{
this.isPretoss = true;
this.forceFrame((num == 1) ? 0 : 7);
};
this.toss = function ()
{
this.isPretoss = false;
this.airHeight = 0;
this.isInAir = true;
var tossAnimNum = this.currentAnim['tossAnimNum'];
this.currentAnim = TOSS_ANIM[this.equipmentType][tossAnimNum];
this.airSpeed = this.currentAnim['tossSpeed'];
};
this.airUpdate = function ()
{
this.airSpeed -= TOSS_GRAVITY;
var flatSpeed = this.airSpeed;
if (flatSpeed > 3.0)
{
flatSpeed = 3.0;
}
else if (flatSpeed < -3.0)
{
flatSpeed = -3.0;
}
this.airHeight += flatSpeed;
if (this.airHeight <= 0)
{
this.catchIt();
}
};
this.catchIt = function ()
{
this.catchMe = true;
this.isInAir = false;
this.airSpeed = 0;
this.airHeight = 0;
this.currentAnim.frameNum = 0;
var catchFrame = this.currentAnim.catchFrame;
this.currentAnim = TOSS_ANIM[this.equipmentType][0];
if (catchFrame == -1)
{
}
else
{
this.currentFrame = catchFrame;
this.setAnim(0);
}
};
this.move = function (ax,ay,az, doForce)
{
var offX = -9;
var offY =  2;
if (! this.isInAir)
{
if (this.isPretoss)
{
offY += 1;
doForce = true;
}
else
{
offX += this.animOffset[0];
offY += this.animOffset[1];
}
}
if (doForce || this.x != ax)
{
this.x = ax;
this.div.style.left = (ax + offX);
}
if (this.isInAir)
{
this.airUpdate();
}
if (doForce || this.y != ay || this.isInAir)
{
this.y = ay;
this.div.style.top = ay + offY - this.airHeight;
if (az > 0)
{
this.resetZ(az);
}
}
};
this.setGhost = function (isOn)
{
if (isOn)
{
setAlpha(this.div.id, 25);
this.isGhost = true;
this.div.style.zIndex = 6;
this.img.style.cursor = 'default';
}
else
{
setAlpha(this.div.id, 100);
this.isGhost = false;
this.move(this.x, this.y, true);
this.img.style.cursor = 'move';
this.resetZ();
}
};
}
function snapX (toX)
{
var interval = GRID_X[ EDITOR.snapX ];
var offX = GRID_X_NUDGE[ EDITOR.snapX ];
toX = (toInt(toX / interval) * interval) + 8 + offX;
return toX;
}
function snapY (toY)
{
var interval = 9;
toY = (toInt(toY / interval) * interval);
return toY;
}
function newHelp (inner, doForce)
{
if (EDITOR.mode == MODE_EDIT && (doForce || (! EDITOR.isRestored && EDITOR.doShowHelp)))
{
$('help').innerHTML = inner;
show('help');
}
}
function newSetNumber (num)
{
if (EDITOR.mode == MODE_EDIT)
{
var msg = "Set " + num;
if (num == MAX_SETS)
msg = "Last Set";
$('setnumber').innerHTML = msg;
show('setnumber');
setAlpha('setnumber', 100);
setTimeout("fadeOut('setnumber')", 500);
}
}
function updateAddSetLink ()
{
if (EDITOR.mode == MODE_EDIT && ! EDITOR.isPlaying)
{
if (EDITOR.show.maxSet < MAX_SETS) // EDITOR.show.FFRXHX == EDITOR.show.maxSet && EDITOR.setIsChanged
{
lightAddSetLink();
}
else
{
darkAddSetLink();
}
}
}
function lightAddSetLink ()
{
$('addsetlink').style.color = "#DFD13A";
}
function darkAddSetLink ()
{
$('addsetlink').style.color = "#17391E";
}
function ajax_vote (showID, score)
{
if (EDITOR.hasVoted) return false;
if (score == 10)
{
if (! confirm("Are you sure this show is worth a Perfect 10?"))
{
return false;
}
}
else if (score == 1)
{
if (! confirm("A score of 1 means this show has absolutely no merit.\n\nAre you sure about this?"))
{
return false;
}
}
EDITOR.hasVoted = true;
if (EDITOR.isPlaying) EDITOR.show.stop();
if (score == 0)
{
$('voting').innerHTML = "Reporting Show to Moderators...";
$('votepanel').style.visibility = "hidden";
}
else
{
$('votepanel').style.visibility = "hidden";
}
show('voting');
params = "showID=" + showID + "&score=" + score + "&rand=" + Math.random();
AJAX_TIME = new Date().getTime();
$('rpc').src = "/remote/vote.php?" + params;
AJAX_TIMEOUT_ID = setTimeout('ajax_problem()', AJAX_TIMEOUT_SECS * 1000);
}
function post_vote ()
{
EDITOR.didVote = true;
hide('voting');
hide('votepanel');
show('nextshowlink');
show('showinforight');
$('commentslink').style.visibility = 'visible';
$('author').style.visibility = 'visible';
$('authordrop').style.visibility = 'visible';
open_comments(EDITOR.showID);
increment_judged_shows();
location.hash = rand(200000,999999);
}
function draw_votepanel (showID, doDisqual)
{
var inner = "";
var start = 1;
if (doDisqual) { start = 0; };
for (i=start; i <= 10; i++)
{
var label = i;
var isdiqual = "true";
if (i == 0)
{
label = 'X';
isdiqual = "confirm('Disqualify this show for being inappropriate?')";
}
inner += '<a class="votenum" href="#" onClick="if (' + isdiqual + ') { ajax_vote(' + showID + ',' + i + '); }; return false">' + label + '</a>'
}
$('voterow').innerHTML = inner;
}
function draw_votepanel_new (showID, doDisqual)
{
isdisqual = "confirm('Disqualify this show for being inappropriate?')";
var inner = "";
if (doDisqual)
inner += '<a class="votenum" href="#" onClick="if (' + isdisqual + ') { ajax_vote(' + showID + ', 0); }; return false">&#10008;</a>'
inner += '<a class="votenum" href="#" onClick="ajax_vote(' + showID + ', 1); return false">&#9733;</a>';
inner += '<a class="votenum" href="#" onClick="ajax_vote(' + showID + ', 4); return false">&#9733;&#9733;</a>';
inner += '<a class="votenum" href="#" onClick="ajax_vote(' + showID + ', 7); return false">&#9733;&#9733;&#9733;</a>';
inner += '<a class="votenum" href="#" onClick="ajax_vote(' + showID + ', 10); return false">&#9733;&#9733;&#9733;&#9733;</a>';
$('voterow').innerHTML = inner;
}
function increment_judged_shows ()
{
if ($('judgecountnum'))
$('judgecountnum').innerHTML = toInt($('judgecountnum').innerHTML) + 1;
}
var IS_FAVORITE = false;
function ajax_favorite (loggedIn, showID, authorID, isRookie)
{
if (! loggedIn)
{
alert("Please log in to Favorite this show.");
return false;
}
if (! isRookie)
{
alert("Sorry, you must be a Rookie (100 XP) to Favorite a show.");
return false;
}
if (EDITOR.isJudge && ! EDITOR.didVote)
{
alert("Please judge the show before adding it as a Favorite.");
return false;
}
if (IS_FAVORITE) return false;
if (! confirm("It will cost 5 XP to add this show to your Favorites.\n\nContinue?"))
{
return false;
}
IS_FAVORITE = true;
$('favoriteLabel').innerHTML = "One Sec...";
var params = "showID=" + showID + "&authorID=" + authorID + "&rand=" + Math.random();
$('rpc').src = "/remote/favorite.php?" + params;
}
function favorite_response (status)
{
setTimeout("buy_favorite()", 400);
}
function buy_favorite ()
{
$('favoriteLabel').innerHTML = 'Favorite!';
$('favoriteLabel').style.color = '#fff';
$('favorite_icon').style.backgroundPosition = '-32px 0px';
$('favoriteCell').style.cursor = 'default';
$('favoriteCell').onclick = null;
$('favoriteCell').onmouseover = null;
}
var ACTION_MESSAGE_ID = 0;
var ACTION_MESSAGE_ON = false;
function action_message (msg, delay, clearMS)
{
$('actionmessage').innerHTML = msg;
if (! delay) { delay = 10; }
if (! clearMS) { clearMS = 600; }
clearTimeout(ACTION_MESSAGE_ID);
ACTION_MESSAGE_ON = true;
setTimeout("show('actionmessage')", delay);
ACTION_MESSAGE_ID = setTimeout("clear_action_message()", clearMS + delay);
}
function clear_action_message ()
{
hide('actionmessage');
ACTION_MESSAGE_ON = false;
}
var OPTION_CLICKED = false;
var PREV_OPTION = null;
function option_click (url)
{
OPTION_CLICKED = true;
location.href = url;
document.onfocus = function () { OPTION_CLICKED = false; };
}
function option_over (option, isBright, isIcon)
{
if (OPTION_CLICKED) return false;
var bg = getElementsByClass(option, 'featurebg');
if (bg[0]) { bg[0].style.backgroundColor = "#067616"; } else { option.style.backgroundColor= (isBright) ? '#3A9E47' : '#66AB6F'; }
if (isIcon)
{
var icons = getElementsByClass(option, 'showicon');
var nowX = parseInt(icons[0].style.backgroundPosition);
var offsetY = (isBright) ? -64 : -32;
icons[0].style.backgroundPosition = nowX + " " + offsetY + "px";
}
}
function option_out (option, isBright, isIcon)
{
if (OPTION_CLICKED) return false;
var bg = getElementsByClass(option, 'featurebg');
if (bg[0]) { bg[0].style.backgroundColor = "transparent"; } else { option.style.backgroundColor='transparent'; }
if (isIcon)
{
var icons = getElementsByClass(option, 'showicon');
var nowX = parseInt(icons[0].style.backgroundPosition);
icons[0].style.backgroundPosition = nowX + " 0px";
}
}
function playbutton_over (option)
{
option.style.borderColor='#fff';
document.body.style.cursor='pointer';
}
function playbutton_out (option)
{
option.style.borderColor='#AAD6AE';
document.body.style.cursor ='default';
}
function toptab_over (option)
{
document.body.style.cursor='pointer';
}
function toptab_out (option)
{
document.body.style.cursor ='default';
}
function group_badge_over (option)
{
option.style.borderColor='#f00';
}
function group_badge_out (option)
{
option.style.borderColor='#589B5F';
}
var STACK_DUMPED = false;
function printStackTrace (passed) {
if (STACK_DUMPED)
{
return false;
}
STACK_DUMPED = true;
var callstack = [];
var isCallstackPopulated = false;
try {
i.dont.exist+=0;
} catch(e) {
if (e.stack) { //Firefox
var lines = e.stack.split("\n");
for (var i=0, len=lines.length; i<len; i++) {
if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
callstack.push(lines[i]);
}
}
callstack.shift();
isCallstackPopulated = true;
}
else if (window.opera && e.message) { //Opera
var lines = e.message.split("\n");
for (var i=0, len=lines.length; i<len; i++) {
if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
var entry = lines[i];
if (lines[i+1]) {
entry += " at " + lines[i+1];
i++;
}
callstack.push(entry);
}
}
callstack.shift();
isCallstackPopulated = true;
}
}
if (!isCallstackPopulated) { //IE and Safari
var currentFunction = arguments.callee.caller;
while (currentFunction) {
var fn = currentFunction.toString();
var fname = fn.substring(fn.indexOf("function") + 8, fn.indexOf("(")) || "anonymous";
callstack.push(fname);
currentFunction = currentFunction.caller;
}
}
output(callstack, passed);
}
function output (arr, passed) {
var dump = arr.join("\n");
dump += "\n\n" + "[num=" + passed + ", current=" + EDITOR.show.FFRXHX + ", max=" + EDITOR.show.maxSet + "]";
var addit = "<br /><b>Please send this to the admin: </b><br /><textarea style=\"width: 500px; height: 300px\">" + dump + "</textarea> <br /><br />";
document.body.innerHTML += addit;
window.scrollBy(200000, 0);
}
function addListener (event, elID, func)
{
var elem = $(elID);
if (elem.addEventListener) // W3C DOM
{
elem.addEventListener(event, func, false);
}
else if (elem.attachEvent)  // IE DOM
{
elem.attachEvent("on" + event, func);
}
}
function FFHWGB (p1, p2)
{
r = Math.atan2(p2[1] - p1[1], p2[0] - p1[0]);
degrees = r * 180 / Math.PI;
degrees = (degrees + 270) % 360;
return degrees;
}
function get_distance (p1, p2)
{
var dx = Math.pow(p2[0] - p1[0], 2);
var dy = Math.pow(p2[1] - p1[1], 2);
var len = Math.sqrt(dx + dy);
return len;
}
function angle_difference (a0, a1)
{
return (a0 + 180 -  a1) % 360 - 180;
}
var AJAX_TIME = 0;
var AJAX_TIMEOUT_ID = 0;
function get_ajax ()
{
var request = null;
try
{
request = new XMLHttpRequest();
}
catch (e)
{
try
{
request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
request = new ActiveXObject("Microsoft.XMLHTTP");
}
}
return request;
}
function ajax_request_get (url)
{
var ajax = get_ajax();
ajax.open("GET", url, true);
ajax.onreadystatechange = function ()
{
if (ajax.readyState == 4)
{
alert(ajax.responseText);
}
}
ajax.send(null);
}
function ajax_problem ()
{
if (EDITOR.isSaving)
{
alert("There is a temporary problem connecting to the server.\n\nPlease try again in another minute.\n\nDo NOT leave this page or you will lose your unsaved changes.\n\nIf the problem continues, check twitter.com/micromarching for any updates on server maintenance.");
hide('saving');
EDITOR.isSaving = false;
}
else if (EDITOR.hasVoted)
{
alert("There is a temporary problem connecting to the server.\n\nPlease try again in another minute.");
hide('voting');
show('votepanel');
EDITOR.hasVoted = false;
}
}
function keyCommandUp (evt)
{
if (EDITOR.pauseKeyListener)
return true;
var key = (evt.which || evt.keyCode || evt.charCode);
var stringKey = String.fromCharCode(key).toLowerCase();
stopEvent = false;
if (stringKey == "`" || stringKey == "~" || key == 192)
{
EDITOR.fakeCtrl = false;
stopEvent = true;
}
if (stringKey == "q")
{
EDITOR.quickSelect = false;
EDITOR.quickUnhighlight();
stopEvent = true;
}
else if (stringKey == '1')
{
EDITOR.disableWandSelect();
stopEvent = true;
}
if (stopEvent)
{
if (evt.preventDefault)
{
evt.preventDefault();
evt.stopPropagation();
}
else
{
evt.returnValue = false;
evt.cancelBubble = true;
}
return false;
}
return true;
}
function keyCommand (evt)
{
if (EDITOR.pauseKeyListener)
{
return true;
}
var key = (evt.which || evt.keyCode || evt.charCode);
var stringKey = String.fromCharCode(key).toLowerCase();
stopEvent = true;
if (evt.shiftKey)
{
var isFine = (evt.ctrlKey || EDITOR.fakeCtrl);
if (key == 39 || key == 102)
{
EDITOR.show.scaleMarchers(1,0,isFine)
}
else if (key == 37 || key == 100)
{
EDITOR.show.scaleMarchers(-1,0,isFine)
}
else if (key == 38 || key == 104)
{
EDITOR.show.scaleMarchers(0,1,isFine)
}
else if (key == 40 || key == 98 || key == 101)
{
EDITOR.show.scaleMarchers(0,-1,isFine)
}
else if (stringKey == 's')
{
EDITOR.show.toggleAutoSave();
}
else if (stringKey == "f")
{
EDITOR.show.followTheLeader(true);
}
else if (stringKey == 'a')
{
EDITOR.show.toggleMarcherState(true);
}
else
{
stopEvent = false;
}
}
else if (evt.altKey)
{
if (key == 39)
{
}
else if (key == 37)
{
}
else if (key == 38)
{
}
else if (key == 40)
{
}
else
{
stopEvent = false;
}
}
else if (evt.ctrlKey || EDITOR.fakeCtrl)
{
if (key == 39)
{
EDITOR.show.nudgeMarchers(9,0);
}
else if (key == 37)
{
EDITOR.show.nudgeMarchers(-9,0);
}
else if (key == 38)
{
EDITOR.show.nudgeMarchers(0,-9);
}
else if (key == 40)
{
EDITOR.show.nudgeMarchers(0,9);
}
else if (key == 33)
{
EDITOR.show.jumpToLastSet();
}
else if (key == 34)
{
EDITOR.show.jumpToFirstSet();
}
else if (key == 8)
{
EDITOR.show.resetMarchers(true);
}
else if (key == 46 || stringKey == 'd')
{
EDITOR.show.deleteMarchers(true);
}
else if (stringKey == ']' || key == 221)
{
EDITOR.show.rotateMarchers(1, true);
}
else if (stringKey == '[' || key == 219)
{
EDITOR.show.rotateMarchers(-1, true);
}
else if (stringKey == '=' || key == 187)
{
if (! EDITOR.fakeCtrl && webkit && ! isChrome)
{
alert("In Safari, you'll need to hold the ~ key instead of Ctrl.");
}
else
{
EDITOR.show.scaleMarchers(1,1, true);
}
}
else if (stringKey == '-' || key == 189)
{
if (! EDITOR.fakeCtrl && webkit && ! isChrome)
{
alert("In Safari, you'll need to hold the ~ key instead of Ctrl.");
}
else
{
EDITOR.show.scaleMarchers(-1,-1, true);
}
}
else if (stringKey == '9' || stringKey == '(')
{
EDITOR.show.arcMarchers(-1, true);
}
else if (stringKey == '0' || stringKey == ')')
{
EDITOR.show.arcMarchers(1, true);
}
else if (stringKey == 'a')
{
EDITOR.show.selectAllMarchers();
}
else if (stringKey == 'l')
{
EDITOR.show.selectLongestMarcher();
}
else if (stringKey == "g")
{
EDITOR.show.ghostMarchers(true);
}
else if (stringKey == "b")
{
EDITOR.show.cleanBlock(true);
}
else if (stringKey == "i")
{
EDITOR.show.cleanLine(true);
}
else if (stringKey == 'o')
{
EDITOR.show.circleMarchers(true, false);
}
else if (stringKey == '8' || stringKey == '*')
{
EDITOR.show.scatterMarchers(true);
}
else if (stringKey == 's')
{
EDITOR.show.ajaxSave();
}
else if (stringKey == 'z')
{
EDITOR.undo();
}
else if (stringKey == 'y')
{
EDITOR.redo();
}
else if (key == 32)
{
if (! THROTTLE_SPACE_BAR)
{
if (EDITOR.isPlaying)
{
EDITOR.show.stop();
}
else
{
EDITOR.isSlowPlay = true;
EDITOR.show.pressPlay();
}
THROTTLE_SPACE_BAR = true;
setTimeout("THROTTLE_SPACE_BAR = false;", 500);
}
}
else if (stringKey == "5" || stringKey == "%")
{
EDITOR.show.selectEveryOtherMarcher(true);
}
else if (stringKey == "3" || stringKey == "#")
{
EDITOR.toggleHashes(true);
}
else
{
stopEvent = false;
}
}
else
{
if (key == 39)
{
EDITOR.show.nudgeMarchers(1,0);
}
else if (key == 37)
{
EDITOR.show.nudgeMarchers(-1,0);
}
else if (key == 38)
{
EDITOR.show.nudgeMarchers(0,-1);
}
else if (key == 40)
{
EDITOR.show.nudgeMarchers(0,1);
}
else if (key == 8)
{
EDITOR.show.resetMarchers(false);
}
else if (key == 46 || stringKey == 'd')
{
EDITOR.show.deleteMarchers(false);
}
else if (key == 33)
{
EDITOR.show.jumpToNextSet();
}
else if (key == 34)
{
EDITOR.show.jumpToPrevSet();
}
else if (stringKey == 'o')
{
EDITOR.show.circleMarchers(false, false);
}
else if (stringKey == '9' || stringKey == '(')
{
EDITOR.show.arcMarchers(-1);
}
else if (stringKey == '0' || stringKey == ')')
{
EDITOR.show.arcMarchers(1);
}
else if (stringKey == '8' || stringKey == '*')
{
EDITOR.show.scatterMarchers(false);
}
else if (stringKey == "r")
{
EDITOR.recoverLostMarchers();
}
else if (stringKey == 's')
{
}
else if (key == 59 || key == 186)
{
EDITOR.toggleSetPins();
}
else if (stringKey == 'p')
{
alert("The Set Dots command has been changed to the ':' key.");
}
else if (stringKey == 'z')
{
}
else if (stringKey == 'a')
{
EDITOR.show.toggleMarcherState(false);
}
else if (stringKey == 'e')
{
EDITOR.show.toggleMarcherEquipment(false);
}
else if (stringKey == '1')
{
EDITOR.enableWandSelect();
}
else if (stringKey == ']' || key == 221)
{
EDITOR.show.rotateMarchers(1,false);
}
else if (stringKey == '[' || key == 219)
{
EDITOR.show.rotateMarchers(-1,false);
}
else if (stringKey == '=' || key == 187)
{
EDITOR.show.scaleMarchers(1,1,false);
}
else if (stringKey == '-' || key == 189)
{
EDITOR.show.scaleMarchers(-1,-1,false);
}
else if (key == 32)
{
if (! THROTTLE_SPACE_BAR)
{
if (EDITOR.isPlaying)
{
EDITOR.show.stop();
}
else
{
EDITOR.show.pressPlay();
}
THROTTLE_SPACE_BAR = true;
setTimeout("THROTTLE_SPACE_BAR = false;", 500);
}
}
else if (stringKey == "i")
{
EDITOR.show.cleanLine(false);
}
else if (stringKey == "b")
{
EDITOR.show.cleanBlock();
}
else if (stringKey == "t")
{
EDITOR.show.tradeSets();
}
else if (stringKey == "g")
{
EDITOR.show.ghostMarchers(false);
}
else if (stringKey == "y")
{
EDITOR.toggleSnap();
}
else if (stringKey == "f")
{
EDITOR.show.followTheLeader(false);
}
else if (stringKey == "`" || stringKey == "~" || key == 192)
{
EDITOR.fakeCtrl = true;
}
else if (stringKey == "q")
{
if (! EDITOR.quickSelect)
{
EDITOR.quickSelect = true;
EDITOR.quickHighlightGroup();
}
}
else if (stringKey == "5")
{
EDITOR.show.selectEveryOtherMarcher(false);
}
else if (stringKey == "2")
{
}
else if (stringKey == "c")
{
EDITOR.show.toggleMarcherCaption();
}
else if (stringKey == "x")
{
}
else if (stringKey == "3")
{
EDITOR.toggleHashes(false);
}
else if (stringKey == "7")
{
EDITOR.show.cleanCurve(false);
}
else if (stringKey == "/" || key == 191)
{
}
else
{
stopEvent = false;
}
}
if (stopEvent)
{
if (evt.preventDefault)
{
evt.preventDefault();
evt.stopPropagation();
}
else
{
evt.returnValue = false;
evt.cancelBubble = true;
evt.keyCode = 0;
}
return false;
}
return true;
}
function keyCommandView (evt)
{
if (EDITOR.pauseKeyListener) {  return true; }
var key = (evt.which || evt.keyCode || evt.charCode);
var stringKey = String.fromCharCode(key).toLowerCase();
stopEvent = true;
if (key == 33)
{
if (EDITOR.isJudge && ! EDITOR.didVote)
{
}
else
{
EDITOR.isAnalyze = true;
EDITOR.show.stop();
if (evt.ctrlKey || EDITOR.fakeCtrl)
{
EDITOR.show.jumpToLastSet();
}
else
{
EDITOR.show.jumpToNextSet();
}
}
}
else if (key == 34)
{
if (EDITOR.isJudge && ! EDITOR.didVote)
{
}
else
{
EDITOR.isAnalyze = true;
EDITOR.show.stop();
if (evt.ctrlKey || EDITOR.fakeCtrl)
{
EDITOR.show.jumpToFirstSet();
}
else
{
EDITOR.show.jumpToPrevSet();
}
}
}
else if (key == 32)
{
if (EDITOR.isJudge && ! EDITOR.didVote)
{
}
else
{
if (! THROTTLE_SPACE_BAR)
{
if (EDITOR.isPlaying)
{
EDITOR.show.stop();
}
else
{
if (evt.ctrlKey || EDITOR.fakeCtrl)
{
EDITOR.isSlowPlay = true;
}
EDITOR.isAnalyze = true;
EDITOR.show.pressPlay();
}
THROTTLE_SPACE_BAR = true;
setTimeout("THROTTLE_SPACE_BAR = false;", 500);
}
}
}
else
{
stopEvent = false;
}
if (stopEvent)
{
if (evt.preventDefault)
{
evt.preventDefault();
evt.stopPropagation();
evt.returnValue = false;
}
else
{
evt.returnValue = false;
evt.cancelBubble = true;
}
return false;
}
return true;
}
function listenForKeyPress ()
{
EDITOR.pauseKeyListener = false;
if (document.addEventListener)
{
var keyevent = (webkit) ? "keydown" : "keypress";
document.addEventListener(keyevent, keyCommand, true);
document.addEventListener("keyup", keyCommandUp, true);
}
else if (document.attachEvent)
{
document.attachEvent("onkeydown", function(evt) {keyCommand(evt)});
document.attachEvent("onkeyup", function(evt) {keyCommandUp(evt)});
}
}
function listenForKeyPressView ()
{
EDITOR.pauseKeyListener = false;
if (document.addEventListener)
{
var keyevent = (webkit) ? "keydown" : "keypress";
document.addEventListener(keyevent, keyCommandView, true);
}
else if (document.attachEvent)
{
document.attachEvent("onkeydown", function(evt) {keyCommandView(evt)});
}
}
var __RPC_ID = 'rpc';
function get_rpc_doc (rpcID)
{
if (! rpcID)
{
rpcID = __RPC_ID;
}
if ($(rpcID).contentDocument)
{
return $(rpcID).contentDocument;
}
else if ($(rpcID).contentWindow)
{
return $(rpcID).contentWindow.document;
}
else if ($(rpcID).document)
{
return $(rpcID).document;
}
else
{
return true;
}
}
function spawn_rpc ()
{
var iframe = document.createElement('IFRAME');
iframe.id = 'rpc' + get_now();
iframe.style.display = "none";
document.body.appendChild(iframe);
__RPC_ID = iframe.id;
return iframe;
}
var __THROTTLE = {};
function throttle (actionID, delayMS)
{
var now = get_now();
if (! __THROTTLE[actionID]) { __THROTTLE[actionID] = 0; }
if (now > __THROTTLE[actionID])
{
__THROTTLE[actionID] = now + delayMS;
return false;
}
else
{
return true;
}
}
var _dec_to_base62 = [];
var _base62_to_dec = [];
var base62offset = 62 * 62 / 2;
init_base62();
function init_base62 ()
{
for (i=0; i <= 9; i++)
{
_dec_to_base62[''+i] = i;
}
for (i=10; i <= 35; i++)
{
_dec_to_base62[i] = String.fromCharCode(87 + i);
}
for (i=36; i <= 61; i++)
{
_dec_to_base62[i] = String.fromCharCode(i + 29);
}
for (i=0; i <= 61; i++)
{
_base62_to_dec[ '' + _dec_to_base62[i] ] = i;
}
}
function dec_to_base62 (dec)
{
if ( dec_to_base62.cache[ dec ] != null )
return dec_to_base62.cache[ dec ];
var dec2 = dec + base62offset;
var ones = dec2 % 62;
var tens = (dec2 / 62) >> 0;
var final = _dec_to_base62[tens] + "" + _dec_to_base62[ones];
dec_to_base62.cache[dec] = final;
return final;
}
dec_to_base62.cache = {};
function base62_to_dec (base62)
{
var tens = base62.charAt(0);
var ones = base62.charAt(1);
var total = (_base62_to_dec[tens] * 62) + _base62_to_dec[ones] - base62offset;
return total;
}
function char_dec_to_base62 (dec)
{
return _dec_to_base62[dec];
}
function char_base62_to_dec (base62)
{
return _base62_to_dec[base62];
}
function toInt (str)
{
return str >> 0;
}
var numAlerts = 0;
function debug (msg)
{
if (numAlerts > 10) {  return false; }
alert(msg);
numAlerts ++;
}
function imageUrl ($fileName)
{
return RELEASE_DIR + "/images/" + $fileName;
}
function fix_png ()
{
if (ie6)
{
if (document.all && document.styleSheets && document.styleSheets[0] && document.styleSheets[0].addRule)
{
document.styleSheets[0].addRule('img', 'behavior: url('+ RELEASE_DIR +'/js/iepngfix.htc)');
}
}
}
function rand (min, max)
{
return min + Math.floor(Math.random() * ((max - min) + 1));
}
function stress ()
{
var numFrames = 500;
var startTime = new Date().getTime();
for (frame=0; frame <= numFrames; frame++)
{
for (m=0; m < EDITOR.show.marchers.length; m++)
{
var nx = 100 + Math.ceil(Math.random() * 300);
var ny = 100 + Math.ceil(Math.random() * 200);
EDITOR.show.marchers[m].move(nx, ny);
EDITOR.show.marchers[m].img.style.left = -1 * nx;
}
}
var endTime = new Date().getTime();
var totalSecs = (endTime - startTime) / 1000;
var fps = numFrames / totalSecs;
alert(totalSecs + " secs  ---- " + fps + " fps");
}
//------------------------------------------------ EXTERNAL -------------------------------------------------
function addCSSRule (selector, attributes)
{
var ss = document.styleSheets[document.styleSheets.length-1];
if (ss.insertRule)
{
ss.insertRule(selector + '{' + attributes + '}', ss.cssRules.length);
}
else if (ss.addRule)
{
ss.addRule(selector, attributes);
}
}
function fadeOut (elID, alpha)
{
show(elID);
if (! defined(alpha))
alpha = 100;
setAlpha(elID, alpha);
if (alpha > 0)
{
setTimeout("fadeOut('"+ elID +"', "+ (alpha - 25) +")", 100);
}
else
{
$(elID).style.display = "none";
}
}
function max_length(obj, maxlen)
{
return (obj.value.length <= maxlen);
}
function validate_form (fields)
{
for (field in fields)
{
$(fields[field]).style.border="solid 1px #bbb";
}
for (field in fields)
{
if ($(fields[field]).value == "")
{
$(fields[field]).style.border="solid 1px #900";
$(fields[field]).focus();
alert('Please fill out the entire form.');
return false;
}
}
if ($('email').value.indexOf('@') == -1)
{
$('email').style.borderColor="red";
$('email').focus();
alert('Please provide a valid e-mail address.');
return false;
}
return true;
}
function get_cookie ( name )
{
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) );
{
return null;
}
if ( start == -1 ) return null
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length
return unescape( document.cookie.substring( len, end ) );
}
function set_cookie (name,value,ex)
{
expires = ex * 1000 * 60 * 60 * 24;
var today = new Date();
today.setTime( today.getTime() );
var expires_date = new Date( today.getTime() + (expires) );
document.cookie = name + "=" + value + ";expires=" + expires_date.toGMTString();
}
function clear_cookie (name)
{
var today = new Date();
today.setTime( today.getTime() );
var expires_date = new Date( today.getTime() - 1);
document.cookie = name + "=;expires=" + expires_date.toGMTString();
}
function $ (elementID)
{
return document.getElementById(elementID);
}
function px (val)
{
if (! defined(val)) { return "0px"; }
return (val >> 0) + "px";
}
function get_now ()
{
return new Date().getTime();
}
function getnum (val)
{
if (! defined(val))
return 0;
return parseInt(val);
}
function setAlpha (elID, value)
{
if (! defined($(elID)) )
return false;
if (ns6)
{
$(elID).style.opacity = value / 100;
}
else
{
if (value == 100)
{
$(elID).style.filter = "";
}
else
{
$(elID).style.filter = "alpha(opacity=" + value + ")";
}
}
}
function setAlphaDirect (el, value)
{
if (ns6)
{
el.style.opacity = value / 100;
}
else
{
el.style.filter = "alpha(opacity=" + value + ")";
}
}
function defined (arg)
{
return (typeof arg != "undefined" && arg != null);
}
function hide (elID)
{
if ($(elID))
{
if ($(elID))
$(elID).style.visibility = "hidden";
}
}
function show (elID)
{
if ($(elID))
{
$(elID).style.visibility = "visible";
if ($(elID).style.display != "inline")
$(elID).style.display = "block";
}
}
var toggled = [];
function toggle (elID)
{
if (! toggled[elID])
{
show(elID);
toggled[elID] = 1;
}
else
{
hide(elID);
toggled[elID] = 0;
}
}
var COMMENTS_LOADED = false;
var COMMENTS_OPEN = false;
function open_comments (nodeID, commentType)
{
if (EDITOR.isJudge && ! EDITOR.didVote)
{
alert("Please judge the show before leaving a comment.");
return false;
}
if (! COMMENTS_LOADED)
{
show('commentloading');
if (commentType == 'showcase')
{
$('commentsframe').src = "/comments.php?scid=" + nodeID + "&rand=" + Math.random();
}
else
{
$('commentsframe').src = "/comments.php?sid=" + nodeID + "&rand=" + Math.random();
}
}
if (COMMENTS_OPEN)
{
close_comments();
}
else
{
show('commentsdiv');
hide('showdesc');
if (! commentType)
{
EDITOR.show.abortShow();
}
COMMENTS_LOADED = true;
COMMENTS_OPEN = true;
}
}
function close_comments ()
{
hide('commentsdiv');
COMMENTS_OPEN = false;
}
var COMMENT_ADDED = false;
function submit_comment ()
{
$('commentbutton').value = "Please Wait...";
if (COMMENT_ADDED)
return false;
COMMENT_ADDED = true;
return true;
}
function open_show_results ()
{
show('showresultspopup');
}
function open_share_show ()
{
if (EDITOR.isJudge && ! EDITOR.didVote)
{
alert("Please judge the show before sharing it.");
return false;
}
else
{
show('showsharepopup');
}
}
function submit_show_comment ()
{
var checkComment = $('commentfield').value.toLowerCase();
checkComment = checkComment.replace(/[^a-z!]/g, "");
if (checkComment.length > 0 && checkComment.length < 3)
{
alert("Please say something a little more than that. =)");
return false;
}
else if (checkComment.match(/^(nice|good|goodjob|nicejob|cool|niceshow|goodshow)$/))
{
alert("Please say something a little more specific. =)");
return false;
}
else if (checkComment.length < 60 && checkComment.match(/[ck]o(l+)i(s+)(h*)(i*)[ou]n/))
{
alert("Please do not comment on collisions.  Thanks!");
return false;
}
else if (checkComment.length < 60 && checkComment.match(/crash/))
{
alert("Please do not comment on crashes.  Thanks!");
return false;
}
else if (checkComment.length < 60 && checkComment.match(/cali(tion|sh(i|o|a)n)/))
{
alert("Please do not comment on collisions.  Thanks!");
return false;
}
else
{
return submit_comment();
}
}
function comment_tab_add (isLoggedIn, age, xp)
{
age = 100;
xp = 1000;
if (! isLoggedIn)
{
alert('Please log in to add comments.');
return false;
}
else if (xp < 100)
{
alert('Sorry, you must be at least a Rookie (100 XP) to leave a comment.');
return false;
}
else if (age < 14)
{
if (xp <= 1000)
{
alert('Sorry, you must be a Veteran (1000 XP) to leave a comment.');
return false;
}
else
{
alert('Sorry, you must be at least 14 years old to leave a comment.');
return false;
}
}
$('commentlink').style.display = "none";
$('comments').style.display = "none";
$('newcomment').style.display = "block";
$('readlink').style.display = "block";
$('commentfield').focus();
}
function comment_tab_read ()
{
$('commentlink').style.display = "block";
$('comments').style.display = "block";
$('newcomment').style.display = "none";
$('readlink').style.display = "none";
}
function profile_comment_tab_add (isLoggedIn, age, xp)
{
if (! isLoggedIn)
{
alert('You must be logged in to add comments.');
return false;
}
else if (age < 14)
{
if (xp <= 1000)
{
alert('You must be a Veteran (1000 XP) to leave a comment.');
return false;
}
else
{
alert('You must be at least 14 years old to leave a comment.');
return false;
}
}
else if (xp < 100)
{
alert('You must be at least a Rookie (100 XP) to leave a comment.');
return false;
}
$('commentlink').style.display = "none";
$('commentlist').style.display = "none";
$('commentpost').style.display = "block";
$('readlink').style.display = "block";
$('forumtextarea').focus();
}
function profile_comment_tab_read ()
{
$('commentlink').style.display = "block";
$('commentlist').style.display = "block";
$('commentpost').style.display = "none";
$('readlink').style.display = "none";
}
function play_link_over (el)
{
el.style.color = "#F3EDAD";
el.style.border = "solid 1px #8CC693";
}
function play_link_out (el)
{
el.style.color = "#DFD13A";
el.style.border = "solid 1px #467C50";
}
function menu_link_over (el)
{
el.style.color = "#fff";
el.style.border = "solid 1px #8CC693";
}
function menu_link_out (el)
{
el.style.color = "#A1CCA9";
el.style.border = "solid 1px #467C50";
}
var addStyled = false;
function add_link_over (el)
{
el.style.color = "#F3EDAD";
el.style.border = "solid 1px #8CC693";
addStyled = true;
}
function add_link_out (el)
{
if (addStyled)
{
el.style.color = "#DFD13A";
el.style.border = "solid 1px #467C50";
addStyled = false;
}
}
function abandon_show ()
{
if (confirm("Discard this show and start a new one?"))
{
EDITOR.showIsChanged = false;
document.location.href="/design.php?rm=menu";
}
}
function save_response (status)
{
clearInterval(AJAX_TIMEOUT_ID);
EDITOR.isSaving = false;
if (status == "resave")
{
if (EDITOR.numSaveAttempts < 3)
{
++ EDITOR.numSaveAttempts;
EDITOR.show.ajaxSave();
}
else
{
hide('saving');
alert("There is a problem saving your show.\n\nFor some reason, all of your show data is not being sent to the server.");
EDITOR.numSaveAttempts = 0;
}
}
else if (status == "logged_out")
{
hide('saving');
EDITOR.numSaveAttempts = 0;
EDITOR.numSaveHeartbeats = 0;
}
else if (status == "cancel")
{
hide('saving');
EDITOR.numSaveAttempts = 0;
EDITOR.numSaveHeartbeats = 0;
EDITOR.showIsChanged = false;
if (ie)
{
document.execCommand('Stop');
}
else
{
var rpc = get_rpc_doc();
try {  rpc.stop(); } catch (e) {};
}
}
else
{
EDITOR.numSaveAttempts = 0;
EDITOR.numSaveHeartbeats = 0;
EDITOR.showIsChanged = false;
if (EDITOR.doPublishAfterSave)
{
EDITOR.show.finishPublish();
}
else if (EDITOR.postSaveAction == "preview")
{
var defaultMsg = $('saving').innerHTML;
$('saving').innerHTML = '<span style="font-size: 80%">If there is a problem, check your popup blocker.</span>';
if (true)
{
var child = window.open(EDITOR.previewURL);
}
else
{
location.hash = rand(200000,999999);
location.href = EDITOR.previewURL;
}
hide('saving');
$('saving').innerHTML = defaultMsg;
EDITOR.postSaveAction = "";
}
else if (EDITOR.postSaveAction == "freezer")
{
hide('saving');
EDITOR.postSaveAction = "";
location.href = EDITOR.freezerURL;
}
else
{
var now = new Date().getTime();
if (now - AJAX_TIME < 500)
{
setTimeout("hide('saving')", 500 - (now - AJAX_TIME));
}
else
{
hide('saving');
}
}
}
}
function vote_response (status)
{
clearInterval(AJAX_TIMEOUT_ID);
var now = new Date().getTime();
var ms = 1;
if (now - AJAX_TIME < 500)
{
ms = 500 - (now - AJAX_TIME);
}
setTimeout('post_vote()', ms);
}
function showSavebox ()
{
if (EDITOR.isPlaying)
return false;
EDITOR.show.saveSet();
if (SHOW_TOOL_MENU)
{
toggleToolMenu();
}
if (EDITOR.isPublished)
{
alert("This show has already been published.");
return false;
}
if (EDITOR.show.maxSet < MIN_SETS - 1)
{
alert("Sorry, you need at least " + MIN_SETS + " sets to publish a show.");
return false;
}
if (EDITOR.isPremium)
{
if (! EDITOR.show.guardLastSetIsOK())
{
alert("The guard must end the show in a pose (Animations 1-" + NUM_FLAG_POSES + ").");
return false;
}
}
$('savebox').style.display = "block";
$('showTitle').focus();
EDITOR.pauseEvents();
}
function design_menu_loading (groupType, isBlocked)
{
if (isBlocked)
{
alert('This option is available to premium members.\n\nYou can visit the Shop (below) to upgrade any time.');
return false;
}
$('groupselectoptions').style.visibility = "hidden";
show('menuloading');
document.location.href="/design.php?rm=startnew&groupType=" + groupType;
}
function hideSavebox ()
{
if (! EDITOR.isPlaying)
$('savebox').style.display = "none";
EDITOR.initEvents();
}
function toggleToolMenu ()
{
SHOW_TOOL_MENU = 1 - SHOW_TOOL_MENU;
$('toolmenu').style.display = (SHOW_TOOL_MENU) ? 'block' : 'none';
}
function confirmExit ()
{
if (EDITOR.mode == MODE_EDIT && EDITOR.show.maxSet > 1)
{
if (ie)
{
return confirm("Abandon your changes?");
}
else
{
return true;
}
}
else
{
return true;
}
}
function deepObjCopy (dupeObj) {
var retObj = new Object();
if (typeof(dupeObj) == 'object') {
if (typeof(dupeObj.length) != 'undefined')
var retObj = [];
for (var objInd in dupeObj) {
if (typeof(dupeObj[objInd]) == 'object') {
retObj[objInd] = deepObjCopy(dupeObj[objInd]);
} else if (typeof(dupeObj[objInd]) == 'string') {
retObj[objInd] = dupeObj[objInd];
} else if (typeof(dupeObj[objInd]) == 'number') {
retObj[objInd] = dupeObj[objInd];
} else if (typeof(dupeObj[objInd]) == 'boolean') {
((dupeObj[objInd] == true) ? retObj[objInd] = true : retObj[objInd] = false);
}
}
}
return retObj;
}
if (typeof Object.create !== 'function')
{
Object.create = function (o)
{
function F() {}
F.prototype = o;
return new F();
};
}
function getElementsByClass (rootobj, classname)
{
var els = [];
var inc = 0;
var children = rootobj.childNodes;
for (i=0; i < children.length; i++)
{
if (children[i].className == classname)
{
els.push(children[i]);
}
}
return els;
}
var oBridge =
{
xinit_show : function (args)
{
EDITOR = new oEditor();
EDITOR.is3D = args.is3D;
EDITOR.isJudge = args.isJudge;
EDITOR.isPreview = args.isPreview;
EDITOR.showID = args.showID;
EDITOR.groupType = args.groupType;
EDITOR.isPremium = args.isPremium;
EDITOR.initViewMode();
if (args.spriteURL)
{
EDITOR.spriteURL = args.spriteURL;
}
},
xinit_loaded : function (data)
{
LOADED = data;
EDITOR.show.loadSaved();
EDITOR.show.hasDescription = data.hasDescription;
},
xplay_show : function ()
{
EDITOR.show.play();
},
xdraw_votepanel : function (showID, doDisqual)
{
draw_votepanel(showID, doDisqual);
},
xstop_and_vote : function ()
{
EDITOR.show.stopAndVote();
},
xreload_sprite : function (spriteType, imageURL)
{
EDITOR.reload_sprite(spriteType, imageURL);
},
xplay_fast : function ()
{
if (! EDITOR.isFastPlay)
{
EDITOR.isFastPlay = true;
EDITOR.show.play();
}
}
}
var ANIM_SCROLL_ID = 0;
var THROTTLE_SCROLL = false;
var IS_SCROLLING = false;
var IS_SCROLLING_ID = 0;
function handle(delta, event)
{
if (! IS_SCROLLING && (EDITOR.FFNWUB.length == 0 || ! EDITOR.cursorInEditor))
{
return true;
}
if (THROTTLE_SCROLL)
{
return false;
}
if (EDITOR.animScroll)
{
EDITOR.show.toggleMarcherState((delta < 0) ? true : false);
throttleScroll(50);
}
else if (event.shiftKey)
{
if (delta < 0)
{
EDITOR.show.scaleMarchers(-3,-3, true);
}
else
{
EDITOR.show.scaleMarchers(3,3, true);
}
}
else if (event.ctrlKey || EDITOR.fakeCtrl)
{
if (webkit && ! EDITOR.fakeCtrl)
{
var agent = (isChrome) ?  " Chrome" : "Safari";
alert("In " + agent + ", you'll need to hold the ~ key instead of Ctrl.");
throttleScroll(1000);
}
else
{
if (delta < 0)
{
EDITOR.show.arcMarchers(1);
}
else
{
EDITOR.show.arcMarchers(-1);
}
}
}
else
{
if (delta < 0)
{
EDITOR.show.rotateMarchers(2,2, true);
}
else
{
EDITOR.show.rotateMarchers(-2,-2, true);
}
}
IS_SCROLLING = true;
clearTimeout(IS_SCROLLING_ID);
IS_SCROLLING_ID = setTimeout("IS_SCROLLING = false;", 1200);
return false;
}
function throttleScroll (delayMS)
{
if (! delayMS) { delayMS = 50; }
THROTTLE_SCROLL = true;
setTimeout("THROTTLE_SCROLL = false", delayMS);
}
function wheel (event) {
var doPropagate = true;
var delta = 0;
if (! event) {  event = window.event; }
if (event.wheelDelta)
{
delta = event.wheelDelta / 120;
if (window.opera) {  delta = -delta; }
}
else if (event.detail)
{
delta = -event.detail / 3;
}
if (delta)
{
doPropagate = handle(delta, event);
}
if (event.preventDefault && ! doPropagate)
{
event.preventDefault();
}
event.returnValue = doPropagate;
}