Ask your WordPress questions! Pay money and get answers fast! (more info)

Transfering Javascript from Old Page to New WP Page (Karma Theme) WordPress

  • SOLVED

I would like to add an interactive chess board that allows users to click on arrow buttons to scroll through chess games. I know there is a simple answer and I am missing something really obvious. *sigh*

If you could kindly take a look at http://bughouse.net/main/?page_id=272, the code, for some reason doesn’t render properly.

The chessboards should look like: http://bughouse.net/training_center/master_games/games_viewable_online/gp1_finals.htm

On the original page, when the user selects a game from the pull-down menu they are able to then click the arrow buttons below and play out the games on the chessboard. Aside from looking funny and oversized on the new page, users are unable to click the buttons to play out the games on the new chessboard.


Here is step by step what I did to modify the source (Below the explanation is the oringal source code and the modified one):


I wrapped the code with the [raw][/raw] tags.

I then Opened the Appearance > Editor

And edited the Karma: Stylesheet (style.css).

I located the following code around line 107.

html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td {
border: 0;
/* outline: 0; */
font-size: 100%;
vertical-align: baseline;
background: transparent;
margin: 0;
padding: 0;
}


and removed table, tr, th, td from the classes like so:

html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead {
border: 0;
/* outline: 0; */
font-size: 100%;
vertical-align: baseline;
background: transparent;
margin: 0;
padding: 0;
}








This is the source code from the original page:
http://bughouse.net/training_center/master_games/games_viewable_online/gp1_finals.htm



<!-- InstanceBeginEditable name="body" --><center><br>

<form name="bugmenu">
<select name="games" size="1" onchange="choosegame('v1',this.selectedIndex);;">
<option>Bughouse Grand Prix 1 - Finals (March 3, 2001)
</option><option>Tecumseh(2167)/LINDEGREN(2360) v ChaseJr(2179)/Marat(2193) 1-0
</option><option>LINDEGREN(2366)/Tecumseh(2173) v Marat(2187)/ChaseJr(2173) 1-0
</option><option>Marat(2181)/ChaseJr(2167) v LINDEGREN(2372)/Tecumseh(2179) 1-0
</option><option>LINDEGREN(2362)/Tecumseh(2169) v Marat(2191)/ChaseJr(2177) 1-0
</option><option>Tecumseh(2175)/LINDEGREN(2368) v ChaseJr(2171)/Marat(2185) 0-1
</option><option>LINDEGREN(2358)/ChaseJr(2181) v Marat(2195)/Tecumseh(2165) 1-0
</option><option>ChaseJr(2187)/LINDEGREN(2364) v Tecumseh(2159)/Marat(2189) 1-0
</option><option>LINDEGREN(2370)/ChaseJr(2193) v Marat(2183)/Tecumseh(2153) 1-0
</option><option>Marat(2177)/Tecumseh(2147) v LINDEGREN(2376)/ChaseJr(2199) 1-0
</option><option>Tecumseh(2158)/Marat(2188) v ChaseJr(2188)/LINDEGREN(2365) 1-0
</option><option>ChaseJr(2178)/Tecumseh(2168) v LINDEGREN(2355)/Marat(2198) 1-0
</option><option>LINDEGREN(2345)/Marat(2188) v ChaseJr(2188)/Tecumseh(2178) 1-0
</option><option>ChaseJr(2182)/Tecumseh(2172) v LINDEGREN(2351)/Marat(2194) 0-1
</option><option>LINDEGREN(2357)/Marat(2200) v ChaseJr(2176)/Tecumseh(2166) 0-1
</option><option>ChaseJr(2186)/Tecumseh(2176) v LINDEGREN(2347)/Marat(2190) 1-0
</option></select></form></center><br>
<script><!--
function choosegame(viewer,ind)
{ if (ind<1) return;
var v=eval(viewer);
var t=eval("bpgn"+ind);
v.reloadgame(t,"");
}
Init();
v1=new game("v1","", "","", "", "", "", "gif/", 32, "333333|CC9966|946651", "flip");
bpgn1='[Event "fics rated bughouse match"][Site "fics, Oklahoma City, OK USA"][Date "2001.03.03"][WhiteA "Tecumseh"][WhiteAElo "2167"][BlackA "ChaseJr"][BlackAElo "2179"][WhiteB "Marat"][WhiteBElo "2193"][BlackB "LINDEGREN"][BlackBElo "2360"][TimeControl "180+0"][Result "1-0"]1B. e4 {179} 1A. e4 {179} 1a. d5 {179} 1b. Nf6 {180} 2A. exd5 {179}2B. Nc3 {178} 2b. Nc6 {179} 2a. e6 {179} 3A. Bb5+ {178} 3a. c6 {178}3B. Nf3 {176} 4A. dxc6 {178} 4a. bxc6 {178} 3b. d5 {179} 4B. exd5 {175}5A. Be2 {176} 4b. Nxd5 {179} 5B. Nxd5 {175} 5a. Bc5 {176} 5b. Qxd5 {178}6A. d4 {176} 6B. d4 {174} 6a. Bxd4 {175} 6b. e6 {178} 7A. Be3 {175}7a. Bxe3 {174} 7B. Bf4 {172} 8A. Qxd8+ {174} 8a. Kxd8 {174} 7b. Bb4+ {177}8B. P@c3 {170} 8b. Qe4+ {174} 9B. P@e3 {169} 9A. P@c7+ {167} 9a. Kxc7 {172}10A. N@e8+ {165} 10a. Kd8 {171} 9b. Bxc3+ {165} 11A. P@c7+ {160}11a. Kxe8 {170} 12A. fxe3 {158} 12a. P@f2+ {167} 10B. bxc3 {160}13A. Kxf2 {156} 10b. B@b2 {163} 13a. N@e4+ {162} 14A. Kf1 {156} 11B. Bxc7 {154}11b. Bxc3+ {162} 12B. P@d2 {152} 14a. B@h4 {148} 12b. O-O {147} 15A. P@f2 {149}15a. Nd7 {137} 16A. Nf3 {146} 13B. dxc3 {132} 16a. Be7 {133} 17A. Nc3 {142}17a. Nxc3 {131} 18A. bxc3 {141} 18a. B@a6 {130} 13b. N@g4 {135} 14B. B@d3 {126}19A. Nd4 {132} 14b. Qxe3+ {134} 19a. Bxe2+ {128} 20A. Nxe2 {131} 20a. Ba6 {127}15B. Qe2 {120} 21A. P@d3 {126} 21a. Ngf6 {126} 22A. Rb1 {124} 15b. Qxe2+ {120}16B. Bfxe2 {118} 16b. P@d2+ {116} 17B. Nxd2 {117} 17b. B@h6 {115}22a. P@f3 {105} 23A. gxf3 {122} 23a. P@g2+ {102} 18B. B@c1 {108}24A. Kxg2 {121} 18b. P@e3 {113} 19B. Bxh7+ {102} 24a. Nd5 {60} 19b. Kxh7 {74}25A. Q@g3 {115} 20B. O-O {92} 25a. P@h3+ {52} 20b. exf2+ {72} 21B. Rxf2 {91}26A. Qxh3 {110} 26a. Nxc7 {50} 27A. P@b7 {108} 27a. Rd8 {45} 28A. Qg3 {107}28a. P@g6 {26} 29A. Qxc7 {106} 29a. Q@g5+ {23} 30A. B@g3 {104} 30a. Bxb7 {16}31A. Qxd8+ {103} 31a. Bxd8 {14} 21b. R@h1+ {23} 32A. Rxb7 {101} 22B. Kxh1 {89}22b. Nxf2+ {20} 23B. Kg1 {89} 32a. R@f6 {11} 33A. R@g4 {99} 33a. Qf5 {10}34A. Nd4 {97} 34a. Qd5 {9} 23b. N@h3+ {12} 35A. Rxd7 {95} 24B. gxh3 {88}24b. Nxh3+ {12} 35a. Qxd7 {7} 36A. h3 {94} 25B. Kg2 {85} 36a. N@e1+ {7}37A. Rxe1 {93} 37a. h5 {6} 38A. Rxg6 {92} 25b. Q@g1+ {7} 26B. Kxh3 {85}38a. Rxg6 {4} 39A. P@g4 {91} 26b. N@f2+ {5} 39a. N@e4 {3} 40A. fxe4 {91}27B. Kh4 {83} 40a. hxg4 {3} 27b. Qg5+ {4}{Marat checkmated} 1-0';
bpgn2='[Event "fics rated bughouse match"][Site "fics, Oklahoma City, OK USA"][Date "2001.03.03"][WhiteA "LINDEGREN"][WhiteAElo "2366"][BlackA "Marat"][BlackAElo "2187"][WhiteB "ChaseJr"][WhiteBElo "2173"][BlackB "Tecumseh"][BlackBElo "2173"][TimeControl "180+0"][Result "1-0"]1B. e4 {179} 1A. e4 {179} 1b. Nc6 {179} 1a. Nf6 {179} 2B. Nc3 {178}2A. Nc3 {179} 2a. d5 {179} 3A. exd5 {179} 2b. Nf6 {178} 3a. Nxd5 {178}4A. d4 {179} 3B. d4 {177} 4a. Nc6 {178} 3b. e6 {177} 5A. Nf3 {178}4B. Nf3 {176} 5a. e6 {177} 4b. d5 {177} 6A. Bb5 {178} 5B. exd5 {176}6a. Bd7 {176} 5b. Nxd5 {176} 7A. Bd2 {178} 6B. Bb5 {176} 6b. Bb4 {175}7a. Bd6 {174} 7B. Bd2 {175} 8A. Nxd5 {177} 8a. exd5 {173} 7b. Bxc3 {173}9A. Bxc6 {176} 8B. bxc3 {175} 8b. N@e4 {172} 9a. bxc6 {172} 10A. Qe2+ {175}10a. P@e4 {170} 9B. B@h4 {172} 11A. N@h5 {175} 9b. P@f6 {170} 10B. N@e5 {171}11a. Rg8 {166} 10b. fxe5 {168} 12A. P@h6 {174} 11B. Nxe5 {169} 11b. Qxh4 {166}12B. P@g3 {168} 12a. B@f6 {159} 12b. Qe7 {161} 13A. hxg7 {168} 13B. Nxc6 {166}13b. bxc6 {158} 14B. Bxc6+ {166} 14b. P@d7 {155} 15B. Bxa8 {165}13a. P@g4 {151} 15b. Ndxc3 {153} 14A. Nxf6+ {165} 14a. Qxf6 {150}16B. Bxe4 {162} 15A. B@g5 {162} 16b. Nxd1 {150} 15a. gxf3 {148} 17B. Rxd1 {161}16A. gxf3 {161} 16a. N@g2+ {147} 17A. Kd1 {159} 17a. P@d3 {145} 17b. P@b2 {141}18B. N@h5 {160} 18b. Rg8 {139} 18A. cxd3 {152} 19B. Bxh7 {158} 18a. P@c2+ {139}19A. Kxc2 {150} 19a. Qxd4 {138} 20A. N@f6+ {146} 19b. B@c1 {125}20a. Qxf6 {137} 21A. Bxf6 {145} 20B. O-O {150} 21a. N@e5 {127} 20b. P@f3 {117}22A. Bxe5 {132} 22a. R@c5+ {125} 23A. P@c4 {129} 21B. gxf3 {129}23a. Rxc4+ {116} 21b. P@h3 {110} 24A. Bdc3 {121} 22B. N@f4 {123}24a. N@b4+ {113} 22b. N@e2+ {107} 25A. Kc1 {119} 25a. Nxd3+ {111}26A. Kb1 {112} 23B. Kh1 {114} 23b. Nxf4 {95} 24B. Nxf4 {114} 24b. Bxd2 {83}25B. P@g2 {113} 25b. Bxf4 {81} 26B. gxh3 {112} 26b. Rh8 {72} 27B. P@g2 {111}27b. Rxh7 {66} 28B. gxf4 {110} 26a. Nxe5 {58} 27A. N@f6+ {109} 28b. Bb7 {58}27a. Kd8 {56} 29B. B@g4 {107} 28A. N@b7+ {106} 28a. Ke7 {55} 29b. N@f6 {54}29A. Nxg8+ {104} 29a. Rxg8 {54} 30B. N@e5 {104} 30b. Nxg4 {53} 31B. hxg4 {100}30A. B@f6+ {93} 30a. Kxf6 {53} 31A. N@h5+ {92} 31b. Rxh2+ {42} 32B. Kxh2 {99}31a. Kg6 {44} 32A. Q@f6+ {89} 32a. Kxh5 {43} 32b. Qh4+ {33} 33B. B@h3 {98}33b. Q@e2 {27} 33A. h3 {62} 34B. P@g3 {75} 34b. Qxf1 {13} 35B. Rxf1 {73}33a. P@f5 {22} 35b. Qe7 {12} 34A. P@g4+ {61} 36B. N@b5 {71} 36b. d6 {10}37B. Ng6 {69} 37b. fxg6 {9} 38B. N@g8 {68} 38b. Qf7 {8} 39B. Nxc7+ {68}39b. Qxc7 {7} 40B. g5 {68} 40b. R@h8 {6} 34a. fxg4 {7} 41B. P@h7 {66}35A. R@h6+ {59}{Marat checkmated} 1-0';
bpgn3='[Event "fics rated bughouse match"][Site "fics, Oklahoma City, OK USA"][Date "2001.03.03"][WhiteA "Marat"][WhiteAElo "2181"][BlackA "LINDEGREN"][BlackAElo "2372"][WhiteB "Tecumseh"][WhiteBElo "2179"][BlackB "ChaseJr"][BlackBElo "2167"][TimeControl "180+0"][Result "1-0"]1A. e4 {178} 1a. Nf6 {180} 1B. e4 {176} 2A. Nc3 {177} 1b. d5 {180}2a. Nc6 {180} 2B. exd5 {175} 2b. e6 {179} 3B. Bb5+ {174} 3A. Nf3 {175}3b. c6 {179} 3a. e6 {179} 4B. dxc6 {174} 4A. d4 {174} 4b. bxc6 {178}5B. d4 {173} 4a. d5 {179} 5A. Bg5 {173} 5b. cxb5 {177} 6B. Nc3 {173}5a. Be7 {177} 6b. Bb4 {176} 6A. Bxf6 {172} 7B. Bf4 {172} 6a. Bxf6 {177}7b. Na6 {175} 7A. P@e5 {170} 8B. a4 {167} 7a. Bg5 {173} 8b. N@d5 {174}8A. Nxg5 {169} 8a. Qxg5 {173} 9B. axb5 {166} 9b. Nxf4 {173} 10B. B@f3 {166}9A. B@e3 {163} 9a. P@f4 {173} 10b. B@b7 {169} 10A. Bxf4 {163} 10a. Qxf4 {172}11A. B@e3 {162} 11B. B@c6+ {163} 11b. Bxc6 {166} 11a. Qxe3+ {167}12B. bxc6 {162} 12A. fxe3 {161} 12a. B@b4 {163} 12b. P@d5 {159} 13A. B@h4 {157}13B. B@b5 {159} 13a. dxe4 {160} 13b. Nc7 {156} 14A. Bb5 {155} 14B. P@d7+ {156}14b. Kf8 {155} 14a. P@f3 {154} 15B. dxc8=Q {149} 15b. Rxc8 {154}16B. N@d7+ {140} 16b. Ke8 {151} 17B. Bf1 {130} 17b. Bxc3+ {148} 18B. bxc3 {129}18b. Q@b2 {148} 15A. Qd2 {116} 15a. B@e7 {145} 16A. Bxe7 {110} 16a. Bxe7 {143}19B. B@b4 {105} 17A. N@h5 {108} 19b. Qxb4 {142} 17a. B@h6 {138} 20B. cxb4 {101}18A. P@f6 {105} 20b. B@c3+ {139} 18a. fxg2 {132} 19A. Qxg2 {102} 21B. P@d2 {91}21b. Bxb4 {137} 19a. Q@f3 {124} 22B. Rxa7 {83} 22b. P@c3 {136} 23B. d3 {31}20A. Nxg7+ {41} 23b. P@d2+ {130} 24B. Qxd2 {30} 24b. cxd2+ {127}{Tecumseh resigns} 1-0';
bpgn4='[Event "fics rated bughouse match"][Site "fics, Oklahoma City, OK USA"][Date "2001.03.03"][WhiteA "LINDEGREN"][WhiteAElo "2362"][BlackA "Marat"][BlackAElo "2191"][WhiteB "ChaseJr"][WhiteBElo "2177"][BlackB "Tecumseh"][BlackBElo "2169"][TimeControl "180+0"][Result "1-0"]1B. e4 {179} 1A. e4 {179} 1b. Nc6 {180} 1a. Nf6 {179} 2B. Nc3 {179}2A. Nc3 {179} 2b. Nf6 {179} 2a. d5 {178} 3B. Nf3 {178} 3A. exd5 {179}3a. Nxd5 {178} 3b. e6 {179} 4A. d4 {179} 4a. Nxc3 {177} 4B. Bb5 {176}4b. d5 {178} 5A. bxc3 {177} 5B. exd5 {176} 5a. Nc6 {177} 5b. exd5 {177}6A. Nf3 {177} 6B. d4 {176} 6a. e6 {174} 6b. Bb4 {175} 7A. Bd3 {177}7B. N@e5 {175} 7b. P@h3 {173} 7a. Bd6 {170} 8B. Nxc6 {172} 8A. P@e5 {175}8a. Be7 {167} 8b. bxc6 {169} 9B. Bxc6+ {172} 9b. Bd7 {169} 9A. N@h5 {173}10B. Bxd7+ {171} 10b. Qxd7 {168} 9a. B@f8 {165} 11B. Ne5 {170} 11b. hxg2 {166}12B. Rg1 {168} 12b. Qe7 {163} 10A. P@h6 {162} 10a. P@h3 {152} 13B. Be3 {143}13b. Bxc3+ {161} 11A. hxg7 {151} 14B. bxc3 {142} 11a. hxg2 {150} 12A. Rg1 {149}12a. Bxg7 {148} 13A. Nxg7+ {148} 13a. Kd7 {147} 14b. B@f1 {150} 14A. d5 {142}14a. exd5 {143} 15A. Bf5+ {142} 15B. P@b7 {135} 15a. P@e6 {142} 15b. Rd8 {148}16A. Qxd5+ {141} 16B. P@e2 {130} 16a. B@d6 {137} 17A. N@c5+ {139}{Marat checkmated} 1-0';
bpgn5='[Event "fics rated bughouse match"][Site "fics, Oklahoma City, OK USA"][Date "2001.03.03"][WhiteA "Tecumseh"][WhiteAElo "2175"][BlackA "ChaseJr"][BlackAElo "2171"][WhiteB "Marat"][WhiteBElo "2185"][BlackB "LINDEGREN"][BlackBElo "2368"][TimeControl "180+0"][Result "0-1"]1A. e4 {179} 1a. d5 {180} 1B. e4 {177} 2A. exd5 {178} 1b. Nf6 {180}2a. e6 {179} 2B. Nc3 {176} 3A. Bb5+ {178} 2b. Nc6 {180} 3a. c6 {178}3B. Nf3 {175} 4A. dxc6 {177} 3b. d5 {180} 4a. bxc6 {178} 4B. exd5 {174}4b. Nxd5 {179} 5A. d4 {176} 5B. Nxd5 {174} 5a. cxb5 {177} 6A. Nc3 {175}5b. Qxd5 {178} 6B. d4 {174} 6b. e6 {178} 6a. Bb4 {176} 7B. Be2 {173}7A. Bf4 {175} 7a. N@d5 {176} 7b. Bb4+ {177} 8A. P@c7 {173} 8B. P@c3 {170}8a. Nxc7 {174} 9A. Bxc7 {173} 9a. Qxc7 {174} 8b. Be7 {175} 10A. Ne2 {166}9B. B@c4 {162} 10a. P@h3 {169} 11A. Rg1 {164} 11a. hxg2 {167} 12A. Rxg2 {162}12a. Bb7 {162} 9b. Qd8 {173} 10B. B@b5 {159} 13A. Rxg7 {145} 10b. N@e4 {168}11B. Bxc6+ {157} 11b. bxc6 {167} 13a. N@f3+ {153} 14A. Kf1 {144}14a. Nxh2+ {152} 12B. Rf1 {153} 15A. Kg1 {138} 15a. Nf3+ {150} 16A. Kh1 {136}12b. P@d6 {158} 13B. Bcd3 {152} 16a. Qh2+ {147}{Tecumseh checkmated} 0-1';
bpgn6='[Event "fics rated bughouse match"][Site "fics, Oklahoma City, OK USA"][Date "2001.03.03"][WhiteA "LINDEGREN"][WhiteAElo "2358"][BlackA "Marat"][BlackAElo "2195"][WhiteB "Tecumseh"][WhiteBElo "2165"][BlackB "ChaseJr"][BlackBElo "2181"][TimeControl "180+0"][Result "1-0"]1A. e4 {178} 1B. e4 {177} 1b. d5 {180} 1a. Nf6 {178} 2A. Nc3 {177} 2a. d5 {177}3A. exd5 {177} 2B. exd5 {174} 3a. Nxd5 {176} 2b. e6 {179} 4A. d4 {177}4a. Nc6 {175} 3B. Bb5+ {171} 5A. Nf3 {177} 5a. Nxc3 {175} 3b. c6 {178}6A. bxc3 {177} 4B. dxc6 {171} 6a. Bg4 {173} 4b. bxc6 {177} 5B. d4 {169}7A. Bb5 {174} 5b. cxb5 {177} 7a. e6 {172} 6B. Nc3 {167} 8A. h3 {174}6b. Bb4 {176} 8a. Bxf3 {171} 9A. Qxf3 {173} 7B. N@h5 {164} 9a. P@f6 {168}7b. B@f8 {173} 10A. P@a6 {169} 8B. P@h6 {161} 10a. P@d7 {166} 11A. axb7 {168}11a. Rb8 {165} 8b. N@f5 {168} 9B. hxg7 {159} 9b. Nxg7 {168} 12A. Bxc6 {162}12a. dxc6 {164} 13A. Qxc6+ {161} 10B. Bf4 {153} 13a. P@d7 {163} 14A. Qf3 {161}10b. N@d5 {165} 11B. B@g3 {151} 11b. Nxc3 {160} 12B. bxc3 {150}12b. Bxc3+ {159} 13B. Kf1 {149} 14a. N@d5 {141} 13b. Bxd4 {151}14B. N@c7+ {144} 15A. B@c8 {155} 14b. Qxc7 {148} 15B. Bxc7 {143}15a. Nxc3 {131} 15b. Nc6 {142} 16A. Qxc3 {152} 16a. Q@b4 {127} 16B. Qxd4 {135}16b. Nxd4 {138} 17B. Nxg7+ {111} 17b. Bxg7 {137} 18B. Rd1 {108} 18b. Ba6 {133}19B. P@e2 {91} 19b. P@f3 {131} 20B. gxf3 {82} 20b. P@h3 {130} 21B. Nxh3 {77}17A. P@d2 {70} 17a. Qxc3 {124} 18A. dxc3 {70} 18a. N@h4 {120} 19A. N@f4 {64}21b. Q@d5 {107} 19a. B@d6 {117} 22B. Bb8 {69} 20A. P@c6 {59} 20a. Rxc8 {114}21A. bxc8=Q {56} 21a. Qxc8 {113} 22A. P@b7 {55} 22a. Qd8 {111} 23A. cxd7+ {53}22b. P@g2+ {90} 23a. Qxd7 {107} 24A. b8=Q+ {52} 23B. Kxg2 {61} 23b. R@g6 {86}24B. B@g4 {59} 24b. Rxg4 {76} 25B. P@d7+ {54} 25b. Qxd7 {41} 26B. fxg4 {52}26b. P@f3+ {40} 24a. R@d8 {39} 27B. exf3 {50} 25A. Qxd8+ {49} 25a. Qxd8 {38}26A. B@b5+ {46} 27b. R@e2 {32} 26a. P@d7 {37} 27A. P@b7 {44} 28B. P@e3 {47}27a. Nxg2+ {36} 28A. Nxg2 {42} 28b. h5 {25} 29B. g5 {44} 29b. Bb7 {24}30B. P@e4 {41} 30b. Bxe4 {22} 28a. Bfe7 {20} 31B. Q@f4 {40} 29A. N@h5 {40}31b. Nxf3 {19} 32B. Qxe4 {38} 32b. Nd2 {13} 29a. B@f8 {9} 33B. Rxd2 {37}33b. Rxd2 {12} 30A. Bxd7+ {39} 34B. Qxa8 {36} 30a. Qxd7 {7} 31A. Q@c8+ {39}34b. P@f3+ {11} 35B. Qxf3 {35} 31a. N@d8 {5} 35b. N@d5 {11} 36B. P@c7 {34}32A. Qxd7+ {38} 32a. Kxd7 {5} 33A. N@b8+ {37} 36b. Nxe3+ {8} 37B. Qxe3 {33}37b. N@h4+ {8} 38B. Bxh4 {32} 33a. Ke8 {0} 38b. Q@b7+ {8} 34A. P@d7+ {35}{Marat checkmated} 1-0';
bpgn7='[Event "fics rated bughouse match"][Site "fics, Oklahoma City, OK USA"][Date "2001.03.03"][WhiteA "ChaseJr"][WhiteAElo "2187"][BlackA "Tecumseh"][BlackAElo "2159"][WhiteB "Marat"][WhiteBElo "2189"][BlackB "LINDEGREN"][BlackBElo "2364"][TimeControl "180+0"][Result "1-0"]1A. e4 {179} 1B. e4 {178} 1a. Nc6 {180} 2A. Nc3 {179} 1b. Nf6 {180}2a. Nf6 {180} 3A. Nf3 {178} 2B. Nc3 {177} 2b. Nc6 {180} 3a. e6 {179}4A. e5 {177} 3B. Nf3 {175} 4a. Nd5 {178} 3b. e6 {179} 5A. d4 {177} 5a. d6 {177}4B. d4 {171} 6A. Bb5 {175} 4b. d5 {179} 5B. Bg5 {170} 6a. Nxc3 {176}7A. bxc3 {174} 5b. Be7 {177} 7a. Bd7 {176} 6B. Bxf6 {169} 8A. O-O {172}6b. Bxf6 {177} 8a. Nxe5 {174} 7B. Bb5 {166} 7b. N@f4 {174} 9A. Bxd7+ {168}8B. Rg1 {165} 9a. Nxd7 {173} 10A. Re1 {168} 10a. Be7 {172} 8b. B@h5 {171}11A. d5 {167} 9B. B@e3 {163} 11a. O-O {170} 12A. B@h6 {163} 12a. gxh6 {168}13A. Bxh6 {161} 13a. N@f5 {168} 9b. Nxg2+ {161} 10B. Rxg2 {161} 10b. Bxf3 {159}14A. P@g5 {157} 11B. Qxf3 {160} 14a. N@g4 {164} 15A. dxe6 {153} 11b. P@b4 {153}12B. exd5 {158} 15a. Ngxh6 {160} 16A. gxh6 {152} 16a. Nxh6 {160}12b. N@h4 {148} 17A. N@h5 {150} 17a. P@g7 {157} 13B. Qg3 {154} 18A. Nxg7 {148}13b. Nxg2+ {146} 14B. Qxg2 {151} 14b. bxc3 {143} 15B. dxc6 {151}15b. P@d2+ {140} 16B. Kf1 {149} 16b. bxc6 {136} 17B. Bxc6+ {149}17b. P@d7 {134} 18B. P@e5 {146} 18a. N@f4 {111} 19A. R@g3 {146} 18b. dxc6 {108}19B. exf6 {145} 19b. Qxf6 {106} 20B. N@h5 {142} 19a. P@g4 {91} 20A. exf7+ {146}20b. P@e2+ {89} 21B. Kxe2 {139} 20a. Kh8 {67} 21A. Ne6 {144} 21a. Nxe6 {59}22A. Rxe6 {143} 22a. B@g7 {50} 23A. Rxe7 {143} 21b. B@f3+ {48} 22B. Qxf3 {138}22b. Qxf3+ {47} 23B. Kxf3 {138} 23a. Qxe7 {43} 24A. B@h4 {142} 24a. P@f6 {39}25A. Bxf6 {141} 23b. N@e1+ {39} 24B. Ke2 {137} 25a. Nxf6 {33} 24b. P@f3+ {32}26A. Ng5 {138} 25B. Kf1 {135} 26a. B@f5 {26} 27A. P@e6 {135} 25b. Ba6+ {13}26B. P@d3 {134} 26b. Bxd3+ {11} 27B. cxd3 {133} 27a. N@h5 {7} 28A. Rxg4 {134}27b. P@g2+ {3} 28B. Kg1 {133} 28a. Bxg4 {4} 28b. Ke7 {2} 29A. Qxg4 {133}29a. Nhxg4 {3} 29B. B@g5+ {130} 29b. B@f6 {1} 30B. Bxf6+ {130} 30A. N@g6+ {130}30b. gxf6 {0} 31B. Q@d7+ {129} 31b. Kxd7 {0} 30a. hxg6 {0} 31A. Q@g8+ {130}32B. N@e5+ {127} 31a. Nxg8 {0} 32A. Q@h7+ {130}{Tecumseh checkmated} 1-0';
bpgn8='[Event "fics rated bughouse match"][Site "fics, Oklahoma City, OK USA"][Date "2001.03.03"][WhiteA "LINDEGREN"][WhiteAElo "2370"][BlackA "Marat"][BlackAElo "2183"][WhiteB "Tecumseh"][WhiteBElo "2153"][BlackB "ChaseJr"][BlackBElo "2193"][TimeControl "180+0"][Result "1-0"]1B. e4 {179} 1b. d5 {180} 1A. e4 {178} 2B. exd5 {178} 1a. Nf6 {180}2b. e6 {179} 2A. Nc3 {178} 2a. d5 {179} 3B. Bb5+ {178} 3b. c6 {178}3A. exd5 {177} 4B. dxc6 {177} 3a. Nxd5 {178} 4b. bxc6 {178} 4A. d4 {176}5B. Be2 {176} 4a. Nc6 {178} 5A. Nf3 {175} 5b. Bc5 {176} 6B. P@e3 {176}5a. e6 {177} 6b. e5 {176} 6A. Bb5 {174} 7B. Nc3 {174} 6a. Bd7 {176}7A. Nxd5 {172} 7b. Nf6 {173} 7a. exd5 {175} 8A. Bxc6 {171} 8a. bxc6 {174}9A. Qe2+ {171} 9a. P@e4 {173} 8B. B@h4 {170} 10A. Ne5 {169} 8b. N@f5 {172}9B. Bxf6 {167} 9b. gxf6 {171} 10a. Qe7 {168} 10B. N@e4 {165} 10b. Be7 {169}11A. P@b7 {165} 11a. Rd8 {166} 11B. Nf3 {161} 12A. B@c8 {164} 11b. Rg8 {167}12B. Rg1 {158} 12b. N@h4 {166} 12a. P@d3 {158} 13B. Nxh4 {156} 13b. Nxh4 {165}13A. Bxd7+ {160} 14B. Bf3 {155} 14b. Nxf3+ {164} 13a. Rxd7 {155}15B. Qxf3 {154} 15b. B@g4 {163} 14A. b8=Q+ {159} 14a. N@d8 {154}15A. cxd3 {154} 15a. exd3 {154} 16A. Qxd3 {150} 16a. N@c5 {146} 17A. Qe2 {148}17a. N@d3+ {143} 16B. B@e2 {128} 18A. Kf1 {146} 18a. Nxe5 {141} 19A. dxe5 {145}19a. Ne4 {120} 20A. B@c8 {144} 20a. Qxe5 {92} 21A. Bxd7+ {143} 16b. Bxf3 {106}21a. Kxd7 {91} 17B. Bxf3 {126} 17b. N@h4 {106} 22A. Q@c8+ {136} 18B. B@e2 {119}22a. Ke7 {87} 18b. Nxf3+ {104} 19B. Bxf3 {118} 23A. Qxd8+ {134} 19b. P@g4 {103}23a. Ke6 {86} 20B. Be2 {117} 20b. N@b4 {100} 24A. B@g4+ {130} 21B. Bd1 {115}24a. B@f5 {83} 21b. P@d3 {99} 25A. Qbc8+ {129} 22B. N@a3 {109}{Marat resigns} 1-0';
bpgn9='[Event "fics rated bughouse match"][Site "fics, Oklahoma City, OK USA"][Date "2001.03.03"][WhiteA "Marat"][WhiteAElo "2177"][BlackA "LINDEGREN"][BlackAElo "2376"][WhiteB "ChaseJr"][WhiteBElo "2199"][BlackB "Tecumseh"][BlackBElo "2147"][TimeControl "180+0"][Result "1-0"]1B. e4 {179} 1A. e4 {178} 1b. Nc6 {180} 1a. Nf6 {180} 2B. Nc3 {179}2A. Nc3 {178} 2b. Nf6 {180} 2a. Nc6 {180} 3A. Nf3 {177} 3B. Nf3 {177}3a. d5 {179} 3b. e6 {179} 4A. exd5 {176} 4B. d4 {177} 4a. Nxd5 {179}4b. d5 {178} 5A. Nxd5 {175} 5B. exd5 {176} 5a. e6 {179} 5b. exd5 {178}6B. Bb5 {176} 6A. Nf4 {173} 6b. Bb4 {177} 7B. Ne5 {175} 6a. Bd6 {177}7A. d4 {172} 7b. P@h3 {174} 7a. P@g4 {174} 8B. Nxc6 {171} 8A. Ng5 {168}8b. bxc6 {172} 9B. Bxc6+ {171} 8a. Qxg5 {173} 9b. Bd7 {170} 10B. Bxd7+ {170}10b. Qxd7 {169} 9A. Nxe6 {164} 11B. N@e5 {170} 11b. hxg2 {168} 12B. Rg1 {169}12b. Qe7 {166} 9a. B@a5+ {166} 10A. B@c3 {158} 10a. Bxc3+ {162} 11A. bxc3 {157}11a. Qxc1 {159} 13B. B@b5+ {152} 12A. Rxc1 {156} 12a. Bxe6 {158} 13A. d5 {155}13b. P@d7 {162} 14B. N@f5 {151} 13a. O-O {152} 14A. dxe6 {153} 14a. Rae8 {149}14b. Q@e4+ {152} 15B. Ne3 {145} 15A. P@d5 {145} 15a. fxe6 {137} 15b. B@f1 {139}16B. B@f3 {143} 16A. P@d7 {139} 16a. exd5+ {135} 17A. dxe8=Q {138}17a. Rxe8+ {135} 16b. Bxb5 {125} 17B. Bxe4 {142} 18A. Be2 {129} 17b. Nxe4 {124}18a. P@f7 {128} 18B. Bd2 {136} 18b. Nxd2 {118} 19B. Qxd2 {129} 19A. N@h6+ {113}19a. gxh6 {126} 19b. N@f3+ {111} 20A. B@e3 {97} 20a. N@f4 {124} 21A. Bxf4 {93}21a. Bxf4 {124} 22A. B@e3 {78} 22a. Bxe3 {121} 23A. fxe3 {78} 20B. Kd1 {84}20b. Nxd2 {97} 21B. N@f5 {83} 21b. B@e2+ {68} 22B. Kxd2 {83} 22b. N@e4+ {64}23B. Kc1 {81} 23b. B@d2+ {47} 24B. Kb1 {78} 23a. Q@f6 {7} 24b. Bxe3 {6}24A. B@g3 {74} 25B. Nxg7+ {76} 25b. Kd8 {5} 24a. N@e4 {5} 26B. B@d2 {76}26b. Nxd2+ {4} 27B. Kc1 {75} 27b. Nb3+ {3} 25A. Rf1 {70} 28B. Kb1 {75}25a. P@f2+ {4} 28b. R@c1+ {3} 29B. Rxc1 {74} 26A. Bxf2 {68} 29b. Nd2+ {2}{ChaseJr checkmated} 1-0';
bpgn10='[Event "fics rated bughouse match"][Site "fics, Oklahoma City, OK USA"][Date "2001.03.03"][WhiteA "Tecumseh"][WhiteAElo "2158"][BlackA "ChaseJr"][BlackAElo "2188"][WhiteB "LINDEGREN"][WhiteBElo "2365"][BlackB "Marat"][BlackBElo "2188"][TimeControl "180+0"][Result "1-0"]1A. e4 {179} 1a. d5 {180} 1B. e4 {178} 2A. exd5 {178} 1b. Nf6 {178}2a. c6 {179} 2B. Nc3 {178} 2b. d5 {178} 3B. exd5 {178} 3b. Nxd5 {178}4B. d4 {178} 4b. Nc6 {176} 3A. P@e6 {172} 5B. Nf3 {177} 5b. Bg4 {175}6B. Bb5 {177} 3a. Qxd5 {177} 6b. e6 {175} 7B. h3 {176} 7b. Bxf3 {174}8B. Qe2 {176} 4A. N@c7+ {168} 8b. Bxe2 {171} 4a. Kd8 {173} 9B. Nxe2 {170}5A. Nxd5 {161} 9b. Bb4+ {167} 5a. cxd5 {169} 6A. exf7 {161} 10B. P@c3 {165}6a. Nf6 {167} 10b. P@e3 {165} 11B. Bxe3 {160} 11b. Nxe3 {164} 12B. fxe3 {159}7A. B@e5 {150} 12b. P@f2+ {160} 13B. Kxf2 {157} 13b. Qf6+ {154} 14B. N@f3 {155}14b. Bd6 {153} 7a. B@d6 {145} 8A. Bxf6 {148} 8a. Bd7 {138} 15B. Ke1 {132}15b. N@e4 {148} 16B. Rf1 {121} 16b. Qxf3 {146} 17B. Rxf3 {103} 9A. Bb5 {102}9a. Q@e6+ {136} 10A. Qe2 {100} 10a. P@e4 {108} 11A. Bxd7 {97} 17b. B@g3+ {102}11a. Nxd7 {100} 12A. Q@e8+ {94} 12a. Kc7 {99} 13A. Qxa8 {94} 18B. B@f2 {95}18b. Nxf2 {101} 13a. N@b8 {96} 19B. Nxg3 {91} 19b. Bxg3 {98} 14A. Qxa7 {88}14a. B@b6 {95} 15A. N@a8+ {86} 15a. Kc8 {93} 16A. Nxb6+ {82} 16a. Nxb6 {91}17A. Qxb6 {81} 17a. P@c7 {90} 20B. Rxg3 {75} 18A. N@a7+ {79} 20b. P@d2+ {96}18a. Kd8 {89} 21B. Ke2 {72} 21b. R@e1+ {93} 22B. Kxd2 {59} 22b. Rxa1 {91}19A. R@e8+ {57} 19a. Kd7 {85} 20A. B@c8+ {56}{ChaseJr checkmated} 1-0';
bpgn11='[Event "fics rated bughouse match"][Site "fics, Oklahoma City, OK USA"][Date "2001.03.03"][WhiteA "ChaseJr"][WhiteAElo "2178"][BlackA "LINDEGREN"][BlackAElo "2355"][WhiteB "Marat"][WhiteBElo "2198"][BlackB "Tecumseh"][BlackBElo "2168"][TimeControl "180+0"][Result "1-0"]1B. e4 {179} 1A. e4 {178} 1b. Nc6 {180} 1a. Nf6 {180} 2B. d4 {178}2A. Nc3 {178} 2b. Nf6 {180} 2a. Nc6 {180} 3B. Nc3 {177} 3A. d4 {177}3b. d5 {179} 3a. d5 {180} 4B. exd5 {176} 4b. Nxd5 {179} 4A. exd5 {176}5B. Nxd5 {176} 4a. Nxd5 {179} 5b. Qxd5 {178} 6B. Nf3 {176} 5A. Bb5 {175}6b. Bg4 {177} 5a. e6 {179} 7B. Be2 {174} 6A. Nf3 {173} 7b. P@e4 {176}6a. Bd7 {178} 8B. Ne5 {172} 7A. Bxc6 {172} 8b. Bxe2 {174} 7a. Bxc6 {178}8A. N@e5 {171} 8a. P@f6 {177} 9B. Qxe2 {169} 9A. Nxc6 {169} 9a. bxc6 {176}10A. B@b7 {168} 10a. B@d7 {174} 9b. B@f3 {167} 10B. gxf3 {163} 10b. Nxe5 {166}11A. Bxa8 {159} 11a. Qxa8 {173} 11B. B@h3 {157} 12A. N@a6 {156} 11b. exf3 {160}12a. B@b7 {161} 13A. Nxd5 {154} 12B. P@d7+ {148} 12b. Nxd7 {159}13B. Bxd7+ {147} 13b. Qxd7 {158} 13a. Bb4+ {134} 14B. Qxf3 {113}14b. R@f6 {156} 14A. P@c3 {140} 15B. N@f4 {109} 15b. Rxf4 {152} 16B. Bxf4 {108}14a. exd5 {125} 15A. Nxc7+ {138} 16b. N@h4 {149} 15a. Kf8 {122} 17B. Qe3 {105}16A. Nxa8 {137} 17b. N@g2+ {145} 16a. R@e8+ {119} 18B. Kd1 {104}18b. Nxe3+ {144} 19B. Bxe3 {104} 17A. N@e5 {132} 19b. Q@f3+ {139}17a. fxe5 {114} 18A. Nxe5 {131} 18a. N@h4 {107} 20B. Kd2 {91} 19A. B@f3 {127}19a. P@g4 {100} 20A. P@h6 {124} 20a. N@f5 {92} 21A. hxg7+ {123} 21a. Nxg7 {91}22A. P@f6 {123} 22a. N@f5 {89} 23A. fxg7+ {122} 23a. Nxg7 {88} 20b. N@e4+ {108}24A. Bh6 {121} 21B. Kd3 {86} 24a. Rg8 {75} 25A. cxb4 {117} 25a. gxf3 {72}21b. B@e2+ {90}{Marat checkmated} 1-0';
bpgn12='[Event "fics rated bughouse match"][Site "fics, Oklahoma City, OK USA"][Date "2001.03.03"][WhiteA "LINDEGREN"][WhiteAElo "2345"][BlackA "ChaseJr"][BlackAElo "2188"][WhiteB "Tecumseh"][WhiteBElo "2178"][BlackB "Marat"][BlackBElo "2188"][TimeControl "180+0"][Result "1-0"]1A. e4 {179} 1B. e4 {178} 1a. d5 {180} 1b. Nf6 {179} 2B. e5 {178} 2A. Nc3 {179}2a. e6 {179} 2b. Ne4 {178} 3B. Nc3 {177} 3A. exd5 {178} 3b. d5 {177}3a. Nf6 {179} 4B. Nxe4 {176} 4A. d4 {177} 4b. dxe4 {176} 4a. Nxd5 {179}5B. d4 {176} 5A. Nf3 {176} 5a. Bb4 {178} 6A. Bd2 {176} 5b. Nc6 {173}6a. Bxc3 {178} 7A. bxc3 {176} 7a. N@e4 {177} 6B. d5 {172} 8A. N@h5 {174}6b. Nxe5 {172} 8a. Rg8 {176} 9A. Bd3 {174} 7B. Bb5+ {169} 9a. Nexc3 {174}7b. P@c6 {170} 10A. Bxc3 {172} 10a. Nxc3 {174} 8B. dxc6 {167} 8b. Qxd1+ {169}11A. Bxh7 {169} 9B. Kxd1 {166} 9b. B@g4+ {164} 10B. B@e2 {163} 11a. Nxd1 {165}10b. bxc6 {162} 12A. Bxg8 {165} 12a. Qe7 {161} 11B. Bxc6+ {154}13A. Nxg7+ {162} 13a. Kd8 {160} 11b. Nxc6 {161} 12B. P@b7 {154} 14A. P@f6 {160}12b. R@f1+ {152} 13B. N@e1 {150} 14a. Q@b4+ {142} 15A. B@d2 {157}13b. Rxe1+ {132} 14B. Kxe1 {148} 14b. Rb8 {90} 15B. bxc8=Q+ {146}15b. Bxc8 {88} 15a. Nc3 {80} 16B. P@d5 {141} 16A. fxe7+ {155} 16a. Qxe7 {79}16b. Nd4 {86} 17B. P@c6 {138} 17b. Nxc2+ {85} 18B. Kd1 {138} 17A. P@e2 {145}18b. Q@e1+ {80} 19B. Kxc2 {137} 19b. N@d4+ {79} 17a. P@b2 {76} 20B. Kb1 {135}20b. P@c2+ {77}{Tecumseh checkmated} 1-0';
bpgn13='[Event "fics rated bughouse match"][Site "fics, Oklahoma City, OK USA"][Date "2001.03.03"][WhiteA "ChaseJr"][WhiteAElo "2182"][BlackA "LINDEGREN"][BlackAElo "2351"][WhiteB "Marat"][WhiteBElo "2194"][BlackB "Tecumseh"][BlackBElo "2172"][TimeControl "180+0"][Result "0-1"]1A. e4 {178} 1B. e4 {178} 1a. Nf6 {180} 1b. Nc6 {180} 2A. Nc3 {178}2B. Nf3 {176} 2a. Nc6 {180} 2b. Nf6 {180} 3B. Nc3 {176} 3A. d4 {176}3b. e6 {179} 3a. d5 {180} 4B. d4 {174} 4A. exd5 {175} 4b. d5 {179}4a. Nxd5 {179} 5A. Nf3 {175} 5B. Bg5 {173} 5a. e6 {179} 5b. dxe4 {177}6A. Bb5 {174} 6B. Bxf6 {172} 6a. Bb4 {179} 6b. gxf6 {176} 7B. Nxe4 {172}7A. Bd2 {173} 7a. Qe7 {178} 7b. P@g4 {174} 8A. Ne5 {171} 8a. Bd7 {177}9A. Bxc6 {170} 8B. Ne5 {168} 9a. Bxc6 {176} 10A. Nxc6 {169} 10a. bxc6 {175}11A. B@b7 {166} 11a. O-O {173} 12A. Bxc6 {165} 8b. Qxd4 {163} 12a. Bxc3 {171}9B. Nxf6+ {165} 13A. bxc3 {164} 9b. Kd8 {161} 13a. N@e4 {163} 14A. P@h6 {161}14a. f5 {160} 10B. Nxc6+ {143} 10b. bxc6 {161} 11B. Qxd4+ {143} 11b. B@d6 {159}12B. N@e5 {136} 15A. N@e5 {141} 12b. B@a5+ {157} 13B. B@c3 {134}13b. Bxc3+ {155} 15a. Nxf2 {154} 14B. bxc3 {132} 14b. N@g5 {155}15B. Nxc6+ {130}{Tecumseh checkmated} 0-1';
bpgn14='[Event "fics rated bughouse match"][Site "fics, Oklahoma City, OK USA"][Date "2001.03.03"][WhiteA "LINDEGREN"][WhiteAElo "2357"][BlackA "ChaseJr"][BlackAElo "2176"][WhiteB "Tecumseh"][WhiteBElo "2166"][BlackB "Marat"][BlackBElo "2200"][TimeControl "180+0"][Result "0-1"]1A. e4 {179} 1a. d5 {180} 1B. d4 {177} 1b. Nf6 {179} 2A. exd5 {177}2a. e6 {179} 2B. Nf3 {176} 3A. d4 {177} 2b. e6 {179} 3a. exd5 {179}3B. Nc3 {175} 4A. Nc3 {177} 3b. d5 {178} 4a. Nf6 {179} 4B. Ne5 {174}5A. Nf3 {176} 5a. Nc6 {178} 6A. Bb5 {176} 4b. Qe7 {175} 6a. Bb4 {177}7A. Qe2+ {176} 7a. Qe7 {176} 8A. Bxc6+ {175} 5B. Bg5 {172} 8a. bxc6 {175}5b. P@d6 {172} 9A. Qxe7+ {175} 9a. Bxe7 {174} 6B. e3 {170} 10A. Ne5 {173}10a. O-O {172} 6b. Nbd7 {167} 11A. Nxc6 {172} 11a. Re8 {171} 7B. P@c6 {164}7b. Nxe5 {164} 8B. dxe5 {163} 8b. bxc6 {163} 9B. exf6 {161} 9b. gxf6 {163}12A. Nxe7+ {157} 12a. Rxe7+ {170} 10B. Bxf6 {158} 13A. P@e5 {157}10b. Qxf6 {162} 11B. N@g4 {158} 13a. N@h4 {169} 14A. N@f4 {151} 11b. B@g7 {155}12B. Nxf6+ {153} 12b. Bxf6 {154} 14a. N@f3+ {161} 13B. B@d4 {149}15A. gxf3 {148} 15a. Nxf3+ {161} 16A. Kd1 {148} 13b. N@e5 {152} 14B. Bxe5 {148}14b. dxe5 {151} 15B. P@b5 {146} 15b. Bb4 {149} 16B. bxc6 {144} 16b. Bxc3+ {146}17B. bxc3 {144} 16a. Bf5 {146} 17b. N@c5 {142} 18B. Be2 {133} 17A. P@h6 {134}18b. e4 {140} 17a. Bxc2+ {144} 19B. Bh5 {131} 19b. Bxc3+ {137} 20B. Kf1 {129}20b. P@g6 {130} 21B. P@d7+ {125} 21b. Nxd7 {126} 22B. cxd7+ {124}22b. Bxd7 {125} 18A. Kxc2 {107} 18a. P@b3+ {140} 23B. Q@b7 {116} 23b. O-O {118}24B. Qxc7 {114} 24b. B@b5+ {114} 25B. Be2 {113} 25b. Bxa1 {110} 19A. Kxb3 {84}19a. Nxd4+ {138} 26B. Qxd7 {106} 20A. Ka3 {80} 26b. Bxd7 {108} 27B. Qxa1 {105}20a. N@c4+ {135} 21A. Kb4 {79} 27b. Bb5 {104} 21a. Q@a5+ {132}{LINDEGREN checkmated} 0-1';
bpgn15='[Event "fics rated bughouse match"][Site "fics, Oklahoma City, OK USA"][Date "2001.03.03"][WhiteA "ChaseJr"][WhiteAElo "2186"][BlackA "LINDEGREN"][BlackAElo "2347"][WhiteB "Marat"][WhiteBElo "2190"][BlackB "Tecumseh"][BlackBElo "2176"][TimeControl "180+0"][Result "1-0"]1A. e4 {178} 1B. e4 {177} 1a. Nf6 {180} 2A. Nc3 {177} 2a. Nc6 {180}3A. d4 {177} 3a. d5 {179} 1b. Nc6 {175} 4A. exd5 {176} 2B. Nf3 {176}4a. Nxd5 {179} 5A. Bc4 {176} 2b. Nf6 {173} 5a. e6 {178} 3B. Nc3 {174}6A. Nf3 {175} 6a. Bb4 {178} 3b. e6 {171} 7A. Bd2 {173} 7a. Qe7 {177}4B. d4 {172} 4b. d5 {170} 8A. O-O {171} 8a. Bxc3 {177} 5B. Bg5 {171}9A. bxc3 {170} 5b. dxe4 {169} 6B. Bxf6 {170} 9a. f5 {176} 6b. gxf6 {168}7B. Nxe4 {170} 10A. Re1 {169} 7b. B@a5+ {167} 10a. P@e4 {174} 8B. P@c3 {168}11A. B@h4 {167} 8b. P@g7 {164} 9B. Bb5 {165} 11a. N@f6 {171} 9b. Bd7 {163}12A. Ne5 {165} 12a. Nxe5 {168} 13A. dxe5 {164} 10B. N@c5 {158} 13a. Rg8 {167}14A. Bxd5 {161} 14a. exd5 {166} 10b. f5 {157} 11B. Nxd7 {157} 15A. Bf4 {157}11b. fxe4 {154} 15a. B@g4 {163} 12B. Bxc6 {155} 12b. bxc6 {152} 13B. Nfe5 {154}16A. exf6 {152} 16a. gxf6 {162} 17A. Qxd5 {150} 13b. N@f4 {145} 14B. Rg1 {153}14b. P@e2 {142} 15B. Qd2 {151} 17a. Be6 {147} 15b. N@f3+ {130} 16B. gxf3 {148}18A. B@b5+ {140} 18a. Kf8 {129} 19A. Bh6+ {134} 16b. N@g2+ {93} 17B. Rxg2 {147}17b. Nxg2+ {92} 18B. Kxe2 {146} 18b. exf3+ {91} 19B. Kd1 {142} 19b. Ba3 {84}20B. B@g5 {137} 19a. P@g7 {83} 20b. Be7 {70} 21B. Bxe7 {134} 21b. Qxe7 {69}22B. N@f6+ {127} 20A. Bxg7+ {121} 22b. gxf6 {67} 20a. Rxg7 {80} 23B. P@g7 {125}21A. R@h8+ {121} 21a. N@g8 {78} 23b. Rg8 {64} 24B. B@f8 {124} 22A. N@d7+ {119}24b. P@e2+ {60} 25B. Kc1 {123} 22a. Bxd7 {71} 23A. Qxg8+ {117} 25b. Bxc3 {23}26B. Qxc3 {121} 26b. e1=Q+ {19} 27B. Qxe1 {120} 27b. Nxe1 {18} 28B. Bxe7 {119}28b. N@e2+ {15} 29B. Kd2 {118} 29b. Kxe7 {14} 30B. Nxc6+ {113} 23a. Rxg8 {18}24A. B@h6+ {116} 30b. Kxd7 {14} 31B. N@e5+ {110} 24a. P@g7 {15}25A. Rxg8+ {116} 31b. fxe5 {13} 32B. Nxe5+ {109} 32b. Kc8 {12} 25a. Kxg8 {14}26A. Q@g3 {115} 26a. N@f3+ {10} 27A. gxf3 {113} 33B. Q@d7+ {100} 27a. N@h3+ {8}33b. Kb7 {12} 28A. Kh1 {111} 28a. P@g2+ {8} 34B. R@b5+ {96} 34b. R@b6 {10}29A. Qxg2 {108} 35B. Qc6+ {94} 29a. Bxf3 {7} 30A. B@b3+ {107} 35b. Kc8 {9}36B. P@b7+ {93} 30a. P@e6 {6} 31A. Bxe6+ {105} 36b. Rxb7 {5} 31a. Bxe6 {4}32A. P@f7+ {104} 37B. Qxb7+ {91} 32a. Qxf7 {3} 33A. N@f4 {104} 37b. Kd8 {4}38B. Qxa8+ {90} 38b. Ke7 {3} 33a. Bxg2+ {1} 34A. Nxg2 {104} 39B. Qxg8 {89}34a. B@f3 {1} 35A. N@e7+ {103} 39b. N@c4+ {2} 35a. Qxe7 {1} 36A. N@f4 {103}40B. Nxc4 {87} 36a. Qf7 {1} 40b. P@e3+ {2} 41B. fxe3 {86} 41b. B@c3+ {1}37A. Bxf6 {100} 37a. Bxg2+ {1} 42B. bxc3 {84} 38A. Nxg2 {100}{LINDEGREN forfeits on time} 1-0';
// --></script><table cellpadding="0" bgcolor="333333" border="0"><form name="v1"></form><tbody><tr><td><table cellpadding="2" bgcolor="333333" border="0"><tbody><tr><td width="352"><table cellpadding="0" border="0" width="100%"><tbody><tr> <td align="center" valign="bottom"> <input size="25" name="upa" onfocus="this.blur();" type="text"> </td> <td align="right" valign="bottom"><img src="gif/mv.gif" name="v1upmva" height="20" width="24"> <input size="5" name="upclocka" onfocus="this.blur();" type="text"> </td> </tr> </tbody></table><center><table border="1"> <tbody><tr> <td rowspan="2"><table cols="8" cellpadding="0" cellspacing="0" border="0"><tbody><tr><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(0,'v1','a');"><img src="gif/wrd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(1,'v1','a');"><img src="gif/wnd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(2,'v1','a');"><img src="gif/wbd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(3,'v1','a');"><img src="gif/wkd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(4,'v1','a');"><img src="gif/wqd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(5,'v1','a');"><img src="gif/wbd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(6,'v1','a');"><img src="gif/wnd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(7,'v1','a');"><img src="gif/wrd.gif" border="0" height="32" width="32"></a></td></tr><tr><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(8,'v1','a');"><img src="gif/wpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(9,'v1','a');"><img src="gif/wpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(10,'v1','a');"><img src="gif/wpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(11,'v1','a');"><img src="gif/wpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(12,'v1','a');"><img src="gif/wpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(13,'v1','a');"><img src="gif/wpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(14,'v1','a');"><img src="gif/wpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(15,'v1','a');"><img src="gif/wpd.gif" border="0" height="32" width="32"></a></td></tr><tr><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(16,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(17,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(18,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(19,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(20,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(21,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(22,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(23,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td></tr><tr><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(24,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(25,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(26,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(27,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(28,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(29,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(30,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(31,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td></tr><tr><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(32,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(33,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(34,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(35,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(36,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(37,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(38,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(39,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td></tr><tr><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(40,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(41,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(42,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(43,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(44,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(45,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(46,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(47,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td></tr><tr><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(48,'v1','a');"><img src="gif/bpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(49,'v1','a');"><img src="gif/bpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(50,'v1','a');"><img src="gif/bpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(51,'v1','a');"><img src="gif/bpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(52,'v1','a');"><img src="gif/bpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(53,'v1','a');"><img src="gif/bpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(54,'v1','a');"><img src="gif/bpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(55,'v1','a');"><img src="gif/bpd.gif" border="0" height="32" width="32"></a></td></tr><tr><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(56,'v1','a');"><img src="gif/brd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(57,'v1','a');"><img src="gif/bnd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(58,'v1','a');"><img src="gif/bbd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(59,'v1','a');"><img src="gif/bkd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(60,'v1','a');"><img src="gif/bqd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(61,'v1','a');"><img src="gif/bbd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(62,'v1','a');"><img src="gif/bnd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(63,'v1','a');"><img src="gif/brd.gif" border="0" height="32" width="32"></a></td></tr></tbody></table></td> <td rowspan="2" nowrap=""><a href="javascript:void(0)" onclick="assclick(64,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a><input size="1" name="ha0" value=" " onfocus="this.blur();" type="text"><a href="javascript:void(0)" onclick="assclick(65,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a><input size="1" name="ha1" value=" " onfocus="this.blur();" type="text"><br><a href="javascript:void(0)" onclick="assclick(66,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a><input size="1" name="ha2" value=" " onfocus="this.blur();" type="text"><a href="javascript:void(0)" onclick="assclick(67,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a><input size="1" name="ha3" value=" " onfocus="this.blur();" type="text"><br><a href="javascript:void(0)" onclick="assclick(68,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a><input size="1" name="ha4" value=" " onfocus="this.blur();" type="text"><a href="javascript:void(0)" onclick="assclick(69,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a><input size="1" name="ha5" value=" " onfocus="this.blur();" type="text"><br><a href="javascript:void(0)" onclick="assclick(70,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a><input size="1" name="ha6" value=" " onfocus="this.blur();" type="text"><a href="javascript:void(0)" onclick="assclick(71,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a><input size="1" name="ha7" value=" " onfocus="this.blur();" type="text"><br><a href="javascript:void(0)" onclick="assclick(72,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a><input size="1" name="ha8" value=" " onfocus="this.blur();" type="text"><a href="javascript:void(0)" onclick="assclick(73,'v1','a');"><img src="gif/d.gif" border="0" height="32" width="32"></a><input size="1" name="ha9" value=" " onfocus="this.blur();" type="text"><br></td> </tr> </tbody></table> </center> <table cellpadding="0" border="0" width="100%"><tbody><tr> <td align="center" valign="top"><input size="7" name="lastmovea" value=" " onchange="assexecmove(this.value,'a','v1')" type="text"> <input size="18" name="dna" onfocus="assexecmove(document.v1.lastmovea.value,'a','v1'); this.blur();" type="text"> </td> <td align="right" valign="top"><img src="gif/d.gif" name="v1dnmva" height="20" width="24"> <input size="5" name="dnclocka" onfocus="this.blur();" type="text"> </td> </tr> </tbody></table></td><td width="352"><table cellpadding="0" border="0" width="100%"><tbody><tr> <td align="center" valign="bottom"> <input size="25" name="upb" onfocus="this.blur();" type="text"> </td> <td align="right" valign="bottom"><img src="gif/d.gif" name="v1upmvb" height="20" width="24"> <input size="5" name="upclockb" onfocus="this.blur();" type="text"> </td> </tr> </tbody></table><center><table border="1"> <tbody><tr> <td rowspan="2"><table cols="8" cellpadding="0" cellspacing="0" border="0"><tbody><tr><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(0,'v1','b');"><img src="gif/brd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(1,'v1','b');"><img src="gif/bnd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(2,'v1','b');"><img src="gif/bbd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(3,'v1','b');"><img src="gif/bqd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(4,'v1','b');"><img src="gif/bkd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(5,'v1','b');"><img src="gif/bbd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(6,'v1','b');"><img src="gif/bnd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(7,'v1','b');"><img src="gif/brd.gif" border="0" height="32" width="32"></a></td></tr><tr><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(8,'v1','b');"><img src="gif/bpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(9,'v1','b');"><img src="gif/bpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(10,'v1','b');"><img src="gif/bpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(11,'v1','b');"><img src="gif/bpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(12,'v1','b');"><img src="gif/bpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(13,'v1','b');"><img src="gif/bpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(14,'v1','b');"><img src="gif/bpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(15,'v1','b');"><img src="gif/bpd.gif" border="0" height="32" width="32"></a></td></tr><tr><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(16,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(17,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(18,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(19,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(20,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(21,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(22,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(23,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td></tr><tr><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(24,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(25,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(26,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(27,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(28,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(29,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(30,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(31,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td></tr><tr><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(32,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(33,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(34,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(35,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(36,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(37,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(38,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(39,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td></tr><tr><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(40,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(41,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(42,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(43,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(44,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(45,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(46,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(47,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a></td></tr><tr><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(48,'v1','b');"><img src="gif/wpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(49,'v1','b');"><img src="gif/wpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(50,'v1','b');"><img src="gif/wpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(51,'v1','b');"><img src="gif/wpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(52,'v1','b');"><img src="gif/wpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(53,'v1','b');"><img src="gif/wpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(54,'v1','b');"><img src="gif/wpd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(55,'v1','b');"><img src="gif/wpd.gif" border="0" height="32" width="32"></a></td></tr><tr><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(56,'v1','b');"><img src="gif/wrd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(57,'v1','b');"><img src="gif/wnd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(58,'v1','b');"><img src="gif/wbd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(59,'v1','b');"><img src="gif/wqd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(60,'v1','b');"><img src="gif/wkd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(61,'v1','b');"><img src="gif/wbd.gif" border="0" height="32" width="32"></a></td><td bgcolor="946651"><a href="javascript:void(0)" onclick="assclick(62,'v1','b');"><img src="gif/wnd.gif" border="0" height="32" width="32"></a></td><td bgcolor="CC9966"><a href="javascript:void(0)" onclick="assclick(63,'v1','b');"><img src="gif/wrd.gif" border="0" height="32" width="32"></a></td></tr></tbody></table></td> <td rowspan="2" nowrap=""><a href="javascript:void(0)" onclick="assclick(64,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a><input size="1" name="hb0" value=" " onfocus="this.blur();" type="text"><a href="javascript:void(0)" onclick="assclick(65,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a><input size="1" name="hb1" value=" " onfocus="this.blur();" type="text"><br><a href="javascript:void(0)" onclick="assclick(66,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a><input size="1" name="hb2" value=" " onfocus="this.blur();" type="text"><a href="javascript:void(0)" onclick="assclick(67,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a><input size="1" name="hb3" value=" " onfocus="this.blur();" type="text"><br><a href="javascript:void(0)" onclick="assclick(68,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a><input size="1" name="hb4" value=" " onfocus="this.blur();" type="text"><a href="javascript:void(0)" onclick="assclick(69,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a><input size="1" name="hb5" value=" " onfocus="this.blur();" type="text"><br><a href="javascript:void(0)" onclick="assclick(70,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a><input size="1" name="hb6" value=" " onfocus="this.blur();" type="text"><a href="javascript:void(0)" onclick="assclick(71,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a><input size="1" name="hb7" value=" " onfocus="this.blur();" type="text"><br><a href="javascript:void(0)" onclick="assclick(72,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a><input size="1" name="hb8" value=" " onfocus="this.blur();" type="text"><a href="javascript:void(0)" onclick="assclick(73,'v1','b');"><img src="gif/d.gif" border="0" height="32" width="32"></a><input size="1" name="hb9" value=" " onfocus="this.blur();" type="text"><br></td> </tr> </tbody></table> </center> <table cellpadding="0" border="0" width="100%"><tbody><tr> <td align="center" valign="top"><input size="7" name="lastmoveb" value=" " onchange="assexecmove(this.value,'b','v1')" type="text"> <input size="18" name="dnb" onfocus="assexecmove(document.v1.lastmoveb.value,'b','v1'); this.blur();" type="text"> </td> <td align="right" valign="top"><img src="gif/mv.gif" name="v1dnmvb" height="20" width="24"> <input size="5" name="dnclockb" onfocus="this.blur();" type="text"> </td> </tr> </tbody></table></td></tr></tbody></table></td></tr><tr><td><center><table cellpadding="0" cellspacing="0" bgcolor="333333" border="0" width="704"><tbody><tr><td align="center" valign="top"><input value=" <<" onclick="assundomove(5,'a','v1')" type="button"><input value=" < " onclick="assundomove(1,'a','v1')" type="button"><input value=" > " onclick="assforward(1,'a','v1',0)" type="button"><input value=">> " onclick="assforward(5,'a','v1',0)" type="button"></td><td align="center" valign="bottom"><input value=" |< " onclick="assundomove(999,'c','v1')" type="button"><input value=" < " onclick="assundomove(1,'c','v1')" type="button"><input name="play" value="Play" onclick="assplay('v1')" type="button"><input value=" > " onclick="assforward(1,'c','v1',0)" type="button"><input value=" >| " onclick="assforward(999,'c','v1',0)" type="button"></td><td align="center" valign="bottom"><input value=" X " onclick="assdelete('v1')" type="button"><input name="bugzh" value="B=>Z" onclick="bugorzh('v1')" type="button"><input value="Flip" onclick="flipboard('v1')" type="button"><input value="Save" onclick="asssave('v1')" type="button"><input value="Load" onclick="assloadgame('v1')" type="button"></td><td align="center" valign="top"><input value=" <<" onclick="assundomove(5,'b','v1')" type="button"><input value=" < " onclick="assundomove(1,'b','v1')" type="button"><input value=" > " onclick="assforward(1,'b','v1',0)" type="button"><input value=">> " onclick="assforward(5,'b','v1',0)" type="button"></td></tr></tbody></table></center></td></tr><tr><td><center><table cellpadding="0" cellspacing="0" bgcolor="333333" border="0"><tbody><tr><td align="center" valign="top"><strong>Next</strong></td><td align="center" valign="top"><strong>Comment</strong></td></tr><tr><td valign="top"><select name="nextmove" size="3" onchange="assforward(1,'c','v1',document.v1.nextmove.selectedIndex);"><option> </option><option> </option><option> </option><option> </option><option> </option><option> </option><option> </option><option> </option><option> </option><option> </option><option> </option><option> </option><option> </option><option> </option><option> </option><option> </option><option> </option><option> </option><option> </option><option> </option><option>XXXXXXXXXXX</option></select></td><td valign="top"><textarea name="comment" wrap="SOFT" value="" rows="3" cols="60"></textarea></td></tr></tbody></table></center></td></tr> </tbody></table>





<!-- InstanceEndEditable -->




The last part of my post got cut off. I included the source that I modified with the tags on the discourse page: http://wpquestions.com/user/discourseShow/id/52029/discourse_id/1050

Answers (1)

2014-07-02

Navjot Singh answers:

You need to include the http://bughouse.net/training_center/master_games/games_viewable_online/bug.js file too.


Navjot Singh comments:

Add this code to your theme's function.php after copying bug.js file to your wordpress theme's folder

wp_enqueue_script( 'bug', get_template_directory_uri() . '/js/bug.js', array(), '1.0.0' );


ambt comments:

Thank you for the reply. I am proceeding to try out your solution. Where (which line) do I insert the above code you suggested?


<?php

/*-----------------------------------------------------------------------------------

Caution: The Sky may fall if you edit this file. Please proceed with caution. :)

-------------------------
Notes for Developers:
-------------------------
In this File:
- WP_DEBUG + PHP Error Reporting
- Load Translation Text Domain
- TrueThemes Framework init
- JetPack + TrueThemes SEO Module + "Activate Karma 4.0"
- Cleanup <head>
- WP add_theme_support
- WP add_editor_style
- WP remove_filter + add_filter
- <!--more--> disable scroll
- WP Theme Customizer
- WooCommerce
- Register Sidebars
- Register WP3.0+ Menus
- Register Custom Taxonomies
- Register Custom Post Types
- Admin CSS additions
- Miscellaneous Settings
- IE9+ YouTube Video Fix
- Sticky Menu

Elsewhere in Theme:
- Action Hooks /framework/hooks.php
- Additional Theme Functions /framework/theme-functions.php
- JavaScript and CSS Enqueue /framework/script-enqueue.php
- Metaboxes /framework/custom-metaboxes.php
- Mobile Stylesheet /css/_mobile.css
- Shortcodes /framework/shortcodes.php
- Site Options Panel /framework/site-options.php
- Site Options Panel CSS Output /framework/site-options-functions.php
- Widgets /framework/widgets.php
- WooCommerce Overriding /framework/extended/woocommerce.php

-------------------------------------------------------------------------------------*/


/*-----------------------------------------------------------------------------------*/
/* WP_DEBUG + PHP Error Reporting
/*-----------------------------------------------------------------------------------*/

//Some plugins such as wpcu3er will disable PHP error reporting,
//therefore we must make sure it is turn on if WP_DEBUG is set to true.
if(defined('WP_DEBUG') == 1 || WP_DEBUG == true){
$error_setting = ini_get("display_errors");
if($error_setting == '0'){
ini_set('display_errors', '1');
}
}

//if PHP error reporting is enabled we will only ALLOW PHP fatal error, syntax error, parse errors etc to show only.
$php_error_setting = ini_get("display_errors");
if($php_error_setting == '1'){
//reference to http://www.php.net/manual/en/errorfunc.constants.php
error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE & ~E_WARNING & ~ E_DEPRECATED & ~ E_USER_NOTICE);
}

/*-----------------------------------------------------------------------------------*/
/* Load Translation Text Domain
/*-----------------------------------------------------------------------------------*/
load_theme_textdomain ('truethemes_localize', get_template_directory() . '/languages');

/*-----------------------------------------------------------------------------------*/
/* TrueThemes Framework init
/*-----------------------------------------------------------------------------------*/
// Define File Directories
define('TRUETHEMES_GLOBAL', get_template_directory() . '/framework');
define('TRUETHEMES_FRAMEWORK', get_template_directory_uri() . '/framework');
define('TRUETHEMES_ADMIN', get_template_directory() . '/framework/admin');
define('TRUETHEMES_EXTENDED', get_template_directory() . '/framework/extended');
define('TRUETHEMES', get_template_directory() . '/framework/truethemes');
define('TRUETHEMES_JS', get_template_directory_uri() . '/js');
define('TRUETHEMES_CSS', get_template_directory_uri() . '/css/');
define('TIMTHUMB_SCRIPT', get_template_directory_uri() . '/framework/extended/timthumb/timthumb.php');
define('TIMTHUMB_SCRIPT_MULTISITE', get_template_directory_uri() . '/framework/extended/timthumb/timthumb.php');
define('TRUETHEMES_HOME', get_template_directory_uri());

// Used in Site Options
$admin_url = admin_url();

// Load Theme-Specific Functions
require_once(TRUETHEMES_GLOBAL . '/script-enqueue.php');
require_once(TRUETHEMES_GLOBAL . '/site-options.php');
require_once(TRUETHEMES_GLOBAL . '/site-options-functions.php'); //formerly named "admin-functions.php"
require_once(TRUETHEMES_GLOBAL . '/custom-metaboxes.php');

// Load Global Elements
require_once(TRUETHEMES_GLOBAL . '/shortcodes.php');
require_once(TRUETHEMES_GLOBAL . '/shortcodes-old.php');
require_once(TRUETHEMES_GLOBAL . '/widgets.php');
require_once(TRUETHEMES_GLOBAL . '/theme-functions.php');
require_once(TRUETHEMES_GLOBAL . '/nav-output.php');
require_once(TRUETHEMES_GLOBAL . '/hooks.php');

// Load TrueThemes Functions
require_once(TRUETHEMES . '/wysiwyg/wysiwyg.php');
require_once(TRUETHEMES . '/image-thumbs.php');
require_once(TRUETHEMES . '/metabox/init.php');

// Load Site Options Admin
require_once(TRUETHEMES_ADMIN . '/admin-functions.php');
require_once(TRUETHEMES_ADMIN . '/admin-interface.php');

// Load Extended Functionality
require_once(TRUETHEMES_EXTENDED . '/tgm-plugin-activation/class-tgm-plugin-activation.php');
require_once(TRUETHEMES_EXTENDED . '/pricing-tables/pricing.php');
require_once(TRUETHEMES_EXTENDED . '/multiple_sidebars.php');
require_once(TRUETHEMES_EXTENDED . '/breadcrumbs.php');
require_once(TRUETHEMES_EXTENDED . '/3d-tag-cloud/wp-cumulus.php');
require_once(TRUETHEMES_EXTENDED . '/latest-tweets.php');
require_once(TRUETHEMES_EXTENDED . '/page_linking.php');
if(!function_exists('wp_pagenavi')){require_once(TRUETHEMES_EXTENDED . '/wp-pagenavi.php');}


//TrueThemes Framework Global Variable
if(!isset($ttso)){
$truethemes_site_option = new truethemes_site_option();
$ttso = $truethemes_site_option->set_all(); // <-- very important
}


/*----------------------------------------------------------------*/
/* JetPack
/*----------------------------------------------------------------*/
if(class_exists('Jetpack')){

//get jetpack activated modules.
$jetpack_activated_modules = get_option('jetpack_active_modules');
//check if jetpack contact form is deactivated, we load our theme contact form.
if(!in_array('contact-form',$jetpack_activated_modules)){

//check if publicize and share module is activated, if yes, we disable it too, so that our contact form shortcode works!
$arr = array_diff($jetpack_activated_modules, array("publicize","sharedaddy"));

//We update back modified jetpack activated modules.
update_option('jetpack_active_modules',$arr);

//check if user enables our theme contact form plugin, if yes, we use it.
$ka_formbuilder = get_option('ka_formbuilder');

//checks for grunion contact form plugin
if(!function_exists('contact_form_parse')){
if ($ka_formbuilder == "true"){require_once(TRUETHEMES_EXTENDED . '/grunion-contact-form/grunion-contact-form.php');}
}
}

} else {
//no Jetpack, we do normal check

//if user enables TrueThemes contact form plugin then display it
$ka_formbuilder = get_option('ka_formbuilder');

//checks for grunion contact form plugin
if(!function_exists('contact_form_parse')){
if ($ka_formbuilder == "true"){require_once(TRUETHEMES_EXTENDED . '/grunion-contact-form/grunion-contact-form.php');}
}

}


/*----------------------------------------------------------------*/
/* TrueThemes SEO Module
/*----------------------------------------------------------------*/
global $ttso;
$seo_module = '';
$seo_module = $ttso->ka_seo_module;

//check user setting at site options general settings.
if ($seo_module == "true"){
//require all seo module files and "activate" seo module.
require_once(TRUETHEMES_EXTENDED. '/seo-module/seo_module.php');
$aioseop_options = get_option('aioseop_options');
if($aioseop_options['aiosp_enabled']==0){
$aioseop_options['aiosp_enabled'] = 1;
update_option('aioseop_options',$aioseop_options);
}
} else {
//user has "disable" seo module,
//we do not include seo module files, but just show an empty seo settings page,
//so that user do not encounter WordPress "permissions" error,
//and the seo settings page is always there.
$aioseop_options = get_option('aioseop_options');
$aioseop_options['aiosp_enabled'] = 0;
update_option('aioseop_options',$aioseop_options);
add_action('admin_menu','truethemes_add_empty_seo_settings_page');
}

/**
* Do not move this function!
* Load empty SEO Setting Page!
* this gets load when user disables SEO Module! so that there is no WordPress Permission error when user clicks on "SEO Settings" menu!
* @since version 2.6
**/
function truethemes_add_empty_seo_settings_page(){
add_theme_page('SEO settings','SEO settings','manage_options','seo_settings','truethemes_empty_seo_settings_page');
}

/**
* Do not move this function!
* Empty SEO settings page!
* for use in function truethemes_add_empty_seo_settings_page()
* @since version 2.6
**/
function truethemes_empty_seo_settings_page(){
?>
<div class="wrap">
<div style='padding:8px 10px 15px 15px'>
<div id="icon-options-general" class="icon32"></div>
<h2><?php _e('SEO Settings', 'truethemes_localize') ?></h2>
</div>
<?php
$aioseop_options = get_option('aioseop_options');
if($aioseop_options['aiosp_enabled'] == 0){
echo "<div id=\"message\" class=\"updated fade\"style='width:765px!important;margin:10px 0px 0px 0px;'><p>The SEO Module is currently disabled. To enable this Module, please go to <a href='".admin_url('admin.php?page=siteoptions')."'>Appearance &gt; Site Options &gt; General Settings</a>.</p></div>";
}

}



/*----------------------------------------------------------------*/
/* "Activate Karma 4.0" (General > Site Options)
/*----------------------------------------------------------------*/
/**
* @since 4.0
* Hides old page templates from Page Attributes metabox when Karma 4.0 is "Activated"
* Hides old "Custom Settings" metabox from Post Editing screen
*/
function tt_remove_page_template_name_from_select_dropdown(){
//do this only in WordPress admin
if(is_admin()):
//check which admin page we are in now.
//do this only if typenow variable is page.

global $typenow;
global $pagenow;
if( ($typenow == 'page') || ($pagenow == 'edit.php') ){
$option = get_option('ka_activate_karma4');
if($option == 'true'):
//we enqueue jquery script.
wp_register_script( 'remove_page_template_select_option', TRUETHEMES_JS .'/admin-remove-page-template-select-option.js', array('jquery'),'1.0');
wp_enqueue_script( 'remove_page_template_select_option');
endif;
}

//do this only if typenow variable is post.
if( $typenow == 'post'){
$option = get_option('ka_activate_karma4');
if($option == 'true'):
//we enqueue jquery script.
wp_register_script( 'hide_post_meta_box', TRUETHEMES_JS .'/admin-hide-post-meta-box.js', array('jquery'),'1.0');
wp_enqueue_script( 'hide_post_meta_box');
endif;
}

endif;
}
add_action( 'admin_enqueue_scripts', 'tt_remove_page_template_name_from_select_dropdown' );



/*-----------------------------------------------------------------------------------*/
/* Register WP3.0+ Menus
/*-----------------------------------------------------------------------------------*/
register_nav_menu('Primary Navigation', 'Main Menu');
register_nav_menu('Footer Navigation', 'Footer Menu');
register_nav_menu('Top Toolbar Navigation', 'Top Toolbar Menu');
//add nav_menu if UberMenu installed...
global $ttso;
$ubermenu = $ttso->ka_ubermenu;
if('true' == $ubermenu):
register_nav_menu('UberMenu', 'UberMenu');
endif;


/*-----------------------------------------------------------------------------------*/
/* Cleanup <head>
/*-----------------------------------------------------------------------------------*/
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'feed_links_extra');
remove_action('wp_head', 'feed_links');
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);


/*-----------------------------------------------------------------------------------*/
/* WP add_theme_support
/*-----------------------------------------------------------------------------------*/
add_theme_support('nav-menus');
add_theme_support('post-thumbnails');
add_theme_support('automatic-feed-links');


/*-----------------------------------------------------------------------------------*/
/* WP add_editor_style
/*-----------------------------------------------------------------------------------*/
add_editor_style('custom-editor-style.css');
if (!isset($content_width)) $content_width = 960;


/*-----------------------------------------------------------------------------------*/
/* WP remove_filter + add_filter
/*-----------------------------------------------------------------------------------*/
/* functon does not alter Wordpress' default wpautop */
function truethemes_formatter($content) {
$new_content = '';
$pattern_full = '{(\[raw\].*?\[/raw\])}is';
$pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
$pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);

foreach ($pieces as $piece) {
if (preg_match($pattern_contents, $piece, $matches)) {
$new_content .= $matches[1];
} else {
//@since 4.0.3 - search for rev_slider in content, if found, do not wpautop
if(stripos($piece,"rev_slider") !== false){
$new_content .= $piece;
}else{
//in normal content, we do auto p tags.
$new_content .= wptexturize(wpautop($piece));
//$new_content .= $piece; //<-- uncomment and delete line above to disable wpautop
}

}
}
return $new_content;
}

remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');
add_filter('widget_text', 'do_shortcode');
add_filter('widget_text', 'truethemes_formatter', 99);
add_filter('the_content', 'truethemes_formatter', 99);


/*-----------------------------------------------------------------------------------*/
/* <!--more--> disable scroll
/*-----------------------------------------------------------------------------------*/
function remove_more_link_scroll( $link ) {
$link = preg_replace( '|#more-[0-9]+|', '', $link );
return $link;
}
add_filter( 'the_content_more_link', 'remove_more_link_scroll' );


/*-----------------------------------------------------------------------------------*/
/* WP Theme Customizer
/*-----------------------------------------------------------------------------------*/
//add seections
function truethemes_customizer( $wp_customize ) {
$wp_customize->add_section(
'tt_customizer_footer_copyright',
array(
'title' => __( 'Footer Copyright' , 'truethemes_localize'),
'description' => __( 'Add Copyright information to the Footer.' , 'truethemes_localize'),
'priority' => 1000,
)
);

//add settings
$wp_customize->add_setting(
'footer_copyright_textbox',
array(
'type' => 'theme_mod',
)
);

//add controls (settings will not display with a control)
$wp_customize->add_control(
'footer_copyright_textbox',
array(
'label' => __( 'Footer &copy; Copyright Text' , 'truethemes_localize'),
'section' => 'tt_customizer_footer_copyright',
'type' => 'text',
)
);

}
add_action( 'customize_register', 'truethemes_customizer' );

/*-----------------------------------------------------------------------------------*/
/* WooCommerce
/*-----------------------------------------------------------------------------------*/
if (class_exists('woocommerce')){
require_once(TRUETHEMES_EXTENDED . '/woocommerce.php');
add_theme_support( 'woocommerce' );
add_theme_support( 'post-thumbnails' , array( 'post','product'));
} else {
add_theme_support( 'post-thumbnails' , array( 'post' ));
}

/*-----------------------------------------------------------------------------------*/
/* Register Sidebars
/*-----------------------------------------------------------------------------------*/
function karma_widgets_init() {
register_sidebar( array(
'name' => 'Toolbar - Left Side',
'description' => 'Add a Widget to this region or easily assign a Menu by clicking on Appearance > Menus.',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<p class="top-block-title">',
'after_title' => '</p>',
));

register_sidebar( array(
'name' => 'Toolbar - Right Side',
'description' => 'This region is located on the right side above the main navigation',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<p class="top-block-title">',
'after_title' => '</p>',
));

register_sidebar( array(
'name' => 'Blog Sidebar',
'description' => 'This sidebar is displayed on all Blog pages.',
'before_widget' => '<div class="sidebar-widget">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));

register_sidebar( array(
'name' => 'Search Results Sidebar',
'description' => 'This sidebar is displayed on the Search Results page.',
'before_widget' => '<div class="sidebar-widget">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));

register_sidebar( array(
'name' => 'Contact Sidebar (iPhone)',
'description' => 'This sidebar is displayed within the iPhone screen on the Contact page.',
'before_widget' => '<div class="sidebar-widget sidebar-smartphone">',
'after_widget' => '</div>',
'before_title' => '<h4 class="smartphone-header">',
'after_title' => '</h4>',
));

register_sidebar( array(
'name' => 'First Footer Column',
'description' => 'First Footer Column.',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h3>',
'after_title' => '</h3>',
));

register_sidebar( array(
'name' => 'Second Footer Column',
'description' => 'Second Footer Column.',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h3>',
'after_title' => '</h3>',
));

register_sidebar( array(
'name' => 'Third Footer Column',
'description' => 'Third Footer Column.',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h3>',
'after_title' => '</h3>',
));

register_sidebar( array(
'name' => 'Fourth Footer Column',
'description' => 'Fourth Footer Column.',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h3>',
'after_title' => '</h3>',
));

register_sidebar( array(
'name' => 'Fifth Footer Column',
'description' => 'Fifth Footer Column.',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h3>',
'after_title' => '</h3>',
));

register_sidebar( array(
'name' => 'Sixth Footer Column',
'description' => 'Sixth Footer Column.',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h3>',
'after_title' => '</h3>',
));

register_sidebar( array(
'name' => 'Footer Copyright - Left Side',
'description' => 'This region is located on the left side below the footer. Use a text widget to enter your copyright info.',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
));

register_sidebar( array(
'name' => 'Footer Menu - Right Side',
'description' => 'Easily assign a menu to this region by clicking on Appearance > Menus.',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
));

// START Woo-check
if (class_exists('woocommerce')){
register_sidebar( array(
'name' => 'WooCommerce Sidebar',
'description' => 'This sidebar is displayed on your WooCommerce pages.',
'before_widget' => '<div class="sidebar-widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));

register_sidebar( array(
'name' => 'WooCommerce - Cart + Checkout',
'description' => 'This sidebar is displayed on your WooCommerce Shopping Cart and Checkout pages.',
'before_widget' => '<div class="sidebar-widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));

} // END Woo-check

}
add_action( 'widgets_init', 'karma_widgets_init' );

/*-----------------------------------------------------------------------------------*/
/* Register Custom Taxonomies
/*-----------------------------------------------------------------------------------*/
//Slider Taxonomy
function truethemes_karma_slider_taxonomy() {
register_taxonomy(
'karma-slider-category',
'karma-slider',
array(
'label' => __('Categories' , 'truethemes_localize'),
'sort' => true,
'hierarchical' => true,
'args' => array( 'orderby' => 'term_order' ),
'rewrite' => array( 'slug' => 'karma-slider-category' )
)
);
}
add_action( 'init', 'truethemes_karma_slider_taxonomy' );


//Gallery Taxonomy
function truethemes_karma_gallery_taxonomy() {
register_taxonomy(
'truethemes-gallery-category',
'tt-gallery',
array(
'label' => __('Categories' , 'truethemes_localize'),
'sort' => true,
'hierarchical' => true,
'args' => array( 'orderby' => 'term_order' ),
'rewrite' => array( 'slug' => 'truethemes-gallery-category' )
)
);
}
add_action( 'init', 'truethemes_karma_gallery_taxonomy' );


/*-----------------------------------------------------------------------------------*/
/* Register Custom Post Types
/*-----------------------------------------------------------------------------------*/
//Slider Post Type
function truethemes_post_type_slider() {
$labels = array(
'name' => __( 'Slider Posts' , 'truethemes_localize'),
'singular_name' => __( 'Slider Post' , 'truethemes_localize'),
'rewrite' => array(
'slug' => __( 'slider' , 'truethemes_localize')),
'add_new' => __('Add New' , 'truethemes_localize'),
'add_new_item' => __('Add New Slider Post' , 'truethemes_localize'),
'edit_item' => __('Edit Slider Post' , 'truethemes_localize'),
'new_item' => __('New Slider Post' , 'truethemes_localize'),
'view_item' => __('View Slider Post' , 'truethemes_localize'),
'search_items' => __('Search Slider Posts' , 'truethemes_localize'),
'not_found' => __('No Slider Posts found' , 'truethemes_localize'),
'not_found_in_trash' => __('No Slider Posts found in Trash' , 'truethemes_localize'),
'parent_item_colon' => ''
);

$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => 6,
'supports' => array('title' , 'editor')
);

register_post_type( 'karma-slider', $args );
}
add_action( 'init', 'truethemes_post_type_slider' );


//Gallery Post Type
function truethemes_post_type_gallery()
{
$labels = array(
'name' => __( 'Gallery Posts' , 'truethemes_localize'),
'singular_name' => __( 'Gallery Post' , 'truethemes_localize'),
'rewrite' => array(
'slug' => __( 'gallery' , 'truethemes_localize')),
'add_new' => __('Add New' , 'truethemes_localize'),
'add_new_item' => __('Add New Gallery Post' , 'truethemes_localize'),
'edit_item' => __('Edit Gallery Post' , 'truethemes_localize'),
'new_item' => __('New Gallery Post' , 'truethemes_localize'),
'view_item' => __('View Gallery Post' , 'truethemes_localize'),
'search_items' => __('Search Gallery Posts' , 'truethemes_localize'),
'not_found' => __('No Gallery Posts found' , 'truethemes_localize'),
'not_found_in_trash' => __('No Gallery Posts found in Trash' , 'truethemes_localize'),
'parent_item_colon' => ''
);

$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => 5,
'supports' => array('title')
);

register_post_type( 'tt-gallery' ,$args );
}
add_action( 'init', 'truethemes_post_type_gallery' );


/*-----------------------------------------------------------------------------------*/
/* CSS for Custom Post Type Icons
/*-----------------------------------------------------------------------------------*/
function truethemes_custom_admin_css(){
echo '<style>

#adminmenu #menu-posts-karma-slider .menu-icon-post div.wp-menu-image:before {
content: "\f169";
/* content: "\f181"; */
}

#adminmenu #menu-posts-tt-gallery .menu-icon-post div.wp-menu-image:before {
content: "\f233";
}

#adminmenu #menu-posts-feedback .menu-icon-post div.wp-menu-image:before {
content: "\f175";
}

.wp-media-buttons .tt-add-form span.wp-media-buttons-icon:before {
font: 400 17px/1 dashicons;
content: "\f175";
margin-left:-1px;
}
/* Social Media Widget select field */
.wp-admin #tt-social-widget-dropdown {
width:95% !important;
}

/* hide revolution slider notice */
.rs-update-notice-wrap {
display: none;
}
</style>';
}
add_action('admin_head','truethemes_custom_admin_css');


/*-----------------------------------------------------------------------------------*/
/* TGM Plugin Activation (LayerSlider, etc)
/*-----------------------------------------------------------------------------------*/
add_action( 'tgmpa_register', 'truethemes_register_required_plugins' );

function truethemes_register_required_plugins() {

/**
* Array of plugin arrays. Required keys are name and slug.
* If the source is NOT from the .org repo, then source is also required.
*/
$plugins = array(

// Include Premium Plugins:
array(
'name' => 'LayerSlider', // The plugin name
'slug' => 'LayerSlider', // The plugin slug (typically the folder name)
'source' => 'http://s3.truethemes.net.s3.amazonaws.com/theme-included-plugins/layersliderwp.zip', // The plugin source
'required' => false, // If false, the plugin is only 'recommended' instead of required
'external_url' => '', // If set, overrides default API URL and points to an external URL
),

array(
'name' => 'Revolution Slider', // The plugin name
'slug' => 'revslider', // The plugin slug (typically the folder name)
'source' => 'http://s3.truethemes.net.s3.amazonaws.com/theme-included-plugins/revslider.zip', // The plugin source
'required' => false, // If false, the plugin is only 'recommended' instead of required
'external_url' => '', // If set, overrides default API URL and points to an external URL
),

// Include Plugins from the WordPress Plugin Repository:
array(
'name' => 'CU3ER 3D Slider',
'slug' => 'wpcu3er',
'required' => false,
),

array(
'name' => 'MailChimp List Subscribe Form',
'slug' => 'mailchimp',
'required' => false,
),

array(
'name' => 'Post Type Order',
'slug' => 'post-types-order',
'required' => false,
),

array(
'name' => 'WooCommerce',
'slug' => 'woocommerce',
'required' => false,
),

);

// Change this to your theme text domain, used for internationalising strings
$theme_text_domain = 'truethemes_localize';

/**
* Array of configuration settings. Amend each line as needed.
* If you want the default strings to be available under your own theme domain,
* leave the strings uncommented.
* Some of the strings are added into a sprintf, so see the comments at the
* end of each line for what each argument will be.
*/
$config = array(
'domain' => $theme_text_domain, // Text domain - likely want to be the same as your theme.
'default_path' => '', // Default absolute path to pre-packaged plugins
'menu' => 'tgmpa-install-plugins', // Menu slug.
'has_notices' => true, // Show admin notices or not.
'dismissable' => true, // If false, a user cannot dismiss the nag message.
'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
'is_automatic' => true, // Automatically activate plugins after installation or not.
'message' => '<br /><h3>Frequently Asked Questions:</h3><ol style="padding:10px 0;"><li style="padding-bottom:12px;"><strong>How do I install the plugins listed below?</strong><br />Simply hover over each plugin that you\'d like to install and click <em>Install</em>. <a href="http://vimeopro.com/truethemes/karma-4" target="_blank">Detailed video instructions outlined here.</a></li><li><strong>I\'m receiving an Error when trying to install the LayerSlider or Slider Revolution Plugins?</strong><br />These premium plugins are hosted on our Secure Amazon S3 server. Certain web servers do not allow for direct installation of files from an outside server, resulting in the error. A workaround for this is to use the "Bulk Actions" dropdown below. Simply check the boxes next to all plugins, choose "Install" from the Bulk Actions dropdown and click "Apply".</li></ol><br />', // Message to output right before the plugins table
'strings' => array(
'page_title' => __( 'Install Required Plugins', $theme_text_domain ),
'menu_title' => __( 'Install Plugins', $theme_text_domain ),
'installing' => __( 'Installing Plugin: %s', $theme_text_domain ), // %1$s = plugin name
'oops' => __( 'Something went wrong with the plugin API.', $theme_text_domain ),
'notice_can_install_required' => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.' ), // %1$s = plugin name(s)
'notice_can_install_recommended' => _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.' ), // %1$s = plugin name(s)
'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.' ), // %1$s = plugin name(s)
'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s)
'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s)
'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.' ), // %1$s = plugin name(s)
'notice_ask_to_update' => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.' ), // %1$s = plugin name(s)
'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.' ), // %1$s = plugin name(s)
'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins' ),
'activate_link' => _n_noop( 'Activate installed plugin', 'Activate installed plugins' ),
'return' => __( 'Return to Required Plugins Installer', $theme_text_domain ),
'plugin_activated' => __( 'Plugin activated successfully.', $theme_text_domain ),
'complete' => __( 'All plugins installed and activated successfully. %s', $theme_text_domain ), // %1$s = dashboard link
'nag_type' => 'updated' // Determines admin notice type - can only be 'updated' or 'error'
)
);

tgmpa( $plugins, $config );

}


/*-----------------------------------------------------------------------------------*/
/* Miscellaneous Settings
/*-----------------------------------------------------------------------------------*/
//
// ----- Remove rel="category" for HTML5 validation
//
add_filter( 'the_category', 'add_nofollow_cat' );
function add_nofollow_cat( $text ) {
$text = str_replace('rel="category tag"', "", $text); return $text;
}
//
// ----- Custom content length for blog page
//
function limit_content($content_length = 250, $allowtags = true, $allowedtags = '') {
global $post;
$content = $post->post_content;
$content = strip_shortcodes($content);
$content = apply_filters('the_content', $content);

if (!$allowtags){
$allowedtags .= '<style>';
$content = strip_tags($content, $allowedtags);
}
$wordarray = explode(' ', $content, $content_length + 1);
if(count($wordarray) > $content_length) :
array_pop($wordarray);
array_push($wordarray, '...');
$content = implode(' ', $wordarray);
$content = force_balance_tags($content);
endif;

echo $content;
}
//
// ----- Modify blog post excerpt length
//
function wp_new_excerpt($text)
{
if ($text == '')
{
$text = get_the_content('');
$text = strip_shortcodes( $text );
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text);
$text = nl2br($text);
$excerpt_length = apply_filters('excerpt_length', 80);
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
array_push($words, '...');
$text = implode(' ', $words);
}
}
return $text;
}
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'wp_new_excerpt');
//
// ----- Modify Tag Cloud Widget
//
function truethemes_tag_cloud_widget($args) {
$args['largest'] = 15;
$args['smallest'] = 12;
$args['unit'] = 'px';
return $args;
}
add_filter( 'widget_tag_cloud_args', 'truethemes_tag_cloud_widget' );
//
// ----- Hide unnecessary user profile fields
//
add_filter('user_contactmethods','hide_profile_fields',10,1);

function hide_profile_fields( $contactmethods ) {
unset($contactmethods['aim']);
unset($contactmethods['jabber']);
unset($contactmethods['yim']);
return $contactmethods;
}
//walker class for filtered gallery template
class truethemes_gallery_walker extends Walker_Category {
function start_el(&$output, $category, $depth = 0, $args = array(), $id = 0) {
extract($args);
$cat_name = esc_attr( $category->name);
$cat_name = apply_filters( 'list_cats', $cat_name, $category );
$link = '<a href="#" data-filter=".term-'.$category->term_id.'" ';
if ( $use_desc_for_title == 0 || empty($category->description) )
$link .= 'title="' . sprintf(__( 'View all items filed under %s' , 'truethemes_localize'), $cat_name) . '"';
else
$link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description', $category->description, $category ) ) ) . '"';
$link .= '>';
// $link .= $cat_name . '</a>';
$link .= $cat_name;
if(!empty($category->description)) {
$link .= ' <span>'.$category->description.'</span>';
}
$link .= '</a>';
if ( (! empty($feed_image)) || (! empty($feed)) ) {
$link .= ' ';
if ( empty($feed_image) )
$link .= '(';
$link .= '<a href="' . get_category_feed_link($category->term_id, $feed_type) . '"';
if ( empty($feed) )
$alt = ' alt="' . sprintf(__( 'Feed for all posts filed under %s' , 'truethemes_localize'), esc_attr( $cat_name ) ) . '"';
else {
$title = ' title="' . $feed . '"';
$alt = ' alt="' . $feed . '"';
$name = $feed;
$link .= $title;
}
$link .= '>';
if ( empty($feed_image) )
$link .= $name;
else
$link .= "<img src='" . esc_url( $feed_image ) . "'$alt$title" . ' />';
$link .= '</a>';
if ( empty($feed_image) )
$link .= ')';
}
if ( isset($show_count) && $show_count )
$link .= ' (' . intval($category->count) . ')';
if ( isset($show_date) && $show_date ) {
$link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp);
}
if ( isset($current_category) && $current_category )
$_current_category = get_category( $current_category );
if ( 'list' == $args['style'] ) {
$output .= '<li class="segment-'.rand(2, 99).'"';
$class = 'cat-item cat-item-'.$category->term_id;
if ( isset($current_category) && $current_category && ($category->term_id == $current_category) )
$class .= ' current-cat';
elseif ( isset($_current_category) && $_current_category && ($category->term_id == $_current_category->parent) )
$class .= ' current-cat-parent';
$output .= '';
$output .= ">$link\n";
} else {
$output .= "\t$link<br />\n";
}
}
}

//
// ----- IE9+ YouTube Video Fix
//
add_filter("embed_oembed_html", "add_wmode");
function add_wmode($html) {
$html = str_replace("feature=oembed", "feature=oembed&wmode=transparent", $html);
return $html;
}
/*-----------------------------------------------------------------------------------*/
/* Sticky Menu
/*-----------------------------------------------------------------------------------*/

/*
* function to hook jQuery to footer to activate sticky menu according to site option setting.
*/
function tt_hook_sticky_menu(){
$activate_sticky_menu = get_option('ka_fix_header_and_menubar');
if($activate_sticky_menu == 'true'){
wp_enqueue_script( 'scrollwatch', TRUETHEMES_JS .'/scrollWatch.js', array('jquery'),'4.0',$in_footer = true);
echo "<!--Site Option Activated Sticky Menu-->\n<script type='text/javascript'>jQuery(document).ready(function(){if (jQuery(window).width() > 770) {truethemes_StickyMenu();}});</script>\n<!--End Sticky Menu Activation-->\n";
}
}
add_action('wp_footer','tt_hook_sticky_menu');
?>


ambt comments:

Here is the Karma: script-enqueue.php (framework/script-enqueue.php).

Should I add your code to the script-enqueue.php instead of functions.php? If so, which line should I insert it?



<?php
function truethemes_manage_javascripts_scripts(){
if (!is_admin()){
/*-----------------------------*/
/* Enqueue Styles
/*-----------------------------*/
//@since 4.0 - enqueue CSS
global $ttso;
$primary_style = $ttso->ka_main_scheme;
$secondary_style = $ttso->ka_secondary_scheme;
$mobile_style = $ttso->ka_responsive;
$tt_custom_primary = $ttso->ka_activate_custom_primary_color_scheme;
$tt_custom_secondary = $ttso->ka_activate_custom_secondary_color_scheme;

//default style.css
wp_enqueue_style( 'style', get_stylesheet_directory_uri() . '/style.css');

//check for custom primary color scheme
if('true' == $tt_custom_primary):
function tt_custom_primary_head() {
require_once(get_template_directory() . '/css/_custom_color_scheme_primary.php');
}
add_action('wp_head', 'tt_custom_primary_head');

else :
//else display default primary color scheme
wp_enqueue_style( 'primary-color', TRUETHEMES_CSS . $primary_style .'.css'); endif;

//check for custom secondary color scheme
if('true' == $tt_custom_secondary):
function tt_custom_secondary_head() {
require_once(get_template_directory() . '/css/_custom_color_scheme_secondary.php');
}
add_action('wp_head', 'tt_custom_secondary_head');

else:
//@since 4.0 - auto-include secondary style. removed CSS @import to improve site load speed.
//customer can use "Better Wordpress Minify" plugin to combine scripts. plugin works perfectly.
if('default' == $secondary_style) :
$color_default = str_replace("karma-", "secondary-", $primary_style);
wp_enqueue_style( 'secondary-color', TRUETHEMES_CSS . $color_default .'.css');
else:
wp_enqueue_style( 'secondary-color', TRUETHEMES_CSS . $secondary_style .'.css');
endif;
endif; //end $tt_custom_secondary check

wp_enqueue_style( 'fontawesome', TRUETHEMES_CSS .'_font-awesome.css');

if (class_exists('woocommerce')) :
wp_enqueue_style( 'woocommerce', TRUETHEMES_CSS . '_woocommerce.css');
endif;

if('false' == $mobile_style) :
wp_enqueue_style( 'mobile', TRUETHEMES_CSS . '_mobile.css');
endif;


/*-----------------------------------------------------------------*/
/* Grab Variables for localize custom-main.js
/*-----------------------------------------------------------------*/
//@since 4.0 - PHP Site Options variables for sliders and testimonial now passed directly into custom-main.js
//http://codex.wordpress.org/Function_Reference/wp_localize_script

$karma_jquery_slideshowSpeed = $ttso->ka_karma_jquery_timeout; // slide display time
$karma_jquery_pause_hover = $ttso->ka_karma_jquery_pause_hover; // pause jquery on hover?
$karma_jquery_randomize = $ttso->ka_karma_jquery_randomize; // randomize slides?
$karma_jquery_directionNav = $ttso->ka_karma_jquery_directionNav; // next-previous arrows
$karma_jquery_animation_effect = $ttso->ka_karma_jquery_animation_effect; // animation effect
$karma_jquery_animationSpeed = $ttso->ka_karma_jquery_animationSpeed; // animation speed
$testimonial_randomize = $ttso->ka_testimonial_randomize; // randomize slides?
$testimonial_directionNav = $ttso->ka_testimonial_directionNav; // next-previous arrows
$testimonial_animation_effect = $ttso->ka_testimonial_animation_effect; // animation effect
$testimonial_animationSpeed = $ttso->ka_testimonial_animationSpeed; // animation speed
$testimonial_slideshowSpeed = $ttso->ka_testimonial_timeout; // slide display time
$testimonial_pause_hover = $ttso->ka_testimonial_pause_hover; // pause on hover?
$mobile_menu_text = $ttso->ka_mobile_menu_text; // main menu - mobile version - text (ie. Main Menu)
$mobile_sub_menu_text = $ttso->ka_mobile_sub_menu_text; // sub menu - mobile version - dropdown text
$dragshare = $ttso->ka_dragshare; // drag-to-share check (bottom of file - not used in localize)
$ubermenu = $ttso->ka_ubermenu; // if "true" user has activated uberMenu.

//pre-define retina logo for backward-compatible
if (@$retina_logo == ''){ @$retina_logo = 'no-retina'; }

//set the data into array
$data = array(
'mobile_menu_text' => $mobile_menu_text,
'mobile_sub_menu_text' => $mobile_sub_menu_text,
'karma_jquery_slideshowSpeed' => $karma_jquery_slideshowSpeed,
'karma_jquery_pause_hover' => $karma_jquery_pause_hover,
'karma_jquery_randomize' => $karma_jquery_randomize,
'karma_jquery_directionNav' => $karma_jquery_directionNav,
'karma_jquery_animation_effect' => $karma_jquery_animation_effect,
'karma_jquery_animationSpeed' => $karma_jquery_animationSpeed,
'testimonial_slideshowSpeed' => $testimonial_slideshowSpeed,
'testimonial_pause_hover' => $testimonial_pause_hover,
'testimonial_randomize' => $testimonial_randomize,
'testimonial_directionNav' => $testimonial_directionNav,
'testimonial_animation_effect' => $testimonial_animation_effect,
'testimonial_animationSpeed' => $testimonial_animationSpeed,
'ubermenu_active' => $ubermenu,
);

/*-----------------------------*/
/* Deregister Scripts
/*-----------------------------*/
wp_deregister_script('comment-reply');


/*-----------------------------*/
/* Enqueue Scripts
/*-----------------------------*/
//wp_register_script removed since 4.0 - only wp_enqueue_script is required
//anytime a script is updated simply use the current Karma version number for the script version number

wp_enqueue_script( 'jquery');
wp_enqueue_script( 'truethemes-custom', TRUETHEMES_JS .'/custom-main.js', array('jquery'),'4.0',$in_footer = true);
wp_enqueue_script( 'superfish', TRUETHEMES_JS .'/superfish.js', array('jquery'),'4.0',$in_footer = true);
wp_enqueue_script( 'flexslider', TRUETHEMES_JS .'/jquery.flexslider.js', array('jquery'),'4.0',$in_footer = true);
wp_enqueue_script( 'fitvids', TRUETHEMES_JS .'/jquery.fitvids.js', array('jquery'),'4.0',$in_footer = true);
wp_enqueue_script( 'isotope', TRUETHEMES_JS .'/jquery.isotope.js', array('jquery'),'4.0',$in_footer = true);
wp_enqueue_script( 'jquery-ui-core');
wp_enqueue_script( 'jquery-ui-widget');
wp_enqueue_script( 'jquery-ui-tabs');
wp_enqueue_script( 'jquery-ui-accordion');
wp_enqueue_script( 'pretty-photo', TRUETHEMES_JS .'/jquery.prettyPhoto.js', array('jquery'),'4.0',$in_footer = true);
wp_enqueue_script( 'comment-reply', site_url().'/wp-includes/js/comment-reply.js',$deps=null,'1.0',$in_footer = true);

//localize custom-main.js (must be placed after enqueue)
wp_localize_script('truethemes-custom', 'php_data', $data);





/*-----------------------------*/
/* WooCommerce Custom Enqueue
/*-----------------------------*/
//check for woocommerce
if (class_exists('woocommerce') && ((is_woocommerce() == "true") || (is_checkout() == "true") || (is_cart() == "true") || (is_account_page() == "true") )){

//de-regsiter unnecessary scripts
wp_deregister_script('comment-reply');
wp_deregister_script('jquery-easing');

//enqueue scripts
wp_enqueue_script('truethemes-woocommerce', TRUETHEMES_JS .'/custom-woocommerce.js', array('jquery'), '',$in_footer = true);
}



/*-----------------------------*/
/* Drag-to-Share
/*-----------------------------*/
//$dragshare comes from top of this file
if($dragshare == "true"):

//prettySociable Icons for wp_localize
define('PRETTYSOCIAL', get_template_directory_uri().'/images/_global/prettySociable/social_icons');
$pretty_delicious = PRETTYSOCIAL.'/delicious.png';
$pretty_digg = PRETTYSOCIAL.'/digg.png';
$pretty_facebook = PRETTYSOCIAL.'/facebook.png';
$pretty_linkedin = PRETTYSOCIAL.'/linkedin.png';
$pretty_reddit = PRETTYSOCIAL.'/reddit.png';
$pretty_stumbleupon = PRETTYSOCIAL.'/stumbleupon.png';
$pretty_tumblr = PRETTYSOCIAL.'/tumblr.png';
$pretty_twitter = PRETTYSOCIAL.'/twitter.png';

//set the data into array
$pretty_data = array(
'delicious' => $pretty_delicious,
'digg' => $pretty_digg,
'facebook' => $pretty_facebook,
'linkedin' => $pretty_linkedin,
'reddit' => $pretty_reddit,
'stumbleupon' => $pretty_stumbleupon,
'tumblr' => $pretty_tumblr,
'twitter' => $pretty_twitter,
);

//load prettySociable only in...
if(is_single()||is_home()||is_archive()||is_category()||is_tag()||is_author()):

//Bitly API script
wp_enqueue_script( 'bitly-api','http://bit.ly/javascript-api.js?version=latest&login=scaron&apiKey=R_6d2a7b26f3f521e79060a081e248770a', array('jquery'),'1.0',$in_footer = true);

wp_enqueue_script( 'pretty-sociable', TRUETHEMES_JS .'/jquery.prettySociable.js', array('jquery'),'1.2.1',$in_footer = true);

//localize prettySociable.js (must be placed after enqueue)
wp_localize_script('pretty-sociable', 'social_data', $pretty_data);

endif; // if_single(), is_home()...
endif; // if($dragshare)
}
}

//hook in last, so that plugins cannot change this? Maybe.
//hook in template redirect instead of init so that is_single() conditional tags works.
add_action('template_redirect', 'truethemes_manage_javascripts_scripts',90);
?>


Navjot Singh comments:

If you have a child theme then I suggest you add it in its functions.php or the theme's function.php only if you don't have a child theme.

And pardon me, that was not the complete code. Here is the complete code to be added before '?>' in the theme's function.php

function karma_bug_include() {
wp_enqueue_script( 'bug', get_template_directory_uri() . '/js/bug.js', array(), '1.0.0' );
}

add_action( 'wp_enqueue_scripts', 'karma_bug_include' );


According to this code bug.js should be placed inside the theme's folder/js folder.


ambt comments:

I did everything you suggested and it appears we are making progress! However, a very funny thing happened when I put the bug.js into the js folder.

Please take a look at:
http://bughouse.net/main/?page_id=272

Two sets of chess boards appeared! The top 2 are correct, but after bug.js in the js folder, there is an extra 2 boards at the bottom.

It should be exactly like the original page:
http://bughouse.net/training_center/master_games/games_viewable_online/gp1_finals.htm

Also, the pull-down menu that is supposed to load each game isn't working on the new page.

hmmm... What am I doing something wrong?


Navjot Singh comments:

The code seems to be replicated in the source. Wrapped in a code tag. Please check.


Navjot Singh comments:

Also use the css

table {
font-size: 0.8em !important;
}

to reduce the table size.


ambt comments:

hmmm.....I did a search in bug.js for 'code' and didn't come up with any matches. It doesn't appear there are any replicated table in the source. But I'm not a programmer, so I could be wrong.

Here is bug.js

<code>// Javascript bughouse viewer v 1.01 (C) Sergiy Vasylkevych aka Fermy on FICS
// Feel free to use/copy/modify/distribute
// This update 01.07.2002
function debug()
{
var tmp='<form name="debug"><p><textarea name="shit" value="" rows="5" cols="70"></textarea></p></form>';
document.writeln(tmp);
}

function Init()
{
//debug();
//Defaults that one may want to change.
DEFAULT_BSQ_COL= "#808080"; //'#A28964';
DEFAULT_WSQ_COL= "#E4E4E4"; //'#DDC7AC'; '#EEC8B0';
BPGN_LINE_SIZE=79;
RDO='[';
RDC=']'; /* opening and closing delimiters that embrace ratings of players in viewer display */
DROPBAR=new Array("br","bq","bb","bn","bp","wp","wb","wn","wr","wq");
PLAY_DELAY=100;
MAX_NEXT=20;
NEXT_WIDTH=14;


BPGN_ROOT=0 ; // BPGN root node index
BPGN_BOARD_A1 = 'A'; // BPGN board 'A'
BPGN_BOARD_A2 = 'a' ; // BPGN board 'a'
BPGN_BOARD_B1 = 'B' ; // BPGN board 'B'
BPGN_BOARD_B2 = 'b' ; // BPGN board 'b'

BPGN_BOARD_ASTR1 = "A" ; // BPGN board 'A' string
BPGN_BOARD_ASTR2 = "a" ; // BPGN board 'a' string
BPGN_BOARD_BSTR1 = "B" ; // BPGN board 'B' string
BPGN_BOARD_BSTR2 = "b" ; // BPGN board 'b' string

BPGN_MOVE_DSTR = "." ; // BPGN move dot string
BPGN_ANNOTATION= 'A'; // BPGN annotation symbol
BPGN_NOTE = 'C'; // BPGN note symbol
BPGN_OMITED_TIME= - 5;

BPGN_VIEWER_DIR='';
BPGN_NORMAL=0;
BPGN_STRING=1;
BPGN_INTEGER=2;
BPGN_COMMENT1=3;
BPGN_COMMENT2=4;
BPGN_NAG=5;
BPGN_SYMBOL=6;

BPGN_WHITE_WINS="1-0";
BPGN_BLACK_WINS="0-1";
BPGN_DRAW="1/2-1/2";
BPGN_UNKNOWN="*";
BPGN_WHITE_WINS="1-0" ; // BPGN white wins string
BPGN_BLACK_WINS ="0-1" ; // BPGN black wins string
BPGN_DRAW ="1/2-1/2"; // BPGN draw string
BPGN_UNKNOWN ="*" ; // BPGN unknown result string

BPGN_EVENT ="Event" ; // BPGN event tag string
BPGN_SITE ="Site" ; // BPGN site tag string
BPGN_DATE ="Date" ; // BPGN date tag string
BPGN_WHITEA ="WhiteA" ; // BPGN whitea tag string
BPGN_BLACKA ="BlackA" ; // BPGN blacka tag string
BPGN_WHITEB ="WhiteB" ; // BPGN whiteb tag string
BPGN_BLACKB ="BlackB" ; // BPGN blackb tag string
BPGN_WHITEAELO ="WhiteAElo" ; // BPGN whiteaelo tag string
BPGN_BLACKAELO ="BlackAElo" ; // BPGN blackaelo tag string
BPGN_WHITEBELO ="WhiteBElo" ; // BPGN whitebelo tag string
BPGN_BLACKBELO ="BlackBElo" ; // BPGN blackbelo tag string
BPGN_TIMECTRL ="TimeControl" ; // BPGN timecontrol tag string
BPGN_RESULT ="Result" ; // BPGN result tag string

DEFAULT_EVENT ="fics rated bughouse match";
DEFAULT_SITE ="fics, Oklahoma City, OK USA";
DEFAULT_DATE ="????.??.??";
DEFAULT_WHITEA ="WhiteA";
DEFAULT_BLACKA ="BlackA";
DEFAULT_WHITEB ="WhiteB";
DEFAULT_BLACKB ="BlackB";
DEFAULT_TIME ="180";
DEFAULT_INC ="0";
DEFAULT_RATING ="++++";
DEFAULT_REASON ="{*}";
DEFAULT_RESULT ="*";
TAB_ASCII_NUM = '\t';
CR_ASCII_NUM='\r';
LF_ASCII_NUM='\n';
NEW_PAR='�';

ERROR_NONE = 0 // No error
ERROR_INCOMPLETE = 1 // Incomplete BPGN file
ERROR_MISSING_NOTE = 2 // Missing note or annotation
ERROR_INVALID_NOTE = 3 // Invalid note or annotation
ERROR_INVALID_ANNOTATION = 4 // Invalid annotation
ERROR_MISSING_BRACKET = 5 // Missing '}'
ERROR_MISSING_MOVE_NUMBER =6 // Missing move number
ERROR_MISSING_BOARD_SYMBOL =7 // Missing board symbol
ERROR_INVALID_BOARD_SYMBOL =8 // Invalid board symbol
ERROR_INVALID_MOVE_NUMBER =9 // Invalid move number
ERROR_MISSING_MOVE_DOT = 10 // Missing '.'
ERROR_INVALID_MOVE_DOT = 11 // Missing '.'
ERROR_MISSING_MOVE = 12 // Missing move
ERROR_INVALID_MOVE = 13 // Invalid move
ERROR_MISSING_TIME = 14 // Missing time
ERROR_INVALID_TIME = 15 // Invalid time
ERROR_MISSING_RESULT = 16 // Missing result
ERROR_INVALID_RESULT = 17 // Invalid game result
ERROR_DOUBLE_NOTE = 18 // Double note
ERROR_DOUBLE_ANNOTATION = 19 // Double annotation
ERROR_MISSING_END_VARIATION= 20 // Missing ')'

CASTLE_BAD = /0-0/gi;
LCASTLE_BAD=/0-0-0/gi;
NUMB=/[0-9]/;
SYMB=/\w|[+#=:\-@]/;
LETT=/[a-zA-z]/;
RELOAD_BPGN=''; //global variable containing reference to the loadbpgn window.
RELOAD_BPGNVIEWER=''; //global variable containing the name of the viewer that called loadbpgn window.
BPGN_FILE_NAME= new Array();//global array containing names of bpgn files to read in readfile.shtml.
BPGN_FILE_VIEWER=new Array(); //global array containing names of the viewers that requested to read files.
READ_INTERVAL=false; //timer used to read files;
READ_WINDOW=false;
SAVE_STR='';
IE = ((navigator.appName.toLowerCase()) =="microsoft internet explorer")?true:false;
}

function readfile(viewer,file)
{
BPGN_FILE_NAME[BPGN_FILE_NAME.length]=file;
BPGN_FILE_VIEWER[BPGN_FILE_VIEWER.length]=viewer;
if (!READ_INTERVAL) {READ_INTERVAL=setInterval("loadfile();",100);};
};

function loadfile()
{var i; var n=BPGN_FILE_NAME.length;
if (n==0) {clearInterval(READ_INTERVAL); READ_INTERVAL=false; return;};
var tmp=BPGN_FILE_NAME[0]; for (i=0;i<n-1;i++) BPGN_FILE_NAME[i]=BPGN_FILE_NAME[i+1]; BPGN_FILE_NAME[n-1]=false;
BPGN_FILE_NAME.length=n-1;
if ((!READ_WINDOW)||(READ_WINDOW.closed)) {READ_WINDOW=window.open(BPGN_VIEWER_DIR+'readfile.shtml?'+tmp,'bpgnfilereadwindow','width=300,height=300');};
READ_INTERVAL=setInterval("loadfile();",100);
}

function setvar(text)
{var i; var n=BPGN_FILE_VIEWER.length;
var viewer=BPGN_FILE_VIEWER[0]; for (i=0;i<n-1;i++) BPGN_FILE_VIEWER[i]=BPGN_FILE_VIEWER[i-1];
BPGN_FILE_VIEWER[n-1]=false; BPGN_FILE_VIEWER.length=n-1;
var v=eval(viewer);
v.reloadgame(text,"","");
READ_WINDOW.close();
}

function streplace(text,ch1,ch2)
{
var found=true;
var j=0;
while (found)
{
j=text.indexOf(ch1);
if (j<0) {found=false;}
else {text=text.substr(0,j)+ch2+text.substr(j+1,text.length); j++};
}
return text
}

function generatesavehtml()
{ var tmp;
tmp='<html><head><title>Save BPGN</title></head>'
tmp+='<body bgcolor="#FFFFFF" text="#000000">';
tmp+='<p align="center"><font color="#C0C0C0" size="6">Save BPGN</font></p>';
tmp+='<form name="saveform">';
tmp+='<p><textarea name="bpgn" rows="10" cols="80"></textarea></p>';
tmp+='<p><strong>BFEN A:</strong><input type="text" size="70"';
tmp+=' name="bfena"></p>';
tmp+='<p><strong>BFEN B:</strong><input type="text" size="70"';
tmp+=' name="bfenb"></p>';
tmp+=' <p>Here is BPGN text for the game and BFEN for the current';
tmp+=' position. Cut&amp;Paste them into your favorite text editor';
tmp+=' and save. Click &quot;Close&quot; button to close this';
tmp+=' window. </p>';
tmp+=' <p><input type="button" name="confirm" value="Close"';
tmp+=' onclick="window.close();"></p>';
tmp+='</form></body></html>';
return tmp;
}

function generateloadhtml(viewer)
{
var tmp;
tmp='<html><head><title>Load BPGN</title></head>'
tmp+='<body bgcolor="#FFFFFF" text="#000000">';
tmp+='<p align="center"><font color="#C0C0C0" size="6">Load Game</font></p>';
tmp+='<p>Here you may load a bughouse/crazyhouse/chess game into the viewer. Also you may setup initial position! Press "Load" button when you are done. You may leave blank any field</p>';
tmp+=' <p>Paste (or type in) moves in <strong>BPGN</strong> format in the box below. You may paste the whole bgpn file (with tags) or just moves. </p>';

tmp+='<form name="loadform">';
tmp+='<p><textarea name="bpgn" rows="5" cols="70"></textarea></p>';
tmp+='<p>If you want to setup position different from the initial, paste it (or type in) below. Position must be in bfen format.</p>';
tmp+='<p><strong>BFEN A:</strong><input type="text" size="70"';
tmp+=' name="bfena"></p>';
tmp+='<p><strong>BFEN B:</strong><input type="text" size="70"';
tmp+=' name="bfenb"></p>';
tmp+='<p><input type="button" name="confirm" value="Load" ';
tmp+='onClick="opener.assreloadgame('+"'"+viewer+"'"+',document.loadform.bpgn.value,document.loadform.bfena.value,document.loadform.bfenb.value);">';
tmp+=' <input type="button" name="confirm" value="Close"';
tmp+=' onclick="window.close();"></p>';
tmp+='</form></body></html>';
return tmp;
}

function killleadspace(str)
{
var i;
str=' '+str;
for (i=0;str.charAt(i)==" ";i++);
return str.substr(i);
}

function killtailspace(str)
{
var i;
for (i=str.length-1;str.charAt(i)==" ";i--);
return str.substring(0,i+1);
}

function isempty (square)
{
var st=this.pos[square];
return (st.length==0)? true:false;
}

function bugmove()
{
this.board=''; //"a" or "b"
this.side=''; //'w' or 'b'
this.frompiece='';//piece that moves
this.fromsquare=-1; //starting square of the frompiece
this.tosquare=-1; // destination square of the frompiece
this.topiece=''; // captured piece
this.backupenpassant=''; //
this.backupshortcastle=''; //
this.backuplongcastle='';
this.backuptime=0;
this.buckuptime1=0;
}



function getdest(move)
{
var cfile='abcdefgh';
var crank='12345678';
var i; var rank='';var file=''; var tmp;
for(i=move.length-1;i>0;i--) {
if (crank.indexOf(move.charAt(i))>-1) {rank=move.charAt(i);break;}
};
file=move.charAt(i-1); tmp=file.toLowerCase();
var res= file+rank;
return ((cfile.indexOf(tmp)<0)||(rank=''))? '': res;
}

function whosmove(turn)
{
return (turn==turn.toLowerCase())? 'b':'w'; /*check who's to move*/
}

function incheck(whomove,dest)
{var i; var piece;
op=othercolor(whomove);
for (i=0;i<64;i++) {
if (this.pos[i].charAt(0)!=op) {continue;};
piece=this.pos[i].charAt(1);
if (this.legalmove(piece,op,i,dest,1)) { return true;};
};
return false;
}

function enpassantvalid(dest)
{ return (dest==this.enpasssq)? true: false; }

function legalmove(piece,whomove,src,dest,mode)
{
var srcp=this.pos[src];
srcp=srcp.toLowerCase();
if ((mode!=1)&&(srcp!=(whomove+piece))) {return false;};
var sfile=getfile(src); var srank=getrank(src);
var dfile=getfile(dest); var drank=getrank(dest);
var dir; var i;
if (piece=='p'){
dir= (whomove=='w')? 1: -1;
if((dfile==sfile)&&(srank+dir==drank)&&(this.isempty(dest))) {return true;} //noncapture one square ahead
if ((dfile==sfile)&&(whomove=='w')&&(srank==2)&&(drank==4)&&(this.isempty(dest+8))&&(this.isempty(dest))) return true;
if ((dfile==sfile)&&(whomove=='b')&&(srank==7)&&(drank==5)&&(this.isempty(dest-8))&&(this.isempty(dest))) return true; //noncapture 2 sq's ahead
if ((Math.abs(dfile-sfile)==1)&&(srank==drank-dir)&&((this.pos[dest]!='')|| (this.enpassantvalid(dest)))) return true;
/* capture. We don't check if we capture our own piece or opponents */
return false;
}
if (piece=='k') {
if ((Math.abs(dfile-sfile)<=1)&&(Math.abs(drank-srank)<=1)&&(src!=dest)) {return true;}
else {return false};
}
if (piece=='n') {
if ((Math.abs(dfile-sfile)+Math.abs(drank-srank)==3)&&(Math.abs(drank-srank)>0)&&(Math.abs(dfile-sfile)>0)) return true;
return false;
}
if (piece=='r'){
if (sfile==dfile){
dir=(dest>src)? 1: -1;
for (i=1; i<Math.abs(drank-srank);i++){ if (!this.isempty(src+8*dir*i)) {return false};};
return true;
};
if (srank==drank){
dir=(dest>src)? 1: -1;
for (i=1; i<Math.abs(dfile-sfile);i++){ if (!this.isempty(src+dir*i)) {return false};};
return true;
};
return false;
}
if (piece=='b') {
if (Math.abs(dfile-sfile)!=Math.abs(drank-srank)) return false;
dirf= (sfile>dfile)? -1:1;
dirr= (srank>drank)? 1:-1;
for (i=1;i<Math.abs(drank-srank);i++){ if (!this.isempty(src+(8*dirr+dirf)*i)) {return false};};
return true;
}
if (piece=='q') {return ((this.legalmove('b',whomove,src,dest,1))||(this.legalmove('r',whomove,src,dest,1)));};
return false; /* should never get here */
}

function getrank(ind)
{ var ss=ind - (ind%8);
return (8-ss/8);
}

function getfile(ind)
{return (ind % 8);
}

function findmove(piece,whomove, spec,dest)
{var cfile='abcdefgh';
var crank='87654321'; /* strange order because index 0 corresposnds to a8 in array this.pos */
var rmin=0; var rmax=8; var fmin=0; var fmax=8;
var r; var f; var c; var f; var c2; var src=-1; var king; var dp; var sp;
var quit=false;
piece=piece.toLowerCase();
spec=spec.toLowerCase();
if(spec.length!= 0 ) {/* translate specifier into search restriction */
c = spec.charAt(0);
if(cfile.indexOf(c)>=0) {fmin=cfile.indexOf(c); fmax=fmin+1;}
else {rmin=crank.indexOf(c); if(rmin>=0) {rmax=rmin+1} else {rmin=0};};
if(spec.length >1 ) {c2 = spec.charAt(1);
if (crank.indexOf(c2)>=0) {rmin=crank.indexOf(c2); rmax=rmin+1};
}
}
/* now find possible move withing restrictions */
var found=false;
for (f=fmin;f<fmax;f++){
for (r=rmin;r<rmax;r++){
src=8*r+f;
if (!this.legalmove(piece,whomove,src,dest,0)) {continue;}
else {
king=eval('this.king'+whomove);
dp=this.pos[dest]; sp=this.pos[src];
this.pos[src]='';
this.pos[dest]=whomove+piece;
if (piece == 'k') king=dest;
if (!this.incheck(whomove,king)) {found=true;quit=true;};
this.pos[src]=sp; this.pos[dest]=dp;
};
if (quit==true) break;
}; if (quit==true) {break;};}
if (!found) return -1;
src=8*r+f;
if (src>63) {return -1} ; /* no moves found */
if (piece=='p'){/* check for promotion and enpassant*/
if (((whomove=='w')&&(getrank(dest)==8))||((whomove=='b')&&(getrank(dest)==1))) {src+=100}; //promotion
if ((f!=getfile(dest)) && (this.isempty(dest))) {src+=200}; //enpassant
}
return src;
}


function promdialog(wh)
{
return (confirm('Promote to Q? \n Cancel will promote to N'))? 'q':'n';
}



function getpromotion(wh, move,dest)
{
var i=move.indexOf(dest);var t=move.length; var j;
var prompiece='qnrb';
if ((i<0)||(i>t-3)) return this.promdialog(wh);
for (j=i+2;j<t;j++) {if (move.charAt(j)!='=') break;};
var c=move.charAt(j);c=c.toLowerCase();
j=prompiece.indexOf(c);
return ((j<0)?this.promdialog(wh):c);
}

function decryptmove (bd,move)
{/* returns bugmove object mv. If something is wrong false is returned;
if this is a drop move fromsquare is set to 65; if this is castling fromsquare is set to o-o or o-o-o; if this is En passant frompiece is set to wpx or bpx; if this is promotion fromsquare is set to wpq, wpr, etc,;very little error checking is done. moves better be valid */
var cfile='abcdefgh';
var crank='12345678';
var drop='rnbqp';
var cpiece='rnbqk';
var mv=new bugmove();
var piece;

move=extractmove(move);
mv.board=bd.turn.toLowerCase();
whomove=whosmove(bd.turn);
mv.side=whomove;
move=killleadspace(killtailspace(move));

// castle?
var tmp=move.toLowerCase();
if((tmp.indexOf("o-o-o")!= -1 )||(move.indexOf("0-0-0")!= -1 ))
{
mv.fromsquare = 'o-o-o';
mv.frompiece= whomove+'k';
return mv;
}
if((tmp.indexOf("o-o")!= -1 )||(move.indexOf("0-0")!= -1 ))
{
mv.fromsquare = 'o-o';
mv.frompiece= whomove+'k';
return mv;
}

var dest=getdest(move); /* dest is a destination square, e.g. 'c7') */
if (dest=='') return false;
var des=sqtoind(dest);
if ((bd.pos[des].charAt(0)==whomove)&&(this.rule=='international')) return false;
mv.tosquare=des;
mv.topiece=bd.pos[des];
// drop move?
if(move.length < 2) {return false;}
if( move.charAt(1) == '@' ) {
if((move.length < 4)||(bd.pos[mv.tosquare]!='')) return false;
mv.fromsquare = 65;
piece= move.charAt(0); piece=piece.toLowerCase();
if (drop.indexOf(piece)<0) return false;
if ((piece=='p')&&((dest.charAt(1)==8)||(dest.charAt(1)==1))) return false;
mv.frompiece=whomove+piece;
return mv;
};

// find source square specifier. for ex, in move Raxd1 modifier is 'a'
var endspec=move.indexOf(dest)-1;
if ((move.charAt(endspec)=='x')||(move.charAt(endspec)=='X')) endspec--;
var srcspec=move.substring(1,endspec+1);

// is it a pawn move?
piece=move.charAt(0);
tmp=srcspec;
if(cfile.indexOf(piece)>= 0)
{
if (srcspec.length<2) {srcspec=piece+srcspec};
var res=bd.findmove('p',whomove,srcspec,des);
if (res>=0) /* yes this is pawn move */
{
mv.fromsquare=res % 100;
mv.frompiece= (res>199)? whomove+'px':whomove+'p';/*check if the move is enpassant */;
if ((res<200)&&(res>99)) {mv.frompiece=whomove+'p'+this.getpromotion(whomove,move,dest);};
return mv;
};
// we are here if it's bishop move, but i won't use this.
};
srcspec=tmp;
res=bd.findmove(piece,whomove,srcspec,des);
if (res<0) return false; /* oh shit, illegal move */
mv.fromsquare=res;
mv.frompiece=bd.pos[res];
return mv;
}

function preload ( path )
{ var gifs = new Array();
for ( var i=0; i< 16; i++)
gifs[i]= new Image();
gifs[0].src=path+'wkd.gif';
gifs[1].src=path+'bkd.gif';
gifs[2].src = path + "wbd.gif";
gifs[3].src = path + "wnd.gif";
gifs[4].src = path + "wrd.gif";
gifs[5].src = path + "wqd.gif";
gifs[6].src = path + "wpd.gif";
gifs[7].src = path + "bnd.gif";
gifs[8].src = path + "bbd.gif";
gifs[9].src = path + "brd.gif";
gifs[10].src = path + "bqd.gif";
gifs[11].src = path + "bpd.gif";
gifs[12].src= path+"d.gif";
gifs[13].src=path+"mv.gif";
gifs[14].src=path+"b.gif";
gifs[15].src=path+"w.gif";
}

function Init1 ( path, filebg, wsq,bsq )
{
var gifpath= new Array();
gifpath["wbd"] = path + "wbd.gif";
gifpath["wnd"] = path + "wnd.gif";
gifpath["wrd"] = path + "wrd.gif";
gifpath["wqd"] = path + "wqd.gif";
gifpath["wpd"] = path + "wpd.gif";
gifpath["bnd"] = path + "bnd.gif";
gifpath["bbd"] =path + "bbd.gif";
gifpath["brd"] = path + "brd.gif";
gifpath["bqd"] = path + "bqd.gif";
gifpath["bpd"] = path + "bpd.gif";
gifpath["wkd"]= path+ "wkd.gif";
gifpath["bkd"]= path+ "bkd.gif";
gifpath["d"] = path + "d.gif";
gifpath["mv"]= path + "mv.gif";
gifpath["nmv"]= path + "d.gif";
if (filebg) {gifpath['w']=path+ "w.gif"; gifpath['b']=path+"b.gif";}
else {gifpath['w']=wsq; gifpath['b']=bsq;};
return gifpath;
}


function fixnumber(the_number) //adds leading zero to a one-digit number
{
if (the_number < 10)
{
the_number = "0" + the_number;
}
return the_number;
}

function indelim(str, pos, del1, del2) /* returns a piece of a string str that sits between first occurences of delimiters del1 and del2 after position pos in str */
{
var p1=str.indexOf(del1,pos);
var p2=str.indexOf(del2,p1+1);
var p3=str.indexOf(']',pos);
if (p3<p2) {return '';};
var value=str.substring(p1+1,p2);
return value;
}

function totime(num)
{
var sec= num % 60;
var min = (num - sec)/ 60;
var time= min + ':'+fixnumber(sec);
return time;
}

function extracttext(text)
{
var s;
var pos = text.indexOf('{');
if (pos<0) {pos=text.lastIndexOf(']')}
else {s=text.substring(0,pos); pos=s.lastIndexOf(']');};
s=text.substr(pos+1);
s=s.replace(LCASTLE_BAD,'o-o-o');
return s.replace(CASTLE_BAD,'o-o');
}

function bpgnheader(source, header) /* returns value of a bpgn header (header) in a bpgn text (source). Essentially looks for first occurence of substring header in the string source and returs whatever is in next " " after header */
{
header='['+header;
var pos=source.indexOf(header);
if (pos<0) {return '';};
pos=pos+header.length;
var value=indelim(source, pos, '"','"');
return value;
}

function insert (str1, ind1, str2) /* inserts string str2 into string str1 at index ind1 */
{
var tmp=str1.substr(ind1);
str1= str1.substr(0,ind1+1);
return (str1+str2+tmp);
}

function sqtoind (sq) /* returns an index in the array pos of a square sq on chess board (e.g. "c7") */
{
var fc=sq.charAt(0)
var rc=sq.charAt(1);
var cfiles='abcdefgh';
var t=cfiles.indexOf(fc);
var s= eval("8"*rc);
return (64-s+t);
}

function generatebfen ()
{
var i; var t; var ec=0; var res=''; var col=0; var p;
for (i=0;i<64;i++)
{
t=this.pos[i];
if (t=='') {
ec++;
if (col>=7) { res+=ec; ec=0;};
}
else {
if (ec>0) {res+=ec; ec=0;};
p=t.charAt(1);
if (p==p.toUpperCase()) {p=p+'~'};
p= (t.charAt(0)=='w')? p.toUpperCase(): p.toLowerCase();
res+=p;
};
col++; if (col>=8) {col=0;res+='/';};
};
res+=' '+whosmove(this.turn)+' '+this.wclock+' '+this.bclock;
return res;
}

function indtosq(ind)
{
var cfiles='abcdefgh';
var rank=getrank(ind);
var file=getfile(ind);
var res=cfiles.charAt(file)+rank;
return res;
}

function indtoind(ind, flip)
{
return (flip==0)? ind: (63-ind);
}

function drawhold()
{
var i;
var j;
var t;
var ind=this.syncpic();
if (this.flip==0)
{for (i=0;i<10;i++)
{if (this.hold[i]>0) { t=this.dropbar[i]+'d'; document.images[ind+64+i].src=this.gifs[t];}
else { document.images[ind+64+i].src=this.gifs["d"];};
}
}
else {for (i=0;i<10;i++)
{if (this.hold[i]>0) { t=this.dropbar[i]+'d'; document.images[ind+73-i].src=this.gifs[t];}
else { document.images[ind+73-i].src=this.gifs["d"];};
}
};
return;
}


function drawpos () /* draws a position and holding (pos and holding respectively) in the viewer, ind is the index of upper left corner of the board in the array document.images[]. That way function doesn't need to know the board name */
{
var i;
var st;
this.brefreshform();
var ind=this.syncpic();
if (this.flip==0) {
for (i=0; i<64;i++) { st=this.pos[i].toLowerCase()+'d'; document.images[ind+i].src=eval('this.gifs["'+st+'"]');}
}
else {for (i=0; i<64;i++) { st=this.pos[63-i].toLowerCase()+'d'; document.images[ind+i].src=eval('this.gifs["'+st+'"]');}};
this.drawhold();
return;
}

function refreshinfo()
{
if ((this.displaymode=='playback')||(this.displaymode=='diagram')) return;
var i; var j; var s=''; var bl=' ';
var n=this.BPGN[this.currentmove].nNext.length;

if (n>MAX_NEXT) n=MAX_NEXT;
var v=eval('window.document.'+this.viewername);
s=(this.currentmove==this.endnode)?this.cResult1 +' '+this.gameresult +'\n\n':'';
//document.debug.shit.value='';
v.comment.value=s+streplace(this.BPGN[this.currentmove].cNote,NEW_PAR,'\n');
bl=bl.substr(0,NEXT_WIDTH);
for (i=0;i<n;i++)
{
j=this.BPGN[this.currentmove].nNext[i];
s=this.BPGN[j].cMove+this.BPGN[j].cAnno;
s+=bl;
v.nextmove.options[i].text=s.substr(0,NEXT_WIDTH);
};
for (i=n;i<MAX_NEXT;i++) {v.nextmove.options[i].text=bl;};
v.nextmove.options[MAX_NEXT].text='XXXXXXXXXXX';
v.nextmove.options[0].selected=true;
}

function NODE()
{
this.nParent=BPGN_ROOT ; // Partner node index
this.nMove=0 ; // Move counter
this.cBoard=BPGN_BOARD_A1 ; // Board type ('A', 'a', 'B', or 'b')
this.cMove='' ; // Move string size (i.e. "e4")
this.cTime=''; // Time (i.e. "300")
this.cAnno=''; // Annotation (i.e. "!")
this.cNote=''; // Note (i.e. "Interesting move!")
this.nNext=new Array(); // Next size (next moves)
this.dmove=false; //decrypted move
}

function QUEUE(state, token)
{
this.nlaststate=state ; // token queue last state
this.cToken=token; // token queue token
}

// get new node
function BPGN_GetNewNode ()
{
var i=this.BPGN.length;
this.BPGN[this.BPGN.length]=new NODE();
return i;
}

// is token queue empty?
function BPGN_QueueIsEmpty ()
{
return (this.Queue.length == 0) ; //return this.nCount;
}

// insert into token queue
function BPGN_InsertQueue (nls, ct)
{
this.nError=ERROR_NONE;
this.Queue[this.Queue.length]=new QUEUE(nls,ct);
return true;
}

// remove from token queue
function BPGN_RemoveQueue ()
{var i;
var n=this.Queue.length;
if (n > 0)
{
this.nError = ERROR_NONE ;
var res=this.Queue[0];
for (i=0;i<n-1;i++) this.Queue[i]=this.Queue[i-1]; this.Queue[n-1]=false; this.Queue.length=n-1;
return res;
}
else
{
this.nError = ERROR_QUEUE_IS_EMPTY ;
return false;
};
}

function gettoken ()
{
var ni;
var ctmp;
var cttt;
var x;
var tmp;

if (!this.BPGN_QueueIsEmpty())
{
tmp=this.BPGN_RemoveQueue();
if (tmp!=false)
{
this.ctoken=tmp.cToken;
this.nlaststate=tmp.nlaststate;
return true ;
};
return false;
};

if ((this.ngamesize == 0) || (this.ngameindex > this.ngamesize))
// introduce ngamesize, ngameindex, ctoken;
{this.ctoken=""; return 0;};
ni = this.ngameindex - 1 ;
while (ni < this.ngamesize)
{
this.ctoken="";
ctmp="";
while (ni < this.ngamesize)
{
ni = ni + 1 ;
// normal state
// introduce this.nstate, this.cgame
x=this.cgame.charAt(ni);
if (this.nstate == BPGN_NORMAL)
{
if ((x== ' ')||(x == TAB_ASCII_NUM)||(x==CR_ASCII_NUM)||(x==LF_ASCII_NUM)) break ;
if ((x == '[') || (x == ']') ||
(x == '(') || (x == ')') ||
(x == '<') || (x == '>') ||
(x == '(') || (x == ')') ||
(x == '.') || (x == '*') ||
(x == '}'))
{this.ctoken = x ; break ;}

if (x == '"'){this.nstate = BPGN_STRING ; continue ;}
if (x == '0'){
if ((ni + 2) <= this.ngamesize)
{
if ((this.cgame.charAt(ni + 1) == '-') && (this.cgame.charAt(ni + 2) == '1'))
{this.ctoken="0-1"; ni = ni + 2 ;break ;}
}
}
if (x == '1')
{
if ((ni + 2) <= this.ngamesize)
{
if ((this.cgame.charAt(ni + 1) == '-') && (this.cgame.charAt(ni + 2) == '0'))
{this.ctoken="1-0"; ni = ni + 2 ; break ;}
}
if ((ni + 6) <= this.ngamesize)
{
if (this.cgame.substr(ni,7) == '1/2-1/2') {this.ctoken="1/2-1/2"; ni = ni + 6 ; break ;}
}
}
if (x.match(NUMB)){this.nstate = BPGN_INTEGER ; ctmp = x ;continue ;}
if (x == ';'){this.nstate = BPGN_COMMENT1 ;ctmp=""; break ;}
if (x == '{'){this.nstate = BPGN_COMMENT2 ;ctmp="{" ;break ;}
if (x == '$'){this.nstate = BPGN_NAG ;ctmp="$" ;continue ;}
if (x.match(LETT)){this.nstate = BPGN_SYMBOL ;ctmp = x ; continue ;}
}
// string token state
if (this.nstate == BPGN_STRING)
{
if (x == '\\')
{
if (ni < this.ngamesize)
{ni = ni + 1 ;
if (this.cgame.charAt(ni) == '"') {cttt = this.cgame.charAt(ni) ; ctmp+=cttt ; continue ;}
if (this.cgame.charAt(ni) == '\\') {cttt = this.cgame.charAt(ni) ;ctmp+=cttt ;continue ;}
cttt = '\\' ;cttt += this.cgame.charAt(ni) ;ctmp+=cttt ;continue ;
}
cttt = this.cgame.charAt(ni) ;ctmp +=cttt ; break ;
}
if (this.cgame.charAt(ni) == '"') break ;
cttt = this.cgame.charAt(ni) ; ctmp +=cttt ; continue ;
}
// integer token state
if (this.nstate == BPGN_INTEGER)
{
if ((this.cgame.charAt(ni) >= '0') && (this.cgame.charAt(ni) <= '9'))
{cttt = this.cgame.charAt(ni) ;ctmp+=cttt ;continue ;}
ni = ni - 1 ;break ;
}
// comment token state
if (this.nstate == BPGN_COMMENT2)
{
if ((this.cgame.charAt(ni)==CR_ASCII_NUM)||(this.cgame.charAt(ni)==LF_ASCII_NUM)) continue ;

if (this.cgame.charAt(ni) == '}'){this.nstate = BPGN_NORMAL ;this.ctoken=ctmp ;ni = ni - 1 ;break ;}
cttt = this.cgame.charAt(ni) ; ctmp += cttt ; continue ;
}
// NAG (Numeric Annotation Glyph) token state
if (this.nstate == BPGN_NAG)
{ if ((this.cgame.charAt(ni) >= '0') && (this.cgame.charAt(ni) <= '9'))
{cttt = this.cgame.charAt(ni) ;ctmp+= cttt ;continue ;}
ni = ni - 1 ; break ;
}
// symbol token state
if (this.nstate == BPGN_SYMBOL)
{
if ((this.cgame.charAt(ni) == ' ') || (this.cgame.charAt(ni) == TAB_ASCII_NUM)|| (this.cgame.charAt(ni)==CR_ASCII_NUM)||(this.cgame.charAt(ni)==LF_ASCII_NUM)) break ;
if (x.match(SYMB)) { cttt = x; ctmp=ctmp+cttt ; continue ;}
ni = ni - 1 ;break ;
}
}
// set BPGN state
// introduce this.nlaststate
this.nlaststate = this.nstate ;
if ((this.nstate == BPGN_STRING ) ||
(this.nstate == BPGN_INTEGER ) ||
(this.nstate == BPGN_COMMENT1) ||
(this.nstate == BPGN_NAG ) ||
(this.nstate == BPGN_SYMBOL ) ||
(this.nstate == BPGN_COMMENT1))
{
this.nstate = BPGN_NORMAL ;
this.ctoken= ctmp ;
}
else
if (this.nstate == BPGN_COMMENT2) this.ctoken=ctmp ;
if (this.ctoken.length > 0) break ;
}
this.ngameindex = ni + 1 ;
return (this.ctoken.length > 0) ;
}

// is the current token a note?
function bpgnisnote()
{
if (this.ctoken.length < 3) return false ;
return ((this.ctoken.charAt(0)==BPGN_NOTE) && (this.ctoken.charAt(1)== ':')) ;
}

// is the current token an annotation?
function bpgnisannotation ()
{
if (this.ctoken.length < 3) return false ;
return ((this.ctoken.charAt(0)== BPGN_ANNOTATION) && (this.ctoken.charAt(1)==':')) ;
}

// get move
function bpgngetmove (nmovea, nmoveb,aside)
{
var nmove;
var bboarda1;
var bboarda2;
var bboardb1;
var bboardb2 ;
var cboard;
// document.writeln('getmove recieves: '+nmovea+':'+nmoveb+':'+aside);
if (!this.gettoken()) {this.nError = ERROR_NONE ;return true;};
if ((this.nlaststate == BPGN_NORMAL) && (this.ctoken=="(")) {return '(';};
if ((this.nlaststate == BPGN_NORMAL) && (this.ctoken==")")) {return ')';};
if (this.nlaststate == BPGN_COMMENT2) // '{' symbol
{
if (! this.gettoken ()) {return false ;};
if (this.nlaststate != BPGN_NORMAL) {return false;};
// maybe it's a game result?
if (this.bpgngetresult ()) {return 'res' ;} else {return false ;};
};
if (this.nlaststate != BPGN_INTEGER) //we assume that it is move on board 'A'
{
this.BPGN_InsertQueue(this.nlaststate,this.ctoken);
nmove=nmovea;
}
// convert move number into integer
else nmove = parseInt(this.ctoken);
if (! this.gettoken ()) // missing board symbol (i.e. must be 'A', 'a', 'B', or 'b')
{return false ;};
if (this.nlaststate != BPGN_SYMBOL) // invalid board symbol (i.e. must be 'A', 'a', 'B', or 'b')
{/*forget about it we insert it later*/};

bboarda1 = ((this.ctoken=='A'))? true: false;
bboarda2 = ((this.ctoken=='a'))? true: false;
bboardb1 = ((this.ctoken=='B'))? true: false;
bboardb2 = ((this.ctoken=='b'))? true: false;
if ((! bboarda1) && (! bboarda2) && (! bboardb1) && (! bboardb2)) // invalid board symbol (i.e. must be 'A', 'a', 'B', or 'b')
{
//lets assume that board is 'a' or 'A' and put the token back. before was return false
this.BPGN_InsertQueue(this.nlaststate,this.ctoken);
if (aside=='a') {bboarda2=true} else {bboarda1=true};
};
if (bboarda1)
{
if (nmovea != nmove) // invalid move number
if (this.afirstmove) {return false ;}
cboard ='A' ;
};
if (bboarda2)
{
if (nmovea != nmove) // invalid move number
if (this.afirstmove) {return false ;};
cboard = 'a' ;
};
if (bboardb1)
{
if (nmoveb != nmove) // invalid move number
if (this.bfirstmove) {return false ;};
cboard ='B';
};
if (bboardb2)
{
if (nmoveb != nmove)
if (this.bfirstmove) {return false ;};
cboard = 'b' ;
};
if (! this.gettoken ()) // missing '.'
{return false ;};
if (this.ctoken!=BPGN_MOVE_DSTR) // no '.' let's forget it
{
this.BPGN_InsertQueue(this.nlaststate,this.ctoken);
};
if (!this.gettoken()) // missing move
{return false ;};
if (this.nlaststate != BPGN_SYMBOL) // invalid move
{return false ;};
// save move number, board, and move string
var tmp=nmove+cboard+BPGN_MOVE_DSTR+' '+this.ctoken;
// document.writeln(' getmove returns '+tmp+'<br>');
return (tmp) ;
}

// get time
function bpgngettime ()
{
var ct;var lt;
if (! this.gettoken ()) // missing time
{return false;};
if (this.nlaststate != BPGN_COMMENT2) // '{' symbol invalid time
{
//We assume that somebody was too lazy to include time. Let's pretend that it's there put the token back
this.BPGN_InsertQueue(this.nlaststate,this.ctoken);
return BPGN_OMITED_TIME;
};
if (! this.gettoken ()) // missing time
{return false ;};
if (this.nlaststate != BPGN_NORMAL) // invalid time, probably comment
{
this.BPGN_InsertQueue(this.nlaststate,this.ctoken);
this.BPGN_InsertQueue(BPGN_COMMENT2,'{');
return BPGN_OMITED_TIME;
};// save time
ct=this.ctoken ;
lt=this.nlaststate;
if (! this.gettoken ()) // missing '}'
{return false;};
if (this.ctoken!="}") // expecting '}' but we got something else
{
this.BPGN_InsertQueue(this.nlaststate,this.ctoken);
this.BPGN_InsertQueue(lt,ct);
this.BPGN_InsertQueue(BPGN_COMMENT2,'{');
return BPGN_OMITED_TIME;
};
// nError = ERROR_NONE ;
return parseInt(ct);
}

// get result
function bpgngetresult ()
{
var nTemp;
var cTemp;
nTemp = this.nlaststate ;
cTemp=this.ctoken;
if (!this.gettoken ()) // incomplete file
{ return false ;};
if (this.nlaststate != BPGN_NORMAL) // expecting '}'
{return false ;};
if (this.ctoken!="}") // expecting '}'
{return false ;}
if (! this.gettoken ()) // incomplete file
{return false ;};
if (this.nlaststate != BPGN_NORMAL) // expecting game result
{return false ;};
if ((this.ctoken!=BPGN_WHITE_WINS) &&
(this.ctoken!=BPGN_BLACK_WINS) &&
(this.ctoken!=BPGN_DRAW) &&
(this.ctoken!=BPGN_UNKNOWN)) // invalid game result
{return false ;};
// copy results
this.cResult1=cTemp;
this.cResult2=this.ctoken;
this.bfinish = true ;
return true;
}

// get note
function bpgngetnote ()
{
var bNote; var bAnno ;
if (! this.gettoken ()) // incomplete file
{return false ;};
if (this.nlaststate != BPGN_NORMAL) // not a note
{return false ;};
bNote = this.bpgnisnote ();
bAnno = this.bpgnisannotation () ;
if ((! bNote) && (! bAnno))
{// maybe it's a game result?
if (this.bpgngetresult ())
{return true;};
return false ;
}
// yes, it's a note or annotation lets save it
this.note=this.ctoken.substr(2) ;
this.bIsNote= (bNote)?true:false;
if (! this.gettoken ())// incomplete file
{return false ;};
if (this.nlaststate != BPGN_NORMAL) // expecting '}'
{return false ;};
if (this.ctoken!="}") // expecting '}'
{return false ;};
return true;
}

function bpgngetfirstnote ()
{
// there can be a note before the game starts so lets scan for it
if (this.gettoken ())
{
if (this.nlaststate == BPGN_COMMENT2) // '{' symbol
{// get note before game start (if any)
if (this.bpgngetnote ())
{
if (this.bfinish) // finish
{ }
else
{
if (this.bIsNote) // save the note
{this.BPGN [BPGN_ROOT].cNote=this.note;}
else // invalid annotation
{this.nError = ERROR_INVALID_ANNOTATION ;};
};
};
}
else // no, there is no note before the game starts so lets put the token back
{this.BPGN_InsertQueue (this.nlaststate, this.ctoken) ;};
};
return (this.nError == ERROR_NONE) ;
}

function getboard (move)
{
if (move.length)
{
var i=move.indexOf(BPGN_MOVE_DSTR);
return (i>0)? (move.charAt(i-1)): false;
}
else return false;
}

function stuffnode(nNewIndex,nParent,nMove,cBoard,cMove,cTime,cAnno,cNote)
{
this.BPGN[nNewIndex].nParent = nParent ;
this.BPGN[nNewIndex].nMove = nMove;
this.BPGN[nNewIndex].cBoard = cBoard ;
this.BPGN[nNewIndex].cMove=cMove;
this.BPGN[nNewIndex].cTime=cTime ;
this.BPGN[nNewIndex].cAnno=cAnno;
this.BPGN[nNewIndex].cNote=cNote;
// hook up with parent
nNext=this.BPGN[nParent].nNext.length;
this.BPGN[nParent].nNext[nNext]=nNewIndex ;
// this.BPGN[nNewIndex].dmove=false;
}

function dispqueue()
{
var ln=this.Queue.length;
var i;
document.writeln('Queue is of length '+ln+' <br>');
for (i=0;i<ln;i++) document.writeln('#'+i+'|token '+this.Queue[i].cToken+'|laststate '+this.Queue[i].nlaststate+'<br>');
}

function getmoven(move)
{
if (move.length)
{
var i=move.indexOf(BPGN_MOVE_DSTR);
if (i<2) return false;
var mv=move.substring(0,i-1);
return parseInt(mv);
}
else return false;
}

function getside(move)
{
var i=move.indexOf(BPGN_MOVE_DSTR);
if (i<2) return false;
return move.charAt(i-1);
}

function changeturnside(side)
{
if (side==side.toLowerCase()) {return side.toUpperCase();}
else {return side.toLowerCase();};
}

function BPGN_GetBody (nParent,nMoveA,nMoveB,aside)
{
var nMove ;
var cBoard ;
var cMove;
var cTime ;
var cAnno;
var cNote;
var cTemp1;
var cTemp2 ;
var bHasNote;
var bHasAnno; var bIsNote1; var bIsNote2;
var nNewIndex =-1;
var nI; var nNext ;
var cLastBoard= BPGN_BOARD_A1 ;
var nMA; var nMB ;
var aaside

while (true)
{
cMove=this.bpgngetmove(nMoveA, nMoveB,aside);
if (cMove==false) break;
cBoard=getboard(cMove);
nMove=getmoven(cMove);
if (((cBoard=='a')||(cBoard=='A'))&&(!this.afirstmovea)) {nMoveA=nMove;this.afirstmovea=true};
if (((cBoard=='b')||(cBoard=='B'))&&(!this.bfirstmovea)) {nMoveB=nMove;this.bfirstmovea=true};
if (nMove!=false)
{
if ((cBoard=='a')||(cBoard=='A')) {aside=changeturnside(aside)};
};

if (this.bfinish) {break ;};
if (cMove=="(")// variation
{
if (cLastBoard == BPGN_BOARD_A2)
{nMA = nMoveA - 1 ; nMB = nMoveB ;}
else
if (cLastBoard == BPGN_BOARD_B2)
{nMA = nMoveA ;nMB = nMoveB - 1 ;}
else
{nMA = nMoveA ;nMB = nMoveB ;};

if ((cLastBoard=='a')||(cLastBoard=='A')) {aaside=changeturnside(aside)} else {aaside=aside};
if (this.BPGN_GetBody (nParent, nMA, nMB,aaside))
{
if (this.ctoken=")") {continue ;}
else
{this.nError = ERROR_MISSING_END_VARIATION ;
this.cError= "expecting ')' but got "+ this.ctoken ;
break ;
}
}
else {break ;}
}
else
{ // new to F4.C
if (nNewIndex != -1) {nParent = nNewIndex ;};
};

if (cMove== ")") break ;


cTime=this.bpgngettime();
if (!cTime) {break};
bHasNote = false ;
bHasAnno = false ;

if (this.gettoken ())
{
if (this.nlaststate == BPGN_COMMENT2) // '{' symbol
{ // get note or annotation
if (!this.bpgngetnote ()) {break} ;
bIsNote1=this.bIsNote;
cTemp1=this.note;
if (this.bfinish)
{// get new node index
nNewIndex=this.BPGN_GetNewNode();
// stuff new node
this.stuffnode(nNewIndex,nParent,nMove,cBoard,cMove,cTime,'','');
break ;
};

if (bIsNote1) {bHasNote = 1 ; bHasAnno = 0 ;}
else {bHasNote = 0 ;bHasAnno = 1 ;};
if (this.gettoken ())
{
if (this.nlaststate == BPGN_COMMENT2) // '{' symbol
{ // get note or annotation
if (! this.bpgngetnote ()) {break ;};
bIsNote2=this.bIsNote;
cTemp2=this.note;
if (this.bfinish)
{ // get new node index
nNewIndex=this.BPGN_GetNewNode ();
// stuff new node
this.stuffnode(nNewIndex,nParent,nMove,cBoard,cMove,cTime,'','');

if (bHasNote) {this.BPGN [nNewIndex].cNote=cTemp1}
else {this.BPGN[nNewIndex].cNote=""} ;
if (bHasAnno) {this.BPGN [nNewIndex].cAnno=cTemp1}
else {this.BPGN[nNewIndex].cAnno=""};

break ;
};
if (bHasNote)
{
if (bIsNote2) {this.nError = ERROR_DOUBLE_NOTE ;this.cError="" ;break ;}
else {bHasAnno = 1 ;};
}
else
if (bHasAnno)
{
if (bIsNote2) {bHasNote = 1 ;}
else {this.nError = ERROR_DOUBLE_ANNOTATION ;this.cError="";break ;};
};
}
else
if ((this.nlaststate == BPGN_NORMAL) && (this.ctoken=="("))
{ // get new node index
nNewIndex=this.BPGN_GetNewNode ();
this.stuffnode(nNewIndex,nParent,nMove,cBoard,cMove,cTime,'','');

if (bHasNote){this.BPGN[nNewIndex].cNote=cTemp1 ;this.BPGN[nNewIndex].cAnno="";}
else
if (bHasAnno){this.BPGN [nNewIndex].cNote="" ; this.BPGN [nNewIndex].cAnno=cTemp1;}
else {this.BPGN[nNewIndex].cNote="";this.BPGN[nNewIndex].cAnno="";};

// advance move counter
cLastBoard = cBoard ;
if (cBoard == BPGN_BOARD_A2){nMoveA = nMoveA + 1 ;}
else
if (cBoard == BPGN_BOARD_B2){nMoveB = nMoveB + 1 ;};

// variation
if (cLastBoard == BPGN_BOARD_A2) {nMA = nMoveA - 1 ; nMB = nMoveB ;}
else
if (cBoard == BPGN_BOARD_B2) {nMA = nMoveA ;nMB = nMoveB - 1 ;}
else {nMA = nMoveA ;nMB = nMoveB ;};

if ((cLastBoard=='a')||(cLastBoard=='A')) {aaside=changeturnside(aside)} else {aaside=aside};
if (this.BPGN_GetBody (nParent, nMA, nMB,aaside))
{
if (this.ctoken==")")
{
// new to F4.C look ahead
if (this.gettoken ())
{
if (this.ctoken=="(") {this.BPGN_InsertQueue (this.nlaststate, this.ctoken) ;}
else // assign new parent
{this.BPGN_InsertQueue (this.nlaststate,this.ctoken) ; nParent = nNewIndex ;};
}
else {nParent = nNewIndex ;};
continue ;
}
else
{
this.nError = ERROR_MISSING_END_VARIATION ;
this.cError ="expecting ')' but got "+ this.ctoken ;
break ;
};
}
else {break ;};
}
else // no note or annotation
{this.BPGN_InsertQueue (this.nlaststate, this.ctoken);};
}
else {/* no more*/ break ;};
}
else
if ((this.nlaststate == BPGN_NORMAL) && (this.ctoken=="("))
{// get new node index
nNewIndex=this.BPGN_GetNewNode ();
this.stuffnode(nNewIndex,nParent,nMove,cBoard,cMove,cTime,'','');

// advance move counter
cLastBoard = cBoard ;
if (cBoard == BPGN_BOARD_A2){nMoveA = nMoveA + 1 ;}
else
if (cBoard == BPGN_BOARD_B2) {nMoveB = nMoveB + 1 ;};

// variation
if (cLastBoard == BPGN_BOARD_A2) {nMA = nMoveA - 1 ;nMB = nMoveB ;}
else
if (cBoard == BPGN_BOARD_B2) {nMA = nMoveA ;nMB = nMoveB - 1 ;}
else{nMA = nMoveA ;nMB = nMoveB ;};

if ((cLastBoard=='a')||(cLastBoard=='A')) {aaside=changeturnside(aside)} else {aaside=aside};
if (this.BPGN_GetBody (nParent, nMA, nMB,aaside))
{
if (this.ctoken==")")
{// new to F4.C look ahead
if (this.gettoken ())
{
if (this.ctoken=="(") {this.BPGN_InsertQueue (this.nlaststate, this.ctoken) ;}
else // assign new parent
{this.BPGN_InsertQueue (this.nlaststate,this.ctoken) ; nParent = nNewIndex ;};
}
else {nParent = nNewIndex ;};
continue ;
}
else
{
this.nError = ERROR_MISSING_END_VARIATION ;
this.cError="expecting ')' but got "+ this.ctoken ;
break ;
};
}
else {break ;};
}
else {/* no note or annotation */ this.BPGN_InsertQueue (this.nlaststate, this.ctoken);};
}
else // no more
{break ;};

nNewIndex=this.BPGN_GetNewNode ();
this.stuffnode(nNewIndex,nParent,nMove,cBoard,cMove,cTime,'','');
if (bHasNote)
{
if (bIsNote1) {this.BPGN [nNewIndex].cNote=cTemp1 }
else
if (bIsNote2){this.BPGN [nNewIndex].cNote= cTemp2}
else {this.BPGN [nNewIndex].cNote="" ;}
}
else {this.BPGN [nNewIndex].cNote="" ;};

if (bHasAnno)
{
if (!bIsNote1){this.BPGN[nNewIndex].cAnno=cTemp1}
else
if(! bIsNote2){this.BPGN[nNewIndex].cAnno=cTemp2}
else {this.BPGN [nNewIndex].cAnno="";}
}
else {this.BPGN [nNewIndex].cAnno="";};

// advance move counter
cLastBoard = cBoard ;
if (cBoard == BPGN_BOARD_A2) {nMoveA = nMoveA + 1 ;}
else
if (cBoard == BPGN_BOARD_B2)
{nMoveB = nMoveB + 1 ;};


// new to F4.C look ahead
if (this.gettoken ())
{
if (this.ctoken=="(") {this.BPGN_InsertQueue (this.nlaststate, this.ctoken) ;}
else // assign new parent
{this.BPGN_InsertQueue (this.nlaststate,this.ctoken) ; nParent = nNewIndex ;};
}
else {nParent = nNewIndex ;};
};//end of while
return (this.nError == ERROR_NONE)
}

function BPGN_SaveAnno(nNode)
{
var nA; var nL; var nI;
var cTmp;
var nA = this.BPGN[nNode].cAnno.length ;
if (nA == 0) return ;
nL = this.cSaveGameString.length;
if (this.cSaveGameString.charAt(nL-1)==' ')
{
if ((nL + 4) > BPGN_LINE_SIZE) {this.sgame+=this.cSaveGameString+'\n';this.cSaveGameString="";};
}
else
{
if ((nL + 4 + 1) > BPGN_LINE_SIZE){this.sgame+=this.cSaveGameString+'\n';this.cSaveGameString="";}
else{if (this.cSaveGameString.length>0) this.cSaveGameString+=" ";};
}
this.cSaveGameString+="{A:";
for (nI = 0 ; nI < nA ; nI++)
{
if (this.cSaveGameString>=BPGN_LINE_SIZE) {this.sgame+=this.cSaveGameString+'\n';this.cSaveGameString="";};
cTmp =this.BPGN[nNode].cAnno.charAt(nI);
if ((cTmp==' ')&&(cSaveGameString.length+1==BPGN_LINE_SIZE)) {this.sgame+=this.cSaveGameString+'\n';this.cSaveGameString="";};
this.cSaveGameString+=cTmp;
};
nL = this.cSaveGameString.length;
if ((nL + 1)>BPGN_LINE_SIZE) {this.sgame+=this.cSaveGameString+'\n';this.cSaveGameString="";};
this.cSaveGameString+="}";
}

function assdelete(viewer)
{
v=eval(viewer);
if (v.currentmove==BPGN_ROOT) return;
v.BPGN_DeleteCurrentMove(v.currentmove);
v.undomove();
}

function BPGN_DeleteCurrentMove (nCurrent)
{
var nI; var nN; var nP ;var ln; var tmp;
// unhook parent's next move to nCurrent
nP = this.BPGN[nCurrent].nParent;

// new to F4.C
// make sure one's parent is an ok index
if (nP < 0) return ;
if (nP >= this.BPGN.length) return ;
// look for parent's next move pointing to nCurrent
ln=this.BPGN[nP].nNext.length;
for (nI = 0 ; nI < ln; nI++) {if (this.BPGN [nP].nNext [nI] == nCurrent) {tmp=nI; break;};};
for (nI=tmp;nI<ln-2;nI++) {this.BPGN[nP].nNext[nI] = this.BPGN[nP].nNext[nI+1];};
this.BPGN[nP].nNext[ln-1]=false; this.BPGN[nP].nNext.length=ln-1;
}


function BPGN_SaveTime (nNode)
{var cTmp;var nL;var nT ;
// save game time
cTmp="{"+ this.BPGN[nNode].cTime+"} ";
nL = this.cSaveGameString.length;
nT = cTmp.length;
if (this.cSaveGameString.charAt(nL-1)==' ')
{
if ((nL + nT) > BPGN_LINE_SIZE) {this.sgame+=this.cSaveGameString+'\n';this.cSaveGameString="";};
}
else
{
if ((nL + nT + 1) > BPGN_LINE_SIZE) {this.sgame+=this.cSaveGameString+'\n';this.cSaveGameString="";}
else {if (this.cSaveGameString.length > 0) this.cSaveGameString+=" ";};
};
this.cSaveGameString+=cTmp;
}

function BPGN_SaveMove (nNode)
{
var cTmp;var nL; var nT ;
// save game move
cTmp=this.BPGN[nNode].cMove;
nL =this.cSaveGameString.length;
nT =cTmp.length;
if ((this.cSaveGameString.charAt(nL-1)==' ')||(this.cSaveGameString.charAt(nL-1)=='('))
{
if ((nL + nT) > BPGN_LINE_SIZE)
{this.sgame+=this.cSaveGameString+'\n';this.cSaveGameString="";};
}
else
{
if ((nL + nT + 1) > BPGN_LINE_SIZE) {this.sgame+=this.cSaveGameString+'\n';this.cSaveGameString="";}
else {if (this.cSaveGameString>0) this.cSaveGameString+=" ";};
};
this.cSaveGameString+=cTmp;
}

function BPGN_SaveNote(nNode)
{
var nC;var nL;var nI;
var cTmp;
nC=this.BPGN[nNode].cNote.length;
if (nC == 0) return false;
nL=this.cSaveGameString.length;
if (this.cSaveGameString.charAt(nL-1)==' ')
{
if ((nL + 4) > BPGN_LINE_SIZE)
{this.sgame+=this.cSaveGameString+'\n';this.cSaveGameString="";};
}
else
{
if ((nL+4+1)>BPGN_LINE_SIZE)
{this.sgame+=this.cSaveGameString+'\n';this.cSaveGameString="";}
else
{if (this.cSaveGameString.length>0) this.cSaveGameString+=" ";};
};
this.cSaveGameString+="{C:";
for (nI=0;nI<nC;nI++)
{
if(this.cSaveGameString.length>=BPGN_LINE_SIZE) {this.sgame+=this.cSaveGameString;this.cSaveGameString="";};
cTmp=this.BPGN[nNode].cNote.charAt(nI);
if (this.cSaveGameString.length + 1>=BPGN_LINE_SIZE)
{this.sgame+=this.cSaveGameString+'\n';this.cSaveGameString="";};
this.cSaveGameString+=cTmp;
};
nL=this.cSaveGameString.length;
if((nL + 1) > BPGN_LINE_SIZE){this.sgame+=this.cSaveGameString+'\n';this.cSaveGameString="";};
this.cSaveGameString+="}";
return true;
}

function BPGN_SaveBody (nNode)
{
var nMain;var nI; var nN; var nL;
// must be a valid index
if ((nNode < 0)||(nNode >=this.BPGN.length)) return ;
// node must be in use
if (!this.BPGN[nNode]) return;

// find the node's next move main line and produce move, time, annotation, and note
nMain = -1 ;
for (nI=0;nI<this.BPGN[nNode].nNext.length;nI++)
{
nN=this.BPGN[nNode].nNext[nI];
if ((nN > 0) && (nN <this.BPGN.length))
{
nMain = nN ;
this.BPGN_SaveMove(nMain);
this.BPGN_SaveTime(nMain);
this.BPGN_SaveAnno(nMain);
this.BPGN_SaveNote(nMain);
break ;
};
};

// process the nodes' variation line and produce move, time, annotation, and note
for (nI = 0 ; nI <this.BPGN[nNode].nNext.length; nI++)
{
// get nNode's variation next move index
nN = this.BPGN[nNode].nNext[nI];
// must be a valid index
if ((nN <= 0)||(nN >=this.BPGN.length)) continue ;

// must not be the nNode's main line next move
if (nN == nMain) continue ;
// begin variation --> add a '(' symbol
nL = this.cSaveGameString.length;
if (this.cSaveGameString.charAt(nL-1)==' ')
{
if ((nL + 1)>BPGN_LINE_SIZE){this.sgame+=this.cSaveGameString+'\n';this.cSaveGameString="";};
}
else
{
if ((nL + 1 + 1) > BPGN_LINE_SIZE) {this.sgame+=this.cSaveGameString+'\n';this.cSaveGameString="";}
else {this.cSaveGameString+=" " ;};
};
this.cSaveGameString+="(";

// process nNode's sibling move
this.BPGN_SaveMove(nN);
this.BPGN_SaveTime(nN);
this.BPGN_SaveAnno(nN);
this.BPGN_SaveNote(nN);
// continue the variation processing
this.BPGN_SaveBody(nN);
// end variation --> add a ')' symbol
if (this.cSaveGameString.length+1>BPGN_LINE_SIZE){this.sgame+=this.cSaveGameString+'\n';this.cSaveGameString="";};
this.cSaveGameString+=")";
};
// process nNode's main line's next move
if (nMain != -1) {this.BPGN_SaveBody (nMain);};
}

function BPGN_SaveGame ()
{
var nL;
this.cSaveGameString='';
this.sgame='';
this.sgame+='[Event "'+this.gameevent+'"]\n';
this.sgame+='[Site "'+this.gamesite+'"]\n';
this.sgame+='[Date "'+this.gamedate+'"]\n';
this.sgame+='[WhiteA "'+this.whitea+'"][WhiteAElo "'+this.whiteaelo+'"]\n';
this.sgame+='[BlackA "'+this.blacka+'"][BlackAElo "'+this.blackaelo+'"]\n';
this.sgame+='[WhiteB "'+this.whiteb+'"][WhiteBElo "'+this.whitebelo+'"]\n';
this.sgame+='[BlackB "'+this.blackb+'"][BlackBElo "'+this.blackbelo+'"]\n';
this.sgame+='[TimeControl "'+this.timecontrol+'"]\n';
this.sgame+='[Result "'+this.gameresult+'"]\n';
this.sgame+='\n';
// check for before game start note
if (this.BPGN_SaveNote(BPGN_ROOT))
{
nL=this.cSaveGameString.length;
if (nL > 0){this.sgame+=this.cSaveGameString+'\n';this.cSaveGameString="";};
};
// save rest of the game
this.BPGN_SaveBody (BPGN_ROOT) ;
// save remaining line
if (this.cSaveGameString.length>0) {this.sgame+=this.cSaveGameString;};
this.sgame+='\n';
// save BPGN game result
this.sgame+='{'+this.cResult1+'} '+this.cResult2+'\n';
}




function assmdown(ind,viewer,bd)
{
var v=eval(viewer);
v.mdown(ind,bd);
return false;
}

function assmup(ind,viewer,bd)
{var v=eval(viewer);
v.mup(ind,bd);
return false;
}

function assclick(ind,viewer,bd)
{var v=eval(viewer);
if (v.movestart=='') {v.mdown(ind,bd);} else {v.mup(ind,bd);};
return false;
}

function tobpgn(mv)
{
var bd=mv.board; var wh=mv.side; var p=mv.frompiece.charAt(1); var c=''; var fr=mv.fromsquare; var prom='';
if (wh=='w') {bd=bd.toUpperCase();};
if (fr=='o-o-o') {return (bd+'.o-o-o');};
if (fr=='o-o') {return (bd+'.o-o');};
fr=((fr<64)?indtosq(fr):'@');
if (p!='p') {p=p.toUpperCase();} else {if (fr!='@') {p='';};};
if (mv.topiece!='') {c='x'};
if ((mv.frompiece.length==3)&&(mv.frompiece.charAt(2)!='x')) {prom='='+mv.frompiece.charAt(2);prom=prom.toUpperCase();};
return (bd+'.'+p+fr+c+indtosq(mv.tosquare)+prom);
}


function mdown(ind,bd)
{
var src;
if (this.displaymode=='diagram') {return;};
var out=eval('document.'+this.viewername+'.lastmove'+bd);
var tbd=eval('this.'+bd);
var c='';
if ((ind<0)||(ind>73)) return;
if (ind<64) {
ind=indtoind(ind,tbd.flip);
if (tbd.isempty(ind)) return;
if (tbd.pos[ind].charAt(0)!=whosmove(tbd.turn)) return;
src=indtosq(ind);
c=tbd.pos[ind].charAt(1);
if (c=='p') {c='';};
this.movestart=bd+c+src;
out.value=tbd.turn+'.'+(this.movestart.substr(1,this.movestart.length));
return;
};
ind=ind-64;
if (tbd.flip!=0) {ind=9-ind;};
if (whosmove(tbd.turn)!=tbd.dropbar[ind].charAt(0)) {return;};
this.movestart=bd+tbd.dropbar[ind].charAt(1)+'@';
out.value=tbd.turn+'.'+(this.movestart.substr(1,this.movestart.length));
return;
}

function mup(ind,bd)
{
if (this.displaymode=='diagram') {return;};
var tmp=this.movestart; var dest;
var out=eval('document.'+this.viewername+'.lastmove'+bd);
this.movestart='';
out.value='';
var tbd=eval('this.'+bd);
if (tmp.charAt(0)!=bd) return;
tmp=tmp.substr(1,tmp.length);
if ((ind<0)||(ind>63)) return;
ind=indtoind(ind,tbd.flip);
dest=indtosq(ind);
tmp+=dest;
tmp=tmp.toLowerCase();
if ((tmp=='ke1g1')||(tmp=='ke8g8')) {tmp='o-o';};
if ((tmp=='ke1c1')||(tmp=='ke8c8')) {tmp='o-o-o';};
if ((tmp.charAt(0)=='p')&&(tmp.charAt(1)!='@')) {tmp=tmp.substr(1,tmp.length)};
this.execmove(bd,tmp);
}

function getbpgnheaders(bpgntext)
{
//first initialize properties that come from bpgn header
this.gameevent=bpgnheader(bpgntext,BPGN_EVENT);
if (this.gameevent=='') {this.gameevent="bughouse match"};
this.gamedate=bpgnheader(bpgntext,BPGN_DATE);
if (this.gamedate=='') {
var the_date = new Date();
this.gamedate=the_date.getYear()+'.'+fixnumber(the_date.getMonth())+'.'+fixnumber(the_date.getDate())};
this.gamesite=bpgnheader(bpgntext,BPGN_SITE);
if (this.gamesite=='') {this.gamesite=DEFAULT_SITE};
this.timecontrol=bpgnheader(bpgntext,BPGN_TIMECTRL);
if (this.timecontrol=='') {this.timecontrol=DEFAULT_TIME+'+'+DEFAULT_INC};
var tmp=this.timecontrol.split('+');
this.gametime=parseInt(tmp[0]); /* numerical: seconds per game, maybe redundant */
if (this.gametime==NaN) {this.gametime=eval(DEFAULT_TIME)};
this.gameinc=parseInt(tmp[1]); /* numerical: time increment */
if (this.gameinc==NaN) {this.gameinc=eval(DEFAULT_INC);};
this.gameresult=bpgnheader(bpgntext,BPGN_RESULT);
if (this.gameresult=='') {this.gameresult=DEFAULT_RESULT};

this.whitea=bpgnheader(bpgntext,BPGN_WHITEA);
if (this.whitea=='') {this.whitea=DEFAULT_WHITEA};
this.blacka=bpgnheader(bpgntext,BPGN_BLACKA);
if (this.blacka=='') {this.blacka=DEFAULT_BLACKA};
this.whiteb=bpgnheader(bpgntext,BPGN_WHITEB);
if (this.whiteb=='') {this.whiteb=DEFAULT_WHITEB};
this.blackb=bpgnheader(bpgntext,BPGN_BLACKB);
if (this.blackb=='') {this.blackb=DEFAULT_BLACKB};

this.whiteaelo=bpgnheader(bpgntext,BPGN_WHITEAELO);
if (this.whiteaelo=='') {this.whiteaelo=DEFAULT_RATING};
this.blackaelo=bpgnheader(bpgntext,BPGN_BLACKAELO);
if (this.blackaelo=='') {this.blackaelo=DEFAULT_RATING};
this.whitebelo=bpgnheader(bpgntext,BPGN_WHITEBELO);
if (this.whitebelo=='') {this.whitebelo=DEFAULT_RATING};
this.blackbelo=bpgnheader(bpgntext,BPGN_BLACKBELO);
if (this.blackbelo=='') {this.blackbelo=DEFAULT_RATING};
return true;
}

function drawboard() /* generates html for the board */
{
var size=this.sqsize;
var sqsize='width="'+size+'" height="'+size+'"';
var tago="<b>";
var tagc="</b>"; /*opening and closing tags to emphasize players handle and ratings (and times) */
var up;
var u;
var d;
var dn;
var s;var k;
var bd=this.boardname;
if (this.flip==1) { up="white"; u="w"; dn="black"; d="b" } else {up="black";dn="white"; u="b"; d="w"}
var tmp='';
tmp=tmp+'<table border="0" cellpadding="0" width="100%">';
tmp=tmp+'<tr> <td align="center" valign="bottom">';
if (this.reloadmode=="noreload")
{tmp=tmp+tago+eval('this.'+up)+' '+this.rdo+eval('this.'+up+'elo')+ this.rdc + tagc }
else {tmp=tmp+' <input type="text" size="25" name="up'+bd+'" onFocus="this.blur();"> '};
tmp=tmp+'</td> <td align="right" valign="bottom">';
tmp+='<image src="'+this.gifs["nmv"]+'" width="24" height="20" name ="'+this.viewername+'upmv'+bd+'">';
if ((this.reloadmode=="noreload")&& (this.displaymode=="diagram"))
{ tmp=tmp+tago;
tmp=tmp+" "+totime(eval('this.'+u+'clock'))+tagc;
}
else {tmp=tmp+' <input type="text" size="5" name="'+'upclock'+bd+'" onFocus="this.blur();"> '};
tmp=tmp+'</td> </tr> </table>';
tmp=tmp+ '<center><table border="1"> <tr> <td rowspan="2">';
var t="";
var i;
var j;
var objn=this.viewername+'.'+bd;
var ind;
t+='<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 COLS=8>';
for (i=0; i<8;i++)
{
t+='<tr>';
for (j=0; j<8 ; j++)
{ ind=8*i+j;
t+='<td '+ ((this.filebg)?'BACKGROUND="':'BGCOLOR="')+ ((i + j) % 2 ? this.gifs["b"] : this.gifs["w"]);
t+='"><a href="javascript:void(0)" onClick="assclick('+ind+",'"+this.viewername+"','"+bd+"');"+'"><img src="'+this.gifs["d"]+'" border="0"'+sqsize+'></a></td>';
};
/* onMouseDown="assmdown('+ind+",'"+this.viewername+"','"+bd+"');"+'" onMouseUp="assmup('+ind+",'"+this.viewername+"','"+bd+"');"+'" */
t+='</tr>';
};
t+='</table>';
t.length-=4;
insert(t,t.indexOf("height")+11,' name="'+this.viewername+bd+'uleft">');
tmp+=t;
t="";
tmp=tmp+'</td>';// <td rowspan="2">&nbsp;</td>
tmp+=' <td NOWRAP rowspan="2">';
for (i=0; i<5;i++)
{
for (j=0;j<2;j++)
{ind=64+i*2+j;
t+='<a href="javascript:void(0)" onClick="assclick('+ind+",'"+this.viewername+"','"+bd+"');"+'">';
t+='<img src="'+this.gifs["d"]+'" border="0"'+sqsize+'></a>';
if ((this.displaymode!="diagram")||(this.reloadmode!="noreload"))
{k=i*2+j; s='h'+bd+k; t+='<input type="text" size="1" name="'+s+'" value=" " onFocus="this.blur();">';}
else {if (this.flip==0) {s=this.hold[2*i+j];} else {s=this.hold[9-2*i-j];}
if (s>1) {t+=s} else {t+=' '} };
}
t+='<br>';
};
tmp+=t;
tmp=tmp+'</td> </tr> </table> </center> ';
tmp=tmp+'<table border="0" cellpadding="0" width="100%">';
tmp=tmp+'<tr> <td align="center" valign="top">';

if (this.displaymode!='diagram') {tmp+='<input type="text" size="7" name="lastmove'+bd+'" value=" " onChange="assexecmove(this.value,\''+bd+'\',\''+this.viewername+"'"+')"> ';};

if (this.reloadmode=="noreload")
{tmp=tmp+tago+eval('this.'+dn)+' '+this.rdo+eval('this.'+dn+'elo')+ this.rdc + tagc }
else {
if (this.displaymode!="diagram") {tmp+=' <input type="text" size="18" name="dn'+bd+'" onFocus="assexecmove(document.'+this.viewername+'.lastmove'+bd+'.value,' +"'"+bd+"','"+this.viewername+"'"+'); this.blur();"> '}
else {tmp+=' <input type="text" size="25" name="dn'+bd+'" onFocus="this.blur();"> '};
};

tmp=tmp+'</td> <td align="right" valign="top">';
tmp+='<image src="'+this.gifs["nmv"]+'" width="24" height="20" name ="'+this.viewername+'dnmv'+bd+'">';
if ((this.reloadmode=="noreload")&& (this.displaymode=="diagram"))
{ tmp=tmp+tago;
tmp=tmp+" "+totime(eval('this.'+d+'clock'))+tagc;
}
else {tmp=tmp+' <input type="text" size="5" name="'+'dnclock'+bd+'" onFocus="this.blur();"> '} ;
tmp=tmp+'</td> </tr> </table>';
return tmp;
}

function brefreshform()
{
if (!this.redraw) return;
var bd=this.boardname;var wh=whosmove(this.turn);
var upmove;
if (((this.flip==0)&&(wh=='b'))||((this.flip==1)&&(wh=='w'))) {upmove=true} else {upmove=false};
var t=eval('window.document.'+this.viewername); var i; var s; var k; var outc;

s=eval('document.'+this.viewername+'upmv'+bd); /* show whose move is now */
k=eval('document.'+this.viewername+'dnmv'+bd);
if (upmove) {s.src=this.gifs["mv"];k.src=this.gifs["nmv"]}
else {k.src=this.gifs["mv"];s.src=this.gifs["nmv"]};

if ((this.displaymode!="diagram") || (this.reloadmode!="noreload"))
{s=eval('document.'+this.viewername+'.upclock'+bd);/*refresh clocks */
k=eval('document.'+this.viewername+'.dnclock'+bd);
if (this.flip==1) {s.value=totime(this.wclock); k.value=totime(this.bclock);}
else {s.value=totime(this.bclock); k.value=totime(this.wclock);}

/* if (upmove) {outc=eval('document.'+this.viewername+'.upclock'+bd)}
else{outc=eval('document.'+this.viewername+'.dnclock'+bd);};
outc.select();*/

for (i=0;i<10;i++) { /*refresh holdings */
s=eval('t.h'+bd+i);
if (this.flip==0) {k=this.hold[i];}else {k=this.hold[9-i]};
if (k>0) {s.value=k} else {s.value=""};
}

};

if ((this.reloadmode)!="noreload") /*refresh handles */
{
s=eval('document.'+this.viewername+'.up'+bd);
k=eval('document.'+this.viewername+'.dn'+bd);
if (this.flip==1) {
s.value=this.white+' '+this.rdo+this.whiteelo+this.rdc;
k.value=this.black+' '+this.rdo+this.blackelo+this.rdc;
}
else {
s.value=this.black+' '+this.rdo+this.blackelo+this.rdc;
k.value=this.white+' '+this.rdo+this.whiteelo+this.rdc;
};
};

}


function setauleft()
{
this.a.uleft= (this.numboard==2)? document.images.length -151: document.images.length-75;
this.b.uleft= this.a.uleft+76;
}

function redrawhold(piece,inc)
{
if (!this.redraw) return;
var ind=this.syncpic();
var i;
var tmp;
for (i=0;i<10;i++) { if (this.dropbar[i]==piece) break;}
if (i>9) return;
this.hold[i]+=inc;
if (this.flip==0) {
if (this.hold[i]>0) {document.images[ind+64+i].src=this.gifs[piece+'d']}
else {document.images[ind+64+i].src=this.gifs['d']};
tmp=i; }
else {
if (this.hold[i]>0) {document.images[ind+73-i].src=this.gifs[piece+'d']}
else {document.images[ind+73-i].src=this.gifs['d']};
tmp=9-i;};

tmp='window.document.'+this.viewername+'.h'+this.boardname+tmp;
s=eval(tmp);
if (this.displaymode!='diagram') {(this.hold[i]==0)? (s.value=''):(s.value=this.hold[i]);};
}

function dropmove(mv)
{
var wh=whosmove(this.turn);
var king= ((wh=='w')?this.kingw:this.kingb);
this.pos[mv.tosquare]=mv.frompiece;
if (this.incheck(wh,king)) {this.pos[mv.tosquare]=''; return false;};
this.redrawsquare(mv.tosquare);this.redrawhold(mv.frompiece, -1 );
if (mv.frompiece=='br'){
if ((mv.tosquare==sqtoind('h8'))&&(this.shortcastleb=='rook')) {this.shortcastleb=true;};
if ((mv.tosquare==sqtoind('a8'))&&(this.longcastleb=='rook')) {this.longcastleb=true;};
};
if (mv.frompiece=='wr'){
if ((mv.tosquare==sqtoind('h1'))&&(this.shortcastlew=='rook')) {this.shortcastlew=true;};
if ((mv.tosquare==sqtoind('a1'))&&(this.longcastlew=='rook')) {this.longcastlew=true;};
};
return true;
}

function undodropmove(mv)
{
var wh=mv.side;
this.pos[mv.tosquare]='';
this.redrawsquare(mv.tosquare);
this.redrawhold(mv.frompiece,1);
}

function enpassant(bd,mv)
{
var cp=mv.frompiece.charAt(0)+mv.frompiece.charAt(1);
var tbd=eval('this.'+bd);
var wh=whosmove(tbd.turn);
var king=eval('this.'+bd+'.king'+wh);
tbd.pos[mv.tosquare]=cp;
tbd.pos[mv.fromsquare]='';
var enpass=((wh=='w') ? (mv.tosquare+8): (mv.tosquare-8));
if (tbd.pos[enpass]!=othercolor(wh)+'p') {return false;};
tbd.pos[enpass]='';
if (tbd.incheck(wh,king)) {tbd.pos[mv.fromsquare]=cp; tbd.pos[mv.tosquare]=mv.topiece; tbd.pos[enpass]=othercolor(wh)+'p'; return false};
this.capture(bd,othercolor(wh)+'p',1);
tbd.redrawsquare(mv.fromsquare);
tbd.redrawsquare(mv.tosquare);
tbd.redrawsquare(enpass);
}

function undoenpassant(mv)
{
var tbd=eval('this.'+mv.board);
var wh=mv.side;
var cp=wh+'p';
var bd=mv.board;
tbd.pos[mv.fromsquare]=cp;
tbd.pos[mv.tosquare]='';
var enpass=((wh=='w') ? (mv.tosquare+8): (mv.tosquare-8));
tbd.pos[enpass]=othercolor(wh)+'p';
this.capture(bd,othercolor(wh)+'p',-1);
tbd.redrawsquare(enpass);
tbd.redrawsquare(mv.tosquare);
tbd.redrawsquare(mv.fromsquare);
}

function promotion (bd,mv)
{ var tbd=eval('this.'+bd);
var wh=whosmove(tbd.turn);
var king=eval('this.'+bd+'.king'+wh);
var p=mv.frompiece.charAt(2); p=p.toUpperCase();
tbd.pos[mv.tosquare]=mv.frompiece.charAt(0)+p;
tbd.pos[mv.fromsquare]='';
if (tbd.incheck(wh,king)) {tbd.pos[mv.fromsquare]=mv.frompiece; tbd.pos[mv.tosquare]=mv.topiece; return false}
tbd.redrawsquare(mv.fromsquare);
tbd.redrawsquare(mv.tosquare);
if (mv.topiece!='') {this.capture(bd,mv.topiece,1);};
return true;
}

function undopromotion (mv)
{ var tbd=eval('this.'+mv.board);
var bd=mv.board;
var wh=mv.side;
tbd.pos[mv.fromsquare]=wh+'p';
tbd.pos[mv.tosquare]=mv.topiece;
tbd.redrawsquare(mv.tosquare);
tbd.redrawsquare(mv.fromsquare);
if (mv.topiece!='') {this.capture(bd,mv.topiece,-1);};
}

function regularmove (mv)
{
var bd=mv.board;
var tbd=eval('this.'+bd);
var wh=mv.side;
tbd.pos[mv.fromsquare]='';
tbd.pos[mv.tosquare]=mv.frompiece;
tbd.redrawsquare(mv.fromsquare);
tbd.redrawsquare(mv.tosquare);
if (mv.topiece!='') {this.capture(bd,mv.topiece,1);};
return true;
}

function undoregularmove(mv)
{
var tbd=eval('this.'+mv.board);
var wh=mv.side;
if (mv.frompiece.charAt(1)=='k'){ if (wh=='w') {tbd.kingw=mv.fromsquare} else {tbd.kingb=mv.fromsquare};};
tbd.pos[mv.fromsquare]=mv.frompiece;tbd.pos[mv.tosquare]=mv.topiece;
if (mv.topiece!='') {this.capture(mv.board,mv.topiece,-1);};
tbd.redrawsquare(mv.tosquare);
tbd.redrawsquare(mv.fromsquare);
}

function shortcastle(color)
{
var tmp=eval('this.shortcastle'+color);
return tmp;
}

function longcastle(color)
{
var tmp=eval('this.longcastle'+color);
return tmp;
}


function setking(mv)
{
var t=mv.fromsquare+'s';
t=t.substr(0,t.length-1);
var wh=whosmove(this.turn);
if (this.pos[sqtoind('e1')]!='wk') {this.shortcastlew='king';this.longcastlew='king';};
if (this.pos[sqtoind('e8')]!='bk') {this.shortcastleb='king';this.longcastleb='king';};
if (mv.frompiece=='wk') {
if (t.charAt(0)!='o') {this.kingw=mv.tosquare;};
if (t=='o-o-o') {this.kingw=sqtoind('c1');};
if (t=='o-o') {this.kingw=sqtoind('g1');};
};
if (mv.frompiece=='bk') {
if (t.charAt(0)!='o') {this.kingb=mv.tosquare;};
if (t=='o-o-o') {this.kingb=sqtoind('c8');};
if (t=='o-o') {this.kingb=sqtoind('g8');};
};
if (this.shortcastlew!='king'){
if (this.pos[sqtoind('h1')]!='wr') {this.shortcastlew='rook';};
if (this.pos[sqtoind('a1')]!='wr') {this.longcastlew='rook';};
};
if (this.shortcastleb!='k


Navjot Singh comments:

Can you PM me your WordPress login details so that I can take a look where the problem is?


Navjot Singh comments:

Check now. Everything you had pasted outside [raw][/raw] tags was causing the duplicate board to appear.


ambt comments:

Thank you VERY much for your help!!! It appears to work perfectly now!

I added another $5 to the prize for all of your help.

Again, thank you!!


ambt comments:

This is my first time using this site. I'm a bit confused. I added extra $5 and tried to vote for your answer to award you the prize, but it says on the page that I am not allowed to vote. Strange... So how do I award you the prize for your help?


ambt comments:

hmmm... really weird... When I first looked at the board it was sized perfectly. Now, when I reload it appears oversized again. I hadn't made any modifications! I wonder what I did wrong....


ambt comments:

I have a question, I noticed that on the edit page for "master games" the code for the pull down menu options and the chess moves are there there. But where is the source (with the tables) for the board itself? Did you place that somewhere else? I can't seem to find where/how to edit the chessboard (i.e. table) sizes.


Navjot Singh comments:

It appears perfectly sized here to me.

The form code (between the raw tags) is the one which generates the board. Its the only code required. Even at the original site only the form code was needed.

Here's the Voting Instructions: http://blog.tailormadeanswers.com/2011/04/22/voting-assign-prize-money/ Can you please try again?


ambt comments:

I tried again and I think I was able to vote for you. It's not showing up in the stats page, but some of the options disappeared, so I think it went through. Please let me know if there are any problems. And thanks again!


ambt comments:

btw, how do I adjust the size of the chessboards/tables? For some reason it still looks big on my firefox browser.


ambt comments:

btw, how do I adjust the size of the chessboards/tables? For some reason it still looks big on my firefox browser.


ambt comments:

oh I understand now, just play with the em number from the table code table {
font-size: .8em !important;
}


But this would affect all tables I generate in the future right? How would I be able to modify each table individually, instead of making a global change?