Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhither2forlorn <vaibhawp@yahoo.co.uk>2010-03-01 09:57:39 (GMT)
committer hither2forlorn <vaibhawp@yahoo.co.uk>2010-03-01 09:57:39 (GMT)
commitfdc062ddf47fa18740dbaf845085e83c14d9b0ad (patch)
tree9d1f1b644f5864ee18b1f1f0561ec51f73e6eea2
parent283943248d836822cc792bdfc5e9bedcdf17e9c3 (diff)
new lessons added for validation purposes.
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/back.wavbin0 -> 63108 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/bean.wavbin0 -> 61344 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/bed.wavbin0 -> 46352 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/black.wavbin0 -> 61784 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/blue.wavbin0 -> 59140 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/blue_bed.wavbin0 -> 55612 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/blue_fish.wavbin0 -> 60900 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/blue_mouse.wavbin0 -> 64432 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/brown.wavbin0 -> 48996 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/correct.oggbin0 -> 12811 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/dead.wavbin0 -> 51200 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/drink.wavbin0 -> 70604 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/fellow.wavbin0 -> 53848 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/flew.wavbin0 -> 52964 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/green.wavbin0 -> 51200 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/grey.wavbin0 -> 57816 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/incorrect.oggbin0 -> 12683 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/ink.wavbin0 -> 66196 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/november.wavbin0 -> 60460 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/one_bed.wavbin0 -> 63548 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/one_fish.wavbin0 -> 58256 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/one_head.wavbin0 -> 59140 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/one_house.wavbin0 -> 56492 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/one_mouse.wavbin0 -> 66196 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/orange.wavbin0 -> 50316 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/pink.wavbin0 -> 54728 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/purple.wavbin0 -> 49876 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/red.wavbin0 -> 53848 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/red_fish.wavbin0 -> 56936 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/red_head.wavbin0 -> 56492 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/red_house.wavbin0 -> 57816 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/sink.wavbin0 -> 67076 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/spots.wavbin0 -> 73692 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/stink.wavbin0 -> 72812 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/think.wavbin0 -> 66636 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/turtle.wavbin0 -> 61344 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/two_fish.wavbin0 -> 61784 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/uncle.wavbin0 -> 46792 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/white.wavbin0 -> 61784 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/yellow.wavbin0 -> 63108 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/audio/zoo.wavbin0 -> 50760 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/Blue bed.pngbin0 -> 8116 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/Blue bed_Clicked.pngbin0 -> 11700 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/Blue fish.pngbin0 -> 5107 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/Blue fish_Clicked.pngbin0 -> 5234 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/Blue mouse.pngbin0 -> 7347 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/Blue mouse_Clicked.pngbin0 -> 7154 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/One bed.pngbin0 -> 8116 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/One head.pngbin0 -> 11061 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/Red fish.pngbin0 -> 5107 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/Red fish_Clicked.pngbin0 -> 5234 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/Red head.pngbin0 -> 11061 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/Red head_Clicked.pngbin0 -> 11731 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/Red house.pngbin0 -> 4925 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/Red house_Clicked.pngbin0 -> 4561 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/background.pngbin0 -> 369956 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/bean.pngbin0 -> 8344 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/bed.pngbin0 -> 8116 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/bg_footer.pngbin0 -> 185 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/bg_header.pngbin0 -> 307 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/bg_title_block.pngbin0 -> 366 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/bird.pngbin0 -> 7845 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/bird_Clicked.pngbin0 -> 8953 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/black_glass.pngbin0 -> 6301 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/brown_uncle.pngbin0 -> 6553 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/btn_back.pngbin0 -> 2665 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/btn_back_hover.pngbin0 -> 4038 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/btn_help.pngbin0 -> 2755 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/btn_help_hover.pngbin0 -> 4190 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/btn_next.pngbin0 -> 2773 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/btn_next_hover.pngbin0 -> 3996 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/btn_ole.pngbin0 -> 4842 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/btn_ole_hover.pngbin0 -> 6253 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/btn_play_again.pngbin0 -> 5627 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/btn_play_again_hover.pngbin0 -> 5468 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/btn_play_again_mouse_down.pngbin0 -> 5688 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/btn_start.pngbin0 -> 5127 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/btn_start_hover.pngbin0 -> 4966 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/btn_start_mouse_down.pngbin0 -> 5109 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/cage.pngbin0 -> 9619 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/cat.pngbin0 -> 10689 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/cat_black.pngbin0 -> 12065 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/cat_strip.pngbin0 -> 14823 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/dead.pngbin0 -> 5248 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/dead_Clicked.pngbin0 -> 5226 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/giraffe.pngbin0 -> 9519 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/giraffe_Clicked.pngbin0 -> 11448 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/gray_glass.pngbin0 -> 6001 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/help.pngbin0 -> 86063 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/namesofcolor.pngbin0 -> 5360 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/orange.pngbin0 -> 13500 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/orange_Clicked.pngbin0 -> 7055 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/pink_glass.pngbin0 -> 6089 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/red_bed_Clicked.pngbin0 -> 9566 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/sink.pngbin0 -> 24121 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/stink.pngbin0 -> 19284 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/think.pngbin0 -> 17262 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/title_block_lt.pngbin0 -> 1337 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/title_block_rt.pngbin0 -> 1362 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/tree.pngbin0 -> 21450 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/turtle.pngbin0 -> 6419 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/turtle_Clicked.pngbin0 -> 6542 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/assets/image/zoo.pngbin0 -> 26862 bytes
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/css/lesson.css340
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/index.html41
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/js/Copy of lesson.js294
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/js/jquery-1.4.js5999
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/js/karma.js1018
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/js/lesson.js743
-rwxr-xr-xexamples/lessons/6_English_namesOfColor/js/ui.core.js519
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/audio/correct.oggbin0 -> 12811 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/audio/incorrect.oggbin0 -> 12683 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/aeroplane.pngbin0 -> 20028 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/backImage.pngbin0 -> 26097 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/bag.pngbin0 -> 16107 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/bear.pngbin0 -> 7172 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/bench.pngbin0 -> 2885 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/bg_footer.pngbin0 -> 185 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/bg_header.pngbin0 -> 307 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/bg_title_block.pngbin0 -> 366 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/boat.pngbin0 -> 46550 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/book.pngbin0 -> 24687 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/brush.pngbin0 -> 37042 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/btn_back.pngbin0 -> 2665 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/btn_back_hover.pngbin0 -> 4038 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/btn_help.pngbin0 -> 2755 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/btn_help_hover.pngbin0 -> 4190 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/btn_next.pngbin0 -> 2773 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/btn_next_hover.pngbin0 -> 3996 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/btn_ole.pngbin0 -> 4842 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/btn_ole_hover.pngbin0 -> 6253 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/btn_play_again.pngbin0 -> 5627 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/btn_play_again_hover.pngbin0 -> 5468 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/btn_play_again_mouse_down.pngbin0 -> 5688 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/btn_start.pngbin0 -> 5127 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/btn_start_hover.pngbin0 -> 4966 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/btn_start_mouse_down.pngbin0 -> 5109 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/bus.pngbin0 -> 31947 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/cart.pngbin0 -> 39565 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/check.pngbin0 -> 9052 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/comma.pngbin0 -> 324 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/correct.pngbin0 -> 6263 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/cycle.pngbin0 -> 33924 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/desk.pngbin0 -> 3426 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/dot.pngbin0 -> 276 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/elephant.pngbin0 -> 43740 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/help.pngbin0 -> 126014 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/incorrect.pngbin0 -> 8029 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/jackel.pngbin0 -> 18684 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/kite.pngbin0 -> 22297 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/ladder.pngbin0 -> 6997 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/monkey.pngbin0 -> 28780 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/objects.pngbin0 -> 9526 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/rhino.pngbin0 -> 9735 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/ship.pngbin0 -> 19280 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/snake.pngbin0 -> 37927 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/soap.pngbin0 -> 32038 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/tempo.pngbin0 -> 66929 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/tiger.pngbin0 -> 47097 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/title_block_lt.pngbin0 -> 1337 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/title_block_rt.pngbin0 -> 1362 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/transportation.pngbin0 -> 9920 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/truck.pngbin0 -> 26004 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/turtle.pngbin0 -> 43395 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/assets/image/wild.pngbin0 -> 10986 bytes
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/css/lesson.css280
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/css/ui.scoreboard.css62
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/index.html49
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/js/jquery-1.4.js5999
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/js/karma.js1018
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/js/lesson.js318
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/js/ui.core.js519
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/js/ui.draggable.js766
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/js/ui.droppable.js282
-rwxr-xr-xexamples/lessons/6_English_oneOrMany/js/ui.scoreboard.js107
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/audio/apple.wavbin0 -> 44144 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/audio/banana.wavbin0 -> 43264 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/audio/boat.wavbin0 -> 47672 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/audio/book.wavbin0 -> 45908 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/audio/bus.wavbin0 -> 52524 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/audio/cake.wavbin0 -> 39296 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/audio/car.wavbin0 -> 34444 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/audio/correct.oggbin0 -> 12811 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/audio/cow.wavbin0 -> 58700 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/audio/flower.wavbin0 -> 53408 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/audio/hat.wavbin0 -> 52964 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/audio/incorrect.oggbin0 -> 12683 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/audio/kite.wavbin0 -> 61344 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/audio/lamp.wavbin0 -> 58700 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/audio/pig.wavbin0 -> 63992 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/audio/pigeon.wavbin0 -> 56936 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/audio/rat.wavbin0 -> 51200 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/audio/tomato.wavbin0 -> 46792 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/audio/tree.wavbin0 -> 33560 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/ant.pngbin0 -> 5011 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/apple.pngbin0 -> 8404 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/banana.pngbin0 -> 17964 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/bg_footer.pngbin0 -> 185 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/bg_header.pngbin0 -> 307 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/bg_title_block.pngbin0 -> 366 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/boat.pngbin0 -> 29148 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/book.pngbin0 -> 11339 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/btn_back.pngbin0 -> 2665 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/btn_back_hover.pngbin0 -> 4038 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/btn_help.pngbin0 -> 2755 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/btn_help_hover.pngbin0 -> 4190 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/btn_next.pngbin0 -> 2773 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/btn_next_hover.pngbin0 -> 3996 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/btn_ole.pngbin0 -> 4842 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/btn_ole_hover.pngbin0 -> 6253 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/btn_play_again.pngbin0 -> 5627 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/btn_play_again_hover.pngbin0 -> 5468 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/btn_play_again_mouse_down.pngbin0 -> 5688 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/btn_start.pngbin0 -> 5127 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/btn_start_hover.pngbin0 -> 4966 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/btn_start_mouse_down.pngbin0 -> 5109 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/bus.pngbin0 -> 18132 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/cake.pngbin0 -> 20688 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/car.pngbin0 -> 15499 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/cow.pngbin0 -> 11564 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/flower.pngbin0 -> 21889 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/hat.pngbin0 -> 19790 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/help.pngbin0 -> 63451 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/kite.pngbin0 -> 17432 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/ladybird.pngbin0 -> 3366 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/lamp.pngbin0 -> 28452 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/pig.pngbin0 -> 14307 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/pigeon.pngbin0 -> 22408 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/rat.pngbin0 -> 17640 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/socks.pngbin0 -> 11118 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/title_block_lt.pngbin0 -> 1337 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/title_block_rt.pngbin0 -> 1362 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/tomato.pngbin0 -> 14859 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/assets/image/tree.pngbin0 -> 35062 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/css/lesson.css247
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/css/ui.scoreboard.css62
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/index.html42
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/js/jquery-1.4.js5999
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/js/jquery.watermarkinput.js81
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/js/karma.js1018
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/js/lesson.js263
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/js/lesson.js~259
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/js/ui.core.js519
-rwxr-xr-xexamples/lessons/6_English_whatsThisLetter/js/ui.scoreboard.js107
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/audio/apple.wavbin0 -> 44144 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/audio/banana.wavbin0 -> 43264 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/audio/boat.wavbin0 -> 47672 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/audio/book.wavbin0 -> 45908 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/audio/bus.wavbin0 -> 52524 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/audio/cake.wavbin0 -> 39296 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/audio/car.wavbin0 -> 34444 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/audio/correct.oggbin0 -> 12811 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/audio/cow.wavbin0 -> 58700 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/audio/flower.wavbin0 -> 53408 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/audio/hat.wavbin0 -> 52964 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/audio/incorrect.oggbin0 -> 12683 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/audio/kite.wavbin0 -> 61344 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/audio/lamp.wavbin0 -> 58700 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/audio/pig.wavbin0 -> 63992 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/audio/pigeon.wavbin0 -> 56936 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/audio/rat.wavbin0 -> 51200 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/audio/tomato.wavbin0 -> 46792 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/audio/tree.wavbin0 -> 33560 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/ant.pngbin0 -> 5011 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/apple.pngbin0 -> 8404 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/banana.pngbin0 -> 17964 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/bg_footer.pngbin0 -> 185 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/bg_header.pngbin0 -> 307 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/bg_title_block.pngbin0 -> 366 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/boat.pngbin0 -> 29148 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/book.pngbin0 -> 11339 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/btn_back.pngbin0 -> 2665 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/btn_back_hover.pngbin0 -> 4038 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/btn_help.pngbin0 -> 2755 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/btn_help_hover.pngbin0 -> 4190 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/btn_next.pngbin0 -> 2773 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/btn_next_hover.pngbin0 -> 3996 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/btn_ole.pngbin0 -> 4842 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/btn_ole_hover.pngbin0 -> 6253 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/btn_play_again.pngbin0 -> 5627 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/btn_play_again_hover.pngbin0 -> 5468 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/btn_play_again_mouse_down.pngbin0 -> 5688 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/btn_start.pngbin0 -> 5127 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/btn_start_hover.pngbin0 -> 4966 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/btn_start_mouse_down.pngbin0 -> 5109 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/bus.pngbin0 -> 18132 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/cake.pngbin0 -> 20688 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/car.pngbin0 -> 15499 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/cow.pngbin0 -> 11564 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/flower.pngbin0 -> 21889 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/hat.pngbin0 -> 19790 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/help.pngbin0 -> 60389 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/kite.pngbin0 -> 17432 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/ladybird.pngbin0 -> 3366 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/lamp.pngbin0 -> 28452 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/piegon.pngbin0 -> 22408 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/pig.pngbin0 -> 14307 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/rat.pngbin0 -> 17640 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/socks.pngbin0 -> 11118 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/title_block_lt.pngbin0 -> 1337 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/title_block_rt.pngbin0 -> 1362 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/tomato.pngbin0 -> 14859 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/assets/image/tree.pngbin0 -> 35062 bytes
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/css/lesson.css247
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/css/ui.scoreboard.css62
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/index.html42
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/js/jquery-1.4.js5999
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/js/jquery.watermarkinput.js81
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/js/karma.js1018
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/js/lesson.js249
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/js/lesson.js~259
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/js/ui.core.js519
-rwxr-xr-xexamples/lessons/6_English_whatsThisWord/js/ui.scoreboard.js107
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/audio/correct.wavbin0 -> 111176 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/audio/incorrect.wavbin0 -> 77660 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/bg_footer.pngbin0 -> 185 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/bg_header.pngbin0 -> 307 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/bg_title_block.pngbin0 -> 366 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/btn_back.pngbin0 -> 2665 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/btn_back_hover.pngbin0 -> 4038 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/btn_help.pngbin0 -> 2755 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/btn_help_hover.pngbin0 -> 4190 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/btn_next.pngbin0 -> 2773 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/btn_next_hover.pngbin0 -> 3996 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/btn_ole.pngbin0 -> 4842 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/btn_ole_hover.pngbin0 -> 6253 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/btn_play_again.pngbin0 -> 5627 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/btn_play_again_hover.pngbin0 -> 5468 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/btn_play_again_mouse_down.pngbin0 -> 5688 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/btn_start.pngbin0 -> 5127 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/btn_start_hover.pngbin0 -> 4966 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/btn_start_mouse_down.pngbin0 -> 5109 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/check.pngbin0 -> 1901 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/correct.pngbin0 -> 3340 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/help.pngbin0 -> 112231 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/image1.pngbin0 -> 259838 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/image2.pngbin0 -> 152211 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/image3.pngbin0 -> 300790 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/incorrect.pngbin0 -> 5627 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level1Img0.pngbin0 -> 886 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level1Img1.pngbin0 -> 544 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level1Img10.pngbin0 -> 28478 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level1Img11.pngbin0 -> 10223 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level1Img12.pngbin0 -> 19560 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level1Img13.pngbin0 -> 12878 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level1Img14.pngbin0 -> 22575 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level1Img15.pngbin0 -> 22088 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level1Img2.pngbin0 -> 18859 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level1Img3.pngbin0 -> 29598 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level1Img4.pngbin0 -> 9508 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level1Img5.pngbin0 -> 2852 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level1Img6.pngbin0 -> 13676 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level1Img7.pngbin0 -> 12529 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level1Img8.pngbin0 -> 28341 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level1Img9.pngbin0 -> 28220 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level2Img0.pngbin0 -> 5835 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level2Img1.pngbin0 -> 942 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level2Img10.pngbin0 -> 11359 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level2Img11.pngbin0 -> 19520 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level2Img12.pngbin0 -> 19618 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level2Img13.pngbin0 -> 12048 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level2Img14.pngbin0 -> 14562 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level2Img15.pngbin0 -> 11696 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level2Img2.pngbin0 -> 5214 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level2Img3.pngbin0 -> 1290 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level2Img4.pngbin0 -> 21103 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level2Img5.pngbin0 -> 3839 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level2Img6.pngbin0 -> 787 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level2Img7.pngbin0 -> 1432 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level2Img8.pngbin0 -> 16364 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level2Img9.pngbin0 -> 9869 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level3Img0.pngbin0 -> 12598 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level3Img1.pngbin0 -> 8641 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level3Img10.pngbin0 -> 20624 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level3Img11.pngbin0 -> 30045 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level3Img12.pngbin0 -> 15394 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level3Img13.pngbin0 -> 1272 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level3Img14.pngbin0 -> 10114 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level3Img15.pngbin0 -> 17411 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level3Img2.pngbin0 -> 9138 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level3Img3.pngbin0 -> 14968 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level3Img4.pngbin0 -> 29398 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level3Img5.pngbin0 -> 29552 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level3Img6.pngbin0 -> 28663 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level3Img7.pngbin0 -> 31719 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level3Img8.pngbin0 -> 21988 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/level3Img9.pngbin0 -> 24032 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/levelDown.pngbin0 -> 4298 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/levelUp.pngbin0 -> 4313 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/picClock.pngbin0 -> 2622 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/title_block_lt.pngbin0 -> 1337 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/assets/image/title_block_rt.pngbin0 -> 1362 bytes
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/css/lesson.css332
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/css/ui.scoreboard.css62
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/index.html47
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/js/jquery-1.4.js5999
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/js/jquery.watermarkinput.js81
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/js/karma.js1018
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/js/lesson.js301
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/js/ui.core.js519
-rwxr-xr-xexamples/lessons/6_Maths_AddSubtract/js/ui.scoreboard.js107
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/audio/correct.oggbin0 -> 12811 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/audio/correct.wavbin0 -> 111176 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/audio/incorrect.oggbin0 -> 12683 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/audio/incorrect.wavbin0 -> 77660 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/background.pngbin0 -> 191348 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/bg_footer.pngbin0 -> 185 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/bg_header.pngbin0 -> 307 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/bg_title_block.pngbin0 -> 366 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/blueBoy0.pngbin0 -> 6110 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/blueBoy1.pngbin0 -> 6315 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/blueBoy2.pngbin0 -> 7149 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/blueBoy3.pngbin0 -> 7321 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/blueNumPlus.pngbin0 -> 7424 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/blueRing.pngbin0 -> 797 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/blueTotal.pngbin0 -> 5610 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/btn_back.pngbin0 -> 2665 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/btn_back_hover.pngbin0 -> 4038 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/btn_help.pngbin0 -> 2755 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/btn_help_hover.pngbin0 -> 4190 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/btn_next.pngbin0 -> 2773 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/btn_next_hover.pngbin0 -> 3996 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/btn_ole.pngbin0 -> 4842 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/btn_ole_hover.pngbin0 -> 6253 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/btn_play_again.pngbin0 -> 5627 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/btn_play_again_hover.pngbin0 -> 5468 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/btn_play_again_mouse_down.pngbin0 -> 5688 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/btn_start.pngbin0 -> 5127 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/btn_start_hover.pngbin0 -> 4966 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/btn_start_mouse_down.pngbin0 -> 5109 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/help.pngbin0 -> 110362 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/imgNumContainer.pngbin0 -> 2856 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/redGirl0.pngbin0 -> 6581 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/redGirl1.pngbin0 -> 6777 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/redGirl2.pngbin0 -> 7737 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/redGirl3.pngbin0 -> 7560 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/redNumPlus.pngbin0 -> 7034 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/redRing.pngbin0 -> 797 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/redTotal.pngbin0 -> 5270 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/scoreBox.pngbin0 -> 3767 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/title.pngbin0 -> 4346 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/title_block_lt.pngbin0 -> 1337 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/title_block_rt.pngbin0 -> 1362 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/assets/image/totalCorrect.pngbin0 -> 3585 bytes
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/css/lesson.css225
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/index.html39
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/js/jquery-1.4.js5999
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/js/karma.js1018
-rwxr-xr-xexamples/lessons/6_Maths_complexAddition/js/lesson.js217
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/audio/correct.wavbin0 -> 111176 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/audio/incorrect.wavbin0 -> 77660 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/bg_footer.pngbin0 -> 185 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/bg_header.pngbin0 -> 307 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/bg_title_block.pngbin0 -> 366 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_back.pngbin0 -> 2665 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_back_hover.pngbin0 -> 4038 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_help.pngbin0 -> 2755 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_help_hover.pngbin0 -> 4190 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_next.pngbin0 -> 2773 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_next_hover.pngbin0 -> 3996 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_ole.pngbin0 -> 4842 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_ole_hover.pngbin0 -> 6253 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_play_again.pngbin0 -> 5627 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_play_again_hover.pngbin0 -> 5468 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_play_again_mouse_down.pngbin0 -> 5688 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_start.pngbin0 -> 5127 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_start_hover.pngbin0 -> 4966 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_start_mouse_down.pngbin0 -> 5109 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/check.pngbin0 -> 1901 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/checkAnsBtn.pngbin0 -> 4365 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/checkAnsBtnHover.pngbin0 -> 10069 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/correct.pngbin0 -> 1883 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise1.pngbin0 -> 9333 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise1Hover.pngbin0 -> 9346 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise1Title.pngbin0 -> 7189 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise2.pngbin0 -> 9414 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise2Hover.pngbin0 -> 9394 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise3.pngbin0 -> 9234 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise3Hover.pngbin0 -> 9433 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/exerciseRestTitle.pngbin0 -> 22786 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/exerciseTitle.pngbin0 -> 10297 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/frog0.pngbin0 -> 3793 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/frog1.pngbin0 -> 5846 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/help.pngbin0 -> 112947 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/imgWhatzLCM.pngbin0 -> 11612 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/incorrect.pngbin0 -> 1909 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson1ImgDef0.pngbin0 -> 6759 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson1ImgDef1.pngbin0 -> 7664 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson1ImgDef2.pngbin0 -> 6026 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson1ImgDef3.pngbin0 -> 7731 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson1ImgDef4.pngbin0 -> 19483 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef0.pngbin0 -> 18842 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef1.pngbin0 -> 4093 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef2.pngbin0 -> 1383 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef3.pngbin0 -> 19291 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef4.pngbin0 -> 3775 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef5.pngbin0 -> 1202 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef6.pngbin0 -> 5811 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef7.pngbin0 -> 3077 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef8.pngbin0 -> 3726 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef9.pngbin0 -> 1143 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgSign.pngbin0 -> 271 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef0.pngbin0 -> 32077 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef1.pngbin0 -> 5249 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef2.pngbin0 -> 26894 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef3.pngbin0 -> 27169 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef4.pngbin0 -> 4703 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef5.pngbin0 -> 4949 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/moreQuesBtn.pngbin0 -> 4397 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/moreQuesBtnHover.pngbin0 -> 10204 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/nextBtn.pngbin0 -> 3904 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/nextBtnHover.pngbin0 -> 9531 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/picClock.pngbin0 -> 2622 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/rabbit0.pngbin0 -> 3880 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/rabbit1.pngbin0 -> 3965 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/showAnsBtn.pngbin0 -> 4417 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/showAnsBtnHover.pngbin0 -> 10415 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/timeLine.pngbin0 -> 37692 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/timeLineIntersect.pngbin0 -> 194 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/timeRing.pngbin0 -> 614 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/title_block_lt.pngbin0 -> 1337 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/assets/image/title_block_rt.pngbin0 -> 1362 bytes
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/css/lesson.css393
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/css/ui.scoreboard.css62
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/index.html53
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/js/jquery-1.4.js5999
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/js/karma.js1018
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/js/lesson.js694
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/js/ui.core.js519
-rwxr-xr-xexamples/lessons/6_Maths_lowestCommonMultiple/js/ui.scoreboard.js107
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/audio/correct.wavbin0 -> 111176 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/audio/incorrect.wavbin0 -> 77660 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/afterSimplify.pngbin0 -> 1760 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/beforeSimplify.pngbin0 -> 1764 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/bg_footer.pngbin0 -> 185 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/bg_header.pngbin0 -> 307 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/bg_title_block.pngbin0 -> 366 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/btn_back.pngbin0 -> 2665 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/btn_back_hover.pngbin0 -> 4038 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/btn_help.pngbin0 -> 2755 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/btn_help_hover.pngbin0 -> 4190 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/btn_next.pngbin0 -> 2773 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/btn_next_hover.pngbin0 -> 3996 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/btn_ole.pngbin0 -> 4842 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/btn_ole_hover.pngbin0 -> 6253 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/btn_play_again.pngbin0 -> 5627 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/btn_play_again_hover.pngbin0 -> 5468 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/btn_play_again_mouse_down.pngbin0 -> 5688 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/btn_start.pngbin0 -> 5127 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/btn_start_hover.pngbin0 -> 4966 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/btn_start_mouse_down.pngbin0 -> 5109 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/check.pngbin0 -> 1901 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/checkAnsBtn.pngbin0 -> 4365 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/checkAnsBtnHover.pngbin0 -> 10069 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/correct.pngbin0 -> 1883 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/help.pngbin0 -> 118315 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/img1FractionTotal.pngbin0 -> 35442 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/img2FractionTotal.pngbin0 -> 50995 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/incorrect.pngbin0 -> 1909 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/leso.pngbin0 -> 11515 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgDef1.pngbin0 -> 14230 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgDef2.pngbin0 -> 5679 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgDown.pngbin0 -> 12107 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgFractions.pngbin0 -> 95930 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgPart1.pngbin0 -> 29343 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgPart2.pngbin0 -> 11986 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1frac1.pngbin0 -> 460 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgDef1.pngbin0 -> 3449 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgDef2.pngbin0 -> 6281 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgDef3.pngbin0 -> 14083 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgDef4.pngbin0 -> 3255 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgFractions.pngbin0 -> 81473 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgPart1.pngbin0 -> 29665 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgPart2.pngbin0 -> 8557 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2frac1.pngbin0 -> 524 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2frac2.pngbin0 -> 643 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2frac3.pngbin0 -> 1728 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson3Img1.pngbin0 -> 58287 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson3Img2.pngbin0 -> 34855 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson3Img3.pngbin0 -> 22627 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson3ImgPart1.pngbin0 -> 28401 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson3ImgPart2.pngbin0 -> 15480 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4Img1.pngbin0 -> 26758 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4Img2.pngbin0 -> 34407 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4Img3.pngbin0 -> 4110 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4ImgDef1.pngbin0 -> 7742 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4ImgDef2.pngbin0 -> 12630 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4ImgDef3.pngbin0 -> 10438 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4ImgDef4.pngbin0 -> 15744 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6Img1.pngbin0 -> 85855 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6ImgDef1.pngbin0 -> 10688 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6ImgDef2.pngbin0 -> 5249 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6ImgDef3.pngbin0 -> 3671 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6ImgDef4.pngbin0 -> 4301 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6ImgDef5.pngbin0 -> 2386 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/nextBtn.pngbin0 -> 3904 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/nextBtnHover.pngbin0 -> 9531 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/showAnsBtn.pngbin0 -> 4417 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/showAnsBtnHover.pngbin0 -> 10415 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/title_block_lt.pngbin0 -> 1337 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/assets/image/title_block_rt.pngbin0 -> 1362 bytes
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/css/lesson.css339
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/css/ui.scoreboard.css62
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/index.html47
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/js/jquery-1.4.js5999
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/js/karma.js1018
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/js/lesson.js813
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/js/lesson.js~813
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/js/ui.core.js519
-rwxr-xr-xexamples/lessons/6_Maths_multiplyingFractions/js/ui.scoreboard.js107
610 files changed, 70060 insertions, 0 deletions
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/back.wav b/examples/lessons/6_English_namesOfColor/assets/audio/back.wav
new file mode 100755
index 0000000..0b529ee
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/back.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/bean.wav b/examples/lessons/6_English_namesOfColor/assets/audio/bean.wav
new file mode 100755
index 0000000..46d56d7
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/bean.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/bed.wav b/examples/lessons/6_English_namesOfColor/assets/audio/bed.wav
new file mode 100755
index 0000000..7abbc4e
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/bed.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/black.wav b/examples/lessons/6_English_namesOfColor/assets/audio/black.wav
new file mode 100755
index 0000000..7f8f1f2
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/black.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/blue.wav b/examples/lessons/6_English_namesOfColor/assets/audio/blue.wav
new file mode 100755
index 0000000..b3ba201
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/blue.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/blue_bed.wav b/examples/lessons/6_English_namesOfColor/assets/audio/blue_bed.wav
new file mode 100755
index 0000000..74e62c8
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/blue_bed.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/blue_fish.wav b/examples/lessons/6_English_namesOfColor/assets/audio/blue_fish.wav
new file mode 100755
index 0000000..c57a20e
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/blue_fish.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/blue_mouse.wav b/examples/lessons/6_English_namesOfColor/assets/audio/blue_mouse.wav
new file mode 100755
index 0000000..57320d7
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/blue_mouse.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/brown.wav b/examples/lessons/6_English_namesOfColor/assets/audio/brown.wav
new file mode 100755
index 0000000..c1d4561
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/brown.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/correct.ogg b/examples/lessons/6_English_namesOfColor/assets/audio/correct.ogg
new file mode 100755
index 0000000..a0d9e3a
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/correct.ogg
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/dead.wav b/examples/lessons/6_English_namesOfColor/assets/audio/dead.wav
new file mode 100755
index 0000000..5c5976e
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/dead.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/drink.wav b/examples/lessons/6_English_namesOfColor/assets/audio/drink.wav
new file mode 100755
index 0000000..ccf2302
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/drink.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/fellow.wav b/examples/lessons/6_English_namesOfColor/assets/audio/fellow.wav
new file mode 100755
index 0000000..77df2f8
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/fellow.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/flew.wav b/examples/lessons/6_English_namesOfColor/assets/audio/flew.wav
new file mode 100755
index 0000000..48451e8
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/flew.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/green.wav b/examples/lessons/6_English_namesOfColor/assets/audio/green.wav
new file mode 100755
index 0000000..8d720a3
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/green.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/grey.wav b/examples/lessons/6_English_namesOfColor/assets/audio/grey.wav
new file mode 100755
index 0000000..2b9aa25
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/grey.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/incorrect.ogg b/examples/lessons/6_English_namesOfColor/assets/audio/incorrect.ogg
new file mode 100755
index 0000000..4805e55
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/incorrect.ogg
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/ink.wav b/examples/lessons/6_English_namesOfColor/assets/audio/ink.wav
new file mode 100755
index 0000000..6112ca0
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/ink.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/november.wav b/examples/lessons/6_English_namesOfColor/assets/audio/november.wav
new file mode 100755
index 0000000..baa4257
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/november.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/one_bed.wav b/examples/lessons/6_English_namesOfColor/assets/audio/one_bed.wav
new file mode 100755
index 0000000..e9d2b52
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/one_bed.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/one_fish.wav b/examples/lessons/6_English_namesOfColor/assets/audio/one_fish.wav
new file mode 100755
index 0000000..a1745f3
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/one_fish.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/one_head.wav b/examples/lessons/6_English_namesOfColor/assets/audio/one_head.wav
new file mode 100755
index 0000000..80649ad
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/one_head.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/one_house.wav b/examples/lessons/6_English_namesOfColor/assets/audio/one_house.wav
new file mode 100755
index 0000000..e13df5a
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/one_house.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/one_mouse.wav b/examples/lessons/6_English_namesOfColor/assets/audio/one_mouse.wav
new file mode 100755
index 0000000..587f261
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/one_mouse.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/orange.wav b/examples/lessons/6_English_namesOfColor/assets/audio/orange.wav
new file mode 100755
index 0000000..b818b4a
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/orange.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/pink.wav b/examples/lessons/6_English_namesOfColor/assets/audio/pink.wav
new file mode 100755
index 0000000..20495e0
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/pink.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/purple.wav b/examples/lessons/6_English_namesOfColor/assets/audio/purple.wav
new file mode 100755
index 0000000..2e9e484
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/purple.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/red.wav b/examples/lessons/6_English_namesOfColor/assets/audio/red.wav
new file mode 100755
index 0000000..11fb992
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/red.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/red_fish.wav b/examples/lessons/6_English_namesOfColor/assets/audio/red_fish.wav
new file mode 100755
index 0000000..68f7c66
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/red_fish.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/red_head.wav b/examples/lessons/6_English_namesOfColor/assets/audio/red_head.wav
new file mode 100755
index 0000000..f5684c2
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/red_head.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/red_house.wav b/examples/lessons/6_English_namesOfColor/assets/audio/red_house.wav
new file mode 100755
index 0000000..7514adf
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/red_house.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/sink.wav b/examples/lessons/6_English_namesOfColor/assets/audio/sink.wav
new file mode 100755
index 0000000..5c6beeb
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/sink.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/spots.wav b/examples/lessons/6_English_namesOfColor/assets/audio/spots.wav
new file mode 100755
index 0000000..cef0716
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/spots.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/stink.wav b/examples/lessons/6_English_namesOfColor/assets/audio/stink.wav
new file mode 100755
index 0000000..7939aae
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/stink.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/think.wav b/examples/lessons/6_English_namesOfColor/assets/audio/think.wav
new file mode 100755
index 0000000..0759f1b
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/think.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/turtle.wav b/examples/lessons/6_English_namesOfColor/assets/audio/turtle.wav
new file mode 100755
index 0000000..c0aa9a5
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/turtle.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/two_fish.wav b/examples/lessons/6_English_namesOfColor/assets/audio/two_fish.wav
new file mode 100755
index 0000000..30bd81f
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/two_fish.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/uncle.wav b/examples/lessons/6_English_namesOfColor/assets/audio/uncle.wav
new file mode 100755
index 0000000..14a0084
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/uncle.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/white.wav b/examples/lessons/6_English_namesOfColor/assets/audio/white.wav
new file mode 100755
index 0000000..786a21b
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/white.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/yellow.wav b/examples/lessons/6_English_namesOfColor/assets/audio/yellow.wav
new file mode 100755
index 0000000..a4a5e39
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/yellow.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/audio/zoo.wav b/examples/lessons/6_English_namesOfColor/assets/audio/zoo.wav
new file mode 100755
index 0000000..91471d6
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/audio/zoo.wav
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/Blue bed.png b/examples/lessons/6_English_namesOfColor/assets/image/Blue bed.png
new file mode 100755
index 0000000..a34d227
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/Blue bed.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/Blue bed_Clicked.png b/examples/lessons/6_English_namesOfColor/assets/image/Blue bed_Clicked.png
new file mode 100755
index 0000000..21cf810
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/Blue bed_Clicked.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/Blue fish.png b/examples/lessons/6_English_namesOfColor/assets/image/Blue fish.png
new file mode 100755
index 0000000..14bfa34
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/Blue fish.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/Blue fish_Clicked.png b/examples/lessons/6_English_namesOfColor/assets/image/Blue fish_Clicked.png
new file mode 100755
index 0000000..ca7f3e7
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/Blue fish_Clicked.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/Blue mouse.png b/examples/lessons/6_English_namesOfColor/assets/image/Blue mouse.png
new file mode 100755
index 0000000..1328f62
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/Blue mouse.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/Blue mouse_Clicked.png b/examples/lessons/6_English_namesOfColor/assets/image/Blue mouse_Clicked.png
new file mode 100755
index 0000000..b030e03
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/Blue mouse_Clicked.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/One bed.png b/examples/lessons/6_English_namesOfColor/assets/image/One bed.png
new file mode 100755
index 0000000..a34d227
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/One bed.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/One head.png b/examples/lessons/6_English_namesOfColor/assets/image/One head.png
new file mode 100755
index 0000000..9bb9b2d
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/One head.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/Red fish.png b/examples/lessons/6_English_namesOfColor/assets/image/Red fish.png
new file mode 100755
index 0000000..14bfa34
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/Red fish.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/Red fish_Clicked.png b/examples/lessons/6_English_namesOfColor/assets/image/Red fish_Clicked.png
new file mode 100755
index 0000000..3392f4a
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/Red fish_Clicked.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/Red head.png b/examples/lessons/6_English_namesOfColor/assets/image/Red head.png
new file mode 100755
index 0000000..9bb9b2d
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/Red head.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/Red head_Clicked.png b/examples/lessons/6_English_namesOfColor/assets/image/Red head_Clicked.png
new file mode 100755
index 0000000..07cce8e
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/Red head_Clicked.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/Red house.png b/examples/lessons/6_English_namesOfColor/assets/image/Red house.png
new file mode 100755
index 0000000..12a6682
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/Red house.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/Red house_Clicked.png b/examples/lessons/6_English_namesOfColor/assets/image/Red house_Clicked.png
new file mode 100755
index 0000000..117d8f6
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/Red house_Clicked.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/background.png b/examples/lessons/6_English_namesOfColor/assets/image/background.png
new file mode 100755
index 0000000..853162f
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/background.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/bean.png b/examples/lessons/6_English_namesOfColor/assets/image/bean.png
new file mode 100755
index 0000000..092a064
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/bean.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/bed.png b/examples/lessons/6_English_namesOfColor/assets/image/bed.png
new file mode 100755
index 0000000..a34d227
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/bed.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/bg_footer.png b/examples/lessons/6_English_namesOfColor/assets/image/bg_footer.png
new file mode 100755
index 0000000..8982264
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/bg_footer.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/bg_header.png b/examples/lessons/6_English_namesOfColor/assets/image/bg_header.png
new file mode 100755
index 0000000..98213f7
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/bg_header.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/bg_title_block.png b/examples/lessons/6_English_namesOfColor/assets/image/bg_title_block.png
new file mode 100755
index 0000000..2c9dacf
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/bg_title_block.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/bird.png b/examples/lessons/6_English_namesOfColor/assets/image/bird.png
new file mode 100755
index 0000000..518df57
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/bird.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/bird_Clicked.png b/examples/lessons/6_English_namesOfColor/assets/image/bird_Clicked.png
new file mode 100755
index 0000000..5edd997
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/bird_Clicked.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/black_glass.png b/examples/lessons/6_English_namesOfColor/assets/image/black_glass.png
new file mode 100755
index 0000000..e27249d
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/black_glass.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/brown_uncle.png b/examples/lessons/6_English_namesOfColor/assets/image/brown_uncle.png
new file mode 100755
index 0000000..907b16a
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/brown_uncle.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/btn_back.png b/examples/lessons/6_English_namesOfColor/assets/image/btn_back.png
new file mode 100755
index 0000000..d9fbf14
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/btn_back.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/btn_back_hover.png b/examples/lessons/6_English_namesOfColor/assets/image/btn_back_hover.png
new file mode 100755
index 0000000..0911fcc
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/btn_back_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/btn_help.png b/examples/lessons/6_English_namesOfColor/assets/image/btn_help.png
new file mode 100755
index 0000000..6753e9c
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/btn_help.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/btn_help_hover.png b/examples/lessons/6_English_namesOfColor/assets/image/btn_help_hover.png
new file mode 100755
index 0000000..d3ccd92
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/btn_help_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/btn_next.png b/examples/lessons/6_English_namesOfColor/assets/image/btn_next.png
new file mode 100755
index 0000000..9d70993
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/btn_next.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/btn_next_hover.png b/examples/lessons/6_English_namesOfColor/assets/image/btn_next_hover.png
new file mode 100755
index 0000000..2cd4d37
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/btn_next_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/btn_ole.png b/examples/lessons/6_English_namesOfColor/assets/image/btn_ole.png
new file mode 100755
index 0000000..0e775e9
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/btn_ole.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/btn_ole_hover.png b/examples/lessons/6_English_namesOfColor/assets/image/btn_ole_hover.png
new file mode 100755
index 0000000..c43c5f7
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/btn_ole_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/btn_play_again.png b/examples/lessons/6_English_namesOfColor/assets/image/btn_play_again.png
new file mode 100755
index 0000000..3594d18
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/btn_play_again.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/btn_play_again_hover.png b/examples/lessons/6_English_namesOfColor/assets/image/btn_play_again_hover.png
new file mode 100755
index 0000000..ebb8f8c
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/btn_play_again_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/btn_play_again_mouse_down.png b/examples/lessons/6_English_namesOfColor/assets/image/btn_play_again_mouse_down.png
new file mode 100755
index 0000000..07d6e45
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/btn_play_again_mouse_down.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/btn_start.png b/examples/lessons/6_English_namesOfColor/assets/image/btn_start.png
new file mode 100755
index 0000000..32e5f20
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/btn_start.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/btn_start_hover.png b/examples/lessons/6_English_namesOfColor/assets/image/btn_start_hover.png
new file mode 100755
index 0000000..811ce78
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/btn_start_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/btn_start_mouse_down.png b/examples/lessons/6_English_namesOfColor/assets/image/btn_start_mouse_down.png
new file mode 100755
index 0000000..5acd43b
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/btn_start_mouse_down.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/cage.png b/examples/lessons/6_English_namesOfColor/assets/image/cage.png
new file mode 100755
index 0000000..f0b14b6
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/cage.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/cat.png b/examples/lessons/6_English_namesOfColor/assets/image/cat.png
new file mode 100755
index 0000000..d2dad1d
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/cat.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/cat_black.png b/examples/lessons/6_English_namesOfColor/assets/image/cat_black.png
new file mode 100755
index 0000000..45f2dc0
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/cat_black.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/cat_strip.png b/examples/lessons/6_English_namesOfColor/assets/image/cat_strip.png
new file mode 100755
index 0000000..a03f8c5
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/cat_strip.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/dead.png b/examples/lessons/6_English_namesOfColor/assets/image/dead.png
new file mode 100755
index 0000000..b82b3c9
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/dead.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/dead_Clicked.png b/examples/lessons/6_English_namesOfColor/assets/image/dead_Clicked.png
new file mode 100755
index 0000000..6d8fb71
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/dead_Clicked.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/giraffe.png b/examples/lessons/6_English_namesOfColor/assets/image/giraffe.png
new file mode 100755
index 0000000..d42c2fe
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/giraffe.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/giraffe_Clicked.png b/examples/lessons/6_English_namesOfColor/assets/image/giraffe_Clicked.png
new file mode 100755
index 0000000..4cadbb9
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/giraffe_Clicked.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/gray_glass.png b/examples/lessons/6_English_namesOfColor/assets/image/gray_glass.png
new file mode 100755
index 0000000..6d98bf3
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/gray_glass.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/help.png b/examples/lessons/6_English_namesOfColor/assets/image/help.png
new file mode 100755
index 0000000..1b65bc5
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/help.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/namesofcolor.png b/examples/lessons/6_English_namesOfColor/assets/image/namesofcolor.png
new file mode 100755
index 0000000..65f3fb6
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/namesofcolor.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/orange.png b/examples/lessons/6_English_namesOfColor/assets/image/orange.png
new file mode 100755
index 0000000..0f3229c
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/orange.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/orange_Clicked.png b/examples/lessons/6_English_namesOfColor/assets/image/orange_Clicked.png
new file mode 100755
index 0000000..c30427c
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/orange_Clicked.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/pink_glass.png b/examples/lessons/6_English_namesOfColor/assets/image/pink_glass.png
new file mode 100755
index 0000000..c451c93
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/pink_glass.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/red_bed_Clicked.png b/examples/lessons/6_English_namesOfColor/assets/image/red_bed_Clicked.png
new file mode 100755
index 0000000..8d48828
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/red_bed_Clicked.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/sink.png b/examples/lessons/6_English_namesOfColor/assets/image/sink.png
new file mode 100755
index 0000000..4bc26ec
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/sink.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/stink.png b/examples/lessons/6_English_namesOfColor/assets/image/stink.png
new file mode 100755
index 0000000..31e1fc6
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/stink.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/think.png b/examples/lessons/6_English_namesOfColor/assets/image/think.png
new file mode 100755
index 0000000..8cdfd4e
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/think.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/title_block_lt.png b/examples/lessons/6_English_namesOfColor/assets/image/title_block_lt.png
new file mode 100755
index 0000000..4696182
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/title_block_lt.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/title_block_rt.png b/examples/lessons/6_English_namesOfColor/assets/image/title_block_rt.png
new file mode 100755
index 0000000..37cc44a
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/title_block_rt.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/tree.png b/examples/lessons/6_English_namesOfColor/assets/image/tree.png
new file mode 100755
index 0000000..0d1ba4b
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/tree.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/turtle.png b/examples/lessons/6_English_namesOfColor/assets/image/turtle.png
new file mode 100755
index 0000000..624914b
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/turtle.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/turtle_Clicked.png b/examples/lessons/6_English_namesOfColor/assets/image/turtle_Clicked.png
new file mode 100755
index 0000000..9ffb0c2
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/turtle_Clicked.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/assets/image/zoo.png b/examples/lessons/6_English_namesOfColor/assets/image/zoo.png
new file mode 100755
index 0000000..bc42578
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/assets/image/zoo.png
Binary files differ
diff --git a/examples/lessons/6_English_namesOfColor/css/lesson.css b/examples/lessons/6_English_namesOfColor/css/lesson.css
new file mode 100755
index 0000000..2eb386d
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/css/lesson.css
@@ -0,0 +1,340 @@
+@CHARSET "UTF-8";
+/****** Page Styles ****/
+
+/* Designed for 1200*900 px screen resolution */
+
+body {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 10pt;
+ margin: 0px;
+ background-color: #FFFFCC;
+}
+#header {
+ background-image: url(../assets/image/bg_header.png);
+ background-repeat: repeat-x;
+ height: 75px;
+ width: 100%;
+ position: absolute;
+ left: 0px;
+ top: 0px;
+}
+#topbtn_left {
+ float: left;
+ height: 60px;
+ width: 60px;
+ padding-top: 6px;
+ padding-left: 15px;
+}
+
+
+ .linkBack{
+ width: 60px; height: 59px;
+ background:url(../assets/image/btn_back.png);
+ }
+ .linkBack:hover{
+ background:url(../assets/image/btn_back_hover.png);
+ }
+
+#lesson_title {
+ float: left;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 16pt;
+ font-weight: bold;
+ color: #FFFFFF;
+ margin-left: 10px;
+ background-image: url(../assets/image/bg_title_block.png);
+}
+#topbtn_right {
+ float: right;
+ height: 60px;
+ width: 60px;
+ padding-top: 6px;
+ padding-right: 15px;
+}
+ #linkHelp{
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_help.png);
+ }
+ #linkHelp:hover{
+ background:url(../assets/image/btn_help_hover.png);
+ }
+ #linkOle{
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_ole.png);
+ }
+ #linkOle:hover{
+ background:url(../assets/image/btn_ole_hover.png);
+ }
+ .linkNext{var bindImgCss = {
+ 'float':'left',
+ 'width': '450px',
+ 'height':'40px',
+ 'margin-top':'0.25em',
+ 'text-align':'center',
+ 'padding-bottom':'0.3em'
+ };
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_next.png);
+ }
+ .linkNext:hover{
+ background:url(../assets/image/btn_next_hover.png);
+ }
+#footer {
+ position:relative;
+ background-image: url(../assets/image/bg_footer.png);
+ background-repeat: repeat-x;
+ height: 75px;
+ width: 100%;
+ left: 0px;
+ bottom: 0px;
+}
+#score_box {
+ float: left;
+ padding-left: 5px;
+ padding-top: 0.7em;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #FFFF00;
+ font-size: 16pt;
+ font-weight: bold;
+}
+#botbtn_right {
+ float: right;
+ height: 55px;
+ padding-right: 5px;
+ padding-top: 10px;
+}
+ #linkCheck{
+ margin: 1em 3em 0 0;
+ width: 101px; height: 30px;
+ background-image: url(../assets/image/check.png);
+ }
+
+ #linkStart{
+ width: 251px; height: 55px;
+ background:url(../assets/image/btn_start.png);
+ }
+ #linkStart:hover{
+ background:url(../assets/image/btn_start_hover.png);
+ }
+ #linkStart:active{
+ background:url(../assets/image/btn_start_mouse_down.png);
+ }
+ #linkPlayAgain{
+ width: 251px; height: 55px;
+ background:url(../assets/image/btn_play_again.png);
+ }
+ #linkPlayAgain:hover{
+ background:url(../assets/image/btn_play_again_hover.png);
+ }
+ #linkPlayAgain:active{
+ background:url(../assets/image/btn_play_again_mouse_down.png);
+ }
+#linkNextLesson{
+ position:absolute;
+ bottom: 75px;
+ right: 10px;
+}
+#linkPrevLesson{
+ position:absolute;
+ bottom: 75px;
+ left: 10px;
+}
+
+/**** End of the page style ****/
+
+/**** Game Styles ****/
+
+a{
+ color:#FFFFCC;
+}
+#currentTitle{
+ width: 150px;
+ height: 80xp;
+ font:25px/30px "Courier New", Courier, monospace;
+ font-weight: bold;
+ color: red;
+}
+#content{
+ margin: 0 auto;
+ margin-top: 75px;
+ width: 1198px;
+ height: 560px;
+ background-image: url(../assets/image/background.png);
+
+}
+ #namesOfColors{
+ position:absolute;
+ top: 15%;
+ right: 20%;
+ }
+
+ .clicktoChange{
+ float:left;
+ padding: 0.5em;
+ height: 30px;
+ font: 20px/25px sans-serif,Arial, Helvetica;
+ cursor:pointer;
+ text-align:center;
+ }
+ .default{
+ background-color: #A6E4FE;
+ }
+ .clicked{lesson5css
+ background-color: #FF9900;
+ }
+ .hoverClick{
+ background-color: #FFFFFF;
+ }
+ .Green,.green{
+ background-color: #3BBA00;
+ }
+ .Brown,.brown{
+ background-color: #B55316;
+ }
+ .Purple,.purple{
+ background-color: purple;
+ }
+ .Yellow,.yellow{
+ background-color: #F4FC88;
+ }
+ .red,.Red{
+ background-color: #FF0000;
+ }
+ .blue,.Blue{
+ background-color: lesson5css#0000FF;
+ }
+ .orange,.Orange{
+ background-color: #FF9900;
+ }
+ .white,.White{
+ background-color: #FFFFFF;
+ }
+ .black,.Black{
+ background-color: #000000;
+ color: #FFFFFF;
+ }
+ .pink,.Pink{
+ background-color: #FF00FF;
+ }
+ .gray,.Gray{
+ background-color: #CCC;
+ }
+
+
+ .large{
+ width: 180px;
+ }
+ .medium{
+ width: 100px;
+ }
+ .small{
+ width: 90px;
+ height: 25px;
+ padding: 0.1em;
+ }
+ .border{
+ border: 2px solid black;
+ }
+
+ .clickTextInfo{
+ float:left;
+ font: 25px/30px Verdana, Geneva, Arial, Helvetica, sans-serif;
+ color:#000;
+ margin: 0.15em 0.5em 0 5em;
+
+ }
+ .smallclickTextInfo{
+ float:left;
+ font: 25px/30px Verdana, Geneva, Arial, Helvetica, sans-serif;
+ color:#000;
+ margin: 0.15em 0.5em 0 1em;
+
+ }
+ .lesson3css{
+ float:left;
+ width: 450px;
+ height:40px;
+ margin-top:0.25em;
+ text-align:center;
+ padding-bottom:0.3em;
+ }
+ .lesson5css{
+ float:left;
+ width: 700px;
+ height:40px;
+ margin-top:0.5em;
+ text-align:center;
+ padding-bottom:1.5em;
+ }
+
+
+ .lesson5tree{
+ margin: 0.15em 0.5em 0 5em;
+
+ }
+
+ .lesson6css{
+ float:left;
+ width: 700px;
+ height:40px;
+ margin-top:0.5em;
+ text-align:center;
+ padding-bottom:.5em;
+ }
+ .lesson7css{
+ float:left;
+ width: 800px;
+ margin-top:0.5em;
+ text-align:left;
+ padding-bottom:.2em;
+ white-space:pre;
+ }
+ .marginSmall{
+ margin-left:-4em;
+ }
+ .marginMedium{
+ margin-left:10em;
+ }
+ .marginLarge{
+ margin-left:30em;
+ }
+ #bindImgGlasses{
+ margin-left: 10em;
+ }
+ #help{
+ display:none;
+ position:absolute;
+ right: 60px;
+ top: 75px;;
+ width: 256px;
+ height: 600px;
+ background:url(../assets/image/help.png);
+ z-index:40;
+ }
+
+ #gameOver{
+ opacity: 1;
+ display:none;
+ position:absolute;
+ top:45%;
+ left: 30%;
+ color: blue;
+ text-align:center;
+ font : bold 45px/65px Arial Black, Times New Roman;
+ }
+ #gameOverInfo{
+ margin-top: 35px;
+ text-align:center;
+ font: 20px/25px Helvetica, Geneva, Arial, Verdana, sans-serif;
+ font-weight:bold;
+ color:#FF0000;
+
+ }
+ .specialText{
+ margin-top: 1em;
+ font: 20px/25px Helvetica, Geneva, Arial, Verdana, sans-serif;
+ font-weight:bold;
+ color:#FF9900;
+ border-bottom: 2px dotted #CCC;
+
+ }
diff --git a/examples/lessons/6_English_namesOfColor/index.html b/examples/lessons/6_English_namesOfColor/index.html
new file mode 100755
index 0000000..0781d1b
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/index.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Class 6 English Names of Color</title>
+ <meta name="keywords" content="karma,javascript,html5,sugar,sugarlabs,gsoc,ole,nepal" />
+ <link type="text/css" rel="stylesheet" href="css/ui.scoreboard.css" />
+ <link type="text/css" rel="stylesheet" href="css/lesson.css" />
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <link type="image/ico" rel="icon" href="../../assets/default/image/favicon.ico" />
+ <script type="text/javascript" src="js/jquery-1.4.js"></script>
+ <script type="text/javascript" src="js/karma.js"></script>
+ <script type="text/javascript" src="js/lesson.js"></script>
+</head>
+<body>
+ <div id="header">
+ <div id="topbtn_left"><a href="#"><div id="linkBackLesson" class="linkBack"></div></a></div>
+ <div id="lesson_title">
+ <img src="assets/image/title_block_lt.png" width="33" height="75" align="absmiddle" />
+ Names of Colors <span id="currentTitle"></span>
+ <img src="assets/image/title_block_rt.png" width="33" height="75" align="absmiddle" />
+ </div>
+ <div id="topbtn_right"><a href="#"><div id="linkHelp"></div></a></div>
+ <div id="topbtn_right"><a href="http://olenepal.org"><div id="linkOle"></div></a></div>
+ </div>
+
+ <div id="content"></div>
+ <img id="namesOfColors" src="assets/image/namesofcolor.png" />
+ <div id="help"></div>
+ <div id="gameOver"></div>
+ <form name="delayForm">
+ <input type="hidden" name="delayval" size="5">
+ </form>
+
+ <div id="footer">
+ <a href="#"><div id="linkNextLesson" class ="linkNext"></div></a>
+ <a href="#"><div id="linkPrevLesson" class ="linkBack"></div></a>
+ <div id="botbtn_right"><a href="#"><div id="linkPlayAgain"></div></a></div>
+ <div id="botbtn_right"><a href="#"><div id="linkStart"></div></a></div>
+ </div>
+</body>
+</html>
diff --git a/examples/lessons/6_English_namesOfColor/js/Copy of lesson.js b/examples/lessons/6_English_namesOfColor/js/Copy of lesson.js
new file mode 100755
index 0000000..487befc
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/js/Copy of lesson.js
@@ -0,0 +1,294 @@
+$(document).ready(function(){
+ var k = Karma({
+ audio: [{'name':'correct','file':'correct.ogg'},
+ {'name':'incorrect','file':'incorrect.ogg'},
+ {'name':'One fish','file':'one_fish.wav'},
+ {'name':'One house','file':'one_house.wav'},
+ {'name':'Two fish','file':'two_fish.wav'},
+ {'name':'Red fish','file':'red_fish.wav'},
+ {'name':'Blue fish','file':'blue_fish.wav'},
+ {'name':'One mouse','file':'one_mouse.wav'},
+ {'name':'Red house','file':'red_house.wav'},
+ {'name':'Blue mouse','file':'blue_mouse.wav'},
+ {'name':'One head','file':'one_head.wav'},
+ {'name':'One bed','file':'one_bed.wav'},
+ {'name':'Red head','file':'red_head.wav'},
+ {'name':'Blue bed','file':'blue_bed.wav'},
+ {'name':'Green','file':'green.wav'},
+ {'name':'Brown','file':'brown.wav'},
+ {'name':'Purple','file':'purple.wav'},
+ {'name':'turtle','file':'turtle.wav'},
+ {'name':'bean','file':'bean.wav'},
+ {'name':'uncle','file':'uncle.wav'},
+ {'name':'red','file':'red.wav'}
+ ]});
+
+ k.ready(function(){
+ var i,j;
+ var currentLesson;
+ var TOTAL_QUES = 6;
+ var currentLessonStart;
+ var num;
+ var numLessonClicks = new Array(8,4);
+ var sounds = new Array('One fish','Two fish','Red fish','Blue fish','One house','One mouse','Red house','Blue mouse',
+ 'One head','One bed','Red head','Blue bed','Green','Brown','Purple','turtle','Purple','Brown','uncle',
+ 'bean','green','bed','red'
+ );
+ var lesson3texts = new Array('See the little','The turtle is','His name is Punckle','He has a','The turtle ate a',
+ 'He became','The turtle went to','He became'
+ );
+
+ var assignImages = function(lessonId){
+ var lessonIdNew;
+ lessonId = currentLessonStart+lessonId;
+ if(currentLesson === 0){
+ lessonIdNew = lessonId-2;
+ }
+ else{
+ lessonIdNew = lessonId;
+ }
+ if(currentLesson === 0 ){
+ $('#bindImg'+lessonIdNew).append('<div id="img'+lessonId+'"></div>');
+ $('#img'+lessonId).html('<img src="assets/image/'+sounds[lessonId]+'.png">');
+ }
+ };
+
+ var assignLesson = function(lessonId){
+ lessonId = currentLessonStart+lessonId;
+ var bindImgCss = {
+ 'float':'left',
+ 'width': '210px',
+ 'text-align':'center',
+ 'padding-bottom':'1em'
+
+ };
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="imgBind"></div>');
+ $('#bindImg'+lessonId).css(bindImgCss);
+ if(currentLesson === 1){
+ $('#bindImg'+lessonId).append('<div id="img'+lessonId+'"></div>');
+ $('#img'+lessonId).html('<img src="assets/image/'+sounds[lessonId]+'.png">');
+ }
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange large"></div>');
+ $('#click'+lessonId).append(sounds[lessonId]).addClass('default');
+
+ $('#click'+lessonId).bind({
+ mouseover: function(){
+ $(this).addClass('hoverClick');
+ },
+ mouseout: function(){
+ $(this).removeClass('hoverClick');
+ },
+ click: function(){
+ $(this).addClass('clicked');
+ var curSound = sounds[lessonId];
+ if(currentLesson === 1){
+ if(lessonId === 10 || lessonId === 11){
+ $('#img'+lessonId).html('<img src="assets/image/'+sounds[lessonId]+'_Clicked.png" />');
+ }
+ }
+ else{
+ $('#img'+lessonId).html('<img src="assets/image/'+sounds[lessonId]+'_Clicked.png" />');
+ }
+ k.audio[curSound].play();
+ }
+ });
+ };
+
+
+ var assignColorBoxes = function(lessonId){
+ $('#bindImg'+currentLessonStart).append('<div id = "click'+lessonId+'" class="clicktoChange medium border"></div>');
+ $('#click'+lessonId).append(sounds[lessonId]).addClass(sounds[lessonId]);
+
+ $('#click'+lessonId).bind({
+ mouseover: function(){
+ $(this).removeClass(sounds[lessonId]);
+ $(this).addClass('hoverClick');
+ },
+ mouseout: function(){
+ $(this).removeClass('hoverClick');
+ $(this).addClass(sounds[lessonId]);
+ },
+ click: function(){
+ $(this).addClass(sounds[lessonId]);
+ var curSound = sounds[lessonId];
+ k.audio[curSound].play();
+ }
+ });
+ };
+
+ var assignTexts = function(lessonId){
+ var bindImgCss = {
+ 'float':'left',
+ 'width': '450px',
+ 'height':'40px',
+ 'text-align':'center',
+ 'padding-bottom':'0.3em'
+ };
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="imgBind"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> '+lesson3texts[num]+' </span>');
+
+ if(num != 2){
+
+
+
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border"></div>');
+
+ if(lessonId === 16){
+ $('#click'+lessonId).append(sounds[lessonId]).addClass('Purple');
+ }
+ if(lessonId === 18){
+ $('#bindImg'+lessonId).append('<div id = "clickBrown" class="clicktoChange small border"></div>');
+ $('#clickBrown').append('brown').addClass('Brown');
+ }
+ else if(lessonId === 20){
+ $('#click'+lessonId).append(sounds[lessonId]).addClass('Green');
+ }
+
+ else if(lessonId === 22){
+ $('#click'+lessonId).append(sounds[lessonId]).addClass('red');
+ }
+ else{
+ $('#click'+lessonId).append(sounds[lessonId]).addClass('Yellow');
+ }
+
+
+ $('#bindImg'+lessonId).css(bindImgCss);
+ $('#click'+lessonId).bind({
+ click: function(){
+ $(this).addClass('clicked');
+ var curSound = sounds[lessonId];
+ alert(curSound);
+ k.audio[curSound].play();
+ }
+ });
+ $('#clickBrown').bind({
+ click: function(){
+ $(this).addClass('clicked');
+ var curSound = sounds[lessonId];
+ alert(curSound);
+ k.audio[curSound].play();
+ }
+ });
+ }
+ num++;
+
+ };
+
+ var startLesson3 = function(){
+ var lessonCss = {
+ 'margin': '1em 0 0 10em',
+ 'float':'left',
+ 'width': '600px',
+ 'height': '520px',
+ 'text-align':'center'
+ };
+ $('#lesson').css(lessonCss);
+ currentLessonStart = 12;
+ var lessonId = currentLessonStart;
+ $('#lesson').append('<div id="bindImg'+currentLessonStart+'" class="imgBind"></div>');
+ var bindImgCss = {
+ 'float':'left',
+ 'width': '500px',
+ 'height':'100px',
+ 'text-align':'center',
+ 'padding-bottom':'1em'
+ };
+ $('#bindImg'+currentLessonStart).css(bindImgCss);
+ for(i = currentLessonStart; i< 15; i++){
+ assignColorBoxes(i);
+ }
+
+ lessonId = 15;
+ num = 0;
+ for(i = lessonId;i<23;i++){
+ assignTexts(i);
+ }
+
+
+ };
+
+ var nextLesson = function(){
+ $('#content').html('').append('<div id="lesson"></div>');
+
+ if(currentLesson === 2){
+ startLesson3();
+ }
+
+ if(currentLesson < 2){ // for being same interface for lesson 0 and 1
+ var lessonCss = {
+ 'margin': '1em 0 0 18em',
+ 'float':'left',
+ 'width': '600px',
+ 'height': '520px',
+ 'text-align':'center'
+ };
+ clickId = 0;
+ $('#lesson').css(lessonCss);
+
+ currentLessonStart = 0;
+ for(j = 0; j< currentLesson;j++){
+ currentLessonStart += numLessonClicks[j];
+ if(currentLesson === 0){
+ currentLessonStart = 0;
+ }
+
+ }
+ for(i = 0;i<numLessonClicks[currentLesson];i++){
+ assignLesson(i);
+ }
+ for(i = 0;i<numLessonClicks[currentLesson];i++){
+ if(currentLesson === 0){
+ if(i === 2|| i === 3 || i === 6||i === 7){
+ assignImages(i);
+ }
+ }
+ else{
+ assignImages(i);
+ }
+ }
+ }
+
+ };
+
+ function gameStart(){
+ currentLesson = 2;
+ nextLesson();
+ }
+
+ function game(){
+ $('#linkPrevLesson').hide();
+ gameStart();
+ }
+
+ game();
+
+ $('#linkNextLesson').click(function(){
+ $('#linkNextLesson').hide();
+ $('#linkPrevLesson').show();
+ currentLesson = 1;
+ displayLessons();
+ });
+ $('#linkPrevLesson').click(function(){
+ $('#linkNextLesson').show();
+ $('#linkPrevLesson').hide();
+ currentLesson = 0;
+ });
+ $('#linkStart').click(function(){
+ gameStart();
+ });
+
+ $('#linkPlayAgain').click(function(){
+ game();
+ });
+ $('#linkHelp').mouseover(function(){
+ $('#help').slideDown(2000);
+ })
+ .mouseout(function(){
+ $('#help').slideUp(2000);
+
+ });
+
+ }); //end of k.ready
+}); //end of document.read
+
+
diff --git a/examples/lessons/6_English_namesOfColor/js/jquery-1.4.js b/examples/lessons/6_English_namesOfColor/js/jquery-1.4.js
new file mode 100755
index 0000000..a448490
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/js/jquery-1.4.js
@@ -0,0 +1,5999 @@
+/*!
+ * jQuery JavaScript Library v1.4
+ * http://jquery.com/
+ *
+ * Copyright 2010, John Resig
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://docs.jquery.com/License
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ * Copyright 2010, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ *
+ * Date: Wed Jan 13 15:23:05 2010 -0500
+ */
+(function( window, undefined ) {
+
+// Define a local copy of jQuery
+var jQuery = function( selector, context ) {
+ // The jQuery object is actually just the init constructor 'enhanced'
+ return new jQuery.fn.init( selector, context );
+ },
+
+ // Map over jQuery in case of overwrite
+ _jQuery = window.jQuery,
+
+ // Map over the $ in case of overwrite
+ _$ = window.$,
+
+ // Use the correct document accordingly with window argument (sandbox)
+ document = window.document,
+
+ // A central reference to the root jQuery(document)
+ rootjQuery,
+
+ // A simple way to check for HTML strings or ID strings
+ // (both of which we optimize for)
+ quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,
+
+ // Is it a simple selector
+ isSimple = /^.[^:#\[\.,]*$/,
+
+ // Check if a string has a non-whitespace character in it
+ rnotwhite = /\S/,
+
+ // Used for trimming whitespace
+ rtrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g,
+
+ // Match a standalone tag
+ rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
+
+ // Keep a UserAgent string for use with jQuery.browser
+ userAgent = navigator.userAgent,
+
+ // For matching the engine and version of the browser
+ browserMatch,
+
+ // Has the ready events already been bound?
+ readyBound = false,
+
+ // The functions to execute on DOM ready
+ readyList = [],
+
+ // The ready event handler
+ DOMContentLoaded,
+
+ // Save a reference to some core methods
+ toString = Object.prototype.toString,
+ hasOwnProperty = Object.prototype.hasOwnProperty,
+ push = Array.prototype.push,
+ slice = Array.prototype.slice,
+ indexOf = Array.prototype.indexOf;
+
+jQuery.fn = jQuery.prototype = {
+ init: function( selector, context ) {
+ var match, elem, ret, doc;
+
+ // Handle $(""), $(null), or $(undefined)
+ if ( !selector ) {
+ return this;
+ }
+
+ // Handle $(DOMElement)
+ if ( selector.nodeType ) {
+ this.context = this[0] = selector;
+ this.length = 1;
+ return this;
+ }
+
+ // Handle HTML strings
+ if ( typeof selector === "string" ) {
+ // Are we dealing with HTML string or an ID?
+ match = quickExpr.exec( selector );
+
+ // Verify a match, and that no context was specified for #id
+ if ( match && (match[1] || !context) ) {
+
+ // HANDLE: $(html) -> $(array)
+ if ( match[1] ) {
+ doc = (context ? context.ownerDocument || context : document);
+
+ // If a single string is passed in and it's a single tag
+ // just do a createElement and skip the rest
+ ret = rsingleTag.exec( selector );
+
+ if ( ret ) {
+ if ( jQuery.isPlainObject( context ) ) {
+ selector = [ document.createElement( ret[1] ) ];
+ jQuery.fn.attr.call( selector, context, true );
+
+ } else {
+ selector = [ doc.createElement( ret[1] ) ];
+ }
+
+ } else {
+ ret = buildFragment( [ match[1] ], [ doc ] );
+ selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
+ }
+
+ // HANDLE: $("#id")
+ } else {
+ elem = document.getElementById( match[2] );
+
+ if ( elem ) {
+ // Handle the case where IE and Opera return items
+ // by name instead of ID
+ if ( elem.id !== match[2] ) {
+ return rootjQuery.find( selector );
+ }
+
+ // Otherwise, we inject the element directly into the jQuery object
+ this.length = 1;
+ this[0] = elem;
+ }
+
+ this.context = document;
+ this.selector = selector;
+ return this;
+ }
+
+ // HANDLE: $("TAG")
+ } else if ( !context && /^\w+$/.test( selector ) ) {
+ this.selector = selector;
+ this.context = document;
+ selector = document.getElementsByTagName( selector );
+
+ // HANDLE: $(expr, $(...))
+ } else if ( !context || context.jquery ) {
+ return (context || rootjQuery).find( selector );
+
+ // HANDLE: $(expr, context)
+ // (which is just equivalent to: $(context).find(expr)
+ } else {
+ return jQuery( context ).find( selector );
+ }
+
+ // HANDLE: $(function)
+ // Shortcut for document ready
+ } else if ( jQuery.isFunction( selector ) ) {
+ return rootjQuery.ready( selector );
+ }
+
+ if (selector.selector !== undefined) {
+ this.selector = selector.selector;
+ this.context = selector.context;
+ }
+
+ return jQuery.isArray( selector ) ?
+ this.setArray( selector ) :
+ jQuery.makeArray( selector, this );
+ },
+
+ // Start with an empty selector
+ selector: "",
+
+ // The current version of jQuery being used
+ jquery: "1.4",
+
+ // The default length of a jQuery object is 0
+ length: 0,
+
+ // The number of elements contained in the matched element set
+ size: function() {
+ return this.length;
+ },
+
+ toArray: function() {
+ return slice.call( this, 0 );
+ },
+
+ // Get the Nth element in the matched element set OR
+ // Get the whole matched element set as a clean array
+ get: function( num ) {
+ return num == null ?
+
+ // Return a 'clean' array
+ this.toArray() :
+
+ // Return just the object
+ ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
+ },
+
+ // Take an array of elements and push it onto the stack
+ // (returning the new matched element set)
+ pushStack: function( elems, name, selector ) {
+ // Build a new jQuery matched element set
+ var ret = jQuery( elems || null );
+
+ // Add the old object onto the stack (as a reference)
+ ret.prevObject = this;
+
+ ret.context = this.context;
+
+ if ( name === "find" ) {
+ ret.selector = this.selector + (this.selector ? " " : "") + selector;
+ } else if ( name ) {
+ ret.selector = this.selector + "." + name + "(" + selector + ")";
+ }
+
+ // Return the newly-formed element set
+ return ret;
+ },
+
+ // Force the current matched set of elements to become
+ // the specified array of elements (destroying the stack in the process)
+ // You should use pushStack() in order to do this, but maintain the stack
+ setArray: function( elems ) {
+ // Resetting the length to 0, then using the native Array push
+ // is a super-fast way to populate an object with array-like properties
+ this.length = 0;
+ push.apply( this, elems );
+
+ return this;
+ },
+
+ // Execute a callback for every element in the matched set.
+ // (You can seed the arguments with an array of args, but this is
+ // only used internally.)
+ each: function( callback, args ) {
+ return jQuery.each( this, callback, args );
+ },
+
+ ready: function( fn ) {
+ // Attach the listeners
+ jQuery.bindReady();
+
+ // If the DOM is already ready
+ if ( jQuery.isReady ) {
+ // Execute the function immediately
+ fn.call( document, jQuery );
+
+ // Otherwise, remember the function for later
+ } else if ( readyList ) {
+ // Add the function to the wait list
+ readyList.push( fn );
+ }
+
+ return this;
+ },
+
+ eq: function( i ) {
+ return i === -1 ?
+ this.slice( i ) :
+ this.slice( i, +i + 1 );
+ },
+
+ first: function() {
+ return this.eq( 0 );
+ },
+
+ last: function() {
+ return this.eq( -1 );
+ },
+
+ slice: function() {
+ return this.pushStack( slice.apply( this, arguments ),
+ "slice", slice.call(arguments).join(",") );
+ },
+
+ map: function( callback ) {
+ return this.pushStack( jQuery.map(this, function( elem, i ) {
+ return callback.call( elem, i, elem );
+ }));
+ },
+
+ end: function() {
+ return this.prevObject || jQuery(null);
+ },
+
+ // For internal use only.
+ // Behaves like an Array's method, not like a jQuery method.
+ push: push,
+ sort: [].sort,
+ splice: [].splice
+};
+
+// Give the init function the jQuery prototype for later instantiation
+jQuery.fn.init.prototype = jQuery.fn;
+
+jQuery.extend = jQuery.fn.extend = function() {
+ // copy reference to target object
+ var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy;
+
+ // Handle a deep copy situation
+ if ( typeof target === "boolean" ) {
+ deep = target;
+ target = arguments[1] || {};
+ // skip the boolean and the target
+ i = 2;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
+ target = {};
+ }
+
+ // extend jQuery itself if only one argument is passed
+ if ( length === i ) {
+ target = this;
+ --i;
+ }
+
+ for ( ; i < length; i++ ) {
+ // Only deal with non-null/undefined values
+ if ( (options = arguments[ i ]) != null ) {
+ // Extend the base object
+ for ( name in options ) {
+ src = target[ name ];
+ copy = options[ name ];
+
+ // Prevent never-ending loop
+ if ( target === copy ) {
+ continue;
+ }
+
+ // Recurse if we're merging object literal values or arrays
+ if ( deep && copy && ( jQuery.isPlainObject(copy) || jQuery.isArray(copy) ) ) {
+ var clone = src && ( jQuery.isPlainObject(src) || jQuery.isArray(src) ) ? src
+ : jQuery.isArray(copy) ? [] : {};
+
+ // Never move original objects, clone them
+ target[ name ] = jQuery.extend( deep, clone, copy );
+
+ // Don't bring in undefined values
+ } else if ( copy !== undefined ) {
+ target[ name ] = copy;
+ }
+ }
+ }
+ }
+
+ // Return the modified object
+ return target;
+};
+
+jQuery.extend({
+ noConflict: function( deep ) {
+ window.$ = _$;
+
+ if ( deep ) {
+ window.jQuery = _jQuery;
+ }
+
+ return jQuery;
+ },
+
+ // Is the DOM ready to be used? Set to true once it occurs.
+ isReady: false,
+
+ // Handle when the DOM is ready
+ ready: function() {
+ // Make sure that the DOM is not already loaded
+ if ( !jQuery.isReady ) {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( !document.body ) {
+ return setTimeout( jQuery.ready, 13 );
+ }
+
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If there are functions bound, to execute
+ if ( readyList ) {
+ // Execute all of them
+ var fn, i = 0;
+ while ( (fn = readyList[ i++ ]) ) {
+ fn.call( document, jQuery );
+ }
+
+ // Reset the list of functions
+ readyList = null;
+ }
+
+ // Trigger any bound ready events
+ if ( jQuery.fn.triggerHandler ) {
+ jQuery( document ).triggerHandler( "ready" );
+ }
+ }
+ },
+
+ bindReady: function() {
+ if ( readyBound ) {
+ return;
+ }
+
+ readyBound = true;
+
+ // Catch cases where $(document).ready() is called after the
+ // browser event has already occurred.
+ if ( document.readyState === "complete" ) {
+ return jQuery.ready();
+ }
+
+ // Mozilla, Opera and webkit nightlies currently support this event
+ if ( document.addEventListener ) {
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+
+ // A fallback to window.onload, that will always work
+ window.addEventListener( "load", jQuery.ready, false );
+
+ // If IE event model is used
+ } else if ( document.attachEvent ) {
+ // ensure firing before onload,
+ // maybe late but safe also for iframes
+ document.attachEvent("onreadystatechange", DOMContentLoaded);
+
+ // A fallback to window.onload, that will always work
+ window.attachEvent( "onload", jQuery.ready );
+
+ // If IE and not a frame
+ // continually check to see if the document is ready
+ var toplevel = false;
+
+ try {
+ toplevel = window.frameElement == null;
+ } catch(e) {}
+
+ if ( document.documentElement.doScroll && toplevel ) {
+ doScrollCheck();
+ }
+ }
+ },
+
+ // See test/unit/core.js for details concerning isFunction.
+ // Since version 1.3, DOM methods and functions like alert
+ // aren't supported. They return false on IE (#2968).
+ isFunction: function( obj ) {
+ return toString.call(obj) === "[object Function]";
+ },
+
+ isArray: function( obj ) {
+ return toString.call(obj) === "[object Array]";
+ },
+
+ isPlainObject: function( obj ) {
+ // Must be an Object.
+ // Because of IE, we also have to check the presence of the constructor property.
+ // Make sure that DOM nodes and window objects don't pass through, as well
+ if ( !obj || toString.call(obj) !== "[object Object]" || obj.nodeType || obj.setInterval ) {
+ return false;
+ }
+
+ // Not own constructor property must be Object
+ if ( obj.constructor
+ && !hasOwnProperty.call(obj, "constructor")
+ && !hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf") ) {
+ return false;
+ }
+
+ // Own properties are enumerated firstly, so to speed up,
+ // if last one is own, then all properties are own.
+
+ var key;
+ for ( key in obj ) {}
+
+ return key === undefined || hasOwnProperty.call( obj, key );
+ },
+
+ isEmptyObject: function( obj ) {
+ for ( var name in obj ) {
+ return false;
+ }
+ return true;
+ },
+
+ noop: function() {},
+
+ // Evalulates a script in a global context
+ globalEval: function( data ) {
+ if ( data && rnotwhite.test(data) ) {
+ // Inspired by code by Andrea Giammarchi
+ // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
+ var head = document.getElementsByTagName("head")[0] || document.documentElement,
+ script = document.createElement("script");
+
+ script.type = "text/javascript";
+
+ if ( jQuery.support.scriptEval ) {
+ script.appendChild( document.createTextNode( data ) );
+ } else {
+ script.text = data;
+ }
+
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709).
+ head.insertBefore( script, head.firstChild );
+ head.removeChild( script );
+ }
+ },
+
+ nodeName: function( elem, name ) {
+ return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
+ },
+
+ // args is for internal usage only
+ each: function( object, callback, args ) {
+ var name, i = 0,
+ length = object.length,
+ isObj = length === undefined || jQuery.isFunction(object);
+
+ if ( args ) {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.apply( object[ name ], args ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( ; i < length; ) {
+ if ( callback.apply( object[ i++ ], args ) === false ) {
+ break;
+ }
+ }
+ }
+
+ // A special, fast, case for the most common use of each
+ } else {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( var value = object[0];
+ i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
+ }
+ }
+
+ return object;
+ },
+
+ trim: function( text ) {
+ return (text || "").replace( rtrim, "" );
+ },
+
+ // results is for internal usage only
+ makeArray: function( array, results ) {
+ var ret = results || [];
+
+ if ( array != null ) {
+ // The window, strings (and functions) also have 'length'
+ // The extra typeof function check is to prevent crashes
+ // in Safari 2 (See: #3039)
+ if ( array.length == null || typeof array === "string" || jQuery.isFunction(array) || (typeof array !== "function" && array.setInterval) ) {
+ push.call( ret, array );
+ } else {
+ jQuery.merge( ret, array );
+ }
+ }
+
+ return ret;
+ },
+
+ inArray: function( elem, array ) {
+ if ( array.indexOf ) {
+ return array.indexOf( elem );
+ }
+
+ for ( var i = 0, length = array.length; i < length; i++ ) {
+ if ( array[ i ] === elem ) {
+ return i;
+ }
+ }
+
+ return -1;
+ },
+
+ merge: function( first, second ) {
+ var i = first.length, j = 0;
+
+ if ( typeof second.length === "number" ) {
+ for ( var l = second.length; j < l; j++ ) {
+ first[ i++ ] = second[ j ];
+ }
+ } else {
+ while ( second[j] !== undefined ) {
+ first[ i++ ] = second[ j++ ];
+ }
+ }
+
+ first.length = i;
+
+ return first;
+ },
+
+ grep: function( elems, callback, inv ) {
+ var ret = [];
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ if ( !inv !== !callback( elems[ i ], i ) ) {
+ ret.push( elems[ i ] );
+ }
+ }
+
+ return ret;
+ },
+
+ // arg is for internal usage only
+ map: function( elems, callback, arg ) {
+ var ret = [], value;
+
+ // Go through the array, translating each of the items to their
+ // new value (or values).
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ value = callback( elems[ i ], i, arg );
+
+ if ( value != null ) {
+ ret[ ret.length ] = value;
+ }
+ }
+
+ return ret.concat.apply( [], ret );
+ },
+
+ // A global GUID counter for objects
+ guid: 1,
+
+ proxy: function( fn, proxy, thisObject ) {
+ if ( arguments.length === 2 ) {
+ if ( typeof proxy === "string" ) {
+ thisObject = fn;
+ fn = thisObject[ proxy ];
+ proxy = undefined;
+
+ } else if ( proxy && !jQuery.isFunction( proxy ) ) {
+ thisObject = proxy;
+ proxy = undefined;
+ }
+ }
+
+ if ( !proxy && fn ) {
+ proxy = function() {
+ return fn.apply( thisObject || this, arguments );
+ };
+ }
+
+ // Set the guid of unique handler to the same of original handler, so it can be removed
+ if ( fn ) {
+ proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
+ }
+
+ // So proxy can be declared as an argument
+ return proxy;
+ },
+
+ // Use of jQuery.browser is frowned upon.
+ // More details: http://docs.jquery.com/Utilities/jQuery.browser
+ uaMatch: function( ua ) {
+ var ret = { browser: "" };
+
+ ua = ua.toLowerCase();
+
+ if ( /webkit/.test( ua ) ) {
+ ret = { browser: "webkit", version: /webkit[\/ ]([\w.]+)/ };
+
+ } else if ( /opera/.test( ua ) ) {
+ ret = { browser: "opera", version: /version/.test( ua ) ? /version[\/ ]([\w.]+)/ : /opera[\/ ]([\w.]+)/ };
+
+ } else if ( /msie/.test( ua ) ) {
+ ret = { browser: "msie", version: /msie ([\w.]+)/ };
+
+ } else if ( /mozilla/.test( ua ) && !/compatible/.test( ua ) ) {
+ ret = { browser: "mozilla", version: /rv:([\w.]+)/ };
+ }
+
+ ret.version = (ret.version && ret.version.exec( ua ) || [0, "0"])[1];
+
+ return ret;
+ },
+
+ browser: {}
+});
+
+browserMatch = jQuery.uaMatch( userAgent );
+if ( browserMatch.browser ) {
+ jQuery.browser[ browserMatch.browser ] = true;
+ jQuery.browser.version = browserMatch.version;
+}
+
+// Deprecated, use jQuery.browser.webkit instead
+if ( jQuery.browser.webkit ) {
+ jQuery.browser.safari = true;
+}
+
+if ( indexOf ) {
+ jQuery.inArray = function( elem, array ) {
+ return indexOf.call( array, elem );
+ };
+}
+
+// All jQuery objects should point back to these
+rootjQuery = jQuery(document);
+
+// Cleanup functions for the document ready method
+if ( document.addEventListener ) {
+ DOMContentLoaded = function() {
+ document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+ jQuery.ready();
+ };
+
+} else if ( document.attachEvent ) {
+ DOMContentLoaded = function() {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( document.readyState === "complete" ) {
+ document.detachEvent( "onreadystatechange", DOMContentLoaded );
+ jQuery.ready();
+ }
+ };
+}
+
+// The DOM ready check for Internet Explorer
+function doScrollCheck() {
+ if ( jQuery.isReady ) {
+ return;
+ }
+
+ try {
+ // If IE is used, use the trick by Diego Perini
+ // http://javascript.nwbox.com/IEContentLoaded/
+ document.documentElement.doScroll("left");
+ } catch( error ) {
+ setTimeout( doScrollCheck, 1 );
+ return;
+ }
+
+ // and execute any waiting functions
+ jQuery.ready();
+}
+
+if ( indexOf ) {
+ jQuery.inArray = function( elem, array ) {
+ return indexOf.call( array, elem );
+ };
+}
+
+function evalScript( i, elem ) {
+ if ( elem.src ) {
+ jQuery.ajax({
+ url: elem.src,
+ async: false,
+ dataType: "script"
+ });
+ } else {
+ jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
+ }
+
+ if ( elem.parentNode ) {
+ elem.parentNode.removeChild( elem );
+ }
+}
+
+// Mutifunctional method to get and set values to a collection
+// The value/s can be optionally by executed if its a function
+function access( elems, key, value, exec, fn, pass ) {
+ var length = elems.length;
+
+ // Setting many attributes
+ if ( typeof key === "object" ) {
+ for ( var k in key ) {
+ access( elems, k, key[k], exec, fn, value );
+ }
+ return elems;
+ }
+
+ // Setting one attribute
+ if ( value !== undefined ) {
+ // Optionally, function values get executed if exec is true
+ exec = !pass && exec && jQuery.isFunction(value);
+
+ for ( var i = 0; i < length; i++ ) {
+ fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
+ }
+
+ return elems;
+ }
+
+ // Getting an attribute
+ return length ? fn( elems[0], key ) : null;
+}
+
+function now() {
+ return (new Date).getTime();
+}
+(function() {
+
+ jQuery.support = {};
+
+ var root = document.documentElement,
+ script = document.createElement("script"),
+ div = document.createElement("div"),
+ id = "script" + now();
+
+ div.style.display = "none";
+ div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
+
+ var all = div.getElementsByTagName("*"),
+ a = div.getElementsByTagName("a")[0];
+
+ // Can't get basic test support
+ if ( !all || !all.length || !a ) {
+ return;
+ }
+
+ jQuery.support = {
+ // IE strips leading whitespace when .innerHTML is used
+ leadingWhitespace: div.firstChild.nodeType === 3,
+
+ // Make sure that tbody elements aren't automatically inserted
+ // IE will insert them into empty tables
+ tbody: !div.getElementsByTagName("tbody").length,
+
+ // Make sure that link elements get serialized correctly by innerHTML
+ // This requires a wrapper element in IE
+ htmlSerialize: !!div.getElementsByTagName("link").length,
+
+ // Get the style information from getAttribute
+ // (IE uses .cssText insted)
+ style: /red/.test( a.getAttribute("style") ),
+
+ // Make sure that URLs aren't manipulated
+ // (IE normalizes it by default)
+ hrefNormalized: a.getAttribute("href") === "/a",
+
+ // Make sure that element opacity exists
+ // (IE uses filter instead)
+ // Use a regex to work around a WebKit issue. See #5145
+ opacity: /^0.55$/.test( a.style.opacity ),
+
+ // Verify style float existence
+ // (IE uses styleFloat instead of cssFloat)
+ cssFloat: !!a.style.cssFloat,
+
+ // Make sure that if no value is specified for a checkbox
+ // that it defaults to "on".
+ // (WebKit defaults to "" instead)
+ checkOn: div.getElementsByTagName("input")[0].value === "on",
+
+ // Make sure that a selected-by-default option has a working selected property.
+ // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
+ optSelected: document.createElement("select").appendChild( document.createElement("option") ).selected,
+
+ // Will be defined later
+ scriptEval: false,
+ noCloneEvent: true,
+ boxModel: null
+ };
+
+ script.type = "text/javascript";
+ try {
+ script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
+ } catch(e) {}
+
+ root.insertBefore( script, root.firstChild );
+
+ // Make sure that the execution of code works by injecting a script
+ // tag with appendChild/createTextNode
+ // (IE doesn't support this, fails, and uses .text instead)
+ if ( window[ id ] ) {
+ jQuery.support.scriptEval = true;
+ delete window[ id ];
+ }
+
+ root.removeChild( script );
+
+ if ( div.attachEvent && div.fireEvent ) {
+ div.attachEvent("onclick", function click() {
+ // Cloning a node shouldn't copy over any
+ // bound event handlers (IE does this)
+ jQuery.support.noCloneEvent = false;
+ div.detachEvent("onclick", click);
+ });
+ div.cloneNode(true).fireEvent("onclick");
+ }
+
+ // Figure out if the W3C box model works as expected
+ // document.body must exist before we can do this
+ // TODO: This timeout is temporary until I move ready into core.js.
+ jQuery(function() {
+ var div = document.createElement("div");
+ div.style.width = div.style.paddingLeft = "1px";
+
+ document.body.appendChild( div );
+ jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
+ document.body.removeChild( div ).style.display = 'none';
+ div = null;
+ });
+
+ // Technique from Juriy Zaytsev
+ // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
+ var eventSupported = function( eventName ) {
+ var el = document.createElement("div");
+ eventName = "on" + eventName;
+
+ var isSupported = (eventName in el);
+ if ( !isSupported ) {
+ el.setAttribute(eventName, "return;");
+ isSupported = typeof el[eventName] === "function";
+ }
+ el = null;
+
+ return isSupported;
+ };
+
+ jQuery.support.submitBubbles = eventSupported("submit");
+ jQuery.support.changeBubbles = eventSupported("change");
+
+ // release memory in IE
+ root = script = div = all = a = null;
+})();
+
+jQuery.props = {
+ "for": "htmlFor",
+ "class": "className",
+ readonly: "readOnly",
+ maxlength: "maxLength",
+ cellspacing: "cellSpacing",
+ rowspan: "rowSpan",
+ colspan: "colSpan",
+ tabindex: "tabIndex",
+ usemap: "useMap",
+ frameborder: "frameBorder"
+};
+var expando = "jQuery" + now(), uuid = 0, windowData = {};
+var emptyObject = {};
+
+jQuery.extend({
+ cache: {},
+
+ expando:expando,
+
+ // The following elements throw uncatchable exceptions if you
+ // attempt to add expando properties to them.
+ noData: {
+ "embed": true,
+ "object": true,
+ "applet": true
+ },
+
+ data: function( elem, name, data ) {
+ if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
+ return;
+ }
+
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var id = elem[ expando ], cache = jQuery.cache, thisCache;
+
+ // Handle the case where there's no name immediately
+ if ( !name && !id ) {
+ return null;
+ }
+
+ // Compute a unique ID for the element
+ if ( !id ) {
+ id = ++uuid;
+ }
+
+ // Avoid generating a new cache unless none exists and we
+ // want to manipulate it.
+ if ( typeof name === "object" ) {
+ elem[ expando ] = id;
+ thisCache = cache[ id ] = jQuery.extend(true, {}, name);
+ } else if ( cache[ id ] ) {
+ thisCache = cache[ id ];
+ } else if ( typeof data === "undefined" ) {
+ thisCache = emptyObject;
+ } else {
+ thisCache = cache[ id ] = {};
+ }
+
+ // Prevent overriding the named cache with undefined values
+ if ( data !== undefined ) {
+ elem[ expando ] = id;
+ thisCache[ name ] = data;
+ }
+
+ return typeof name === "string" ? thisCache[ name ] : thisCache;
+ },
+
+ removeData: function( elem, name ) {
+ if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
+ return;
+ }
+
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ];
+
+ // If we want to remove a specific section of the element's data
+ if ( name ) {
+ if ( thisCache ) {
+ // Remove the section of cache data
+ delete thisCache[ name ];
+
+ // If we've removed all the data, remove the element's cache
+ if ( jQuery.isEmptyObject(thisCache) ) {
+ jQuery.removeData( elem );
+ }
+ }
+
+ // Otherwise, we want to remove all of the element's data
+ } else {
+ // Clean up the element expando
+ try {
+ delete elem[ expando ];
+ } catch( e ) {
+ // IE has trouble directly removing the expando
+ // but it's ok with using removeAttribute
+ if ( elem.removeAttribute ) {
+ elem.removeAttribute( expando );
+ }
+ }
+
+ // Completely remove the data cache
+ delete cache[ id ];
+ }
+ }
+});
+
+jQuery.fn.extend({
+ data: function( key, value ) {
+ if ( typeof key === "undefined" && this.length ) {
+ return jQuery.data( this[0] );
+
+ } else if ( typeof key === "object" ) {
+ return this.each(function() {
+ jQuery.data( this, key );
+ });
+ }
+
+ var parts = key.split(".");
+ parts[1] = parts[1] ? "." + parts[1] : "";
+
+ if ( value === undefined ) {
+ var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
+
+ if ( data === undefined && this.length ) {
+ data = jQuery.data( this[0], key );
+ }
+ return data === undefined && parts[1] ?
+ this.data( parts[0] ) :
+ data;
+ } else {
+ return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function() {
+ jQuery.data( this, key, value );
+ });
+ }
+ },
+
+ removeData: function( key ) {
+ return this.each(function() {
+ jQuery.removeData( this, key );
+ });
+ }
+});
+jQuery.extend({
+ queue: function( elem, type, data ) {
+ if ( !elem ) {
+ return;
+ }
+
+ type = (type || "fx") + "queue";
+ var q = jQuery.data( elem, type );
+
+ // Speed up dequeue by getting out quickly if this is just a lookup
+ if ( !data ) {
+ return q || [];
+ }
+
+ if ( !q || jQuery.isArray(data) ) {
+ q = jQuery.data( elem, type, jQuery.makeArray(data) );
+
+ } else {
+ q.push( data );
+ }
+
+ return q;
+ },
+
+ dequeue: function( elem, type ) {
+ type = type || "fx";
+
+ var queue = jQuery.queue( elem, type ), fn = queue.shift();
+
+ // If the fx queue is dequeued, always remove the progress sentinel
+ if ( fn === "inprogress" ) {
+ fn = queue.shift();
+ }
+
+ if ( fn ) {
+ // Add a progress sentinel to prevent the fx queue from being
+ // automatically dequeued
+ if ( type === "fx" ) {
+ queue.unshift("inprogress");
+ }
+
+ fn.call(elem, function() {
+ jQuery.dequeue(elem, type);
+ });
+ }
+ }
+});
+
+jQuery.fn.extend({
+ queue: function( type, data ) {
+ if ( typeof type !== "string" ) {
+ data = type;
+ type = "fx";
+ }
+
+ if ( data === undefined ) {
+ return jQuery.queue( this[0], type );
+ }
+ return this.each(function( i, elem ) {
+ var queue = jQuery.queue( this, type, data );
+
+ if ( type === "fx" && queue[0] !== "inprogress" ) {
+ jQuery.dequeue( this, type );
+ }
+ });
+ },
+ dequeue: function( type ) {
+ return this.each(function() {
+ jQuery.dequeue( this, type );
+ });
+ },
+
+ // Based off of the plugin by Clint Helfers, with permission.
+ // http://blindsignals.com/index.php/2009/07/jquery-delay/
+ delay: function( time, type ) {
+ time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
+ type = type || "fx";
+
+ return this.queue( type, function() {
+ var elem = this;
+ setTimeout(function() {
+ jQuery.dequeue( elem, type );
+ }, time );
+ });
+ },
+
+ clearQueue: function( type ) {
+ return this.queue( type || "fx", [] );
+ }
+});
+var rclass = /[\n\t]/g,
+ rspace = /\s+/,
+ rreturn = /\r/g,
+ rspecialurl = /href|src|style/,
+ rtype = /(button|input)/i,
+ rfocusable = /(button|input|object|select|textarea)/i,
+ rclickable = /^(a|area)$/i,
+ rradiocheck = /radio|checkbox/;
+
+jQuery.fn.extend({
+ attr: function( name, value ) {
+ return access( this, name, value, true, jQuery.attr );
+ },
+
+ removeAttr: function( name, fn ) {
+ return this.each(function(){
+ jQuery.attr( this, name, "" );
+ if ( this.nodeType === 1 ) {
+ this.removeAttribute( name );
+ }
+ });
+ },
+
+ addClass: function( value ) {
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.addClass( value.call(this, i, self.attr("class")) );
+ });
+ }
+
+ if ( value && typeof value === "string" ) {
+ var classNames = (value || "").split( rspace );
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var elem = this[i];
+
+ if ( elem.nodeType === 1 ) {
+ if ( !elem.className ) {
+ elem.className = value;
+
+ } else {
+ var className = " " + elem.className + " ";
+ for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
+ if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
+ elem.className += " " + classNames[c];
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ removeClass: function( value ) {
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.removeClass( value.call(this, i, self.attr("class")) );
+ });
+ }
+
+ if ( (value && typeof value === "string") || value === undefined ) {
+ var classNames = (value || "").split(rspace);
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var elem = this[i];
+
+ if ( elem.nodeType === 1 && elem.className ) {
+ if ( value ) {
+ var className = (" " + elem.className + " ").replace(rclass, " ");
+ for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
+ className = className.replace(" " + classNames[c] + " ", " ");
+ }
+ elem.className = className.substring(1, className.length - 1);
+
+ } else {
+ elem.className = "";
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ toggleClass: function( value, stateVal ) {
+ var type = typeof value, isBool = typeof stateVal === "boolean";
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
+ });
+ }
+
+ return this.each(function() {
+ if ( type === "string" ) {
+ // toggle individual class names
+ var className, i = 0, self = jQuery(this),
+ state = stateVal,
+ classNames = value.split( rspace );
+
+ while ( (className = classNames[ i++ ]) ) {
+ // check each className given, space seperated list
+ state = isBool ? state : !self.hasClass( className );
+ self[ state ? "addClass" : "removeClass" ]( className );
+ }
+
+ } else if ( type === "undefined" || type === "boolean" ) {
+ if ( this.className ) {
+ // store className if set
+ jQuery.data( this, "__className__", this.className );
+ }
+
+ // toggle whole className
+ this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || "";
+ }
+ });
+ },
+
+ hasClass: function( selector ) {
+ var className = " " + selector + " ";
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ val: function( value ) {
+ if ( value === undefined ) {
+ var elem = this[0];
+
+ if ( elem ) {
+ if ( jQuery.nodeName( elem, "option" ) ) {
+ return (elem.attributes.value || {}).specified ? elem.value : elem.text;
+ }
+
+ // We need to handle select boxes special
+ if ( jQuery.nodeName( elem, "select" ) ) {
+ var index = elem.selectedIndex,
+ values = [],
+ options = elem.options,
+ one = elem.type === "select-one";
+
+ // Nothing was selected
+ if ( index < 0 ) {
+ return null;
+ }
+
+ // Loop through all the selected options
+ for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
+ var option = options[ i ];
+
+ if ( option.selected ) {
+ // Get the specifc value for the option
+ value = jQuery(option).val();
+
+ // We don't need an array for one selects
+ if ( one ) {
+ return value;
+ }
+
+ // Multi-Selects return an array
+ values.push( value );
+ }
+ }
+
+ return values;
+ }
+
+ // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
+ if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
+ return elem.getAttribute("value") === null ? "on" : elem.value;
+ }
+
+
+ // Everything else, we just grab the value
+ return (elem.value || "").replace(rreturn, "");
+
+ }
+
+ return undefined;
+ }
+
+ var isFunction = jQuery.isFunction(value);
+
+ return this.each(function(i) {
+ var self = jQuery(this), val = value;
+
+ if ( this.nodeType !== 1 ) {
+ return;
+ }
+
+ if ( isFunction ) {
+ val = value.call(this, i, self.val());
+ }
+
+ // Typecast each time if the value is a Function and the appended
+ // value is therefore different each time.
+ if ( typeof val === "number" ) {
+ val += "";
+ }
+
+ if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
+ this.checked = jQuery.inArray( self.val(), val ) >= 0;
+
+ } else if ( jQuery.nodeName( this, "select" ) ) {
+ var values = jQuery.makeArray(val);
+
+ jQuery( "option", this ).each(function() {
+ this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
+ });
+
+ if ( !values.length ) {
+ this.selectedIndex = -1;
+ }
+
+ } else {
+ this.value = val;
+ }
+ });
+ }
+});
+
+jQuery.extend({
+ attrFn: {
+ val: true,
+ css: true,
+ html: true,
+ text: true,
+ data: true,
+ width: true,
+ height: true,
+ offset: true
+ },
+
+ attr: function( elem, name, value, pass ) {
+ // don't set attributes on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ if ( pass && name in jQuery.attrFn ) {
+ return jQuery(elem)[name](value);
+ }
+
+ var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
+ // Whether we are setting (or getting)
+ set = value !== undefined;
+
+ // Try to normalize/fix the name
+ name = notxml && jQuery.props[ name ] || name;
+
+ // Only do all the following if this is a node (faster for style)
+ if ( elem.nodeType === 1 ) {
+ // These attributes require special treatment
+ var special = rspecialurl.test( name );
+
+ // Safari mis-reports the default selected property of an option
+ // Accessing the parent's selectedIndex property fixes it
+ if ( name === "selected" && !jQuery.support.optSelected ) {
+ var parent = elem.parentNode;
+ if ( parent ) {
+ parent.selectedIndex;
+
+ // Make sure that it also works with optgroups, see #5701
+ if ( parent.parentNode ) {
+ parent.parentNode.selectedIndex;
+ }
+ }
+ }
+
+ // If applicable, access the attribute via the DOM 0 way
+ if ( name in elem && notxml && !special ) {
+ if ( set ) {
+ // We can't allow the type property to be changed (since it causes problems in IE)
+ if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
+ throw "type property can't be changed";
+ }
+
+ elem[ name ] = value;
+ }
+
+ // browsers index elements by id/name on forms, give priority to attributes.
+ if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
+ return elem.getAttributeNode( name ).nodeValue;
+ }
+
+ // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
+ // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
+ if ( name === "tabIndex" ) {
+ var attributeNode = elem.getAttributeNode( "tabIndex" );
+
+ return attributeNode && attributeNode.specified ?
+ attributeNode.value :
+ rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
+ 0 :
+ undefined;
+ }
+
+ return elem[ name ];
+ }
+
+ if ( !jQuery.support.style && notxml && name === "style" ) {
+ if ( set ) {
+ elem.style.cssText = "" + value;
+ }
+
+ return elem.style.cssText;
+ }
+
+ if ( set ) {
+ // convert the value to a string (all browsers do this but IE) see #1070
+ elem.setAttribute( name, "" + value );
+ }
+
+ var attr = !jQuery.support.hrefNormalized && notxml && special ?
+ // Some attributes require a special call on IE
+ elem.getAttribute( name, 2 ) :
+ elem.getAttribute( name );
+
+ // Non-existent attributes return null, we normalize to undefined
+ return attr === null ? undefined : attr;
+ }
+
+ // elem is actually elem.style ... set the style
+ // Using attr for specific style information is now deprecated. Use style insead.
+ return jQuery.style( elem, name, value );
+ }
+});
+var fcleanup = function( nm ) {
+ return nm.replace(/[^\w\s\.\|`]/g, function( ch ) {
+ return "\\" + ch;
+ });
+};
+
+/*
+ * A number of helper functions used for managing events.
+ * Many of the ideas behind this code originated from
+ * Dean Edwards' addEvent library.
+ */
+jQuery.event = {
+
+ // Bind an event to an element
+ // Original by Dean Edwards
+ add: function( elem, types, handler, data ) {
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ // For whatever reason, IE has trouble passing the window object
+ // around, causing it to be cloned in the process
+ if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) {
+ elem = window;
+ }
+
+ // Make sure that the function being executed has a unique ID
+ if ( !handler.guid ) {
+ handler.guid = jQuery.guid++;
+ }
+
+ // if data is passed, bind to handler
+ if ( data !== undefined ) {
+ // Create temporary function pointer to original handler
+ var fn = handler;
+
+ // Create unique handler function, wrapped around original handler
+ handler = jQuery.proxy( fn );
+
+ // Store data in unique handler
+ handler.data = data;
+ }
+
+ // Init the element's event structure
+ var events = jQuery.data( elem, "events" ) || jQuery.data( elem, "events", {} ),
+ handle = jQuery.data( elem, "handle" ), eventHandle;
+
+ if ( !handle ) {
+ eventHandle = function() {
+ // Handle the second event of a trigger and when
+ // an event is called after a page has unloaded
+ return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
+ jQuery.event.handle.apply( eventHandle.elem, arguments ) :
+ undefined;
+ };
+
+ handle = jQuery.data( elem, "handle", eventHandle );
+ }
+
+ // If no handle is found then we must be trying to bind to one of the
+ // banned noData elements
+ if ( !handle ) {
+ return;
+ }
+
+ // Add elem as a property of the handle function
+ // This is to prevent a memory leak with non-native
+ // event in IE.
+ handle.elem = elem;
+
+ // Handle multiple events separated by a space
+ // jQuery(...).bind("mouseover mouseout", fn);
+ types = types.split( /\s+/ );
+ var type, i=0;
+ while ( (type = types[ i++ ]) ) {
+ // Namespaced event handlers
+ var namespaces = type.split(".");
+ type = namespaces.shift();
+ handler.type = namespaces.slice(0).sort().join(".");
+
+ // Get the current list of functions bound to this event
+ var handlers = events[ type ],
+ special = this.special[ type ] || {};
+
+
+
+ // Init the event handler queue
+ if ( !handlers ) {
+ handlers = events[ type ] = {};
+
+ // Check for a special event handler
+ // Only use addEventListener/attachEvent if the special
+ // events handler returns false
+ if ( !special.setup || special.setup.call( elem, data, namespaces, handler) === false ) {
+ // Bind the global event handler to the element
+ if ( elem.addEventListener ) {
+ elem.addEventListener( type, handle, false );
+ } else if ( elem.attachEvent ) {
+ elem.attachEvent( "on" + type, handle );
+ }
+ }
+ }
+
+ if ( special.add ) {
+ var modifiedHandler = special.add.call( elem, handler, data, namespaces, handlers );
+ if ( modifiedHandler && jQuery.isFunction( modifiedHandler ) ) {
+ modifiedHandler.guid = modifiedHandler.guid || handler.guid;
+ handler = modifiedHandler;
+ }
+ }
+
+ // Add the function to the element's handler list
+ handlers[ handler.guid ] = handler;
+
+ // Keep track of which events have been used, for global triggering
+ this.global[ type ] = true;
+ }
+
+ // Nullify elem to prevent memory leaks in IE
+ elem = null;
+ },
+
+ global: {},
+
+ // Detach an event or set of events from an element
+ remove: function( elem, types, handler ) {
+ // don't do events on text and comment nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ var events = jQuery.data( elem, "events" ), ret, type, fn;
+
+ if ( events ) {
+ // Unbind all events for the element
+ if ( types === undefined || (typeof types === "string" && types.charAt(0) === ".") ) {
+ for ( type in events ) {
+ this.remove( elem, type + (types || "") );
+ }
+ } else {
+ // types is actually an event object here
+ if ( types.type ) {
+ handler = types.handler;
+ types = types.type;
+ }
+
+ // Handle multiple events separated by a space
+ // jQuery(...).unbind("mouseover mouseout", fn);
+ types = types.split(/\s+/);
+ var i = 0;
+ while ( (type = types[ i++ ]) ) {
+ // Namespaced event handlers
+ var namespaces = type.split(".");
+ type = namespaces.shift();
+ var all = !namespaces.length,
+ cleaned = jQuery.map( namespaces.slice(0).sort(), fcleanup ),
+ namespace = new RegExp("(^|\\.)" + cleaned.join("\\.(?:.*\\.)?") + "(\\.|$)"),
+ special = this.special[ type ] || {};
+
+ if ( events[ type ] ) {
+ // remove the given handler for the given type
+ if ( handler ) {
+ fn = events[ type ][ handler.guid ];
+ delete events[ type ][ handler.guid ];
+
+ // remove all handlers for the given type
+ } else {
+ for ( var handle in events[ type ] ) {
+ // Handle the removal of namespaced events
+ if ( all || namespace.test( events[ type ][ handle ].type ) ) {
+ delete events[ type ][ handle ];
+ }
+ }
+ }
+
+ if ( special.remove ) {
+ special.remove.call( elem, namespaces, fn);
+ }
+
+ // remove generic event handler if no more handlers exist
+ for ( ret in events[ type ] ) {
+ break;
+ }
+ if ( !ret ) {
+ if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
+ if ( elem.removeEventListener ) {
+ elem.removeEventListener( type, jQuery.data( elem, "handle" ), false );
+ } else if ( elem.detachEvent ) {
+ elem.detachEvent( "on" + type, jQuery.data( elem, "handle" ) );
+ }
+ }
+ ret = null;
+ delete events[ type ];
+ }
+ }
+ }
+ }
+
+ // Remove the expando if it's no longer used
+ for ( ret in events ) {
+ break;
+ }
+ if ( !ret ) {
+ var handle = jQuery.data( elem, "handle" );
+ if ( handle ) {
+ handle.elem = null;
+ }
+ jQuery.removeData( elem, "events" );
+ jQuery.removeData( elem, "handle" );
+ }
+ }
+ },
+
+ // bubbling is internal
+ trigger: function( event, data, elem /*, bubbling */ ) {
+ // Event object or event type
+ var type = event.type || event,
+ bubbling = arguments[3];
+
+ if ( !bubbling ) {
+ event = typeof event === "object" ?
+ // jQuery.Event object
+ event[expando] ? event :
+ // Object literal
+ jQuery.extend( jQuery.Event(type), event ) :
+ // Just the event type (string)
+ jQuery.Event(type);
+
+ if ( type.indexOf("!") >= 0 ) {
+ event.type = type = type.slice(0, -1);
+ event.exclusive = true;
+ }
+
+ // Handle a global trigger
+ if ( !elem ) {
+ // Don't bubble custom events when global (to avoid too much overhead)
+ event.stopPropagation();
+
+ // Only trigger if we've ever bound an event for it
+ if ( this.global[ type ] ) {
+ jQuery.each( jQuery.cache, function() {
+ if ( this.events && this.events[type] ) {
+ jQuery.event.trigger( event, data, this.handle.elem );
+ }
+ });
+ }
+ }
+
+ // Handle triggering a single element
+
+ // don't do events on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ // Clean up in case it is reused
+ event.result = undefined;
+ event.target = elem;
+
+ // Clone the incoming data, if any
+ data = jQuery.makeArray( data );
+ data.unshift( event );
+ }
+
+ event.currentTarget = elem;
+
+ // Trigger the event, it is assumed that "handle" is a function
+ var handle = jQuery.data( elem, "handle" );
+ if ( handle ) {
+ handle.apply( elem, data );
+ }
+
+ var nativeFn, nativeHandler;
+ try {
+ if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
+ nativeFn = elem[ type ];
+ nativeHandler = elem[ "on" + type ];
+ }
+ // prevent IE from throwing an error for some elements with some event types, see #3533
+ } catch (e) {}
+
+ var isClick = jQuery.nodeName(elem, "a") && type === "click";
+
+ // Trigger the native events (except for clicks on links)
+ if ( !bubbling && nativeFn && !event.isDefaultPrevented() && !isClick ) {
+ this.triggered = true;
+ try {
+ elem[ type ]();
+ // prevent IE from throwing an error for some hidden elements
+ } catch (e) {}
+
+ // Handle triggering native .onfoo handlers
+ } else if ( nativeHandler && elem[ "on" + type ].apply( elem, data ) === false ) {
+ event.result = false;
+ }
+
+ this.triggered = false;
+
+ if ( !event.isPropagationStopped() ) {
+ var parent = elem.parentNode || elem.ownerDocument;
+ if ( parent ) {
+ jQuery.event.trigger( event, data, parent, true );
+ }
+ }
+ },
+
+ handle: function( event ) {
+ // returned undefined or false
+ var all, handlers;
+
+ event = arguments[0] = jQuery.event.fix( event || window.event );
+ event.currentTarget = this;
+
+ // Namespaced event handlers
+ var namespaces = event.type.split(".");
+ event.type = namespaces.shift();
+
+ // Cache this now, all = true means, any handler
+ all = !namespaces.length && !event.exclusive;
+
+ var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)");
+
+ handlers = ( jQuery.data(this, "events") || {} )[ event.type ];
+
+ for ( var j in handlers ) {
+ var handler = handlers[ j ];
+
+ // Filter the functions by class
+ if ( all || namespace.test(handler.type) ) {
+ // Pass in a reference to the handler function itself
+ // So that we can later remove it
+ event.handler = handler;
+ event.data = handler.data;
+
+ var ret = handler.apply( this, arguments );
+
+ if ( ret !== undefined ) {
+ event.result = ret;
+ if ( ret === false ) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }
+
+ if ( event.isImmediatePropagationStopped() ) {
+ break;
+ }
+
+ }
+ }
+
+ return event.result;
+ },
+
+ props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
+
+ fix: function( event ) {
+ if ( event[ expando ] ) {
+ return event;
+ }
+
+ // store a copy of the original event object
+ // and "clone" to set read-only properties
+ var originalEvent = event;
+ event = jQuery.Event( originalEvent );
+
+ for ( var i = this.props.length, prop; i; ) {
+ prop = this.props[ --i ];
+ event[ prop ] = originalEvent[ prop ];
+ }
+
+ // Fix target property, if necessary
+ if ( !event.target ) {
+ event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
+ }
+
+ // check if target is a textnode (safari)
+ if ( event.target.nodeType === 3 ) {
+ event.target = event.target.parentNode;
+ }
+
+ // Add relatedTarget, if necessary
+ if ( !event.relatedTarget && event.fromElement ) {
+ event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
+ }
+
+ // Calculate pageX/Y if missing and clientX/Y available
+ if ( event.pageX == null && event.clientX != null ) {
+ var doc = document.documentElement, body = document.body;
+ event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
+ event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
+ }
+
+ // Add which for key events
+ if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) {
+ event.which = event.charCode || event.keyCode;
+ }
+
+ // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
+ if ( !event.metaKey && event.ctrlKey ) {
+ event.metaKey = event.ctrlKey;
+ }
+
+ // Add which for click: 1 === left; 2 === middle; 3 === right
+ // Note: button is not normalized, so don't use it
+ if ( !event.which && event.button !== undefined ) {
+ event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
+ }
+
+ return event;
+ },
+
+ // Deprecated, use jQuery.guid instead
+ guid: 1E8,
+
+ // Deprecated, use jQuery.proxy instead
+ proxy: jQuery.proxy,
+
+ special: {
+ ready: {
+ // Make sure the ready event is setup
+ setup: jQuery.bindReady,
+ teardown: jQuery.noop
+ },
+
+ live: {
+ add: function( proxy, data, namespaces, live ) {
+ jQuery.extend( proxy, data || {} );
+
+ proxy.guid += data.selector + data.live;
+ jQuery.event.add( this, data.live, liveHandler, data );
+
+ },
+
+ remove: function( namespaces ) {
+ if ( namespaces.length ) {
+ var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)");
+
+ jQuery.each( (jQuery.data(this, "events").live || {}), function() {
+ if ( name.test(this.type) ) {
+ remove++;
+ }
+ });
+
+ if ( remove < 1 ) {
+ jQuery.event.remove( this, namespaces[0], liveHandler );
+ }
+ }
+ },
+ special: {}
+ },
+ beforeunload: {
+ setup: function( data, namespaces, fn ) {
+ // We only want to do this special case on windows
+ if ( this.setInterval ) {
+ this.onbeforeunload = fn;
+ }
+
+ return false;
+ },
+ teardown: function( namespaces, fn ) {
+ if ( this.onbeforeunload === fn ) {
+ this.onbeforeunload = null;
+ }
+ }
+ }
+ }
+};
+
+jQuery.Event = function( src ) {
+ // Allow instantiation without the 'new' keyword
+ if ( !this.preventDefault ) {
+ return new jQuery.Event( src );
+ }
+
+ // Event object
+ if ( src && src.type ) {
+ this.originalEvent = src;
+ this.type = src.type;
+ // Event type
+ } else {
+ this.type = src;
+ }
+
+ // timeStamp is buggy for some events on Firefox(#3843)
+ // So we won't rely on the native value
+ this.timeStamp = now();
+
+ // Mark it as fixed
+ this[ expando ] = true;
+};
+
+function returnFalse() {
+ return false;
+}
+function returnTrue() {
+ return true;
+}
+
+// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
+// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
+jQuery.Event.prototype = {
+ preventDefault: function() {
+ this.isDefaultPrevented = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+
+ // if preventDefault exists run it on the original event
+ if ( e.preventDefault ) {
+ e.preventDefault();
+ }
+ // otherwise set the returnValue property of the original event to false (IE)
+ e.returnValue = false;
+ },
+ stopPropagation: function() {
+ this.isPropagationStopped = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+ // if stopPropagation exists run it on the original event
+ if ( e.stopPropagation ) {
+ e.stopPropagation();
+ }
+ // otherwise set the cancelBubble property of the original event to true (IE)
+ e.cancelBubble = true;
+ },
+ stopImmediatePropagation: function() {
+ this.isImmediatePropagationStopped = returnTrue;
+ this.stopPropagation();
+ },
+ isDefaultPrevented: returnFalse,
+ isPropagationStopped: returnFalse,
+ isImmediatePropagationStopped: returnFalse
+};
+
+// Checks if an event happened on an element within another element
+// Used in jQuery.event.special.mouseenter and mouseleave handlers
+var withinElement = function( event ) {
+ // Check if mouse(over|out) are still within the same parent element
+ var parent = event.relatedTarget;
+
+ // Traverse up the tree
+ while ( parent && parent !== this ) {
+ // Firefox sometimes assigns relatedTarget a XUL element
+ // which we cannot access the parentNode property of
+ try {
+ parent = parent.parentNode;
+
+ // assuming we've left the element since we most likely mousedover a xul element
+ } catch(e) {
+ break;
+ }
+ }
+
+ if ( parent !== this ) {
+ // set the correct event type
+ event.type = event.data;
+
+ // handle event if we actually just moused on to a non sub-element
+ jQuery.event.handle.apply( this, arguments );
+ }
+
+},
+
+// In case of event delegation, we only need to rename the event.type,
+// liveHandler will take care of the rest.
+delegate = function( event ) {
+ event.type = event.data;
+ jQuery.event.handle.apply( this, arguments );
+};
+
+// Create mouseenter and mouseleave events
+jQuery.each({
+ mouseenter: "mouseover",
+ mouseleave: "mouseout"
+}, function( orig, fix ) {
+ jQuery.event.special[ orig ] = {
+ setup: function( data ) {
+ jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
+ },
+ teardown: function( data ) {
+ jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
+ }
+ };
+});
+
+// submit delegation
+if ( !jQuery.support.submitBubbles ) {
+
+jQuery.event.special.submit = {
+ setup: function( data, namespaces, fn ) {
+ if ( this.nodeName.toLowerCase() !== "form" ) {
+ jQuery.event.add(this, "click.specialSubmit." + fn.guid, function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
+ return trigger( "submit", this, arguments );
+ }
+ });
+
+ jQuery.event.add(this, "keypress.specialSubmit." + fn.guid, function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
+ return trigger( "submit", this, arguments );
+ }
+ });
+
+ } else {
+ return false;
+ }
+ },
+
+ remove: function( namespaces, fn ) {
+ jQuery.event.remove( this, "click.specialSubmit" + (fn ? "."+fn.guid : "") );
+ jQuery.event.remove( this, "keypress.specialSubmit" + (fn ? "."+fn.guid : "") );
+ }
+};
+
+}
+
+// change delegation, happens here so we have bind.
+if ( !jQuery.support.changeBubbles ) {
+
+var formElems = /textarea|input|select/i;
+
+function getVal( elem ) {
+ var type = elem.type, val = elem.value;
+
+ if ( type === "radio" || type === "checkbox" ) {
+ val = elem.checked;
+
+ } else if ( type === "select-multiple" ) {
+ val = elem.selectedIndex > -1 ?
+ jQuery.map( elem.options, function( elem ) {
+ return elem.selected;
+ }).join("-") :
+ "";
+
+ } else if ( elem.nodeName.toLowerCase() === "select" ) {
+ val = elem.selectedIndex;
+ }
+
+ return val;
+}
+
+function testChange( e ) {
+ var elem = e.target, data, val;
+
+ if ( !formElems.test( elem.nodeName ) || elem.readOnly ) {
+ return;
+ }
+
+ data = jQuery.data( elem, "_change_data" );
+ val = getVal(elem);
+
+ if ( val === data ) {
+ return;
+ }
+
+ // the current data will be also retrieved by beforeactivate
+ if ( e.type !== "focusout" || elem.type !== "radio" ) {
+ jQuery.data( elem, "_change_data", val );
+ }
+
+ if ( elem.type !== "select" && (data != null || val) ) {
+ e.type = "change";
+ return jQuery.event.trigger( e, arguments[1], this );
+ }
+}
+
+jQuery.event.special.change = {
+ filters: {
+ focusout: testChange,
+
+ click: function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
+ return testChange.call( this, e );
+ }
+ },
+
+ // Change has to be called before submit
+ // Keydown will be called before keypress, which is used in submit-event delegation
+ keydown: function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
+ (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
+ type === "select-multiple" ) {
+ return testChange.call( this, e );
+ }
+ },
+
+ // Beforeactivate happens also before the previous element is blurred
+ // with this event you can't trigger a change event, but you can store
+ // information/focus[in] is not needed anymore
+ beforeactivate: function( e ) {
+ var elem = e.target;
+
+ if ( elem.nodeName.toLowerCase() === "input" && elem.type === "radio" ) {
+ jQuery.data( elem, "_change_data", getVal(elem) );
+ }
+ }
+ },
+ setup: function( data, namespaces, fn ) {
+ for ( var type in changeFilters ) {
+ jQuery.event.add( this, type + ".specialChange." + fn.guid, changeFilters[type] );
+ }
+
+ return formElems.test( this.nodeName );
+ },
+ remove: function( namespaces, fn ) {
+ for ( var type in changeFilters ) {
+ jQuery.event.remove( this, type + ".specialChange" + (fn ? "."+fn.guid : ""), changeFilters[type] );
+ }
+
+ return formElems.test( this.nodeName );
+ }
+};
+
+var changeFilters = jQuery.event.special.change.filters;
+
+}
+
+function trigger( type, elem, args ) {
+ args[0].type = type;
+ return jQuery.event.handle.apply( elem, args );
+}
+
+// Create "bubbling" focus and blur events
+if ( document.addEventListener ) {
+ jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
+ jQuery.event.special[ fix ] = {
+ setup: function() {
+ this.addEventListener( orig, handler, true );
+ },
+ teardown: function() {
+ this.removeEventListener( orig, handler, true );
+ }
+ };
+
+ function handler( e ) {
+ e = jQuery.event.fix( e );
+ e.type = fix;
+ return jQuery.event.handle.call( this, e );
+ }
+ });
+}
+
+jQuery.each(["bind", "one"], function( i, name ) {
+ jQuery.fn[ name ] = function( type, data, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" ) {
+ for ( var key in type ) {
+ this[ name ](key, data, type[key], fn);
+ }
+ return this;
+ }
+
+ if ( jQuery.isFunction( data ) ) {
+ thisObject = fn;
+ fn = data;
+ data = undefined;
+ }
+
+ var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
+ jQuery( this ).unbind( event, handler );
+ return fn.apply( this, arguments );
+ }) : fn;
+
+ return type === "unload" && name !== "one" ?
+ this.one( type, data, fn, thisObject ) :
+ this.each(function() {
+ jQuery.event.add( this, type, handler, data );
+ });
+ };
+});
+
+jQuery.fn.extend({
+ unbind: function( type, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" && !type.preventDefault ) {
+ for ( var key in type ) {
+ this.unbind(key, type[key]);
+ }
+ return this;
+ }
+
+ return this.each(function() {
+ jQuery.event.remove( this, type, fn );
+ });
+ },
+ trigger: function( type, data ) {
+ return this.each(function() {
+ jQuery.event.trigger( type, data, this );
+ });
+ },
+
+ triggerHandler: function( type, data ) {
+ if ( this[0] ) {
+ var event = jQuery.Event( type );
+ event.preventDefault();
+ event.stopPropagation();
+ jQuery.event.trigger( event, data, this[0] );
+ return event.result;
+ }
+ },
+
+ toggle: function( fn ) {
+ // Save reference to arguments for access in closure
+ var args = arguments, i = 1;
+
+ // link all the functions, so any of them can unbind this click handler
+ while ( i < args.length ) {
+ jQuery.proxy( fn, args[ i++ ] );
+ }
+
+ return this.click( jQuery.proxy( fn, function( event ) {
+ // Figure out which function to execute
+ var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
+ jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
+
+ // Make sure that clicks stop
+ event.preventDefault();
+
+ // and execute the function
+ return args[ lastToggle ].apply( this, arguments ) || false;
+ }));
+ },
+
+ hover: function( fnOver, fnOut ) {
+ return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
+ },
+
+ live: function( type, data, fn ) {
+ if ( jQuery.isFunction( data ) ) {
+ fn = data;
+ data = undefined;
+ }
+
+ jQuery( this.context ).bind( liveConvert( type, this.selector ), {
+ data: data, selector: this.selector, live: type
+ }, fn );
+
+ return this;
+ },
+
+ die: function( type, fn ) {
+ jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null );
+ return this;
+ }
+});
+
+function liveHandler( event ) {
+ var stop = true, elems = [], selectors = [], args = arguments,
+ related, match, fn, elem, j, i, data,
+ live = jQuery.extend({}, jQuery.data( this, "events" ).live);
+
+ for ( j in live ) {
+ fn = live[j];
+ if ( fn.live === event.type ||
+ fn.altLive && jQuery.inArray(event.type, fn.altLive) > -1 ) {
+
+ data = fn.data;
+ if ( !(data.beforeFilter && data.beforeFilter[event.type] &&
+ !data.beforeFilter[event.type](event)) ) {
+ selectors.push( fn.selector );
+ }
+ } else {
+ delete live[j];
+ }
+ }
+
+ match = jQuery( event.target ).closest( selectors, event.currentTarget );
+
+ for ( i = 0, l = match.length; i < l; i++ ) {
+ for ( j in live ) {
+ fn = live[j];
+ elem = match[i].elem;
+ related = null;
+
+ if ( match[i].selector === fn.selector ) {
+ // Those two events require additional checking
+ if ( fn.live === "mouseenter" || fn.live === "mouseleave" ) {
+ related = jQuery( event.relatedTarget ).closest( fn.selector )[0];
+ }
+
+ if ( !related || related !== elem ) {
+ elems.push({ elem: elem, fn: fn });
+ }
+ }
+ }
+ }
+
+ for ( i = 0, l = elems.length; i < l; i++ ) {
+ match = elems[i];
+ event.currentTarget = match.elem;
+ event.data = match.fn.data;
+ if ( match.fn.apply( match.elem, args ) === false ) {
+ stop = false;
+ break;
+ }
+ }
+
+ return stop;
+}
+
+function liveConvert( type, selector ) {
+ return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "&")].join(".");
+}
+
+jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
+ "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
+ "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
+
+ // Handle event binding
+ jQuery.fn[ name ] = function( fn ) {
+ return fn ? this.bind( name, fn ) : this.trigger( name );
+ };
+
+ if ( jQuery.attrFn ) {
+ jQuery.attrFn[ name ] = true;
+ }
+});
+
+// Prevent memory leaks in IE
+// Window isn't included so as not to unbind existing unload events
+// More info:
+// - http://isaacschlueter.com/2006/10/msie-memory-leaks/
+if ( window.attachEvent && !window.addEventListener ) {
+ window.attachEvent("onunload", function() {
+ for ( var id in jQuery.cache ) {
+ if ( jQuery.cache[ id ].handle ) {
+ // Try/Catch is to handle iframes being unloaded, see #4280
+ try {
+ jQuery.event.remove( jQuery.cache[ id ].handle.elem );
+ } catch(e) {}
+ }
+ }
+ });
+}
+/*!
+ * Sizzle CSS Selector Engine - v1.0
+ * Copyright 2009, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ * More information: http://sizzlejs.com/
+ */
+(function(){
+
+var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
+ done = 0,
+ toString = Object.prototype.toString,
+ hasDuplicate = false,
+ baseHasDuplicate = true;
+
+// Here we check if the JavaScript engine is using some sort of
+// optimization where it does not always call our comparision
+// function. If that is the case, discard the hasDuplicate value.
+// Thus far that includes Google Chrome.
+[0, 0].sort(function(){
+ baseHasDuplicate = false;
+ return 0;
+});
+
+var Sizzle = function(selector, context, results, seed) {
+ results = results || [];
+ var origContext = context = context || document;
+
+ if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
+ return [];
+ }
+
+ if ( !selector || typeof selector !== "string" ) {
+ return results;
+ }
+
+ var parts = [], m, set, checkSet, extra, prune = true, contextXML = isXML(context),
+ soFar = selector;
+
+ // Reset the position of the chunker regexp (start from head)
+ while ( (chunker.exec(""), m = chunker.exec(soFar)) !== null ) {
+ soFar = m[3];
+
+ parts.push( m[1] );
+
+ if ( m[2] ) {
+ extra = m[3];
+ break;
+ }
+ }
+
+ if ( parts.length > 1 && origPOS.exec( selector ) ) {
+ if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
+ set = posProcess( parts[0] + parts[1], context );
+ } else {
+ set = Expr.relative[ parts[0] ] ?
+ [ context ] :
+ Sizzle( parts.shift(), context );
+
+ while ( parts.length ) {
+ selector = parts.shift();
+
+ if ( Expr.relative[ selector ] ) {
+ selector += parts.shift();
+ }
+
+ set = posProcess( selector, set );
+ }
+ }
+ } else {
+ // Take a shortcut and set the context if the root selector is an ID
+ // (but not if it'll be faster if the inner selector is an ID)
+ if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
+ Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
+ var ret = Sizzle.find( parts.shift(), context, contextXML );
+ context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];
+ }
+
+ if ( context ) {
+ var ret = seed ?
+ { expr: parts.pop(), set: makeArray(seed) } :
+ Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
+ set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set;
+
+ if ( parts.length > 0 ) {
+ checkSet = makeArray(set);
+ } else {
+ prune = false;
+ }
+
+ while ( parts.length ) {
+ var cur = parts.pop(), pop = cur;
+
+ if ( !Expr.relative[ cur ] ) {
+ cur = "";
+ } else {
+ pop = parts.pop();
+ }
+
+ if ( pop == null ) {
+ pop = context;
+ }
+
+ Expr.relative[ cur ]( checkSet, pop, contextXML );
+ }
+ } else {
+ checkSet = parts = [];
+ }
+ }
+
+ if ( !checkSet ) {
+ checkSet = set;
+ }
+
+ if ( !checkSet ) {
+ throw "Syntax error, unrecognized expression: " + (cur || selector);
+ }
+
+ if ( toString.call(checkSet) === "[object Array]" ) {
+ if ( !prune ) {
+ results.push.apply( results, checkSet );
+ } else if ( context && context.nodeType === 1 ) {
+ for ( var i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {
+ results.push( set[i] );
+ }
+ }
+ } else {
+ for ( var i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
+ results.push( set[i] );
+ }
+ }
+ }
+ } else {
+ makeArray( checkSet, results );
+ }
+
+ if ( extra ) {
+ Sizzle( extra, origContext, results, seed );
+ Sizzle.uniqueSort( results );
+ }
+
+ return results;
+};
+
+Sizzle.uniqueSort = function(results){
+ if ( sortOrder ) {
+ hasDuplicate = baseHasDuplicate;
+ results.sort(sortOrder);
+
+ if ( hasDuplicate ) {
+ for ( var i = 1; i < results.length; i++ ) {
+ if ( results[i] === results[i-1] ) {
+ results.splice(i--, 1);
+ }
+ }
+ }
+ }
+
+ return results;
+};
+
+Sizzle.matches = function(expr, set){
+ return Sizzle(expr, null, null, set);
+};
+
+Sizzle.find = function(expr, context, isXML){
+ var set, match;
+
+ if ( !expr ) {
+ return [];
+ }
+
+ for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
+ var type = Expr.order[i], match;
+
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
+ var left = match[1];
+ match.splice(1,1);
+
+ if ( left.substr( left.length - 1 ) !== "\\" ) {
+ match[1] = (match[1] || "").replace(/\\/g, "");
+ set = Expr.find[ type ]( match, context, isXML );
+ if ( set != null ) {
+ expr = expr.replace( Expr.match[ type ], "" );
+ break;
+ }
+ }
+ }
+ }
+
+ if ( !set ) {
+ set = context.getElementsByTagName("*");
+ }
+
+ return {set: set, expr: expr};
+};
+
+Sizzle.filter = function(expr, set, inplace, not){
+ var old = expr, result = [], curLoop = set, match, anyFound,
+ isXMLFilter = set && set[0] && isXML(set[0]);
+
+ while ( expr && set.length ) {
+ for ( var type in Expr.filter ) {
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
+ var filter = Expr.filter[ type ], found, item, left = match[1];
+ anyFound = false;
+
+ match.splice(1,1);
+
+ if ( left.substr( left.length - 1 ) === "\\" ) {
+ continue;
+ }
+
+ if ( curLoop === result ) {
+ result = [];
+ }
+
+ if ( Expr.preFilter[ type ] ) {
+ match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
+
+ if ( !match ) {
+ anyFound = found = true;
+ } else if ( match === true ) {
+ continue;
+ }
+ }
+
+ if ( match ) {
+ for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
+ if ( item ) {
+ found = filter( item, match, i, curLoop );
+ var pass = not ^ !!found;
+
+ if ( inplace && found != null ) {
+ if ( pass ) {
+ anyFound = true;
+ } else {
+ curLoop[i] = false;
+ }
+ } else if ( pass ) {
+ result.push( item );
+ anyFound = true;
+ }
+ }
+ }
+ }
+
+ if ( found !== undefined ) {
+ if ( !inplace ) {
+ curLoop = result;
+ }
+
+ expr = expr.replace( Expr.match[ type ], "" );
+
+ if ( !anyFound ) {
+ return [];
+ }
+
+ break;
+ }
+ }
+ }
+
+ // Improper expression
+ if ( expr === old ) {
+ if ( anyFound == null ) {
+ throw "Syntax error, unrecognized expression: " + expr;
+ } else {
+ break;
+ }
+ }
+
+ old = expr;
+ }
+
+ return curLoop;
+};
+
+var Expr = Sizzle.selectors = {
+ order: [ "ID", "NAME", "TAG" ],
+ match: {
+ ID: /#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
+ CLASS: /\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
+ NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,
+ ATTR: /\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
+ TAG: /^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,
+ CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
+ POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
+ PSEUDO: /:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
+ },
+ leftMatch: {},
+ attrMap: {
+ "class": "className",
+ "for": "htmlFor"
+ },
+ attrHandle: {
+ href: function(elem){
+ return elem.getAttribute("href");
+ }
+ },
+ relative: {
+ "+": function(checkSet, part){
+ var isPartStr = typeof part === "string",
+ isTag = isPartStr && !/\W/.test(part),
+ isPartStrNotTag = isPartStr && !isTag;
+
+ if ( isTag ) {
+ part = part.toLowerCase();
+ }
+
+ for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
+ if ( (elem = checkSet[i]) ) {
+ while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
+
+ checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
+ elem || false :
+ elem === part;
+ }
+ }
+
+ if ( isPartStrNotTag ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ },
+ ">": function(checkSet, part){
+ var isPartStr = typeof part === "string";
+
+ if ( isPartStr && !/\W/.test(part) ) {
+ part = part.toLowerCase();
+
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ var parent = elem.parentNode;
+ checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
+ }
+ }
+ } else {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ checkSet[i] = isPartStr ?
+ elem.parentNode :
+ elem.parentNode === part;
+ }
+ }
+
+ if ( isPartStr ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ }
+ },
+ "": function(checkSet, part, isXML){
+ var doneName = done++, checkFn = dirCheck;
+
+ if ( typeof part === "string" && !/\W/.test(part) ) {
+ var nodeCheck = part = part.toLowerCase();
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
+ },
+ "~": function(checkSet, part, isXML){
+ var doneName = done++, checkFn = dirCheck;
+
+ if ( typeof part === "string" && !/\W/.test(part) ) {
+ var nodeCheck = part = part.toLowerCase();
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);
+ }
+ },
+ find: {
+ ID: function(match, context, isXML){
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+ return m ? [m] : [];
+ }
+ },
+ NAME: function(match, context){
+ if ( typeof context.getElementsByName !== "undefined" ) {
+ var ret = [], results = context.getElementsByName(match[1]);
+
+ for ( var i = 0, l = results.length; i < l; i++ ) {
+ if ( results[i].getAttribute("name") === match[1] ) {
+ ret.push( results[i] );
+ }
+ }
+
+ return ret.length === 0 ? null : ret;
+ }
+ },
+ TAG: function(match, context){
+ return context.getElementsByTagName(match[1]);
+ }
+ },
+ preFilter: {
+ CLASS: function(match, curLoop, inplace, result, not, isXML){
+ match = " " + match[1].replace(/\\/g, "") + " ";
+
+ if ( isXML ) {
+ return match;
+ }
+
+ for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
+ if ( elem ) {
+ if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) {
+ if ( !inplace ) {
+ result.push( elem );
+ }
+ } else if ( inplace ) {
+ curLoop[i] = false;
+ }
+ }
+ }
+
+ return false;
+ },
+ ID: function(match){
+ return match[1].replace(/\\/g, "");
+ },
+ TAG: function(match, curLoop){
+ return match[1].toLowerCase();
+ },
+ CHILD: function(match){
+ if ( match[1] === "nth" ) {
+ // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
+ var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
+ match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
+ !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
+
+ // calculate the numbers (first)n+(last) including if they are negative
+ match[2] = (test[1] + (test[2] || 1)) - 0;
+ match[3] = test[3] - 0;
+ }
+
+ // TODO: Move to normal caching system
+ match[0] = done++;
+
+ return match;
+ },
+ ATTR: function(match, curLoop, inplace, result, not, isXML){
+ var name = match[1].replace(/\\/g, "");
+
+ if ( !isXML && Expr.attrMap[name] ) {
+ match[1] = Expr.attrMap[name];
+ }
+
+ if ( match[2] === "~=" ) {
+ match[4] = " " + match[4] + " ";
+ }
+
+ return match;
+ },
+ PSEUDO: function(match, curLoop, inplace, result, not){
+ if ( match[1] === "not" ) {
+ // If we're dealing with a complex expression, or a simple one
+ if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
+ match[3] = Sizzle(match[3], null, null, curLoop);
+ } else {
+ var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
+ if ( !inplace ) {
+ result.push.apply( result, ret );
+ }
+ return false;
+ }
+ } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
+ return true;
+ }
+
+ return match;
+ },
+ POS: function(match){
+ match.unshift( true );
+ return match;
+ }
+ },
+ filters: {
+ enabled: function(elem){
+ return elem.disabled === false && elem.type !== "hidden";
+ },
+ disabled: function(elem){
+ return elem.disabled === true;
+ },
+ checked: function(elem){
+ return elem.checked === true;
+ },
+ selected: function(elem){
+ // Accessing this property makes selected-by-default
+ // options in Safari work properly
+ elem.parentNode.selectedIndex;
+ return elem.selected === true;
+ },
+ parent: function(elem){
+ return !!elem.firstChild;
+ },
+ empty: function(elem){
+ return !elem.firstChild;
+ },
+ has: function(elem, i, match){
+ return !!Sizzle( match[3], elem ).length;
+ },
+ header: function(elem){
+ return /h\d/i.test( elem.nodeName );
+ },
+ text: function(elem){
+ return "text" === elem.type;
+ },
+ radio: function(elem){
+ return "radio" === elem.type;
+ },
+ checkbox: function(elem){
+ return "checkbox" === elem.type;
+ },
+ file: function(elem){
+ return "file" === elem.type;
+ },
+ password: function(elem){
+ return "password" === elem.type;
+ },
+ submit: function(elem){
+ return "submit" === elem.type;
+ },
+ image: function(elem){
+ return "image" === elem.type;
+ },
+ reset: function(elem){
+ return "reset" === elem.type;
+ },
+ button: function(elem){
+ return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
+ },
+ input: function(elem){
+ return /input|select|textarea|button/i.test(elem.nodeName);
+ }
+ },
+ setFilters: {
+ first: function(elem, i){
+ return i === 0;
+ },
+ last: function(elem, i, match, array){
+ return i === array.length - 1;
+ },
+ even: function(elem, i){
+ return i % 2 === 0;
+ },
+ odd: function(elem, i){
+ return i % 2 === 1;
+ },
+ lt: function(elem, i, match){
+ return i < match[3] - 0;
+ },
+ gt: function(elem, i, match){
+ return i > match[3] - 0;
+ },
+ nth: function(elem, i, match){
+ return match[3] - 0 === i;
+ },
+ eq: function(elem, i, match){
+ return match[3] - 0 === i;
+ }
+ },
+ filter: {
+ PSEUDO: function(elem, match, i, array){
+ var name = match[1], filter = Expr.filters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+ } else if ( name === "contains" ) {
+ return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
+ } else if ( name === "not" ) {
+ var not = match[3];
+
+ for ( var i = 0, l = not.length; i < l; i++ ) {
+ if ( not[i] === elem ) {
+ return false;
+ }
+ }
+
+ return true;
+ } else {
+ throw "Syntax error, unrecognized expression: " + name;
+ }
+ },
+ CHILD: function(elem, match){
+ var type = match[1], node = elem;
+ switch (type) {
+ case 'only':
+ case 'first':
+ while ( (node = node.previousSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+ if ( type === "first" ) {
+ return true;
+ }
+ node = elem;
+ case 'last':
+ while ( (node = node.nextSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+ return true;
+ case 'nth':
+ var first = match[2], last = match[3];
+
+ if ( first === 1 && last === 0 ) {
+ return true;
+ }
+
+ var doneName = match[0],
+ parent = elem.parentNode;
+
+ if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
+ var count = 0;
+ for ( node = parent.firstChild; node; node = node.nextSibling ) {
+ if ( node.nodeType === 1 ) {
+ node.nodeIndex = ++count;
+ }
+ }
+ parent.sizcache = doneName;
+ }
+
+ var diff = elem.nodeIndex - last;
+ if ( first === 0 ) {
+ return diff === 0;
+ } else {
+ return ( diff % first === 0 && diff / first >= 0 );
+ }
+ }
+ },
+ ID: function(elem, match){
+ return elem.nodeType === 1 && elem.getAttribute("id") === match;
+ },
+ TAG: function(elem, match){
+ return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
+ },
+ CLASS: function(elem, match){
+ return (" " + (elem.className || elem.getAttribute("class")) + " ")
+ .indexOf( match ) > -1;
+ },
+ ATTR: function(elem, match){
+ var name = match[1],
+ result = Expr.attrHandle[ name ] ?
+ Expr.attrHandle[ name ]( elem ) :
+ elem[ name ] != null ?
+ elem[ name ] :
+ elem.getAttribute( name ),
+ value = result + "",
+ type = match[2],
+ check = match[4];
+
+ return result == null ?
+ type === "!=" :
+ type === "=" ?
+ value === check :
+ type === "*=" ?
+ value.indexOf(check) >= 0 :
+ type === "~=" ?
+ (" " + value + " ").indexOf(check) >= 0 :
+ !check ?
+ value && result !== false :
+ type === "!=" ?
+ value !== check :
+ type === "^=" ?
+ value.indexOf(check) === 0 :
+ type === "$=" ?
+ value.substr(value.length - check.length) === check :
+ type === "|=" ?
+ value === check || value.substr(0, check.length + 1) === check + "-" :
+ false;
+ },
+ POS: function(elem, match, i, array){
+ var name = match[2], filter = Expr.setFilters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+ }
+ }
+ }
+};
+
+var origPOS = Expr.match.POS;
+
+for ( var type in Expr.match ) {
+ Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source );
+ Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, function(all, num){
+ return "\\" + (num - 0 + 1);
+ }));
+}
+
+var makeArray = function(array, results) {
+ array = Array.prototype.slice.call( array, 0 );
+
+ if ( results ) {
+ results.push.apply( results, array );
+ return results;
+ }
+
+ return array;
+};
+
+// Perform a simple check to determine if the browser is capable of
+// converting a NodeList to an array using builtin methods.
+try {
+ Array.prototype.slice.call( document.documentElement.childNodes, 0 );
+
+// Provide a fallback method if it does not work
+} catch(e){
+ makeArray = function(array, results) {
+ var ret = results || [];
+
+ if ( toString.call(array) === "[object Array]" ) {
+ Array.prototype.push.apply( ret, array );
+ } else {
+ if ( typeof array.length === "number" ) {
+ for ( var i = 0, l = array.length; i < l; i++ ) {
+ ret.push( array[i] );
+ }
+ } else {
+ for ( var i = 0; array[i]; i++ ) {
+ ret.push( array[i] );
+ }
+ }
+ }
+
+ return ret;
+ };
+}
+
+var sortOrder;
+
+if ( document.documentElement.compareDocumentPosition ) {
+ sortOrder = function( a, b ) {
+ if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.compareDocumentPosition ? -1 : 1;
+ }
+
+ var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+} else if ( "sourceIndex" in document.documentElement ) {
+ sortOrder = function( a, b ) {
+ if ( !a.sourceIndex || !b.sourceIndex ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.sourceIndex ? -1 : 1;
+ }
+
+ var ret = a.sourceIndex - b.sourceIndex;
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+} else if ( document.createRange ) {
+ sortOrder = function( a, b ) {
+ if ( !a.ownerDocument || !b.ownerDocument ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.ownerDocument ? -1 : 1;
+ }
+
+ var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();
+ aRange.setStart(a, 0);
+ aRange.setEnd(a, 0);
+ bRange.setStart(b, 0);
+ bRange.setEnd(b, 0);
+ var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange);
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+}
+
+// Utility function for retreiving the text value of an array of DOM nodes
+function getText( elems ) {
+ var ret = "", elem;
+
+ for ( var i = 0; elems[i]; i++ ) {
+ elem = elems[i];
+
+ // Get the text from text nodes and CDATA nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
+ ret += elem.nodeValue;
+
+ // Traverse everything else, except comment nodes
+ } else if ( elem.nodeType !== 8 ) {
+ ret += getText( elem.childNodes );
+ }
+ }
+
+ return ret;
+}
+
+// Check to see if the browser returns elements by name when
+// querying by getElementById (and provide a workaround)
+(function(){
+ // We're going to inject a fake input element with a specified name
+ var form = document.createElement("div"),
+ id = "script" + (new Date).getTime();
+ form.innerHTML = "<a name='" + id + "'/>";
+
+ // Inject it into the root element, check its status, and remove it quickly
+ var root = document.documentElement;
+ root.insertBefore( form, root.firstChild );
+
+ // The workaround has to do additional checks after a getElementById
+ // Which slows things down for other browsers (hence the branching)
+ if ( document.getElementById( id ) ) {
+ Expr.find.ID = function(match, context, isXML){
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+ return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
+ }
+ };
+
+ Expr.filter.ID = function(elem, match){
+ var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
+ return elem.nodeType === 1 && node && node.nodeValue === match;
+ };
+ }
+
+ root.removeChild( form );
+ root = form = null; // release memory in IE
+})();
+
+(function(){
+ // Check to see if the browser returns only elements
+ // when doing getElementsByTagName("*")
+
+ // Create a fake element
+ var div = document.createElement("div");
+ div.appendChild( document.createComment("") );
+
+ // Make sure no comments are found
+ if ( div.getElementsByTagName("*").length > 0 ) {
+ Expr.find.TAG = function(match, context){
+ var results = context.getElementsByTagName(match[1]);
+
+ // Filter out possible comments
+ if ( match[1] === "*" ) {
+ var tmp = [];
+
+ for ( var i = 0; results[i]; i++ ) {
+ if ( results[i].nodeType === 1 ) {
+ tmp.push( results[i] );
+ }
+ }
+
+ results = tmp;
+ }
+
+ return results;
+ };
+ }
+
+ // Check to see if an attribute returns normalized href attributes
+ div.innerHTML = "<a href='#'></a>";
+ if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
+ div.firstChild.getAttribute("href") !== "#" ) {
+ Expr.attrHandle.href = function(elem){
+ return elem.getAttribute("href", 2);
+ };
+ }
+
+ div = null; // release memory in IE
+})();
+
+if ( document.querySelectorAll ) {
+ (function(){
+ var oldSizzle = Sizzle, div = document.createElement("div");
+ div.innerHTML = "<p class='TEST'></p>";
+
+ // Safari can't handle uppercase or unicode characters when
+ // in quirks mode.
+ if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
+ return;
+ }
+
+ Sizzle = function(query, context, extra, seed){
+ context = context || document;
+
+ // Only use querySelectorAll on non-XML documents
+ // (ID selectors don't work in non-HTML documents)
+ if ( !seed && context.nodeType === 9 && !isXML(context) ) {
+ try {
+ return makeArray( context.querySelectorAll(query), extra );
+ } catch(e){}
+ }
+
+ return oldSizzle(query, context, extra, seed);
+ };
+
+ for ( var prop in oldSizzle ) {
+ Sizzle[ prop ] = oldSizzle[ prop ];
+ }
+
+ div = null; // release memory in IE
+ })();
+}
+
+(function(){
+ var div = document.createElement("div");
+
+ div.innerHTML = "<div class='test e'></div><div class='test'></div>";
+
+ // Opera can't find a second classname (in 9.6)
+ // Also, make sure that getElementsByClassName actually exists
+ if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
+ return;
+ }
+
+ // Safari caches class attributes, doesn't catch changes (in 3.2)
+ div.lastChild.className = "e";
+
+ if ( div.getElementsByClassName("e").length === 1 ) {
+ return;
+ }
+
+ Expr.order.splice(1, 0, "CLASS");
+ Expr.find.CLASS = function(match, context, isXML) {
+ if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
+ return context.getElementsByClassName(match[1]);
+ }
+ };
+
+ div = null; // release memory in IE
+})();
+
+function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ elem = elem[dir];
+ var match = false;
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 && !isXML ){
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+
+ if ( elem.nodeName.toLowerCase() === cur ) {
+ match = elem;
+ break;
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ elem = elem[dir];
+ var match = false;
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 ) {
+ if ( !isXML ) {
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+ if ( typeof cur !== "string" ) {
+ if ( elem === cur ) {
+ match = true;
+ break;
+ }
+
+ } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
+ match = elem;
+ break;
+ }
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+var contains = document.compareDocumentPosition ? function(a, b){
+ return a.compareDocumentPosition(b) & 16;
+} : function(a, b){
+ return a !== b && (a.contains ? a.contains(b) : true);
+};
+
+var isXML = function(elem){
+ // documentElement is verified for cases where it doesn't yet exist
+ // (such as loading iframes in IE - #4833)
+ var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
+ return documentElement ? documentElement.nodeName !== "HTML" : false;
+};
+
+var posProcess = function(selector, context){
+ var tmpSet = [], later = "", match,
+ root = context.nodeType ? [context] : context;
+
+ // Position selectors must be done after the filter
+ // And so must :not(positional) so we move all PSEUDOs to the end
+ while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
+ later += match[0];
+ selector = selector.replace( Expr.match.PSEUDO, "" );
+ }
+
+ selector = Expr.relative[selector] ? selector + "*" : selector;
+
+ for ( var i = 0, l = root.length; i < l; i++ ) {
+ Sizzle( selector, root[i], tmpSet );
+ }
+
+ return Sizzle.filter( later, tmpSet );
+};
+
+// EXPOSE
+jQuery.find = Sizzle;
+jQuery.expr = Sizzle.selectors;
+jQuery.expr[":"] = jQuery.expr.filters;
+jQuery.unique = Sizzle.uniqueSort;
+jQuery.getText = getText;
+jQuery.isXMLDoc = isXML;
+jQuery.contains = contains;
+
+return;
+
+window.Sizzle = Sizzle;
+
+})();
+var runtil = /Until$/,
+ rparentsprev = /^(?:parents|prevUntil|prevAll)/,
+ // Note: This RegExp should be improved, or likely pulled from Sizzle
+ rmultiselector = /,/,
+ slice = Array.prototype.slice;
+
+// Implement the identical functionality for filter and not
+var winnow = function( elements, qualifier, keep ) {
+ if ( jQuery.isFunction( qualifier ) ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ return !!qualifier.call( elem, i, elem ) === keep;
+ });
+
+ } else if ( qualifier.nodeType ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ return (elem === qualifier) === keep;
+ });
+
+ } else if ( typeof qualifier === "string" ) {
+ var filtered = jQuery.grep(elements, function( elem ) {
+ return elem.nodeType === 1;
+ });
+
+ if ( isSimple.test( qualifier ) ) {
+ return jQuery.filter(qualifier, filtered, !keep);
+ } else {
+ qualifier = jQuery.filter( qualifier, elements );
+ }
+ }
+
+ return jQuery.grep(elements, function( elem, i ) {
+ return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
+ });
+};
+
+jQuery.fn.extend({
+ find: function( selector ) {
+ var ret = this.pushStack( "", "find", selector ), length = 0;
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ length = ret.length;
+ jQuery.find( selector, this[i], ret );
+
+ if ( i > 0 ) {
+ // Make sure that the results are unique
+ for ( var n = length; n < ret.length; n++ ) {
+ for ( var r = 0; r < length; r++ ) {
+ if ( ret[r] === ret[n] ) {
+ ret.splice(n--, 1);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return ret;
+ },
+
+ has: function( target ) {
+ var targets = jQuery( target );
+ return this.filter(function() {
+ for ( var i = 0, l = targets.length; i < l; i++ ) {
+ if ( jQuery.contains( this, targets[i] ) ) {
+ return true;
+ }
+ }
+ });
+ },
+
+ not: function( selector ) {
+ return this.pushStack( winnow(this, selector, false), "not", selector);
+ },
+
+ filter: function( selector ) {
+ return this.pushStack( winnow(this, selector, true), "filter", selector );
+ },
+
+ is: function( selector ) {
+ return !!selector && jQuery.filter( selector, this ).length > 0;
+ },
+
+ closest: function( selectors, context ) {
+ if ( jQuery.isArray( selectors ) ) {
+ var ret = [], cur = this[0], match, matches = {}, selector;
+
+ if ( cur && selectors.length ) {
+ for ( var i = 0, l = selectors.length; i < l; i++ ) {
+ selector = selectors[i];
+
+ if ( !matches[selector] ) {
+ matches[selector] = jQuery.expr.match.POS.test( selector ) ?
+ jQuery( selector, context || this.context ) :
+ selector;
+ }
+ }
+
+ while ( cur && cur.ownerDocument && cur !== context ) {
+ for ( selector in matches ) {
+ match = matches[selector];
+
+ if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) {
+ ret.push({ selector: selector, elem: cur });
+ delete matches[selector];
+ }
+ }
+ cur = cur.parentNode;
+ }
+ }
+
+ return ret;
+ }
+
+ var pos = jQuery.expr.match.POS.test( selectors ) ?
+ jQuery( selectors, context || this.context ) : null;
+
+ return this.map(function( i, cur ) {
+ while ( cur && cur.ownerDocument && cur !== context ) {
+ if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selectors) ) {
+ return cur;
+ }
+ cur = cur.parentNode;
+ }
+ return null;
+ });
+ },
+
+ // Determine the position of an element within
+ // the matched set of elements
+ index: function( elem ) {
+ if ( !elem || typeof elem === "string" ) {
+ return jQuery.inArray( this[0],
+ // If it receives a string, the selector is used
+ // If it receives nothing, the siblings are used
+ elem ? jQuery( elem ) : this.parent().children() );
+ }
+ // Locate the position of the desired element
+ return jQuery.inArray(
+ // If it receives a jQuery object, the first element is used
+ elem.jquery ? elem[0] : elem, this );
+ },
+
+ add: function( selector, context ) {
+ var set = typeof selector === "string" ?
+ jQuery( selector, context || this.context ) :
+ jQuery.makeArray( selector ),
+ all = jQuery.merge( this.get(), set );
+
+ return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
+ all :
+ jQuery.unique( all ) );
+ },
+
+ andSelf: function() {
+ return this.add( this.prevObject );
+ }
+});
+
+// A painfully simple check to see if an element is disconnected
+// from a document (should be improved, where feasible).
+function isDisconnected( node ) {
+ return !node || !node.parentNode || node.parentNode.nodeType === 11;
+}
+
+jQuery.each({
+ parent: function( elem ) {
+ var parent = elem.parentNode;
+ return parent && parent.nodeType !== 11 ? parent : null;
+ },
+ parents: function( elem ) {
+ return jQuery.dir( elem, "parentNode" );
+ },
+ parentsUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "parentNode", until );
+ },
+ next: function( elem ) {
+ return jQuery.nth( elem, 2, "nextSibling" );
+ },
+ prev: function( elem ) {
+ return jQuery.nth( elem, 2, "previousSibling" );
+ },
+ nextAll: function( elem ) {
+ return jQuery.dir( elem, "nextSibling" );
+ },
+ prevAll: function( elem ) {
+ return jQuery.dir( elem, "previousSibling" );
+ },
+ nextUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "nextSibling", until );
+ },
+ prevUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "previousSibling", until );
+ },
+ siblings: function( elem ) {
+ return jQuery.sibling( elem.parentNode.firstChild, elem );
+ },
+ children: function( elem ) {
+ return jQuery.sibling( elem.firstChild );
+ },
+ contents: function( elem ) {
+ return jQuery.nodeName( elem, "iframe" ) ?
+ elem.contentDocument || elem.contentWindow.document :
+ jQuery.makeArray( elem.childNodes );
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function( until, selector ) {
+ var ret = jQuery.map( this, fn, until );
+
+ if ( !runtil.test( name ) ) {
+ selector = until;
+ }
+
+ if ( selector && typeof selector === "string" ) {
+ ret = jQuery.filter( selector, ret );
+ }
+
+ ret = this.length > 1 ? jQuery.unique( ret ) : ret;
+
+ if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
+ ret = ret.reverse();
+ }
+
+ return this.pushStack( ret, name, slice.call(arguments).join(",") );
+ };
+});
+
+jQuery.extend({
+ filter: function( expr, elems, not ) {
+ if ( not ) {
+ expr = ":not(" + expr + ")";
+ }
+
+ return jQuery.find.matches(expr, elems);
+ },
+
+ dir: function( elem, dir, until ) {
+ var matched = [], cur = elem[dir];
+ while ( cur && cur.nodeType !== 9 && (until === undefined || !jQuery( cur ).is( until )) ) {
+ if ( cur.nodeType === 1 ) {
+ matched.push( cur );
+ }
+ cur = cur[dir];
+ }
+ return matched;
+ },
+
+ nth: function( cur, result, dir, elem ) {
+ result = result || 1;
+ var num = 0;
+
+ for ( ; cur; cur = cur[dir] ) {
+ if ( cur.nodeType === 1 && ++num === result ) {
+ break;
+ }
+ }
+
+ return cur;
+ },
+
+ sibling: function( n, elem ) {
+ var r = [];
+
+ for ( ; n; n = n.nextSibling ) {
+ if ( n.nodeType === 1 && n !== elem ) {
+ r.push( n );
+ }
+ }
+
+ return r;
+ }
+});
+var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
+ rleadingWhitespace = /^\s+/,
+ rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g,
+ rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,
+ rtagName = /<([\w:]+)/,
+ rtbody = /<tbody/i,
+ rhtml = /<|&\w+;/,
+ fcloseTag = function( all, front, tag ) {
+ return rselfClosing.test( tag ) ?
+ all :
+ front + "></" + tag + ">";
+ },
+ wrapMap = {
+ option: [ 1, "<select multiple='multiple'>", "</select>" ],
+ legend: [ 1, "<fieldset>", "</fieldset>" ],
+ thead: [ 1, "<table>", "</table>" ],
+ tr: [ 2, "<table><tbody>", "</tbody></table>" ],
+ td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
+ col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
+ area: [ 1, "<map>", "</map>" ],
+ _default: [ 0, "", "" ]
+ };
+
+wrapMap.optgroup = wrapMap.option;
+wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
+wrapMap.th = wrapMap.td;
+
+// IE can't serialize <link> and <script> tags normally
+if ( !jQuery.support.htmlSerialize ) {
+ wrapMap._default = [ 1, "div<div>", "</div>" ];
+}
+
+jQuery.fn.extend({
+ text: function( text ) {
+ if ( jQuery.isFunction(text) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ return self.text( text.call(this, i, self.text()) );
+ });
+ }
+
+ if ( typeof text !== "object" && text !== undefined ) {
+ return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
+ }
+
+ return jQuery.getText( this );
+ },
+
+ wrapAll: function( html ) {
+ if ( jQuery.isFunction( html ) ) {
+ return this.each(function(i) {
+ jQuery(this).wrapAll( html.call(this, i) );
+ });
+ }
+
+ if ( this[0] ) {
+ // The elements to wrap the target around
+ var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
+
+ if ( this[0].parentNode ) {
+ wrap.insertBefore( this[0] );
+ }
+
+ wrap.map(function() {
+ var elem = this;
+
+ while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
+ elem = elem.firstChild;
+ }
+
+ return elem;
+ }).append(this);
+ }
+
+ return this;
+ },
+
+ wrapInner: function( html ) {
+ return this.each(function() {
+ var self = jQuery( this ), contents = self.contents();
+
+ if ( contents.length ) {
+ contents.wrapAll( html );
+
+ } else {
+ self.append( html );
+ }
+ });
+ },
+
+ wrap: function( html ) {
+ return this.each(function() {
+ jQuery( this ).wrapAll( html );
+ });
+ },
+
+ unwrap: function() {
+ return this.parent().each(function() {
+ if ( !jQuery.nodeName( this, "body" ) ) {
+ jQuery( this ).replaceWith( this.childNodes );
+ }
+ }).end();
+ },
+
+ append: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 ) {
+ this.appendChild( elem );
+ }
+ });
+ },
+
+ prepend: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 ) {
+ this.insertBefore( elem, this.firstChild );
+ }
+ });
+ },
+
+ before: function() {
+ if ( this[0] && this[0].parentNode ) {
+ return this.domManip(arguments, false, function( elem ) {
+ this.parentNode.insertBefore( elem, this );
+ });
+ } else if ( arguments.length ) {
+ var set = jQuery(arguments[0]);
+ set.push.apply( set, this.toArray() );
+ return this.pushStack( set, "before", arguments );
+ }
+ },
+
+ after: function() {
+ if ( this[0] && this[0].parentNode ) {
+ return this.domManip(arguments, false, function( elem ) {
+ this.parentNode.insertBefore( elem, this.nextSibling );
+ });
+ } else if ( arguments.length ) {
+ var set = this.pushStack( this, "after", arguments );
+ set.push.apply( set, jQuery(arguments[0]).toArray() );
+ return set;
+ }
+ },
+
+ clone: function( events ) {
+ // Do the clone
+ var ret = this.map(function() {
+ if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) {
+ // IE copies events bound via attachEvent when
+ // using cloneNode. Calling detachEvent on the
+ // clone will also remove the events from the orignal
+ // In order to get around this, we use innerHTML.
+ // Unfortunately, this means some modifications to
+ // attributes in IE that are actually only stored
+ // as properties will not be copied (such as the
+ // the name attribute on an input).
+ var html = this.outerHTML, ownerDocument = this.ownerDocument;
+ if ( !html ) {
+ var div = ownerDocument.createElement("div");
+ div.appendChild( this.cloneNode(true) );
+ html = div.innerHTML;
+ }
+
+ return jQuery.clean([html.replace(rinlinejQuery, "")
+ .replace(rleadingWhitespace, "")], ownerDocument)[0];
+ } else {
+ return this.cloneNode(true);
+ }
+ });
+
+ // Copy the events from the original to the clone
+ if ( events === true ) {
+ cloneCopyEvent( this, ret );
+ cloneCopyEvent( this.find("*"), ret.find("*") );
+ }
+
+ // Return the cloned set
+ return ret;
+ },
+
+ html: function( value ) {
+ if ( value === undefined ) {
+ return this[0] && this[0].nodeType === 1 ?
+ this[0].innerHTML.replace(rinlinejQuery, "") :
+ null;
+
+ // See if we can take a shortcut and just use innerHTML
+ } else if ( typeof value === "string" && !/<script/i.test( value ) &&
+ (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
+ !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
+
+ try {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ // Remove element nodes and prevent memory leaks
+ if ( this[i].nodeType === 1 ) {
+ cleanData( this[i].getElementsByTagName("*") );
+ this[i].innerHTML = value;
+ }
+ }
+
+ // If using innerHTML throws an exception, use the fallback method
+ } catch(e) {
+ this.empty().append( value );
+ }
+
+ } else if ( jQuery.isFunction( value ) ) {
+ this.each(function(i){
+ var self = jQuery(this), old = self.html();
+ self.empty().append(function(){
+ return value.call( this, i, old );
+ });
+ });
+
+ } else {
+ this.empty().append( value );
+ }
+
+ return this;
+ },
+
+ replaceWith: function( value ) {
+ if ( this[0] && this[0].parentNode ) {
+ // Make sure that the elements are removed from the DOM before they are inserted
+ // this can help fix replacing a parent with child elements
+ if ( !jQuery.isFunction( value ) ) {
+ value = jQuery( value ).detach();
+ }
+
+ return this.each(function() {
+ var next = this.nextSibling, parent = this.parentNode;
+
+ jQuery(this).remove();
+
+ if ( next ) {
+ jQuery(next).before( value );
+ } else {
+ jQuery(parent).append( value );
+ }
+ });
+ } else {
+ return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value );
+ }
+ },
+
+ detach: function( selector ) {
+ return this.remove( selector, true );
+ },
+
+ domManip: function( args, table, callback ) {
+ var results, first, value = args[0], scripts = [];
+
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ args[0] = value.call(this, i, table ? self.html() : undefined);
+ return self.domManip( args, table, callback );
+ });
+ }
+
+ if ( this[0] ) {
+ // If we're in a fragment, just use that instead of building a new one
+ if ( args[0] && args[0].parentNode && args[0].parentNode.nodeType === 11 ) {
+ results = { fragment: args[0].parentNode };
+ } else {
+ results = buildFragment( args, this, scripts );
+ }
+
+ first = results.fragment.firstChild;
+
+ if ( first ) {
+ table = table && jQuery.nodeName( first, "tr" );
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ callback.call(
+ table ?
+ root(this[i], first) :
+ this[i],
+ results.cacheable || this.length > 1 || i > 0 ?
+ results.fragment.cloneNode(true) :
+ results.fragment
+ );
+ }
+ }
+
+ if ( scripts ) {
+ jQuery.each( scripts, evalScript );
+ }
+ }
+
+ return this;
+
+ function root( elem, cur ) {
+ return jQuery.nodeName(elem, "table") ?
+ (elem.getElementsByTagName("tbody")[0] ||
+ elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
+ elem;
+ }
+ }
+});
+
+function cloneCopyEvent(orig, ret) {
+ var i = 0;
+
+ ret.each(function() {
+ if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) {
+ return;
+ }
+
+ var oldData = jQuery.data( orig[i++] ), curData = jQuery.data( this, oldData ), events = oldData && oldData.events;
+
+ if ( events ) {
+ delete curData.handle;
+ curData.events = {};
+
+ for ( var type in events ) {
+ for ( var handler in events[ type ] ) {
+ jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data );
+ }
+ }
+ }
+ });
+}
+
+function buildFragment( args, nodes, scripts ) {
+ var fragment, cacheable, cached, cacheresults, doc;
+
+ if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) {
+ cacheable = true;
+ cacheresults = jQuery.fragments[ args[0] ];
+ if ( cacheresults ) {
+ if ( cacheresults !== 1 ) {
+ fragment = cacheresults;
+ }
+ cached = true;
+ }
+ }
+
+ if ( !fragment ) {
+ doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
+ fragment = doc.createDocumentFragment();
+ jQuery.clean( args, doc, fragment, scripts );
+ }
+
+ if ( cacheable ) {
+ jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
+ }
+
+ return { fragment: fragment, cacheable: cacheable };
+}
+
+jQuery.fragments = {};
+
+jQuery.each({
+ appendTo: "append",
+ prependTo: "prepend",
+ insertBefore: "before",
+ insertAfter: "after",
+ replaceAll: "replaceWith"
+}, function( name, original ) {
+ jQuery.fn[ name ] = function( selector ) {
+ var ret = [], insert = jQuery( selector );
+
+ for ( var i = 0, l = insert.length; i < l; i++ ) {
+ var elems = (i > 0 ? this.clone(true) : this).get();
+ jQuery.fn[ original ].apply( jQuery(insert[i]), elems );
+ ret = ret.concat( elems );
+ }
+ return this.pushStack( ret, name, insert.selector );
+ };
+});
+
+jQuery.each({
+ // keepData is for internal use only--do not document
+ remove: function( selector, keepData ) {
+ if ( !selector || jQuery.filter( selector, [ this ] ).length ) {
+ if ( !keepData && this.nodeType === 1 ) {
+ cleanData( this.getElementsByTagName("*") );
+ cleanData( [ this ] );
+ }
+
+ if ( this.parentNode ) {
+ this.parentNode.removeChild( this );
+ }
+ }
+ },
+
+ empty: function() {
+ // Remove element nodes and prevent memory leaks
+ if ( this.nodeType === 1 ) {
+ cleanData( this.getElementsByTagName("*") );
+ }
+
+ // Remove any remaining nodes
+ while ( this.firstChild ) {
+ this.removeChild( this.firstChild );
+ }
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function() {
+ return this.each( fn, arguments );
+ };
+});
+
+jQuery.extend({
+ clean: function( elems, context, fragment, scripts ) {
+ context = context || document;
+
+ // !context.createElement fails in IE with an error but returns typeof 'object'
+ if ( typeof context.createElement === "undefined" ) {
+ context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
+ }
+
+ var ret = [];
+
+ jQuery.each(elems, function( i, elem ) {
+ if ( typeof elem === "number" ) {
+ elem += "";
+ }
+
+ if ( !elem ) {
+ return;
+ }
+
+ // Convert html string into DOM nodes
+ if ( typeof elem === "string" && !rhtml.test( elem ) ) {
+ elem = context.createTextNode( elem );
+
+ } else if ( typeof elem === "string" ) {
+ // Fix "XHTML"-style tags in all browsers
+ elem = elem.replace(rxhtmlTag, fcloseTag);
+
+ // Trim whitespace, otherwise indexOf won't work as expected
+ var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
+ wrap = wrapMap[ tag ] || wrapMap._default,
+ depth = wrap[0],
+ div = context.createElement("div");
+
+ // Go to html and back, then peel off extra wrappers
+ div.innerHTML = wrap[1] + elem + wrap[2];
+
+ // Move to the right depth
+ while ( depth-- ) {
+ div = div.lastChild;
+ }
+
+ // Remove IE's autoinserted <tbody> from table fragments
+ if ( !jQuery.support.tbody ) {
+
+ // String was a <table>, *may* have spurious <tbody>
+ var hasBody = rtbody.test(elem),
+ tbody = tag === "table" && !hasBody ?
+ div.firstChild && div.firstChild.childNodes :
+
+ // String was a bare <thead> or <tfoot>
+ wrap[1] === "<table>" && !hasBody ?
+ div.childNodes :
+ [];
+
+ for ( var j = tbody.length - 1; j >= 0 ; --j ) {
+ if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
+ tbody[ j ].parentNode.removeChild( tbody[ j ] );
+ }
+ }
+
+ }
+
+ // IE completely kills leading whitespace when innerHTML is used
+ if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
+ div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
+ }
+
+ elem = jQuery.makeArray( div.childNodes );
+ }
+
+ if ( elem.nodeType ) {
+ ret.push( elem );
+ } else {
+ ret = jQuery.merge( ret, elem );
+ }
+
+ });
+
+ if ( fragment ) {
+ for ( var i = 0; ret[i]; i++ ) {
+ if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
+ scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
+ } else {
+ if ( ret[i].nodeType === 1 ) {
+ ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
+ }
+ fragment.appendChild( ret[i] );
+ }
+ }
+ }
+
+ return ret;
+ }
+});
+
+function cleanData( elems ) {
+ for ( var i = 0, elem, id; (elem = elems[i]) != null; i++ ) {
+ if ( !jQuery.noData[elem.nodeName.toLowerCase()] && (id = elem[expando]) ) {
+ delete jQuery.cache[ id ];
+ }
+ }
+}
+// exclude the following css properties to add px
+var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
+ ralpha = /alpha\([^)]*\)/,
+ ropacity = /opacity=([^)]*)/,
+ rfloat = /float/i,
+ rdashAlpha = /-([a-z])/ig,
+ rupper = /([A-Z])/g,
+ rnumpx = /^-?\d+(?:px)?$/i,
+ rnum = /^-?\d/,
+
+ cssShow = { position: "absolute", visibility: "hidden", display:"block" },
+ cssWidth = [ "Left", "Right" ],
+ cssHeight = [ "Top", "Bottom" ],
+
+ // cache check for defaultView.getComputedStyle
+ getComputedStyle = document.defaultView && document.defaultView.getComputedStyle,
+ // normalize float css property
+ styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat",
+ fcamelCase = function( all, letter ) {
+ return letter.toUpperCase();
+ };
+
+jQuery.fn.css = function( name, value ) {
+ return access( this, name, value, true, function( elem, name, value ) {
+ if ( value === undefined ) {
+ return jQuery.curCSS( elem, name );
+ }
+
+ if ( typeof value === "number" && !rexclude.test(name) ) {
+ value += "px";
+ }
+
+ jQuery.style( elem, name, value );
+ });
+};
+
+jQuery.extend({
+ style: function( elem, name, value ) {
+ // don't set styles on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ // ignore negative width and height values #1599
+ if ( (name === "width" || name === "height") && parseFloat(value) < 0 ) {
+ value = undefined;
+ }
+
+ var style = elem.style || elem, set = value !== undefined;
+
+ // IE uses filters for opacity
+ if ( !jQuery.support.opacity && name === "opacity" ) {
+ if ( set ) {
+ // IE has trouble with opacity if it does not have layout
+ // Force it by setting the zoom level
+ style.zoom = 1;
+
+ // Set the alpha filter to set the opacity
+ var opacity = parseInt( value, 10 ) + "" === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")";
+ var filter = style.filter || jQuery.curCSS( elem, "filter" ) || "";
+ style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : opacity;
+ }
+
+ return style.filter && style.filter.indexOf("opacity=") >= 0 ?
+ (parseFloat( ropacity.exec(style.filter)[1] ) / 100) + "":
+ "";
+ }
+
+ // Make sure we're using the right name for getting the float value
+ if ( rfloat.test( name ) ) {
+ name = styleFloat;
+ }
+
+ name = name.replace(rdashAlpha, fcamelCase);
+
+ if ( set ) {
+ style[ name ] = value;
+ }
+
+ return style[ name ];
+ },
+
+ css: function( elem, name, force, extra ) {
+ if ( name === "width" || name === "height" ) {
+ var val, props = cssShow, which = name === "width" ? cssWidth : cssHeight;
+
+ function getWH() {
+ val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
+
+ if ( extra === "border" ) {
+ return;
+ }
+
+ jQuery.each( which, function() {
+ if ( !extra ) {
+ val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
+ }
+
+ if ( extra === "margin" ) {
+ val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0;
+ } else {
+ val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
+ }
+ });
+ }
+
+ if ( elem.offsetWidth !== 0 ) {
+ getWH();
+ } else {
+ jQuery.swap( elem, props, getWH );
+ }
+
+ return Math.max(0, Math.round(val));
+ }
+
+ return jQuery.curCSS( elem, name, force );
+ },
+
+ curCSS: function( elem, name, force ) {
+ var ret, style = elem.style, filter;
+
+ // IE uses filters for opacity
+ if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) {
+ ret = ropacity.test(elem.currentStyle.filter || "") ?
+ (parseFloat(RegExp.$1) / 100) + "" :
+ "";
+
+ return ret === "" ?
+ "1" :
+ ret;
+ }
+
+ // Make sure we're using the right name for getting the float value
+ if ( rfloat.test( name ) ) {
+ name = styleFloat;
+ }
+
+ if ( !force && style && style[ name ] ) {
+ ret = style[ name ];
+
+ } else if ( getComputedStyle ) {
+
+ // Only "float" is needed here
+ if ( rfloat.test( name ) ) {
+ name = "float";
+ }
+
+ name = name.replace( rupper, "-$1" ).toLowerCase();
+
+ var defaultView = elem.ownerDocument.defaultView;
+
+ if ( !defaultView ) {
+ return null;
+ }
+
+ var computedStyle = defaultView.getComputedStyle( elem, null );
+
+ if ( computedStyle ) {
+ ret = computedStyle.getPropertyValue( name );
+ }
+
+ // We should always get a number back from opacity
+ if ( name === "opacity" && ret === "" ) {
+ ret = "1";
+ }
+
+ } else if ( elem.currentStyle ) {
+ var camelCase = name.replace(rdashAlpha, fcamelCase);
+
+ ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
+
+ // From the awesome hack by Dean Edwards
+ // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
+
+ // If we're not dealing with a regular pixel number
+ // but a number that has a weird ending, we need to convert it to pixels
+ if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
+ // Remember the original values
+ var left = style.left, rsLeft = elem.runtimeStyle.left;
+
+ // Put in the new values to get a computed value out
+ elem.runtimeStyle.left = elem.currentStyle.left;
+ style.left = camelCase === "fontSize" ? "1em" : (ret || 0);
+ ret = style.pixelLeft + "px";
+
+ // Revert the changed values
+ style.left = left;
+ elem.runtimeStyle.left = rsLeft;
+ }
+ }
+
+ return ret;
+ },
+
+ // A method for quickly swapping in/out CSS properties to get correct calculations
+ swap: function( elem, options, callback ) {
+ var old = {};
+
+ // Remember the old values, and insert the new ones
+ for ( var name in options ) {
+ old[ name ] = elem.style[ name ];
+ elem.style[ name ] = options[ name ];
+ }
+
+ callback.call( elem );
+
+ // Revert the old values
+ for ( var name in options ) {
+ elem.style[ name ] = old[ name ];
+ }
+ }
+});
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.hidden = function( elem ) {
+ var width = elem.offsetWidth, height = elem.offsetHeight,
+ skip = elem.nodeName.toLowerCase() === "tr";
+
+ return width === 0 && height === 0 && !skip ?
+ true :
+ width > 0 && height > 0 && !skip ?
+ false :
+ jQuery.curCSS(elem, "display") === "none";
+ };
+
+ jQuery.expr.filters.visible = function( elem ) {
+ return !jQuery.expr.filters.hidden( elem );
+ };
+}
+var jsc = now(),
+ rscript = /<script(.|\s)*?\/script>/gi,
+ rselectTextarea = /select|textarea/i,
+ rinput = /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,
+ jsre = /=\?(&|$)/,
+ rquery = /\?/,
+ rts = /(\?|&)_=.*?(&|$)/,
+ rurl = /^(\w+:)?\/\/([^\/?#]+)/,
+ r20 = /%20/g;
+
+jQuery.fn.extend({
+ // Keep a copy of the old load
+ _load: jQuery.fn.load,
+
+ load: function( url, params, callback ) {
+ if ( typeof url !== "string" ) {
+ return this._load( url );
+
+ // Don't do a request if no elements are being requested
+ } else if ( !this.length ) {
+ return this;
+ }
+
+ var off = url.indexOf(" ");
+ if ( off >= 0 ) {
+ var selector = url.slice(off, url.length);
+ url = url.slice(0, off);
+ }
+
+ // Default to a GET request
+ var type = "GET";
+
+ // If the second parameter was provided
+ if ( params ) {
+ // If it's a function
+ if ( jQuery.isFunction( params ) ) {
+ // We assume that it's the callback
+ callback = params;
+ params = null;
+
+ // Otherwise, build a param string
+ } else if ( typeof params === "object" ) {
+ params = jQuery.param( params, jQuery.ajaxSettings.traditional );
+ type = "POST";
+ }
+ }
+
+ // Request the remote document
+ jQuery.ajax({
+ url: url,
+ type: type,
+ dataType: "html",
+ data: params,
+ context:this,
+ complete: function( res, status ) {
+ // If successful, inject the HTML into all the matched elements
+ if ( status === "success" || status === "notmodified" ) {
+ // See if a selector was specified
+ this.html( selector ?
+ // Create a dummy div to hold the results
+ jQuery("<div />")
+ // inject the contents of the document in, removing the scripts
+ // to avoid any 'Permission Denied' errors in IE
+ .append(res.responseText.replace(rscript, ""))
+
+ // Locate the specified elements
+ .find(selector) :
+
+ // If not, just inject the full result
+ res.responseText );
+ }
+
+ if ( callback ) {
+ this.each( callback, [res.responseText, status, res] );
+ }
+ }
+ });
+
+ return this;
+ },
+
+ serialize: function() {
+ return jQuery.param(this.serializeArray());
+ },
+ serializeArray: function() {
+ return this.map(function() {
+ return this.elements ? jQuery.makeArray(this.elements) : this;
+ })
+ .filter(function() {
+ return this.name && !this.disabled &&
+ (this.checked || rselectTextarea.test(this.nodeName) ||
+ rinput.test(this.type));
+ })
+ .map(function( i, elem ) {
+ var val = jQuery(this).val();
+
+ return val == null ?
+ null :
+ jQuery.isArray(val) ?
+ jQuery.map( val, function( val, i ) {
+ return { name: elem.name, value: val };
+ }) :
+ { name: elem.name, value: val };
+ }).get();
+ }
+});
+
+// Attach a bunch of functions for handling common AJAX events
+jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function( i, o ) {
+ jQuery.fn[o] = function( f ) {
+ return this.bind(o, f);
+ };
+});
+
+jQuery.extend({
+
+ get: function( url, data, callback, type ) {
+ // shift arguments if data argument was omited
+ if ( jQuery.isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = null;
+ }
+
+ return jQuery.ajax({
+ type: "GET",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ getScript: function( url, callback ) {
+ return jQuery.get(url, null, callback, "script");
+ },
+
+ getJSON: function( url, data, callback ) {
+ return jQuery.get(url, data, callback, "json");
+ },
+
+ post: function( url, data, callback, type ) {
+ // shift arguments if data argument was omited
+ if ( jQuery.isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = {};
+ }
+
+ return jQuery.ajax({
+ type: "POST",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ ajaxSetup: function( settings ) {
+ jQuery.extend( jQuery.ajaxSettings, settings );
+ },
+
+ ajaxSettings: {
+ url: location.href,
+ global: true,
+ type: "GET",
+ contentType: "application/x-www-form-urlencoded",
+ processData: true,
+ async: true,
+ /*
+ timeout: 0,
+ data: null,
+ username: null,
+ password: null,
+ traditional: false,
+ */
+ // Create the request object; Microsoft failed to properly
+ // implement the XMLHttpRequest in IE7 (can't request local files),
+ // so we use the ActiveXObject when it is available
+ // This function can be overriden by calling jQuery.ajaxSetup
+ xhr: window.XMLHttpRequest && (window.location.protocol !== "file:" || !window.ActiveXObject) ?
+ function() {
+ return new window.XMLHttpRequest();
+ } :
+ function() {
+ try {
+ return new window.ActiveXObject("Microsoft.XMLHTTP");
+ } catch(e) {}
+ },
+ accepts: {
+ xml: "application/xml, text/xml",
+ html: "text/html",
+ script: "text/javascript, application/javascript",
+ json: "application/json, text/javascript",
+ text: "text/plain",
+ _default: "*/*"
+ }
+ },
+
+ // Last-Modified header cache for next request
+ lastModified: {},
+ etag: {},
+
+ ajax: function( origSettings ) {
+ var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings);
+
+ var jsonp, status, data,
+ callbackContext = s.context || s,
+ type = s.type.toUpperCase();
+
+ // convert data if not already a string
+ if ( s.data && s.processData && typeof s.data !== "string" ) {
+ s.data = jQuery.param( s.data, s.traditional );
+ }
+
+ // Handle JSONP Parameter Callbacks
+ if ( s.dataType === "jsonp" ) {
+ if ( type === "GET" ) {
+ if ( !jsre.test( s.url ) ) {
+ s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?";
+ }
+ } else if ( !s.data || !jsre.test(s.data) ) {
+ s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
+ }
+ s.dataType = "json";
+ }
+
+ // Build temporary JSONP function
+ if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) {
+ jsonp = s.jsonpCallback || ("jsonp" + jsc++);
+
+ // Replace the =? sequence both in the query string and the data
+ if ( s.data ) {
+ s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
+ }
+
+ s.url = s.url.replace(jsre, "=" + jsonp + "$1");
+
+ // We need to make sure
+ // that a JSONP style response is executed properly
+ s.dataType = "script";
+
+ // Handle JSONP-style loading
+ window[ jsonp ] = window[ jsonp ] || function( tmp ) {
+ data = tmp;
+ success();
+ complete();
+ // Garbage collect
+ window[ jsonp ] = undefined;
+
+ try {
+ delete window[ jsonp ];
+ } catch(e) {}
+
+ if ( head ) {
+ head.removeChild( script );
+ }
+ };
+ }
+
+ if ( s.dataType === "script" && s.cache === null ) {
+ s.cache = false;
+ }
+
+ if ( s.cache === false && type === "GET" ) {
+ var ts = now();
+
+ // try replacing _= if it is there
+ var ret = s.url.replace(rts, "$1_=" + ts + "$2");
+
+ // if nothing was replaced, add timestamp to the end
+ s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : "");
+ }
+
+ // If data is available, append data to url for get requests
+ if ( s.data && type === "GET" ) {
+ s.url += (rquery.test(s.url) ? "&" : "?") + s.data;
+ }
+
+ // Watch for a new set of requests
+ if ( s.global && ! jQuery.active++ ) {
+ jQuery.event.trigger( "ajaxStart" );
+ }
+
+ // Matches an absolute URL, and saves the domain
+ var parts = rurl.exec( s.url ),
+ remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host);
+
+ // If we're requesting a remote document
+ // and trying to load JSON or Script with a GET
+ if ( s.dataType === "script" && type === "GET" && remote ) {
+ var head = document.getElementsByTagName("head")[0] || document.documentElement;
+ var script = document.createElement("script");
+ script.src = s.url;
+ if ( s.scriptCharset ) {
+ script.charset = s.scriptCharset;
+ }
+
+ // Handle Script loading
+ if ( !jsonp ) {
+ var done = false;
+
+ // Attach handlers for all browsers
+ script.onload = script.onreadystatechange = function() {
+ if ( !done && (!this.readyState ||
+ this.readyState === "loaded" || this.readyState === "complete") ) {
+ done = true;
+ success();
+ complete();
+
+ // Handle memory leak in IE
+ script.onload = script.onreadystatechange = null;
+ if ( head && script.parentNode ) {
+ head.removeChild( script );
+ }
+ }
+ };
+ }
+
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709 and #4378).
+ head.insertBefore( script, head.firstChild );
+
+ // We handle everything using the script element injection
+ return undefined;
+ }
+
+ var requestDone = false;
+
+ // Create the request object
+ var xhr = s.xhr();
+
+ if ( !xhr ) {
+ return;
+ }
+
+ // Open the socket
+ // Passing null username, generates a login popup on Opera (#2865)
+ if ( s.username ) {
+ xhr.open(type, s.url, s.async, s.username, s.password);
+ } else {
+ xhr.open(type, s.url, s.async);
+ }
+
+ // Need an extra try/catch for cross domain requests in Firefox 3
+ try {
+ // Set the correct header, if data is being sent
+ if ( s.data || origSettings && origSettings.contentType ) {
+ xhr.setRequestHeader("Content-Type", s.contentType);
+ }
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if ( s.ifModified ) {
+ if ( jQuery.lastModified[s.url] ) {
+ xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]);
+ }
+
+ if ( jQuery.etag[s.url] ) {
+ xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]);
+ }
+ }
+
+ // Set header so the called script knows that it's an XMLHttpRequest
+ // Only send the header if it's not a remote XHR
+ if ( !remote ) {
+ xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+ }
+
+ // Set the Accepts header for the server, depending on the dataType
+ xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ?
+ s.accepts[ s.dataType ] + ", */*" :
+ s.accepts._default );
+ } catch(e) {}
+
+ // Allow custom headers/mimetypes and early abort
+ if ( s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false ) {
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active ) {
+ jQuery.event.trigger( "ajaxStop" );
+ }
+
+ // close opended socket
+ xhr.abort();
+ return false;
+ }
+
+ if ( s.global ) {
+ trigger("ajaxSend", [xhr, s]);
+ }
+
+ // Wait for a response to come back
+ var onreadystatechange = xhr.onreadystatechange = function( isTimeout ) {
+ // The request was aborted
+ if ( !xhr || xhr.readyState === 0 ) {
+ // Opera doesn't call onreadystatechange before this point
+ // so we simulate the call
+ if ( !requestDone ) {
+ complete();
+ }
+
+ requestDone = true;
+ if ( xhr ) {
+ xhr.onreadystatechange = jQuery.noop;
+ }
+
+ // The transfer is complete and the data is available, or the request timed out
+ } else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) {
+ requestDone = true;
+ xhr.onreadystatechange = jQuery.noop;
+
+ status = isTimeout === "timeout" ?
+ "timeout" :
+ !jQuery.httpSuccess( xhr ) ?
+ "error" :
+ s.ifModified && jQuery.httpNotModified( xhr, s.url ) ?
+ "notmodified" :
+ "success";
+
+ if ( status === "success" ) {
+ // Watch for, and catch, XML document parse errors
+ try {
+ // process the data (runs the xml through httpData regardless of callback)
+ data = jQuery.httpData( xhr, s.dataType, s );
+ } catch(e) {
+ status = "parsererror";
+ }
+ }
+
+ // Make sure that the request was successful or notmodified
+ if ( status === "success" || status === "notmodified" ) {
+ // JSONP handles its own success callback
+ if ( !jsonp ) {
+ success();
+ }
+ } else {
+ jQuery.handleError(s, xhr, status);
+ }
+
+ // Fire the complete handlers
+ complete();
+
+ if ( isTimeout === "timeout" ) {
+ xhr.abort();
+ }
+
+ // Stop memory leaks
+ if ( s.async ) {
+ xhr = null;
+ }
+ }
+ };
+
+ // Override the abort handler, if we can (IE doesn't allow it, but that's OK)
+ // Opera doesn't fire onreadystatechange at all on abort
+ try {
+ var oldAbort = xhr.abort;
+ xhr.abort = function() {
+ if ( xhr ) {
+ oldAbort.call( xhr );
+ if ( xhr ) {
+ xhr.readyState = 0;
+ }
+ }
+
+ onreadystatechange();
+ };
+ } catch(e) { }
+
+ // Timeout checker
+ if ( s.async && s.timeout > 0 ) {
+ setTimeout(function() {
+ // Check to see if the request is still happening
+ if ( xhr && !requestDone ) {
+ onreadystatechange( "timeout" );
+ }
+ }, s.timeout);
+ }
+
+ // Send the data
+ try {
+ xhr.send( type === "POST" || type === "PUT" || type === "DELETE" ? s.data : null );
+ } catch(e) {
+ jQuery.handleError(s, xhr, null, e);
+ // Fire the complete handlers
+ complete();
+ }
+
+ // firefox 1.5 doesn't fire statechange for sync requests
+ if ( !s.async ) {
+ onreadystatechange();
+ }
+
+ function success() {
+ // If a local callback was specified, fire it and pass it the data
+ if ( s.success ) {
+ s.success.call( callbackContext, data, status, xhr );
+ }
+
+ // Fire the global callback
+ if ( s.global ) {
+ trigger( "ajaxSuccess", [xhr, s] );
+ }
+ }
+
+ function complete() {
+ // Process result
+ if ( s.complete ) {
+ s.complete.call( callbackContext, xhr, status);
+ }
+
+ // The request was completed
+ if ( s.global ) {
+ trigger( "ajaxComplete", [xhr, s] );
+ }
+
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active ) {
+ jQuery.event.trigger( "ajaxStop" );
+ }
+ }
+
+ function trigger(type, args) {
+ (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args);
+ }
+
+ // return XMLHttpRequest to allow aborting the request etc.
+ return xhr;
+ },
+
+ handleError: function( s, xhr, status, e ) {
+ // If a local callback was specified, fire it
+ if ( s.error ) {
+ s.error.call( s.context || window, xhr, status, e );
+ }
+
+ // Fire the global callback
+ if ( s.global ) {
+ (s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] );
+ }
+ },
+
+ // Counter for holding the number of active queries
+ active: 0,
+
+ // Determines if an XMLHttpRequest was successful or not
+ httpSuccess: function( xhr ) {
+ try {
+ // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
+ return !xhr.status && location.protocol === "file:" ||
+ // Opera returns 0 when status is 304
+ ( xhr.status >= 200 && xhr.status < 300 ) ||
+ xhr.status === 304 || xhr.status === 1223 || xhr.status === 0;
+ } catch(e) {}
+
+ return false;
+ },
+
+ // Determines if an XMLHttpRequest returns NotModified
+ httpNotModified: function( xhr, url ) {
+ var lastModified = xhr.getResponseHeader("Last-Modified"),
+ etag = xhr.getResponseHeader("Etag");
+
+ if ( lastModified ) {
+ jQuery.lastModified[url] = lastModified;
+ }
+
+ if ( etag ) {
+ jQuery.etag[url] = etag;
+ }
+
+ // Opera returns 0 when status is 304
+ return xhr.status === 304 || xhr.status === 0;
+ },
+
+ httpData: function( xhr, type, s ) {
+ var ct = xhr.getResponseHeader("content-type") || "",
+ xml = type === "xml" || !type && ct.indexOf("xml") >= 0,
+ data = xml ? xhr.responseXML : xhr.responseText;
+
+ if ( xml && data.documentElement.nodeName === "parsererror" ) {
+ throw "parsererror";
+ }
+
+ // Allow a pre-filtering function to sanitize the response
+ // s is checked to keep backwards compatibility
+ if ( s && s.dataFilter ) {
+ data = s.dataFilter( data, type );
+ }
+
+ // The filter can actually parse the response
+ if ( typeof data === "string" ) {
+ // Get the JavaScript object, if JSON is used.
+ if ( type === "json" || !type && ct.indexOf("json") >= 0 ) {
+ // Make sure the incoming data is actual JSON
+ // Logic borrowed from http://json.org/json2.js
+ if (/^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]")
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ""))) {
+
+ // Try to use the native JSON parser first
+ if ( window.JSON && window.JSON.parse ) {
+ data = window.JSON.parse( data );
+
+ } else {
+ data = (new Function("return " + data))();
+ }
+
+ } else {
+ throw "Invalid JSON: " + data;
+ }
+
+ // If the type is "script", eval it in global context
+ } else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) {
+ jQuery.globalEval( data );
+ }
+ }
+
+ return data;
+ },
+
+ // Serialize an array of form elements or a set of
+ // key/values into a query string
+ param: function( a, traditional ) {
+
+ var s = [];
+
+ // Set traditional to true for jQuery <= 1.3.2 behavior.
+ if ( traditional === undefined ) {
+ traditional = jQuery.ajaxSettings.traditional;
+ }
+
+ function add( key, value ) {
+ // If value is a function, invoke it and return its value
+ value = jQuery.isFunction(value) ? value() : value;
+ s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
+ }
+
+ // If an array was passed in, assume that it is an array of form elements.
+ if ( jQuery.isArray(a) || a.jquery ) {
+ // Serialize the form elements
+ jQuery.each( a, function() {
+ add( this.name, this.value );
+ });
+
+ } else {
+ // If traditional, encode the "old" way (the way 1.3.2 or older
+ // did it), otherwise encode params recursively.
+ jQuery.each( a, function buildParams( prefix, obj ) {
+
+ if ( jQuery.isArray(obj) ) {
+ // Serialize array item.
+ jQuery.each( obj, function( i, v ) {
+ if ( traditional ) {
+ // Treat each array item as a scalar.
+ add( prefix, v );
+ } else {
+ // If array item is non-scalar (array or object), encode its
+ // numeric index to resolve deserialization ambiguity issues.
+ // Note that rack (as of 1.0.0) can't currently deserialize
+ // nested arrays properly, and attempting to do so may cause
+ // a server error. Possible fixes are to modify rack's
+ // deserialization algorithm or to provide an option or flag
+ // to force array serialization to be shallow.
+ buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v );
+ }
+ });
+
+ } else if ( !traditional && obj != null && typeof obj === "object" ) {
+ // Serialize object item.
+ jQuery.each( obj, function( k, v ) {
+ buildParams( prefix + "[" + k + "]", v );
+ });
+
+ } else {
+ // Serialize scalar item.
+ add( prefix, obj );
+ }
+ });
+ }
+
+ // Return the resulting serialization
+ return s.join("&").replace(r20, "+");
+ }
+
+});
+var elemdisplay = {},
+ rfxtypes = /toggle|show|hide/,
+ rfxnum = /^([+-]=)?([\d+-.]+)(.*)$/,
+ timerId,
+ fxAttrs = [
+ // height animations
+ [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
+ // width animations
+ [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
+ // opacity animations
+ [ "opacity" ]
+ ];
+
+jQuery.fn.extend({
+ show: function( speed, callback ) {
+ if ( speed != null ) {
+ return this.animate( genFx("show", 3), speed, callback);
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var old = jQuery.data(this[i], "olddisplay");
+
+ this[i].style.display = old || "";
+
+ if ( jQuery.css(this[i], "display") === "none" ) {
+ var nodeName = this[i].nodeName, display;
+
+ if ( elemdisplay[ nodeName ] ) {
+ display = elemdisplay[ nodeName ];
+
+ } else {
+ var elem = jQuery("<" + nodeName + " />").appendTo("body");
+
+ display = elem.css("display");
+
+ if ( display === "none" ) {
+ display = "block";
+ }
+
+ elem.remove();
+
+ elemdisplay[ nodeName ] = display;
+ }
+
+ jQuery.data(this[i], "olddisplay", display);
+ }
+ }
+
+ // Set the display of the elements in a second loop
+ // to avoid the constant reflow
+ for ( var j = 0, k = this.length; j < k; j++ ) {
+ this[j].style.display = jQuery.data(this[j], "olddisplay") || "";
+ }
+
+ return this;
+ }
+ },
+
+ hide: function( speed, callback ) {
+ if ( speed != null ) {
+ return this.animate( genFx("hide", 3), speed, callback);
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var old = jQuery.data(this[i], "olddisplay");
+ if ( !old && old !== "none" ) {
+ jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display"));
+ }
+ }
+
+ // Set the display of the elements in a second loop
+ // to avoid the constant reflow
+ for ( var j = 0, k = this.length; j < k; j++ ) {
+ this[j].style.display = "none";
+ }
+
+ return this;
+ }
+ },
+
+ // Save the old toggle function
+ _toggle: jQuery.fn.toggle,
+
+ toggle: function( fn, fn2 ) {
+ var bool = typeof fn === "boolean";
+
+ if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
+ this._toggle.apply( this, arguments );
+
+ } else if ( fn == null || bool ) {
+ this.each(function() {
+ var state = bool ? fn : jQuery(this).is(":hidden");
+ jQuery(this)[ state ? "show" : "hide" ]();
+ });
+
+ } else {
+ this.animate(genFx("toggle", 3), fn, fn2);
+ }
+
+ return this;
+ },
+
+ fadeTo: function( speed, to, callback ) {
+ return this.filter(":hidden").css("opacity", 0).show().end()
+ .animate({opacity: to}, speed, callback);
+ },
+
+ animate: function( prop, speed, easing, callback ) {
+ var optall = jQuery.speed(speed, easing, callback);
+
+ if ( jQuery.isEmptyObject( prop ) ) {
+ return this.each( optall.complete );
+ }
+
+ return this[ optall.queue === false ? "each" : "queue" ](function() {
+ var opt = jQuery.extend({}, optall), p,
+ hidden = this.nodeType === 1 && jQuery(this).is(":hidden"),
+ self = this;
+
+ for ( p in prop ) {
+ var name = p.replace(rdashAlpha, fcamelCase);
+
+ if ( p !== name ) {
+ prop[ name ] = prop[ p ];
+ delete prop[ p ];
+ p = name;
+ }
+
+ if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
+ return opt.complete.call(this);
+ }
+
+ if ( ( p === "height" || p === "width" ) && this.style ) {
+ // Store display property
+ opt.display = jQuery.css(this, "display");
+
+ // Make sure that nothing sneaks out
+ opt.overflow = this.style.overflow;
+ }
+
+ if ( jQuery.isArray( prop[p] ) ) {
+ // Create (if needed) and add to specialEasing
+ (opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1];
+ prop[p] = prop[p][0];
+ }
+ }
+
+ if ( opt.overflow != null ) {
+ this.style.overflow = "hidden";
+ }
+
+ opt.curAnim = jQuery.extend({}, prop);
+
+ jQuery.each( prop, function( name, val ) {
+ var e = new jQuery.fx( self, opt, name );
+
+ if ( rfxtypes.test(val) ) {
+ e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop );
+
+ } else {
+ var parts = rfxnum.exec(val),
+ start = e.cur(true) || 0;
+
+ if ( parts ) {
+ var end = parseFloat( parts[2] ),
+ unit = parts[3] || "px";
+
+ // We need to compute starting value
+ if ( unit !== "px" ) {
+ self.style[ name ] = (end || 1) + unit;
+ start = ((end || 1) / e.cur(true)) * start;
+ self.style[ name ] = start + unit;
+ }
+
+ // If a +=/-= token was provided, we're doing a relative animation
+ if ( parts[1] ) {
+ end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
+ }
+
+ e.custom( start, end, unit );
+
+ } else {
+ e.custom( start, val, "" );
+ }
+ }
+ });
+
+ // For JS strict compliance
+ return true;
+ });
+ },
+
+ stop: function( clearQueue, gotoEnd ) {
+ var timers = jQuery.timers;
+
+ if ( clearQueue ) {
+ this.queue([]);
+ }
+
+ this.each(function() {
+ // go in reverse order so anything added to the queue during the loop is ignored
+ for ( var i = timers.length - 1; i >= 0; i-- ) {
+ if ( timers[i].elem === this ) {
+ if (gotoEnd) {
+ // force the next step to be the last
+ timers[i](true);
+ }
+
+ timers.splice(i, 1);
+ }
+ }
+ });
+
+ // start the next in the queue if the last step wasn't forced
+ if ( !gotoEnd ) {
+ this.dequeue();
+ }
+
+ return this;
+ }
+
+});
+
+// Generate shortcuts for custom animations
+jQuery.each({
+ slideDown: genFx("show", 1),
+ slideUp: genFx("hide", 1),
+ slideToggle: genFx("toggle", 1),
+ fadeIn: { opacity: "show" },
+ fadeOut: { opacity: "hide" }
+}, function( name, props ) {
+ jQuery.fn[ name ] = function( speed, callback ) {
+ return this.animate( props, speed, callback );
+ };
+});
+
+jQuery.extend({
+ speed: function( speed, easing, fn ) {
+ var opt = speed && typeof speed === "object" ? speed : {
+ complete: fn || !fn && easing ||
+ jQuery.isFunction( speed ) && speed,
+ duration: speed,
+ easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
+ };
+
+ opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
+ jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default;
+
+ // Queueing
+ opt.old = opt.complete;
+ opt.complete = function() {
+ if ( opt.queue !== false ) {
+ jQuery(this).dequeue();
+ }
+ if ( jQuery.isFunction( opt.old ) ) {
+ opt.old.call( this );
+ }
+ };
+
+ return opt;
+ },
+
+ easing: {
+ linear: function( p, n, firstNum, diff ) {
+ return firstNum + diff * p;
+ },
+ swing: function( p, n, firstNum, diff ) {
+ return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
+ }
+ },
+
+ timers: [],
+
+ fx: function( elem, options, prop ) {
+ this.options = options;
+ this.elem = elem;
+ this.prop = prop;
+
+ if ( !options.orig ) {
+ options.orig = {};
+ }
+ }
+
+});
+
+jQuery.fx.prototype = {
+ // Simple function for setting a style value
+ update: function() {
+ if ( this.options.step ) {
+ this.options.step.call( this.elem, this.now, this );
+ }
+
+ (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
+
+ // Set display property to block for height/width animations
+ if ( ( this.prop === "height" || this.prop === "width" ) && this.elem.style ) {
+ this.elem.style.display = "block";
+ }
+ },
+
+ // Get the current size
+ cur: function( force ) {
+ if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
+ return this.elem[ this.prop ];
+ }
+
+ var r = parseFloat(jQuery.css(this.elem, this.prop, force));
+ return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
+ },
+
+ // Start an animation from one number to another
+ custom: function( from, to, unit ) {
+ this.startTime = now();
+ this.start = from;
+ this.end = to;
+ this.unit = unit || this.unit || "px";
+ this.now = this.start;
+ this.pos = this.state = 0;
+
+ var self = this;
+ function t( gotoEnd ) {
+ return self.step(gotoEnd);
+ }
+
+ t.elem = this.elem;
+
+ if ( t() && jQuery.timers.push(t) && !timerId ) {
+ timerId = setInterval(jQuery.fx.tick, 13);
+ }
+ },
+
+ // Simple 'show' function
+ show: function() {
+ // Remember where we started, so that we can go back to it later
+ this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
+ this.options.show = true;
+
+ // Begin the animation
+ // Make sure that we start at a small width/height to avoid any
+ // flash of content
+ this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
+
+ // Start by showing the element
+ jQuery( this.elem ).show();
+ },
+
+ // Simple 'hide' function
+ hide: function() {
+ // Remember where we started, so that we can go back to it later
+ this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
+ this.options.hide = true;
+
+ // Begin the animation
+ this.custom(this.cur(), 0);
+ },
+
+ // Each step of an animation
+ step: function( gotoEnd ) {
+ var t = now(), done = true;
+
+ if ( gotoEnd || t >= this.options.duration + this.startTime ) {
+ this.now = this.end;
+ this.pos = this.state = 1;
+ this.update();
+
+ this.options.curAnim[ this.prop ] = true;
+
+ for ( var i in this.options.curAnim ) {
+ if ( this.options.curAnim[i] !== true ) {
+ done = false;
+ }
+ }
+
+ if ( done ) {
+ if ( this.options.display != null ) {
+ // Reset the overflow
+ this.elem.style.overflow = this.options.overflow;
+
+ // Reset the display
+ var old = jQuery.data(this.elem, "olddisplay");
+ this.elem.style.display = old ? old : this.options.display;
+
+ if ( jQuery.css(this.elem, "display") === "none" ) {
+ this.elem.style.display = "block";
+ }
+ }
+
+ // Hide the element if the "hide" operation was done
+ if ( this.options.hide ) {
+ jQuery(this.elem).hide();
+ }
+
+ // Reset the properties, if the item has been hidden or shown
+ if ( this.options.hide || this.options.show ) {
+ for ( var p in this.options.curAnim ) {
+ jQuery.style(this.elem, p, this.options.orig[p]);
+ }
+ }
+
+ // Execute the complete function
+ this.options.complete.call( this.elem );
+ }
+
+ return false;
+
+ } else {
+ var n = t - this.startTime;
+ this.state = n / this.options.duration;
+
+ // Perform the easing function, defaults to swing
+ var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop];
+ var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear");
+ this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration);
+ this.now = this.start + ((this.end - this.start) * this.pos);
+
+ // Perform the next step of the animation
+ this.update();
+ }
+
+ return true;
+ }
+};
+
+jQuery.extend( jQuery.fx, {
+ tick: function() {
+ var timers = jQuery.timers;
+
+ for ( var i = 0; i < timers.length; i++ ) {
+ if ( !timers[i]() ) {
+ timers.splice(i--, 1);
+ }
+ }
+
+ if ( !timers.length ) {
+ jQuery.fx.stop();
+ }
+ },
+
+ stop: function() {
+ clearInterval( timerId );
+ timerId = null;
+ },
+
+ speeds: {
+ slow: 600,
+ fast: 200,
+ // Default speed
+ _default: 400
+ },
+
+ step: {
+ opacity: function( fx ) {
+ jQuery.style(fx.elem, "opacity", fx.now);
+ },
+
+ _default: function( fx ) {
+ if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
+ fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
+ } else {
+ fx.elem[ fx.prop ] = fx.now;
+ }
+ }
+ }
+});
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.animated = function( elem ) {
+ return jQuery.grep(jQuery.timers, function( fn ) {
+ return elem === fn.elem;
+ }).length;
+ };
+}
+
+function genFx( type, num ) {
+ var obj = {};
+
+ jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
+ obj[ this ] = type;
+ });
+
+ return obj;
+}
+if ( "getBoundingClientRect" in document.documentElement ) {
+ jQuery.fn.offset = function( options ) {
+ var elem = this[0];
+
+ if ( !elem || !elem.ownerDocument ) {
+ return null;
+ }
+
+ if ( options ) {
+ return this.each(function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ });
+ }
+
+ if ( elem === elem.ownerDocument.body ) {
+ return jQuery.offset.bodyOffset( elem );
+ }
+
+ var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement,
+ clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
+ top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop,
+ left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft;
+
+ return { top: top, left: left };
+ };
+
+} else {
+ jQuery.fn.offset = function( options ) {
+ var elem = this[0];
+
+ if ( !elem || !elem.ownerDocument ) {
+ return null;
+ }
+
+ if ( options ) {
+ return this.each(function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ });
+ }
+
+ if ( elem === elem.ownerDocument.body ) {
+ return jQuery.offset.bodyOffset( elem );
+ }
+
+ jQuery.offset.initialize();
+
+ var offsetParent = elem.offsetParent, prevOffsetParent = elem,
+ doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement,
+ body = doc.body, defaultView = doc.defaultView,
+ prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
+ top = elem.offsetTop, left = elem.offsetLeft;
+
+ while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
+ if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
+ break;
+ }
+
+ computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
+ top -= elem.scrollTop;
+ left -= elem.scrollLeft;
+
+ if ( elem === offsetParent ) {
+ top += elem.offsetTop;
+ left += elem.offsetLeft;
+
+ if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.nodeName)) ) {
+ top += parseFloat( computedStyle.borderTopWidth ) || 0;
+ left += parseFloat( computedStyle.borderLeftWidth ) || 0;
+ }
+
+ prevOffsetParent = offsetParent, offsetParent = elem.offsetParent;
+ }
+
+ if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
+ top += parseFloat( computedStyle.borderTopWidth ) || 0;
+ left += parseFloat( computedStyle.borderLeftWidth ) || 0;
+ }
+
+ prevComputedStyle = computedStyle;
+ }
+
+ if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
+ top += body.offsetTop;
+ left += body.offsetLeft;
+ }
+
+ if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
+ top += Math.max( docElem.scrollTop, body.scrollTop );
+ left += Math.max( docElem.scrollLeft, body.scrollLeft );
+ }
+
+ return { top: top, left: left };
+ };
+}
+
+jQuery.offset = {
+ initialize: function() {
+ var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0,
+ html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
+
+ jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
+
+ container.innerHTML = html;
+ body.insertBefore( container, body.firstChild );
+ innerDiv = container.firstChild;
+ checkDiv = innerDiv.firstChild;
+ td = innerDiv.nextSibling.firstChild.firstChild;
+
+ this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
+ this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
+
+ checkDiv.style.position = "fixed", checkDiv.style.top = "20px";
+ // safari subtracts parent border width here which is 5px
+ this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
+ checkDiv.style.position = checkDiv.style.top = "";
+
+ innerDiv.style.overflow = "hidden", innerDiv.style.position = "relative";
+ this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
+
+ this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
+
+ body.removeChild( container );
+ body = container = innerDiv = checkDiv = table = td = null;
+ jQuery.offset.initialize = jQuery.noop;
+ },
+
+ bodyOffset: function( body ) {
+ var top = body.offsetTop, left = body.offsetLeft;
+
+ jQuery.offset.initialize();
+
+ if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
+ top += parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0;
+ left += parseFloat( jQuery.curCSS(body, "marginLeft", true) ) || 0;
+ }
+
+ return { top: top, left: left };
+ },
+
+ setOffset: function( elem, options, i ) {
+ // set position first, in-case top/left are set even on static elem
+ if ( /static/.test( jQuery.curCSS( elem, "position" ) ) ) {
+ elem.style.position = "relative";
+ }
+ var curElem = jQuery( elem ),
+ curOffset = curElem.offset(),
+ curTop = parseInt( jQuery.curCSS( elem, "top", true ), 10 ) || 0,
+ curLeft = parseInt( jQuery.curCSS( elem, "left", true ), 10 ) || 0;
+
+ if ( jQuery.isFunction( options ) ) {
+ options = options.call( elem, i, curOffset );
+ }
+
+ var props = {
+ top: (options.top - curOffset.top) + curTop,
+ left: (options.left - curOffset.left) + curLeft
+ };
+
+ if ( "using" in options ) {
+ options.using.call( elem, props );
+ } else {
+ curElem.css( props );
+ }
+ }
+};
+
+
+jQuery.fn.extend({
+ position: function() {
+ if ( !this[0] ) {
+ return null;
+ }
+
+ var elem = this[0],
+
+ // Get *real* offsetParent
+ offsetParent = this.offsetParent(),
+
+ // Get correct offsets
+ offset = this.offset(),
+ parentOffset = /^body|html$/i.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
+
+ // Subtract element margins
+ // note: when an element has margin: auto the offsetLeft and marginLeft
+ // are the same in Safari causing offset.left to incorrectly be 0
+ offset.top -= parseFloat( jQuery.curCSS(elem, "marginTop", true) ) || 0;
+ offset.left -= parseFloat( jQuery.curCSS(elem, "marginLeft", true) ) || 0;
+
+ // Add offsetParent borders
+ parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], "borderTopWidth", true) ) || 0;
+ parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], "borderLeftWidth", true) ) || 0;
+
+ // Subtract the two offsets
+ return {
+ top: offset.top - parentOffset.top,
+ left: offset.left - parentOffset.left
+ };
+ },
+
+ offsetParent: function() {
+ return this.map(function() {
+ var offsetParent = this.offsetParent || document.body;
+ while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
+ offsetParent = offsetParent.offsetParent;
+ }
+ return offsetParent;
+ });
+ }
+});
+
+
+// Create scrollLeft and scrollTop methods
+jQuery.each( ["Left", "Top"], function( i, name ) {
+ var method = "scroll" + name;
+
+ jQuery.fn[ method ] = function(val) {
+ var elem = this[0], win;
+
+ if ( !elem ) {
+ return null;
+ }
+
+ if ( val !== undefined ) {
+ // Set the scroll offset
+ return this.each(function() {
+ win = getWindow( this );
+
+ if ( win ) {
+ win.scrollTo(
+ !i ? val : jQuery(win).scrollLeft(),
+ i ? val : jQuery(win).scrollTop()
+ );
+
+ } else {
+ this[ method ] = val;
+ }
+ });
+ } else {
+ win = getWindow( elem );
+
+ // Return the scroll offset
+ return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
+ jQuery.support.boxModel && win.document.documentElement[ method ] ||
+ win.document.body[ method ] :
+ elem[ method ];
+ }
+ };
+});
+
+function getWindow( elem ) {
+ return ("scrollTo" in elem && elem.document) ?
+ elem :
+ elem.nodeType === 9 ?
+ elem.defaultView || elem.parentWindow :
+ false;
+}
+// Create innerHeight, innerWidth, outerHeight and outerWidth methods
+jQuery.each([ "Height", "Width" ], function( i, name ) {
+
+ var type = name.toLowerCase();
+
+ // innerHeight and innerWidth
+ jQuery.fn["inner" + name] = function() {
+ return this[0] ?
+ jQuery.css( this[0], type, false, "padding" ) :
+ null;
+ };
+
+ // outerHeight and outerWidth
+ jQuery.fn["outer" + name] = function( margin ) {
+ return this[0] ?
+ jQuery.css( this[0], type, false, margin ? "margin" : "border" ) :
+ null;
+ };
+
+ jQuery.fn[ type ] = function( size ) {
+ // Get window width or height
+ var elem = this[0];
+ if ( !elem ) {
+ return size == null ? null : this;
+ }
+
+ return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window?
+ // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
+ elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
+ elem.document.body[ "client" + name ] :
+
+ // Get document width or height
+ (elem.nodeType === 9) ? // is it a document
+ // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
+ Math.max(
+ elem.documentElement["client" + name],
+ elem.body["scroll" + name], elem.documentElement["scroll" + name],
+ elem.body["offset" + name], elem.documentElement["offset" + name]
+ ) :
+
+ // Get or set width or height on the element
+ size === undefined ?
+ // Get width or height on the element
+ jQuery.css( elem, type ) :
+
+ // Set the width or height on the element (default to pixels if value is unitless)
+ this.css( type, typeof size === "string" ? size : size + "px" );
+ };
+
+});
+// Expose jQuery to the global object
+window.jQuery = window.$ = jQuery;
+
+})(window);
diff --git a/examples/lessons/6_English_namesOfColor/js/karma.js b/examples/lessons/6_English_namesOfColor/js/karma.js
new file mode 100755
index 0000000..03f027b
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/js/karma.js
@@ -0,0 +1,1018 @@
+/* Documentation Note:
+ * Public methods and properties are commented with /** some text *\/
+ * and private methods and properties are commented with //
+ *
+ * Please leave it that way to keep this documentation sane
+ */
+
+
+/*
+* Karma Framework
+* http://karmaeducation.org
+*
+* Copyright (c) 2009
+* Bryan W Berry bryan@olenepal.org
+* Felipe López Toledo zer.subzero@gmail.com
+*
+* Under MIT License:
+* Permission is hereby granted, free of charge, to any person
+* obtaining a copy of this software and associated documentation
+* files (the "Software"), to deal in the Software without
+* restriction, including without limitation the rights to use,
+* copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following
+* conditions:
+*
+* The above copyright notice and this permission notice shall be
+* included in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+/**
+* @fileOverview Contains karma library
+* @author Bryan Berry <bryan@olenepal.org>
+* @author Felipe Lopez Toledo <zer.subzero@gmail.com>
+*/
+
+
+//common.js modules use exports object
+if(!this.exports) {
+ exports = {};
+}
+
+
+
+/** Checks if the current document type is set to HTML 5, throws
+ * an error otherwise, then initializes the karma object and returns
+ * a reference to that object.
+ * @namespace Global namespace for Karma library
+ * @param {Object} [options={}] options for intializing Karma library
+ * @param {String} [options.locale=''] sets current locale Not Yet Implemented
+ * @param {Array} [options.image=[]] array of images to be converted into a collection
+ * @param {Array} [options.audio=[]] array of audio to be converted into a collection
+ * @param {Array} [options.video=[]] array of videos to be converted into a collection
+ * @param {Array} [options.svg=[]] array of SVG elements to be
+ * converted into a collection. Each SVG element must already exist in the html document
+ * @param {Array} [options.canvas=[]] array of canvas elements
+ * to be converted into a collection. Each canvas element must already exist in the
+ * html document and width and height of each element must be set as attributes
+ * @throws {Error} if the document type declaration is not set to HTML 5, e.g.
+ * <!DOCTYPE html>
+ * @throws {Error} If any of the initialization parameters are invalid values
+ * @returns {Object} Karma.karma -- reference to the initialized Karma library
+ * @example
+ *
+ * var k = Karma({
+ * image: [
+ * {name: "ninja", file: "ninja.png"},
+ * {name: "cowboy", file: "cowboy.png"}
+ * ],
+ * audio: [
+ * {name: "woosh", file: "woosh.ogg"},
+ * {name: "yeehaw", file: "yeehaw.ogg"}
+ * ],
+ * video: [
+ * {name: "attack", file: "attack.ogv"},
+ * {name: "ride", file: "ride.ogv"}
+ * ]
+ * canvas: [
+ * {name: "ninja", domId: "ninjaCanvas"},
+ * {name: "cowboy", domId: "cowboyCanvas"}
+ * ],
+ * svg: [
+ * {name: "ninja", domId: "ninjaSvg"},
+ * {name: "cowboy", domId: "cowboySvg"}
+ * ],
+ * });
+ * Next, call the ready function with a callback to your program code
+ *
+ * k.ready(function () { ... your application code . . . }
+ *
+ * after that you can access each asset like so
+ * k.image.ninja;
+ * k.svg.cowboy;
+ * k.audio.yeehaw.play();
+ * k.canvas.ninja.drawImage(k.image.ninja, 0, 0);
+ *
+ */
+var Karma = exports.Karma = function (options) {
+ Karma._isHtml5(document.doctype.nodeName);
+
+ if ( Karma.karma._initialized === true ) {
+ return Karma.karma;
+ } else {
+ return Karma.karma._init(options);
+ }
+};
+
+
+//helper functions
+
+/**This emulates the Object.create method in ecmascript 5 spec
+ * This isn't a full implementation as it doesn't support
+ * This has the same functionality as Crockford's beget method
+ * and this primary building block for prototypal inheritance in
+ * this library
+ * @param {Object} target that the new object's prototype should point to
+ * @returns {Object} object whose prototype points to target
+ * @example
+ *
+ * var ninja = { weapon : "sword" };
+ * var ninja1 = Karma.create(ninja);
+ * ninja1.sword === "sword"
+ */
+Karma.create = function (target){
+ function F () {};
+ F.prototype = target;
+ return new F();
+};
+
+/** Returns a shallow copy of the passed in object
+ * @param {Object} target to be copied
+ * @returns {Object} a shallow copy of target
+ */
+Karma.clone = function (target){
+ var copy = {};
+ for ( var i in target ) {
+ if(target.hasOwnProperty(i)){
+ copy[i] = target[i];
+ }
+ }
+ return copy;
+};
+
+/** Extends properties of the target object with those of
+ * the source object
+ * @param {Object} target object to be extended
+ * @param {Object} source whose properties will extend target
+ * @returns {Object} target extended by source
+ */
+Karma.objectPlus = function (target, source){
+ for ( var i in source){
+ if (source.hasOwnProperty(i)){
+ target[i] = source[i];
+ }
+ }
+ return target;
+};
+
+/** Creates a new object that is a prototype of the first argument
+ * then extends it with the properties of the second argument
+ * @param {Object} parent1 will be prototype of returned object
+ * @param {Object} parent2 will extend properties of returned object
+ * @returns {Object} object that whose prototype is parent1 and has
+ * been extended with properties of parent2
+ */
+Karma.copyObjectPlus = function (parent1, parent2){
+ function F () {};
+ F.prototype = parent1;
+ var G = new F();
+ return Karma.objectPlus(G, parent2);
+};
+
+//Enables function chaining for a specified list of function names
+//IMPORTANT: use of closures here with "this" and "that" is __very__
+//complicated here
+Karma._makeChain = function (chainingFunctions) {
+ var that = this;
+ var _chainFunction = function ( name ){
+ that[ name ] = function ( ){
+ var type = typeof this.ctx[name];
+ if ( type === "function") {
+ this.ctx[ name ].apply( this.ctx, arguments );
+ }else if ( type === "string" ){
+ this.ctx[ name ] = arguments[0];
+ }else {
+ throw ("wtf?!: impossible to chain " + name + "!");
+ }
+ return this;
+ };
+ };
+
+ for (var i = 0; i < chainingFunctions.length; i++){
+ _chainFunction( chainingFunctions[ i ] );
+ }
+};
+
+//Throws big ugly error if doctype isn't html5
+Karma._isHtml5 = function (doctype){
+ var regex = new RegExp('^html$', 'i');
+ if(!regex.test(doctype)){
+ var errorMsg = "ERROR: The doctype must be set to <!DOCTYPE html> " +
+ "in order to use Karma. Karma require you use html5";
+ var errorElem = document.createElement('div');
+ errorElem.setAttribute('id', 'errorDoctype');
+ errorElem.innerText = errorMsg;
+ document.body.appendChild(errorElem);
+ throw new Error(errorMsg);
+ }
+};
+
+
+/** Stores global settings for the Karma library
+ * @class This object stores the global settings for the Karma library
+ */
+Karma.karma = {
+ /** This is the global locale as passed to Karma(),
+ * such as "en", "es_SP"
+ * @type string
+ * @default undefined
+ */
+ locale : undefined,
+ /** Collection of images with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ image : {},
+ /** Collection of audio with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ audio : {},
+ /** Collection of canvas with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ canvas : {},
+ /** Collection of svgs with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ svg : {},
+ /** Collection of videos with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ video : {},
+ _localized : false,
+ _assetPath : "assets/",
+ _localePath : "",
+ _initialized : false,
+ _statusDiv: undefined,
+ _loaderDiv : undefined,
+ _counters : { total : 0, errors : 0, loaded : 0},
+
+ //init initializes all the assets passed to Karma, that's it
+ //it returns 'this' so it can be used for function chaining
+ _init: function(options) {
+ this._initialized = true;
+
+ //set up message that show count of assets loaded
+ //and has an ordered list to append error messages to
+ var _statusDiv = this._statusDiv = document.createElement('div');
+ this._loaderDiv = this._loaderDiv = document.createElement('div');
+ var errorList = document.createElement('ol');
+
+ _statusDiv.setAttribute('id', 'karma-status');
+ _statusDiv.setAttribute('style', 'position:absolute;');
+ _statusDiv.innerHTML = 'Karma is loading ...';
+ this._loaderDiv.setAttribute('id', 'karma-loader');
+ this._loaderDiv.setAttribute('class', 'status');
+ errorList.setAttribute('id', 'errorList');
+
+ _statusDiv.appendChild(this._loaderDiv);
+ this._statusDiv.appendChild(errorList);
+ document.body.appendChild(_statusDiv);
+
+
+ //chain the functions for kCanvas and kSvg
+ Karma._makeChain.call(Karma.kCanvas,
+ Karma.kCanvas._chainingFunctions);
+ //Karma._makeChain.apply(Karma.kSvg, Karma.kSvg._chainingFunctions);
+
+
+
+ //regular expression that matches the name of aprivate property
+ // the karma object
+ var regexPrivate = new RegExp('^_.*');
+
+ for ( var option in options ) {
+ if (options.hasOwnProperty(option)){
+ if (option === "image" || option === "audio" || option ===
+ "svg" || option === "video" || option === "canvas"){
+
+ if(!(options[option] instanceof Array)){
+ throw new Error("" + option + " must be an array");
+ } else if (options[option].length === 0){
+ continue;
+ }
+ } else if (regexPrivate.test(option)){
+ //don't overwrite a private property of karma object
+ continue;
+ }
+
+ switch (option){
+ case "locale":
+
+ if (this._isValidLocale(options[option])){
+ this.locale = this._normalizeLocale(options[option]);
+ this._localized = true;
+ this._localePath = Karma._computeLocalePath(this.locale);
+ } else {
+ throw new Error("locale provided to karma._init() is invalid");
+ }
+
+ break;
+ case "image":
+ options[option]._type = 'image';
+ Karma._makeImages(options[option]);
+ break;
+ case "audio":
+ options[option]._type = 'audio';
+ Karma._makeAudio(options[option]);
+ break;
+ case "video":
+ options[option]._type = 'video';
+ Karma._makeVideos(options[option]);
+ break;
+ case "svg":
+ options[option]._type = 'svg';
+ Karma._makeSvgs(options[option]);
+ break;
+ case "canvas":
+ options[option]._type = 'canvas';
+ Karma._makeCanvases(options[option]);
+ break;
+ }
+ }
+ }
+
+
+
+ return this;
+ },
+
+ /** Waits until all assets loaded, i.e. ready, then calls callback
+ * @param {Function} [cb] callback function
+ * @returns this
+ * @throws {Error} if Karma.karma is not initialized with the
+ * Karma({ options }) function
+ * @example
+ *
+ * var k = Karma({ . . . your assets here . . . });
+ * k.ready(function(){ .. your code here . . .});
+ *
+ * your code will not be called until all assets have been loaded
+ *
+ */
+ ready : function( cb ) {
+ var that = this;
+ if (Karma.karma._initialized !== true){
+ throw new Error("Karma.karma not initialized");
+ }
+
+ if (this._counters.loaded !== this._counters.total){
+ setTimeout(function(){ that.ready(cb);}, 5);
+ } else if (cb) {
+ //hide the "Karma is loading..." message
+ this._statusDiv.setAttribute('style', 'display:none;');
+
+ cb();
+ } else if (!cb) {
+ //hide the "Karma is loading..." message
+ this._statusDiv.setAttribute('style', 'display:none;');
+
+ //if no options passed, show it works message
+ this._showStarterMessage();
+ }
+
+
+
+
+ return this;
+ },
+
+ //Display Apache-like "It works" message if no options
+ _showStarterMessage : function (){
+ var starterMsg = document.createElement('div');
+ starterMsg.setAttribute('id', 'starterMsg');
+ starterMsg.innerHTML = "<h1>It Works</h1>";
+ document.body.appendChild(starterMsg);
+ },
+
+ //Updates visible counter of how many assets are loaded
+ _updateStatus : function (errorMsg) {
+ var loaded = this._counters.loaded;
+ var total = this._counters.total;
+ var errors = this._counters.errors;
+ this._loaderDiv.innerHTML = "Loaded " + loaded + " / " + total +
+ "" + (errors > 0 ? " Errors [ " + errors +" ]" : '');
+ if (errorMsg) {
+ var liError = document.createElement('li');
+ liError.innerHTML = errorMsg;
+ var errorList = document.getElementById('errorList');
+ errorList.appendChild(liError);
+ }
+ },
+
+ //matches 2 letter country code then optionally
+ //a dash or underscore followed by a country or language identifier
+ //i currently only allow a language identifier 2-3 chars long
+ _isValidLocale : function (locale) {
+ var localeRegex = new RegExp('^[a-zA-Z][a-zA-Z]([-_][a-zA-z]{2,3})?$');
+ return localeRegex.test(locale);
+ },
+
+ _normalizeLocale : function(locale) {
+ var lang = "";
+ var country = "";
+ var divider = "";
+
+ lang = locale.slice(0, 2).toLowerCase();
+ divider = "_";
+ country = locale.slice(3, 6).toUpperCase();
+
+ return locale.length > 2 ? "" + lang + divider + country : lang;
+ },
+
+ // Below are geometry and math helper methods
+
+ /**
+ * Converts a value from degrees to radians.
+ * @param {Number} angle The angle in degrees
+ * @returns {Number} The angle in radians
+ */
+ radians : function( angle ){
+ return ( angle / 180 ) * Math.PI;
+ },
+ /**
+ * Gets the square of the Euclidian (ordinary) distance between 2 points.
+ * @param {Object} Point No. 0
+ * @param {Number} Point0.x
+ * @param {Number} Point0.y
+ * @param {Object} Point No. 1
+ * @param {Number} Point1.x
+ * @param {Number} Point1.y
+ * @returns {Number} The square of the Euclidian distance
+ * @example
+ *
+ * p0 = {x:0, y:1};
+ * p1 = {x:50, y:70};
+ * var d = distance2(p0, p1);
+ *
+ */
+ distance2 : function ( p0, p1 ) {
+ return (p1.x - p0.x) * (p1.x - p0.x) + (p1.y - p1.y) * (p1.y - p1.y);
+ },
+ /**
+ * Gets the Euclidian (ordinary) distance between 2 points.<br>
+ * <b>Warning:</b> It's slower than distance2 function
+ * @param {Object} Point No. 0
+ * @param {Number} Point0.x
+ * @param {Number} Point0.y
+ * @param {Object} Point No. 1
+ * @param {Number} Point1.x
+ * @param {Number} Point1.y
+ * @returns {Number} The Euclidian distance
+ * @example
+ *
+ * p0 = {x:0, y:1};
+ * p1 = {x:50, y:70};
+ * var d = distance2(p0, p1);
+ *
+ */
+ distance : function ( p0, p1 ) {
+ return Math.sqrt( this.distance2( p0, p1 ) );
+ },
+ /** Returns a random number within the range provided
+ * @param {Number} lower limit of the range, lowest number that can be returned
+ * @param {Number} upper limit of the range, highest number that can be returned
+ * @returns {Number} number that is >= lower and <= upper
+ * @example
+ *
+ * var num = rand(0, 10);
+ *
+ * num could be 0, 1, 2, 3 ... or 10
+ *
+ */
+ rand : function ( lower, upper ){
+ return Math.round( Math.random() * (upper - lower) + lower );
+ }
+
+};
+
+/** Prototypal object for images, videos, and audio files but
+ * does not include svg or canvas elements
+ * @class This object is the prototype for images, videos, and audio files but
+ * does not include svg or canvas elements
+ * @ throws {Error} if the individual asset is set to be localized but
+ * the globale locale is not set on the Karma.karma object
+ * @ throws {Error} if the name and file properties are not supplied
+ * @example
+ * kMedia is the prototype object for images, audio, and videos.
+ * These 'media' assets are loaded in a distinctly different way
+ * from the canvas or svg assets. They also have distinctly different
+ * helper methods
+ *
+ * You initialize the kMedia assets by passing an array of objects
+ */
+Karma.kMedia = {
+ /** file location of asset
+ * @type String
+ * @default ""
+ */
+ file : "",
+ /** media object
+ * @type Audio|Image|Video
+ * @default undefined
+ */
+ media : undefined,
+ //actual path to the file
+ _path : "",
+ //if using localized version of this asset
+ _localized : false,
+ //audio, image, or video
+ _type : "",
+ //initializes kMedia instance with values provided by user
+ _init : function (asset) {
+ asset._localized = asset._localized || false;
+ Karma.karma._counters.total++;
+
+ if (asset.name === undefined || asset.file === undefined){
+ throw new Error("properties name and file have to be defined");
+ } else {
+ this.name = asset.name;
+ this.file = asset.file;
+ }
+
+ //_type is a private variable used internally
+ if (asset._type === undefined){
+ throw new Error("the _type property must be set. " +
+ "Blame the karma library authors as this is an internal value");
+ } else {
+ if (Karma._isValidType(asset._type)){
+ this._type = asset._type;
+ switch ( this._type ) {
+ case "image": this.media = new Image();
+ break;
+ case "audio": this.media = new Audio();
+ break;
+ //case "video":
+ //NYI
+ //this.media = new Video();
+ break;
+ default: throw new Error("Media type not supported");
+ }
+
+ } else {
+ throw new Error("the _type property supplied is invalid. " +
+ "Blame the karma library authors as this is an internal value");
+ }
+ }
+
+ if(Karma._isLocalized(asset._localized)){
+ this._localized = asset._localized;
+ this._path = Karma.karma._localePath +
+ this._type + "/";
+ } else {
+ this._path = Karma.karma._assetPath +
+ this._type + "/";
+ }
+
+
+ //IMPORTANT: This one magic line loads the file
+ this.media.src = this.src = this._path + this.file;
+
+ //add event handlers
+ this._addEventHandlers();
+
+ if (this._type === "audio"){
+ this.media.autobuffer = true;
+ this.media.load();
+ }
+
+
+ return this;
+ },
+ //Adds event handlers to update the counters when
+ //the asset is successfully or unsuccessfully loaded
+ _addEventHandlers : function () {
+ var that = this;
+ var loadEvent = "load";
+ //Browser Hack recommended by chromium devs
+ //http://code.google.com/p/chromium/issues/detail?id=20251&q=loading%20audio&colspec=ID%20Stars%20Pri%20Area%20Type%20Status%20Summary%20Modified%20Owner%20Mstone%20OS#c4
+ if (this._type === "audio" || this._type === "video"){
+ loadEvent = "canplaythrough";
+ }
+
+ that.media.addEventListener(
+ loadEvent,
+ function (e) {
+ Karma.karma._counters.loaded++;
+ Karma.karma._updateStatus();
+ that.status = "loaded";}, false);
+
+ that.media.addEventListener(
+ "error",
+ function (e) {
+ Karma.karma._counters.errors++;
+ that.status = "error";
+ var errorMsg = "Error: " + that._type.toUpperCase() +
+ " " + that.name + " cannot be loaded.";
+ Karma.karma._updateStatus(errorMsg);
+ },
+ false);
+ that.media.addEventListener(
+ "abort",
+ function (e) {
+ Karma.karma._counters.total++;
+ that.status = "aborted";
+ var errorMsg = "ABORT: " + that._type.toUpperCase() +
+ " " + that.name + " loading was aborted.";
+ Karma.karma._updateStatus(errorMsg);
+
+ }, false);
+
+ }
+
+};
+
+//determine if it is a valid type of asset
+Karma._isValidType = function (type){
+ return type === "image" ||
+ type === "svg" ||
+ type === "audio" ||
+ type === "video" ||
+ type === "canvas";
+};
+
+Karma._isLocalized = function (boolLocalized) {
+ if (typeof boolLocalized === "boolean" ) {
+ if(boolLocalized === true &&
+ Karma.karma.locale === undefined){
+ throw new Error("You cannot localize a media asset" +
+ " if the global locale for Karma isn't set");
+ } else {
+ return boolLocalized;
+ }
+ } else if (typeof boolLocalized === undefined){
+ return false;
+ } else{
+ throw new Error("This is not a valid value for the localized option");
+ }
+};
+
+Karma._computeLocalePath = function(locale) {
+ return Karma.karma._assetPath + locale + "/";
+};
+
+Karma._makeImages = function (imgConfigs){
+ var makeImage = function (imgConfig){
+ var image = undefined;
+ imgConfig._type = "image";
+ image = Karma.create(Karma.kMedia)._init(imgConfig);
+ Karma.karma.image[imgConfig.name] = image;
+ };
+
+ imgConfigs.forEach(function(imgConfig){ makeImage(imgConfig);});
+
+};
+
+Karma._makeAudio = function (audioConfigs){
+ var makeAudio = function (audioConfig){
+ var audio = undefined;
+ audioConfig._type = "audio";
+ audio = Karma.create(Karma.kMedia)._init(audioConfig);
+ audio.play = function () {
+ //hack to fix the audio "stuttering" problem
+ //more info: https://bugs.launchpad.net/karma/+bug/426108
+ this.media.currentTime = 0.1;
+ this.media.play();
+ };
+ Karma.karma.audio[audioConfig.name] = audio;
+ };
+
+ audioConfigs.forEach(function(audioConfig){ makeAudio(audioConfig);});
+
+};
+
+
+Karma._makeCanvases = function (canvasConfigs){
+ var makeCanvas = function (canvasConfig){
+ var canvas = undefined;
+ canvas = Karma.create(Karma.kCanvas)._init(canvasConfig);
+ Karma.karma.canvas[canvasConfig.name] = canvas;
+ };
+
+ canvasConfigs.forEach(function(canvasConfig){ makeCanvas(canvasConfig);});
+
+};
+
+/** Prototypal object for each canvas element submitted to Karma in the
+ * Karma() method
+ * @throws {Error} if the name and domId for the canvas element are not specified
+ * @thows {Error} if the supplied domId does not match an element in the DOM
+ * @class This object is the prototype for each canvas element submitted to Karma in the
+ * Karma() method
+ */
+Karma.kCanvas = {
+ /** Name of the canvas, used internally by karma.js
+ * @type String
+ * @default ''
+ */
+ name : '',
+ /** Width of canvas element
+ * @type Number
+ * @default 0
+ */
+ width: 0,
+ /** Height of canvas element
+ * @type Number
+ * @default 0
+ */
+ height: 0,
+ /** Whether canvas is visible
+ * @type boolean
+ * @default true
+ */
+ visible: true,
+ /** Element ID for canvas element in html document
+ * @type String
+ * @default undefined
+ */
+ domId: undefined,
+ /** Reference to the DOM element
+ * @type DOMElement
+ * @default undefined
+ */
+ node: undefined,
+ /** The 2 Dimensional Rendering context property for this canvas
+ * @type 2DRenderingContext
+ * @default undefined
+ */
+ ctx: undefined,
+ /** Frames Per Second, I don't know what the purpose of this is,
+ * Felipe made it up
+ * @type Number
+ * @default 24
+ */
+ fps: 24,
+
+ //initializes object with values provides by user
+ _init: function (config) {
+ for (var option in config){
+ if (config.hasOwnProperty(option)){
+ switch (option){
+ case "name":
+ this.name = config[option];
+ break;
+ case "domId":
+ this.domId = config[option];
+ break;
+ case "width":
+ if(!this.height){
+ throw new Error("If you specify a width you must also" +
+ "specify a height");
+ }
+ this.width = config[option];
+ break;
+ case "height":
+ if(!this.width){
+ throw new Error("If you specify a height you must also" +
+ "specify a width");
+ }
+ this.height = parseInt(config.option, 10);
+ break;
+ case "fps":
+ this.fps = parseInt(config.option, 10);
+ break;
+ }
+ }
+ }
+
+ if(this.domId && document.getElementById(this.domId)){
+ this.node = document.getElementById(this.domId);
+ this.ctx = this.node.getContext('2d');
+ } else {
+ throw new Error('you must specify a valid domId that' +
+ 'is in your html page');
+ }
+
+ if(!config.height && !config.width){
+ this.width = parseInt(this.node.getAttribute('width'), 10);
+ this.height = parseInt(this.node.getAttribute('height'), 10);
+ }
+
+ return this;
+ },
+ /** Clear area of canvas element specified by parameters, if no
+ * parameters supplied, clears entire canvas
+ * @param {Number} [x=0] x coordinate, defaults to zero if left blank
+ * @param {Number} [y=0] y coordinate, defaults to zero if left blank
+ * @param {Number} [width=0] width of area to be cleared, defaults
+ * entire width of canvas
+ * @param {Number} [height=0] height of area to be cleared, defaults
+ * entire height of canvas
+ * @returns this
+ * @example
+ *
+ * k.canvas.ninja.clear();
+ * // clears the entire ninja canvas
+ *
+ * k.canvas.ninja.clear(0, 10, 20, 30);
+ * //clears a specific portion of the ninja canvas
+ *
+ */
+ clear : function ( x, y, width, height ) {
+ var that = this;
+ that.ctx.clearRect(
+ x || 0,
+ y || 0,
+ width || that.width,
+ height || that.height
+ );
+ return that;
+ },
+
+ //These are all properties or methods of the canvas element's
+ //2 dimensional context
+ _chainingFunctions : [
+ "globalAlpha", "globalCompositeOperation", "lineWidth", "lineCap",
+ "lineJoin", "miterLimit", "font", "textAlign", "textBaseline", "save",
+ "restore", "scale", "rotate", "translate", "transform", "setTransform",
+ "clearRect", "fillRect", "strokeRect", "beginPath", "closePath",
+ "moveTo", "lineTo", "quadraticCurveTo", "bezierCurveTo", "arcTo",
+ "arc", "rect", "fill", "stroke", "clip", "fillText", "strokeText",
+ "measureText", "isPointInPath", "strokeStyle", "fillStyle",
+ "createLinearGradient", "createRadialGradient", "createPattern",
+ "shadowOffsetX", "shadowOffsetY", "shadowBlur", "shadowColor",
+ //"mozTextStyle", "mozDrawText", "mozMeasureText", "mozPathText",
+ "mozTextAlongPath", "drawImage", "getImageData", "putImageData",
+ "createImageData", "drawWindow"
+ ]
+};
+
+
+
+Karma._makeSvgs = function (svgConfigs){
+ var makeSvg = function (svgConfig){
+ var svg = undefined;
+ svg = Karma.create(Karma.kSvg)._init(svgConfig);
+ Karma.karma.svg[svgConfig.name] = svg;
+ };
+
+ svgConfigs.forEach(function(svgConfig){ makeSvg(svgConfig);});
+
+};
+
+/** Prototypal object for each svg element submitted to Karma in the
+ * Karma() method
+ * @throws {Error} if the name and domId for the svg element are not specified
+ * @thows {Error} if the supplied domId does not match an element in the DOM
+ * @class This object is the prototype for each svg element submitted to Karma in the
+ * Karma() method
+ */
+Karma.kSvg = {
+ /** name of instance, used internally
+ * @typeof string
+ * @default ""
+ */
+ name : "",
+ /** width of element
+ * @type number
+ * @default 0
+ */
+ width: 0,
+ /** height of element
+ * @type number
+ * @default 0
+ */
+ height: 0,
+ /** Status of element, either "loaded" or "error"
+ * @type string
+ * @default ""
+ */
+ status: "",
+ /** Whether canvas is visible
+ * @type boolean
+ * @default true
+ */
+ visible: true,
+ /** Element ID for canvas element in html document
+ * @type String
+ * @default undefined
+ */
+ domId: undefined,
+ /** Reference to the DOM element
+ * @type DOMElement
+ * @default undefined
+ */
+ node: undefined,
+ /** Reference to the SVGDocument
+ * @type SVGDocument
+ * @default undefined
+ */
+ doc: undefined,
+ /** Reference to the root element of the SVG Document
+ * @type DocumentElement
+ * @default undefined
+ */
+ root: undefined,
+ _localized : undefined,
+ _chainingFunctions: [],
+ _init: function (config) {
+ Karma.karma._counters.total++;
+
+ for (var option in config){
+ if (config.hasOwnProperty(option)){
+ switch (option){
+ case "name":
+ this.name = config[option];
+ break;
+ case "domId":
+ this.domId = config[option];
+ break;
+ case "width":
+ if(!this.height){
+ throw new Error("If you specify a width you must also" +
+ "specify a height");
+ }
+ this.width = parseInt(config[option], 10);
+ break;
+ case "height":
+ if(!this.width){
+ throw new Error("If you specify a height you must also" +
+ "specify a width");
+ }
+ this.height = config[option];
+ break;
+ case "fps":
+ this.fps = config[option];
+ break;
+ }
+ }
+ }
+
+ if(this.domId && document.getElementById(this.domId)){
+ this.node = document.getElementById(this.domId);
+ } else {
+ throw new Error('you must specify a valid domId that' +
+ 'is in your html page');
+ }
+
+ if(!config.height && !config.width){
+ this.width = parseInt(this.node.getAttribute('width'), 10);
+ this.height = parseInt(this.node.getAttribute('height'), 10);
+ }
+
+ var that = this;
+ that._addEventHandlers();
+
+ return this;
+
+
+ },
+ _addEventHandlers : function () {
+ var that = this;
+ that.doc = that.node.getSVGDocument();
+ that.node.addEventListener(
+ "load",
+ function (e) {
+ that.doc = that.node.getSVGDocument();
+ that.root = that.doc.documentElement;
+ Karma.karma._counters.loaded++;
+ Karma.karma._updateStatus();
+ that.status = "loaded";
+ }, false);
+
+ that.node.addEventListener(
+ "error",
+ function (e) {
+ Karma.karma._counters.loaded--;
+ Karma.karma._counters.errors++;
+ that.status = "error";
+ var errorMsg = "Error: " + that._type.toUpperCase() +
+ " " + that.name + " cannot be loaded.";
+ Karma.karma._updateStatus(errorMsg);
+ },
+ false);
+ that.node.addEventListener(
+ "abort",
+ function (e) {
+ that.status = "aborted";
+ var errorMsg = "ABORT: " + that._type.toUpperCase() +
+ " " + that.name + " loading was aborted.";
+ Karma.karma._updateStatus(errorMsg);
+
+ }, false);
+
+ }
+};
+
+Karma._makeVideos = function (video){
+
+};
diff --git a/examples/lessons/6_English_namesOfColor/js/lesson.js b/examples/lessons/6_English_namesOfColor/js/lesson.js
new file mode 100755
index 0000000..8908da4
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/js/lesson.js
@@ -0,0 +1,743 @@
+$(document).ready(function(){
+ var k = Karma({
+ audio: [{'name':'correct','file':'correct.ogg'},
+ {'name':'incorrect','file':'incorrect.ogg'},
+ {'name':'One fish','file':'one_fish.wav'},
+ {'name':'One house','file':'one_house.wav'},
+ {'name':'Two fish','file':'two_fish.wav'},
+ {'name':'Red fish','file':'red_fish.wav'},
+ {'name':'Blue fish','file':'blue_fish.wav'},
+ {'name':'One mouse','file':'one_mouse.wav'},
+ {'name':'Red house','file':'red_house.wav'},
+ {'name':'Blue mouse','file':'blue_mouse.wav'},
+ {'name':'One head','file':'one_head.wav'},
+ {'name':'One bed','file':'one_bed.wav'},
+ {'name':'Red head','file':'red_head.wav'},
+ {'name':'Blue bed','file':'blue_bed.wav'},
+ {'name':'Green','file':'green.wav'},
+ {'name':'Brown','file':'brown.wav'},
+ {'name':'Purple','file':'purple.wav'},
+ {'name':'turtle','file':'turtle.wav'},
+ {'name':'bean','file':'bean.wav'},
+ {'name':'uncle','file':'uncle.wav'},
+ {'name':'bed','file':'bed.wav'},
+ {'name':'Red','file':'red.wav'},
+ {'name':'Blue','file':'blue.wav'},
+ {'name':'Yellow','file':'yellow.wav'},
+ {'name':'dead','file':'dead.wav'},
+ {'name':'fellow','file':'fellow.wav'},
+ {'name':'flew','file':'flew.wav'},
+ {'name':'zoo','file':'zoo.wav'},
+ {'name':'Orange','file':'orange.wav'},
+ {'name':'White','file':'white.wav'},
+ {'name':'back','file':'back.wav'},
+ {'name':'November','file':'november.wav'},
+ {'name':'spots','file':'spots.wav'},
+ {'name':'Black','file':'black.wav'},
+ {'name':'Gray','file':'grey.wav'},
+ {'name':'Pink','file':'pink.wav'},
+ {'name':'drink','file':'drink.wav'},
+ {'name':'ink','file':'ink.wav'},
+ {'name':'think','file':'think.wav'},
+ {'name':'sink','file':'sink.wav'},
+ {'name':'stink','file':'stink.wav'}
+
+ ]});
+
+ k.ready(function(){
+ var i,j;
+ var currentLesson;
+ var TOTAL_QUES = 6;
+ var currentLessonStart;
+ var num;
+ var numLessonClicks = new Array(8,4);
+ var sounds = new Array('One fish','Two fish','Red fish','Blue fish','One house','One mouse','Red house','Blue mouse',
+ 'One head','One bed','Red head','Blue bed',
+ 'Green','Brown','Purple','turtle','Purple','Brown','uncle','bean','Green','bed', //23
+ 'Red','Yellow','Blue','zoo','dead','Red','Yellow','fellow','flew','Blue', //32
+ 'Orange','White','Black','back','Orange','Green','Green','Orange','November', //42
+ 'White','Black','spots','White','Black',
+ 'Black','Gray','Pink','drink','Black','ink','Black','Black','sink','Gray','stink','Pink','think'
+
+ );
+ var lesson3texts = new Array('See the little','The turtle is','His name is Punckle','He has a','The turtle ate a',
+ 'He became','The turtle went to','He became'
+ );
+ var lesson4texts = new Array('We go the little','One animal is','Its color is','This animal is','She is tall',
+ 'We go to see the birds','A bird just','Its color is'
+ );
+ var lesson5texts = new Array('From the zoo we came','Let us go to see the orange tree','An orange is','Have you seen an orange that is',
+ 'An orange on a','It becomes'
+ );
+
+ var assignImages = function(lessonId){
+ var lessonIdNew;
+ lessonId = currentLessonStart+lessonId;
+ if(currentLesson === 0){
+ lessonIdNew = lessonId-2;
+ }
+ else{
+ lessonIdNew = lessonId;
+ }
+ if(currentLesson === 0 ){
+ $('#bindImg'+lessonIdNew).append('<div id="img'+lessonId+'"></div>');
+ $('#img'+lessonId).html('<img src="assets/image/'+sounds[lessonId]+'.png">');
+ }
+ };
+
+ var assignLesson = function(lessonId){
+ lessonId = currentLessonStart+lessonId;
+ var bindImgCss = {
+ 'float':'left',
+ 'width': '210px',
+ 'text-align':'center',
+ 'padding-bottom':'1em'
+ };
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="imgBind"></div>');
+ $('#bindImg'+lessonId).css(bindImgCss);
+ if(currentLesson === 1){
+ $('#bindImg'+lessonId).append('<div id="img'+lessonId+'"></div>');
+ $('#img'+lessonId).html('<img src="assets/image/'+sounds[lessonId]+'.png">');
+ }
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange large"></div>');
+ $('#click'+lessonId).append(sounds[lessonId]).addClass('default');
+
+ $('#click'+lessonId).bind({
+ mouseover: function(){
+ $(this).addClass('hoverClick');
+ },
+ mouseout: function(){
+ $(this).removeClass('hoverClick');
+ },
+ click: function(){
+ $(this).addClass('clicked');
+ var curSound = sounds[lessonId];
+ if(currentLesson === 1){
+ if(lessonId === 10 || lessonId === 11){
+ $('#img'+lessonId).html('<img src="assets/image/'+sounds[lessonId]+'_Clicked.png" />');
+ }
+ }
+ else{
+ $('#img'+lessonId).html('<img src="assets/image/'+sounds[lessonId]+'_Clicked.png" />');
+ }
+ k.audio[curSound].play();
+ }
+ });
+ };
+
+
+ var assignColorBoxes = function(lessonId){ //for lesson 3 and 4
+ $('#bindImg'+currentLessonStart).append('<div id = "click'+lessonId+'" class="clicktoChange medium border"></div>');
+ $('#click'+lessonId).append(sounds[lessonId]).addClass(sounds[lessonId]);
+
+ $('#click'+lessonId).bind({
+ mouseover: function(){
+ $(this).removeClass(sounds[lessonId]);
+ $(this).addClass('hoverClick');
+ },
+ mouseout: function(){
+ $(this).removeClass('hoverClick');
+ $(this).addClass(sounds[lessonId]);
+ },
+ click: function(){
+ $(this).addClass(sounds[lessonId]);
+ var curSound = sounds[lessonId];
+ k.audio[curSound].play();
+ }
+ });
+ };
+
+ var bindSounds = function(lessonId){
+ $('#click'+lessonId).bind({
+ mouseover: function(){
+ $(this).removeClass(sounds[lessonId]);
+ $(this).addClass('hoverClick');
+ },
+ mouseout: function(){
+ $(this).removeClass('hoverClick');
+ $(this).addClass(sounds[lessonId]);
+ },
+ click: function(){
+ //$(this).addClass(sounds[lessonId]);
+ var curSound = sounds[lessonId];
+ //alert(curSound);
+ k.audio[curSound].play();
+ if(lessonId === 16){
+ $('#img0').html('<img src="assets/image/turtle_Clicked.png" />');
+ }
+ if(lessonId === 22){
+ $('#img3').html('<img src="assets/image/red_bed_Clicked.png" />');
+ }
+ if(lessonId === 27){
+ $('#img5').html('<img src="assets/image/dead_Clicked.png" />');
+ }
+ if(lessonId === 28){
+ $('#img6').html('<img src="assets/image/giraffe_Clicked.png" />');
+ }
+ if(lessonId === 31){
+ $('#img7').html('<img src="assets/image/bird_Clicked.png" />');
+ }
+ if(lessonId === 37 || lessonId === 38 ){
+ $('#img9').html('<img src="assets/image/orange_Clicked.png" />');
+ }
+ if(lessonId === 39 || lessonId === 36){
+ $('#img9').html('<img src="assets/image/orange.png" />');
+ }
+ if(lessonId === 41 || lessonId === 44){
+ $('#img11').html('<img src="assets/image/cat.png" />');
+ }
+ if(lessonId === 42 || lessonId === 45){
+ $('#img11').html('<img src="assets/image/cat_black.png" />');
+ }
+ if(lessonId === 43){
+ $('#img11').html('<img src="assets/image/cat_strip.png" />');
+ }
+ }
+ });
+
+ }
+
+
+
+
+
+ var assignImagesAbsolute = function(imgId,topPos,leftPos,imgName){
+ $('#lesson').append('<div id="img'+imgId+'"></div>')
+ $('#img'+imgId).html('<img src="assets/image/'+imgName+'.png" />');
+ var imgCss = {
+ 'position':'absolute',
+ 'top':topPos+'px',
+ 'left':leftPos+'px'
+ };
+ $('#img'+imgId).css(imgCss);
+ bindSounds(imgId);
+ };
+
+ var startLesson7 = function(){
+ var lessonCss = {
+ 'position':'relative',
+ 'margin': '1em 0 0 1em',
+ 'float':'left',
+ 'width': '800px',
+ 'height': '520px',
+
+ };
+ $('#lesson').html('').css(lessonCss);
+ currentLessonStart = 46;
+ var lessonId = currentLessonStart;
+ $('#lesson').append('<div id="bindImg'+currentLessonStart+'" class="imgBind"></div>');
+ var bindImgCss = {
+ 'position':'relative',
+ 'float':'left',
+ 'width': '500px',
+ 'height':'40px',
+ 'text-align':'center',
+ 'padding-bottom':'1em',
+ 'margin-left':'5em'
+ };
+ $('#bindImg'+currentLessonStart).css(bindImgCss);
+ for(i = currentLessonStart; i< 49; i++){
+ assignColorBoxes(i);
+ }
+
+ lessonId = 49;
+ num = 0;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson7css marginSmall"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> Which would you like to </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border yellow"></div>');
+ $('#click'+lessonId).append('drink ?');
+ bindSounds(lessonId);
+ lessonId++;
+
+ $('#lesson').append('<div id="bindImgGlasses" class="lesson7css marginSmall"></div>');
+ $('#bindImgGlasses').append('<img src="assets/image/black_glass.png" />');
+ $('#bindImgGlasses').append('<img src="assets/image/gray_glass.png" />');
+ $('#bindImgGlasses').append('<img src="assets/image/pink_glass.png" />');
+
+ $('#lesson').append('<div id="bindImgGlassTexts" class="lesson7css marginSmall"></div>');
+ $('#bindImgGlassTexts').append('<span class = "clickTextInfo"> This this or this? </span>');
+
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson7css marginSmall"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> That one is </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border black"></div>');
+ $('#click'+lessonId).append('black');
+ bindSounds(lessonId);
+ lessonIdNew = lessonId+1;
+ $('#bindImg'+lessonId).append('<span class = "smallclickTextInfo"></span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonIdNew+'" class="clicktoChange small border yellow"></div>');
+ $('#click'+lessonIdNew).append('ink');
+ bindSounds(lessonIdNew);
+ lessonId+=2;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson7css marginSmall"></div>');
+ $('#bindImg'+lessonId).append("<span class = 'clickTextInfo'> Don't drink</span>");
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border black"></div>');
+ bindSounds(lessonId);
+ $('#bindImg'+lessonId).append('<span class = "smallclickTextInfo">ink</span>');
+ lessonId+=2;
+
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson7css marginSmall"></div>');
+ $('#bindImg'+lessonId).append("<span class = 'clickTextInfo'> It will make you</span>");
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border yellow"></div>');
+ $('#click'+lessonId).append('sink');
+ bindSounds(lessonId);
+ lessonId++;
+
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson7css marginMedium"></div>');
+ $('#bindImg'+lessonId).append("<span class = 'clickTextInfo'> That is </span>");
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border gray"></div>');
+ $('#click'+lessonId).append('gray');
+ bindSounds(lessonId);
+ $('#bindImg'+lessonId).append('<span class = "smallclickTextInfo">ink</span>');
+ lessonId++;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson7css marginMedium"></div>');
+ $('#bindImg'+lessonId).append("<span class = 'clickTextInfo'> It will make you</span>");
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border yellow"></div>');
+ $('#click'+lessonId).append('stink');
+ bindSounds(lessonId);
+ lessonId++;
+
+
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson7css marginLarge"></div>');
+ $('#bindImg'+lessonId).append("<span class = 'clickTextInfo'> That is </span>");
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border pink"></div>');
+ $('#click'+lessonId).append('pink');
+ bindSounds(lessonId);
+ $('#bindImg'+lessonId).append('<span class = "smallclickTextInfo">ink</span>');
+ lessonId++;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson7css marginLarge"></div>');
+ $('#bindImg'+lessonId).append("<span class = 'clickTextInfo'> It will make you</span>");
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border yellow"></div>');
+ $('#click'+lessonId).append('think');
+ bindSounds(lessonId);
+
+ assignImagesAbsolute(5,135,450,'sink');
+ assignImagesAbsolute(6,280,550,'stink');
+ assignImagesAbsolute(7,375,800,'think');
+
+ };
+
+
+ var startLesson6 = function(){
+ var lessonCss = {
+ 'position':'relative',
+ 'margin': '6em 0 0 10em',
+ 'float':'left',
+ 'width': '600px',
+ 'height': '400px',
+ 'text-align':'center'
+ };
+ $('#lesson').html('').css(lessonCss);
+ currentLessonStart = 41;
+ var lessonId = currentLessonStart;
+
+ $('#lesson').append('<div id="bindImg211" class="lesson6css"></div>');
+ $('#bindImg211').append('<span class = "clickTextInfo"> Look at cat</span>');
+
+ $('#lesson').append('<div id="img11"></img>');
+ $('#img11').append('<img src="assets/image/cat.png />');
+
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson6css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> It is </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border white"></div>');
+ $('#click'+lessonId).append('white');
+ bindSounds(lessonId);
+ $('#bindImg'+lessonId).append('<span class = "smallclickTextInfo"> and fat.</span>');
+ lessonId++;
+
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson5css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> Make the white cat </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border black"></div>');
+ $('#click'+lessonId).append('black');
+ bindSounds(lessonId);
+ lessonId++;
+
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson5css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> Give that black cat spots </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border yellow"></div>');
+ $('#click'+lessonId).append('white');
+ bindSounds(lessonId);
+ lessonId++;
+
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson5css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> Now is the cat </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border white"></div>');
+ $('#bindImg'+lessonId).append('<span class = "smallclickTextInfo">,</span>');
+ bindSounds(lessonId);
+ lessonIdNew = lessonId+1;
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonIdNew+'" class="clicktoChange small border black"></div>');
+ bindSounds(lessonIdNew);
+ $('#bindImg'+lessonId).append('<span class = "smallclickTextInfo"> or fat.</span>');
+
+ }
+
+ var startLesson5 = function(){
+ var lessonCss = {
+ 'position':'relative',
+ 'margin': '1em 0 0 10em',
+ 'float':'left',
+ 'width': '700px',
+ 'height': '520px',
+ 'text-align':'center'
+ };
+ $('#lesson').html('').css(lessonCss);
+ currentLessonStart = 32;
+ var lessonId = currentLessonStart;
+ $('#lesson').append('<div id="bindImg'+currentLessonStart+'" class="imgBind"></div>');
+ var bindImgCss = {
+ 'position':'relative',
+ 'float':'left',
+ 'width': '700px',
+ 'height':'100px',
+ 'text-align':'center',
+ 'padding-bottom':'1em'
+ };
+ $('#bindImg'+currentLessonStart).css(bindImgCss);
+ for(i = currentLessonStart; i< 35; i++){
+ assignColorBoxes(i);
+ }
+
+ lessonId = 35;
+ num = 0;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson5css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> '+lesson5texts[num]+' </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border yellow"></div>');
+ $('#click'+lessonId).append(sounds[lessonId]);
+ bindSounds(lessonId);
+ num++;
+ $('#lesson').append('<div id="bindImg120" class="lesson5css"></div>');
+ $('#bindImg120').append('<span class = "clickTextInfo"> '+lesson5texts[num]+'</span>');
+ lessonId++;
+ num++;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson5css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> '+lesson5texts[num]+' </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border orange"></div>');
+ $('#click'+lessonId).append('orange');
+ bindSounds(lessonId);
+ lessonId++;
+ num++;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson5css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> '+lesson5texts[num]+' </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border yellow"></div>');
+ $('#click'+lessonId).append('green ?');
+ bindSounds(lessonId);
+ lessonId++;
+ num++;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson5css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> '+lesson5texts[num]+' </span>');
+ $('#bindImg'+lessonId).append('<span class = "lesson5tree"></span>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo">is</span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border green"></div>');
+ $('#click'+lessonId).append('green');
+ bindSounds(lessonId);
+ lessonId++;
+ num++;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson5css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> '+lesson5texts[num]+' </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border orange"></div>');
+ bindSounds(lessonId);
+ lessonIdNew = lessonId+1;
+ $('#bindImg'+lessonId).append('<span class = "smallclickTextInfo"> in </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonIdNew+'" class="clicktoChange small border yellow"></div>');
+ $('#click'+lessonIdNew).append('November');
+ bindSounds(lessonIdNew);
+
+ assignImagesAbsolute(9,190,600,'orange');
+ assignImagesAbsolute(10,350,320,'tree');
+
+ };
+
+
+ var startLesson4 = function(){
+ var lessonCss = {
+ 'position':'relative',
+ 'margin': '1em 0 0 10em',
+ 'float':'left',
+ 'width': '700px',
+ 'height': '520px',
+ 'text-align':'center'
+ };
+ $('#lesson').html('').css(lessonCss);
+ currentLessonStart = 22;
+ var lessonId = currentLessonStart;
+ $('#lesson').append('<div id="bindImg'+currentLessonStart+'" class="imgBind"></div>');
+ var bindImgCss = {
+ 'position':'relative',
+ 'float':'left',
+ 'width': '500px',
+ 'height':'100px',
+ 'text-align':'center',
+ 'padding-bottom':'1em'
+ };
+ $('#bindImg'+currentLessonStart).css(bindImgCss);
+ for(i = currentLessonStart; i< 25; i++){
+ assignColorBoxes(i);
+ }
+
+ lessonId = 25;
+ num = 0;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson3css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> '+lesson4texts[num]+' </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border yellow"></div>');
+ $('#click'+lessonId).append(sounds[lessonId]);
+ bindSounds(lessonId);
+ lessonId++;
+ num++;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson3css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> '+lesson4texts[num]+' </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border yellow"></div>');
+ $('#click'+lessonId).append(sounds[lessonId]);
+ bindSounds(lessonId);
+ lessonId++;
+ num++;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson3css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> '+lesson4texts[num]+' </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border red "></div>');
+ bindSounds(lessonId);
+ lessonId++;
+ num++;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson3css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> '+lesson4texts[num]+' </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border yellow"></div>');
+ $('#click'+lessonId).append(sounds[lessonId]);
+ bindSounds(lessonId);
+ lessonId++;
+ num++;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson3css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> '+lesson4texts[num]+' </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border yellow"></div>');
+ $('#click'+lessonId).append(sounds[lessonId]);
+ bindSounds(lessonId);
+
+
+ num++;
+ $('#lesson').append('<div id="bindImg120" class="lesson3css"></div>');
+ $('#bindImg120').append('<span class = "clickTextInfo"> '+lesson4texts[num]+' </span>');
+ lessonId++;
+ num++;
+
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson3css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> '+lesson4texts[num]+' </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border yellow"></div>');
+ $('#click'+lessonId).append(sounds[lessonId]);
+ bindSounds(lessonId);
+ lessonId++;
+ num++;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson3css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> '+lesson4texts[num]+' </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border blue"></div>');
+ $('#click'+lessonId);
+ bindSounds(lessonId);
+
+
+ assignImagesAbsolute(4,20,450,'zoo');
+ assignImagesAbsolute(5,135,425,'dead');
+ assignImagesAbsolute(6,180,0,'giraffe');
+ assignImagesAbsolute(7,250,500,'bird');
+ assignImagesAbsolute(8,280,550,'cage');
+
+ };
+
+
+
+ var startLesson3 = function(){
+ var lessonCss = {
+ 'position':'relative',
+ 'margin': '1em 0 0 10em',
+ 'float':'left',
+ 'width': '600px',
+ 'height': '520px',
+ 'text-align':'center'
+ };
+ $('#lesson').css(lessonCss);
+ currentLessonStart = 12;
+ var lessonId = currentLessonStart;
+ $('#lesson').append('<div id="bindImg'+currentLessonStart+'" class="imgBind"></div>');
+ var bindImgCss = {
+ 'position':'relative',
+ 'float':'left',
+ 'width': '500px',
+ 'height':'100px',
+ 'text-align':'center',
+ 'padding-bottom':'1em'
+ };
+ $('#bindImg'+currentLessonStart).css(bindImgCss);
+ for(i = currentLessonStart; i< 15; i++){
+ assignColorBoxes(i);
+ }
+
+
+ lessonId = 15;
+ num = 0;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson3css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> '+lesson3texts[num]+' </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border yellow"></div>');
+ $('#click'+lessonId).append(sounds[lessonId]);
+ bindSounds(lessonId);
+ lessonId++;
+ num++;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson3css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> '+lesson3texts[num]+' </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border purple"></div>');
+ $('#click'+lessonId).append(sounds[lessonId]);
+ bindSounds(lessonId);
+ lessonId++;
+ num++;
+ $('#lesson').append('<div id="bindImg100" class="lesson3css"></div>');
+ $('#bindImg100').append('<span class = "clickTextInfo"> '+lesson3texts[num]+' </span>');
+
+ num++;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson3css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> '+lesson3texts[num]+' </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border brown"></div>');
+ $('#click'+lessonId).append('brown');
+ bindSounds(lessonId);
+ lessonId++;
+ $('#bindImg'+(lessonId-1)).append('<div id = "click'+lessonId+'" class="clicktoChange small border yellow"></div>');
+ $('#click'+lessonId).append('uncle');
+ bindSounds(lessonId);
+ lessonId++;
+ num++;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson3css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> '+lesson3texts[num]+' </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border yellow"></div>');
+ $('#click'+lessonId).append(sounds[lessonId]);
+ bindSounds(lessonId);
+ lessonId++;
+ num++;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson3css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> '+lesson3texts[num]+' </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border green"></div>');
+ $('#click'+lessonId).append('');
+ bindSounds(lessonId);
+ lessonId++;
+ num++;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson3css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> '+lesson3texts[num]+' </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border yellow"></div>');
+ $('#click'+lessonId).append(sounds[lessonId]);
+ bindSounds(lessonId);
+ lessonId++;
+ num++;
+ $('#lesson').append('<div id="bindImg'+lessonId+'" class="lesson3css"></div>');
+ $('#bindImg'+lessonId).append('<span class = "clickTextInfo"> '+lesson3texts[num]+' </span>');
+ $('#bindImg'+lessonId).append('<div id = "click'+lessonId+'" class="clicktoChange small border red"></div>');
+ $('#click'+lessonId).append(sounds[lessonId]);
+ bindSounds(lessonId);
+
+ assignImagesAbsolute(0,75,0,'turtle');
+ assignImagesAbsolute(1,150,500,'brown_uncle');
+ assignImagesAbsolute(2,275,450,'bean');
+ assignImagesAbsolute(3,400,450,'bed');
+
+ };
+
+
+
+ var nextLesson = function(){
+ $('#content').html('').append('<div id="lesson"></div>');
+ if(currentLesson === 2){
+ startLesson3();
+ }
+ if(currentLesson === 3){
+ startLesson4();
+ }
+ if(currentLesson === 4){
+ startLesson5();
+ }
+ if(currentLesson === 5){
+ startLesson6();
+ }
+ if(currentLesson === 6){
+ startLesson7();
+ }
+ if(currentLesson < 2){ // for being same interface for lesson 0 and 1
+ var lessonCss = {
+ 'margin': '1em 0 0 18em',
+ 'float':'left',
+ 'width': '600px',
+ 'height': '520px',
+ 'text-align':'center'
+ };
+ clickId = 0;
+ $('#lesson').css(lessonCss);
+
+ currentLessonStart = 0;
+ for(j = 0; j< currentLesson;j++){
+ currentLessonStart += numLessonClicks[j];
+ if(currentLesson === 0){
+ currentLessonStart = 0;
+ }
+
+ }
+ for(i = 0;i<numLessonClicks[currentLesson];i++){
+ assignLesson(i);
+ }
+ for(i = 0;i<numLessonClicks[currentLesson];i++){
+ if(currentLesson === 0){
+ if(i === 2|| i === 3 || i === 6||i === 7){
+ assignImages(i);
+ }
+ }
+ else{
+ assignImages(i);
+ }
+ }
+ }
+
+ };
+
+ function gameStart(){
+ nextLesson();
+ }
+
+ function game(){
+ $('#linkPrevLesson').hide();
+ currentLesson = 0;
+ gameStart();
+ }
+ $('#linkPrevLesson').hide();
+ currentLesson = 0;
+
+ $('#linkNextLesson').click(function(){
+ currentLesson++;
+ if(currentLesson === 6){
+ $('#linkNextLesson').hide();
+ }
+ else{
+ $('#linkNextLesson').show();
+ $('#linkPrevLesson').show();
+ }
+
+ nextLesson();
+ });
+ $('#linkPrevLesson').click(function(){
+ currentLesson--;
+ if(currentLesson === 0){
+ $('#linkPrevLesson').hide();
+ }
+ else{
+ $('#linkNextLesson').show();
+ $('#linkPrevLesson').show();
+ }
+
+ nextLesson();
+ });
+ $('#linkStart').click(function(){
+ gameStart();
+ });
+
+ $('#linkPlayAgain').click(function(){
+ game();
+ });
+ $('#linkHelp').mouseover(function(){
+ $('#help').slideDown(2000);
+ })
+ .mouseout(function(){
+ $('#help').slideUp(2000);
+
+ });
+
+ }); //end of k.ready
+}); //end of document.read
+
+
diff --git a/examples/lessons/6_English_namesOfColor/js/ui.core.js b/examples/lessons/6_English_namesOfColor/js/ui.core.js
new file mode 100755
index 0000000..5493e0a
--- /dev/null
+++ b/examples/lessons/6_English_namesOfColor/js/ui.core.js
@@ -0,0 +1,519 @@
+/*
+ * jQuery UI 1.7.2
+ *
+ * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * http://docs.jquery.com/UI
+ */
+;jQuery.ui || (function($) {
+
+var _remove = $.fn.remove,
+ isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9);
+
+//Helper functions and ui object
+$.ui = {
+ version: "1.7.2",
+
+ // $.ui.plugin is deprecated. Use the proxy pattern instead.
+ plugin: {
+ add: function(module, option, set) {
+ var proto = $.ui[module].prototype;
+ for(var i in set) {
+ proto.plugins[i] = proto.plugins[i] || [];
+ proto.plugins[i].push([option, set[i]]);
+ }
+ },
+ call: function(instance, name, args) {
+ var set = instance.plugins[name];
+ if(!set || !instance.element[0].parentNode) { return; }
+
+ for (var i = 0; i < set.length; i++) {
+ if (instance.options[set[i][0]]) {
+ set[i][1].apply(instance.element, args);
+ }
+ }
+ }
+ },
+
+ contains: function(a, b) {
+ return document.compareDocumentPosition
+ ? a.compareDocumentPosition(b) & 16
+ : a !== b && a.contains(b);
+ },
+
+ hasScroll: function(el, a) {
+
+ //If overflow is hidden, the element might have extra content, but the user wants to hide it
+ if ($(el).css('overflow') == 'hidden') { return false; }
+
+ var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop',
+ has = false;
+
+ if (el[scroll] > 0) { return true; }
+
+ // TODO: determine which cases actually cause this to happen
+ // if the element doesn't have the scroll set, see if it's possible to
+ // set the scroll
+ el[scroll] = 1;
+ has = (el[scroll] > 0);
+ el[scroll] = 0;
+ return has;
+ },
+
+ isOverAxis: function(x, reference, size) {
+ //Determines when x coordinate is over "b" element axis
+ return (x > reference) && (x < (reference + size));
+ },
+
+ isOver: function(y, x, top, left, height, width) {
+ //Determines when x, y coordinates is over "b" element
+ return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width);
+ },
+
+ keyCode: {
+ BACKSPACE: 8,
+ CAPS_LOCK: 20,
+ COMMA: 188,
+ CONTROL: 17,
+ DELETE: 46,
+ DOWN: 40,
+ END: 35,
+ ENTER: 13,
+ ESCAPE: 27,
+ HOME: 36,
+ INSERT: 45,
+ LEFT: 37,
+ NUMPAD_ADD: 107,
+ NUMPAD_DECIMAL: 110,
+ NUMPAD_DIVIDE: 111,
+ NUMPAD_ENTER: 108,
+ NUMPAD_MULTIPLY: 106,
+ NUMPAD_SUBTRACT: 109,
+ PAGE_DOWN: 34,
+ PAGE_UP: 33,
+ PERIOD: 190,
+ RIGHT: 39,
+ SHIFT: 16,
+ SPACE: 32,
+ TAB: 9,
+ UP: 38
+ }
+};
+
+// WAI-ARIA normalization
+if (isFF2) {
+ var attr = $.attr,
+ removeAttr = $.fn.removeAttr,
+ ariaNS = "http://www.w3.org/2005/07/aaa",
+ ariaState = /^aria-/,
+ ariaRole = /^wairole:/;
+
+ $.attr = function(elem, name, value) {
+ var set = value !== undefined;
+
+ return (name == 'role'
+ ? (set
+ ? attr.call(this, elem, name, "wairole:" + value)
+ : (attr.apply(this, arguments) || "").replace(ariaRole, ""))
+ : (ariaState.test(name)
+ ? (set
+ ? elem.setAttributeNS(ariaNS,
+ name.replace(ariaState, "aaa:"), value)
+ : attr.call(this, elem, name.replace(ariaState, "aaa:")))
+ : attr.apply(this, arguments)));
+ };
+
+ $.fn.removeAttr = function(name) {
+ return (ariaState.test(name)
+ ? this.each(function() {
+ this.removeAttributeNS(ariaNS, name.replace(ariaState, ""));
+ }) : removeAttr.call(this, name));
+ };
+}
+
+//jQuery plugins
+$.fn.extend({
+ remove: function() {
+ // Safari has a native remove event which actually removes DOM elements,
+ // so we have to use triggerHandler instead of trigger (#3037).
+ $("*", this).add(this).each(function() {
+ $(this).triggerHandler("remove");
+ });
+ return _remove.apply(this, arguments );
+ },
+
+ enableSelection: function() {
+ return this
+ .attr('unselectable', 'off')
+ .css('MozUserSelect', '')
+ .unbind('selectstart.ui');
+ },
+
+ disableSelection: function() {
+ return this
+ .attr('unselectable', 'on')
+ .css('MozUserSelect', 'none')
+ .bind('selectstart.ui', function() { return false; });
+ },
+
+ scrollParent: function() {
+ var scrollParent;
+ if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
+ scrollParent = this.parents().filter(function() {
+ return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
+ }).eq(0);
+ } else {
+ scrollParent = this.parents().filter(function() {
+ return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
+ }).eq(0);
+ }
+
+ return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
+ }
+});
+
+
+//Additional selectors
+$.extend($.expr[':'], {
+ data: function(elem, i, match) {
+ return !!$.data(elem, match[3]);
+ },
+
+ focusable: function(element) {
+ var nodeName = element.nodeName.toLowerCase(),
+ tabIndex = $.attr(element, 'tabindex');
+ return (/input|select|textarea|button|object/.test(nodeName)
+ ? !element.disabled
+ : 'a' == nodeName || 'area' == nodeName
+ ? element.href || !isNaN(tabIndex)
+ : !isNaN(tabIndex))
+ // the element and all of its ancestors must be visible
+ // the browser may report that the area is hidden
+ && !$(element)['area' == nodeName ? 'parents' : 'closest'](':hidden').length;
+ },
+
+ tabbable: function(element) {
+ var tabIndex = $.attr(element, 'tabindex');
+ return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(':focusable');
+ }
+});
+
+
+// $.widget is a factory to create jQuery plugins
+// taking some boilerplate code out of the plugin code
+function getter(namespace, plugin, method, args) {
+ function getMethods(type) {
+ var methods = $[namespace][plugin][type] || [];
+ return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods);
+ }
+
+ var methods = getMethods('getter');
+ if (args.length == 1 && typeof args[0] == 'string') {
+ methods = methods.concat(getMethods('getterSetter'));
+ }
+ return ($.inArray(method, methods) != -1);
+}
+
+$.widget = function(name, prototype) {
+ var namespace = name.split(".")[0];
+ name = name.split(".")[1];
+
+ // create plugin method
+ $.fn[name] = function(options) {
+ var isMethodCall = (typeof options == 'string'),
+ args = Array.prototype.slice.call(arguments, 1);
+
+ // prevent calls to internal methods
+ if (isMethodCall && options.substring(0, 1) == '_') {
+ return this;
+ }
+
+ // handle getter methods
+ if (isMethodCall && getter(namespace, name, options, args)) {
+ var instance = $.data(this[0], name);
+ return (instance ? instance[options].apply(instance, args)
+ : undefined);
+ }
+
+ // handle initialization and non-getter methods
+ return this.each(function() {
+ var instance = $.data(this, name);
+
+ // constructor
+ (!instance && !isMethodCall &&
+ $.data(this, name, new $[namespace][name](this, options))._init());
+
+ // method call
+ (instance && isMethodCall && $.isFunction(instance[options]) &&
+ instance[options].apply(instance, args));
+ });
+ };
+
+ // create widget constructor
+ $[namespace] = $[namespace] || {};
+ $[namespace][name] = function(element, options) {
+ var self = this;
+
+ this.namespace = namespace;
+ this.widgetName = name;
+ this.widgetEventPrefix = $[namespace][name].eventPrefix || name;
+ this.widgetBaseClass = namespace + '-' + name;
+
+ this.options = $.extend({},
+ $.widget.defaults,
+ $[namespace][name].defaults,
+ $.metadata && $.metadata.get(element)[name],
+ options);
+
+ this.element = $(element)
+ .bind('setData.' + name, function(event, key, value) {
+ if (event.target == element) {
+ return self._setData(key, value);
+ }
+ })
+ .bind('getData.' + name, function(event, key) {
+ if (event.target == element) {
+ return self._getData(key);
+ }
+ })
+ .bind('remove', function() {
+ return self.destroy();
+ });
+ };
+
+ // add widget prototype
+ $[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype);
+
+ // TODO: merge getter and getterSetter properties from widget prototype
+ // and plugin prototype
+ $[namespace][name].getterSetter = 'option';
+};
+
+$.widget.prototype = {
+ _init: function() {},
+ destroy: function() {
+ this.element.removeData(this.widgetName)
+ .removeClass(this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled')
+ .removeAttr('aria-disabled');
+ },
+
+ option: function(key, value) {
+ var options = key,
+ self = this;
+
+ if (typeof key == "string") {
+ if (value === undefined) {
+ return this._getData(key);
+ }
+ options = {};
+ options[key] = value;
+ }
+
+ $.each(options, function(key, value) {
+ self._setData(key, value);
+ });
+ },
+ _getData: function(key) {
+ return this.options[key];
+ },
+ _setData: function(key, value) {
+ this.options[key] = value;
+
+ if (key == 'disabled') {
+ this.element
+ [value ? 'addClass' : 'removeClass'](
+ this.widgetBaseClass + '-disabled' + ' ' +
+ this.namespace + '-state-disabled')
+ .attr("aria-disabled", value);
+ }
+ },
+
+ enable: function() {
+ this._setData('disabled', false);
+ },
+ disable: function() {
+ this._setData('disabled', true);
+ },
+
+ _trigger: function(type, event, data) {
+ var callback = this.options[type],
+ eventName = (type == this.widgetEventPrefix
+ ? type : this.widgetEventPrefix + type);
+
+ event = $.Event(event);
+ event.type = eventName;
+
+ // copy original event properties over to the new event
+ // this would happen if we could call $.event.fix instead of $.Event
+ // but we don't have a way to force an event to be fixed multiple times
+ if (event.originalEvent) {
+ for (var i = $.event.props.length, prop; i;) {
+ prop = $.event.props[--i];
+ event[prop] = event.originalEvent[prop];
+ }
+ }
+
+ this.element.trigger(event, data);
+
+ return !($.isFunction(callback) && callback.call(this.element[0], event, data) === false
+ || event.isDefaultPrevented());
+ }
+};
+
+$.widget.defaults = {
+ disabled: false
+};
+
+
+/** Mouse Interaction Plugin **/
+
+$.ui.mouse = {
+ _mouseInit: function() {
+ var self = this;
+
+ this.element
+ .bind('mousedown.'+this.widgetName, function(event) {
+ return self._mouseDown(event);
+ })
+ .bind('click.'+this.widgetName, function(event) {
+ if(self._preventClickEvent) {
+ self._preventClickEvent = false;
+ event.stopImmediatePropagation();
+ return false;
+ }
+ });
+
+ // Prevent text selection in IE
+ if ($.browser.msie) {
+ this._mouseUnselectable = this.element.attr('unselectable');
+ this.element.attr('unselectable', 'on');
+ }
+
+ this.started = false;
+ },
+
+ // TODO: make sure destroying one instance of mouse doesn't mess with
+ // other instances of mouse
+ _mouseDestroy: function() {
+ this.element.unbind('.'+this.widgetName);
+
+ // Restore text selection in IE
+ ($.browser.msie
+ && this.element.attr('unselectable', this._mouseUnselectable));
+ },
+
+ _mouseDown: function(event) {
+ // don't let more than one widget handle mouseStart
+ // TODO: figure out why we have to use originalEvent
+ event.originalEvent = event.originalEvent || {};
+ if (event.originalEvent.mouseHandled) { return; }
+
+ // we may have missed mouseup (out of window)
+ (this._mouseStarted && this._mouseUp(event));
+
+ this._mouseDownEvent = event;
+
+ var self = this,
+ btnIsLeft = (event.which == 1),
+ elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false);
+ if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
+ return true;
+ }
+
+ this.mouseDelayMet = !this.options.delay;
+ if (!this.mouseDelayMet) {
+ this._mouseDelayTimer = setTimeout(function() {
+ self.mouseDelayMet = true;
+ }, this.options.delay);
+ }
+
+ if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+ this._mouseStarted = (this._mouseStart(event) !== false);
+ if (!this._mouseStarted) {
+ event.preventDefault();
+ return true;
+ }
+ }
+
+ // these delegates are required to keep context
+ this._mouseMoveDelegate = function(event) {
+ return self._mouseMove(event);
+ };
+ this._mouseUpDelegate = function(event) {
+ return self._mouseUp(event);
+ };
+ $(document)
+ .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
+ .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
+
+ // preventDefault() is used to prevent the selection of text here -
+ // however, in Safari, this causes select boxes not to be selectable
+ // anymore, so this fix is needed
+ ($.browser.safari || event.preventDefault());
+
+ event.originalEvent.mouseHandled = true;
+ return true;
+ },
+
+ _mouseMove: function(event) {
+ // IE mouseup check - mouseup happened when mouse was out of window
+ if ($.browser.msie && !event.button) {
+ return this._mouseUp(event);
+ }
+
+ if (this._mouseStarted) {
+ this._mouseDrag(event);
+ return event.preventDefault();
+ }
+
+ if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+ this._mouseStarted =
+ (this._mouseStart(this._mouseDownEvent, event) !== false);
+ (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
+ }
+
+ return !this._mouseStarted;
+ },
+
+ _mouseUp: function(event) {
+ $(document)
+ .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
+ .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
+
+ if (this._mouseStarted) {
+ this._mouseStarted = false;
+ this._preventClickEvent = (event.target == this._mouseDownEvent.target);
+ this._mouseStop(event);
+ }
+
+ return false;
+ },
+
+ _mouseDistanceMet: function(event) {
+ return (Math.max(
+ Math.abs(this._mouseDownEvent.pageX - event.pageX),
+ Math.abs(this._mouseDownEvent.pageY - event.pageY)
+ ) >= this.options.distance
+ );
+ },
+
+ _mouseDelayMet: function(event) {
+ return this.mouseDelayMet;
+ },
+
+ // These are placeholder methods, to be overriden by extending plugin
+ _mouseStart: function(event) {},
+ _mouseDrag: function(event) {},
+ _mouseStop: function(event) {},
+ _mouseCapture: function(event) { return true; }
+};
+
+$.ui.mouse.defaults = {
+ cancel: null,
+ distance: 1,
+ delay: 0
+};
+
+})(jQuery);
diff --git a/examples/lessons/6_English_oneOrMany/assets/audio/correct.ogg b/examples/lessons/6_English_oneOrMany/assets/audio/correct.ogg
new file mode 100755
index 0000000..a0d9e3a
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/audio/correct.ogg
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/audio/incorrect.ogg b/examples/lessons/6_English_oneOrMany/assets/audio/incorrect.ogg
new file mode 100755
index 0000000..4805e55
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/audio/incorrect.ogg
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/aeroplane.png b/examples/lessons/6_English_oneOrMany/assets/image/aeroplane.png
new file mode 100755
index 0000000..99fd5a2
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/aeroplane.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/backImage.png b/examples/lessons/6_English_oneOrMany/assets/image/backImage.png
new file mode 100755
index 0000000..395650b
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/backImage.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/bag.png b/examples/lessons/6_English_oneOrMany/assets/image/bag.png
new file mode 100755
index 0000000..0c08252
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/bag.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/bear.png b/examples/lessons/6_English_oneOrMany/assets/image/bear.png
new file mode 100755
index 0000000..b8c29e4
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/bear.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/bench.png b/examples/lessons/6_English_oneOrMany/assets/image/bench.png
new file mode 100755
index 0000000..d5a559e
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/bench.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/bg_footer.png b/examples/lessons/6_English_oneOrMany/assets/image/bg_footer.png
new file mode 100755
index 0000000..8982264
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/bg_footer.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/bg_header.png b/examples/lessons/6_English_oneOrMany/assets/image/bg_header.png
new file mode 100755
index 0000000..98213f7
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/bg_header.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/bg_title_block.png b/examples/lessons/6_English_oneOrMany/assets/image/bg_title_block.png
new file mode 100755
index 0000000..2c9dacf
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/bg_title_block.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/boat.png b/examples/lessons/6_English_oneOrMany/assets/image/boat.png
new file mode 100755
index 0000000..09e3154
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/boat.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/book.png b/examples/lessons/6_English_oneOrMany/assets/image/book.png
new file mode 100755
index 0000000..536be2b
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/book.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/brush.png b/examples/lessons/6_English_oneOrMany/assets/image/brush.png
new file mode 100755
index 0000000..ee6e220
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/brush.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/btn_back.png b/examples/lessons/6_English_oneOrMany/assets/image/btn_back.png
new file mode 100755
index 0000000..d9fbf14
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/btn_back.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/btn_back_hover.png b/examples/lessons/6_English_oneOrMany/assets/image/btn_back_hover.png
new file mode 100755
index 0000000..0911fcc
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/btn_back_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/btn_help.png b/examples/lessons/6_English_oneOrMany/assets/image/btn_help.png
new file mode 100755
index 0000000..6753e9c
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/btn_help.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/btn_help_hover.png b/examples/lessons/6_English_oneOrMany/assets/image/btn_help_hover.png
new file mode 100755
index 0000000..d3ccd92
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/btn_help_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/btn_next.png b/examples/lessons/6_English_oneOrMany/assets/image/btn_next.png
new file mode 100755
index 0000000..9d70993
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/btn_next.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/btn_next_hover.png b/examples/lessons/6_English_oneOrMany/assets/image/btn_next_hover.png
new file mode 100755
index 0000000..2cd4d37
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/btn_next_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/btn_ole.png b/examples/lessons/6_English_oneOrMany/assets/image/btn_ole.png
new file mode 100755
index 0000000..0e775e9
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/btn_ole.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/btn_ole_hover.png b/examples/lessons/6_English_oneOrMany/assets/image/btn_ole_hover.png
new file mode 100755
index 0000000..c43c5f7
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/btn_ole_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/btn_play_again.png b/examples/lessons/6_English_oneOrMany/assets/image/btn_play_again.png
new file mode 100755
index 0000000..3594d18
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/btn_play_again.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/btn_play_again_hover.png b/examples/lessons/6_English_oneOrMany/assets/image/btn_play_again_hover.png
new file mode 100755
index 0000000..ebb8f8c
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/btn_play_again_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/btn_play_again_mouse_down.png b/examples/lessons/6_English_oneOrMany/assets/image/btn_play_again_mouse_down.png
new file mode 100755
index 0000000..07d6e45
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/btn_play_again_mouse_down.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/btn_start.png b/examples/lessons/6_English_oneOrMany/assets/image/btn_start.png
new file mode 100755
index 0000000..32e5f20
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/btn_start.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/btn_start_hover.png b/examples/lessons/6_English_oneOrMany/assets/image/btn_start_hover.png
new file mode 100755
index 0000000..811ce78
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/btn_start_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/btn_start_mouse_down.png b/examples/lessons/6_English_oneOrMany/assets/image/btn_start_mouse_down.png
new file mode 100755
index 0000000..5acd43b
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/btn_start_mouse_down.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/bus.png b/examples/lessons/6_English_oneOrMany/assets/image/bus.png
new file mode 100755
index 0000000..e0bcc24
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/bus.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/cart.png b/examples/lessons/6_English_oneOrMany/assets/image/cart.png
new file mode 100755
index 0000000..42998c8
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/cart.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/check.png b/examples/lessons/6_English_oneOrMany/assets/image/check.png
new file mode 100755
index 0000000..84fc229
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/check.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/comma.png b/examples/lessons/6_English_oneOrMany/assets/image/comma.png
new file mode 100755
index 0000000..aa0474e
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/comma.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/correct.png b/examples/lessons/6_English_oneOrMany/assets/image/correct.png
new file mode 100755
index 0000000..ca9b9db
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/correct.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/cycle.png b/examples/lessons/6_English_oneOrMany/assets/image/cycle.png
new file mode 100755
index 0000000..90afbd6
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/cycle.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/desk.png b/examples/lessons/6_English_oneOrMany/assets/image/desk.png
new file mode 100755
index 0000000..2c63613
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/desk.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/dot.png b/examples/lessons/6_English_oneOrMany/assets/image/dot.png
new file mode 100755
index 0000000..74ac1ff
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/dot.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/elephant.png b/examples/lessons/6_English_oneOrMany/assets/image/elephant.png
new file mode 100755
index 0000000..6467a4b
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/elephant.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/help.png b/examples/lessons/6_English_oneOrMany/assets/image/help.png
new file mode 100755
index 0000000..21ae5e0
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/help.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/incorrect.png b/examples/lessons/6_English_oneOrMany/assets/image/incorrect.png
new file mode 100755
index 0000000..49ee2a2
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/incorrect.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/jackel.png b/examples/lessons/6_English_oneOrMany/assets/image/jackel.png
new file mode 100755
index 0000000..88d7463
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/jackel.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/kite.png b/examples/lessons/6_English_oneOrMany/assets/image/kite.png
new file mode 100755
index 0000000..2eb6ded
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/kite.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/ladder.png b/examples/lessons/6_English_oneOrMany/assets/image/ladder.png
new file mode 100755
index 0000000..84f8b9f
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/ladder.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/monkey.png b/examples/lessons/6_English_oneOrMany/assets/image/monkey.png
new file mode 100755
index 0000000..6c8dce0
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/monkey.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/objects.png b/examples/lessons/6_English_oneOrMany/assets/image/objects.png
new file mode 100755
index 0000000..828a1a2
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/objects.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/rhino.png b/examples/lessons/6_English_oneOrMany/assets/image/rhino.png
new file mode 100755
index 0000000..d853865
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/rhino.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/ship.png b/examples/lessons/6_English_oneOrMany/assets/image/ship.png
new file mode 100755
index 0000000..a732c86
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/ship.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/snake.png b/examples/lessons/6_English_oneOrMany/assets/image/snake.png
new file mode 100755
index 0000000..103e9a5
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/snake.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/soap.png b/examples/lessons/6_English_oneOrMany/assets/image/soap.png
new file mode 100755
index 0000000..a7a4826
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/soap.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/tempo.png b/examples/lessons/6_English_oneOrMany/assets/image/tempo.png
new file mode 100755
index 0000000..e823d6a
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/tempo.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/tiger.png b/examples/lessons/6_English_oneOrMany/assets/image/tiger.png
new file mode 100755
index 0000000..4228ecf
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/tiger.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/title_block_lt.png b/examples/lessons/6_English_oneOrMany/assets/image/title_block_lt.png
new file mode 100755
index 0000000..4696182
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/title_block_lt.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/title_block_rt.png b/examples/lessons/6_English_oneOrMany/assets/image/title_block_rt.png
new file mode 100755
index 0000000..37cc44a
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/title_block_rt.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/transportation.png b/examples/lessons/6_English_oneOrMany/assets/image/transportation.png
new file mode 100755
index 0000000..ce0e783
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/transportation.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/truck.png b/examples/lessons/6_English_oneOrMany/assets/image/truck.png
new file mode 100755
index 0000000..6b86748
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/truck.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/turtle.png b/examples/lessons/6_English_oneOrMany/assets/image/turtle.png
new file mode 100755
index 0000000..d679b9b
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/turtle.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/assets/image/wild.png b/examples/lessons/6_English_oneOrMany/assets/image/wild.png
new file mode 100755
index 0000000..a8cc09e
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/assets/image/wild.png
Binary files differ
diff --git a/examples/lessons/6_English_oneOrMany/css/lesson.css b/examples/lessons/6_English_oneOrMany/css/lesson.css
new file mode 100755
index 0000000..240e51e
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/css/lesson.css
@@ -0,0 +1,280 @@
+@CHARSET "UTF-8";
+/****** Page Styles ****/
+
+/* Designed for 1200*900 px screen resolution */
+
+body {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 10pt;
+ margin: 0px;
+ background-color: #FFFFCC;
+}
+#header {
+ background-image: url(../assets/image/bg_header.png);
+ background-repeat: repeat-x;
+ height: 75px;
+ width: 100%;
+ position: absolute;
+ left: 0px;
+ top: 0px;
+}
+#topbtn_left {
+ float: left;
+ height: 60px;
+ width: 60px;
+ padding-top: 6px;
+ padding-left: 15px;
+}
+
+
+ .linkBack{
+ width: 60px; height: 59px;
+ background:url(../assets/image/btn_back.png);
+ }
+ .linkBack:hover{
+ background:url(../assets/image/btn_back_hover.png);
+ }
+
+#lesson_title {
+ float: left;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 16pt;
+ font-weight: bold;
+ color: #FFFFFF;
+ margin-left: 10px;
+ background-image: url(../assets/image/bg_title_block.png);
+}
+#topbtn_right {
+ float: right;
+ height: 60px;
+ width: 60px;
+ padding-top: 6px;
+ padding-right: 15px;
+}
+ #linkHelp{
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_help.png);
+ }
+ #linkHelp:hover{
+ background:url(../assets/image/btn_help_hover.png);
+ }
+ #linkOle{
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_ole.png);
+ }
+ #linkOle:hover{
+ background:url(../assets/image/btn_ole_hover.png);
+ }
+ .linkNext{var bindImgCss = {
+ 'float':'left',
+ 'width': '450px',
+ 'height':'40px',
+ 'margin-top':'0.25em',
+ 'text-align':'center',
+ 'padding-bottom':'0.3em'
+ };
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_next.png);
+ }
+ .linkNext:hover{
+ background:url(../assets/image/btn_next_hover.png);
+ }
+#footer {
+ position:relative;
+ background-image: url(../assets/image/bg_footer.png);
+ background-repeat: repeat-x;
+ height: 75px;
+ width: 100%;
+ left: 0px;
+ bottom: 0px;
+}
+#score_box {
+ float: left;
+ padding-left: 5px;
+ padding-top: 0.7em;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #FFFF00;
+ font-size: 16pt;
+ font-weight: bold;
+}
+#botbtn_right {
+ float: right;
+ height: 55px;
+ padding-right: 5px;
+ padding-top: 10px;
+}
+ #linkCheck{
+ width: 187px; height: 55px;
+ background-image: url(../assets/image/check.png);
+ }
+
+ #linkStart{
+ width: 251px; height: 55px;
+ background:url(../assets/image/btn_start.png);
+ }
+ #linkStart:hover{
+ background:url(../assets/image/btn_start_hover.png);
+ }
+ #linkStart:active{
+ background:url(../assets/image/btn_start_mouse_down.png);
+ }
+ #linkPlayAgain{
+ width: 251px; height: 55px;
+ background:url(../assets/image/btn_play_again.png);
+ }
+ #linkPlayAgain:hover{
+ background:url(../assets/image/btn_play_again_hover.png);
+ }
+ #linkPlayAgain:active{
+ background:url(../assets/image/btn_play_again_mouse_down.png);
+ }
+#linkNextLesson{
+ position:absolute;
+ bottom: 75px;
+ right: 10px;
+}
+#linkPrevLesson{
+ position:absolute;
+ bottom: 75px;
+ left: 10px;
+}
+/**** End of the page style ****/
+
+/**** Game Styles ****/
+
+a{
+ color:#FFFFCC;
+}
+#currentTitle{
+ width: 150px;
+ height: 80xp;
+ font:25px/30px "Courier New", Courier, monospace;
+ font-weight: bold;
+ color: red;
+}
+#content{
+ position:relative;
+ margin: 0 auto;
+ margin-top: 75px;
+ width: 1198px;
+ height: 560px;
+
+}
+ #tabs{
+ margin-left: 0.5em;
+ width: 650px;
+ height: 60px;
+ }
+ .tabBox{
+ float:left;
+ margin: 0.5em;
+ }
+ .tabSelected{
+ background-color: #00FF00;
+ }
+
+ #section{
+ width: 900px;
+ height: 300px;
+ margin: 5px auto;
+ }
+
+ #questionSection{
+ margin-top: 100px;
+ margin-left: 300px;
+ }
+ .questions{
+ margin-top: 5px;
+ margin-left: 20px;
+ height: 35px;
+ font: 30px/35px Verdana, Geneva, Arial, Helvetica, sans-serif;
+ color: #000000;
+ }
+ #answerSection{
+ margin-left: 50px;
+ margin-top: 10px;
+ width: 700px;
+ height: 70px;
+ }
+ #comma{
+ width: 36px;
+ height: 60px;
+ margin-left: 118px;
+ background-image: url(../assets/image/comma.png);
+ }
+ #dot{
+ position:absolute;
+ top: 36%;
+ right: 10%;
+ width: 36px;
+ height: 60px;
+ background-image: url(../assets/image/dot.png);
+ }
+ #dragAnswers{
+ padding: 10px;
+ margin-top: 40px;
+ margin-left: 0px;
+ width:700px;
+ height: 30px;
+ border: 2px solid #ABF549;
+ text-align:center;
+
+ }
+ #imgAnimals{
+ position:absolute;
+ left: 10%;
+ top: 30%;
+ width: 222px;
+ height: 300px;
+ background: url(../assets/image/backImage.png);
+ text-align:center;
+ }
+ .imgAnim{
+ margin-top: 100px;
+ }
+
+ .drophover{
+ background-color: #FF9900;
+ }
+ #checkAnswer{
+ position:absolute;
+ right: 1%;
+ bottom: 47%;
+ width: 100px;
+ height: 92px;
+ }
+
+ #help{
+ display:none;
+ position:absolute;
+ right: 60px;
+ top: 75px;;
+ width: 256px;
+ height: 600px;
+ background:url(../assets/image/help.png);
+ z-index:40;
+}
+
+#gameOver{
+ margin: 10px auto;
+ width: 500px;
+ text-align:center;
+ font: 30px/35px Verdana, Geneva, Arial, Helvetica, sans-serif;
+ font-weight:bold;
+ color:red;
+}
+#gameOverInfo{
+ margin-top: 35px;
+ text-align:center;
+ font: 20px/25px Helvetica, Geneva, Arial, Verdana, sans-serif;
+ font-weight:bold;
+ color:#06D946;
+
+}
+.specialText{
+ font: 20px/25px Helvetica, Geneva, Arial, Verdana, sans-serif;
+ font-weight:bold;
+ color:#FF9900;
+ border-bottom: 2px dotted #CCC;
+
+} \ No newline at end of file
diff --git a/examples/lessons/6_English_oneOrMany/css/ui.scoreboard.css b/examples/lessons/6_English_oneOrMany/css/ui.scoreboard.css
new file mode 100755
index 0000000..11cdbb5
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/css/ui.scoreboard.css
@@ -0,0 +1,62 @@
+.ui-scoreboard-container-h{
+max-width: 800em;
+max-height: 200px;
+float:left;
+padding-top:0.4em;
+padding-bottom:0.4em;
+}
+
+.ui-scoreboard-spacing-h{
+max-width: 200em;
+max-height: 300em;
+display:inline;
+margin-left:0.2em;
+margin-right:0.4em;
+}
+
+.ui-scoreboard-text{
+font-size:larger;
+text-align: center;
+}
+
+.ui-scoreboard-number-h {
+background-color:black;
+color: white;
+padding-left:0.4em;
+padding-right:0.4em;
+font-size:larger;
+}
+
+.ui-scoreboard-button{
+float:right;
+cursor:pointer;
+}
+
+button .ui-scoreboard-icon{
+float: left;
+margin-right:0.3em;
+}
+.ui-scoreboard-container-v{
+max-width: 200px;
+max-height: 400px;
+float:left;
+padding-top:0.4em;
+padding-bottom:0.4em;
+}
+.ui-scoreboard-spacing-v{
+display:block;
+margin: 0.4em;
+}
+
+.ui-scoreboard-number-v{
+background-color:black;
+color: white;
+width: 1em;
+text-align:center;
+margin-left:auto;
+margin-right: auto;
+padding:0.4em;
+font-size:larger;
+}
+
+
diff --git a/examples/lessons/6_English_oneOrMany/index.html b/examples/lessons/6_English_oneOrMany/index.html
new file mode 100755
index 0000000..7068eb2
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/index.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<head>
+ <title>Class 6 English One or Many</title>
+ <meta name="keywords" content="karma,javascript,html5,sugar,sugarlabs,gsoc,ole,nepal" />
+ <link type="text/css" rel="stylesheet" href="css/lesson.css" />
+ <link type="text/css" rel="stylesheet" href="css/ui.scoreboard.css" />
+ <link type="text/css" rel="stylesheet" href="css/demos.css" />
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <link type="image/ico" rel="icon" href="../../assets/default/image/favicon.ico" />
+ <script type="text/javascript" src="js/jquery-1.4.js"></script>
+ <script type="text/javascript" src="js/ui.core.js"></script>
+ <script type="text/javascript" src="js/ui.draggable.js"></script>
+ <script type="text/javascript" src="js/ui.droppable.js"></script>
+ <script type="text/javascript" src="js/karma.js"></script>
+ <script type="text/javascript" src="js/ui.scoreboard.js"></script>
+ <script type="text/javascript" src="js/lesson.js"></script>
+</head>
+<body>
+ <div id="header">
+ <div id="topbtn_left"><a href="#"><div id="linkBackLesson" class="linkBack"></div></a></div>
+ <div id="lesson_title">
+ <img src="assets/image/title_block_lt.png" width="33" height="75" align="absmiddle" />
+ English One or Many<span id="currentTitle"></span>
+ <img src="assets/image/title_block_rt.png" width="33" height="75" align="absmiddle" />
+ </div>
+ <div id="topbtn_right"><a href="#"><div id="linkHelp"></div></a></div>
+ <div id="topbtn_right"><a href="http://olenepal.org"><div id="linkOle"></div></a></div>
+ </div>
+
+ <div id="content">
+ <div id="tabs"></div>
+ <div id="section"></div>
+ <div id="checkAnswer"></div>
+ <div id="displayImgArea"></div>
+ <div id="gameOver"></div>
+ </div>
+ <div id="help"></div>
+ <form name="delayForm">
+ <input type="hidden" name="delayval" size="5">
+ </form>
+
+ <div id="footer">
+ <div id="score_box"></div>
+ <div id="botbtn_right"><a href="#"><div id="linkPlayAgain"></div></a></div>
+ <div id="botbtn_right"><a href="#"><div id="linkStart"></div></a></div>
+ <div id="botbtn_right"><a href="#"><div id="linkCheck"></div></a></div>
+ </div>
+</body>
+</html>
diff --git a/examples/lessons/6_English_oneOrMany/js/jquery-1.4.js b/examples/lessons/6_English_oneOrMany/js/jquery-1.4.js
new file mode 100755
index 0000000..a448490
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/js/jquery-1.4.js
@@ -0,0 +1,5999 @@
+/*!
+ * jQuery JavaScript Library v1.4
+ * http://jquery.com/
+ *
+ * Copyright 2010, John Resig
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://docs.jquery.com/License
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ * Copyright 2010, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ *
+ * Date: Wed Jan 13 15:23:05 2010 -0500
+ */
+(function( window, undefined ) {
+
+// Define a local copy of jQuery
+var jQuery = function( selector, context ) {
+ // The jQuery object is actually just the init constructor 'enhanced'
+ return new jQuery.fn.init( selector, context );
+ },
+
+ // Map over jQuery in case of overwrite
+ _jQuery = window.jQuery,
+
+ // Map over the $ in case of overwrite
+ _$ = window.$,
+
+ // Use the correct document accordingly with window argument (sandbox)
+ document = window.document,
+
+ // A central reference to the root jQuery(document)
+ rootjQuery,
+
+ // A simple way to check for HTML strings or ID strings
+ // (both of which we optimize for)
+ quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,
+
+ // Is it a simple selector
+ isSimple = /^.[^:#\[\.,]*$/,
+
+ // Check if a string has a non-whitespace character in it
+ rnotwhite = /\S/,
+
+ // Used for trimming whitespace
+ rtrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g,
+
+ // Match a standalone tag
+ rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
+
+ // Keep a UserAgent string for use with jQuery.browser
+ userAgent = navigator.userAgent,
+
+ // For matching the engine and version of the browser
+ browserMatch,
+
+ // Has the ready events already been bound?
+ readyBound = false,
+
+ // The functions to execute on DOM ready
+ readyList = [],
+
+ // The ready event handler
+ DOMContentLoaded,
+
+ // Save a reference to some core methods
+ toString = Object.prototype.toString,
+ hasOwnProperty = Object.prototype.hasOwnProperty,
+ push = Array.prototype.push,
+ slice = Array.prototype.slice,
+ indexOf = Array.prototype.indexOf;
+
+jQuery.fn = jQuery.prototype = {
+ init: function( selector, context ) {
+ var match, elem, ret, doc;
+
+ // Handle $(""), $(null), or $(undefined)
+ if ( !selector ) {
+ return this;
+ }
+
+ // Handle $(DOMElement)
+ if ( selector.nodeType ) {
+ this.context = this[0] = selector;
+ this.length = 1;
+ return this;
+ }
+
+ // Handle HTML strings
+ if ( typeof selector === "string" ) {
+ // Are we dealing with HTML string or an ID?
+ match = quickExpr.exec( selector );
+
+ // Verify a match, and that no context was specified for #id
+ if ( match && (match[1] || !context) ) {
+
+ // HANDLE: $(html) -> $(array)
+ if ( match[1] ) {
+ doc = (context ? context.ownerDocument || context : document);
+
+ // If a single string is passed in and it's a single tag
+ // just do a createElement and skip the rest
+ ret = rsingleTag.exec( selector );
+
+ if ( ret ) {
+ if ( jQuery.isPlainObject( context ) ) {
+ selector = [ document.createElement( ret[1] ) ];
+ jQuery.fn.attr.call( selector, context, true );
+
+ } else {
+ selector = [ doc.createElement( ret[1] ) ];
+ }
+
+ } else {
+ ret = buildFragment( [ match[1] ], [ doc ] );
+ selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
+ }
+
+ // HANDLE: $("#id")
+ } else {
+ elem = document.getElementById( match[2] );
+
+ if ( elem ) {
+ // Handle the case where IE and Opera return items
+ // by name instead of ID
+ if ( elem.id !== match[2] ) {
+ return rootjQuery.find( selector );
+ }
+
+ // Otherwise, we inject the element directly into the jQuery object
+ this.length = 1;
+ this[0] = elem;
+ }
+
+ this.context = document;
+ this.selector = selector;
+ return this;
+ }
+
+ // HANDLE: $("TAG")
+ } else if ( !context && /^\w+$/.test( selector ) ) {
+ this.selector = selector;
+ this.context = document;
+ selector = document.getElementsByTagName( selector );
+
+ // HANDLE: $(expr, $(...))
+ } else if ( !context || context.jquery ) {
+ return (context || rootjQuery).find( selector );
+
+ // HANDLE: $(expr, context)
+ // (which is just equivalent to: $(context).find(expr)
+ } else {
+ return jQuery( context ).find( selector );
+ }
+
+ // HANDLE: $(function)
+ // Shortcut for document ready
+ } else if ( jQuery.isFunction( selector ) ) {
+ return rootjQuery.ready( selector );
+ }
+
+ if (selector.selector !== undefined) {
+ this.selector = selector.selector;
+ this.context = selector.context;
+ }
+
+ return jQuery.isArray( selector ) ?
+ this.setArray( selector ) :
+ jQuery.makeArray( selector, this );
+ },
+
+ // Start with an empty selector
+ selector: "",
+
+ // The current version of jQuery being used
+ jquery: "1.4",
+
+ // The default length of a jQuery object is 0
+ length: 0,
+
+ // The number of elements contained in the matched element set
+ size: function() {
+ return this.length;
+ },
+
+ toArray: function() {
+ return slice.call( this, 0 );
+ },
+
+ // Get the Nth element in the matched element set OR
+ // Get the whole matched element set as a clean array
+ get: function( num ) {
+ return num == null ?
+
+ // Return a 'clean' array
+ this.toArray() :
+
+ // Return just the object
+ ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
+ },
+
+ // Take an array of elements and push it onto the stack
+ // (returning the new matched element set)
+ pushStack: function( elems, name, selector ) {
+ // Build a new jQuery matched element set
+ var ret = jQuery( elems || null );
+
+ // Add the old object onto the stack (as a reference)
+ ret.prevObject = this;
+
+ ret.context = this.context;
+
+ if ( name === "find" ) {
+ ret.selector = this.selector + (this.selector ? " " : "") + selector;
+ } else if ( name ) {
+ ret.selector = this.selector + "." + name + "(" + selector + ")";
+ }
+
+ // Return the newly-formed element set
+ return ret;
+ },
+
+ // Force the current matched set of elements to become
+ // the specified array of elements (destroying the stack in the process)
+ // You should use pushStack() in order to do this, but maintain the stack
+ setArray: function( elems ) {
+ // Resetting the length to 0, then using the native Array push
+ // is a super-fast way to populate an object with array-like properties
+ this.length = 0;
+ push.apply( this, elems );
+
+ return this;
+ },
+
+ // Execute a callback for every element in the matched set.
+ // (You can seed the arguments with an array of args, but this is
+ // only used internally.)
+ each: function( callback, args ) {
+ return jQuery.each( this, callback, args );
+ },
+
+ ready: function( fn ) {
+ // Attach the listeners
+ jQuery.bindReady();
+
+ // If the DOM is already ready
+ if ( jQuery.isReady ) {
+ // Execute the function immediately
+ fn.call( document, jQuery );
+
+ // Otherwise, remember the function for later
+ } else if ( readyList ) {
+ // Add the function to the wait list
+ readyList.push( fn );
+ }
+
+ return this;
+ },
+
+ eq: function( i ) {
+ return i === -1 ?
+ this.slice( i ) :
+ this.slice( i, +i + 1 );
+ },
+
+ first: function() {
+ return this.eq( 0 );
+ },
+
+ last: function() {
+ return this.eq( -1 );
+ },
+
+ slice: function() {
+ return this.pushStack( slice.apply( this, arguments ),
+ "slice", slice.call(arguments).join(",") );
+ },
+
+ map: function( callback ) {
+ return this.pushStack( jQuery.map(this, function( elem, i ) {
+ return callback.call( elem, i, elem );
+ }));
+ },
+
+ end: function() {
+ return this.prevObject || jQuery(null);
+ },
+
+ // For internal use only.
+ // Behaves like an Array's method, not like a jQuery method.
+ push: push,
+ sort: [].sort,
+ splice: [].splice
+};
+
+// Give the init function the jQuery prototype for later instantiation
+jQuery.fn.init.prototype = jQuery.fn;
+
+jQuery.extend = jQuery.fn.extend = function() {
+ // copy reference to target object
+ var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy;
+
+ // Handle a deep copy situation
+ if ( typeof target === "boolean" ) {
+ deep = target;
+ target = arguments[1] || {};
+ // skip the boolean and the target
+ i = 2;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
+ target = {};
+ }
+
+ // extend jQuery itself if only one argument is passed
+ if ( length === i ) {
+ target = this;
+ --i;
+ }
+
+ for ( ; i < length; i++ ) {
+ // Only deal with non-null/undefined values
+ if ( (options = arguments[ i ]) != null ) {
+ // Extend the base object
+ for ( name in options ) {
+ src = target[ name ];
+ copy = options[ name ];
+
+ // Prevent never-ending loop
+ if ( target === copy ) {
+ continue;
+ }
+
+ // Recurse if we're merging object literal values or arrays
+ if ( deep && copy && ( jQuery.isPlainObject(copy) || jQuery.isArray(copy) ) ) {
+ var clone = src && ( jQuery.isPlainObject(src) || jQuery.isArray(src) ) ? src
+ : jQuery.isArray(copy) ? [] : {};
+
+ // Never move original objects, clone them
+ target[ name ] = jQuery.extend( deep, clone, copy );
+
+ // Don't bring in undefined values
+ } else if ( copy !== undefined ) {
+ target[ name ] = copy;
+ }
+ }
+ }
+ }
+
+ // Return the modified object
+ return target;
+};
+
+jQuery.extend({
+ noConflict: function( deep ) {
+ window.$ = _$;
+
+ if ( deep ) {
+ window.jQuery = _jQuery;
+ }
+
+ return jQuery;
+ },
+
+ // Is the DOM ready to be used? Set to true once it occurs.
+ isReady: false,
+
+ // Handle when the DOM is ready
+ ready: function() {
+ // Make sure that the DOM is not already loaded
+ if ( !jQuery.isReady ) {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( !document.body ) {
+ return setTimeout( jQuery.ready, 13 );
+ }
+
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If there are functions bound, to execute
+ if ( readyList ) {
+ // Execute all of them
+ var fn, i = 0;
+ while ( (fn = readyList[ i++ ]) ) {
+ fn.call( document, jQuery );
+ }
+
+ // Reset the list of functions
+ readyList = null;
+ }
+
+ // Trigger any bound ready events
+ if ( jQuery.fn.triggerHandler ) {
+ jQuery( document ).triggerHandler( "ready" );
+ }
+ }
+ },
+
+ bindReady: function() {
+ if ( readyBound ) {
+ return;
+ }
+
+ readyBound = true;
+
+ // Catch cases where $(document).ready() is called after the
+ // browser event has already occurred.
+ if ( document.readyState === "complete" ) {
+ return jQuery.ready();
+ }
+
+ // Mozilla, Opera and webkit nightlies currently support this event
+ if ( document.addEventListener ) {
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+
+ // A fallback to window.onload, that will always work
+ window.addEventListener( "load", jQuery.ready, false );
+
+ // If IE event model is used
+ } else if ( document.attachEvent ) {
+ // ensure firing before onload,
+ // maybe late but safe also for iframes
+ document.attachEvent("onreadystatechange", DOMContentLoaded);
+
+ // A fallback to window.onload, that will always work
+ window.attachEvent( "onload", jQuery.ready );
+
+ // If IE and not a frame
+ // continually check to see if the document is ready
+ var toplevel = false;
+
+ try {
+ toplevel = window.frameElement == null;
+ } catch(e) {}
+
+ if ( document.documentElement.doScroll && toplevel ) {
+ doScrollCheck();
+ }
+ }
+ },
+
+ // See test/unit/core.js for details concerning isFunction.
+ // Since version 1.3, DOM methods and functions like alert
+ // aren't supported. They return false on IE (#2968).
+ isFunction: function( obj ) {
+ return toString.call(obj) === "[object Function]";
+ },
+
+ isArray: function( obj ) {
+ return toString.call(obj) === "[object Array]";
+ },
+
+ isPlainObject: function( obj ) {
+ // Must be an Object.
+ // Because of IE, we also have to check the presence of the constructor property.
+ // Make sure that DOM nodes and window objects don't pass through, as well
+ if ( !obj || toString.call(obj) !== "[object Object]" || obj.nodeType || obj.setInterval ) {
+ return false;
+ }
+
+ // Not own constructor property must be Object
+ if ( obj.constructor
+ && !hasOwnProperty.call(obj, "constructor")
+ && !hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf") ) {
+ return false;
+ }
+
+ // Own properties are enumerated firstly, so to speed up,
+ // if last one is own, then all properties are own.
+
+ var key;
+ for ( key in obj ) {}
+
+ return key === undefined || hasOwnProperty.call( obj, key );
+ },
+
+ isEmptyObject: function( obj ) {
+ for ( var name in obj ) {
+ return false;
+ }
+ return true;
+ },
+
+ noop: function() {},
+
+ // Evalulates a script in a global context
+ globalEval: function( data ) {
+ if ( data && rnotwhite.test(data) ) {
+ // Inspired by code by Andrea Giammarchi
+ // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
+ var head = document.getElementsByTagName("head")[0] || document.documentElement,
+ script = document.createElement("script");
+
+ script.type = "text/javascript";
+
+ if ( jQuery.support.scriptEval ) {
+ script.appendChild( document.createTextNode( data ) );
+ } else {
+ script.text = data;
+ }
+
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709).
+ head.insertBefore( script, head.firstChild );
+ head.removeChild( script );
+ }
+ },
+
+ nodeName: function( elem, name ) {
+ return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
+ },
+
+ // args is for internal usage only
+ each: function( object, callback, args ) {
+ var name, i = 0,
+ length = object.length,
+ isObj = length === undefined || jQuery.isFunction(object);
+
+ if ( args ) {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.apply( object[ name ], args ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( ; i < length; ) {
+ if ( callback.apply( object[ i++ ], args ) === false ) {
+ break;
+ }
+ }
+ }
+
+ // A special, fast, case for the most common use of each
+ } else {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( var value = object[0];
+ i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
+ }
+ }
+
+ return object;
+ },
+
+ trim: function( text ) {
+ return (text || "").replace( rtrim, "" );
+ },
+
+ // results is for internal usage only
+ makeArray: function( array, results ) {
+ var ret = results || [];
+
+ if ( array != null ) {
+ // The window, strings (and functions) also have 'length'
+ // The extra typeof function check is to prevent crashes
+ // in Safari 2 (See: #3039)
+ if ( array.length == null || typeof array === "string" || jQuery.isFunction(array) || (typeof array !== "function" && array.setInterval) ) {
+ push.call( ret, array );
+ } else {
+ jQuery.merge( ret, array );
+ }
+ }
+
+ return ret;
+ },
+
+ inArray: function( elem, array ) {
+ if ( array.indexOf ) {
+ return array.indexOf( elem );
+ }
+
+ for ( var i = 0, length = array.length; i < length; i++ ) {
+ if ( array[ i ] === elem ) {
+ return i;
+ }
+ }
+
+ return -1;
+ },
+
+ merge: function( first, second ) {
+ var i = first.length, j = 0;
+
+ if ( typeof second.length === "number" ) {
+ for ( var l = second.length; j < l; j++ ) {
+ first[ i++ ] = second[ j ];
+ }
+ } else {
+ while ( second[j] !== undefined ) {
+ first[ i++ ] = second[ j++ ];
+ }
+ }
+
+ first.length = i;
+
+ return first;
+ },
+
+ grep: function( elems, callback, inv ) {
+ var ret = [];
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ if ( !inv !== !callback( elems[ i ], i ) ) {
+ ret.push( elems[ i ] );
+ }
+ }
+
+ return ret;
+ },
+
+ // arg is for internal usage only
+ map: function( elems, callback, arg ) {
+ var ret = [], value;
+
+ // Go through the array, translating each of the items to their
+ // new value (or values).
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ value = callback( elems[ i ], i, arg );
+
+ if ( value != null ) {
+ ret[ ret.length ] = value;
+ }
+ }
+
+ return ret.concat.apply( [], ret );
+ },
+
+ // A global GUID counter for objects
+ guid: 1,
+
+ proxy: function( fn, proxy, thisObject ) {
+ if ( arguments.length === 2 ) {
+ if ( typeof proxy === "string" ) {
+ thisObject = fn;
+ fn = thisObject[ proxy ];
+ proxy = undefined;
+
+ } else if ( proxy && !jQuery.isFunction( proxy ) ) {
+ thisObject = proxy;
+ proxy = undefined;
+ }
+ }
+
+ if ( !proxy && fn ) {
+ proxy = function() {
+ return fn.apply( thisObject || this, arguments );
+ };
+ }
+
+ // Set the guid of unique handler to the same of original handler, so it can be removed
+ if ( fn ) {
+ proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
+ }
+
+ // So proxy can be declared as an argument
+ return proxy;
+ },
+
+ // Use of jQuery.browser is frowned upon.
+ // More details: http://docs.jquery.com/Utilities/jQuery.browser
+ uaMatch: function( ua ) {
+ var ret = { browser: "" };
+
+ ua = ua.toLowerCase();
+
+ if ( /webkit/.test( ua ) ) {
+ ret = { browser: "webkit", version: /webkit[\/ ]([\w.]+)/ };
+
+ } else if ( /opera/.test( ua ) ) {
+ ret = { browser: "opera", version: /version/.test( ua ) ? /version[\/ ]([\w.]+)/ : /opera[\/ ]([\w.]+)/ };
+
+ } else if ( /msie/.test( ua ) ) {
+ ret = { browser: "msie", version: /msie ([\w.]+)/ };
+
+ } else if ( /mozilla/.test( ua ) && !/compatible/.test( ua ) ) {
+ ret = { browser: "mozilla", version: /rv:([\w.]+)/ };
+ }
+
+ ret.version = (ret.version && ret.version.exec( ua ) || [0, "0"])[1];
+
+ return ret;
+ },
+
+ browser: {}
+});
+
+browserMatch = jQuery.uaMatch( userAgent );
+if ( browserMatch.browser ) {
+ jQuery.browser[ browserMatch.browser ] = true;
+ jQuery.browser.version = browserMatch.version;
+}
+
+// Deprecated, use jQuery.browser.webkit instead
+if ( jQuery.browser.webkit ) {
+ jQuery.browser.safari = true;
+}
+
+if ( indexOf ) {
+ jQuery.inArray = function( elem, array ) {
+ return indexOf.call( array, elem );
+ };
+}
+
+// All jQuery objects should point back to these
+rootjQuery = jQuery(document);
+
+// Cleanup functions for the document ready method
+if ( document.addEventListener ) {
+ DOMContentLoaded = function() {
+ document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+ jQuery.ready();
+ };
+
+} else if ( document.attachEvent ) {
+ DOMContentLoaded = function() {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( document.readyState === "complete" ) {
+ document.detachEvent( "onreadystatechange", DOMContentLoaded );
+ jQuery.ready();
+ }
+ };
+}
+
+// The DOM ready check for Internet Explorer
+function doScrollCheck() {
+ if ( jQuery.isReady ) {
+ return;
+ }
+
+ try {
+ // If IE is used, use the trick by Diego Perini
+ // http://javascript.nwbox.com/IEContentLoaded/
+ document.documentElement.doScroll("left");
+ } catch( error ) {
+ setTimeout( doScrollCheck, 1 );
+ return;
+ }
+
+ // and execute any waiting functions
+ jQuery.ready();
+}
+
+if ( indexOf ) {
+ jQuery.inArray = function( elem, array ) {
+ return indexOf.call( array, elem );
+ };
+}
+
+function evalScript( i, elem ) {
+ if ( elem.src ) {
+ jQuery.ajax({
+ url: elem.src,
+ async: false,
+ dataType: "script"
+ });
+ } else {
+ jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
+ }
+
+ if ( elem.parentNode ) {
+ elem.parentNode.removeChild( elem );
+ }
+}
+
+// Mutifunctional method to get and set values to a collection
+// The value/s can be optionally by executed if its a function
+function access( elems, key, value, exec, fn, pass ) {
+ var length = elems.length;
+
+ // Setting many attributes
+ if ( typeof key === "object" ) {
+ for ( var k in key ) {
+ access( elems, k, key[k], exec, fn, value );
+ }
+ return elems;
+ }
+
+ // Setting one attribute
+ if ( value !== undefined ) {
+ // Optionally, function values get executed if exec is true
+ exec = !pass && exec && jQuery.isFunction(value);
+
+ for ( var i = 0; i < length; i++ ) {
+ fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
+ }
+
+ return elems;
+ }
+
+ // Getting an attribute
+ return length ? fn( elems[0], key ) : null;
+}
+
+function now() {
+ return (new Date).getTime();
+}
+(function() {
+
+ jQuery.support = {};
+
+ var root = document.documentElement,
+ script = document.createElement("script"),
+ div = document.createElement("div"),
+ id = "script" + now();
+
+ div.style.display = "none";
+ div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
+
+ var all = div.getElementsByTagName("*"),
+ a = div.getElementsByTagName("a")[0];
+
+ // Can't get basic test support
+ if ( !all || !all.length || !a ) {
+ return;
+ }
+
+ jQuery.support = {
+ // IE strips leading whitespace when .innerHTML is used
+ leadingWhitespace: div.firstChild.nodeType === 3,
+
+ // Make sure that tbody elements aren't automatically inserted
+ // IE will insert them into empty tables
+ tbody: !div.getElementsByTagName("tbody").length,
+
+ // Make sure that link elements get serialized correctly by innerHTML
+ // This requires a wrapper element in IE
+ htmlSerialize: !!div.getElementsByTagName("link").length,
+
+ // Get the style information from getAttribute
+ // (IE uses .cssText insted)
+ style: /red/.test( a.getAttribute("style") ),
+
+ // Make sure that URLs aren't manipulated
+ // (IE normalizes it by default)
+ hrefNormalized: a.getAttribute("href") === "/a",
+
+ // Make sure that element opacity exists
+ // (IE uses filter instead)
+ // Use a regex to work around a WebKit issue. See #5145
+ opacity: /^0.55$/.test( a.style.opacity ),
+
+ // Verify style float existence
+ // (IE uses styleFloat instead of cssFloat)
+ cssFloat: !!a.style.cssFloat,
+
+ // Make sure that if no value is specified for a checkbox
+ // that it defaults to "on".
+ // (WebKit defaults to "" instead)
+ checkOn: div.getElementsByTagName("input")[0].value === "on",
+
+ // Make sure that a selected-by-default option has a working selected property.
+ // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
+ optSelected: document.createElement("select").appendChild( document.createElement("option") ).selected,
+
+ // Will be defined later
+ scriptEval: false,
+ noCloneEvent: true,
+ boxModel: null
+ };
+
+ script.type = "text/javascript";
+ try {
+ script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
+ } catch(e) {}
+
+ root.insertBefore( script, root.firstChild );
+
+ // Make sure that the execution of code works by injecting a script
+ // tag with appendChild/createTextNode
+ // (IE doesn't support this, fails, and uses .text instead)
+ if ( window[ id ] ) {
+ jQuery.support.scriptEval = true;
+ delete window[ id ];
+ }
+
+ root.removeChild( script );
+
+ if ( div.attachEvent && div.fireEvent ) {
+ div.attachEvent("onclick", function click() {
+ // Cloning a node shouldn't copy over any
+ // bound event handlers (IE does this)
+ jQuery.support.noCloneEvent = false;
+ div.detachEvent("onclick", click);
+ });
+ div.cloneNode(true).fireEvent("onclick");
+ }
+
+ // Figure out if the W3C box model works as expected
+ // document.body must exist before we can do this
+ // TODO: This timeout is temporary until I move ready into core.js.
+ jQuery(function() {
+ var div = document.createElement("div");
+ div.style.width = div.style.paddingLeft = "1px";
+
+ document.body.appendChild( div );
+ jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
+ document.body.removeChild( div ).style.display = 'none';
+ div = null;
+ });
+
+ // Technique from Juriy Zaytsev
+ // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
+ var eventSupported = function( eventName ) {
+ var el = document.createElement("div");
+ eventName = "on" + eventName;
+
+ var isSupported = (eventName in el);
+ if ( !isSupported ) {
+ el.setAttribute(eventName, "return;");
+ isSupported = typeof el[eventName] === "function";
+ }
+ el = null;
+
+ return isSupported;
+ };
+
+ jQuery.support.submitBubbles = eventSupported("submit");
+ jQuery.support.changeBubbles = eventSupported("change");
+
+ // release memory in IE
+ root = script = div = all = a = null;
+})();
+
+jQuery.props = {
+ "for": "htmlFor",
+ "class": "className",
+ readonly: "readOnly",
+ maxlength: "maxLength",
+ cellspacing: "cellSpacing",
+ rowspan: "rowSpan",
+ colspan: "colSpan",
+ tabindex: "tabIndex",
+ usemap: "useMap",
+ frameborder: "frameBorder"
+};
+var expando = "jQuery" + now(), uuid = 0, windowData = {};
+var emptyObject = {};
+
+jQuery.extend({
+ cache: {},
+
+ expando:expando,
+
+ // The following elements throw uncatchable exceptions if you
+ // attempt to add expando properties to them.
+ noData: {
+ "embed": true,
+ "object": true,
+ "applet": true
+ },
+
+ data: function( elem, name, data ) {
+ if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
+ return;
+ }
+
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var id = elem[ expando ], cache = jQuery.cache, thisCache;
+
+ // Handle the case where there's no name immediately
+ if ( !name && !id ) {
+ return null;
+ }
+
+ // Compute a unique ID for the element
+ if ( !id ) {
+ id = ++uuid;
+ }
+
+ // Avoid generating a new cache unless none exists and we
+ // want to manipulate it.
+ if ( typeof name === "object" ) {
+ elem[ expando ] = id;
+ thisCache = cache[ id ] = jQuery.extend(true, {}, name);
+ } else if ( cache[ id ] ) {
+ thisCache = cache[ id ];
+ } else if ( typeof data === "undefined" ) {
+ thisCache = emptyObject;
+ } else {
+ thisCache = cache[ id ] = {};
+ }
+
+ // Prevent overriding the named cache with undefined values
+ if ( data !== undefined ) {
+ elem[ expando ] = id;
+ thisCache[ name ] = data;
+ }
+
+ return typeof name === "string" ? thisCache[ name ] : thisCache;
+ },
+
+ removeData: function( elem, name ) {
+ if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
+ return;
+ }
+
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ];
+
+ // If we want to remove a specific section of the element's data
+ if ( name ) {
+ if ( thisCache ) {
+ // Remove the section of cache data
+ delete thisCache[ name ];
+
+ // If we've removed all the data, remove the element's cache
+ if ( jQuery.isEmptyObject(thisCache) ) {
+ jQuery.removeData( elem );
+ }
+ }
+
+ // Otherwise, we want to remove all of the element's data
+ } else {
+ // Clean up the element expando
+ try {
+ delete elem[ expando ];
+ } catch( e ) {
+ // IE has trouble directly removing the expando
+ // but it's ok with using removeAttribute
+ if ( elem.removeAttribute ) {
+ elem.removeAttribute( expando );
+ }
+ }
+
+ // Completely remove the data cache
+ delete cache[ id ];
+ }
+ }
+});
+
+jQuery.fn.extend({
+ data: function( key, value ) {
+ if ( typeof key === "undefined" && this.length ) {
+ return jQuery.data( this[0] );
+
+ } else if ( typeof key === "object" ) {
+ return this.each(function() {
+ jQuery.data( this, key );
+ });
+ }
+
+ var parts = key.split(".");
+ parts[1] = parts[1] ? "." + parts[1] : "";
+
+ if ( value === undefined ) {
+ var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
+
+ if ( data === undefined && this.length ) {
+ data = jQuery.data( this[0], key );
+ }
+ return data === undefined && parts[1] ?
+ this.data( parts[0] ) :
+ data;
+ } else {
+ return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function() {
+ jQuery.data( this, key, value );
+ });
+ }
+ },
+
+ removeData: function( key ) {
+ return this.each(function() {
+ jQuery.removeData( this, key );
+ });
+ }
+});
+jQuery.extend({
+ queue: function( elem, type, data ) {
+ if ( !elem ) {
+ return;
+ }
+
+ type = (type || "fx") + "queue";
+ var q = jQuery.data( elem, type );
+
+ // Speed up dequeue by getting out quickly if this is just a lookup
+ if ( !data ) {
+ return q || [];
+ }
+
+ if ( !q || jQuery.isArray(data) ) {
+ q = jQuery.data( elem, type, jQuery.makeArray(data) );
+
+ } else {
+ q.push( data );
+ }
+
+ return q;
+ },
+
+ dequeue: function( elem, type ) {
+ type = type || "fx";
+
+ var queue = jQuery.queue( elem, type ), fn = queue.shift();
+
+ // If the fx queue is dequeued, always remove the progress sentinel
+ if ( fn === "inprogress" ) {
+ fn = queue.shift();
+ }
+
+ if ( fn ) {
+ // Add a progress sentinel to prevent the fx queue from being
+ // automatically dequeued
+ if ( type === "fx" ) {
+ queue.unshift("inprogress");
+ }
+
+ fn.call(elem, function() {
+ jQuery.dequeue(elem, type);
+ });
+ }
+ }
+});
+
+jQuery.fn.extend({
+ queue: function( type, data ) {
+ if ( typeof type !== "string" ) {
+ data = type;
+ type = "fx";
+ }
+
+ if ( data === undefined ) {
+ return jQuery.queue( this[0], type );
+ }
+ return this.each(function( i, elem ) {
+ var queue = jQuery.queue( this, type, data );
+
+ if ( type === "fx" && queue[0] !== "inprogress" ) {
+ jQuery.dequeue( this, type );
+ }
+ });
+ },
+ dequeue: function( type ) {
+ return this.each(function() {
+ jQuery.dequeue( this, type );
+ });
+ },
+
+ // Based off of the plugin by Clint Helfers, with permission.
+ // http://blindsignals.com/index.php/2009/07/jquery-delay/
+ delay: function( time, type ) {
+ time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
+ type = type || "fx";
+
+ return this.queue( type, function() {
+ var elem = this;
+ setTimeout(function() {
+ jQuery.dequeue( elem, type );
+ }, time );
+ });
+ },
+
+ clearQueue: function( type ) {
+ return this.queue( type || "fx", [] );
+ }
+});
+var rclass = /[\n\t]/g,
+ rspace = /\s+/,
+ rreturn = /\r/g,
+ rspecialurl = /href|src|style/,
+ rtype = /(button|input)/i,
+ rfocusable = /(button|input|object|select|textarea)/i,
+ rclickable = /^(a|area)$/i,
+ rradiocheck = /radio|checkbox/;
+
+jQuery.fn.extend({
+ attr: function( name, value ) {
+ return access( this, name, value, true, jQuery.attr );
+ },
+
+ removeAttr: function( name, fn ) {
+ return this.each(function(){
+ jQuery.attr( this, name, "" );
+ if ( this.nodeType === 1 ) {
+ this.removeAttribute( name );
+ }
+ });
+ },
+
+ addClass: function( value ) {
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.addClass( value.call(this, i, self.attr("class")) );
+ });
+ }
+
+ if ( value && typeof value === "string" ) {
+ var classNames = (value || "").split( rspace );
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var elem = this[i];
+
+ if ( elem.nodeType === 1 ) {
+ if ( !elem.className ) {
+ elem.className = value;
+
+ } else {
+ var className = " " + elem.className + " ";
+ for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
+ if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
+ elem.className += " " + classNames[c];
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ removeClass: function( value ) {
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.removeClass( value.call(this, i, self.attr("class")) );
+ });
+ }
+
+ if ( (value && typeof value === "string") || value === undefined ) {
+ var classNames = (value || "").split(rspace);
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var elem = this[i];
+
+ if ( elem.nodeType === 1 && elem.className ) {
+ if ( value ) {
+ var className = (" " + elem.className + " ").replace(rclass, " ");
+ for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
+ className = className.replace(" " + classNames[c] + " ", " ");
+ }
+ elem.className = className.substring(1, className.length - 1);
+
+ } else {
+ elem.className = "";
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ toggleClass: function( value, stateVal ) {
+ var type = typeof value, isBool = typeof stateVal === "boolean";
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
+ });
+ }
+
+ return this.each(function() {
+ if ( type === "string" ) {
+ // toggle individual class names
+ var className, i = 0, self = jQuery(this),
+ state = stateVal,
+ classNames = value.split( rspace );
+
+ while ( (className = classNames[ i++ ]) ) {
+ // check each className given, space seperated list
+ state = isBool ? state : !self.hasClass( className );
+ self[ state ? "addClass" : "removeClass" ]( className );
+ }
+
+ } else if ( type === "undefined" || type === "boolean" ) {
+ if ( this.className ) {
+ // store className if set
+ jQuery.data( this, "__className__", this.className );
+ }
+
+ // toggle whole className
+ this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || "";
+ }
+ });
+ },
+
+ hasClass: function( selector ) {
+ var className = " " + selector + " ";
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ val: function( value ) {
+ if ( value === undefined ) {
+ var elem = this[0];
+
+ if ( elem ) {
+ if ( jQuery.nodeName( elem, "option" ) ) {
+ return (elem.attributes.value || {}).specified ? elem.value : elem.text;
+ }
+
+ // We need to handle select boxes special
+ if ( jQuery.nodeName( elem, "select" ) ) {
+ var index = elem.selectedIndex,
+ values = [],
+ options = elem.options,
+ one = elem.type === "select-one";
+
+ // Nothing was selected
+ if ( index < 0 ) {
+ return null;
+ }
+
+ // Loop through all the selected options
+ for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
+ var option = options[ i ];
+
+ if ( option.selected ) {
+ // Get the specifc value for the option
+ value = jQuery(option).val();
+
+ // We don't need an array for one selects
+ if ( one ) {
+ return value;
+ }
+
+ // Multi-Selects return an array
+ values.push( value );
+ }
+ }
+
+ return values;
+ }
+
+ // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
+ if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
+ return elem.getAttribute("value") === null ? "on" : elem.value;
+ }
+
+
+ // Everything else, we just grab the value
+ return (elem.value || "").replace(rreturn, "");
+
+ }
+
+ return undefined;
+ }
+
+ var isFunction = jQuery.isFunction(value);
+
+ return this.each(function(i) {
+ var self = jQuery(this), val = value;
+
+ if ( this.nodeType !== 1 ) {
+ return;
+ }
+
+ if ( isFunction ) {
+ val = value.call(this, i, self.val());
+ }
+
+ // Typecast each time if the value is a Function and the appended
+ // value is therefore different each time.
+ if ( typeof val === "number" ) {
+ val += "";
+ }
+
+ if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
+ this.checked = jQuery.inArray( self.val(), val ) >= 0;
+
+ } else if ( jQuery.nodeName( this, "select" ) ) {
+ var values = jQuery.makeArray(val);
+
+ jQuery( "option", this ).each(function() {
+ this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
+ });
+
+ if ( !values.length ) {
+ this.selectedIndex = -1;
+ }
+
+ } else {
+ this.value = val;
+ }
+ });
+ }
+});
+
+jQuery.extend({
+ attrFn: {
+ val: true,
+ css: true,
+ html: true,
+ text: true,
+ data: true,
+ width: true,
+ height: true,
+ offset: true
+ },
+
+ attr: function( elem, name, value, pass ) {
+ // don't set attributes on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ if ( pass && name in jQuery.attrFn ) {
+ return jQuery(elem)[name](value);
+ }
+
+ var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
+ // Whether we are setting (or getting)
+ set = value !== undefined;
+
+ // Try to normalize/fix the name
+ name = notxml && jQuery.props[ name ] || name;
+
+ // Only do all the following if this is a node (faster for style)
+ if ( elem.nodeType === 1 ) {
+ // These attributes require special treatment
+ var special = rspecialurl.test( name );
+
+ // Safari mis-reports the default selected property of an option
+ // Accessing the parent's selectedIndex property fixes it
+ if ( name === "selected" && !jQuery.support.optSelected ) {
+ var parent = elem.parentNode;
+ if ( parent ) {
+ parent.selectedIndex;
+
+ // Make sure that it also works with optgroups, see #5701
+ if ( parent.parentNode ) {
+ parent.parentNode.selectedIndex;
+ }
+ }
+ }
+
+ // If applicable, access the attribute via the DOM 0 way
+ if ( name in elem && notxml && !special ) {
+ if ( set ) {
+ // We can't allow the type property to be changed (since it causes problems in IE)
+ if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
+ throw "type property can't be changed";
+ }
+
+ elem[ name ] = value;
+ }
+
+ // browsers index elements by id/name on forms, give priority to attributes.
+ if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
+ return elem.getAttributeNode( name ).nodeValue;
+ }
+
+ // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
+ // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
+ if ( name === "tabIndex" ) {
+ var attributeNode = elem.getAttributeNode( "tabIndex" );
+
+ return attributeNode && attributeNode.specified ?
+ attributeNode.value :
+ rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
+ 0 :
+ undefined;
+ }
+
+ return elem[ name ];
+ }
+
+ if ( !jQuery.support.style && notxml && name === "style" ) {
+ if ( set ) {
+ elem.style.cssText = "" + value;
+ }
+
+ return elem.style.cssText;
+ }
+
+ if ( set ) {
+ // convert the value to a string (all browsers do this but IE) see #1070
+ elem.setAttribute( name, "" + value );
+ }
+
+ var attr = !jQuery.support.hrefNormalized && notxml && special ?
+ // Some attributes require a special call on IE
+ elem.getAttribute( name, 2 ) :
+ elem.getAttribute( name );
+
+ // Non-existent attributes return null, we normalize to undefined
+ return attr === null ? undefined : attr;
+ }
+
+ // elem is actually elem.style ... set the style
+ // Using attr for specific style information is now deprecated. Use style insead.
+ return jQuery.style( elem, name, value );
+ }
+});
+var fcleanup = function( nm ) {
+ return nm.replace(/[^\w\s\.\|`]/g, function( ch ) {
+ return "\\" + ch;
+ });
+};
+
+/*
+ * A number of helper functions used for managing events.
+ * Many of the ideas behind this code originated from
+ * Dean Edwards' addEvent library.
+ */
+jQuery.event = {
+
+ // Bind an event to an element
+ // Original by Dean Edwards
+ add: function( elem, types, handler, data ) {
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ // For whatever reason, IE has trouble passing the window object
+ // around, causing it to be cloned in the process
+ if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) {
+ elem = window;
+ }
+
+ // Make sure that the function being executed has a unique ID
+ if ( !handler.guid ) {
+ handler.guid = jQuery.guid++;
+ }
+
+ // if data is passed, bind to handler
+ if ( data !== undefined ) {
+ // Create temporary function pointer to original handler
+ var fn = handler;
+
+ // Create unique handler function, wrapped around original handler
+ handler = jQuery.proxy( fn );
+
+ // Store data in unique handler
+ handler.data = data;
+ }
+
+ // Init the element's event structure
+ var events = jQuery.data( elem, "events" ) || jQuery.data( elem, "events", {} ),
+ handle = jQuery.data( elem, "handle" ), eventHandle;
+
+ if ( !handle ) {
+ eventHandle = function() {
+ // Handle the second event of a trigger and when
+ // an event is called after a page has unloaded
+ return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
+ jQuery.event.handle.apply( eventHandle.elem, arguments ) :
+ undefined;
+ };
+
+ handle = jQuery.data( elem, "handle", eventHandle );
+ }
+
+ // If no handle is found then we must be trying to bind to one of the
+ // banned noData elements
+ if ( !handle ) {
+ return;
+ }
+
+ // Add elem as a property of the handle function
+ // This is to prevent a memory leak with non-native
+ // event in IE.
+ handle.elem = elem;
+
+ // Handle multiple events separated by a space
+ // jQuery(...).bind("mouseover mouseout", fn);
+ types = types.split( /\s+/ );
+ var type, i=0;
+ while ( (type = types[ i++ ]) ) {
+ // Namespaced event handlers
+ var namespaces = type.split(".");
+ type = namespaces.shift();
+ handler.type = namespaces.slice(0).sort().join(".");
+
+ // Get the current list of functions bound to this event
+ var handlers = events[ type ],
+ special = this.special[ type ] || {};
+
+
+
+ // Init the event handler queue
+ if ( !handlers ) {
+ handlers = events[ type ] = {};
+
+ // Check for a special event handler
+ // Only use addEventListener/attachEvent if the special
+ // events handler returns false
+ if ( !special.setup || special.setup.call( elem, data, namespaces, handler) === false ) {
+ // Bind the global event handler to the element
+ if ( elem.addEventListener ) {
+ elem.addEventListener( type, handle, false );
+ } else if ( elem.attachEvent ) {
+ elem.attachEvent( "on" + type, handle );
+ }
+ }
+ }
+
+ if ( special.add ) {
+ var modifiedHandler = special.add.call( elem, handler, data, namespaces, handlers );
+ if ( modifiedHandler && jQuery.isFunction( modifiedHandler ) ) {
+ modifiedHandler.guid = modifiedHandler.guid || handler.guid;
+ handler = modifiedHandler;
+ }
+ }
+
+ // Add the function to the element's handler list
+ handlers[ handler.guid ] = handler;
+
+ // Keep track of which events have been used, for global triggering
+ this.global[ type ] = true;
+ }
+
+ // Nullify elem to prevent memory leaks in IE
+ elem = null;
+ },
+
+ global: {},
+
+ // Detach an event or set of events from an element
+ remove: function( elem, types, handler ) {
+ // don't do events on text and comment nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ var events = jQuery.data( elem, "events" ), ret, type, fn;
+
+ if ( events ) {
+ // Unbind all events for the element
+ if ( types === undefined || (typeof types === "string" && types.charAt(0) === ".") ) {
+ for ( type in events ) {
+ this.remove( elem, type + (types || "") );
+ }
+ } else {
+ // types is actually an event object here
+ if ( types.type ) {
+ handler = types.handler;
+ types = types.type;
+ }
+
+ // Handle multiple events separated by a space
+ // jQuery(...).unbind("mouseover mouseout", fn);
+ types = types.split(/\s+/);
+ var i = 0;
+ while ( (type = types[ i++ ]) ) {
+ // Namespaced event handlers
+ var namespaces = type.split(".");
+ type = namespaces.shift();
+ var all = !namespaces.length,
+ cleaned = jQuery.map( namespaces.slice(0).sort(), fcleanup ),
+ namespace = new RegExp("(^|\\.)" + cleaned.join("\\.(?:.*\\.)?") + "(\\.|$)"),
+ special = this.special[ type ] || {};
+
+ if ( events[ type ] ) {
+ // remove the given handler for the given type
+ if ( handler ) {
+ fn = events[ type ][ handler.guid ];
+ delete events[ type ][ handler.guid ];
+
+ // remove all handlers for the given type
+ } else {
+ for ( var handle in events[ type ] ) {
+ // Handle the removal of namespaced events
+ if ( all || namespace.test( events[ type ][ handle ].type ) ) {
+ delete events[ type ][ handle ];
+ }
+ }
+ }
+
+ if ( special.remove ) {
+ special.remove.call( elem, namespaces, fn);
+ }
+
+ // remove generic event handler if no more handlers exist
+ for ( ret in events[ type ] ) {
+ break;
+ }
+ if ( !ret ) {
+ if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
+ if ( elem.removeEventListener ) {
+ elem.removeEventListener( type, jQuery.data( elem, "handle" ), false );
+ } else if ( elem.detachEvent ) {
+ elem.detachEvent( "on" + type, jQuery.data( elem, "handle" ) );
+ }
+ }
+ ret = null;
+ delete events[ type ];
+ }
+ }
+ }
+ }
+
+ // Remove the expando if it's no longer used
+ for ( ret in events ) {
+ break;
+ }
+ if ( !ret ) {
+ var handle = jQuery.data( elem, "handle" );
+ if ( handle ) {
+ handle.elem = null;
+ }
+ jQuery.removeData( elem, "events" );
+ jQuery.removeData( elem, "handle" );
+ }
+ }
+ },
+
+ // bubbling is internal
+ trigger: function( event, data, elem /*, bubbling */ ) {
+ // Event object or event type
+ var type = event.type || event,
+ bubbling = arguments[3];
+
+ if ( !bubbling ) {
+ event = typeof event === "object" ?
+ // jQuery.Event object
+ event[expando] ? event :
+ // Object literal
+ jQuery.extend( jQuery.Event(type), event ) :
+ // Just the event type (string)
+ jQuery.Event(type);
+
+ if ( type.indexOf("!") >= 0 ) {
+ event.type = type = type.slice(0, -1);
+ event.exclusive = true;
+ }
+
+ // Handle a global trigger
+ if ( !elem ) {
+ // Don't bubble custom events when global (to avoid too much overhead)
+ event.stopPropagation();
+
+ // Only trigger if we've ever bound an event for it
+ if ( this.global[ type ] ) {
+ jQuery.each( jQuery.cache, function() {
+ if ( this.events && this.events[type] ) {
+ jQuery.event.trigger( event, data, this.handle.elem );
+ }
+ });
+ }
+ }
+
+ // Handle triggering a single element
+
+ // don't do events on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ // Clean up in case it is reused
+ event.result = undefined;
+ event.target = elem;
+
+ // Clone the incoming data, if any
+ data = jQuery.makeArray( data );
+ data.unshift( event );
+ }
+
+ event.currentTarget = elem;
+
+ // Trigger the event, it is assumed that "handle" is a function
+ var handle = jQuery.data( elem, "handle" );
+ if ( handle ) {
+ handle.apply( elem, data );
+ }
+
+ var nativeFn, nativeHandler;
+ try {
+ if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
+ nativeFn = elem[ type ];
+ nativeHandler = elem[ "on" + type ];
+ }
+ // prevent IE from throwing an error for some elements with some event types, see #3533
+ } catch (e) {}
+
+ var isClick = jQuery.nodeName(elem, "a") && type === "click";
+
+ // Trigger the native events (except for clicks on links)
+ if ( !bubbling && nativeFn && !event.isDefaultPrevented() && !isClick ) {
+ this.triggered = true;
+ try {
+ elem[ type ]();
+ // prevent IE from throwing an error for some hidden elements
+ } catch (e) {}
+
+ // Handle triggering native .onfoo handlers
+ } else if ( nativeHandler && elem[ "on" + type ].apply( elem, data ) === false ) {
+ event.result = false;
+ }
+
+ this.triggered = false;
+
+ if ( !event.isPropagationStopped() ) {
+ var parent = elem.parentNode || elem.ownerDocument;
+ if ( parent ) {
+ jQuery.event.trigger( event, data, parent, true );
+ }
+ }
+ },
+
+ handle: function( event ) {
+ // returned undefined or false
+ var all, handlers;
+
+ event = arguments[0] = jQuery.event.fix( event || window.event );
+ event.currentTarget = this;
+
+ // Namespaced event handlers
+ var namespaces = event.type.split(".");
+ event.type = namespaces.shift();
+
+ // Cache this now, all = true means, any handler
+ all = !namespaces.length && !event.exclusive;
+
+ var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)");
+
+ handlers = ( jQuery.data(this, "events") || {} )[ event.type ];
+
+ for ( var j in handlers ) {
+ var handler = handlers[ j ];
+
+ // Filter the functions by class
+ if ( all || namespace.test(handler.type) ) {
+ // Pass in a reference to the handler function itself
+ // So that we can later remove it
+ event.handler = handler;
+ event.data = handler.data;
+
+ var ret = handler.apply( this, arguments );
+
+ if ( ret !== undefined ) {
+ event.result = ret;
+ if ( ret === false ) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }
+
+ if ( event.isImmediatePropagationStopped() ) {
+ break;
+ }
+
+ }
+ }
+
+ return event.result;
+ },
+
+ props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
+
+ fix: function( event ) {
+ if ( event[ expando ] ) {
+ return event;
+ }
+
+ // store a copy of the original event object
+ // and "clone" to set read-only properties
+ var originalEvent = event;
+ event = jQuery.Event( originalEvent );
+
+ for ( var i = this.props.length, prop; i; ) {
+ prop = this.props[ --i ];
+ event[ prop ] = originalEvent[ prop ];
+ }
+
+ // Fix target property, if necessary
+ if ( !event.target ) {
+ event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
+ }
+
+ // check if target is a textnode (safari)
+ if ( event.target.nodeType === 3 ) {
+ event.target = event.target.parentNode;
+ }
+
+ // Add relatedTarget, if necessary
+ if ( !event.relatedTarget && event.fromElement ) {
+ event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
+ }
+
+ // Calculate pageX/Y if missing and clientX/Y available
+ if ( event.pageX == null && event.clientX != null ) {
+ var doc = document.documentElement, body = document.body;
+ event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
+ event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
+ }
+
+ // Add which for key events
+ if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) {
+ event.which = event.charCode || event.keyCode;
+ }
+
+ // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
+ if ( !event.metaKey && event.ctrlKey ) {
+ event.metaKey = event.ctrlKey;
+ }
+
+ // Add which for click: 1 === left; 2 === middle; 3 === right
+ // Note: button is not normalized, so don't use it
+ if ( !event.which && event.button !== undefined ) {
+ event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
+ }
+
+ return event;
+ },
+
+ // Deprecated, use jQuery.guid instead
+ guid: 1E8,
+
+ // Deprecated, use jQuery.proxy instead
+ proxy: jQuery.proxy,
+
+ special: {
+ ready: {
+ // Make sure the ready event is setup
+ setup: jQuery.bindReady,
+ teardown: jQuery.noop
+ },
+
+ live: {
+ add: function( proxy, data, namespaces, live ) {
+ jQuery.extend( proxy, data || {} );
+
+ proxy.guid += data.selector + data.live;
+ jQuery.event.add( this, data.live, liveHandler, data );
+
+ },
+
+ remove: function( namespaces ) {
+ if ( namespaces.length ) {
+ var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)");
+
+ jQuery.each( (jQuery.data(this, "events").live || {}), function() {
+ if ( name.test(this.type) ) {
+ remove++;
+ }
+ });
+
+ if ( remove < 1 ) {
+ jQuery.event.remove( this, namespaces[0], liveHandler );
+ }
+ }
+ },
+ special: {}
+ },
+ beforeunload: {
+ setup: function( data, namespaces, fn ) {
+ // We only want to do this special case on windows
+ if ( this.setInterval ) {
+ this.onbeforeunload = fn;
+ }
+
+ return false;
+ },
+ teardown: function( namespaces, fn ) {
+ if ( this.onbeforeunload === fn ) {
+ this.onbeforeunload = null;
+ }
+ }
+ }
+ }
+};
+
+jQuery.Event = function( src ) {
+ // Allow instantiation without the 'new' keyword
+ if ( !this.preventDefault ) {
+ return new jQuery.Event( src );
+ }
+
+ // Event object
+ if ( src && src.type ) {
+ this.originalEvent = src;
+ this.type = src.type;
+ // Event type
+ } else {
+ this.type = src;
+ }
+
+ // timeStamp is buggy for some events on Firefox(#3843)
+ // So we won't rely on the native value
+ this.timeStamp = now();
+
+ // Mark it as fixed
+ this[ expando ] = true;
+};
+
+function returnFalse() {
+ return false;
+}
+function returnTrue() {
+ return true;
+}
+
+// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
+// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
+jQuery.Event.prototype = {
+ preventDefault: function() {
+ this.isDefaultPrevented = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+
+ // if preventDefault exists run it on the original event
+ if ( e.preventDefault ) {
+ e.preventDefault();
+ }
+ // otherwise set the returnValue property of the original event to false (IE)
+ e.returnValue = false;
+ },
+ stopPropagation: function() {
+ this.isPropagationStopped = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+ // if stopPropagation exists run it on the original event
+ if ( e.stopPropagation ) {
+ e.stopPropagation();
+ }
+ // otherwise set the cancelBubble property of the original event to true (IE)
+ e.cancelBubble = true;
+ },
+ stopImmediatePropagation: function() {
+ this.isImmediatePropagationStopped = returnTrue;
+ this.stopPropagation();
+ },
+ isDefaultPrevented: returnFalse,
+ isPropagationStopped: returnFalse,
+ isImmediatePropagationStopped: returnFalse
+};
+
+// Checks if an event happened on an element within another element
+// Used in jQuery.event.special.mouseenter and mouseleave handlers
+var withinElement = function( event ) {
+ // Check if mouse(over|out) are still within the same parent element
+ var parent = event.relatedTarget;
+
+ // Traverse up the tree
+ while ( parent && parent !== this ) {
+ // Firefox sometimes assigns relatedTarget a XUL element
+ // which we cannot access the parentNode property of
+ try {
+ parent = parent.parentNode;
+
+ // assuming we've left the element since we most likely mousedover a xul element
+ } catch(e) {
+ break;
+ }
+ }
+
+ if ( parent !== this ) {
+ // set the correct event type
+ event.type = event.data;
+
+ // handle event if we actually just moused on to a non sub-element
+ jQuery.event.handle.apply( this, arguments );
+ }
+
+},
+
+// In case of event delegation, we only need to rename the event.type,
+// liveHandler will take care of the rest.
+delegate = function( event ) {
+ event.type = event.data;
+ jQuery.event.handle.apply( this, arguments );
+};
+
+// Create mouseenter and mouseleave events
+jQuery.each({
+ mouseenter: "mouseover",
+ mouseleave: "mouseout"
+}, function( orig, fix ) {
+ jQuery.event.special[ orig ] = {
+ setup: function( data ) {
+ jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
+ },
+ teardown: function( data ) {
+ jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
+ }
+ };
+});
+
+// submit delegation
+if ( !jQuery.support.submitBubbles ) {
+
+jQuery.event.special.submit = {
+ setup: function( data, namespaces, fn ) {
+ if ( this.nodeName.toLowerCase() !== "form" ) {
+ jQuery.event.add(this, "click.specialSubmit." + fn.guid, function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
+ return trigger( "submit", this, arguments );
+ }
+ });
+
+ jQuery.event.add(this, "keypress.specialSubmit." + fn.guid, function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
+ return trigger( "submit", this, arguments );
+ }
+ });
+
+ } else {
+ return false;
+ }
+ },
+
+ remove: function( namespaces, fn ) {
+ jQuery.event.remove( this, "click.specialSubmit" + (fn ? "."+fn.guid : "") );
+ jQuery.event.remove( this, "keypress.specialSubmit" + (fn ? "."+fn.guid : "") );
+ }
+};
+
+}
+
+// change delegation, happens here so we have bind.
+if ( !jQuery.support.changeBubbles ) {
+
+var formElems = /textarea|input|select/i;
+
+function getVal( elem ) {
+ var type = elem.type, val = elem.value;
+
+ if ( type === "radio" || type === "checkbox" ) {
+ val = elem.checked;
+
+ } else if ( type === "select-multiple" ) {
+ val = elem.selectedIndex > -1 ?
+ jQuery.map( elem.options, function( elem ) {
+ return elem.selected;
+ }).join("-") :
+ "";
+
+ } else if ( elem.nodeName.toLowerCase() === "select" ) {
+ val = elem.selectedIndex;
+ }
+
+ return val;
+}
+
+function testChange( e ) {
+ var elem = e.target, data, val;
+
+ if ( !formElems.test( elem.nodeName ) || elem.readOnly ) {
+ return;
+ }
+
+ data = jQuery.data( elem, "_change_data" );
+ val = getVal(elem);
+
+ if ( val === data ) {
+ return;
+ }
+
+ // the current data will be also retrieved by beforeactivate
+ if ( e.type !== "focusout" || elem.type !== "radio" ) {
+ jQuery.data( elem, "_change_data", val );
+ }
+
+ if ( elem.type !== "select" && (data != null || val) ) {
+ e.type = "change";
+ return jQuery.event.trigger( e, arguments[1], this );
+ }
+}
+
+jQuery.event.special.change = {
+ filters: {
+ focusout: testChange,
+
+ click: function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
+ return testChange.call( this, e );
+ }
+ },
+
+ // Change has to be called before submit
+ // Keydown will be called before keypress, which is used in submit-event delegation
+ keydown: function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
+ (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
+ type === "select-multiple" ) {
+ return testChange.call( this, e );
+ }
+ },
+
+ // Beforeactivate happens also before the previous element is blurred
+ // with this event you can't trigger a change event, but you can store
+ // information/focus[in] is not needed anymore
+ beforeactivate: function( e ) {
+ var elem = e.target;
+
+ if ( elem.nodeName.toLowerCase() === "input" && elem.type === "radio" ) {
+ jQuery.data( elem, "_change_data", getVal(elem) );
+ }
+ }
+ },
+ setup: function( data, namespaces, fn ) {
+ for ( var type in changeFilters ) {
+ jQuery.event.add( this, type + ".specialChange." + fn.guid, changeFilters[type] );
+ }
+
+ return formElems.test( this.nodeName );
+ },
+ remove: function( namespaces, fn ) {
+ for ( var type in changeFilters ) {
+ jQuery.event.remove( this, type + ".specialChange" + (fn ? "."+fn.guid : ""), changeFilters[type] );
+ }
+
+ return formElems.test( this.nodeName );
+ }
+};
+
+var changeFilters = jQuery.event.special.change.filters;
+
+}
+
+function trigger( type, elem, args ) {
+ args[0].type = type;
+ return jQuery.event.handle.apply( elem, args );
+}
+
+// Create "bubbling" focus and blur events
+if ( document.addEventListener ) {
+ jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
+ jQuery.event.special[ fix ] = {
+ setup: function() {
+ this.addEventListener( orig, handler, true );
+ },
+ teardown: function() {
+ this.removeEventListener( orig, handler, true );
+ }
+ };
+
+ function handler( e ) {
+ e = jQuery.event.fix( e );
+ e.type = fix;
+ return jQuery.event.handle.call( this, e );
+ }
+ });
+}
+
+jQuery.each(["bind", "one"], function( i, name ) {
+ jQuery.fn[ name ] = function( type, data, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" ) {
+ for ( var key in type ) {
+ this[ name ](key, data, type[key], fn);
+ }
+ return this;
+ }
+
+ if ( jQuery.isFunction( data ) ) {
+ thisObject = fn;
+ fn = data;
+ data = undefined;
+ }
+
+ var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
+ jQuery( this ).unbind( event, handler );
+ return fn.apply( this, arguments );
+ }) : fn;
+
+ return type === "unload" && name !== "one" ?
+ this.one( type, data, fn, thisObject ) :
+ this.each(function() {
+ jQuery.event.add( this, type, handler, data );
+ });
+ };
+});
+
+jQuery.fn.extend({
+ unbind: function( type, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" && !type.preventDefault ) {
+ for ( var key in type ) {
+ this.unbind(key, type[key]);
+ }
+ return this;
+ }
+
+ return this.each(function() {
+ jQuery.event.remove( this, type, fn );
+ });
+ },
+ trigger: function( type, data ) {
+ return this.each(function() {
+ jQuery.event.trigger( type, data, this );
+ });
+ },
+
+ triggerHandler: function( type, data ) {
+ if ( this[0] ) {
+ var event = jQuery.Event( type );
+ event.preventDefault();
+ event.stopPropagation();
+ jQuery.event.trigger( event, data, this[0] );
+ return event.result;
+ }
+ },
+
+ toggle: function( fn ) {
+ // Save reference to arguments for access in closure
+ var args = arguments, i = 1;
+
+ // link all the functions, so any of them can unbind this click handler
+ while ( i < args.length ) {
+ jQuery.proxy( fn, args[ i++ ] );
+ }
+
+ return this.click( jQuery.proxy( fn, function( event ) {
+ // Figure out which function to execute
+ var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
+ jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
+
+ // Make sure that clicks stop
+ event.preventDefault();
+
+ // and execute the function
+ return args[ lastToggle ].apply( this, arguments ) || false;
+ }));
+ },
+
+ hover: function( fnOver, fnOut ) {
+ return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
+ },
+
+ live: function( type, data, fn ) {
+ if ( jQuery.isFunction( data ) ) {
+ fn = data;
+ data = undefined;
+ }
+
+ jQuery( this.context ).bind( liveConvert( type, this.selector ), {
+ data: data, selector: this.selector, live: type
+ }, fn );
+
+ return this;
+ },
+
+ die: function( type, fn ) {
+ jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null );
+ return this;
+ }
+});
+
+function liveHandler( event ) {
+ var stop = true, elems = [], selectors = [], args = arguments,
+ related, match, fn, elem, j, i, data,
+ live = jQuery.extend({}, jQuery.data( this, "events" ).live);
+
+ for ( j in live ) {
+ fn = live[j];
+ if ( fn.live === event.type ||
+ fn.altLive && jQuery.inArray(event.type, fn.altLive) > -1 ) {
+
+ data = fn.data;
+ if ( !(data.beforeFilter && data.beforeFilter[event.type] &&
+ !data.beforeFilter[event.type](event)) ) {
+ selectors.push( fn.selector );
+ }
+ } else {
+ delete live[j];
+ }
+ }
+
+ match = jQuery( event.target ).closest( selectors, event.currentTarget );
+
+ for ( i = 0, l = match.length; i < l; i++ ) {
+ for ( j in live ) {
+ fn = live[j];
+ elem = match[i].elem;
+ related = null;
+
+ if ( match[i].selector === fn.selector ) {
+ // Those two events require additional checking
+ if ( fn.live === "mouseenter" || fn.live === "mouseleave" ) {
+ related = jQuery( event.relatedTarget ).closest( fn.selector )[0];
+ }
+
+ if ( !related || related !== elem ) {
+ elems.push({ elem: elem, fn: fn });
+ }
+ }
+ }
+ }
+
+ for ( i = 0, l = elems.length; i < l; i++ ) {
+ match = elems[i];
+ event.currentTarget = match.elem;
+ event.data = match.fn.data;
+ if ( match.fn.apply( match.elem, args ) === false ) {
+ stop = false;
+ break;
+ }
+ }
+
+ return stop;
+}
+
+function liveConvert( type, selector ) {
+ return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "&")].join(".");
+}
+
+jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
+ "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
+ "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
+
+ // Handle event binding
+ jQuery.fn[ name ] = function( fn ) {
+ return fn ? this.bind( name, fn ) : this.trigger( name );
+ };
+
+ if ( jQuery.attrFn ) {
+ jQuery.attrFn[ name ] = true;
+ }
+});
+
+// Prevent memory leaks in IE
+// Window isn't included so as not to unbind existing unload events
+// More info:
+// - http://isaacschlueter.com/2006/10/msie-memory-leaks/
+if ( window.attachEvent && !window.addEventListener ) {
+ window.attachEvent("onunload", function() {
+ for ( var id in jQuery.cache ) {
+ if ( jQuery.cache[ id ].handle ) {
+ // Try/Catch is to handle iframes being unloaded, see #4280
+ try {
+ jQuery.event.remove( jQuery.cache[ id ].handle.elem );
+ } catch(e) {}
+ }
+ }
+ });
+}
+/*!
+ * Sizzle CSS Selector Engine - v1.0
+ * Copyright 2009, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ * More information: http://sizzlejs.com/
+ */
+(function(){
+
+var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
+ done = 0,
+ toString = Object.prototype.toString,
+ hasDuplicate = false,
+ baseHasDuplicate = true;
+
+// Here we check if the JavaScript engine is using some sort of
+// optimization where it does not always call our comparision
+// function. If that is the case, discard the hasDuplicate value.
+// Thus far that includes Google Chrome.
+[0, 0].sort(function(){
+ baseHasDuplicate = false;
+ return 0;
+});
+
+var Sizzle = function(selector, context, results, seed) {
+ results = results || [];
+ var origContext = context = context || document;
+
+ if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
+ return [];
+ }
+
+ if ( !selector || typeof selector !== "string" ) {
+ return results;
+ }
+
+ var parts = [], m, set, checkSet, extra, prune = true, contextXML = isXML(context),
+ soFar = selector;
+
+ // Reset the position of the chunker regexp (start from head)
+ while ( (chunker.exec(""), m = chunker.exec(soFar)) !== null ) {
+ soFar = m[3];
+
+ parts.push( m[1] );
+
+ if ( m[2] ) {
+ extra = m[3];
+ break;
+ }
+ }
+
+ if ( parts.length > 1 && origPOS.exec( selector ) ) {
+ if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
+ set = posProcess( parts[0] + parts[1], context );
+ } else {
+ set = Expr.relative[ parts[0] ] ?
+ [ context ] :
+ Sizzle( parts.shift(), context );
+
+ while ( parts.length ) {
+ selector = parts.shift();
+
+ if ( Expr.relative[ selector ] ) {
+ selector += parts.shift();
+ }
+
+ set = posProcess( selector, set );
+ }
+ }
+ } else {
+ // Take a shortcut and set the context if the root selector is an ID
+ // (but not if it'll be faster if the inner selector is an ID)
+ if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
+ Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
+ var ret = Sizzle.find( parts.shift(), context, contextXML );
+ context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];
+ }
+
+ if ( context ) {
+ var ret = seed ?
+ { expr: parts.pop(), set: makeArray(seed) } :
+ Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
+ set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set;
+
+ if ( parts.length > 0 ) {
+ checkSet = makeArray(set);
+ } else {
+ prune = false;
+ }
+
+ while ( parts.length ) {
+ var cur = parts.pop(), pop = cur;
+
+ if ( !Expr.relative[ cur ] ) {
+ cur = "";
+ } else {
+ pop = parts.pop();
+ }
+
+ if ( pop == null ) {
+ pop = context;
+ }
+
+ Expr.relative[ cur ]( checkSet, pop, contextXML );
+ }
+ } else {
+ checkSet = parts = [];
+ }
+ }
+
+ if ( !checkSet ) {
+ checkSet = set;
+ }
+
+ if ( !checkSet ) {
+ throw "Syntax error, unrecognized expression: " + (cur || selector);
+ }
+
+ if ( toString.call(checkSet) === "[object Array]" ) {
+ if ( !prune ) {
+ results.push.apply( results, checkSet );
+ } else if ( context && context.nodeType === 1 ) {
+ for ( var i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {
+ results.push( set[i] );
+ }
+ }
+ } else {
+ for ( var i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
+ results.push( set[i] );
+ }
+ }
+ }
+ } else {
+ makeArray( checkSet, results );
+ }
+
+ if ( extra ) {
+ Sizzle( extra, origContext, results, seed );
+ Sizzle.uniqueSort( results );
+ }
+
+ return results;
+};
+
+Sizzle.uniqueSort = function(results){
+ if ( sortOrder ) {
+ hasDuplicate = baseHasDuplicate;
+ results.sort(sortOrder);
+
+ if ( hasDuplicate ) {
+ for ( var i = 1; i < results.length; i++ ) {
+ if ( results[i] === results[i-1] ) {
+ results.splice(i--, 1);
+ }
+ }
+ }
+ }
+
+ return results;
+};
+
+Sizzle.matches = function(expr, set){
+ return Sizzle(expr, null, null, set);
+};
+
+Sizzle.find = function(expr, context, isXML){
+ var set, match;
+
+ if ( !expr ) {
+ return [];
+ }
+
+ for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
+ var type = Expr.order[i], match;
+
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
+ var left = match[1];
+ match.splice(1,1);
+
+ if ( left.substr( left.length - 1 ) !== "\\" ) {
+ match[1] = (match[1] || "").replace(/\\/g, "");
+ set = Expr.find[ type ]( match, context, isXML );
+ if ( set != null ) {
+ expr = expr.replace( Expr.match[ type ], "" );
+ break;
+ }
+ }
+ }
+ }
+
+ if ( !set ) {
+ set = context.getElementsByTagName("*");
+ }
+
+ return {set: set, expr: expr};
+};
+
+Sizzle.filter = function(expr, set, inplace, not){
+ var old = expr, result = [], curLoop = set, match, anyFound,
+ isXMLFilter = set && set[0] && isXML(set[0]);
+
+ while ( expr && set.length ) {
+ for ( var type in Expr.filter ) {
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
+ var filter = Expr.filter[ type ], found, item, left = match[1];
+ anyFound = false;
+
+ match.splice(1,1);
+
+ if ( left.substr( left.length - 1 ) === "\\" ) {
+ continue;
+ }
+
+ if ( curLoop === result ) {
+ result = [];
+ }
+
+ if ( Expr.preFilter[ type ] ) {
+ match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
+
+ if ( !match ) {
+ anyFound = found = true;
+ } else if ( match === true ) {
+ continue;
+ }
+ }
+
+ if ( match ) {
+ for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
+ if ( item ) {
+ found = filter( item, match, i, curLoop );
+ var pass = not ^ !!found;
+
+ if ( inplace && found != null ) {
+ if ( pass ) {
+ anyFound = true;
+ } else {
+ curLoop[i] = false;
+ }
+ } else if ( pass ) {
+ result.push( item );
+ anyFound = true;
+ }
+ }
+ }
+ }
+
+ if ( found !== undefined ) {
+ if ( !inplace ) {
+ curLoop = result;
+ }
+
+ expr = expr.replace( Expr.match[ type ], "" );
+
+ if ( !anyFound ) {
+ return [];
+ }
+
+ break;
+ }
+ }
+ }
+
+ // Improper expression
+ if ( expr === old ) {
+ if ( anyFound == null ) {
+ throw "Syntax error, unrecognized expression: " + expr;
+ } else {
+ break;
+ }
+ }
+
+ old = expr;
+ }
+
+ return curLoop;
+};
+
+var Expr = Sizzle.selectors = {
+ order: [ "ID", "NAME", "TAG" ],
+ match: {
+ ID: /#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
+ CLASS: /\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
+ NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,
+ ATTR: /\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
+ TAG: /^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,
+ CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
+ POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
+ PSEUDO: /:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
+ },
+ leftMatch: {},
+ attrMap: {
+ "class": "className",
+ "for": "htmlFor"
+ },
+ attrHandle: {
+ href: function(elem){
+ return elem.getAttribute("href");
+ }
+ },
+ relative: {
+ "+": function(checkSet, part){
+ var isPartStr = typeof part === "string",
+ isTag = isPartStr && !/\W/.test(part),
+ isPartStrNotTag = isPartStr && !isTag;
+
+ if ( isTag ) {
+ part = part.toLowerCase();
+ }
+
+ for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
+ if ( (elem = checkSet[i]) ) {
+ while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
+
+ checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
+ elem || false :
+ elem === part;
+ }
+ }
+
+ if ( isPartStrNotTag ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ },
+ ">": function(checkSet, part){
+ var isPartStr = typeof part === "string";
+
+ if ( isPartStr && !/\W/.test(part) ) {
+ part = part.toLowerCase();
+
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ var parent = elem.parentNode;
+ checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
+ }
+ }
+ } else {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ checkSet[i] = isPartStr ?
+ elem.parentNode :
+ elem.parentNode === part;
+ }
+ }
+
+ if ( isPartStr ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ }
+ },
+ "": function(checkSet, part, isXML){
+ var doneName = done++, checkFn = dirCheck;
+
+ if ( typeof part === "string" && !/\W/.test(part) ) {
+ var nodeCheck = part = part.toLowerCase();
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
+ },
+ "~": function(checkSet, part, isXML){
+ var doneName = done++, checkFn = dirCheck;
+
+ if ( typeof part === "string" && !/\W/.test(part) ) {
+ var nodeCheck = part = part.toLowerCase();
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);
+ }
+ },
+ find: {
+ ID: function(match, context, isXML){
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+ return m ? [m] : [];
+ }
+ },
+ NAME: function(match, context){
+ if ( typeof context.getElementsByName !== "undefined" ) {
+ var ret = [], results = context.getElementsByName(match[1]);
+
+ for ( var i = 0, l = results.length; i < l; i++ ) {
+ if ( results[i].getAttribute("name") === match[1] ) {
+ ret.push( results[i] );
+ }
+ }
+
+ return ret.length === 0 ? null : ret;
+ }
+ },
+ TAG: function(match, context){
+ return context.getElementsByTagName(match[1]);
+ }
+ },
+ preFilter: {
+ CLASS: function(match, curLoop, inplace, result, not, isXML){
+ match = " " + match[1].replace(/\\/g, "") + " ";
+
+ if ( isXML ) {
+ return match;
+ }
+
+ for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
+ if ( elem ) {
+ if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) {
+ if ( !inplace ) {
+ result.push( elem );
+ }
+ } else if ( inplace ) {
+ curLoop[i] = false;
+ }
+ }
+ }
+
+ return false;
+ },
+ ID: function(match){
+ return match[1].replace(/\\/g, "");
+ },
+ TAG: function(match, curLoop){
+ return match[1].toLowerCase();
+ },
+ CHILD: function(match){
+ if ( match[1] === "nth" ) {
+ // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
+ var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
+ match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
+ !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
+
+ // calculate the numbers (first)n+(last) including if they are negative
+ match[2] = (test[1] + (test[2] || 1)) - 0;
+ match[3] = test[3] - 0;
+ }
+
+ // TODO: Move to normal caching system
+ match[0] = done++;
+
+ return match;
+ },
+ ATTR: function(match, curLoop, inplace, result, not, isXML){
+ var name = match[1].replace(/\\/g, "");
+
+ if ( !isXML && Expr.attrMap[name] ) {
+ match[1] = Expr.attrMap[name];
+ }
+
+ if ( match[2] === "~=" ) {
+ match[4] = " " + match[4] + " ";
+ }
+
+ return match;
+ },
+ PSEUDO: function(match, curLoop, inplace, result, not){
+ if ( match[1] === "not" ) {
+ // If we're dealing with a complex expression, or a simple one
+ if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
+ match[3] = Sizzle(match[3], null, null, curLoop);
+ } else {
+ var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
+ if ( !inplace ) {
+ result.push.apply( result, ret );
+ }
+ return false;
+ }
+ } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
+ return true;
+ }
+
+ return match;
+ },
+ POS: function(match){
+ match.unshift( true );
+ return match;
+ }
+ },
+ filters: {
+ enabled: function(elem){
+ return elem.disabled === false && elem.type !== "hidden";
+ },
+ disabled: function(elem){
+ return elem.disabled === true;
+ },
+ checked: function(elem){
+ return elem.checked === true;
+ },
+ selected: function(elem){
+ // Accessing this property makes selected-by-default
+ // options in Safari work properly
+ elem.parentNode.selectedIndex;
+ return elem.selected === true;
+ },
+ parent: function(elem){
+ return !!elem.firstChild;
+ },
+ empty: function(elem){
+ return !elem.firstChild;
+ },
+ has: function(elem, i, match){
+ return !!Sizzle( match[3], elem ).length;
+ },
+ header: function(elem){
+ return /h\d/i.test( elem.nodeName );
+ },
+ text: function(elem){
+ return "text" === elem.type;
+ },
+ radio: function(elem){
+ return "radio" === elem.type;
+ },
+ checkbox: function(elem){
+ return "checkbox" === elem.type;
+ },
+ file: function(elem){
+ return "file" === elem.type;
+ },
+ password: function(elem){
+ return "password" === elem.type;
+ },
+ submit: function(elem){
+ return "submit" === elem.type;
+ },
+ image: function(elem){
+ return "image" === elem.type;
+ },
+ reset: function(elem){
+ return "reset" === elem.type;
+ },
+ button: function(elem){
+ return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
+ },
+ input: function(elem){
+ return /input|select|textarea|button/i.test(elem.nodeName);
+ }
+ },
+ setFilters: {
+ first: function(elem, i){
+ return i === 0;
+ },
+ last: function(elem, i, match, array){
+ return i === array.length - 1;
+ },
+ even: function(elem, i){
+ return i % 2 === 0;
+ },
+ odd: function(elem, i){
+ return i % 2 === 1;
+ },
+ lt: function(elem, i, match){
+ return i < match[3] - 0;
+ },
+ gt: function(elem, i, match){
+ return i > match[3] - 0;
+ },
+ nth: function(elem, i, match){
+ return match[3] - 0 === i;
+ },
+ eq: function(elem, i, match){
+ return match[3] - 0 === i;
+ }
+ },
+ filter: {
+ PSEUDO: function(elem, match, i, array){
+ var name = match[1], filter = Expr.filters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+ } else if ( name === "contains" ) {
+ return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
+ } else if ( name === "not" ) {
+ var not = match[3];
+
+ for ( var i = 0, l = not.length; i < l; i++ ) {
+ if ( not[i] === elem ) {
+ return false;
+ }
+ }
+
+ return true;
+ } else {
+ throw "Syntax error, unrecognized expression: " + name;
+ }
+ },
+ CHILD: function(elem, match){
+ var type = match[1], node = elem;
+ switch (type) {
+ case 'only':
+ case 'first':
+ while ( (node = node.previousSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+ if ( type === "first" ) {
+ return true;
+ }
+ node = elem;
+ case 'last':
+ while ( (node = node.nextSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+ return true;
+ case 'nth':
+ var first = match[2], last = match[3];
+
+ if ( first === 1 && last === 0 ) {
+ return true;
+ }
+
+ var doneName = match[0],
+ parent = elem.parentNode;
+
+ if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
+ var count = 0;
+ for ( node = parent.firstChild; node; node = node.nextSibling ) {
+ if ( node.nodeType === 1 ) {
+ node.nodeIndex = ++count;
+ }
+ }
+ parent.sizcache = doneName;
+ }
+
+ var diff = elem.nodeIndex - last;
+ if ( first === 0 ) {
+ return diff === 0;
+ } else {
+ return ( diff % first === 0 && diff / first >= 0 );
+ }
+ }
+ },
+ ID: function(elem, match){
+ return elem.nodeType === 1 && elem.getAttribute("id") === match;
+ },
+ TAG: function(elem, match){
+ return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
+ },
+ CLASS: function(elem, match){
+ return (" " + (elem.className || elem.getAttribute("class")) + " ")
+ .indexOf( match ) > -1;
+ },
+ ATTR: function(elem, match){
+ var name = match[1],
+ result = Expr.attrHandle[ name ] ?
+ Expr.attrHandle[ name ]( elem ) :
+ elem[ name ] != null ?
+ elem[ name ] :
+ elem.getAttribute( name ),
+ value = result + "",
+ type = match[2],
+ check = match[4];
+
+ return result == null ?
+ type === "!=" :
+ type === "=" ?
+ value === check :
+ type === "*=" ?
+ value.indexOf(check) >= 0 :
+ type === "~=" ?
+ (" " + value + " ").indexOf(check) >= 0 :
+ !check ?
+ value && result !== false :
+ type === "!=" ?
+ value !== check :
+ type === "^=" ?
+ value.indexOf(check) === 0 :
+ type === "$=" ?
+ value.substr(value.length - check.length) === check :
+ type === "|=" ?
+ value === check || value.substr(0, check.length + 1) === check + "-" :
+ false;
+ },
+ POS: function(elem, match, i, array){
+ var name = match[2], filter = Expr.setFilters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+ }
+ }
+ }
+};
+
+var origPOS = Expr.match.POS;
+
+for ( var type in Expr.match ) {
+ Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source );
+ Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, function(all, num){
+ return "\\" + (num - 0 + 1);
+ }));
+}
+
+var makeArray = function(array, results) {
+ array = Array.prototype.slice.call( array, 0 );
+
+ if ( results ) {
+ results.push.apply( results, array );
+ return results;
+ }
+
+ return array;
+};
+
+// Perform a simple check to determine if the browser is capable of
+// converting a NodeList to an array using builtin methods.
+try {
+ Array.prototype.slice.call( document.documentElement.childNodes, 0 );
+
+// Provide a fallback method if it does not work
+} catch(e){
+ makeArray = function(array, results) {
+ var ret = results || [];
+
+ if ( toString.call(array) === "[object Array]" ) {
+ Array.prototype.push.apply( ret, array );
+ } else {
+ if ( typeof array.length === "number" ) {
+ for ( var i = 0, l = array.length; i < l; i++ ) {
+ ret.push( array[i] );
+ }
+ } else {
+ for ( var i = 0; array[i]; i++ ) {
+ ret.push( array[i] );
+ }
+ }
+ }
+
+ return ret;
+ };
+}
+
+var sortOrder;
+
+if ( document.documentElement.compareDocumentPosition ) {
+ sortOrder = function( a, b ) {
+ if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.compareDocumentPosition ? -1 : 1;
+ }
+
+ var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+} else if ( "sourceIndex" in document.documentElement ) {
+ sortOrder = function( a, b ) {
+ if ( !a.sourceIndex || !b.sourceIndex ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.sourceIndex ? -1 : 1;
+ }
+
+ var ret = a.sourceIndex - b.sourceIndex;
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+} else if ( document.createRange ) {
+ sortOrder = function( a, b ) {
+ if ( !a.ownerDocument || !b.ownerDocument ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.ownerDocument ? -1 : 1;
+ }
+
+ var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();
+ aRange.setStart(a, 0);
+ aRange.setEnd(a, 0);
+ bRange.setStart(b, 0);
+ bRange.setEnd(b, 0);
+ var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange);
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+}
+
+// Utility function for retreiving the text value of an array of DOM nodes
+function getText( elems ) {
+ var ret = "", elem;
+
+ for ( var i = 0; elems[i]; i++ ) {
+ elem = elems[i];
+
+ // Get the text from text nodes and CDATA nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
+ ret += elem.nodeValue;
+
+ // Traverse everything else, except comment nodes
+ } else if ( elem.nodeType !== 8 ) {
+ ret += getText( elem.childNodes );
+ }
+ }
+
+ return ret;
+}
+
+// Check to see if the browser returns elements by name when
+// querying by getElementById (and provide a workaround)
+(function(){
+ // We're going to inject a fake input element with a specified name
+ var form = document.createElement("div"),
+ id = "script" + (new Date).getTime();
+ form.innerHTML = "<a name='" + id + "'/>";
+
+ // Inject it into the root element, check its status, and remove it quickly
+ var root = document.documentElement;
+ root.insertBefore( form, root.firstChild );
+
+ // The workaround has to do additional checks after a getElementById
+ // Which slows things down for other browsers (hence the branching)
+ if ( document.getElementById( id ) ) {
+ Expr.find.ID = function(match, context, isXML){
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+ return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
+ }
+ };
+
+ Expr.filter.ID = function(elem, match){
+ var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
+ return elem.nodeType === 1 && node && node.nodeValue === match;
+ };
+ }
+
+ root.removeChild( form );
+ root = form = null; // release memory in IE
+})();
+
+(function(){
+ // Check to see if the browser returns only elements
+ // when doing getElementsByTagName("*")
+
+ // Create a fake element
+ var div = document.createElement("div");
+ div.appendChild( document.createComment("") );
+
+ // Make sure no comments are found
+ if ( div.getElementsByTagName("*").length > 0 ) {
+ Expr.find.TAG = function(match, context){
+ var results = context.getElementsByTagName(match[1]);
+
+ // Filter out possible comments
+ if ( match[1] === "*" ) {
+ var tmp = [];
+
+ for ( var i = 0; results[i]; i++ ) {
+ if ( results[i].nodeType === 1 ) {
+ tmp.push( results[i] );
+ }
+ }
+
+ results = tmp;
+ }
+
+ return results;
+ };
+ }
+
+ // Check to see if an attribute returns normalized href attributes
+ div.innerHTML = "<a href='#'></a>";
+ if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
+ div.firstChild.getAttribute("href") !== "#" ) {
+ Expr.attrHandle.href = function(elem){
+ return elem.getAttribute("href", 2);
+ };
+ }
+
+ div = null; // release memory in IE
+})();
+
+if ( document.querySelectorAll ) {
+ (function(){
+ var oldSizzle = Sizzle, div = document.createElement("div");
+ div.innerHTML = "<p class='TEST'></p>";
+
+ // Safari can't handle uppercase or unicode characters when
+ // in quirks mode.
+ if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
+ return;
+ }
+
+ Sizzle = function(query, context, extra, seed){
+ context = context || document;
+
+ // Only use querySelectorAll on non-XML documents
+ // (ID selectors don't work in non-HTML documents)
+ if ( !seed && context.nodeType === 9 && !isXML(context) ) {
+ try {
+ return makeArray( context.querySelectorAll(query), extra );
+ } catch(e){}
+ }
+
+ return oldSizzle(query, context, extra, seed);
+ };
+
+ for ( var prop in oldSizzle ) {
+ Sizzle[ prop ] = oldSizzle[ prop ];
+ }
+
+ div = null; // release memory in IE
+ })();
+}
+
+(function(){
+ var div = document.createElement("div");
+
+ div.innerHTML = "<div class='test e'></div><div class='test'></div>";
+
+ // Opera can't find a second classname (in 9.6)
+ // Also, make sure that getElementsByClassName actually exists
+ if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
+ return;
+ }
+
+ // Safari caches class attributes, doesn't catch changes (in 3.2)
+ div.lastChild.className = "e";
+
+ if ( div.getElementsByClassName("e").length === 1 ) {
+ return;
+ }
+
+ Expr.order.splice(1, 0, "CLASS");
+ Expr.find.CLASS = function(match, context, isXML) {
+ if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
+ return context.getElementsByClassName(match[1]);
+ }
+ };
+
+ div = null; // release memory in IE
+})();
+
+function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ elem = elem[dir];
+ var match = false;
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 && !isXML ){
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+
+ if ( elem.nodeName.toLowerCase() === cur ) {
+ match = elem;
+ break;
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ elem = elem[dir];
+ var match = false;
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 ) {
+ if ( !isXML ) {
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+ if ( typeof cur !== "string" ) {
+ if ( elem === cur ) {
+ match = true;
+ break;
+ }
+
+ } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
+ match = elem;
+ break;
+ }
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+var contains = document.compareDocumentPosition ? function(a, b){
+ return a.compareDocumentPosition(b) & 16;
+} : function(a, b){
+ return a !== b && (a.contains ? a.contains(b) : true);
+};
+
+var isXML = function(elem){
+ // documentElement is verified for cases where it doesn't yet exist
+ // (such as loading iframes in IE - #4833)
+ var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
+ return documentElement ? documentElement.nodeName !== "HTML" : false;
+};
+
+var posProcess = function(selector, context){
+ var tmpSet = [], later = "", match,
+ root = context.nodeType ? [context] : context;
+
+ // Position selectors must be done after the filter
+ // And so must :not(positional) so we move all PSEUDOs to the end
+ while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
+ later += match[0];
+ selector = selector.replace( Expr.match.PSEUDO, "" );
+ }
+
+ selector = Expr.relative[selector] ? selector + "*" : selector;
+
+ for ( var i = 0, l = root.length; i < l; i++ ) {
+ Sizzle( selector, root[i], tmpSet );
+ }
+
+ return Sizzle.filter( later, tmpSet );
+};
+
+// EXPOSE
+jQuery.find = Sizzle;
+jQuery.expr = Sizzle.selectors;
+jQuery.expr[":"] = jQuery.expr.filters;
+jQuery.unique = Sizzle.uniqueSort;
+jQuery.getText = getText;
+jQuery.isXMLDoc = isXML;
+jQuery.contains = contains;
+
+return;
+
+window.Sizzle = Sizzle;
+
+})();
+var runtil = /Until$/,
+ rparentsprev = /^(?:parents|prevUntil|prevAll)/,
+ // Note: This RegExp should be improved, or likely pulled from Sizzle
+ rmultiselector = /,/,
+ slice = Array.prototype.slice;
+
+// Implement the identical functionality for filter and not
+var winnow = function( elements, qualifier, keep ) {
+ if ( jQuery.isFunction( qualifier ) ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ return !!qualifier.call( elem, i, elem ) === keep;
+ });
+
+ } else if ( qualifier.nodeType ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ return (elem === qualifier) === keep;
+ });
+
+ } else if ( typeof qualifier === "string" ) {
+ var filtered = jQuery.grep(elements, function( elem ) {
+ return elem.nodeType === 1;
+ });
+
+ if ( isSimple.test( qualifier ) ) {
+ return jQuery.filter(qualifier, filtered, !keep);
+ } else {
+ qualifier = jQuery.filter( qualifier, elements );
+ }
+ }
+
+ return jQuery.grep(elements, function( elem, i ) {
+ return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
+ });
+};
+
+jQuery.fn.extend({
+ find: function( selector ) {
+ var ret = this.pushStack( "", "find", selector ), length = 0;
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ length = ret.length;
+ jQuery.find( selector, this[i], ret );
+
+ if ( i > 0 ) {
+ // Make sure that the results are unique
+ for ( var n = length; n < ret.length; n++ ) {
+ for ( var r = 0; r < length; r++ ) {
+ if ( ret[r] === ret[n] ) {
+ ret.splice(n--, 1);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return ret;
+ },
+
+ has: function( target ) {
+ var targets = jQuery( target );
+ return this.filter(function() {
+ for ( var i = 0, l = targets.length; i < l; i++ ) {
+ if ( jQuery.contains( this, targets[i] ) ) {
+ return true;
+ }
+ }
+ });
+ },
+
+ not: function( selector ) {
+ return this.pushStack( winnow(this, selector, false), "not", selector);
+ },
+
+ filter: function( selector ) {
+ return this.pushStack( winnow(this, selector, true), "filter", selector );
+ },
+
+ is: function( selector ) {
+ return !!selector && jQuery.filter( selector, this ).length > 0;
+ },
+
+ closest: function( selectors, context ) {
+ if ( jQuery.isArray( selectors ) ) {
+ var ret = [], cur = this[0], match, matches = {}, selector;
+
+ if ( cur && selectors.length ) {
+ for ( var i = 0, l = selectors.length; i < l; i++ ) {
+ selector = selectors[i];
+
+ if ( !matches[selector] ) {
+ matches[selector] = jQuery.expr.match.POS.test( selector ) ?
+ jQuery( selector, context || this.context ) :
+ selector;
+ }
+ }
+
+ while ( cur && cur.ownerDocument && cur !== context ) {
+ for ( selector in matches ) {
+ match = matches[selector];
+
+ if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) {
+ ret.push({ selector: selector, elem: cur });
+ delete matches[selector];
+ }
+ }
+ cur = cur.parentNode;
+ }
+ }
+
+ return ret;
+ }
+
+ var pos = jQuery.expr.match.POS.test( selectors ) ?
+ jQuery( selectors, context || this.context ) : null;
+
+ return this.map(function( i, cur ) {
+ while ( cur && cur.ownerDocument && cur !== context ) {
+ if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selectors) ) {
+ return cur;
+ }
+ cur = cur.parentNode;
+ }
+ return null;
+ });
+ },
+
+ // Determine the position of an element within
+ // the matched set of elements
+ index: function( elem ) {
+ if ( !elem || typeof elem === "string" ) {
+ return jQuery.inArray( this[0],
+ // If it receives a string, the selector is used
+ // If it receives nothing, the siblings are used
+ elem ? jQuery( elem ) : this.parent().children() );
+ }
+ // Locate the position of the desired element
+ return jQuery.inArray(
+ // If it receives a jQuery object, the first element is used
+ elem.jquery ? elem[0] : elem, this );
+ },
+
+ add: function( selector, context ) {
+ var set = typeof selector === "string" ?
+ jQuery( selector, context || this.context ) :
+ jQuery.makeArray( selector ),
+ all = jQuery.merge( this.get(), set );
+
+ return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
+ all :
+ jQuery.unique( all ) );
+ },
+
+ andSelf: function() {
+ return this.add( this.prevObject );
+ }
+});
+
+// A painfully simple check to see if an element is disconnected
+// from a document (should be improved, where feasible).
+function isDisconnected( node ) {
+ return !node || !node.parentNode || node.parentNode.nodeType === 11;
+}
+
+jQuery.each({
+ parent: function( elem ) {
+ var parent = elem.parentNode;
+ return parent && parent.nodeType !== 11 ? parent : null;
+ },
+ parents: function( elem ) {
+ return jQuery.dir( elem, "parentNode" );
+ },
+ parentsUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "parentNode", until );
+ },
+ next: function( elem ) {
+ return jQuery.nth( elem, 2, "nextSibling" );
+ },
+ prev: function( elem ) {
+ return jQuery.nth( elem, 2, "previousSibling" );
+ },
+ nextAll: function( elem ) {
+ return jQuery.dir( elem, "nextSibling" );
+ },
+ prevAll: function( elem ) {
+ return jQuery.dir( elem, "previousSibling" );
+ },
+ nextUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "nextSibling", until );
+ },
+ prevUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "previousSibling", until );
+ },
+ siblings: function( elem ) {
+ return jQuery.sibling( elem.parentNode.firstChild, elem );
+ },
+ children: function( elem ) {
+ return jQuery.sibling( elem.firstChild );
+ },
+ contents: function( elem ) {
+ return jQuery.nodeName( elem, "iframe" ) ?
+ elem.contentDocument || elem.contentWindow.document :
+ jQuery.makeArray( elem.childNodes );
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function( until, selector ) {
+ var ret = jQuery.map( this, fn, until );
+
+ if ( !runtil.test( name ) ) {
+ selector = until;
+ }
+
+ if ( selector && typeof selector === "string" ) {
+ ret = jQuery.filter( selector, ret );
+ }
+
+ ret = this.length > 1 ? jQuery.unique( ret ) : ret;
+
+ if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
+ ret = ret.reverse();
+ }
+
+ return this.pushStack( ret, name, slice.call(arguments).join(",") );
+ };
+});
+
+jQuery.extend({
+ filter: function( expr, elems, not ) {
+ if ( not ) {
+ expr = ":not(" + expr + ")";
+ }
+
+ return jQuery.find.matches(expr, elems);
+ },
+
+ dir: function( elem, dir, until ) {
+ var matched = [], cur = elem[dir];
+ while ( cur && cur.nodeType !== 9 && (until === undefined || !jQuery( cur ).is( until )) ) {
+ if ( cur.nodeType === 1 ) {
+ matched.push( cur );
+ }
+ cur = cur[dir];
+ }
+ return matched;
+ },
+
+ nth: function( cur, result, dir, elem ) {
+ result = result || 1;
+ var num = 0;
+
+ for ( ; cur; cur = cur[dir] ) {
+ if ( cur.nodeType === 1 && ++num === result ) {
+ break;
+ }
+ }
+
+ return cur;
+ },
+
+ sibling: function( n, elem ) {
+ var r = [];
+
+ for ( ; n; n = n.nextSibling ) {
+ if ( n.nodeType === 1 && n !== elem ) {
+ r.push( n );
+ }
+ }
+
+ return r;
+ }
+});
+var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
+ rleadingWhitespace = /^\s+/,
+ rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g,
+ rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,
+ rtagName = /<([\w:]+)/,
+ rtbody = /<tbody/i,
+ rhtml = /<|&\w+;/,
+ fcloseTag = function( all, front, tag ) {
+ return rselfClosing.test( tag ) ?
+ all :
+ front + "></" + tag + ">";
+ },
+ wrapMap = {
+ option: [ 1, "<select multiple='multiple'>", "</select>" ],
+ legend: [ 1, "<fieldset>", "</fieldset>" ],
+ thead: [ 1, "<table>", "</table>" ],
+ tr: [ 2, "<table><tbody>", "</tbody></table>" ],
+ td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
+ col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
+ area: [ 1, "<map>", "</map>" ],
+ _default: [ 0, "", "" ]
+ };
+
+wrapMap.optgroup = wrapMap.option;
+wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
+wrapMap.th = wrapMap.td;
+
+// IE can't serialize <link> and <script> tags normally
+if ( !jQuery.support.htmlSerialize ) {
+ wrapMap._default = [ 1, "div<div>", "</div>" ];
+}
+
+jQuery.fn.extend({
+ text: function( text ) {
+ if ( jQuery.isFunction(text) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ return self.text( text.call(this, i, self.text()) );
+ });
+ }
+
+ if ( typeof text !== "object" && text !== undefined ) {
+ return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
+ }
+
+ return jQuery.getText( this );
+ },
+
+ wrapAll: function( html ) {
+ if ( jQuery.isFunction( html ) ) {
+ return this.each(function(i) {
+ jQuery(this).wrapAll( html.call(this, i) );
+ });
+ }
+
+ if ( this[0] ) {
+ // The elements to wrap the target around
+ var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
+
+ if ( this[0].parentNode ) {
+ wrap.insertBefore( this[0] );
+ }
+
+ wrap.map(function() {
+ var elem = this;
+
+ while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
+ elem = elem.firstChild;
+ }
+
+ return elem;
+ }).append(this);
+ }
+
+ return this;
+ },
+
+ wrapInner: function( html ) {
+ return this.each(function() {
+ var self = jQuery( this ), contents = self.contents();
+
+ if ( contents.length ) {
+ contents.wrapAll( html );
+
+ } else {
+ self.append( html );
+ }
+ });
+ },
+
+ wrap: function( html ) {
+ return this.each(function() {
+ jQuery( this ).wrapAll( html );
+ });
+ },
+
+ unwrap: function() {
+ return this.parent().each(function() {
+ if ( !jQuery.nodeName( this, "body" ) ) {
+ jQuery( this ).replaceWith( this.childNodes );
+ }
+ }).end();
+ },
+
+ append: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 ) {
+ this.appendChild( elem );
+ }
+ });
+ },
+
+ prepend: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 ) {
+ this.insertBefore( elem, this.firstChild );
+ }
+ });
+ },
+
+ before: function() {
+ if ( this[0] && this[0].parentNode ) {
+ return this.domManip(arguments, false, function( elem ) {
+ this.parentNode.insertBefore( elem, this );
+ });
+ } else if ( arguments.length ) {
+ var set = jQuery(arguments[0]);
+ set.push.apply( set, this.toArray() );
+ return this.pushStack( set, "before", arguments );
+ }
+ },
+
+ after: function() {
+ if ( this[0] && this[0].parentNode ) {
+ return this.domManip(arguments, false, function( elem ) {
+ this.parentNode.insertBefore( elem, this.nextSibling );
+ });
+ } else if ( arguments.length ) {
+ var set = this.pushStack( this, "after", arguments );
+ set.push.apply( set, jQuery(arguments[0]).toArray() );
+ return set;
+ }
+ },
+
+ clone: function( events ) {
+ // Do the clone
+ var ret = this.map(function() {
+ if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) {
+ // IE copies events bound via attachEvent when
+ // using cloneNode. Calling detachEvent on the
+ // clone will also remove the events from the orignal
+ // In order to get around this, we use innerHTML.
+ // Unfortunately, this means some modifications to
+ // attributes in IE that are actually only stored
+ // as properties will not be copied (such as the
+ // the name attribute on an input).
+ var html = this.outerHTML, ownerDocument = this.ownerDocument;
+ if ( !html ) {
+ var div = ownerDocument.createElement("div");
+ div.appendChild( this.cloneNode(true) );
+ html = div.innerHTML;
+ }
+
+ return jQuery.clean([html.replace(rinlinejQuery, "")
+ .replace(rleadingWhitespace, "")], ownerDocument)[0];
+ } else {
+ return this.cloneNode(true);
+ }
+ });
+
+ // Copy the events from the original to the clone
+ if ( events === true ) {
+ cloneCopyEvent( this, ret );
+ cloneCopyEvent( this.find("*"), ret.find("*") );
+ }
+
+ // Return the cloned set
+ return ret;
+ },
+
+ html: function( value ) {
+ if ( value === undefined ) {
+ return this[0] && this[0].nodeType === 1 ?
+ this[0].innerHTML.replace(rinlinejQuery, "") :
+ null;
+
+ // See if we can take a shortcut and just use innerHTML
+ } else if ( typeof value === "string" && !/<script/i.test( value ) &&
+ (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
+ !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
+
+ try {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ // Remove element nodes and prevent memory leaks
+ if ( this[i].nodeType === 1 ) {
+ cleanData( this[i].getElementsByTagName("*") );
+ this[i].innerHTML = value;
+ }
+ }
+
+ // If using innerHTML throws an exception, use the fallback method
+ } catch(e) {
+ this.empty().append( value );
+ }
+
+ } else if ( jQuery.isFunction( value ) ) {
+ this.each(function(i){
+ var self = jQuery(this), old = self.html();
+ self.empty().append(function(){
+ return value.call( this, i, old );
+ });
+ });
+
+ } else {
+ this.empty().append( value );
+ }
+
+ return this;
+ },
+
+ replaceWith: function( value ) {
+ if ( this[0] && this[0].parentNode ) {
+ // Make sure that the elements are removed from the DOM before they are inserted
+ // this can help fix replacing a parent with child elements
+ if ( !jQuery.isFunction( value ) ) {
+ value = jQuery( value ).detach();
+ }
+
+ return this.each(function() {
+ var next = this.nextSibling, parent = this.parentNode;
+
+ jQuery(this).remove();
+
+ if ( next ) {
+ jQuery(next).before( value );
+ } else {
+ jQuery(parent).append( value );
+ }
+ });
+ } else {
+ return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value );
+ }
+ },
+
+ detach: function( selector ) {
+ return this.remove( selector, true );
+ },
+
+ domManip: function( args, table, callback ) {
+ var results, first, value = args[0], scripts = [];
+
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ args[0] = value.call(this, i, table ? self.html() : undefined);
+ return self.domManip( args, table, callback );
+ });
+ }
+
+ if ( this[0] ) {
+ // If we're in a fragment, just use that instead of building a new one
+ if ( args[0] && args[0].parentNode && args[0].parentNode.nodeType === 11 ) {
+ results = { fragment: args[0].parentNode };
+ } else {
+ results = buildFragment( args, this, scripts );
+ }
+
+ first = results.fragment.firstChild;
+
+ if ( first ) {
+ table = table && jQuery.nodeName( first, "tr" );
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ callback.call(
+ table ?
+ root(this[i], first) :
+ this[i],
+ results.cacheable || this.length > 1 || i > 0 ?
+ results.fragment.cloneNode(true) :
+ results.fragment
+ );
+ }
+ }
+
+ if ( scripts ) {
+ jQuery.each( scripts, evalScript );
+ }
+ }
+
+ return this;
+
+ function root( elem, cur ) {
+ return jQuery.nodeName(elem, "table") ?
+ (elem.getElementsByTagName("tbody")[0] ||
+ elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
+ elem;
+ }
+ }
+});
+
+function cloneCopyEvent(orig, ret) {
+ var i = 0;
+
+ ret.each(function() {
+ if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) {
+ return;
+ }
+
+ var oldData = jQuery.data( orig[i++] ), curData = jQuery.data( this, oldData ), events = oldData && oldData.events;
+
+ if ( events ) {
+ delete curData.handle;
+ curData.events = {};
+
+ for ( var type in events ) {
+ for ( var handler in events[ type ] ) {
+ jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data );
+ }
+ }
+ }
+ });
+}
+
+function buildFragment( args, nodes, scripts ) {
+ var fragment, cacheable, cached, cacheresults, doc;
+
+ if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) {
+ cacheable = true;
+ cacheresults = jQuery.fragments[ args[0] ];
+ if ( cacheresults ) {
+ if ( cacheresults !== 1 ) {
+ fragment = cacheresults;
+ }
+ cached = true;
+ }
+ }
+
+ if ( !fragment ) {
+ doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
+ fragment = doc.createDocumentFragment();
+ jQuery.clean( args, doc, fragment, scripts );
+ }
+
+ if ( cacheable ) {
+ jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
+ }
+
+ return { fragment: fragment, cacheable: cacheable };
+}
+
+jQuery.fragments = {};
+
+jQuery.each({
+ appendTo: "append",
+ prependTo: "prepend",
+ insertBefore: "before",
+ insertAfter: "after",
+ replaceAll: "replaceWith"
+}, function( name, original ) {
+ jQuery.fn[ name ] = function( selector ) {
+ var ret = [], insert = jQuery( selector );
+
+ for ( var i = 0, l = insert.length; i < l; i++ ) {
+ var elems = (i > 0 ? this.clone(true) : this).get();
+ jQuery.fn[ original ].apply( jQuery(insert[i]), elems );
+ ret = ret.concat( elems );
+ }
+ return this.pushStack( ret, name, insert.selector );
+ };
+});
+
+jQuery.each({
+ // keepData is for internal use only--do not document
+ remove: function( selector, keepData ) {
+ if ( !selector || jQuery.filter( selector, [ this ] ).length ) {
+ if ( !keepData && this.nodeType === 1 ) {
+ cleanData( this.getElementsByTagName("*") );
+ cleanData( [ this ] );
+ }
+
+ if ( this.parentNode ) {
+ this.parentNode.removeChild( this );
+ }
+ }
+ },
+
+ empty: function() {
+ // Remove element nodes and prevent memory leaks
+ if ( this.nodeType === 1 ) {
+ cleanData( this.getElementsByTagName("*") );
+ }
+
+ // Remove any remaining nodes
+ while ( this.firstChild ) {
+ this.removeChild( this.firstChild );
+ }
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function() {
+ return this.each( fn, arguments );
+ };
+});
+
+jQuery.extend({
+ clean: function( elems, context, fragment, scripts ) {
+ context = context || document;
+
+ // !context.createElement fails in IE with an error but returns typeof 'object'
+ if ( typeof context.createElement === "undefined" ) {
+ context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
+ }
+
+ var ret = [];
+
+ jQuery.each(elems, function( i, elem ) {
+ if ( typeof elem === "number" ) {
+ elem += "";
+ }
+
+ if ( !elem ) {
+ return;
+ }
+
+ // Convert html string into DOM nodes
+ if ( typeof elem === "string" && !rhtml.test( elem ) ) {
+ elem = context.createTextNode( elem );
+
+ } else if ( typeof elem === "string" ) {
+ // Fix "XHTML"-style tags in all browsers
+ elem = elem.replace(rxhtmlTag, fcloseTag);
+
+ // Trim whitespace, otherwise indexOf won't work as expected
+ var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
+ wrap = wrapMap[ tag ] || wrapMap._default,
+ depth = wrap[0],
+ div = context.createElement("div");
+
+ // Go to html and back, then peel off extra wrappers
+ div.innerHTML = wrap[1] + elem + wrap[2];
+
+ // Move to the right depth
+ while ( depth-- ) {
+ div = div.lastChild;
+ }
+
+ // Remove IE's autoinserted <tbody> from table fragments
+ if ( !jQuery.support.tbody ) {
+
+ // String was a <table>, *may* have spurious <tbody>
+ var hasBody = rtbody.test(elem),
+ tbody = tag === "table" && !hasBody ?
+ div.firstChild && div.firstChild.childNodes :
+
+ // String was a bare <thead> or <tfoot>
+ wrap[1] === "<table>" && !hasBody ?
+ div.childNodes :
+ [];
+
+ for ( var j = tbody.length - 1; j >= 0 ; --j ) {
+ if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
+ tbody[ j ].parentNode.removeChild( tbody[ j ] );
+ }
+ }
+
+ }
+
+ // IE completely kills leading whitespace when innerHTML is used
+ if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
+ div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
+ }
+
+ elem = jQuery.makeArray( div.childNodes );
+ }
+
+ if ( elem.nodeType ) {
+ ret.push( elem );
+ } else {
+ ret = jQuery.merge( ret, elem );
+ }
+
+ });
+
+ if ( fragment ) {
+ for ( var i = 0; ret[i]; i++ ) {
+ if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
+ scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
+ } else {
+ if ( ret[i].nodeType === 1 ) {
+ ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
+ }
+ fragment.appendChild( ret[i] );
+ }
+ }
+ }
+
+ return ret;
+ }
+});
+
+function cleanData( elems ) {
+ for ( var i = 0, elem, id; (elem = elems[i]) != null; i++ ) {
+ if ( !jQuery.noData[elem.nodeName.toLowerCase()] && (id = elem[expando]) ) {
+ delete jQuery.cache[ id ];
+ }
+ }
+}
+// exclude the following css properties to add px
+var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
+ ralpha = /alpha\([^)]*\)/,
+ ropacity = /opacity=([^)]*)/,
+ rfloat = /float/i,
+ rdashAlpha = /-([a-z])/ig,
+ rupper = /([A-Z])/g,
+ rnumpx = /^-?\d+(?:px)?$/i,
+ rnum = /^-?\d/,
+
+ cssShow = { position: "absolute", visibility: "hidden", display:"block" },
+ cssWidth = [ "Left", "Right" ],
+ cssHeight = [ "Top", "Bottom" ],
+
+ // cache check for defaultView.getComputedStyle
+ getComputedStyle = document.defaultView && document.defaultView.getComputedStyle,
+ // normalize float css property
+ styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat",
+ fcamelCase = function( all, letter ) {
+ return letter.toUpperCase();
+ };
+
+jQuery.fn.css = function( name, value ) {
+ return access( this, name, value, true, function( elem, name, value ) {
+ if ( value === undefined ) {
+ return jQuery.curCSS( elem, name );
+ }
+
+ if ( typeof value === "number" && !rexclude.test(name) ) {
+ value += "px";
+ }
+
+ jQuery.style( elem, name, value );
+ });
+};
+
+jQuery.extend({
+ style: function( elem, name, value ) {
+ // don't set styles on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ // ignore negative width and height values #1599
+ if ( (name === "width" || name === "height") && parseFloat(value) < 0 ) {
+ value = undefined;
+ }
+
+ var style = elem.style || elem, set = value !== undefined;
+
+ // IE uses filters for opacity
+ if ( !jQuery.support.opacity && name === "opacity" ) {
+ if ( set ) {
+ // IE has trouble with opacity if it does not have layout
+ // Force it by setting the zoom level
+ style.zoom = 1;
+
+ // Set the alpha filter to set the opacity
+ var opacity = parseInt( value, 10 ) + "" === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")";
+ var filter = style.filter || jQuery.curCSS( elem, "filter" ) || "";
+ style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : opacity;
+ }
+
+ return style.filter && style.filter.indexOf("opacity=") >= 0 ?
+ (parseFloat( ropacity.exec(style.filter)[1] ) / 100) + "":
+ "";
+ }
+
+ // Make sure we're using the right name for getting the float value
+ if ( rfloat.test( name ) ) {
+ name = styleFloat;
+ }
+
+ name = name.replace(rdashAlpha, fcamelCase);
+
+ if ( set ) {
+ style[ name ] = value;
+ }
+
+ return style[ name ];
+ },
+
+ css: function( elem, name, force, extra ) {
+ if ( name === "width" || name === "height" ) {
+ var val, props = cssShow, which = name === "width" ? cssWidth : cssHeight;
+
+ function getWH() {
+ val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
+
+ if ( extra === "border" ) {
+ return;
+ }
+
+ jQuery.each( which, function() {
+ if ( !extra ) {
+ val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
+ }
+
+ if ( extra === "margin" ) {
+ val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0;
+ } else {
+ val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
+ }
+ });
+ }
+
+ if ( elem.offsetWidth !== 0 ) {
+ getWH();
+ } else {
+ jQuery.swap( elem, props, getWH );
+ }
+
+ return Math.max(0, Math.round(val));
+ }
+
+ return jQuery.curCSS( elem, name, force );
+ },
+
+ curCSS: function( elem, name, force ) {
+ var ret, style = elem.style, filter;
+
+ // IE uses filters for opacity
+ if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) {
+ ret = ropacity.test(elem.currentStyle.filter || "") ?
+ (parseFloat(RegExp.$1) / 100) + "" :
+ "";
+
+ return ret === "" ?
+ "1" :
+ ret;
+ }
+
+ // Make sure we're using the right name for getting the float value
+ if ( rfloat.test( name ) ) {
+ name = styleFloat;
+ }
+
+ if ( !force && style && style[ name ] ) {
+ ret = style[ name ];
+
+ } else if ( getComputedStyle ) {
+
+ // Only "float" is needed here
+ if ( rfloat.test( name ) ) {
+ name = "float";
+ }
+
+ name = name.replace( rupper, "-$1" ).toLowerCase();
+
+ var defaultView = elem.ownerDocument.defaultView;
+
+ if ( !defaultView ) {
+ return null;
+ }
+
+ var computedStyle = defaultView.getComputedStyle( elem, null );
+
+ if ( computedStyle ) {
+ ret = computedStyle.getPropertyValue( name );
+ }
+
+ // We should always get a number back from opacity
+ if ( name === "opacity" && ret === "" ) {
+ ret = "1";
+ }
+
+ } else if ( elem.currentStyle ) {
+ var camelCase = name.replace(rdashAlpha, fcamelCase);
+
+ ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
+
+ // From the awesome hack by Dean Edwards
+ // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
+
+ // If we're not dealing with a regular pixel number
+ // but a number that has a weird ending, we need to convert it to pixels
+ if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
+ // Remember the original values
+ var left = style.left, rsLeft = elem.runtimeStyle.left;
+
+ // Put in the new values to get a computed value out
+ elem.runtimeStyle.left = elem.currentStyle.left;
+ style.left = camelCase === "fontSize" ? "1em" : (ret || 0);
+ ret = style.pixelLeft + "px";
+
+ // Revert the changed values
+ style.left = left;
+ elem.runtimeStyle.left = rsLeft;
+ }
+ }
+
+ return ret;
+ },
+
+ // A method for quickly swapping in/out CSS properties to get correct calculations
+ swap: function( elem, options, callback ) {
+ var old = {};
+
+ // Remember the old values, and insert the new ones
+ for ( var name in options ) {
+ old[ name ] = elem.style[ name ];
+ elem.style[ name ] = options[ name ];
+ }
+
+ callback.call( elem );
+
+ // Revert the old values
+ for ( var name in options ) {
+ elem.style[ name ] = old[ name ];
+ }
+ }
+});
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.hidden = function( elem ) {
+ var width = elem.offsetWidth, height = elem.offsetHeight,
+ skip = elem.nodeName.toLowerCase() === "tr";
+
+ return width === 0 && height === 0 && !skip ?
+ true :
+ width > 0 && height > 0 && !skip ?
+ false :
+ jQuery.curCSS(elem, "display") === "none";
+ };
+
+ jQuery.expr.filters.visible = function( elem ) {
+ return !jQuery.expr.filters.hidden( elem );
+ };
+}
+var jsc = now(),
+ rscript = /<script(.|\s)*?\/script>/gi,
+ rselectTextarea = /select|textarea/i,
+ rinput = /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,
+ jsre = /=\?(&|$)/,
+ rquery = /\?/,
+ rts = /(\?|&)_=.*?(&|$)/,
+ rurl = /^(\w+:)?\/\/([^\/?#]+)/,
+ r20 = /%20/g;
+
+jQuery.fn.extend({
+ // Keep a copy of the old load
+ _load: jQuery.fn.load,
+
+ load: function( url, params, callback ) {
+ if ( typeof url !== "string" ) {
+ return this._load( url );
+
+ // Don't do a request if no elements are being requested
+ } else if ( !this.length ) {
+ return this;
+ }
+
+ var off = url.indexOf(" ");
+ if ( off >= 0 ) {
+ var selector = url.slice(off, url.length);
+ url = url.slice(0, off);
+ }
+
+ // Default to a GET request
+ var type = "GET";
+
+ // If the second parameter was provided
+ if ( params ) {
+ // If it's a function
+ if ( jQuery.isFunction( params ) ) {
+ // We assume that it's the callback
+ callback = params;
+ params = null;
+
+ // Otherwise, build a param string
+ } else if ( typeof params === "object" ) {
+ params = jQuery.param( params, jQuery.ajaxSettings.traditional );
+ type = "POST";
+ }
+ }
+
+ // Request the remote document
+ jQuery.ajax({
+ url: url,
+ type: type,
+ dataType: "html",
+ data: params,
+ context:this,
+ complete: function( res, status ) {
+ // If successful, inject the HTML into all the matched elements
+ if ( status === "success" || status === "notmodified" ) {
+ // See if a selector was specified
+ this.html( selector ?
+ // Create a dummy div to hold the results
+ jQuery("<div />")
+ // inject the contents of the document in, removing the scripts
+ // to avoid any 'Permission Denied' errors in IE
+ .append(res.responseText.replace(rscript, ""))
+
+ // Locate the specified elements
+ .find(selector) :
+
+ // If not, just inject the full result
+ res.responseText );
+ }
+
+ if ( callback ) {
+ this.each( callback, [res.responseText, status, res] );
+ }
+ }
+ });
+
+ return this;
+ },
+
+ serialize: function() {
+ return jQuery.param(this.serializeArray());
+ },
+ serializeArray: function() {
+ return this.map(function() {
+ return this.elements ? jQuery.makeArray(this.elements) : this;
+ })
+ .filter(function() {
+ return this.name && !this.disabled &&
+ (this.checked || rselectTextarea.test(this.nodeName) ||
+ rinput.test(this.type));
+ })
+ .map(function( i, elem ) {
+ var val = jQuery(this).val();
+
+ return val == null ?
+ null :
+ jQuery.isArray(val) ?
+ jQuery.map( val, function( val, i ) {
+ return { name: elem.name, value: val };
+ }) :
+ { name: elem.name, value: val };
+ }).get();
+ }
+});
+
+// Attach a bunch of functions for handling common AJAX events
+jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function( i, o ) {
+ jQuery.fn[o] = function( f ) {
+ return this.bind(o, f);
+ };
+});
+
+jQuery.extend({
+
+ get: function( url, data, callback, type ) {
+ // shift arguments if data argument was omited
+ if ( jQuery.isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = null;
+ }
+
+ return jQuery.ajax({
+ type: "GET",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ getScript: function( url, callback ) {
+ return jQuery.get(url, null, callback, "script");
+ },
+
+ getJSON: function( url, data, callback ) {
+ return jQuery.get(url, data, callback, "json");
+ },
+
+ post: function( url, data, callback, type ) {
+ // shift arguments if data argument was omited
+ if ( jQuery.isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = {};
+ }
+
+ return jQuery.ajax({
+ type: "POST",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ ajaxSetup: function( settings ) {
+ jQuery.extend( jQuery.ajaxSettings, settings );
+ },
+
+ ajaxSettings: {
+ url: location.href,
+ global: true,
+ type: "GET",
+ contentType: "application/x-www-form-urlencoded",
+ processData: true,
+ async: true,
+ /*
+ timeout: 0,
+ data: null,
+ username: null,
+ password: null,
+ traditional: false,
+ */
+ // Create the request object; Microsoft failed to properly
+ // implement the XMLHttpRequest in IE7 (can't request local files),
+ // so we use the ActiveXObject when it is available
+ // This function can be overriden by calling jQuery.ajaxSetup
+ xhr: window.XMLHttpRequest && (window.location.protocol !== "file:" || !window.ActiveXObject) ?
+ function() {
+ return new window.XMLHttpRequest();
+ } :
+ function() {
+ try {
+ return new window.ActiveXObject("Microsoft.XMLHTTP");
+ } catch(e) {}
+ },
+ accepts: {
+ xml: "application/xml, text/xml",
+ html: "text/html",
+ script: "text/javascript, application/javascript",
+ json: "application/json, text/javascript",
+ text: "text/plain",
+ _default: "*/*"
+ }
+ },
+
+ // Last-Modified header cache for next request
+ lastModified: {},
+ etag: {},
+
+ ajax: function( origSettings ) {
+ var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings);
+
+ var jsonp, status, data,
+ callbackContext = s.context || s,
+ type = s.type.toUpperCase();
+
+ // convert data if not already a string
+ if ( s.data && s.processData && typeof s.data !== "string" ) {
+ s.data = jQuery.param( s.data, s.traditional );
+ }
+
+ // Handle JSONP Parameter Callbacks
+ if ( s.dataType === "jsonp" ) {
+ if ( type === "GET" ) {
+ if ( !jsre.test( s.url ) ) {
+ s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?";
+ }
+ } else if ( !s.data || !jsre.test(s.data) ) {
+ s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
+ }
+ s.dataType = "json";
+ }
+
+ // Build temporary JSONP function
+ if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) {
+ jsonp = s.jsonpCallback || ("jsonp" + jsc++);
+
+ // Replace the =? sequence both in the query string and the data
+ if ( s.data ) {
+ s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
+ }
+
+ s.url = s.url.replace(jsre, "=" + jsonp + "$1");
+
+ // We need to make sure
+ // that a JSONP style response is executed properly
+ s.dataType = "script";
+
+ // Handle JSONP-style loading
+ window[ jsonp ] = window[ jsonp ] || function( tmp ) {
+ data = tmp;
+ success();
+ complete();
+ // Garbage collect
+ window[ jsonp ] = undefined;
+
+ try {
+ delete window[ jsonp ];
+ } catch(e) {}
+
+ if ( head ) {
+ head.removeChild( script );
+ }
+ };
+ }
+
+ if ( s.dataType === "script" && s.cache === null ) {
+ s.cache = false;
+ }
+
+ if ( s.cache === false && type === "GET" ) {
+ var ts = now();
+
+ // try replacing _= if it is there
+ var ret = s.url.replace(rts, "$1_=" + ts + "$2");
+
+ // if nothing was replaced, add timestamp to the end
+ s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : "");
+ }
+
+ // If data is available, append data to url for get requests
+ if ( s.data && type === "GET" ) {
+ s.url += (rquery.test(s.url) ? "&" : "?") + s.data;
+ }
+
+ // Watch for a new set of requests
+ if ( s.global && ! jQuery.active++ ) {
+ jQuery.event.trigger( "ajaxStart" );
+ }
+
+ // Matches an absolute URL, and saves the domain
+ var parts = rurl.exec( s.url ),
+ remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host);
+
+ // If we're requesting a remote document
+ // and trying to load JSON or Script with a GET
+ if ( s.dataType === "script" && type === "GET" && remote ) {
+ var head = document.getElementsByTagName("head")[0] || document.documentElement;
+ var script = document.createElement("script");
+ script.src = s.url;
+ if ( s.scriptCharset ) {
+ script.charset = s.scriptCharset;
+ }
+
+ // Handle Script loading
+ if ( !jsonp ) {
+ var done = false;
+
+ // Attach handlers for all browsers
+ script.onload = script.onreadystatechange = function() {
+ if ( !done && (!this.readyState ||
+ this.readyState === "loaded" || this.readyState === "complete") ) {
+ done = true;
+ success();
+ complete();
+
+ // Handle memory leak in IE
+ script.onload = script.onreadystatechange = null;
+ if ( head && script.parentNode ) {
+ head.removeChild( script );
+ }
+ }
+ };
+ }
+
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709 and #4378).
+ head.insertBefore( script, head.firstChild );
+
+ // We handle everything using the script element injection
+ return undefined;
+ }
+
+ var requestDone = false;
+
+ // Create the request object
+ var xhr = s.xhr();
+
+ if ( !xhr ) {
+ return;
+ }
+
+ // Open the socket
+ // Passing null username, generates a login popup on Opera (#2865)
+ if ( s.username ) {
+ xhr.open(type, s.url, s.async, s.username, s.password);
+ } else {
+ xhr.open(type, s.url, s.async);
+ }
+
+ // Need an extra try/catch for cross domain requests in Firefox 3
+ try {
+ // Set the correct header, if data is being sent
+ if ( s.data || origSettings && origSettings.contentType ) {
+ xhr.setRequestHeader("Content-Type", s.contentType);
+ }
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if ( s.ifModified ) {
+ if ( jQuery.lastModified[s.url] ) {
+ xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]);
+ }
+
+ if ( jQuery.etag[s.url] ) {
+ xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]);
+ }
+ }
+
+ // Set header so the called script knows that it's an XMLHttpRequest
+ // Only send the header if it's not a remote XHR
+ if ( !remote ) {
+ xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+ }
+
+ // Set the Accepts header for the server, depending on the dataType
+ xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ?
+ s.accepts[ s.dataType ] + ", */*" :
+ s.accepts._default );
+ } catch(e) {}
+
+ // Allow custom headers/mimetypes and early abort
+ if ( s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false ) {
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active ) {
+ jQuery.event.trigger( "ajaxStop" );
+ }
+
+ // close opended socket
+ xhr.abort();
+ return false;
+ }
+
+ if ( s.global ) {
+ trigger("ajaxSend", [xhr, s]);
+ }
+
+ // Wait for a response to come back
+ var onreadystatechange = xhr.onreadystatechange = function( isTimeout ) {
+ // The request was aborted
+ if ( !xhr || xhr.readyState === 0 ) {
+ // Opera doesn't call onreadystatechange before this point
+ // so we simulate the call
+ if ( !requestDone ) {
+ complete();
+ }
+
+ requestDone = true;
+ if ( xhr ) {
+ xhr.onreadystatechange = jQuery.noop;
+ }
+
+ // The transfer is complete and the data is available, or the request timed out
+ } else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) {
+ requestDone = true;
+ xhr.onreadystatechange = jQuery.noop;
+
+ status = isTimeout === "timeout" ?
+ "timeout" :
+ !jQuery.httpSuccess( xhr ) ?
+ "error" :
+ s.ifModified && jQuery.httpNotModified( xhr, s.url ) ?
+ "notmodified" :
+ "success";
+
+ if ( status === "success" ) {
+ // Watch for, and catch, XML document parse errors
+ try {
+ // process the data (runs the xml through httpData regardless of callback)
+ data = jQuery.httpData( xhr, s.dataType, s );
+ } catch(e) {
+ status = "parsererror";
+ }
+ }
+
+ // Make sure that the request was successful or notmodified
+ if ( status === "success" || status === "notmodified" ) {
+ // JSONP handles its own success callback
+ if ( !jsonp ) {
+ success();
+ }
+ } else {
+ jQuery.handleError(s, xhr, status);
+ }
+
+ // Fire the complete handlers
+ complete();
+
+ if ( isTimeout === "timeout" ) {
+ xhr.abort();
+ }
+
+ // Stop memory leaks
+ if ( s.async ) {
+ xhr = null;
+ }
+ }
+ };
+
+ // Override the abort handler, if we can (IE doesn't allow it, but that's OK)
+ // Opera doesn't fire onreadystatechange at all on abort
+ try {
+ var oldAbort = xhr.abort;
+ xhr.abort = function() {
+ if ( xhr ) {
+ oldAbort.call( xhr );
+ if ( xhr ) {
+ xhr.readyState = 0;
+ }
+ }
+
+ onreadystatechange();
+ };
+ } catch(e) { }
+
+ // Timeout checker
+ if ( s.async && s.timeout > 0 ) {
+ setTimeout(function() {
+ // Check to see if the request is still happening
+ if ( xhr && !requestDone ) {
+ onreadystatechange( "timeout" );
+ }
+ }, s.timeout);
+ }
+
+ // Send the data
+ try {
+ xhr.send( type === "POST" || type === "PUT" || type === "DELETE" ? s.data : null );
+ } catch(e) {
+ jQuery.handleError(s, xhr, null, e);
+ // Fire the complete handlers
+ complete();
+ }
+
+ // firefox 1.5 doesn't fire statechange for sync requests
+ if ( !s.async ) {
+ onreadystatechange();
+ }
+
+ function success() {
+ // If a local callback was specified, fire it and pass it the data
+ if ( s.success ) {
+ s.success.call( callbackContext, data, status, xhr );
+ }
+
+ // Fire the global callback
+ if ( s.global ) {
+ trigger( "ajaxSuccess", [xhr, s] );
+ }
+ }
+
+ function complete() {
+ // Process result
+ if ( s.complete ) {
+ s.complete.call( callbackContext, xhr, status);
+ }
+
+ // The request was completed
+ if ( s.global ) {
+ trigger( "ajaxComplete", [xhr, s] );
+ }
+
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active ) {
+ jQuery.event.trigger( "ajaxStop" );
+ }
+ }
+
+ function trigger(type, args) {
+ (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args);
+ }
+
+ // return XMLHttpRequest to allow aborting the request etc.
+ return xhr;
+ },
+
+ handleError: function( s, xhr, status, e ) {
+ // If a local callback was specified, fire it
+ if ( s.error ) {
+ s.error.call( s.context || window, xhr, status, e );
+ }
+
+ // Fire the global callback
+ if ( s.global ) {
+ (s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] );
+ }
+ },
+
+ // Counter for holding the number of active queries
+ active: 0,
+
+ // Determines if an XMLHttpRequest was successful or not
+ httpSuccess: function( xhr ) {
+ try {
+ // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
+ return !xhr.status && location.protocol === "file:" ||
+ // Opera returns 0 when status is 304
+ ( xhr.status >= 200 && xhr.status < 300 ) ||
+ xhr.status === 304 || xhr.status === 1223 || xhr.status === 0;
+ } catch(e) {}
+
+ return false;
+ },
+
+ // Determines if an XMLHttpRequest returns NotModified
+ httpNotModified: function( xhr, url ) {
+ var lastModified = xhr.getResponseHeader("Last-Modified"),
+ etag = xhr.getResponseHeader("Etag");
+
+ if ( lastModified ) {
+ jQuery.lastModified[url] = lastModified;
+ }
+
+ if ( etag ) {
+ jQuery.etag[url] = etag;
+ }
+
+ // Opera returns 0 when status is 304
+ return xhr.status === 304 || xhr.status === 0;
+ },
+
+ httpData: function( xhr, type, s ) {
+ var ct = xhr.getResponseHeader("content-type") || "",
+ xml = type === "xml" || !type && ct.indexOf("xml") >= 0,
+ data = xml ? xhr.responseXML : xhr.responseText;
+
+ if ( xml && data.documentElement.nodeName === "parsererror" ) {
+ throw "parsererror";
+ }
+
+ // Allow a pre-filtering function to sanitize the response
+ // s is checked to keep backwards compatibility
+ if ( s && s.dataFilter ) {
+ data = s.dataFilter( data, type );
+ }
+
+ // The filter can actually parse the response
+ if ( typeof data === "string" ) {
+ // Get the JavaScript object, if JSON is used.
+ if ( type === "json" || !type && ct.indexOf("json") >= 0 ) {
+ // Make sure the incoming data is actual JSON
+ // Logic borrowed from http://json.org/json2.js
+ if (/^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]")
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ""))) {
+
+ // Try to use the native JSON parser first
+ if ( window.JSON && window.JSON.parse ) {
+ data = window.JSON.parse( data );
+
+ } else {
+ data = (new Function("return " + data))();
+ }
+
+ } else {
+ throw "Invalid JSON: " + data;
+ }
+
+ // If the type is "script", eval it in global context
+ } else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) {
+ jQuery.globalEval( data );
+ }
+ }
+
+ return data;
+ },
+
+ // Serialize an array of form elements or a set of
+ // key/values into a query string
+ param: function( a, traditional ) {
+
+ var s = [];
+
+ // Set traditional to true for jQuery <= 1.3.2 behavior.
+ if ( traditional === undefined ) {
+ traditional = jQuery.ajaxSettings.traditional;
+ }
+
+ function add( key, value ) {
+ // If value is a function, invoke it and return its value
+ value = jQuery.isFunction(value) ? value() : value;
+ s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
+ }
+
+ // If an array was passed in, assume that it is an array of form elements.
+ if ( jQuery.isArray(a) || a.jquery ) {
+ // Serialize the form elements
+ jQuery.each( a, function() {
+ add( this.name, this.value );
+ });
+
+ } else {
+ // If traditional, encode the "old" way (the way 1.3.2 or older
+ // did it), otherwise encode params recursively.
+ jQuery.each( a, function buildParams( prefix, obj ) {
+
+ if ( jQuery.isArray(obj) ) {
+ // Serialize array item.
+ jQuery.each( obj, function( i, v ) {
+ if ( traditional ) {
+ // Treat each array item as a scalar.
+ add( prefix, v );
+ } else {
+ // If array item is non-scalar (array or object), encode its
+ // numeric index to resolve deserialization ambiguity issues.
+ // Note that rack (as of 1.0.0) can't currently deserialize
+ // nested arrays properly, and attempting to do so may cause
+ // a server error. Possible fixes are to modify rack's
+ // deserialization algorithm or to provide an option or flag
+ // to force array serialization to be shallow.
+ buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v );
+ }
+ });
+
+ } else if ( !traditional && obj != null && typeof obj === "object" ) {
+ // Serialize object item.
+ jQuery.each( obj, function( k, v ) {
+ buildParams( prefix + "[" + k + "]", v );
+ });
+
+ } else {
+ // Serialize scalar item.
+ add( prefix, obj );
+ }
+ });
+ }
+
+ // Return the resulting serialization
+ return s.join("&").replace(r20, "+");
+ }
+
+});
+var elemdisplay = {},
+ rfxtypes = /toggle|show|hide/,
+ rfxnum = /^([+-]=)?([\d+-.]+)(.*)$/,
+ timerId,
+ fxAttrs = [
+ // height animations
+ [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
+ // width animations
+ [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
+ // opacity animations
+ [ "opacity" ]
+ ];
+
+jQuery.fn.extend({
+ show: function( speed, callback ) {
+ if ( speed != null ) {
+ return this.animate( genFx("show", 3), speed, callback);
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var old = jQuery.data(this[i], "olddisplay");
+
+ this[i].style.display = old || "";
+
+ if ( jQuery.css(this[i], "display") === "none" ) {
+ var nodeName = this[i].nodeName, display;
+
+ if ( elemdisplay[ nodeName ] ) {
+ display = elemdisplay[ nodeName ];
+
+ } else {
+ var elem = jQuery("<" + nodeName + " />").appendTo("body");
+
+ display = elem.css("display");
+
+ if ( display === "none" ) {
+ display = "block";
+ }
+
+ elem.remove();
+
+ elemdisplay[ nodeName ] = display;
+ }
+
+ jQuery.data(this[i], "olddisplay", display);
+ }
+ }
+
+ // Set the display of the elements in a second loop
+ // to avoid the constant reflow
+ for ( var j = 0, k = this.length; j < k; j++ ) {
+ this[j].style.display = jQuery.data(this[j], "olddisplay") || "";
+ }
+
+ return this;
+ }
+ },
+
+ hide: function( speed, callback ) {
+ if ( speed != null ) {
+ return this.animate( genFx("hide", 3), speed, callback);
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var old = jQuery.data(this[i], "olddisplay");
+ if ( !old && old !== "none" ) {
+ jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display"));
+ }
+ }
+
+ // Set the display of the elements in a second loop
+ // to avoid the constant reflow
+ for ( var j = 0, k = this.length; j < k; j++ ) {
+ this[j].style.display = "none";
+ }
+
+ return this;
+ }
+ },
+
+ // Save the old toggle function
+ _toggle: jQuery.fn.toggle,
+
+ toggle: function( fn, fn2 ) {
+ var bool = typeof fn === "boolean";
+
+ if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
+ this._toggle.apply( this, arguments );
+
+ } else if ( fn == null || bool ) {
+ this.each(function() {
+ var state = bool ? fn : jQuery(this).is(":hidden");
+ jQuery(this)[ state ? "show" : "hide" ]();
+ });
+
+ } else {
+ this.animate(genFx("toggle", 3), fn, fn2);
+ }
+
+ return this;
+ },
+
+ fadeTo: function( speed, to, callback ) {
+ return this.filter(":hidden").css("opacity", 0).show().end()
+ .animate({opacity: to}, speed, callback);
+ },
+
+ animate: function( prop, speed, easing, callback ) {
+ var optall = jQuery.speed(speed, easing, callback);
+
+ if ( jQuery.isEmptyObject( prop ) ) {
+ return this.each( optall.complete );
+ }
+
+ return this[ optall.queue === false ? "each" : "queue" ](function() {
+ var opt = jQuery.extend({}, optall), p,
+ hidden = this.nodeType === 1 && jQuery(this).is(":hidden"),
+ self = this;
+
+ for ( p in prop ) {
+ var name = p.replace(rdashAlpha, fcamelCase);
+
+ if ( p !== name ) {
+ prop[ name ] = prop[ p ];
+ delete prop[ p ];
+ p = name;
+ }
+
+ if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
+ return opt.complete.call(this);
+ }
+
+ if ( ( p === "height" || p === "width" ) && this.style ) {
+ // Store display property
+ opt.display = jQuery.css(this, "display");
+
+ // Make sure that nothing sneaks out
+ opt.overflow = this.style.overflow;
+ }
+
+ if ( jQuery.isArray( prop[p] ) ) {
+ // Create (if needed) and add to specialEasing
+ (opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1];
+ prop[p] = prop[p][0];
+ }
+ }
+
+ if ( opt.overflow != null ) {
+ this.style.overflow = "hidden";
+ }
+
+ opt.curAnim = jQuery.extend({}, prop);
+
+ jQuery.each( prop, function( name, val ) {
+ var e = new jQuery.fx( self, opt, name );
+
+ if ( rfxtypes.test(val) ) {
+ e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop );
+
+ } else {
+ var parts = rfxnum.exec(val),
+ start = e.cur(true) || 0;
+
+ if ( parts ) {
+ var end = parseFloat( parts[2] ),
+ unit = parts[3] || "px";
+
+ // We need to compute starting value
+ if ( unit !== "px" ) {
+ self.style[ name ] = (end || 1) + unit;
+ start = ((end || 1) / e.cur(true)) * start;
+ self.style[ name ] = start + unit;
+ }
+
+ // If a +=/-= token was provided, we're doing a relative animation
+ if ( parts[1] ) {
+ end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
+ }
+
+ e.custom( start, end, unit );
+
+ } else {
+ e.custom( start, val, "" );
+ }
+ }
+ });
+
+ // For JS strict compliance
+ return true;
+ });
+ },
+
+ stop: function( clearQueue, gotoEnd ) {
+ var timers = jQuery.timers;
+
+ if ( clearQueue ) {
+ this.queue([]);
+ }
+
+ this.each(function() {
+ // go in reverse order so anything added to the queue during the loop is ignored
+ for ( var i = timers.length - 1; i >= 0; i-- ) {
+ if ( timers[i].elem === this ) {
+ if (gotoEnd) {
+ // force the next step to be the last
+ timers[i](true);
+ }
+
+ timers.splice(i, 1);
+ }
+ }
+ });
+
+ // start the next in the queue if the last step wasn't forced
+ if ( !gotoEnd ) {
+ this.dequeue();
+ }
+
+ return this;
+ }
+
+});
+
+// Generate shortcuts for custom animations
+jQuery.each({
+ slideDown: genFx("show", 1),
+ slideUp: genFx("hide", 1),
+ slideToggle: genFx("toggle", 1),
+ fadeIn: { opacity: "show" },
+ fadeOut: { opacity: "hide" }
+}, function( name, props ) {
+ jQuery.fn[ name ] = function( speed, callback ) {
+ return this.animate( props, speed, callback );
+ };
+});
+
+jQuery.extend({
+ speed: function( speed, easing, fn ) {
+ var opt = speed && typeof speed === "object" ? speed : {
+ complete: fn || !fn && easing ||
+ jQuery.isFunction( speed ) && speed,
+ duration: speed,
+ easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
+ };
+
+ opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
+ jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default;
+
+ // Queueing
+ opt.old = opt.complete;
+ opt.complete = function() {
+ if ( opt.queue !== false ) {
+ jQuery(this).dequeue();
+ }
+ if ( jQuery.isFunction( opt.old ) ) {
+ opt.old.call( this );
+ }
+ };
+
+ return opt;
+ },
+
+ easing: {
+ linear: function( p, n, firstNum, diff ) {
+ return firstNum + diff * p;
+ },
+ swing: function( p, n, firstNum, diff ) {
+ return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
+ }
+ },
+
+ timers: [],
+
+ fx: function( elem, options, prop ) {
+ this.options = options;
+ this.elem = elem;
+ this.prop = prop;
+
+ if ( !options.orig ) {
+ options.orig = {};
+ }
+ }
+
+});
+
+jQuery.fx.prototype = {
+ // Simple function for setting a style value
+ update: function() {
+ if ( this.options.step ) {
+ this.options.step.call( this.elem, this.now, this );
+ }
+
+ (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
+
+ // Set display property to block for height/width animations
+ if ( ( this.prop === "height" || this.prop === "width" ) && this.elem.style ) {
+ this.elem.style.display = "block";
+ }
+ },
+
+ // Get the current size
+ cur: function( force ) {
+ if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
+ return this.elem[ this.prop ];
+ }
+
+ var r = parseFloat(jQuery.css(this.elem, this.prop, force));
+ return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
+ },
+
+ // Start an animation from one number to another
+ custom: function( from, to, unit ) {
+ this.startTime = now();
+ this.start = from;
+ this.end = to;
+ this.unit = unit || this.unit || "px";
+ this.now = this.start;
+ this.pos = this.state = 0;
+
+ var self = this;
+ function t( gotoEnd ) {
+ return self.step(gotoEnd);
+ }
+
+ t.elem = this.elem;
+
+ if ( t() && jQuery.timers.push(t) && !timerId ) {
+ timerId = setInterval(jQuery.fx.tick, 13);
+ }
+ },
+
+ // Simple 'show' function
+ show: function() {
+ // Remember where we started, so that we can go back to it later
+ this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
+ this.options.show = true;
+
+ // Begin the animation
+ // Make sure that we start at a small width/height to avoid any
+ // flash of content
+ this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
+
+ // Start by showing the element
+ jQuery( this.elem ).show();
+ },
+
+ // Simple 'hide' function
+ hide: function() {
+ // Remember where we started, so that we can go back to it later
+ this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
+ this.options.hide = true;
+
+ // Begin the animation
+ this.custom(this.cur(), 0);
+ },
+
+ // Each step of an animation
+ step: function( gotoEnd ) {
+ var t = now(), done = true;
+
+ if ( gotoEnd || t >= this.options.duration + this.startTime ) {
+ this.now = this.end;
+ this.pos = this.state = 1;
+ this.update();
+
+ this.options.curAnim[ this.prop ] = true;
+
+ for ( var i in this.options.curAnim ) {
+ if ( this.options.curAnim[i] !== true ) {
+ done = false;
+ }
+ }
+
+ if ( done ) {
+ if ( this.options.display != null ) {
+ // Reset the overflow
+ this.elem.style.overflow = this.options.overflow;
+
+ // Reset the display
+ var old = jQuery.data(this.elem, "olddisplay");
+ this.elem.style.display = old ? old : this.options.display;
+
+ if ( jQuery.css(this.elem, "display") === "none" ) {
+ this.elem.style.display = "block";
+ }
+ }
+
+ // Hide the element if the "hide" operation was done
+ if ( this.options.hide ) {
+ jQuery(this.elem).hide();
+ }
+
+ // Reset the properties, if the item has been hidden or shown
+ if ( this.options.hide || this.options.show ) {
+ for ( var p in this.options.curAnim ) {
+ jQuery.style(this.elem, p, this.options.orig[p]);
+ }
+ }
+
+ // Execute the complete function
+ this.options.complete.call( this.elem );
+ }
+
+ return false;
+
+ } else {
+ var n = t - this.startTime;
+ this.state = n / this.options.duration;
+
+ // Perform the easing function, defaults to swing
+ var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop];
+ var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear");
+ this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration);
+ this.now = this.start + ((this.end - this.start) * this.pos);
+
+ // Perform the next step of the animation
+ this.update();
+ }
+
+ return true;
+ }
+};
+
+jQuery.extend( jQuery.fx, {
+ tick: function() {
+ var timers = jQuery.timers;
+
+ for ( var i = 0; i < timers.length; i++ ) {
+ if ( !timers[i]() ) {
+ timers.splice(i--, 1);
+ }
+ }
+
+ if ( !timers.length ) {
+ jQuery.fx.stop();
+ }
+ },
+
+ stop: function() {
+ clearInterval( timerId );
+ timerId = null;
+ },
+
+ speeds: {
+ slow: 600,
+ fast: 200,
+ // Default speed
+ _default: 400
+ },
+
+ step: {
+ opacity: function( fx ) {
+ jQuery.style(fx.elem, "opacity", fx.now);
+ },
+
+ _default: function( fx ) {
+ if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
+ fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
+ } else {
+ fx.elem[ fx.prop ] = fx.now;
+ }
+ }
+ }
+});
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.animated = function( elem ) {
+ return jQuery.grep(jQuery.timers, function( fn ) {
+ return elem === fn.elem;
+ }).length;
+ };
+}
+
+function genFx( type, num ) {
+ var obj = {};
+
+ jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
+ obj[ this ] = type;
+ });
+
+ return obj;
+}
+if ( "getBoundingClientRect" in document.documentElement ) {
+ jQuery.fn.offset = function( options ) {
+ var elem = this[0];
+
+ if ( !elem || !elem.ownerDocument ) {
+ return null;
+ }
+
+ if ( options ) {
+ return this.each(function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ });
+ }
+
+ if ( elem === elem.ownerDocument.body ) {
+ return jQuery.offset.bodyOffset( elem );
+ }
+
+ var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement,
+ clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
+ top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop,
+ left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft;
+
+ return { top: top, left: left };
+ };
+
+} else {
+ jQuery.fn.offset = function( options ) {
+ var elem = this[0];
+
+ if ( !elem || !elem.ownerDocument ) {
+ return null;
+ }
+
+ if ( options ) {
+ return this.each(function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ });
+ }
+
+ if ( elem === elem.ownerDocument.body ) {
+ return jQuery.offset.bodyOffset( elem );
+ }
+
+ jQuery.offset.initialize();
+
+ var offsetParent = elem.offsetParent, prevOffsetParent = elem,
+ doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement,
+ body = doc.body, defaultView = doc.defaultView,
+ prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
+ top = elem.offsetTop, left = elem.offsetLeft;
+
+ while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
+ if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
+ break;
+ }
+
+ computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
+ top -= elem.scrollTop;
+ left -= elem.scrollLeft;
+
+ if ( elem === offsetParent ) {
+ top += elem.offsetTop;
+ left += elem.offsetLeft;
+
+ if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.nodeName)) ) {
+ top += parseFloat( computedStyle.borderTopWidth ) || 0;
+ left += parseFloat( computedStyle.borderLeftWidth ) || 0;
+ }
+
+ prevOffsetParent = offsetParent, offsetParent = elem.offsetParent;
+ }
+
+ if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
+ top += parseFloat( computedStyle.borderTopWidth ) || 0;
+ left += parseFloat( computedStyle.borderLeftWidth ) || 0;
+ }
+
+ prevComputedStyle = computedStyle;
+ }
+
+ if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
+ top += body.offsetTop;
+ left += body.offsetLeft;
+ }
+
+ if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
+ top += Math.max( docElem.scrollTop, body.scrollTop );
+ left += Math.max( docElem.scrollLeft, body.scrollLeft );
+ }
+
+ return { top: top, left: left };
+ };
+}
+
+jQuery.offset = {
+ initialize: function() {
+ var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0,
+ html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
+
+ jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
+
+ container.innerHTML = html;
+ body.insertBefore( container, body.firstChild );
+ innerDiv = container.firstChild;
+ checkDiv = innerDiv.firstChild;
+ td = innerDiv.nextSibling.firstChild.firstChild;
+
+ this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
+ this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
+
+ checkDiv.style.position = "fixed", checkDiv.style.top = "20px";
+ // safari subtracts parent border width here which is 5px
+ this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
+ checkDiv.style.position = checkDiv.style.top = "";
+
+ innerDiv.style.overflow = "hidden", innerDiv.style.position = "relative";
+ this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
+
+ this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
+
+ body.removeChild( container );
+ body = container = innerDiv = checkDiv = table = td = null;
+ jQuery.offset.initialize = jQuery.noop;
+ },
+
+ bodyOffset: function( body ) {
+ var top = body.offsetTop, left = body.offsetLeft;
+
+ jQuery.offset.initialize();
+
+ if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
+ top += parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0;
+ left += parseFloat( jQuery.curCSS(body, "marginLeft", true) ) || 0;
+ }
+
+ return { top: top, left: left };
+ },
+
+ setOffset: function( elem, options, i ) {
+ // set position first, in-case top/left are set even on static elem
+ if ( /static/.test( jQuery.curCSS( elem, "position" ) ) ) {
+ elem.style.position = "relative";
+ }
+ var curElem = jQuery( elem ),
+ curOffset = curElem.offset(),
+ curTop = parseInt( jQuery.curCSS( elem, "top", true ), 10 ) || 0,
+ curLeft = parseInt( jQuery.curCSS( elem, "left", true ), 10 ) || 0;
+
+ if ( jQuery.isFunction( options ) ) {
+ options = options.call( elem, i, curOffset );
+ }
+
+ var props = {
+ top: (options.top - curOffset.top) + curTop,
+ left: (options.left - curOffset.left) + curLeft
+ };
+
+ if ( "using" in options ) {
+ options.using.call( elem, props );
+ } else {
+ curElem.css( props );
+ }
+ }
+};
+
+
+jQuery.fn.extend({
+ position: function() {
+ if ( !this[0] ) {
+ return null;
+ }
+
+ var elem = this[0],
+
+ // Get *real* offsetParent
+ offsetParent = this.offsetParent(),
+
+ // Get correct offsets
+ offset = this.offset(),
+ parentOffset = /^body|html$/i.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
+
+ // Subtract element margins
+ // note: when an element has margin: auto the offsetLeft and marginLeft
+ // are the same in Safari causing offset.left to incorrectly be 0
+ offset.top -= parseFloat( jQuery.curCSS(elem, "marginTop", true) ) || 0;
+ offset.left -= parseFloat( jQuery.curCSS(elem, "marginLeft", true) ) || 0;
+
+ // Add offsetParent borders
+ parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], "borderTopWidth", true) ) || 0;
+ parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], "borderLeftWidth", true) ) || 0;
+
+ // Subtract the two offsets
+ return {
+ top: offset.top - parentOffset.top,
+ left: offset.left - parentOffset.left
+ };
+ },
+
+ offsetParent: function() {
+ return this.map(function() {
+ var offsetParent = this.offsetParent || document.body;
+ while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
+ offsetParent = offsetParent.offsetParent;
+ }
+ return offsetParent;
+ });
+ }
+});
+
+
+// Create scrollLeft and scrollTop methods
+jQuery.each( ["Left", "Top"], function( i, name ) {
+ var method = "scroll" + name;
+
+ jQuery.fn[ method ] = function(val) {
+ var elem = this[0], win;
+
+ if ( !elem ) {
+ return null;
+ }
+
+ if ( val !== undefined ) {
+ // Set the scroll offset
+ return this.each(function() {
+ win = getWindow( this );
+
+ if ( win ) {
+ win.scrollTo(
+ !i ? val : jQuery(win).scrollLeft(),
+ i ? val : jQuery(win).scrollTop()
+ );
+
+ } else {
+ this[ method ] = val;
+ }
+ });
+ } else {
+ win = getWindow( elem );
+
+ // Return the scroll offset
+ return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
+ jQuery.support.boxModel && win.document.documentElement[ method ] ||
+ win.document.body[ method ] :
+ elem[ method ];
+ }
+ };
+});
+
+function getWindow( elem ) {
+ return ("scrollTo" in elem && elem.document) ?
+ elem :
+ elem.nodeType === 9 ?
+ elem.defaultView || elem.parentWindow :
+ false;
+}
+// Create innerHeight, innerWidth, outerHeight and outerWidth methods
+jQuery.each([ "Height", "Width" ], function( i, name ) {
+
+ var type = name.toLowerCase();
+
+ // innerHeight and innerWidth
+ jQuery.fn["inner" + name] = function() {
+ return this[0] ?
+ jQuery.css( this[0], type, false, "padding" ) :
+ null;
+ };
+
+ // outerHeight and outerWidth
+ jQuery.fn["outer" + name] = function( margin ) {
+ return this[0] ?
+ jQuery.css( this[0], type, false, margin ? "margin" : "border" ) :
+ null;
+ };
+
+ jQuery.fn[ type ] = function( size ) {
+ // Get window width or height
+ var elem = this[0];
+ if ( !elem ) {
+ return size == null ? null : this;
+ }
+
+ return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window?
+ // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
+ elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
+ elem.document.body[ "client" + name ] :
+
+ // Get document width or height
+ (elem.nodeType === 9) ? // is it a document
+ // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
+ Math.max(
+ elem.documentElement["client" + name],
+ elem.body["scroll" + name], elem.documentElement["scroll" + name],
+ elem.body["offset" + name], elem.documentElement["offset" + name]
+ ) :
+
+ // Get or set width or height on the element
+ size === undefined ?
+ // Get width or height on the element
+ jQuery.css( elem, type ) :
+
+ // Set the width or height on the element (default to pixels if value is unitless)
+ this.css( type, typeof size === "string" ? size : size + "px" );
+ };
+
+});
+// Expose jQuery to the global object
+window.jQuery = window.$ = jQuery;
+
+})(window);
diff --git a/examples/lessons/6_English_oneOrMany/js/karma.js b/examples/lessons/6_English_oneOrMany/js/karma.js
new file mode 100755
index 0000000..03f027b
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/js/karma.js
@@ -0,0 +1,1018 @@
+/* Documentation Note:
+ * Public methods and properties are commented with /** some text *\/
+ * and private methods and properties are commented with //
+ *
+ * Please leave it that way to keep this documentation sane
+ */
+
+
+/*
+* Karma Framework
+* http://karmaeducation.org
+*
+* Copyright (c) 2009
+* Bryan W Berry bryan@olenepal.org
+* Felipe López Toledo zer.subzero@gmail.com
+*
+* Under MIT License:
+* Permission is hereby granted, free of charge, to any person
+* obtaining a copy of this software and associated documentation
+* files (the "Software"), to deal in the Software without
+* restriction, including without limitation the rights to use,
+* copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following
+* conditions:
+*
+* The above copyright notice and this permission notice shall be
+* included in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+/**
+* @fileOverview Contains karma library
+* @author Bryan Berry <bryan@olenepal.org>
+* @author Felipe Lopez Toledo <zer.subzero@gmail.com>
+*/
+
+
+//common.js modules use exports object
+if(!this.exports) {
+ exports = {};
+}
+
+
+
+/** Checks if the current document type is set to HTML 5, throws
+ * an error otherwise, then initializes the karma object and returns
+ * a reference to that object.
+ * @namespace Global namespace for Karma library
+ * @param {Object} [options={}] options for intializing Karma library
+ * @param {String} [options.locale=''] sets current locale Not Yet Implemented
+ * @param {Array} [options.image=[]] array of images to be converted into a collection
+ * @param {Array} [options.audio=[]] array of audio to be converted into a collection
+ * @param {Array} [options.video=[]] array of videos to be converted into a collection
+ * @param {Array} [options.svg=[]] array of SVG elements to be
+ * converted into a collection. Each SVG element must already exist in the html document
+ * @param {Array} [options.canvas=[]] array of canvas elements
+ * to be converted into a collection. Each canvas element must already exist in the
+ * html document and width and height of each element must be set as attributes
+ * @throws {Error} if the document type declaration is not set to HTML 5, e.g.
+ * <!DOCTYPE html>
+ * @throws {Error} If any of the initialization parameters are invalid values
+ * @returns {Object} Karma.karma -- reference to the initialized Karma library
+ * @example
+ *
+ * var k = Karma({
+ * image: [
+ * {name: "ninja", file: "ninja.png"},
+ * {name: "cowboy", file: "cowboy.png"}
+ * ],
+ * audio: [
+ * {name: "woosh", file: "woosh.ogg"},
+ * {name: "yeehaw", file: "yeehaw.ogg"}
+ * ],
+ * video: [
+ * {name: "attack", file: "attack.ogv"},
+ * {name: "ride", file: "ride.ogv"}
+ * ]
+ * canvas: [
+ * {name: "ninja", domId: "ninjaCanvas"},
+ * {name: "cowboy", domId: "cowboyCanvas"}
+ * ],
+ * svg: [
+ * {name: "ninja", domId: "ninjaSvg"},
+ * {name: "cowboy", domId: "cowboySvg"}
+ * ],
+ * });
+ * Next, call the ready function with a callback to your program code
+ *
+ * k.ready(function () { ... your application code . . . }
+ *
+ * after that you can access each asset like so
+ * k.image.ninja;
+ * k.svg.cowboy;
+ * k.audio.yeehaw.play();
+ * k.canvas.ninja.drawImage(k.image.ninja, 0, 0);
+ *
+ */
+var Karma = exports.Karma = function (options) {
+ Karma._isHtml5(document.doctype.nodeName);
+
+ if ( Karma.karma._initialized === true ) {
+ return Karma.karma;
+ } else {
+ return Karma.karma._init(options);
+ }
+};
+
+
+//helper functions
+
+/**This emulates the Object.create method in ecmascript 5 spec
+ * This isn't a full implementation as it doesn't support
+ * This has the same functionality as Crockford's beget method
+ * and this primary building block for prototypal inheritance in
+ * this library
+ * @param {Object} target that the new object's prototype should point to
+ * @returns {Object} object whose prototype points to target
+ * @example
+ *
+ * var ninja = { weapon : "sword" };
+ * var ninja1 = Karma.create(ninja);
+ * ninja1.sword === "sword"
+ */
+Karma.create = function (target){
+ function F () {};
+ F.prototype = target;
+ return new F();
+};
+
+/** Returns a shallow copy of the passed in object
+ * @param {Object} target to be copied
+ * @returns {Object} a shallow copy of target
+ */
+Karma.clone = function (target){
+ var copy = {};
+ for ( var i in target ) {
+ if(target.hasOwnProperty(i)){
+ copy[i] = target[i];
+ }
+ }
+ return copy;
+};
+
+/** Extends properties of the target object with those of
+ * the source object
+ * @param {Object} target object to be extended
+ * @param {Object} source whose properties will extend target
+ * @returns {Object} target extended by source
+ */
+Karma.objectPlus = function (target, source){
+ for ( var i in source){
+ if (source.hasOwnProperty(i)){
+ target[i] = source[i];
+ }
+ }
+ return target;
+};
+
+/** Creates a new object that is a prototype of the first argument
+ * then extends it with the properties of the second argument
+ * @param {Object} parent1 will be prototype of returned object
+ * @param {Object} parent2 will extend properties of returned object
+ * @returns {Object} object that whose prototype is parent1 and has
+ * been extended with properties of parent2
+ */
+Karma.copyObjectPlus = function (parent1, parent2){
+ function F () {};
+ F.prototype = parent1;
+ var G = new F();
+ return Karma.objectPlus(G, parent2);
+};
+
+//Enables function chaining for a specified list of function names
+//IMPORTANT: use of closures here with "this" and "that" is __very__
+//complicated here
+Karma._makeChain = function (chainingFunctions) {
+ var that = this;
+ var _chainFunction = function ( name ){
+ that[ name ] = function ( ){
+ var type = typeof this.ctx[name];
+ if ( type === "function") {
+ this.ctx[ name ].apply( this.ctx, arguments );
+ }else if ( type === "string" ){
+ this.ctx[ name ] = arguments[0];
+ }else {
+ throw ("wtf?!: impossible to chain " + name + "!");
+ }
+ return this;
+ };
+ };
+
+ for (var i = 0; i < chainingFunctions.length; i++){
+ _chainFunction( chainingFunctions[ i ] );
+ }
+};
+
+//Throws big ugly error if doctype isn't html5
+Karma._isHtml5 = function (doctype){
+ var regex = new RegExp('^html$', 'i');
+ if(!regex.test(doctype)){
+ var errorMsg = "ERROR: The doctype must be set to <!DOCTYPE html> " +
+ "in order to use Karma. Karma require you use html5";
+ var errorElem = document.createElement('div');
+ errorElem.setAttribute('id', 'errorDoctype');
+ errorElem.innerText = errorMsg;
+ document.body.appendChild(errorElem);
+ throw new Error(errorMsg);
+ }
+};
+
+
+/** Stores global settings for the Karma library
+ * @class This object stores the global settings for the Karma library
+ */
+Karma.karma = {
+ /** This is the global locale as passed to Karma(),
+ * such as "en", "es_SP"
+ * @type string
+ * @default undefined
+ */
+ locale : undefined,
+ /** Collection of images with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ image : {},
+ /** Collection of audio with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ audio : {},
+ /** Collection of canvas with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ canvas : {},
+ /** Collection of svgs with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ svg : {},
+ /** Collection of videos with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ video : {},
+ _localized : false,
+ _assetPath : "assets/",
+ _localePath : "",
+ _initialized : false,
+ _statusDiv: undefined,
+ _loaderDiv : undefined,
+ _counters : { total : 0, errors : 0, loaded : 0},
+
+ //init initializes all the assets passed to Karma, that's it
+ //it returns 'this' so it can be used for function chaining
+ _init: function(options) {
+ this._initialized = true;
+
+ //set up message that show count of assets loaded
+ //and has an ordered list to append error messages to
+ var _statusDiv = this._statusDiv = document.createElement('div');
+ this._loaderDiv = this._loaderDiv = document.createElement('div');
+ var errorList = document.createElement('ol');
+
+ _statusDiv.setAttribute('id', 'karma-status');
+ _statusDiv.setAttribute('style', 'position:absolute;');
+ _statusDiv.innerHTML = 'Karma is loading ...';
+ this._loaderDiv.setAttribute('id', 'karma-loader');
+ this._loaderDiv.setAttribute('class', 'status');
+ errorList.setAttribute('id', 'errorList');
+
+ _statusDiv.appendChild(this._loaderDiv);
+ this._statusDiv.appendChild(errorList);
+ document.body.appendChild(_statusDiv);
+
+
+ //chain the functions for kCanvas and kSvg
+ Karma._makeChain.call(Karma.kCanvas,
+ Karma.kCanvas._chainingFunctions);
+ //Karma._makeChain.apply(Karma.kSvg, Karma.kSvg._chainingFunctions);
+
+
+
+ //regular expression that matches the name of aprivate property
+ // the karma object
+ var regexPrivate = new RegExp('^_.*');
+
+ for ( var option in options ) {
+ if (options.hasOwnProperty(option)){
+ if (option === "image" || option === "audio" || option ===
+ "svg" || option === "video" || option === "canvas"){
+
+ if(!(options[option] instanceof Array)){
+ throw new Error("" + option + " must be an array");
+ } else if (options[option].length === 0){
+ continue;
+ }
+ } else if (regexPrivate.test(option)){
+ //don't overwrite a private property of karma object
+ continue;
+ }
+
+ switch (option){
+ case "locale":
+
+ if (this._isValidLocale(options[option])){
+ this.locale = this._normalizeLocale(options[option]);
+ this._localized = true;
+ this._localePath = Karma._computeLocalePath(this.locale);
+ } else {
+ throw new Error("locale provided to karma._init() is invalid");
+ }
+
+ break;
+ case "image":
+ options[option]._type = 'image';
+ Karma._makeImages(options[option]);
+ break;
+ case "audio":
+ options[option]._type = 'audio';
+ Karma._makeAudio(options[option]);
+ break;
+ case "video":
+ options[option]._type = 'video';
+ Karma._makeVideos(options[option]);
+ break;
+ case "svg":
+ options[option]._type = 'svg';
+ Karma._makeSvgs(options[option]);
+ break;
+ case "canvas":
+ options[option]._type = 'canvas';
+ Karma._makeCanvases(options[option]);
+ break;
+ }
+ }
+ }
+
+
+
+ return this;
+ },
+
+ /** Waits until all assets loaded, i.e. ready, then calls callback
+ * @param {Function} [cb] callback function
+ * @returns this
+ * @throws {Error} if Karma.karma is not initialized with the
+ * Karma({ options }) function
+ * @example
+ *
+ * var k = Karma({ . . . your assets here . . . });
+ * k.ready(function(){ .. your code here . . .});
+ *
+ * your code will not be called until all assets have been loaded
+ *
+ */
+ ready : function( cb ) {
+ var that = this;
+ if (Karma.karma._initialized !== true){
+ throw new Error("Karma.karma not initialized");
+ }
+
+ if (this._counters.loaded !== this._counters.total){
+ setTimeout(function(){ that.ready(cb);}, 5);
+ } else if (cb) {
+ //hide the "Karma is loading..." message
+ this._statusDiv.setAttribute('style', 'display:none;');
+
+ cb();
+ } else if (!cb) {
+ //hide the "Karma is loading..." message
+ this._statusDiv.setAttribute('style', 'display:none;');
+
+ //if no options passed, show it works message
+ this._showStarterMessage();
+ }
+
+
+
+
+ return this;
+ },
+
+ //Display Apache-like "It works" message if no options
+ _showStarterMessage : function (){
+ var starterMsg = document.createElement('div');
+ starterMsg.setAttribute('id', 'starterMsg');
+ starterMsg.innerHTML = "<h1>It Works</h1>";
+ document.body.appendChild(starterMsg);
+ },
+
+ //Updates visible counter of how many assets are loaded
+ _updateStatus : function (errorMsg) {
+ var loaded = this._counters.loaded;
+ var total = this._counters.total;
+ var errors = this._counters.errors;
+ this._loaderDiv.innerHTML = "Loaded " + loaded + " / " + total +
+ "" + (errors > 0 ? " Errors [ " + errors +" ]" : '');
+ if (errorMsg) {
+ var liError = document.createElement('li');
+ liError.innerHTML = errorMsg;
+ var errorList = document.getElementById('errorList');
+ errorList.appendChild(liError);
+ }
+ },
+
+ //matches 2 letter country code then optionally
+ //a dash or underscore followed by a country or language identifier
+ //i currently only allow a language identifier 2-3 chars long
+ _isValidLocale : function (locale) {
+ var localeRegex = new RegExp('^[a-zA-Z][a-zA-Z]([-_][a-zA-z]{2,3})?$');
+ return localeRegex.test(locale);
+ },
+
+ _normalizeLocale : function(locale) {
+ var lang = "";
+ var country = "";
+ var divider = "";
+
+ lang = locale.slice(0, 2).toLowerCase();
+ divider = "_";
+ country = locale.slice(3, 6).toUpperCase();
+
+ return locale.length > 2 ? "" + lang + divider + country : lang;
+ },
+
+ // Below are geometry and math helper methods
+
+ /**
+ * Converts a value from degrees to radians.
+ * @param {Number} angle The angle in degrees
+ * @returns {Number} The angle in radians
+ */
+ radians : function( angle ){
+ return ( angle / 180 ) * Math.PI;
+ },
+ /**
+ * Gets the square of the Euclidian (ordinary) distance between 2 points.
+ * @param {Object} Point No. 0
+ * @param {Number} Point0.x
+ * @param {Number} Point0.y
+ * @param {Object} Point No. 1
+ * @param {Number} Point1.x
+ * @param {Number} Point1.y
+ * @returns {Number} The square of the Euclidian distance
+ * @example
+ *
+ * p0 = {x:0, y:1};
+ * p1 = {x:50, y:70};
+ * var d = distance2(p0, p1);
+ *
+ */
+ distance2 : function ( p0, p1 ) {
+ return (p1.x - p0.x) * (p1.x - p0.x) + (p1.y - p1.y) * (p1.y - p1.y);
+ },
+ /**
+ * Gets the Euclidian (ordinary) distance between 2 points.<br>
+ * <b>Warning:</b> It's slower than distance2 function
+ * @param {Object} Point No. 0
+ * @param {Number} Point0.x
+ * @param {Number} Point0.y
+ * @param {Object} Point No. 1
+ * @param {Number} Point1.x
+ * @param {Number} Point1.y
+ * @returns {Number} The Euclidian distance
+ * @example
+ *
+ * p0 = {x:0, y:1};
+ * p1 = {x:50, y:70};
+ * var d = distance2(p0, p1);
+ *
+ */
+ distance : function ( p0, p1 ) {
+ return Math.sqrt( this.distance2( p0, p1 ) );
+ },
+ /** Returns a random number within the range provided
+ * @param {Number} lower limit of the range, lowest number that can be returned
+ * @param {Number} upper limit of the range, highest number that can be returned
+ * @returns {Number} number that is >= lower and <= upper
+ * @example
+ *
+ * var num = rand(0, 10);
+ *
+ * num could be 0, 1, 2, 3 ... or 10
+ *
+ */
+ rand : function ( lower, upper ){
+ return Math.round( Math.random() * (upper - lower) + lower );
+ }
+
+};
+
+/** Prototypal object for images, videos, and audio files but
+ * does not include svg or canvas elements
+ * @class This object is the prototype for images, videos, and audio files but
+ * does not include svg or canvas elements
+ * @ throws {Error} if the individual asset is set to be localized but
+ * the globale locale is not set on the Karma.karma object
+ * @ throws {Error} if the name and file properties are not supplied
+ * @example
+ * kMedia is the prototype object for images, audio, and videos.
+ * These 'media' assets are loaded in a distinctly different way
+ * from the canvas or svg assets. They also have distinctly different
+ * helper methods
+ *
+ * You initialize the kMedia assets by passing an array of objects
+ */
+Karma.kMedia = {
+ /** file location of asset
+ * @type String
+ * @default ""
+ */
+ file : "",
+ /** media object
+ * @type Audio|Image|Video
+ * @default undefined
+ */
+ media : undefined,
+ //actual path to the file
+ _path : "",
+ //if using localized version of this asset
+ _localized : false,
+ //audio, image, or video
+ _type : "",
+ //initializes kMedia instance with values provided by user
+ _init : function (asset) {
+ asset._localized = asset._localized || false;
+ Karma.karma._counters.total++;
+
+ if (asset.name === undefined || asset.file === undefined){
+ throw new Error("properties name and file have to be defined");
+ } else {
+ this.name = asset.name;
+ this.file = asset.file;
+ }
+
+ //_type is a private variable used internally
+ if (asset._type === undefined){
+ throw new Error("the _type property must be set. " +
+ "Blame the karma library authors as this is an internal value");
+ } else {
+ if (Karma._isValidType(asset._type)){
+ this._type = asset._type;
+ switch ( this._type ) {
+ case "image": this.media = new Image();
+ break;
+ case "audio": this.media = new Audio();
+ break;
+ //case "video":
+ //NYI
+ //this.media = new Video();
+ break;
+ default: throw new Error("Media type not supported");
+ }
+
+ } else {
+ throw new Error("the _type property supplied is invalid. " +
+ "Blame the karma library authors as this is an internal value");
+ }
+ }
+
+ if(Karma._isLocalized(asset._localized)){
+ this._localized = asset._localized;
+ this._path = Karma.karma._localePath +
+ this._type + "/";
+ } else {
+ this._path = Karma.karma._assetPath +
+ this._type + "/";
+ }
+
+
+ //IMPORTANT: This one magic line loads the file
+ this.media.src = this.src = this._path + this.file;
+
+ //add event handlers
+ this._addEventHandlers();
+
+ if (this._type === "audio"){
+ this.media.autobuffer = true;
+ this.media.load();
+ }
+
+
+ return this;
+ },
+ //Adds event handlers to update the counters when
+ //the asset is successfully or unsuccessfully loaded
+ _addEventHandlers : function () {
+ var that = this;
+ var loadEvent = "load";
+ //Browser Hack recommended by chromium devs
+ //http://code.google.com/p/chromium/issues/detail?id=20251&q=loading%20audio&colspec=ID%20Stars%20Pri%20Area%20Type%20Status%20Summary%20Modified%20Owner%20Mstone%20OS#c4
+ if (this._type === "audio" || this._type === "video"){
+ loadEvent = "canplaythrough";
+ }
+
+ that.media.addEventListener(
+ loadEvent,
+ function (e) {
+ Karma.karma._counters.loaded++;
+ Karma.karma._updateStatus();
+ that.status = "loaded";}, false);
+
+ that.media.addEventListener(
+ "error",
+ function (e) {
+ Karma.karma._counters.errors++;
+ that.status = "error";
+ var errorMsg = "Error: " + that._type.toUpperCase() +
+ " " + that.name + " cannot be loaded.";
+ Karma.karma._updateStatus(errorMsg);
+ },
+ false);
+ that.media.addEventListener(
+ "abort",
+ function (e) {
+ Karma.karma._counters.total++;
+ that.status = "aborted";
+ var errorMsg = "ABORT: " + that._type.toUpperCase() +
+ " " + that.name + " loading was aborted.";
+ Karma.karma._updateStatus(errorMsg);
+
+ }, false);
+
+ }
+
+};
+
+//determine if it is a valid type of asset
+Karma._isValidType = function (type){
+ return type === "image" ||
+ type === "svg" ||
+ type === "audio" ||
+ type === "video" ||
+ type === "canvas";
+};
+
+Karma._isLocalized = function (boolLocalized) {
+ if (typeof boolLocalized === "boolean" ) {
+ if(boolLocalized === true &&
+ Karma.karma.locale === undefined){
+ throw new Error("You cannot localize a media asset" +
+ " if the global locale for Karma isn't set");
+ } else {
+ return boolLocalized;
+ }
+ } else if (typeof boolLocalized === undefined){
+ return false;
+ } else{
+ throw new Error("This is not a valid value for the localized option");
+ }
+};
+
+Karma._computeLocalePath = function(locale) {
+ return Karma.karma._assetPath + locale + "/";
+};
+
+Karma._makeImages = function (imgConfigs){
+ var makeImage = function (imgConfig){
+ var image = undefined;
+ imgConfig._type = "image";
+ image = Karma.create(Karma.kMedia)._init(imgConfig);
+ Karma.karma.image[imgConfig.name] = image;
+ };
+
+ imgConfigs.forEach(function(imgConfig){ makeImage(imgConfig);});
+
+};
+
+Karma._makeAudio = function (audioConfigs){
+ var makeAudio = function (audioConfig){
+ var audio = undefined;
+ audioConfig._type = "audio";
+ audio = Karma.create(Karma.kMedia)._init(audioConfig);
+ audio.play = function () {
+ //hack to fix the audio "stuttering" problem
+ //more info: https://bugs.launchpad.net/karma/+bug/426108
+ this.media.currentTime = 0.1;
+ this.media.play();
+ };
+ Karma.karma.audio[audioConfig.name] = audio;
+ };
+
+ audioConfigs.forEach(function(audioConfig){ makeAudio(audioConfig);});
+
+};
+
+
+Karma._makeCanvases = function (canvasConfigs){
+ var makeCanvas = function (canvasConfig){
+ var canvas = undefined;
+ canvas = Karma.create(Karma.kCanvas)._init(canvasConfig);
+ Karma.karma.canvas[canvasConfig.name] = canvas;
+ };
+
+ canvasConfigs.forEach(function(canvasConfig){ makeCanvas(canvasConfig);});
+
+};
+
+/** Prototypal object for each canvas element submitted to Karma in the
+ * Karma() method
+ * @throws {Error} if the name and domId for the canvas element are not specified
+ * @thows {Error} if the supplied domId does not match an element in the DOM
+ * @class This object is the prototype for each canvas element submitted to Karma in the
+ * Karma() method
+ */
+Karma.kCanvas = {
+ /** Name of the canvas, used internally by karma.js
+ * @type String
+ * @default ''
+ */
+ name : '',
+ /** Width of canvas element
+ * @type Number
+ * @default 0
+ */
+ width: 0,
+ /** Height of canvas element
+ * @type Number
+ * @default 0
+ */
+ height: 0,
+ /** Whether canvas is visible
+ * @type boolean
+ * @default true
+ */
+ visible: true,
+ /** Element ID for canvas element in html document
+ * @type String
+ * @default undefined
+ */
+ domId: undefined,
+ /** Reference to the DOM element
+ * @type DOMElement
+ * @default undefined
+ */
+ node: undefined,
+ /** The 2 Dimensional Rendering context property for this canvas
+ * @type 2DRenderingContext
+ * @default undefined
+ */
+ ctx: undefined,
+ /** Frames Per Second, I don't know what the purpose of this is,
+ * Felipe made it up
+ * @type Number
+ * @default 24
+ */
+ fps: 24,
+
+ //initializes object with values provides by user
+ _init: function (config) {
+ for (var option in config){
+ if (config.hasOwnProperty(option)){
+ switch (option){
+ case "name":
+ this.name = config[option];
+ break;
+ case "domId":
+ this.domId = config[option];
+ break;
+ case "width":
+ if(!this.height){
+ throw new Error("If you specify a width you must also" +
+ "specify a height");
+ }
+ this.width = config[option];
+ break;
+ case "height":
+ if(!this.width){
+ throw new Error("If you specify a height you must also" +
+ "specify a width");
+ }
+ this.height = parseInt(config.option, 10);
+ break;
+ case "fps":
+ this.fps = parseInt(config.option, 10);
+ break;
+ }
+ }
+ }
+
+ if(this.domId && document.getElementById(this.domId)){
+ this.node = document.getElementById(this.domId);
+ this.ctx = this.node.getContext('2d');
+ } else {
+ throw new Error('you must specify a valid domId that' +
+ 'is in your html page');
+ }
+
+ if(!config.height && !config.width){
+ this.width = parseInt(this.node.getAttribute('width'), 10);
+ this.height = parseInt(this.node.getAttribute('height'), 10);
+ }
+
+ return this;
+ },
+ /** Clear area of canvas element specified by parameters, if no
+ * parameters supplied, clears entire canvas
+ * @param {Number} [x=0] x coordinate, defaults to zero if left blank
+ * @param {Number} [y=0] y coordinate, defaults to zero if left blank
+ * @param {Number} [width=0] width of area to be cleared, defaults
+ * entire width of canvas
+ * @param {Number} [height=0] height of area to be cleared, defaults
+ * entire height of canvas
+ * @returns this
+ * @example
+ *
+ * k.canvas.ninja.clear();
+ * // clears the entire ninja canvas
+ *
+ * k.canvas.ninja.clear(0, 10, 20, 30);
+ * //clears a specific portion of the ninja canvas
+ *
+ */
+ clear : function ( x, y, width, height ) {
+ var that = this;
+ that.ctx.clearRect(
+ x || 0,
+ y || 0,
+ width || that.width,
+ height || that.height
+ );
+ return that;
+ },
+
+ //These are all properties or methods of the canvas element's
+ //2 dimensional context
+ _chainingFunctions : [
+ "globalAlpha", "globalCompositeOperation", "lineWidth", "lineCap",
+ "lineJoin", "miterLimit", "font", "textAlign", "textBaseline", "save",
+ "restore", "scale", "rotate", "translate", "transform", "setTransform",
+ "clearRect", "fillRect", "strokeRect", "beginPath", "closePath",
+ "moveTo", "lineTo", "quadraticCurveTo", "bezierCurveTo", "arcTo",
+ "arc", "rect", "fill", "stroke", "clip", "fillText", "strokeText",
+ "measureText", "isPointInPath", "strokeStyle", "fillStyle",
+ "createLinearGradient", "createRadialGradient", "createPattern",
+ "shadowOffsetX", "shadowOffsetY", "shadowBlur", "shadowColor",
+ //"mozTextStyle", "mozDrawText", "mozMeasureText", "mozPathText",
+ "mozTextAlongPath", "drawImage", "getImageData", "putImageData",
+ "createImageData", "drawWindow"
+ ]
+};
+
+
+
+Karma._makeSvgs = function (svgConfigs){
+ var makeSvg = function (svgConfig){
+ var svg = undefined;
+ svg = Karma.create(Karma.kSvg)._init(svgConfig);
+ Karma.karma.svg[svgConfig.name] = svg;
+ };
+
+ svgConfigs.forEach(function(svgConfig){ makeSvg(svgConfig);});
+
+};
+
+/** Prototypal object for each svg element submitted to Karma in the
+ * Karma() method
+ * @throws {Error} if the name and domId for the svg element are not specified
+ * @thows {Error} if the supplied domId does not match an element in the DOM
+ * @class This object is the prototype for each svg element submitted to Karma in the
+ * Karma() method
+ */
+Karma.kSvg = {
+ /** name of instance, used internally
+ * @typeof string
+ * @default ""
+ */
+ name : "",
+ /** width of element
+ * @type number
+ * @default 0
+ */
+ width: 0,
+ /** height of element
+ * @type number
+ * @default 0
+ */
+ height: 0,
+ /** Status of element, either "loaded" or "error"
+ * @type string
+ * @default ""
+ */
+ status: "",
+ /** Whether canvas is visible
+ * @type boolean
+ * @default true
+ */
+ visible: true,
+ /** Element ID for canvas element in html document
+ * @type String
+ * @default undefined
+ */
+ domId: undefined,
+ /** Reference to the DOM element
+ * @type DOMElement
+ * @default undefined
+ */
+ node: undefined,
+ /** Reference to the SVGDocument
+ * @type SVGDocument
+ * @default undefined
+ */
+ doc: undefined,
+ /** Reference to the root element of the SVG Document
+ * @type DocumentElement
+ * @default undefined
+ */
+ root: undefined,
+ _localized : undefined,
+ _chainingFunctions: [],
+ _init: function (config) {
+ Karma.karma._counters.total++;
+
+ for (var option in config){
+ if (config.hasOwnProperty(option)){
+ switch (option){
+ case "name":
+ this.name = config[option];
+ break;
+ case "domId":
+ this.domId = config[option];
+ break;
+ case "width":
+ if(!this.height){
+ throw new Error("If you specify a width you must also" +
+ "specify a height");
+ }
+ this.width = parseInt(config[option], 10);
+ break;
+ case "height":
+ if(!this.width){
+ throw new Error("If you specify a height you must also" +
+ "specify a width");
+ }
+ this.height = config[option];
+ break;
+ case "fps":
+ this.fps = config[option];
+ break;
+ }
+ }
+ }
+
+ if(this.domId && document.getElementById(this.domId)){
+ this.node = document.getElementById(this.domId);
+ } else {
+ throw new Error('you must specify a valid domId that' +
+ 'is in your html page');
+ }
+
+ if(!config.height && !config.width){
+ this.width = parseInt(this.node.getAttribute('width'), 10);
+ this.height = parseInt(this.node.getAttribute('height'), 10);
+ }
+
+ var that = this;
+ that._addEventHandlers();
+
+ return this;
+
+
+ },
+ _addEventHandlers : function () {
+ var that = this;
+ that.doc = that.node.getSVGDocument();
+ that.node.addEventListener(
+ "load",
+ function (e) {
+ that.doc = that.node.getSVGDocument();
+ that.root = that.doc.documentElement;
+ Karma.karma._counters.loaded++;
+ Karma.karma._updateStatus();
+ that.status = "loaded";
+ }, false);
+
+ that.node.addEventListener(
+ "error",
+ function (e) {
+ Karma.karma._counters.loaded--;
+ Karma.karma._counters.errors++;
+ that.status = "error";
+ var errorMsg = "Error: " + that._type.toUpperCase() +
+ " " + that.name + " cannot be loaded.";
+ Karma.karma._updateStatus(errorMsg);
+ },
+ false);
+ that.node.addEventListener(
+ "abort",
+ function (e) {
+ that.status = "aborted";
+ var errorMsg = "ABORT: " + that._type.toUpperCase() +
+ " " + that.name + " loading was aborted.";
+ Karma.karma._updateStatus(errorMsg);
+
+ }, false);
+
+ }
+};
+
+Karma._makeVideos = function (video){
+
+};
diff --git a/examples/lessons/6_English_oneOrMany/js/lesson.js b/examples/lessons/6_English_oneOrMany/js/lesson.js
new file mode 100755
index 0000000..b53f945
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/js/lesson.js
@@ -0,0 +1,318 @@
+$(document).ready(function(){
+ var k = Karma({
+ audio: [{'name':'correct','file':'correct.ogg'},
+ {'name':'incorrect','file':'incorrect.ogg'}
+ ]});
+
+ k.ready(function(){
+ var i,j,flag;
+ var TOTAL_QUES = 8;
+ var TOTAL_LEVEL = 3;
+ var MAX_NUMBERS = 7;
+ var currentDragObject;
+ var randPositions = [];
+ var randImages = [];
+ var randOptions = [];
+ var totalCounter;
+ var correctCounter;
+ var currentQuestion;
+ var currentDragObject;
+ var arrangedAns = []; //store the answer arranged by players
+ var correctAns = []; //store the correct ans of the current question
+ var checked;
+ var sectionNum; //store the current tab num
+ var flag_checked;
+ var currentQues; //store the current Animal name
+ var currentAnimal; //store the current Animal Image name
+ var correctQuest; //store 1 if the question and image is same
+
+ var animals = new Array('tiger','elephant','jackel','bear','rhino','monkey','turtle','snake',
+ 'aeroplane','ship','cart','bus','cycle','boat','tempo','truck',
+ 'desk','bench','brush','soap','kite','bag','book','ladder'
+ );
+ var numbersWords = ['zero','one','two','three','four','five','six','seven','eight','nine','ten'];
+ var animalNumbers = [2,3,2,1,1,3,5,4,
+ 1,1,3,2,5,5,3,2,
+ 1,1,5,3,4,1,3,2
+ ];
+ var answersOpts = [];
+ var tabs = new Array('wild','transportation','objects');
+
+ var scoreboard = $('#score_box').scoreboard({'layout':'horizontal',
+ 'winningScore': 8});
+ /*scoreboard.bind('winGame',function(){ //needs total score counter to be checked problem
+ $('#gameOver').show();
+ $('#dot').hide();
+ $('#questionSection').hide();
+ $('#gameOver').append('Game Over !!!');
+ $('#gameOver').append('<div id="gameOverInfo">You got <span class="specialText">'+correctCounter+
+ '</span> correct out of <span class="specialText">'+totalCounter+'</span> questions .</div>');
+
+ });
+ */
+
+ var genRandOpts=function (){
+ randOptions[0] = k.rand(0,5);
+ for(i=1; i<6; i++){
+ do{
+ flag = 0;
+ randOptions[i] = k.rand(0,5);
+ for(j=0; j<i; j++){
+ if(randOptions[i] === randOptions[j]){
+ flag++;
+ }
+ }
+ }while(flag != 0 ); //end of do while loop
+ }
+
+ };
+ var genRandImages=function (){
+ randImages[0] = k.rand(0,TOTAL_QUES-1);
+ for(i=1; i<TOTAL_QUES; i++){
+ do{
+ flag = 0;
+ randImages[i] = k.rand(0,TOTAL_QUES-1);
+ for(j=0; j<i; j++){
+ if(randImages[i] === randImages[j]){
+ flag++;
+ }
+ }
+ }while(flag != 0 ); //end of do while loop
+ }
+ };
+ var genRandPosition=function (){
+ randPositions[0] = k.rand(0,TOTAL_QUES-1);
+ for(i=1; i<TOTAL_QUES; i++){
+ do{
+ flag = 0;
+ randPositions[i] = k.rand(0,TOTAL_QUES-1);
+ for(j=0; j<i; j++){
+ if(randPositions[i] === randPositions[j]){
+ flag++;
+ }
+ }
+ }while(flag != 0 ); //end of do while loop
+ }
+ };
+ var display_game_over = function(){
+ $('#dot').hide();
+ $('#gameOver').show();
+ $('#questionSection').html('').append('<div id="gameOver"></div>');
+ $('#gameOver').append('Game Over !!!');
+ $('#gameOver').append('<div id="gameOverInfo">You got <span class="specialText">'+correctCounter+
+ '</span> correct out of <span class="specialText">'+totalCounter+'</span> questions .</div>');
+
+ };
+ var display_control = function(){
+ if(checked === 1){
+ next_questions();
+ }
+ };
+ var delay_correctShow = function(){
+ document.delayForm.delayval.value = 1;
+ $('#checkAnswer').hide();
+ display_control();
+ }
+
+ var check_answers = function(){
+ $('#checkAnswer').show();
+ var correct = 0;
+ var correctCheck = 0;
+ for(i = 0;i<3;i++){
+ if(correctAns[i] === arrangedAns[i]){
+ correctCheck++;
+ }
+ }
+ if(correctCheck === 3){
+ if(flag_checked === 0){
+ scoreboard.scoreboard('inc');
+ correctCounter++;
+ }
+ k.audio.correct.play();
+ $('#checkAnswer').html('<img src="assets/image/correct.png" />');
+ checked = 1;
+ totalCounter++;
+ scoreboard.scoreboard('incTotal');
+ }
+ else{
+ k.audio.incorrect.play();
+ $('#checkAnswer').html('<img src="assets/image/incorrect.png" />');
+ checked = 0;
+ flag_checked = 1;
+ }
+ t=setTimeout(function(){delay_correctShow();},1000);
+ };
+
+ var assignTabs = function (tabId){
+ $('#tabs').append('<div id="tabs'+tabId+'" class="tabBox"></div>');
+ var tabImgCss = {
+ 'width': '179px',
+ 'height': '50px',
+ 'background-image': 'url("assets/image/'+tabs[tabId]+'.png")',
+ 'background-repeat': 'no-repeat'
+ };
+ $('#tabs'+tabId).css(tabImgCss);
+ $('#tabs'+tabId).click(function(){
+ for(j = 0; j<TOTAL_LEVEL; j++){
+ if(tabId === j){
+ $('#tabs'+j).addClass('tabSelected');
+ }
+ else{
+ $('#tabs'+j).removeClass('tabSelected');
+ }
+ }
+ sectionNum = tabId;
+ game();
+ });
+ };
+
+ var assignAns = function (ansId){
+ $('#answerSection').append('<div id="drop'+ansId+'" class="dropObjects"></div>');
+ var dropObjCss = {
+ 'width':'125px','height': '30px','margin':'1.7em 0.5em 0.2em 0.5em' ,
+ 'border-bottom': '2px solid black','float':'left'
+ };
+ $('.dropObjects').css(dropObjCss);
+ };
+
+ var assignDragAns = function (optId){
+ $('#dragAnswers').append('<div id="drag'+optId+'" class="dragObjects">'+answersOpts[optId]+'</div>');
+ var dragObjCss = {
+ 'float': 'left','cursor': 'move',
+ 'height':'30px','padding': '0px 0.7em',
+ 'font':'25px/35px bold Arial,Verdana,Geneva,Helvetica'
+ };
+ $('.dragObjects').css(dragObjCss);
+ };
+
+ var next_questions = function(){
+ if(totalCounter === TOTAL_QUES){
+ display_game_over();
+ }
+ else{
+ currentQuestion = totalCounter;
+ flag_checked = 0;
+ genRandOpts();
+ for(i=0; i<3; i++){
+ arrangedAns[i] = 0;
+ }
+ var randImage = randImages[currentQuestion]+(sectionNum*TOTAL_QUES);
+ currentAnimal = animals[randImage];
+ var animalPlural;
+ if(currentAnimal == 'brush' || currentAnimal == 'bus'|| currentAnimal == 'bench' ){
+ animalPlural = currentAnimal+'es';
+ }
+ else{
+ animalPlural = currentAnimal+'s';
+ }
+ $('#questionSection').html('');
+ $('#imgAnimals').html('<img class="imgAnim" src = "assets/image/'+currentAnimal+'.png" />');
+ $('#questionSection').append('<div id="ques'+currentQuestion+'" class="questions"></div>');
+ $('#ques'+currentQuestion).append(totalCounter+1+'.').append(' How many ');
+ $('#ques'+currentQuestion).append(animalPlural+' are there?');
+ $('#questionSection').append('<div id="answerSection"></div>');
+ $('#answerSection').append('<div id="dropThere"></div>');
+ var dropObjCss = {
+ 'width':'125px','height': '20px','margin':'1.3em 0.5em 0.5em 0.5em' ,
+ 'border-bottom': '2px solid black','float':'left','font':'25px/5px bold Arial,Verdana,Geneva,Helvetica',
+ 'text-align':'center'
+ };
+ $('#dropThere').css(dropObjCss).append('There');
+ for(i = 0; i<3 ;i++){
+ assignAns(i);
+ }
+ $('#section').append('<div id="dot"></div>');
+ $('#questionSection').append('<div id="dragAnswers"></div>');
+ var randOption;
+
+ // generate suitable options for the option section
+ answersOpts[0] = 'is';
+ answersOpts[1] = 'are';
+ answersOpts[2] = currentAnimal;
+ answersOpts[3] = animalPlural;
+
+ answersOpts[4] = numbersWords[animalNumbers[randImage]];
+ var secondNumber;
+ do{
+ secondNumber = k.rand(0,MAX_NUMBERS);
+ }while(secondNumber == animalNumbers[randImage]);
+ answersOpts[5] = numbersWords[secondNumber];
+
+ //generate correct answer for the current Question
+ if(animalNumbers[randImage]>1){
+ correctAns[0] = 'are';
+ correctAns[2] = animalPlural;
+ }else{
+ correctAns[0] = 'is';
+ correctAns[2] = currentAnimal;
+ }
+ correctAns[1] = numbersWords[animalNumbers[randImage]];
+
+
+ for(i = 0; i<6 ;i++){
+ randOption = randOptions[i];
+ assignDragAns(randOption);
+ }
+ drag_drop();
+ }
+
+ };
+
+ function game(){
+ scoreboard.scoreboard('reset');
+ $('#linkNext').hide();
+ $('#gameOver').hide();
+ correctCounter = 0;
+ totalCounter = 0;
+ genRandPosition();
+ genRandImages();
+ $('#section').html('');
+ $('#tabs1').removeClass('tabSelected');
+ $('#tabs2').removeClass('tabSelected');
+ $('#tabs'+sectionNum).addClass('tabSelected');
+ $('#section').append('<div id="imgAnimals"></div>');
+ $('#section').append('<div id="questionSection"></div>');
+ next_questions();
+ }
+ for(i = 0; i< TOTAL_LEVEL; i++){
+ assignTabs(i);
+ }
+ sectionNum = 0;
+
+ $('#linkCheck').click(function(){
+ check_answers();
+ });
+ $('#linkStart').click(function(){
+
+ sectionNum = 0;
+ game();
+ });
+
+ $('#linkPlayAgain').click(function(){
+ game();
+ });
+
+ function drag_drop(){
+ $('.dragObjects').draggable({ containment: '#content'});
+ $('.dragObjects').bind('dragstart', function(event, ui) {
+ currentDragObject = event.target.id;
+ });
+
+ $(".dropObjects").droppable({ tolerence: 'intersect' ,hoverClass: 'drophover' });
+ $('.dropObjects').bind('drop', function(event, ui) {
+ var currentDropObject = event.target.id;
+ var droppedWord = parseInt(currentDropObject.substring(4));
+ arrangedAns[droppedWord] = $('#'+currentDragObject).text();
+ });
+ }
+
+ $('#linkHelp').mouseover(function(){
+ $('#help').slideDown(2000);
+ })
+ .mouseout(function(){
+ $('#help').slideUp(2000);
+ });
+
+
+ }); //end of k.ready
+}); //end of document.ready \ No newline at end of file
diff --git a/examples/lessons/6_English_oneOrMany/js/ui.core.js b/examples/lessons/6_English_oneOrMany/js/ui.core.js
new file mode 100755
index 0000000..5493e0a
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/js/ui.core.js
@@ -0,0 +1,519 @@
+/*
+ * jQuery UI 1.7.2
+ *
+ * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * http://docs.jquery.com/UI
+ */
+;jQuery.ui || (function($) {
+
+var _remove = $.fn.remove,
+ isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9);
+
+//Helper functions and ui object
+$.ui = {
+ version: "1.7.2",
+
+ // $.ui.plugin is deprecated. Use the proxy pattern instead.
+ plugin: {
+ add: function(module, option, set) {
+ var proto = $.ui[module].prototype;
+ for(var i in set) {
+ proto.plugins[i] = proto.plugins[i] || [];
+ proto.plugins[i].push([option, set[i]]);
+ }
+ },
+ call: function(instance, name, args) {
+ var set = instance.plugins[name];
+ if(!set || !instance.element[0].parentNode) { return; }
+
+ for (var i = 0; i < set.length; i++) {
+ if (instance.options[set[i][0]]) {
+ set[i][1].apply(instance.element, args);
+ }
+ }
+ }
+ },
+
+ contains: function(a, b) {
+ return document.compareDocumentPosition
+ ? a.compareDocumentPosition(b) & 16
+ : a !== b && a.contains(b);
+ },
+
+ hasScroll: function(el, a) {
+
+ //If overflow is hidden, the element might have extra content, but the user wants to hide it
+ if ($(el).css('overflow') == 'hidden') { return false; }
+
+ var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop',
+ has = false;
+
+ if (el[scroll] > 0) { return true; }
+
+ // TODO: determine which cases actually cause this to happen
+ // if the element doesn't have the scroll set, see if it's possible to
+ // set the scroll
+ el[scroll] = 1;
+ has = (el[scroll] > 0);
+ el[scroll] = 0;
+ return has;
+ },
+
+ isOverAxis: function(x, reference, size) {
+ //Determines when x coordinate is over "b" element axis
+ return (x > reference) && (x < (reference + size));
+ },
+
+ isOver: function(y, x, top, left, height, width) {
+ //Determines when x, y coordinates is over "b" element
+ return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width);
+ },
+
+ keyCode: {
+ BACKSPACE: 8,
+ CAPS_LOCK: 20,
+ COMMA: 188,
+ CONTROL: 17,
+ DELETE: 46,
+ DOWN: 40,
+ END: 35,
+ ENTER: 13,
+ ESCAPE: 27,
+ HOME: 36,
+ INSERT: 45,
+ LEFT: 37,
+ NUMPAD_ADD: 107,
+ NUMPAD_DECIMAL: 110,
+ NUMPAD_DIVIDE: 111,
+ NUMPAD_ENTER: 108,
+ NUMPAD_MULTIPLY: 106,
+ NUMPAD_SUBTRACT: 109,
+ PAGE_DOWN: 34,
+ PAGE_UP: 33,
+ PERIOD: 190,
+ RIGHT: 39,
+ SHIFT: 16,
+ SPACE: 32,
+ TAB: 9,
+ UP: 38
+ }
+};
+
+// WAI-ARIA normalization
+if (isFF2) {
+ var attr = $.attr,
+ removeAttr = $.fn.removeAttr,
+ ariaNS = "http://www.w3.org/2005/07/aaa",
+ ariaState = /^aria-/,
+ ariaRole = /^wairole:/;
+
+ $.attr = function(elem, name, value) {
+ var set = value !== undefined;
+
+ return (name == 'role'
+ ? (set
+ ? attr.call(this, elem, name, "wairole:" + value)
+ : (attr.apply(this, arguments) || "").replace(ariaRole, ""))
+ : (ariaState.test(name)
+ ? (set
+ ? elem.setAttributeNS(ariaNS,
+ name.replace(ariaState, "aaa:"), value)
+ : attr.call(this, elem, name.replace(ariaState, "aaa:")))
+ : attr.apply(this, arguments)));
+ };
+
+ $.fn.removeAttr = function(name) {
+ return (ariaState.test(name)
+ ? this.each(function() {
+ this.removeAttributeNS(ariaNS, name.replace(ariaState, ""));
+ }) : removeAttr.call(this, name));
+ };
+}
+
+//jQuery plugins
+$.fn.extend({
+ remove: function() {
+ // Safari has a native remove event which actually removes DOM elements,
+ // so we have to use triggerHandler instead of trigger (#3037).
+ $("*", this).add(this).each(function() {
+ $(this).triggerHandler("remove");
+ });
+ return _remove.apply(this, arguments );
+ },
+
+ enableSelection: function() {
+ return this
+ .attr('unselectable', 'off')
+ .css('MozUserSelect', '')
+ .unbind('selectstart.ui');
+ },
+
+ disableSelection: function() {
+ return this
+ .attr('unselectable', 'on')
+ .css('MozUserSelect', 'none')
+ .bind('selectstart.ui', function() { return false; });
+ },
+
+ scrollParent: function() {
+ var scrollParent;
+ if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
+ scrollParent = this.parents().filter(function() {
+ return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
+ }).eq(0);
+ } else {
+ scrollParent = this.parents().filter(function() {
+ return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
+ }).eq(0);
+ }
+
+ return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
+ }
+});
+
+
+//Additional selectors
+$.extend($.expr[':'], {
+ data: function(elem, i, match) {
+ return !!$.data(elem, match[3]);
+ },
+
+ focusable: function(element) {
+ var nodeName = element.nodeName.toLowerCase(),
+ tabIndex = $.attr(element, 'tabindex');
+ return (/input|select|textarea|button|object/.test(nodeName)
+ ? !element.disabled
+ : 'a' == nodeName || 'area' == nodeName
+ ? element.href || !isNaN(tabIndex)
+ : !isNaN(tabIndex))
+ // the element and all of its ancestors must be visible
+ // the browser may report that the area is hidden
+ && !$(element)['area' == nodeName ? 'parents' : 'closest'](':hidden').length;
+ },
+
+ tabbable: function(element) {
+ var tabIndex = $.attr(element, 'tabindex');
+ return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(':focusable');
+ }
+});
+
+
+// $.widget is a factory to create jQuery plugins
+// taking some boilerplate code out of the plugin code
+function getter(namespace, plugin, method, args) {
+ function getMethods(type) {
+ var methods = $[namespace][plugin][type] || [];
+ return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods);
+ }
+
+ var methods = getMethods('getter');
+ if (args.length == 1 && typeof args[0] == 'string') {
+ methods = methods.concat(getMethods('getterSetter'));
+ }
+ return ($.inArray(method, methods) != -1);
+}
+
+$.widget = function(name, prototype) {
+ var namespace = name.split(".")[0];
+ name = name.split(".")[1];
+
+ // create plugin method
+ $.fn[name] = function(options) {
+ var isMethodCall = (typeof options == 'string'),
+ args = Array.prototype.slice.call(arguments, 1);
+
+ // prevent calls to internal methods
+ if (isMethodCall && options.substring(0, 1) == '_') {
+ return this;
+ }
+
+ // handle getter methods
+ if (isMethodCall && getter(namespace, name, options, args)) {
+ var instance = $.data(this[0], name);
+ return (instance ? instance[options].apply(instance, args)
+ : undefined);
+ }
+
+ // handle initialization and non-getter methods
+ return this.each(function() {
+ var instance = $.data(this, name);
+
+ // constructor
+ (!instance && !isMethodCall &&
+ $.data(this, name, new $[namespace][name](this, options))._init());
+
+ // method call
+ (instance && isMethodCall && $.isFunction(instance[options]) &&
+ instance[options].apply(instance, args));
+ });
+ };
+
+ // create widget constructor
+ $[namespace] = $[namespace] || {};
+ $[namespace][name] = function(element, options) {
+ var self = this;
+
+ this.namespace = namespace;
+ this.widgetName = name;
+ this.widgetEventPrefix = $[namespace][name].eventPrefix || name;
+ this.widgetBaseClass = namespace + '-' + name;
+
+ this.options = $.extend({},
+ $.widget.defaults,
+ $[namespace][name].defaults,
+ $.metadata && $.metadata.get(element)[name],
+ options);
+
+ this.element = $(element)
+ .bind('setData.' + name, function(event, key, value) {
+ if (event.target == element) {
+ return self._setData(key, value);
+ }
+ })
+ .bind('getData.' + name, function(event, key) {
+ if (event.target == element) {
+ return self._getData(key);
+ }
+ })
+ .bind('remove', function() {
+ return self.destroy();
+ });
+ };
+
+ // add widget prototype
+ $[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype);
+
+ // TODO: merge getter and getterSetter properties from widget prototype
+ // and plugin prototype
+ $[namespace][name].getterSetter = 'option';
+};
+
+$.widget.prototype = {
+ _init: function() {},
+ destroy: function() {
+ this.element.removeData(this.widgetName)
+ .removeClass(this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled')
+ .removeAttr('aria-disabled');
+ },
+
+ option: function(key, value) {
+ var options = key,
+ self = this;
+
+ if (typeof key == "string") {
+ if (value === undefined) {
+ return this._getData(key);
+ }
+ options = {};
+ options[key] = value;
+ }
+
+ $.each(options, function(key, value) {
+ self._setData(key, value);
+ });
+ },
+ _getData: function(key) {
+ return this.options[key];
+ },
+ _setData: function(key, value) {
+ this.options[key] = value;
+
+ if (key == 'disabled') {
+ this.element
+ [value ? 'addClass' : 'removeClass'](
+ this.widgetBaseClass + '-disabled' + ' ' +
+ this.namespace + '-state-disabled')
+ .attr("aria-disabled", value);
+ }
+ },
+
+ enable: function() {
+ this._setData('disabled', false);
+ },
+ disable: function() {
+ this._setData('disabled', true);
+ },
+
+ _trigger: function(type, event, data) {
+ var callback = this.options[type],
+ eventName = (type == this.widgetEventPrefix
+ ? type : this.widgetEventPrefix + type);
+
+ event = $.Event(event);
+ event.type = eventName;
+
+ // copy original event properties over to the new event
+ // this would happen if we could call $.event.fix instead of $.Event
+ // but we don't have a way to force an event to be fixed multiple times
+ if (event.originalEvent) {
+ for (var i = $.event.props.length, prop; i;) {
+ prop = $.event.props[--i];
+ event[prop] = event.originalEvent[prop];
+ }
+ }
+
+ this.element.trigger(event, data);
+
+ return !($.isFunction(callback) && callback.call(this.element[0], event, data) === false
+ || event.isDefaultPrevented());
+ }
+};
+
+$.widget.defaults = {
+ disabled: false
+};
+
+
+/** Mouse Interaction Plugin **/
+
+$.ui.mouse = {
+ _mouseInit: function() {
+ var self = this;
+
+ this.element
+ .bind('mousedown.'+this.widgetName, function(event) {
+ return self._mouseDown(event);
+ })
+ .bind('click.'+this.widgetName, function(event) {
+ if(self._preventClickEvent) {
+ self._preventClickEvent = false;
+ event.stopImmediatePropagation();
+ return false;
+ }
+ });
+
+ // Prevent text selection in IE
+ if ($.browser.msie) {
+ this._mouseUnselectable = this.element.attr('unselectable');
+ this.element.attr('unselectable', 'on');
+ }
+
+ this.started = false;
+ },
+
+ // TODO: make sure destroying one instance of mouse doesn't mess with
+ // other instances of mouse
+ _mouseDestroy: function() {
+ this.element.unbind('.'+this.widgetName);
+
+ // Restore text selection in IE
+ ($.browser.msie
+ && this.element.attr('unselectable', this._mouseUnselectable));
+ },
+
+ _mouseDown: function(event) {
+ // don't let more than one widget handle mouseStart
+ // TODO: figure out why we have to use originalEvent
+ event.originalEvent = event.originalEvent || {};
+ if (event.originalEvent.mouseHandled) { return; }
+
+ // we may have missed mouseup (out of window)
+ (this._mouseStarted && this._mouseUp(event));
+
+ this._mouseDownEvent = event;
+
+ var self = this,
+ btnIsLeft = (event.which == 1),
+ elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false);
+ if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
+ return true;
+ }
+
+ this.mouseDelayMet = !this.options.delay;
+ if (!this.mouseDelayMet) {
+ this._mouseDelayTimer = setTimeout(function() {
+ self.mouseDelayMet = true;
+ }, this.options.delay);
+ }
+
+ if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+ this._mouseStarted = (this._mouseStart(event) !== false);
+ if (!this._mouseStarted) {
+ event.preventDefault();
+ return true;
+ }
+ }
+
+ // these delegates are required to keep context
+ this._mouseMoveDelegate = function(event) {
+ return self._mouseMove(event);
+ };
+ this._mouseUpDelegate = function(event) {
+ return self._mouseUp(event);
+ };
+ $(document)
+ .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
+ .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
+
+ // preventDefault() is used to prevent the selection of text here -
+ // however, in Safari, this causes select boxes not to be selectable
+ // anymore, so this fix is needed
+ ($.browser.safari || event.preventDefault());
+
+ event.originalEvent.mouseHandled = true;
+ return true;
+ },
+
+ _mouseMove: function(event) {
+ // IE mouseup check - mouseup happened when mouse was out of window
+ if ($.browser.msie && !event.button) {
+ return this._mouseUp(event);
+ }
+
+ if (this._mouseStarted) {
+ this._mouseDrag(event);
+ return event.preventDefault();
+ }
+
+ if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+ this._mouseStarted =
+ (this._mouseStart(this._mouseDownEvent, event) !== false);
+ (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
+ }
+
+ return !this._mouseStarted;
+ },
+
+ _mouseUp: function(event) {
+ $(document)
+ .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
+ .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
+
+ if (this._mouseStarted) {
+ this._mouseStarted = false;
+ this._preventClickEvent = (event.target == this._mouseDownEvent.target);
+ this._mouseStop(event);
+ }
+
+ return false;
+ },
+
+ _mouseDistanceMet: function(event) {
+ return (Math.max(
+ Math.abs(this._mouseDownEvent.pageX - event.pageX),
+ Math.abs(this._mouseDownEvent.pageY - event.pageY)
+ ) >= this.options.distance
+ );
+ },
+
+ _mouseDelayMet: function(event) {
+ return this.mouseDelayMet;
+ },
+
+ // These are placeholder methods, to be overriden by extending plugin
+ _mouseStart: function(event) {},
+ _mouseDrag: function(event) {},
+ _mouseStop: function(event) {},
+ _mouseCapture: function(event) { return true; }
+};
+
+$.ui.mouse.defaults = {
+ cancel: null,
+ distance: 1,
+ delay: 0
+};
+
+})(jQuery);
diff --git a/examples/lessons/6_English_oneOrMany/js/ui.draggable.js b/examples/lessons/6_English_oneOrMany/js/ui.draggable.js
new file mode 100755
index 0000000..0402f0e
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/js/ui.draggable.js
@@ -0,0 +1,766 @@
+/*
+ * jQuery UI Draggable 1.7.2
+ *
+ * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * http://docs.jquery.com/UI/Draggables
+ *
+ * Depends:
+ * ui.core.js
+ */
+(function($) {
+
+$.widget("ui.draggable", $.extend({}, $.ui.mouse, {
+
+ _init: function() {
+
+ if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
+ this.element[0].style.position = 'relative';
+
+ (this.options.addClasses && this.element.addClass("ui-draggable"));
+ (this.options.disabled && this.element.addClass("ui-draggable-disabled"));
+
+ this._mouseInit();
+
+ },
+
+ destroy: function() {
+ if(!this.element.data('draggable')) return;
+ this.element
+ .removeData("draggable")
+ .unbind(".draggable")
+ .removeClass("ui-draggable"
+ + " ui-draggable-dragging"
+ + " ui-draggable-disabled");
+ this._mouseDestroy();
+ },
+
+ _mouseCapture: function(event) {
+
+ var o = this.options;
+
+ if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle'))
+ return false;
+
+ //Quit if we're not on a valid handle
+ this.handle = this._getHandle(event);
+ if (!this.handle)
+ return false;
+
+ return true;
+
+ },
+
+ _mouseStart: function(event) {
+
+ var o = this.options;
+
+ //Create and append the visible helper
+ this.helper = this._createHelper(event);
+
+ //Cache the helper size
+ this._cacheHelperProportions();
+
+ //If ddmanager is used for droppables, set the global draggable
+ if($.ui.ddmanager)
+ $.ui.ddmanager.current = this;
+
+ /*
+ * - Position generation -
+ * This block generates everything position related - it's the core of draggables.
+ */
+
+ //Cache the margins of the original element
+ this._cacheMargins();
+
+ //Store the helper's css position
+ this.cssPosition = this.helper.css("position");
+ this.scrollParent = this.helper.scrollParent();
+
+ //The element's absolute position on the page minus margins
+ this.offset = this.element.offset();
+ this.offset = {
+ top: this.offset.top - this.margins.top,
+ left: this.offset.left - this.margins.left
+ };
+
+ $.extend(this.offset, {
+ click: { //Where the click happened, relative to the element
+ left: event.pageX - this.offset.left,
+ top: event.pageY - this.offset.top
+ },
+ parent: this._getParentOffset(),
+ relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
+ });
+
+ //Generate the original position
+ this.originalPosition = this._generatePosition(event);
+ this.originalPageX = event.pageX;
+ this.originalPageY = event.pageY;
+
+ //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
+ if(o.cursorAt)
+ this._adjustOffsetFromHelper(o.cursorAt);
+
+ //Set a containment if given in the options
+ if(o.containment)
+ this._setContainment();
+
+ //Call plugins and callbacks
+ this._trigger("start", event);
+
+ //Recache the helper size
+ this._cacheHelperProportions();
+
+ //Prepare the droppable offsets
+ if ($.ui.ddmanager && !o.dropBehaviour)
+ $.ui.ddmanager.prepareOffsets(this, event);
+
+ this.helper.addClass("ui-draggable-dragging");
+ this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
+ return true;
+ },
+
+ _mouseDrag: function(event, noPropagation) {
+
+ //Compute the helpers position
+ this.position = this._generatePosition(event);
+ this.positionAbs = this._convertPositionTo("absolute");
+
+ //Call plugins and callbacks and use the resulting position if something is returned
+ if (!noPropagation) {
+ var ui = this._uiHash();
+ this._trigger('drag', event, ui);
+ this.position = ui.position;
+ }
+
+ if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
+ if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
+ if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
+
+ return false;
+ },
+
+ _mouseStop: function(event) {
+
+ //If we are using droppables, inform the manager about the drop
+ var dropped = false;
+ if ($.ui.ddmanager && !this.options.dropBehaviour)
+ dropped = $.ui.ddmanager.drop(this, event);
+
+ //if a drop comes from outside (a sortable)
+ if(this.dropped) {
+ dropped = this.dropped;
+ this.dropped = false;
+ }
+
+ if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
+ var self = this;
+ $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
+ self._trigger("stop", event);
+ self._clear();
+ });
+ } else {
+ this._trigger("stop", event);
+ this._clear();
+ }
+
+ return false;
+ },
+
+ _getHandle: function(event) {
+
+ var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
+ $(this.options.handle, this.element)
+ .find("*")
+ .andSelf()
+ .each(function() {
+ if(this == event.target) handle = true;
+ });
+
+ return handle;
+
+ },
+
+ _createHelper: function(event) {
+
+ var o = this.options;
+ var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone() : this.element);
+
+ if(!helper.parents('body').length)
+ helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
+
+ if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
+ helper.css("position", "absolute");
+
+ return helper;
+
+ },
+
+ _adjustOffsetFromHelper: function(obj) {
+ if(obj.left != undefined) this.offset.click.left = obj.left + this.margins.left;
+ if(obj.right != undefined) this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
+ if(obj.top != undefined) this.offset.click.top = obj.top + this.margins.top;
+ if(obj.bottom != undefined) this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
+ },
+
+ _getParentOffset: function() {
+
+ //Get the offsetParent and cache its position
+ this.offsetParent = this.helper.offsetParent();
+ var po = this.offsetParent.offset();
+
+ // This is a special case where we need to modify a offset calculated on start, since the following happened:
+ // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
+ // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
+ // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
+ if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
+ po.left += this.scrollParent.scrollLeft();
+ po.top += this.scrollParent.scrollTop();
+ }
+
+ if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
+ || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
+ po = { top: 0, left: 0 };
+
+ return {
+ top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
+ left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
+ };
+
+ },
+
+ _getRelativeOffset: function() {
+
+ if(this.cssPosition == "relative") {
+ var p = this.element.position();
+ return {
+ top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
+ left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
+ };
+ } else {
+ return { top: 0, left: 0 };
+ }
+
+ },
+
+ _cacheMargins: function() {
+ this.margins = {
+ left: (parseInt(this.element.css("marginLeft"),10) || 0),
+ top: (parseInt(this.element.css("marginTop"),10) || 0)
+ };
+ },
+
+ _cacheHelperProportions: function() {
+ this.helperProportions = {
+ width: this.helper.outerWidth(),
+ height: this.helper.outerHeight()
+ };
+ },
+
+ _setContainment: function() {
+
+ var o = this.options;
+ if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
+ if(o.containment == 'document' || o.containment == 'window') this.containment = [
+ 0 - this.offset.relative.left - this.offset.parent.left,
+ 0 - this.offset.relative.top - this.offset.parent.top,
+ $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
+ ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
+ ];
+
+ if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {
+ var ce = $(o.containment)[0]; if(!ce) return;
+ var co = $(o.containment).offset();
+ var over = ($(ce).css("overflow") != 'hidden');
+
+ this.containment = [
+ co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
+ co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
+ co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
+ co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
+ ];
+ } else if(o.containment.constructor == Array) {
+ this.containment = o.containment;
+ }
+
+ },
+
+ _convertPositionTo: function(d, pos) {
+
+ if(!pos) pos = this.position;
+ var mod = d == "absolute" ? 1 : -1;
+ var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+
+ return {
+ top: (
+ pos.top // The absolute mouse position
+ + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
+ + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
+ - ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
+ ),
+ left: (
+ pos.left // The absolute mouse position
+ + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
+ + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
+ - ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
+ )
+ };
+
+ },
+
+ _generatePosition: function(event) {
+
+ var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+
+ // This is another very weird special case that only happens for relative elements:
+ // 1. If the css position is relative
+ // 2. and the scroll parent is the document or similar to the offset parent
+ // we have to refresh the relative offset during the scroll so there are no jumps
+ if(this.cssPosition == 'relative' && !(this.scrollParent[0] != document && this.scrollParent[0] != this.offsetParent[0])) {
+ this.offset.relative = this._getRelativeOffset();
+ }
+
+ var pageX = event.pageX;
+ var pageY = event.pageY;
+
+ /*
+ * - Position constraining -
+ * Constrain the position to a mix of grid, containment.
+ */
+
+ if(this.originalPosition) { //If we are not dragging yet, we won't check for options
+
+ if(this.containment) {
+ if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left;
+ if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top;
+ if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left;
+ if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top;
+ }
+
+ if(o.grid) {
+ var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
+ pageY = this.containment ? (!(top - this.offset.click.top < this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top : (!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
+
+ var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
+ pageX = this.containment ? (!(left - this.offset.click.left < this.containment[0] || left - this.offset.click.left > this.containment[2]) ? left : (!(left - this.offset.click.left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
+ }
+
+ }
+
+ return {
+ top: (
+ pageY // The absolute mouse position
+ - this.offset.click.top // Click offset (relative to the element)
+ - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
+ - this.offset.parent.top // The offsetParent's offset without borders (offset + border)
+ + ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
+ ),
+ left: (
+ pageX // The absolute mouse position
+ - this.offset.click.left // Click offset (relative to the element)
+ - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
+ - this.offset.parent.left // The offsetParent's offset without borders (offset + border)
+ + ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
+ )
+ };
+
+ },
+
+ _clear: function() {
+ this.helper.removeClass("ui-draggable-dragging");
+ if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove();
+ //if($.ui.ddmanager) $.ui.ddmanager.current = null;
+ this.helper = null;
+ this.cancelHelperRemoval = false;
+ },
+
+ // From now on bulk stuff - mainly helpers
+
+ _trigger: function(type, event, ui) {
+ ui = ui || this._uiHash();
+ $.ui.plugin.call(this, type, [event, ui]);
+ if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins
+ return $.widget.prototype._trigger.call(this, type, event, ui);
+ },
+
+ plugins: {},
+
+ _uiHash: function(event) {
+ return {
+ helper: this.helper,
+ position: this.position,
+ absolutePosition: this.positionAbs, //deprecated
+ offset: this.positionAbs
+ };
+ }
+
+}));
+
+$.extend($.ui.draggable, {
+ version: "1.7.2",
+ eventPrefix: "drag",
+ defaults: {
+ addClasses: true,
+ appendTo: "parent",
+ axis: false,
+ cancel: ":input,option",
+ connectToSortable: false,
+ containment: false,
+ cursor: "auto",
+ cursorAt: false,
+ delay: 0,
+ distance: 1,
+ grid: false,
+ handle: false,
+ helper: "original",
+ iframeFix: false,
+ opacity: false,
+ refreshPositions: false,
+ revert: false,
+ revertDuration: 500,
+ scope: "default",
+ scroll: true,
+ scrollSensitivity: 20,
+ scrollSpeed: 20,
+ snap: false,
+ snapMode: "both",
+ snapTolerance: 20,
+ stack: false,
+ zIndex: false
+ }
+});
+
+$.ui.plugin.add("draggable", "connectToSortable", {
+ start: function(event, ui) {
+
+ var inst = $(this).data("draggable"), o = inst.options,
+ uiSortable = $.extend({}, ui, { item: inst.element });
+ inst.sortables = [];
+ $(o.connectToSortable).each(function() {
+ var sortable = $.data(this, 'sortable');
+ if (sortable && !sortable.options.disabled) {
+ inst.sortables.push({
+ instance: sortable,
+ shouldRevert: sortable.options.revert
+ });
+ sortable._refreshItems(); //Do a one-time refresh at start to refresh the containerCache
+ sortable._trigger("activate", event, uiSortable);
+ }
+ });
+
+ },
+ stop: function(event, ui) {
+
+ //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
+ var inst = $(this).data("draggable"),
+ uiSortable = $.extend({}, ui, { item: inst.element });
+
+ $.each(inst.sortables, function() {
+ if(this.instance.isOver) {
+
+ this.instance.isOver = 0;
+
+ inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
+ this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
+
+ //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid'
+ if(this.shouldRevert) this.instance.options.revert = true;
+
+ //Trigger the stop of the sortable
+ this.instance._mouseStop(event);
+
+ this.instance.options.helper = this.instance.options._helper;
+
+ //If the helper has been the original item, restore properties in the sortable
+ if(inst.options.helper == 'original')
+ this.instance.currentItem.css({ top: 'auto', left: 'auto' });
+
+ } else {
+ this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
+ this.instance._trigger("deactivate", event, uiSortable);
+ }
+
+ });
+
+ },
+ drag: function(event, ui) {
+
+ var inst = $(this).data("draggable"), self = this;
+
+ var checkPos = function(o) {
+ var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
+ var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left;
+ var itemHeight = o.height, itemWidth = o.width;
+ var itemTop = o.top, itemLeft = o.left;
+
+ return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth);
+ };
+
+ $.each(inst.sortables, function(i) {
+
+ //Copy over some variables to allow calling the sortable's native _intersectsWith
+ this.instance.positionAbs = inst.positionAbs;
+ this.instance.helperProportions = inst.helperProportions;
+ this.instance.offset.click = inst.offset.click;
+
+ if(this.instance._intersectsWith(this.instance.containerCache)) {
+
+ //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
+ if(!this.instance.isOver) {
+
+ this.instance.isOver = 1;
+ //Now we fake the start of dragging for the sortable instance,
+ //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
+ //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
+ this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true);
+ this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
+ this.instance.options.helper = function() { return ui.helper[0]; };
+
+ event.target = this.instance.currentItem[0];
+ this.instance._mouseCapture(event, true);
+ this.instance._mouseStart(event, true, true);
+
+ //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
+ this.instance.offset.click.top = inst.offset.click.top;
+ this.instance.offset.click.left = inst.offset.click.left;
+ this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
+ this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
+
+ inst._trigger("toSortable", event);
+ inst.dropped = this.instance.element; //draggable revert needs that
+ //hack so receive/update callbacks work (mostly)
+ inst.currentItem = inst.element;
+ this.instance.fromOutside = inst;
+
+ }
+
+ //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable
+ if(this.instance.currentItem) this.instance._mouseDrag(event);
+
+ } else {
+
+ //If it doesn't intersect with the sortable, and it intersected before,
+ //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
+ if(this.instance.isOver) {
+
+ this.instance.isOver = 0;
+ this.instance.cancelHelperRemoval = true;
+
+ //Prevent reverting on this forced stop
+ this.instance.options.revert = false;
+
+ // The out event needs to be triggered independently
+ this.instance._trigger('out', event, this.instance._uiHash(this.instance));
+
+ this.instance._mouseStop(event, true);
+ this.instance.options.helper = this.instance.options._helper;
+
+ //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
+ this.instance.currentItem.remove();
+ if(this.instance.placeholder) this.instance.placeholder.remove();
+
+ inst._trigger("fromSortable", event);
+ inst.dropped = false; //draggable revert needs that
+ }
+
+ };
+
+ });
+
+ }
+});
+
+$.ui.plugin.add("draggable", "cursor", {
+ start: function(event, ui) {
+ var t = $('body'), o = $(this).data('draggable').options;
+ if (t.css("cursor")) o._cursor = t.css("cursor");
+ t.css("cursor", o.cursor);
+ },
+ stop: function(event, ui) {
+ var o = $(this).data('draggable').options;
+ if (o._cursor) $('body').css("cursor", o._cursor);
+ }
+});
+
+$.ui.plugin.add("draggable", "iframeFix", {
+ start: function(event, ui) {
+ var o = $(this).data('draggable').options;
+ $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
+ $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
+ .css({
+ width: this.offsetWidth+"px", height: this.offsetHeight+"px",
+ position: "absolute", opacity: "0.001", zIndex: 1000
+ })
+ .css($(this).offset())
+ .appendTo("body");
+ });
+ },
+ stop: function(event, ui) {
+ $("div.ui-draggable-iframeFix").each(function() { this.parentNode.removeChild(this); }); //Remove frame helpers
+ }
+});
+
+$.ui.plugin.add("draggable", "opacity", {
+ start: function(event, ui) {
+ var t = $(ui.helper), o = $(this).data('draggable').options;
+ if(t.css("opacity")) o._opacity = t.css("opacity");
+ t.css('opacity', o.opacity);
+ },
+ stop: function(event, ui) {
+ var o = $(this).data('draggable').options;
+ if(o._opacity) $(ui.helper).css('opacity', o._opacity);
+ }
+});
+
+$.ui.plugin.add("draggable", "scroll", {
+ start: function(event, ui) {
+ var i = $(this).data("draggable");
+ if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset();
+ },
+ drag: function(event, ui) {
+
+ var i = $(this).data("draggable"), o = i.options, scrolled = false;
+
+ if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') {
+
+ if(!o.axis || o.axis != 'x') {
+ if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
+ i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
+ else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity)
+ i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
+ }
+
+ if(!o.axis || o.axis != 'y') {
+ if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
+ i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
+ else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity)
+ i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
+ }
+
+ } else {
+
+ if(!o.axis || o.axis != 'x') {
+ if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
+ scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
+ else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
+ scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
+ }
+
+ if(!o.axis || o.axis != 'y') {
+ if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
+ scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
+ else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
+ scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
+ }
+
+ }
+
+ if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
+ $.ui.ddmanager.prepareOffsets(i, event);
+
+ }
+});
+
+$.ui.plugin.add("draggable", "snap", {
+ start: function(event, ui) {
+
+ var i = $(this).data("draggable"), o = i.options;
+ i.snapElements = [];
+
+ $(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() {
+ var $t = $(this); var $o = $t.offset();
+ if(this != i.element[0]) i.snapElements.push({
+ item: this,
+ width: $t.outerWidth(), height: $t.outerHeight(),
+ top: $o.top, left: $o.left
+ });
+ });
+
+ },
+ drag: function(event, ui) {
+
+ var inst = $(this).data("draggable"), o = inst.options;
+ var d = o.snapTolerance;
+
+ var x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
+ y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
+
+ for (var i = inst.snapElements.length - 1; i >= 0; i--){
+
+ var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width,
+ t = inst.snapElements[i].top, b = t + inst.snapElements[i].height;
+
+ //Yes, I know, this is insane ;)
+ if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) {
+ if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
+ inst.snapElements[i].snapping = false;
+ continue;
+ }
+
+ if(o.snapMode != 'inner') {
+ var ts = Math.abs(t - y2) <= d;
+ var bs = Math.abs(b - y1) <= d;
+ var ls = Math.abs(l - x2) <= d;
+ var rs = Math.abs(r - x1) <= d;
+ if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
+ if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
+ if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
+ if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
+ }
+
+ var first = (ts || bs || ls || rs);
+
+ if(o.snapMode != 'outer') {
+ var ts = Math.abs(t - y1) <= d;
+ var bs = Math.abs(b - y2) <= d;
+ var ls = Math.abs(l - x1) <= d;
+ var rs = Math.abs(r - x2) <= d;
+ if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
+ if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
+ if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
+ if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
+ }
+
+ if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))
+ (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
+ inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
+
+ };
+
+ }
+});
+
+$.ui.plugin.add("draggable", "stack", {
+ start: function(event, ui) {
+
+ var o = $(this).data("draggable").options;
+
+ var group = $.makeArray($(o.stack.group)).sort(function(a,b) {
+ return (parseInt($(a).css("zIndex"),10) || o.stack.min) - (parseInt($(b).css("zIndex"),10) || o.stack.min);
+ });
+
+ $(group).each(function(i) {
+ this.style.zIndex = o.stack.min + i;
+ });
+
+ this[0].style.zIndex = o.stack.min + group.length;
+
+ }
+});
+
+$.ui.plugin.add("draggable", "zIndex", {
+ start: function(event, ui) {
+ var t = $(ui.helper), o = $(this).data("draggable").options;
+ if(t.css("zIndex")) o._zIndex = t.css("zIndex");
+ t.css('zIndex', o.zIndex);
+ },
+ stop: function(event, ui) {
+ var o = $(this).data("draggable").options;
+ if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex);
+ }
+});
+
+})(jQuery);
diff --git a/examples/lessons/6_English_oneOrMany/js/ui.droppable.js b/examples/lessons/6_English_oneOrMany/js/ui.droppable.js
new file mode 100755
index 0000000..8e7be33
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/js/ui.droppable.js
@@ -0,0 +1,282 @@
+/*
+ * jQuery UI Droppable 1.7.2
+ *
+ * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * http://docs.jquery.com/UI/Droppables
+ *
+ * Depends:
+ * ui.core.js
+ * ui.draggable.js
+ */
+(function($) {
+
+$.widget("ui.droppable", {
+
+ _init: function() {
+
+ var o = this.options, accept = o.accept;
+ this.isover = 0; this.isout = 1;
+
+ this.options.accept = this.options.accept && $.isFunction(this.options.accept) ? this.options.accept : function(d) {
+ return d.is(accept);
+ };
+
+ //Store the droppable's proportions
+ this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
+
+ // Add the reference and positions to the manager
+ $.ui.ddmanager.droppables[this.options.scope] = $.ui.ddmanager.droppables[this.options.scope] || [];
+ $.ui.ddmanager.droppables[this.options.scope].push(this);
+
+ (this.options.addClasses && this.element.addClass("ui-droppable"));
+
+ },
+
+ destroy: function() {
+ var drop = $.ui.ddmanager.droppables[this.options.scope];
+ for ( var i = 0; i < drop.length; i++ )
+ if ( drop[i] == this )
+ drop.splice(i, 1);
+
+ this.element
+ .removeClass("ui-droppable ui-droppable-disabled")
+ .removeData("droppable")
+ .unbind(".droppable");
+ },
+
+ _setData: function(key, value) {
+
+ if(key == 'accept') {
+ this.options.accept = value && $.isFunction(value) ? value : function(d) {
+ return d.is(value);
+ };
+ } else {
+ $.widget.prototype._setData.apply(this, arguments);
+ }
+
+ },
+
+ _activate: function(event) {
+ var draggable = $.ui.ddmanager.current;
+ if(this.options.activeClass) this.element.addClass(this.options.activeClass);
+ (draggable && this._trigger('activate', event, this.ui(draggable)));
+ },
+
+ _deactivate: function(event) {
+ var draggable = $.ui.ddmanager.current;
+ if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
+ (draggable && this._trigger('deactivate', event, this.ui(draggable)));
+ },
+
+ _over: function(event) {
+
+ var draggable = $.ui.ddmanager.current;
+ if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
+
+ if (this.options.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
+ if(this.options.hoverClass) this.element.addClass(this.options.hoverClass);
+ this._trigger('over', event, this.ui(draggable));
+ }
+
+ },
+
+ _out: function(event) {
+
+ var draggable = $.ui.ddmanager.current;
+ if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
+
+ if (this.options.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
+ if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
+ this._trigger('out', event, this.ui(draggable));
+ }
+
+ },
+
+ _drop: function(event,custom) {
+
+ var draggable = custom || $.ui.ddmanager.current;
+ if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element
+
+ var childrenIntersection = false;
+ this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() {
+ var inst = $.data(this, 'droppable');
+ if(inst.options.greedy && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)) {
+ childrenIntersection = true; return false;
+ }
+ });
+ if(childrenIntersection) return false;
+
+ if(this.options.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
+ if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
+ if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
+ this._trigger('drop', event, this.ui(draggable));
+ return this.element;
+ }
+
+ return false;
+
+ },
+
+ ui: function(c) {
+ return {
+ draggable: (c.currentItem || c.element),
+ helper: c.helper,
+ position: c.position,
+ absolutePosition: c.positionAbs, //deprecated
+ offset: c.positionAbs
+ };
+ }
+
+});
+
+$.extend($.ui.droppable, {
+ version: "1.7.2",
+ eventPrefix: 'drop',
+ defaults: {
+ accept: '*',
+ activeClass: false,
+ addClasses: true,
+ greedy: false,
+ hoverClass: false,
+ scope: 'default',
+ tolerance: 'intersect'
+ }
+});
+
+$.ui.intersect = function(draggable, droppable, toleranceMode) {
+
+ if (!droppable.offset) return false;
+
+ var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
+ y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height;
+ var l = droppable.offset.left, r = l + droppable.proportions.width,
+ t = droppable.offset.top, b = t + droppable.proportions.height;
+
+ switch (toleranceMode) {
+ case 'fit':
+ return (l < x1 && x2 < r
+ && t < y1 && y2 < b);
+ break;
+ case 'intersect':
+ return (l < x1 + (draggable.helperProportions.width / 2) // Right Half
+ && x2 - (draggable.helperProportions.width / 2) < r // Left Half
+ && t < y1 + (draggable.helperProportions.height / 2) // Bottom Half
+ && y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
+ break;
+ case 'pointer':
+ var draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left),
+ draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top),
+ isOver = $.ui.isOver(draggableTop, draggableLeft, t, l, droppable.proportions.height, droppable.proportions.width);
+ return isOver;
+ break;
+ case 'touch':
+ return (
+ (y1 >= t && y1 <= b) || // Top edge touching
+ (y2 >= t && y2 <= b) || // Bottom edge touching
+ (y1 < t && y2 > b) // Surrounded vertically
+ ) && (
+ (x1 >= l && x1 <= r) || // Left edge touching
+ (x2 >= l && x2 <= r) || // Right edge touching
+ (x1 < l && x2 > r) // Surrounded horizontally
+ );
+ break;
+ default:
+ return false;
+ break;
+ }
+
+};
+
+/*
+ This manager tracks offsets of draggables and droppables
+*/
+$.ui.ddmanager = {
+ current: null,
+ droppables: { 'default': [] },
+ prepareOffsets: function(t, event) {
+
+ var m = $.ui.ddmanager.droppables[t.options.scope];
+ var type = event ? event.type : null; // workaround for #2317
+ var list = (t.currentItem || t.element).find(":data(droppable)").andSelf();
+
+ droppablesLoop: for (var i = 0; i < m.length; i++) {
+
+ if(m[i].options.disabled || (t && !m[i].options.accept.call(m[i].element[0],(t.currentItem || t.element)))) continue; //No disabled and non-accepted
+ for (var j=0; j < list.length; j++) { if(list[j] == m[i].element[0]) { m[i].proportions.height = 0; continue droppablesLoop; } }; //Filter out elements in the current dragged item
+ m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue; //If the element is not visible, continue
+
+ m[i].offset = m[i].element.offset();
+ m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
+
+ if(type == "mousedown") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables
+
+ }
+
+ },
+ drop: function(draggable, event) {
+
+ var dropped = false;
+ $.each($.ui.ddmanager.droppables[draggable.options.scope], function() {
+
+ if(!this.options) return;
+ if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))
+ dropped = this._drop.call(this, event);
+
+ if (!this.options.disabled && this.visible && this.options.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
+ this.isout = 1; this.isover = 0;
+ this._deactivate.call(this, event);
+ }
+
+ });
+ return dropped;
+
+ },
+ drag: function(draggable, event) {
+
+ //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
+ if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, event);
+
+ //Run through all droppables and check their positions based on specific tolerance options
+
+ $.each($.ui.ddmanager.droppables[draggable.options.scope], function() {
+
+ if(this.options.disabled || this.greedyChild || !this.visible) return;
+ var intersects = $.ui.intersect(draggable, this, this.options.tolerance);
+
+ var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null);
+ if(!c) return;
+
+ var parentInstance;
+ if (this.options.greedy) {
+ var parent = this.element.parents(':data(droppable):eq(0)');
+ if (parent.length) {
+ parentInstance = $.data(parent[0], 'droppable');
+ parentInstance.greedyChild = (c == 'isover' ? 1 : 0);
+ }
+ }
+
+ // we just moved into a greedy child
+ if (parentInstance && c == 'isover') {
+ parentInstance['isover'] = 0;
+ parentInstance['isout'] = 1;
+ parentInstance._out.call(parentInstance, event);
+ }
+
+ this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0;
+ this[c == "isover" ? "_over" : "_out"].call(this, event);
+
+ // we just moved out of a greedy child
+ if (parentInstance && c == 'isout') {
+ parentInstance['isout'] = 0;
+ parentInstance['isover'] = 1;
+ parentInstance._over.call(parentInstance, event);
+ }
+ });
+
+ }
+};
+
+})(jQuery);
diff --git a/examples/lessons/6_English_oneOrMany/js/ui.scoreboard.js b/examples/lessons/6_English_oneOrMany/js/ui.scoreboard.js
new file mode 100755
index 0000000..53a930a
--- /dev/null
+++ b/examples/lessons/6_English_oneOrMany/js/ui.scoreboard.js
@@ -0,0 +1,107 @@
+(function($){
+ $.widget('ui.scoreboard',
+ {
+ getScore : function(){
+ return this._getData('score');
+ },
+ setScore : function(newScore){
+ this._setData('score', parseInt(newScore));
+ this._refresh();
+ },
+ getTotal : function(){
+ return this._getData('total');
+ },
+ setTotal : function(newTotal){
+ this._setData('total', parseInt(newTotal));
+ this._refresh();
+ },
+ reset : function(){
+ this._setData('score', this._getData('initialScore'));
+ this._setData('total', this._getData('initialTotal'));
+ this._refresh();
+ },
+ inc : function(val){
+ var incVal = parseInt(val) || 1;
+ this._setData('score', this._getData('score') + incVal);
+ this._refresh();
+ if(this._getData('winScore') === this._getData('score')){
+ this.element.trigger('winGame');
+ }
+ },
+ incTotal : function(val){
+ var incVal = parseInt(val) || 1;
+ this._setData('total', this._getData('total') + incVal);
+ this._refresh();
+ },
+ dec : function(val){
+ var decVal = parseInt(val) || 1;
+ this._setData('score', this._getData('score') - decVal);
+ this._refresh();
+ },
+ decTotal : function(val){
+ var decVal = parseInt(val) || 1;
+ this._setData('total', this._getData('total') - decVal);
+ this._refresh();
+ },
+ _init : function(){
+
+ var divDisplay = "inline";
+ var score = this.options.score;
+ var total = this.options.total;
+ var layoutId = "h";
+ var self = this;
+
+
+ this._setData('initialScore', parseInt(this.options.score));
+ this._setData('initialTotal', parseInt(this.options.total));
+ this._setData('score', parseInt(this.options.score));
+ this._setData('total', parseInt(this.options.total));
+ this._setData('winScore', parseInt(this.options.winningScore) || 0);
+
+ if(this.options.layout === "vertical"){
+ layoutId = "v";
+ }
+
+ this.evWinGame = document.createEvent('Events');
+
+ this.element.addClass('ui-scoreboard-container-' + layoutId +
+ ' ui-widget ui-widget-content ui-corner-all');
+
+ var clone = $('<div>')
+ .addClass('ui-scoreboard-spacing-' + layoutId);
+ this._scoreText = $("<div>Score</div>")
+ .addClass('ui-scoreboard-spacing-'+ layoutId +
+ ' ui-corner-all ui-scoreboard-text')
+ .appendTo(this.element);
+ this._score = $("<div>" + score + "</div>")
+ .addClass('ui-scoreboard-spacing-' + layoutId +
+ ' ui-scoreboard-number-' + layoutId)
+ .appendTo(this.element);
+ $("<div>Total</div>")
+ .addClass('ui-scoreboard-spacing-' + layoutId +
+ ' ui-corner-all ' +
+ 'ui-scoreboard-text')
+ .appendTo(this.element);
+ this._total = $("<div>" + total + "</div>")
+ .addClass('ui-scoreboard-spacing-' + layoutId +
+ ' ui-scoreboard-number-' + layoutId)
+ .appendTo(this.element);
+ },
+ _refresh : function(){
+ this._score.text(this._getData('score'));
+ this._total.text(this._getData('total'));
+ },
+ destroy : function(){
+ this.element.remove();
+ $.widget.prototype.destroy.apply(this, arguments);
+ }
+
+
+ });
+
+ $.ui.scoreboard.getter = ['getScore', 'getTotal'];
+ $.ui.scoreboard.defaults = {
+ score: 0, total: 0, layout: "horizontal", winningScore: 0
+ };
+
+ })(jQuery); \ No newline at end of file
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/audio/apple.wav b/examples/lessons/6_English_whatsThisLetter/assets/audio/apple.wav
new file mode 100755
index 0000000..aa15243
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/audio/apple.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/audio/banana.wav b/examples/lessons/6_English_whatsThisLetter/assets/audio/banana.wav
new file mode 100755
index 0000000..5066c59
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/audio/banana.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/audio/boat.wav b/examples/lessons/6_English_whatsThisLetter/assets/audio/boat.wav
new file mode 100755
index 0000000..5131b2a
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/audio/boat.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/audio/book.wav b/examples/lessons/6_English_whatsThisLetter/assets/audio/book.wav
new file mode 100755
index 0000000..dcdb483
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/audio/book.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/audio/bus.wav b/examples/lessons/6_English_whatsThisLetter/assets/audio/bus.wav
new file mode 100755
index 0000000..8db7671
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/audio/bus.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/audio/cake.wav b/examples/lessons/6_English_whatsThisLetter/assets/audio/cake.wav
new file mode 100755
index 0000000..07e78b6
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/audio/cake.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/audio/car.wav b/examples/lessons/6_English_whatsThisLetter/assets/audio/car.wav
new file mode 100755
index 0000000..2733bfc
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/audio/car.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/audio/correct.ogg b/examples/lessons/6_English_whatsThisLetter/assets/audio/correct.ogg
new file mode 100755
index 0000000..a0d9e3a
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/audio/correct.ogg
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/audio/cow.wav b/examples/lessons/6_English_whatsThisLetter/assets/audio/cow.wav
new file mode 100755
index 0000000..edcece5
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/audio/cow.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/audio/flower.wav b/examples/lessons/6_English_whatsThisLetter/assets/audio/flower.wav
new file mode 100755
index 0000000..c8710af
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/audio/flower.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/audio/hat.wav b/examples/lessons/6_English_whatsThisLetter/assets/audio/hat.wav
new file mode 100755
index 0000000..62ab73e
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/audio/hat.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/audio/incorrect.ogg b/examples/lessons/6_English_whatsThisLetter/assets/audio/incorrect.ogg
new file mode 100755
index 0000000..4805e55
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/audio/incorrect.ogg
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/audio/kite.wav b/examples/lessons/6_English_whatsThisLetter/assets/audio/kite.wav
new file mode 100755
index 0000000..6d8c65f
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/audio/kite.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/audio/lamp.wav b/examples/lessons/6_English_whatsThisLetter/assets/audio/lamp.wav
new file mode 100755
index 0000000..d174df3
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/audio/lamp.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/audio/pig.wav b/examples/lessons/6_English_whatsThisLetter/assets/audio/pig.wav
new file mode 100755
index 0000000..9b45e34
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/audio/pig.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/audio/pigeon.wav b/examples/lessons/6_English_whatsThisLetter/assets/audio/pigeon.wav
new file mode 100755
index 0000000..4146930
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/audio/pigeon.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/audio/rat.wav b/examples/lessons/6_English_whatsThisLetter/assets/audio/rat.wav
new file mode 100755
index 0000000..9d8723d
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/audio/rat.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/audio/tomato.wav b/examples/lessons/6_English_whatsThisLetter/assets/audio/tomato.wav
new file mode 100755
index 0000000..86f1144
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/audio/tomato.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/audio/tree.wav b/examples/lessons/6_English_whatsThisLetter/assets/audio/tree.wav
new file mode 100755
index 0000000..3444ed5
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/audio/tree.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/ant.png b/examples/lessons/6_English_whatsThisLetter/assets/image/ant.png
new file mode 100755
index 0000000..82a26bb
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/ant.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/apple.png b/examples/lessons/6_English_whatsThisLetter/assets/image/apple.png
new file mode 100755
index 0000000..a09c8c5
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/apple.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/banana.png b/examples/lessons/6_English_whatsThisLetter/assets/image/banana.png
new file mode 100755
index 0000000..5c1f1a1
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/banana.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/bg_footer.png b/examples/lessons/6_English_whatsThisLetter/assets/image/bg_footer.png
new file mode 100755
index 0000000..8982264
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/bg_footer.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/bg_header.png b/examples/lessons/6_English_whatsThisLetter/assets/image/bg_header.png
new file mode 100755
index 0000000..98213f7
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/bg_header.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/bg_title_block.png b/examples/lessons/6_English_whatsThisLetter/assets/image/bg_title_block.png
new file mode 100755
index 0000000..2c9dacf
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/bg_title_block.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/boat.png b/examples/lessons/6_English_whatsThisLetter/assets/image/boat.png
new file mode 100755
index 0000000..cc41d58
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/boat.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/book.png b/examples/lessons/6_English_whatsThisLetter/assets/image/book.png
new file mode 100755
index 0000000..ec53795
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/book.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/btn_back.png b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_back.png
new file mode 100755
index 0000000..d9fbf14
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_back.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/btn_back_hover.png b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_back_hover.png
new file mode 100755
index 0000000..0911fcc
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_back_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/btn_help.png b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_help.png
new file mode 100755
index 0000000..6753e9c
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_help.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/btn_help_hover.png b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_help_hover.png
new file mode 100755
index 0000000..d3ccd92
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_help_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/btn_next.png b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_next.png
new file mode 100755
index 0000000..9d70993
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_next.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/btn_next_hover.png b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_next_hover.png
new file mode 100755
index 0000000..2cd4d37
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_next_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/btn_ole.png b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_ole.png
new file mode 100755
index 0000000..0e775e9
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_ole.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/btn_ole_hover.png b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_ole_hover.png
new file mode 100755
index 0000000..c43c5f7
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_ole_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/btn_play_again.png b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_play_again.png
new file mode 100755
index 0000000..3594d18
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_play_again.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/btn_play_again_hover.png b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_play_again_hover.png
new file mode 100755
index 0000000..ebb8f8c
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_play_again_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/btn_play_again_mouse_down.png b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_play_again_mouse_down.png
new file mode 100755
index 0000000..07d6e45
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_play_again_mouse_down.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/btn_start.png b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_start.png
new file mode 100755
index 0000000..32e5f20
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_start.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/btn_start_hover.png b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_start_hover.png
new file mode 100755
index 0000000..811ce78
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_start_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/btn_start_mouse_down.png b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_start_mouse_down.png
new file mode 100755
index 0000000..5acd43b
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/btn_start_mouse_down.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/bus.png b/examples/lessons/6_English_whatsThisLetter/assets/image/bus.png
new file mode 100755
index 0000000..d0db371
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/bus.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/cake.png b/examples/lessons/6_English_whatsThisLetter/assets/image/cake.png
new file mode 100755
index 0000000..569e7fd
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/cake.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/car.png b/examples/lessons/6_English_whatsThisLetter/assets/image/car.png
new file mode 100755
index 0000000..72b7a47
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/car.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/cow.png b/examples/lessons/6_English_whatsThisLetter/assets/image/cow.png
new file mode 100755
index 0000000..205fd8e
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/cow.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/flower.png b/examples/lessons/6_English_whatsThisLetter/assets/image/flower.png
new file mode 100755
index 0000000..11ef0e7
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/flower.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/hat.png b/examples/lessons/6_English_whatsThisLetter/assets/image/hat.png
new file mode 100755
index 0000000..691ec6d
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/hat.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/help.png b/examples/lessons/6_English_whatsThisLetter/assets/image/help.png
new file mode 100755
index 0000000..2a2ec47
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/help.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/kite.png b/examples/lessons/6_English_whatsThisLetter/assets/image/kite.png
new file mode 100755
index 0000000..c07a545
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/kite.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/ladybird.png b/examples/lessons/6_English_whatsThisLetter/assets/image/ladybird.png
new file mode 100755
index 0000000..5b40810
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/ladybird.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/lamp.png b/examples/lessons/6_English_whatsThisLetter/assets/image/lamp.png
new file mode 100755
index 0000000..ad94f45
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/lamp.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/pig.png b/examples/lessons/6_English_whatsThisLetter/assets/image/pig.png
new file mode 100755
index 0000000..c523e35
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/pig.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/pigeon.png b/examples/lessons/6_English_whatsThisLetter/assets/image/pigeon.png
new file mode 100755
index 0000000..6c0edd7
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/pigeon.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/rat.png b/examples/lessons/6_English_whatsThisLetter/assets/image/rat.png
new file mode 100755
index 0000000..44934a4
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/rat.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/socks.png b/examples/lessons/6_English_whatsThisLetter/assets/image/socks.png
new file mode 100755
index 0000000..0e85c41
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/socks.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/title_block_lt.png b/examples/lessons/6_English_whatsThisLetter/assets/image/title_block_lt.png
new file mode 100755
index 0000000..4696182
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/title_block_lt.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/title_block_rt.png b/examples/lessons/6_English_whatsThisLetter/assets/image/title_block_rt.png
new file mode 100755
index 0000000..37cc44a
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/title_block_rt.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/tomato.png b/examples/lessons/6_English_whatsThisLetter/assets/image/tomato.png
new file mode 100755
index 0000000..f92c972
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/tomato.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/assets/image/tree.png b/examples/lessons/6_English_whatsThisLetter/assets/image/tree.png
new file mode 100755
index 0000000..d3df317
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/assets/image/tree.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisLetter/css/lesson.css b/examples/lessons/6_English_whatsThisLetter/css/lesson.css
new file mode 100755
index 0000000..462a640
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/css/lesson.css
@@ -0,0 +1,247 @@
+@CHARSET "UTF-8";
+/****** Page Styles ****/
+
+/* Designed for 1200*900 px screen resolution */
+
+body {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 10pt;
+ margin: 0px;
+ background-color: #FFFFCC;
+}
+#header {
+ background-image: url(../assets/image/bg_header.png);
+ background-repeat: repeat-x;
+ height: 75px;
+ width: 100%;
+ position: absolute;
+ left: 0px;
+ top: 0px;
+}
+#topbtn_left {
+ float: left;
+ height: 60px;
+ width: 60px;
+ padding-top: 6px;
+ padding-left: 15px;
+}
+
+
+ .linkBack{
+ width: 60px; height: 59px;
+ background:url(../assets/image/btn_back.png);
+ }
+ .linkBack:hover{
+ background:url(../assets/image/btn_back_hover.png);
+ }
+
+#lesson_title {
+ float: left;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 16pt;
+ font-weight: bold;
+ color: #FFFFFF;
+ margin-left: 10px;
+ background-image: url(../assets/image/bg_title_block.png);
+}
+#topbtn_right {
+ float: right;
+ height: 60px;
+ width: 60px;
+ padding-top: 6px;
+ padding-right: 15px;
+}
+ #linkHelp{
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_help.png);
+ }
+ #linkHelp:hover{
+ background:url(../assets/image/btn_help_hover.png);
+ }
+ #linkOle{
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_ole.png);
+ }
+ #linkOle:hover{
+ background:url(../assets/image/btn_ole_hover.png);
+ }
+ .linkNext{var bindImgCss = {
+ 'float':'left',
+ 'width': '450px',
+ 'height':'40px',
+ 'margin-top':'0.25em',
+ 'text-align':'center',
+ 'padding-bottom':'0.3em'
+ };
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_next.png);
+ }
+ .linkNext:hover{
+ background:url(../assets/image/btn_next_hover.png);
+ }
+#footer {
+ position:relative;
+ background-image: url(../assets/image/bg_footer.png);
+ background-repeat: repeat-x;
+ height: 75px;
+ width: 100%;
+ left: 0px;
+ bottom: 0px;
+}
+#score_box {
+ float: left;
+ padding-left: 5px;
+ padding-top: 0.7em;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #FFFF00;
+ font-size: 16pt;
+ font-weight: bold;
+}
+#botbtn_right {
+ float: right;
+ height: 55px;
+ padding-right: 5px;
+ padding-top: 10px;
+}
+ #linkCheck{
+ margin: 1em 3em 0 0;
+ width: 101px; height: 30px;
+ background-image: url(../assets/image/check.png);
+ }
+
+ #linkStart{
+ width: 251px; height: 55px;
+ background:url(../assets/image/btn_start.png);
+ }
+ #linkStart:hover{
+ background:url(../assets/image/btn_start_hover.png);
+ }
+ #linkStart:active{
+ background:url(../assets/image/btn_start_mouse_down.png);
+ }
+ #linkPlayAgain{
+ width: 251px; height: 55px;
+ background:url(../assets/image/btn_play_again.png);
+ }
+ #linkPlayAgain:hover{
+ background:url(../assets/image/btn_play_again_hover.png);
+ }
+ #linkPlayAgain:active{
+ background:url(../assets/image/btn_play_again_mouse_down.png);
+ }
+#linkNextLesson{
+ position:absolute;
+ bottom: 75px;
+ right: 10px;
+}
+#linkPrevLesson{
+ position:absolute;
+ bottom: 75px;
+ left: 10px;
+}
+
+/**** End of the page style ****/
+
+/**** Game Styles ****/
+
+a{
+ color:#FFFFCC;
+}
+#currentTitle{
+ width: 150px;
+ height: 80px;
+ font:25px/30px "Courier New", Courier, monospace;
+ font-weight: bold;
+ color: red;
+}
+#content{
+ position:relative;
+ margin: 0 auto;
+ margin-top: 75px;
+ width: 1198px;
+ height: 560px;
+
+}
+
+ #questionSection{
+ position:absolute;
+ top: 150px;
+ left: 270px;
+ width: 350px;
+ text-align:center;
+ }
+ #question{
+ position:relative;
+ display:block;
+ margin-top: 0.25em;
+ font: 40px Arial, Helvetica, sans-serif;
+ color: #000;
+ }
+ #answers{
+ position:relative;
+ font: 40px Arial, Helvetica, sans-serif;
+ color: #000;
+ text-align:center;
+ }
+
+ input.blankBox{
+ font: 35px Verdana, Geneva, Arial, Helvetica, sans-serif;
+ height:40px;
+ width: 30px;
+ color:red;
+
+ text-align:center;
+ }
+ .focus {
+ /* border: 2px solid #AA88FF;*/
+ background-color: #FFEEAA;
+ }
+ .correct{
+ background-color: #C0F9F3;
+ }
+ .incorrect{
+ background-color: #FFFF00;
+ }
+ .backOpaque{
+ background-color: #A4A4A4;
+ opacity: 0.2;
+ }
+
+#help{
+ display:none;
+ position:absolute;
+ right: 60px;
+ top: 75px;;
+ width: 256px;
+ height: 600px;
+ background:url(../assets/image/help.png);
+ z-index:40;
+}
+
+
+ #gameOver{
+ opacity: 1;
+ display:none;
+ position:absolute;
+ top:45%;
+ left: 30%;
+ color: blue;
+ text-align:center;
+ font : bold 45px/65px Arial Black, Times New Roman;
+ }
+ #gameOverInfo{
+ margin-top: 35px;
+ text-align:center;
+ font: 20px/25px Helvetica, Geneva, Arial, Verdana, sans-serif;
+ font-weight:bold;
+ color:#FF0000;
+
+ }
+ .specialText{
+ margin-top: 1em;
+ font: 20px/25px Helvetica, Geneva, Arial, Verdana, sans-serif;
+ font-weight:bold;
+ color:#FF9900;
+ border-bottom: 2px dotted #CCC;
+
+ }
diff --git a/examples/lessons/6_English_whatsThisLetter/css/ui.scoreboard.css b/examples/lessons/6_English_whatsThisLetter/css/ui.scoreboard.css
new file mode 100755
index 0000000..11cdbb5
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/css/ui.scoreboard.css
@@ -0,0 +1,62 @@
+.ui-scoreboard-container-h{
+max-width: 800em;
+max-height: 200px;
+float:left;
+padding-top:0.4em;
+padding-bottom:0.4em;
+}
+
+.ui-scoreboard-spacing-h{
+max-width: 200em;
+max-height: 300em;
+display:inline;
+margin-left:0.2em;
+margin-right:0.4em;
+}
+
+.ui-scoreboard-text{
+font-size:larger;
+text-align: center;
+}
+
+.ui-scoreboard-number-h {
+background-color:black;
+color: white;
+padding-left:0.4em;
+padding-right:0.4em;
+font-size:larger;
+}
+
+.ui-scoreboard-button{
+float:right;
+cursor:pointer;
+}
+
+button .ui-scoreboard-icon{
+float: left;
+margin-right:0.3em;
+}
+.ui-scoreboard-container-v{
+max-width: 200px;
+max-height: 400px;
+float:left;
+padding-top:0.4em;
+padding-bottom:0.4em;
+}
+.ui-scoreboard-spacing-v{
+display:block;
+margin: 0.4em;
+}
+
+.ui-scoreboard-number-v{
+background-color:black;
+color: white;
+width: 1em;
+text-align:center;
+margin-left:auto;
+margin-right: auto;
+padding:0.4em;
+font-size:larger;
+}
+
+
diff --git a/examples/lessons/6_English_whatsThisLetter/index.html b/examples/lessons/6_English_whatsThisLetter/index.html
new file mode 100755
index 0000000..feec44a
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/index.html
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Class 6 English What This Letter</title>
+ <meta name="keywords" content="karma,javascript,html5,sugar,sugarlabs,gsoc,ole,nepal" />
+ <link type="text/css" rel="stylesheet" href="css/ui.scoreboard.css" />
+ <link type="text/css" rel="stylesheet" href="css/lesson.css" />
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <link type="image/ico" rel="icon" href="../../assets/default/image/favicon.ico" />
+ <script type="text/javascript" src="js/jquery-1.4.js"></script>
+ <script type="text/javascript" src="js/ui.core.js"></script>
+ <script type="text/javascript" src="js/ui.scoreboard.js"></script>
+ <script type="text/javascript" src="js/karma.js"></script>
+ <script type="text/javascript" src="js/jquery.watermarkinput.js"></script>
+ <script type="text/javascript" src="js/lesson.js"></script>
+</head>
+<body>
+ <div id="header">
+ <div id="topbtn_left"><a href="#"><div id="linkBackLesson" class="linkBack"></div></a></div>
+ <div id="lesson_title">
+ <img src="assets/image/title_block_lt.png" width="33" height="75" align="absmiddle" />
+ What This Letter <span id="currentTitle"></span>
+ <img src="assets/image/title_block_rt.png" width="33" height="75" align="absmiddle" />
+ </div>
+ <div id="topbtn_right"><a href="#"><div id="linkHelp"></div></a></div>
+ <div id="topbtn_right"><a href="http://olenepal.org"><div id="linkOle"></div></a></div>
+ </div>
+
+ <div id="content"></div>
+ <div id="help"></div>
+ <div id="gameOver"></div>
+ <form name="delayForm">
+ <input type="hidden" name="delayval" size="5">
+ </form>
+
+ <div id="footer">
+ <div id="botbtn_right"><a href="#"><div id="linkPlayAgain"></div></a></div>
+ <div id="botbtn_right"><a href="#"><div id="linkStart"></div></a></div>
+ <div id="score_box"></div>
+ </div>
+</body>
+</html>
diff --git a/examples/lessons/6_English_whatsThisLetter/js/jquery-1.4.js b/examples/lessons/6_English_whatsThisLetter/js/jquery-1.4.js
new file mode 100755
index 0000000..a448490
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/js/jquery-1.4.js
@@ -0,0 +1,5999 @@
+/*!
+ * jQuery JavaScript Library v1.4
+ * http://jquery.com/
+ *
+ * Copyright 2010, John Resig
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://docs.jquery.com/License
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ * Copyright 2010, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ *
+ * Date: Wed Jan 13 15:23:05 2010 -0500
+ */
+(function( window, undefined ) {
+
+// Define a local copy of jQuery
+var jQuery = function( selector, context ) {
+ // The jQuery object is actually just the init constructor 'enhanced'
+ return new jQuery.fn.init( selector, context );
+ },
+
+ // Map over jQuery in case of overwrite
+ _jQuery = window.jQuery,
+
+ // Map over the $ in case of overwrite
+ _$ = window.$,
+
+ // Use the correct document accordingly with window argument (sandbox)
+ document = window.document,
+
+ // A central reference to the root jQuery(document)
+ rootjQuery,
+
+ // A simple way to check for HTML strings or ID strings
+ // (both of which we optimize for)
+ quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,
+
+ // Is it a simple selector
+ isSimple = /^.[^:#\[\.,]*$/,
+
+ // Check if a string has a non-whitespace character in it
+ rnotwhite = /\S/,
+
+ // Used for trimming whitespace
+ rtrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g,
+
+ // Match a standalone tag
+ rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
+
+ // Keep a UserAgent string for use with jQuery.browser
+ userAgent = navigator.userAgent,
+
+ // For matching the engine and version of the browser
+ browserMatch,
+
+ // Has the ready events already been bound?
+ readyBound = false,
+
+ // The functions to execute on DOM ready
+ readyList = [],
+
+ // The ready event handler
+ DOMContentLoaded,
+
+ // Save a reference to some core methods
+ toString = Object.prototype.toString,
+ hasOwnProperty = Object.prototype.hasOwnProperty,
+ push = Array.prototype.push,
+ slice = Array.prototype.slice,
+ indexOf = Array.prototype.indexOf;
+
+jQuery.fn = jQuery.prototype = {
+ init: function( selector, context ) {
+ var match, elem, ret, doc;
+
+ // Handle $(""), $(null), or $(undefined)
+ if ( !selector ) {
+ return this;
+ }
+
+ // Handle $(DOMElement)
+ if ( selector.nodeType ) {
+ this.context = this[0] = selector;
+ this.length = 1;
+ return this;
+ }
+
+ // Handle HTML strings
+ if ( typeof selector === "string" ) {
+ // Are we dealing with HTML string or an ID?
+ match = quickExpr.exec( selector );
+
+ // Verify a match, and that no context was specified for #id
+ if ( match && (match[1] || !context) ) {
+
+ // HANDLE: $(html) -> $(array)
+ if ( match[1] ) {
+ doc = (context ? context.ownerDocument || context : document);
+
+ // If a single string is passed in and it's a single tag
+ // just do a createElement and skip the rest
+ ret = rsingleTag.exec( selector );
+
+ if ( ret ) {
+ if ( jQuery.isPlainObject( context ) ) {
+ selector = [ document.createElement( ret[1] ) ];
+ jQuery.fn.attr.call( selector, context, true );
+
+ } else {
+ selector = [ doc.createElement( ret[1] ) ];
+ }
+
+ } else {
+ ret = buildFragment( [ match[1] ], [ doc ] );
+ selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
+ }
+
+ // HANDLE: $("#id")
+ } else {
+ elem = document.getElementById( match[2] );
+
+ if ( elem ) {
+ // Handle the case where IE and Opera return items
+ // by name instead of ID
+ if ( elem.id !== match[2] ) {
+ return rootjQuery.find( selector );
+ }
+
+ // Otherwise, we inject the element directly into the jQuery object
+ this.length = 1;
+ this[0] = elem;
+ }
+
+ this.context = document;
+ this.selector = selector;
+ return this;
+ }
+
+ // HANDLE: $("TAG")
+ } else if ( !context && /^\w+$/.test( selector ) ) {
+ this.selector = selector;
+ this.context = document;
+ selector = document.getElementsByTagName( selector );
+
+ // HANDLE: $(expr, $(...))
+ } else if ( !context || context.jquery ) {
+ return (context || rootjQuery).find( selector );
+
+ // HANDLE: $(expr, context)
+ // (which is just equivalent to: $(context).find(expr)
+ } else {
+ return jQuery( context ).find( selector );
+ }
+
+ // HANDLE: $(function)
+ // Shortcut for document ready
+ } else if ( jQuery.isFunction( selector ) ) {
+ return rootjQuery.ready( selector );
+ }
+
+ if (selector.selector !== undefined) {
+ this.selector = selector.selector;
+ this.context = selector.context;
+ }
+
+ return jQuery.isArray( selector ) ?
+ this.setArray( selector ) :
+ jQuery.makeArray( selector, this );
+ },
+
+ // Start with an empty selector
+ selector: "",
+
+ // The current version of jQuery being used
+ jquery: "1.4",
+
+ // The default length of a jQuery object is 0
+ length: 0,
+
+ // The number of elements contained in the matched element set
+ size: function() {
+ return this.length;
+ },
+
+ toArray: function() {
+ return slice.call( this, 0 );
+ },
+
+ // Get the Nth element in the matched element set OR
+ // Get the whole matched element set as a clean array
+ get: function( num ) {
+ return num == null ?
+
+ // Return a 'clean' array
+ this.toArray() :
+
+ // Return just the object
+ ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
+ },
+
+ // Take an array of elements and push it onto the stack
+ // (returning the new matched element set)
+ pushStack: function( elems, name, selector ) {
+ // Build a new jQuery matched element set
+ var ret = jQuery( elems || null );
+
+ // Add the old object onto the stack (as a reference)
+ ret.prevObject = this;
+
+ ret.context = this.context;
+
+ if ( name === "find" ) {
+ ret.selector = this.selector + (this.selector ? " " : "") + selector;
+ } else if ( name ) {
+ ret.selector = this.selector + "." + name + "(" + selector + ")";
+ }
+
+ // Return the newly-formed element set
+ return ret;
+ },
+
+ // Force the current matched set of elements to become
+ // the specified array of elements (destroying the stack in the process)
+ // You should use pushStack() in order to do this, but maintain the stack
+ setArray: function( elems ) {
+ // Resetting the length to 0, then using the native Array push
+ // is a super-fast way to populate an object with array-like properties
+ this.length = 0;
+ push.apply( this, elems );
+
+ return this;
+ },
+
+ // Execute a callback for every element in the matched set.
+ // (You can seed the arguments with an array of args, but this is
+ // only used internally.)
+ each: function( callback, args ) {
+ return jQuery.each( this, callback, args );
+ },
+
+ ready: function( fn ) {
+ // Attach the listeners
+ jQuery.bindReady();
+
+ // If the DOM is already ready
+ if ( jQuery.isReady ) {
+ // Execute the function immediately
+ fn.call( document, jQuery );
+
+ // Otherwise, remember the function for later
+ } else if ( readyList ) {
+ // Add the function to the wait list
+ readyList.push( fn );
+ }
+
+ return this;
+ },
+
+ eq: function( i ) {
+ return i === -1 ?
+ this.slice( i ) :
+ this.slice( i, +i + 1 );
+ },
+
+ first: function() {
+ return this.eq( 0 );
+ },
+
+ last: function() {
+ return this.eq( -1 );
+ },
+
+ slice: function() {
+ return this.pushStack( slice.apply( this, arguments ),
+ "slice", slice.call(arguments).join(",") );
+ },
+
+ map: function( callback ) {
+ return this.pushStack( jQuery.map(this, function( elem, i ) {
+ return callback.call( elem, i, elem );
+ }));
+ },
+
+ end: function() {
+ return this.prevObject || jQuery(null);
+ },
+
+ // For internal use only.
+ // Behaves like an Array's method, not like a jQuery method.
+ push: push,
+ sort: [].sort,
+ splice: [].splice
+};
+
+// Give the init function the jQuery prototype for later instantiation
+jQuery.fn.init.prototype = jQuery.fn;
+
+jQuery.extend = jQuery.fn.extend = function() {
+ // copy reference to target object
+ var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy;
+
+ // Handle a deep copy situation
+ if ( typeof target === "boolean" ) {
+ deep = target;
+ target = arguments[1] || {};
+ // skip the boolean and the target
+ i = 2;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
+ target = {};
+ }
+
+ // extend jQuery itself if only one argument is passed
+ if ( length === i ) {
+ target = this;
+ --i;
+ }
+
+ for ( ; i < length; i++ ) {
+ // Only deal with non-null/undefined values
+ if ( (options = arguments[ i ]) != null ) {
+ // Extend the base object
+ for ( name in options ) {
+ src = target[ name ];
+ copy = options[ name ];
+
+ // Prevent never-ending loop
+ if ( target === copy ) {
+ continue;
+ }
+
+ // Recurse if we're merging object literal values or arrays
+ if ( deep && copy && ( jQuery.isPlainObject(copy) || jQuery.isArray(copy) ) ) {
+ var clone = src && ( jQuery.isPlainObject(src) || jQuery.isArray(src) ) ? src
+ : jQuery.isArray(copy) ? [] : {};
+
+ // Never move original objects, clone them
+ target[ name ] = jQuery.extend( deep, clone, copy );
+
+ // Don't bring in undefined values
+ } else if ( copy !== undefined ) {
+ target[ name ] = copy;
+ }
+ }
+ }
+ }
+
+ // Return the modified object
+ return target;
+};
+
+jQuery.extend({
+ noConflict: function( deep ) {
+ window.$ = _$;
+
+ if ( deep ) {
+ window.jQuery = _jQuery;
+ }
+
+ return jQuery;
+ },
+
+ // Is the DOM ready to be used? Set to true once it occurs.
+ isReady: false,
+
+ // Handle when the DOM is ready
+ ready: function() {
+ // Make sure that the DOM is not already loaded
+ if ( !jQuery.isReady ) {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( !document.body ) {
+ return setTimeout( jQuery.ready, 13 );
+ }
+
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If there are functions bound, to execute
+ if ( readyList ) {
+ // Execute all of them
+ var fn, i = 0;
+ while ( (fn = readyList[ i++ ]) ) {
+ fn.call( document, jQuery );
+ }
+
+ // Reset the list of functions
+ readyList = null;
+ }
+
+ // Trigger any bound ready events
+ if ( jQuery.fn.triggerHandler ) {
+ jQuery( document ).triggerHandler( "ready" );
+ }
+ }
+ },
+
+ bindReady: function() {
+ if ( readyBound ) {
+ return;
+ }
+
+ readyBound = true;
+
+ // Catch cases where $(document).ready() is called after the
+ // browser event has already occurred.
+ if ( document.readyState === "complete" ) {
+ return jQuery.ready();
+ }
+
+ // Mozilla, Opera and webkit nightlies currently support this event
+ if ( document.addEventListener ) {
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+
+ // A fallback to window.onload, that will always work
+ window.addEventListener( "load", jQuery.ready, false );
+
+ // If IE event model is used
+ } else if ( document.attachEvent ) {
+ // ensure firing before onload,
+ // maybe late but safe also for iframes
+ document.attachEvent("onreadystatechange", DOMContentLoaded);
+
+ // A fallback to window.onload, that will always work
+ window.attachEvent( "onload", jQuery.ready );
+
+ // If IE and not a frame
+ // continually check to see if the document is ready
+ var toplevel = false;
+
+ try {
+ toplevel = window.frameElement == null;
+ } catch(e) {}
+
+ if ( document.documentElement.doScroll && toplevel ) {
+ doScrollCheck();
+ }
+ }
+ },
+
+ // See test/unit/core.js for details concerning isFunction.
+ // Since version 1.3, DOM methods and functions like alert
+ // aren't supported. They return false on IE (#2968).
+ isFunction: function( obj ) {
+ return toString.call(obj) === "[object Function]";
+ },
+
+ isArray: function( obj ) {
+ return toString.call(obj) === "[object Array]";
+ },
+
+ isPlainObject: function( obj ) {
+ // Must be an Object.
+ // Because of IE, we also have to check the presence of the constructor property.
+ // Make sure that DOM nodes and window objects don't pass through, as well
+ if ( !obj || toString.call(obj) !== "[object Object]" || obj.nodeType || obj.setInterval ) {
+ return false;
+ }
+
+ // Not own constructor property must be Object
+ if ( obj.constructor
+ && !hasOwnProperty.call(obj, "constructor")
+ && !hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf") ) {
+ return false;
+ }
+
+ // Own properties are enumerated firstly, so to speed up,
+ // if last one is own, then all properties are own.
+
+ var key;
+ for ( key in obj ) {}
+
+ return key === undefined || hasOwnProperty.call( obj, key );
+ },
+
+ isEmptyObject: function( obj ) {
+ for ( var name in obj ) {
+ return false;
+ }
+ return true;
+ },
+
+ noop: function() {},
+
+ // Evalulates a script in a global context
+ globalEval: function( data ) {
+ if ( data && rnotwhite.test(data) ) {
+ // Inspired by code by Andrea Giammarchi
+ // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
+ var head = document.getElementsByTagName("head")[0] || document.documentElement,
+ script = document.createElement("script");
+
+ script.type = "text/javascript";
+
+ if ( jQuery.support.scriptEval ) {
+ script.appendChild( document.createTextNode( data ) );
+ } else {
+ script.text = data;
+ }
+
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709).
+ head.insertBefore( script, head.firstChild );
+ head.removeChild( script );
+ }
+ },
+
+ nodeName: function( elem, name ) {
+ return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
+ },
+
+ // args is for internal usage only
+ each: function( object, callback, args ) {
+ var name, i = 0,
+ length = object.length,
+ isObj = length === undefined || jQuery.isFunction(object);
+
+ if ( args ) {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.apply( object[ name ], args ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( ; i < length; ) {
+ if ( callback.apply( object[ i++ ], args ) === false ) {
+ break;
+ }
+ }
+ }
+
+ // A special, fast, case for the most common use of each
+ } else {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( var value = object[0];
+ i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
+ }
+ }
+
+ return object;
+ },
+
+ trim: function( text ) {
+ return (text || "").replace( rtrim, "" );
+ },
+
+ // results is for internal usage only
+ makeArray: function( array, results ) {
+ var ret = results || [];
+
+ if ( array != null ) {
+ // The window, strings (and functions) also have 'length'
+ // The extra typeof function check is to prevent crashes
+ // in Safari 2 (See: #3039)
+ if ( array.length == null || typeof array === "string" || jQuery.isFunction(array) || (typeof array !== "function" && array.setInterval) ) {
+ push.call( ret, array );
+ } else {
+ jQuery.merge( ret, array );
+ }
+ }
+
+ return ret;
+ },
+
+ inArray: function( elem, array ) {
+ if ( array.indexOf ) {
+ return array.indexOf( elem );
+ }
+
+ for ( var i = 0, length = array.length; i < length; i++ ) {
+ if ( array[ i ] === elem ) {
+ return i;
+ }
+ }
+
+ return -1;
+ },
+
+ merge: function( first, second ) {
+ var i = first.length, j = 0;
+
+ if ( typeof second.length === "number" ) {
+ for ( var l = second.length; j < l; j++ ) {
+ first[ i++ ] = second[ j ];
+ }
+ } else {
+ while ( second[j] !== undefined ) {
+ first[ i++ ] = second[ j++ ];
+ }
+ }
+
+ first.length = i;
+
+ return first;
+ },
+
+ grep: function( elems, callback, inv ) {
+ var ret = [];
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ if ( !inv !== !callback( elems[ i ], i ) ) {
+ ret.push( elems[ i ] );
+ }
+ }
+
+ return ret;
+ },
+
+ // arg is for internal usage only
+ map: function( elems, callback, arg ) {
+ var ret = [], value;
+
+ // Go through the array, translating each of the items to their
+ // new value (or values).
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ value = callback( elems[ i ], i, arg );
+
+ if ( value != null ) {
+ ret[ ret.length ] = value;
+ }
+ }
+
+ return ret.concat.apply( [], ret );
+ },
+
+ // A global GUID counter for objects
+ guid: 1,
+
+ proxy: function( fn, proxy, thisObject ) {
+ if ( arguments.length === 2 ) {
+ if ( typeof proxy === "string" ) {
+ thisObject = fn;
+ fn = thisObject[ proxy ];
+ proxy = undefined;
+
+ } else if ( proxy && !jQuery.isFunction( proxy ) ) {
+ thisObject = proxy;
+ proxy = undefined;
+ }
+ }
+
+ if ( !proxy && fn ) {
+ proxy = function() {
+ return fn.apply( thisObject || this, arguments );
+ };
+ }
+
+ // Set the guid of unique handler to the same of original handler, so it can be removed
+ if ( fn ) {
+ proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
+ }
+
+ // So proxy can be declared as an argument
+ return proxy;
+ },
+
+ // Use of jQuery.browser is frowned upon.
+ // More details: http://docs.jquery.com/Utilities/jQuery.browser
+ uaMatch: function( ua ) {
+ var ret = { browser: "" };
+
+ ua = ua.toLowerCase();
+
+ if ( /webkit/.test( ua ) ) {
+ ret = { browser: "webkit", version: /webkit[\/ ]([\w.]+)/ };
+
+ } else if ( /opera/.test( ua ) ) {
+ ret = { browser: "opera", version: /version/.test( ua ) ? /version[\/ ]([\w.]+)/ : /opera[\/ ]([\w.]+)/ };
+
+ } else if ( /msie/.test( ua ) ) {
+ ret = { browser: "msie", version: /msie ([\w.]+)/ };
+
+ } else if ( /mozilla/.test( ua ) && !/compatible/.test( ua ) ) {
+ ret = { browser: "mozilla", version: /rv:([\w.]+)/ };
+ }
+
+ ret.version = (ret.version && ret.version.exec( ua ) || [0, "0"])[1];
+
+ return ret;
+ },
+
+ browser: {}
+});
+
+browserMatch = jQuery.uaMatch( userAgent );
+if ( browserMatch.browser ) {
+ jQuery.browser[ browserMatch.browser ] = true;
+ jQuery.browser.version = browserMatch.version;
+}
+
+// Deprecated, use jQuery.browser.webkit instead
+if ( jQuery.browser.webkit ) {
+ jQuery.browser.safari = true;
+}
+
+if ( indexOf ) {
+ jQuery.inArray = function( elem, array ) {
+ return indexOf.call( array, elem );
+ };
+}
+
+// All jQuery objects should point back to these
+rootjQuery = jQuery(document);
+
+// Cleanup functions for the document ready method
+if ( document.addEventListener ) {
+ DOMContentLoaded = function() {
+ document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+ jQuery.ready();
+ };
+
+} else if ( document.attachEvent ) {
+ DOMContentLoaded = function() {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( document.readyState === "complete" ) {
+ document.detachEvent( "onreadystatechange", DOMContentLoaded );
+ jQuery.ready();
+ }
+ };
+}
+
+// The DOM ready check for Internet Explorer
+function doScrollCheck() {
+ if ( jQuery.isReady ) {
+ return;
+ }
+
+ try {
+ // If IE is used, use the trick by Diego Perini
+ // http://javascript.nwbox.com/IEContentLoaded/
+ document.documentElement.doScroll("left");
+ } catch( error ) {
+ setTimeout( doScrollCheck, 1 );
+ return;
+ }
+
+ // and execute any waiting functions
+ jQuery.ready();
+}
+
+if ( indexOf ) {
+ jQuery.inArray = function( elem, array ) {
+ return indexOf.call( array, elem );
+ };
+}
+
+function evalScript( i, elem ) {
+ if ( elem.src ) {
+ jQuery.ajax({
+ url: elem.src,
+ async: false,
+ dataType: "script"
+ });
+ } else {
+ jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
+ }
+
+ if ( elem.parentNode ) {
+ elem.parentNode.removeChild( elem );
+ }
+}
+
+// Mutifunctional method to get and set values to a collection
+// The value/s can be optionally by executed if its a function
+function access( elems, key, value, exec, fn, pass ) {
+ var length = elems.length;
+
+ // Setting many attributes
+ if ( typeof key === "object" ) {
+ for ( var k in key ) {
+ access( elems, k, key[k], exec, fn, value );
+ }
+ return elems;
+ }
+
+ // Setting one attribute
+ if ( value !== undefined ) {
+ // Optionally, function values get executed if exec is true
+ exec = !pass && exec && jQuery.isFunction(value);
+
+ for ( var i = 0; i < length; i++ ) {
+ fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
+ }
+
+ return elems;
+ }
+
+ // Getting an attribute
+ return length ? fn( elems[0], key ) : null;
+}
+
+function now() {
+ return (new Date).getTime();
+}
+(function() {
+
+ jQuery.support = {};
+
+ var root = document.documentElement,
+ script = document.createElement("script"),
+ div = document.createElement("div"),
+ id = "script" + now();
+
+ div.style.display = "none";
+ div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
+
+ var all = div.getElementsByTagName("*"),
+ a = div.getElementsByTagName("a")[0];
+
+ // Can't get basic test support
+ if ( !all || !all.length || !a ) {
+ return;
+ }
+
+ jQuery.support = {
+ // IE strips leading whitespace when .innerHTML is used
+ leadingWhitespace: div.firstChild.nodeType === 3,
+
+ // Make sure that tbody elements aren't automatically inserted
+ // IE will insert them into empty tables
+ tbody: !div.getElementsByTagName("tbody").length,
+
+ // Make sure that link elements get serialized correctly by innerHTML
+ // This requires a wrapper element in IE
+ htmlSerialize: !!div.getElementsByTagName("link").length,
+
+ // Get the style information from getAttribute
+ // (IE uses .cssText insted)
+ style: /red/.test( a.getAttribute("style") ),
+
+ // Make sure that URLs aren't manipulated
+ // (IE normalizes it by default)
+ hrefNormalized: a.getAttribute("href") === "/a",
+
+ // Make sure that element opacity exists
+ // (IE uses filter instead)
+ // Use a regex to work around a WebKit issue. See #5145
+ opacity: /^0.55$/.test( a.style.opacity ),
+
+ // Verify style float existence
+ // (IE uses styleFloat instead of cssFloat)
+ cssFloat: !!a.style.cssFloat,
+
+ // Make sure that if no value is specified for a checkbox
+ // that it defaults to "on".
+ // (WebKit defaults to "" instead)
+ checkOn: div.getElementsByTagName("input")[0].value === "on",
+
+ // Make sure that a selected-by-default option has a working selected property.
+ // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
+ optSelected: document.createElement("select").appendChild( document.createElement("option") ).selected,
+
+ // Will be defined later
+ scriptEval: false,
+ noCloneEvent: true,
+ boxModel: null
+ };
+
+ script.type = "text/javascript";
+ try {
+ script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
+ } catch(e) {}
+
+ root.insertBefore( script, root.firstChild );
+
+ // Make sure that the execution of code works by injecting a script
+ // tag with appendChild/createTextNode
+ // (IE doesn't support this, fails, and uses .text instead)
+ if ( window[ id ] ) {
+ jQuery.support.scriptEval = true;
+ delete window[ id ];
+ }
+
+ root.removeChild( script );
+
+ if ( div.attachEvent && div.fireEvent ) {
+ div.attachEvent("onclick", function click() {
+ // Cloning a node shouldn't copy over any
+ // bound event handlers (IE does this)
+ jQuery.support.noCloneEvent = false;
+ div.detachEvent("onclick", click);
+ });
+ div.cloneNode(true).fireEvent("onclick");
+ }
+
+ // Figure out if the W3C box model works as expected
+ // document.body must exist before we can do this
+ // TODO: This timeout is temporary until I move ready into core.js.
+ jQuery(function() {
+ var div = document.createElement("div");
+ div.style.width = div.style.paddingLeft = "1px";
+
+ document.body.appendChild( div );
+ jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
+ document.body.removeChild( div ).style.display = 'none';
+ div = null;
+ });
+
+ // Technique from Juriy Zaytsev
+ // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
+ var eventSupported = function( eventName ) {
+ var el = document.createElement("div");
+ eventName = "on" + eventName;
+
+ var isSupported = (eventName in el);
+ if ( !isSupported ) {
+ el.setAttribute(eventName, "return;");
+ isSupported = typeof el[eventName] === "function";
+ }
+ el = null;
+
+ return isSupported;
+ };
+
+ jQuery.support.submitBubbles = eventSupported("submit");
+ jQuery.support.changeBubbles = eventSupported("change");
+
+ // release memory in IE
+ root = script = div = all = a = null;
+})();
+
+jQuery.props = {
+ "for": "htmlFor",
+ "class": "className",
+ readonly: "readOnly",
+ maxlength: "maxLength",
+ cellspacing: "cellSpacing",
+ rowspan: "rowSpan",
+ colspan: "colSpan",
+ tabindex: "tabIndex",
+ usemap: "useMap",
+ frameborder: "frameBorder"
+};
+var expando = "jQuery" + now(), uuid = 0, windowData = {};
+var emptyObject = {};
+
+jQuery.extend({
+ cache: {},
+
+ expando:expando,
+
+ // The following elements throw uncatchable exceptions if you
+ // attempt to add expando properties to them.
+ noData: {
+ "embed": true,
+ "object": true,
+ "applet": true
+ },
+
+ data: function( elem, name, data ) {
+ if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
+ return;
+ }
+
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var id = elem[ expando ], cache = jQuery.cache, thisCache;
+
+ // Handle the case where there's no name immediately
+ if ( !name && !id ) {
+ return null;
+ }
+
+ // Compute a unique ID for the element
+ if ( !id ) {
+ id = ++uuid;
+ }
+
+ // Avoid generating a new cache unless none exists and we
+ // want to manipulate it.
+ if ( typeof name === "object" ) {
+ elem[ expando ] = id;
+ thisCache = cache[ id ] = jQuery.extend(true, {}, name);
+ } else if ( cache[ id ] ) {
+ thisCache = cache[ id ];
+ } else if ( typeof data === "undefined" ) {
+ thisCache = emptyObject;
+ } else {
+ thisCache = cache[ id ] = {};
+ }
+
+ // Prevent overriding the named cache with undefined values
+ if ( data !== undefined ) {
+ elem[ expando ] = id;
+ thisCache[ name ] = data;
+ }
+
+ return typeof name === "string" ? thisCache[ name ] : thisCache;
+ },
+
+ removeData: function( elem, name ) {
+ if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
+ return;
+ }
+
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ];
+
+ // If we want to remove a specific section of the element's data
+ if ( name ) {
+ if ( thisCache ) {
+ // Remove the section of cache data
+ delete thisCache[ name ];
+
+ // If we've removed all the data, remove the element's cache
+ if ( jQuery.isEmptyObject(thisCache) ) {
+ jQuery.removeData( elem );
+ }
+ }
+
+ // Otherwise, we want to remove all of the element's data
+ } else {
+ // Clean up the element expando
+ try {
+ delete elem[ expando ];
+ } catch( e ) {
+ // IE has trouble directly removing the expando
+ // but it's ok with using removeAttribute
+ if ( elem.removeAttribute ) {
+ elem.removeAttribute( expando );
+ }
+ }
+
+ // Completely remove the data cache
+ delete cache[ id ];
+ }
+ }
+});
+
+jQuery.fn.extend({
+ data: function( key, value ) {
+ if ( typeof key === "undefined" && this.length ) {
+ return jQuery.data( this[0] );
+
+ } else if ( typeof key === "object" ) {
+ return this.each(function() {
+ jQuery.data( this, key );
+ });
+ }
+
+ var parts = key.split(".");
+ parts[1] = parts[1] ? "." + parts[1] : "";
+
+ if ( value === undefined ) {
+ var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
+
+ if ( data === undefined && this.length ) {
+ data = jQuery.data( this[0], key );
+ }
+ return data === undefined && parts[1] ?
+ this.data( parts[0] ) :
+ data;
+ } else {
+ return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function() {
+ jQuery.data( this, key, value );
+ });
+ }
+ },
+
+ removeData: function( key ) {
+ return this.each(function() {
+ jQuery.removeData( this, key );
+ });
+ }
+});
+jQuery.extend({
+ queue: function( elem, type, data ) {
+ if ( !elem ) {
+ return;
+ }
+
+ type = (type || "fx") + "queue";
+ var q = jQuery.data( elem, type );
+
+ // Speed up dequeue by getting out quickly if this is just a lookup
+ if ( !data ) {
+ return q || [];
+ }
+
+ if ( !q || jQuery.isArray(data) ) {
+ q = jQuery.data( elem, type, jQuery.makeArray(data) );
+
+ } else {
+ q.push( data );
+ }
+
+ return q;
+ },
+
+ dequeue: function( elem, type ) {
+ type = type || "fx";
+
+ var queue = jQuery.queue( elem, type ), fn = queue.shift();
+
+ // If the fx queue is dequeued, always remove the progress sentinel
+ if ( fn === "inprogress" ) {
+ fn = queue.shift();
+ }
+
+ if ( fn ) {
+ // Add a progress sentinel to prevent the fx queue from being
+ // automatically dequeued
+ if ( type === "fx" ) {
+ queue.unshift("inprogress");
+ }
+
+ fn.call(elem, function() {
+ jQuery.dequeue(elem, type);
+ });
+ }
+ }
+});
+
+jQuery.fn.extend({
+ queue: function( type, data ) {
+ if ( typeof type !== "string" ) {
+ data = type;
+ type = "fx";
+ }
+
+ if ( data === undefined ) {
+ return jQuery.queue( this[0], type );
+ }
+ return this.each(function( i, elem ) {
+ var queue = jQuery.queue( this, type, data );
+
+ if ( type === "fx" && queue[0] !== "inprogress" ) {
+ jQuery.dequeue( this, type );
+ }
+ });
+ },
+ dequeue: function( type ) {
+ return this.each(function() {
+ jQuery.dequeue( this, type );
+ });
+ },
+
+ // Based off of the plugin by Clint Helfers, with permission.
+ // http://blindsignals.com/index.php/2009/07/jquery-delay/
+ delay: function( time, type ) {
+ time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
+ type = type || "fx";
+
+ return this.queue( type, function() {
+ var elem = this;
+ setTimeout(function() {
+ jQuery.dequeue( elem, type );
+ }, time );
+ });
+ },
+
+ clearQueue: function( type ) {
+ return this.queue( type || "fx", [] );
+ }
+});
+var rclass = /[\n\t]/g,
+ rspace = /\s+/,
+ rreturn = /\r/g,
+ rspecialurl = /href|src|style/,
+ rtype = /(button|input)/i,
+ rfocusable = /(button|input|object|select|textarea)/i,
+ rclickable = /^(a|area)$/i,
+ rradiocheck = /radio|checkbox/;
+
+jQuery.fn.extend({
+ attr: function( name, value ) {
+ return access( this, name, value, true, jQuery.attr );
+ },
+
+ removeAttr: function( name, fn ) {
+ return this.each(function(){
+ jQuery.attr( this, name, "" );
+ if ( this.nodeType === 1 ) {
+ this.removeAttribute( name );
+ }
+ });
+ },
+
+ addClass: function( value ) {
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.addClass( value.call(this, i, self.attr("class")) );
+ });
+ }
+
+ if ( value && typeof value === "string" ) {
+ var classNames = (value || "").split( rspace );
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var elem = this[i];
+
+ if ( elem.nodeType === 1 ) {
+ if ( !elem.className ) {
+ elem.className = value;
+
+ } else {
+ var className = " " + elem.className + " ";
+ for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
+ if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
+ elem.className += " " + classNames[c];
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ removeClass: function( value ) {
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.removeClass( value.call(this, i, self.attr("class")) );
+ });
+ }
+
+ if ( (value && typeof value === "string") || value === undefined ) {
+ var classNames = (value || "").split(rspace);
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var elem = this[i];
+
+ if ( elem.nodeType === 1 && elem.className ) {
+ if ( value ) {
+ var className = (" " + elem.className + " ").replace(rclass, " ");
+ for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
+ className = className.replace(" " + classNames[c] + " ", " ");
+ }
+ elem.className = className.substring(1, className.length - 1);
+
+ } else {
+ elem.className = "";
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ toggleClass: function( value, stateVal ) {
+ var type = typeof value, isBool = typeof stateVal === "boolean";
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
+ });
+ }
+
+ return this.each(function() {
+ if ( type === "string" ) {
+ // toggle individual class names
+ var className, i = 0, self = jQuery(this),
+ state = stateVal,
+ classNames = value.split( rspace );
+
+ while ( (className = classNames[ i++ ]) ) {
+ // check each className given, space seperated list
+ state = isBool ? state : !self.hasClass( className );
+ self[ state ? "addClass" : "removeClass" ]( className );
+ }
+
+ } else if ( type === "undefined" || type === "boolean" ) {
+ if ( this.className ) {
+ // store className if set
+ jQuery.data( this, "__className__", this.className );
+ }
+
+ // toggle whole className
+ this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || "";
+ }
+ });
+ },
+
+ hasClass: function( selector ) {
+ var className = " " + selector + " ";
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ val: function( value ) {
+ if ( value === undefined ) {
+ var elem = this[0];
+
+ if ( elem ) {
+ if ( jQuery.nodeName( elem, "option" ) ) {
+ return (elem.attributes.value || {}).specified ? elem.value : elem.text;
+ }
+
+ // We need to handle select boxes special
+ if ( jQuery.nodeName( elem, "select" ) ) {
+ var index = elem.selectedIndex,
+ values = [],
+ options = elem.options,
+ one = elem.type === "select-one";
+
+ // Nothing was selected
+ if ( index < 0 ) {
+ return null;
+ }
+
+ // Loop through all the selected options
+ for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
+ var option = options[ i ];
+
+ if ( option.selected ) {
+ // Get the specifc value for the option
+ value = jQuery(option).val();
+
+ // We don't need an array for one selects
+ if ( one ) {
+ return value;
+ }
+
+ // Multi-Selects return an array
+ values.push( value );
+ }
+ }
+
+ return values;
+ }
+
+ // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
+ if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
+ return elem.getAttribute("value") === null ? "on" : elem.value;
+ }
+
+
+ // Everything else, we just grab the value
+ return (elem.value || "").replace(rreturn, "");
+
+ }
+
+ return undefined;
+ }
+
+ var isFunction = jQuery.isFunction(value);
+
+ return this.each(function(i) {
+ var self = jQuery(this), val = value;
+
+ if ( this.nodeType !== 1 ) {
+ return;
+ }
+
+ if ( isFunction ) {
+ val = value.call(this, i, self.val());
+ }
+
+ // Typecast each time if the value is a Function and the appended
+ // value is therefore different each time.
+ if ( typeof val === "number" ) {
+ val += "";
+ }
+
+ if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
+ this.checked = jQuery.inArray( self.val(), val ) >= 0;
+
+ } else if ( jQuery.nodeName( this, "select" ) ) {
+ var values = jQuery.makeArray(val);
+
+ jQuery( "option", this ).each(function() {
+ this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
+ });
+
+ if ( !values.length ) {
+ this.selectedIndex = -1;
+ }
+
+ } else {
+ this.value = val;
+ }
+ });
+ }
+});
+
+jQuery.extend({
+ attrFn: {
+ val: true,
+ css: true,
+ html: true,
+ text: true,
+ data: true,
+ width: true,
+ height: true,
+ offset: true
+ },
+
+ attr: function( elem, name, value, pass ) {
+ // don't set attributes on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ if ( pass && name in jQuery.attrFn ) {
+ return jQuery(elem)[name](value);
+ }
+
+ var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
+ // Whether we are setting (or getting)
+ set = value !== undefined;
+
+ // Try to normalize/fix the name
+ name = notxml && jQuery.props[ name ] || name;
+
+ // Only do all the following if this is a node (faster for style)
+ if ( elem.nodeType === 1 ) {
+ // These attributes require special treatment
+ var special = rspecialurl.test( name );
+
+ // Safari mis-reports the default selected property of an option
+ // Accessing the parent's selectedIndex property fixes it
+ if ( name === "selected" && !jQuery.support.optSelected ) {
+ var parent = elem.parentNode;
+ if ( parent ) {
+ parent.selectedIndex;
+
+ // Make sure that it also works with optgroups, see #5701
+ if ( parent.parentNode ) {
+ parent.parentNode.selectedIndex;
+ }
+ }
+ }
+
+ // If applicable, access the attribute via the DOM 0 way
+ if ( name in elem && notxml && !special ) {
+ if ( set ) {
+ // We can't allow the type property to be changed (since it causes problems in IE)
+ if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
+ throw "type property can't be changed";
+ }
+
+ elem[ name ] = value;
+ }
+
+ // browsers index elements by id/name on forms, give priority to attributes.
+ if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
+ return elem.getAttributeNode( name ).nodeValue;
+ }
+
+ // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
+ // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
+ if ( name === "tabIndex" ) {
+ var attributeNode = elem.getAttributeNode( "tabIndex" );
+
+ return attributeNode && attributeNode.specified ?
+ attributeNode.value :
+ rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
+ 0 :
+ undefined;
+ }
+
+ return elem[ name ];
+ }
+
+ if ( !jQuery.support.style && notxml && name === "style" ) {
+ if ( set ) {
+ elem.style.cssText = "" + value;
+ }
+
+ return elem.style.cssText;
+ }
+
+ if ( set ) {
+ // convert the value to a string (all browsers do this but IE) see #1070
+ elem.setAttribute( name, "" + value );
+ }
+
+ var attr = !jQuery.support.hrefNormalized && notxml && special ?
+ // Some attributes require a special call on IE
+ elem.getAttribute( name, 2 ) :
+ elem.getAttribute( name );
+
+ // Non-existent attributes return null, we normalize to undefined
+ return attr === null ? undefined : attr;
+ }
+
+ // elem is actually elem.style ... set the style
+ // Using attr for specific style information is now deprecated. Use style insead.
+ return jQuery.style( elem, name, value );
+ }
+});
+var fcleanup = function( nm ) {
+ return nm.replace(/[^\w\s\.\|`]/g, function( ch ) {
+ return "\\" + ch;
+ });
+};
+
+/*
+ * A number of helper functions used for managing events.
+ * Many of the ideas behind this code originated from
+ * Dean Edwards' addEvent library.
+ */
+jQuery.event = {
+
+ // Bind an event to an element
+ // Original by Dean Edwards
+ add: function( elem, types, handler, data ) {
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ // For whatever reason, IE has trouble passing the window object
+ // around, causing it to be cloned in the process
+ if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) {
+ elem = window;
+ }
+
+ // Make sure that the function being executed has a unique ID
+ if ( !handler.guid ) {
+ handler.guid = jQuery.guid++;
+ }
+
+ // if data is passed, bind to handler
+ if ( data !== undefined ) {
+ // Create temporary function pointer to original handler
+ var fn = handler;
+
+ // Create unique handler function, wrapped around original handler
+ handler = jQuery.proxy( fn );
+
+ // Store data in unique handler
+ handler.data = data;
+ }
+
+ // Init the element's event structure
+ var events = jQuery.data( elem, "events" ) || jQuery.data( elem, "events", {} ),
+ handle = jQuery.data( elem, "handle" ), eventHandle;
+
+ if ( !handle ) {
+ eventHandle = function() {
+ // Handle the second event of a trigger and when
+ // an event is called after a page has unloaded
+ return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
+ jQuery.event.handle.apply( eventHandle.elem, arguments ) :
+ undefined;
+ };
+
+ handle = jQuery.data( elem, "handle", eventHandle );
+ }
+
+ // If no handle is found then we must be trying to bind to one of the
+ // banned noData elements
+ if ( !handle ) {
+ return;
+ }
+
+ // Add elem as a property of the handle function
+ // This is to prevent a memory leak with non-native
+ // event in IE.
+ handle.elem = elem;
+
+ // Handle multiple events separated by a space
+ // jQuery(...).bind("mouseover mouseout", fn);
+ types = types.split( /\s+/ );
+ var type, i=0;
+ while ( (type = types[ i++ ]) ) {
+ // Namespaced event handlers
+ var namespaces = type.split(".");
+ type = namespaces.shift();
+ handler.type = namespaces.slice(0).sort().join(".");
+
+ // Get the current list of functions bound to this event
+ var handlers = events[ type ],
+ special = this.special[ type ] || {};
+
+
+
+ // Init the event handler queue
+ if ( !handlers ) {
+ handlers = events[ type ] = {};
+
+ // Check for a special event handler
+ // Only use addEventListener/attachEvent if the special
+ // events handler returns false
+ if ( !special.setup || special.setup.call( elem, data, namespaces, handler) === false ) {
+ // Bind the global event handler to the element
+ if ( elem.addEventListener ) {
+ elem.addEventListener( type, handle, false );
+ } else if ( elem.attachEvent ) {
+ elem.attachEvent( "on" + type, handle );
+ }
+ }
+ }
+
+ if ( special.add ) {
+ var modifiedHandler = special.add.call( elem, handler, data, namespaces, handlers );
+ if ( modifiedHandler && jQuery.isFunction( modifiedHandler ) ) {
+ modifiedHandler.guid = modifiedHandler.guid || handler.guid;
+ handler = modifiedHandler;
+ }
+ }
+
+ // Add the function to the element's handler list
+ handlers[ handler.guid ] = handler;
+
+ // Keep track of which events have been used, for global triggering
+ this.global[ type ] = true;
+ }
+
+ // Nullify elem to prevent memory leaks in IE
+ elem = null;
+ },
+
+ global: {},
+
+ // Detach an event or set of events from an element
+ remove: function( elem, types, handler ) {
+ // don't do events on text and comment nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ var events = jQuery.data( elem, "events" ), ret, type, fn;
+
+ if ( events ) {
+ // Unbind all events for the element
+ if ( types === undefined || (typeof types === "string" && types.charAt(0) === ".") ) {
+ for ( type in events ) {
+ this.remove( elem, type + (types || "") );
+ }
+ } else {
+ // types is actually an event object here
+ if ( types.type ) {
+ handler = types.handler;
+ types = types.type;
+ }
+
+ // Handle multiple events separated by a space
+ // jQuery(...).unbind("mouseover mouseout", fn);
+ types = types.split(/\s+/);
+ var i = 0;
+ while ( (type = types[ i++ ]) ) {
+ // Namespaced event handlers
+ var namespaces = type.split(".");
+ type = namespaces.shift();
+ var all = !namespaces.length,
+ cleaned = jQuery.map( namespaces.slice(0).sort(), fcleanup ),
+ namespace = new RegExp("(^|\\.)" + cleaned.join("\\.(?:.*\\.)?") + "(\\.|$)"),
+ special = this.special[ type ] || {};
+
+ if ( events[ type ] ) {
+ // remove the given handler for the given type
+ if ( handler ) {
+ fn = events[ type ][ handler.guid ];
+ delete events[ type ][ handler.guid ];
+
+ // remove all handlers for the given type
+ } else {
+ for ( var handle in events[ type ] ) {
+ // Handle the removal of namespaced events
+ if ( all || namespace.test( events[ type ][ handle ].type ) ) {
+ delete events[ type ][ handle ];
+ }
+ }
+ }
+
+ if ( special.remove ) {
+ special.remove.call( elem, namespaces, fn);
+ }
+
+ // remove generic event handler if no more handlers exist
+ for ( ret in events[ type ] ) {
+ break;
+ }
+ if ( !ret ) {
+ if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
+ if ( elem.removeEventListener ) {
+ elem.removeEventListener( type, jQuery.data( elem, "handle" ), false );
+ } else if ( elem.detachEvent ) {
+ elem.detachEvent( "on" + type, jQuery.data( elem, "handle" ) );
+ }
+ }
+ ret = null;
+ delete events[ type ];
+ }
+ }
+ }
+ }
+
+ // Remove the expando if it's no longer used
+ for ( ret in events ) {
+ break;
+ }
+ if ( !ret ) {
+ var handle = jQuery.data( elem, "handle" );
+ if ( handle ) {
+ handle.elem = null;
+ }
+ jQuery.removeData( elem, "events" );
+ jQuery.removeData( elem, "handle" );
+ }
+ }
+ },
+
+ // bubbling is internal
+ trigger: function( event, data, elem /*, bubbling */ ) {
+ // Event object or event type
+ var type = event.type || event,
+ bubbling = arguments[3];
+
+ if ( !bubbling ) {
+ event = typeof event === "object" ?
+ // jQuery.Event object
+ event[expando] ? event :
+ // Object literal
+ jQuery.extend( jQuery.Event(type), event ) :
+ // Just the event type (string)
+ jQuery.Event(type);
+
+ if ( type.indexOf("!") >= 0 ) {
+ event.type = type = type.slice(0, -1);
+ event.exclusive = true;
+ }
+
+ // Handle a global trigger
+ if ( !elem ) {
+ // Don't bubble custom events when global (to avoid too much overhead)
+ event.stopPropagation();
+
+ // Only trigger if we've ever bound an event for it
+ if ( this.global[ type ] ) {
+ jQuery.each( jQuery.cache, function() {
+ if ( this.events && this.events[type] ) {
+ jQuery.event.trigger( event, data, this.handle.elem );
+ }
+ });
+ }
+ }
+
+ // Handle triggering a single element
+
+ // don't do events on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ // Clean up in case it is reused
+ event.result = undefined;
+ event.target = elem;
+
+ // Clone the incoming data, if any
+ data = jQuery.makeArray( data );
+ data.unshift( event );
+ }
+
+ event.currentTarget = elem;
+
+ // Trigger the event, it is assumed that "handle" is a function
+ var handle = jQuery.data( elem, "handle" );
+ if ( handle ) {
+ handle.apply( elem, data );
+ }
+
+ var nativeFn, nativeHandler;
+ try {
+ if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
+ nativeFn = elem[ type ];
+ nativeHandler = elem[ "on" + type ];
+ }
+ // prevent IE from throwing an error for some elements with some event types, see #3533
+ } catch (e) {}
+
+ var isClick = jQuery.nodeName(elem, "a") && type === "click";
+
+ // Trigger the native events (except for clicks on links)
+ if ( !bubbling && nativeFn && !event.isDefaultPrevented() && !isClick ) {
+ this.triggered = true;
+ try {
+ elem[ type ]();
+ // prevent IE from throwing an error for some hidden elements
+ } catch (e) {}
+
+ // Handle triggering native .onfoo handlers
+ } else if ( nativeHandler && elem[ "on" + type ].apply( elem, data ) === false ) {
+ event.result = false;
+ }
+
+ this.triggered = false;
+
+ if ( !event.isPropagationStopped() ) {
+ var parent = elem.parentNode || elem.ownerDocument;
+ if ( parent ) {
+ jQuery.event.trigger( event, data, parent, true );
+ }
+ }
+ },
+
+ handle: function( event ) {
+ // returned undefined or false
+ var all, handlers;
+
+ event = arguments[0] = jQuery.event.fix( event || window.event );
+ event.currentTarget = this;
+
+ // Namespaced event handlers
+ var namespaces = event.type.split(".");
+ event.type = namespaces.shift();
+
+ // Cache this now, all = true means, any handler
+ all = !namespaces.length && !event.exclusive;
+
+ var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)");
+
+ handlers = ( jQuery.data(this, "events") || {} )[ event.type ];
+
+ for ( var j in handlers ) {
+ var handler = handlers[ j ];
+
+ // Filter the functions by class
+ if ( all || namespace.test(handler.type) ) {
+ // Pass in a reference to the handler function itself
+ // So that we can later remove it
+ event.handler = handler;
+ event.data = handler.data;
+
+ var ret = handler.apply( this, arguments );
+
+ if ( ret !== undefined ) {
+ event.result = ret;
+ if ( ret === false ) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }
+
+ if ( event.isImmediatePropagationStopped() ) {
+ break;
+ }
+
+ }
+ }
+
+ return event.result;
+ },
+
+ props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
+
+ fix: function( event ) {
+ if ( event[ expando ] ) {
+ return event;
+ }
+
+ // store a copy of the original event object
+ // and "clone" to set read-only properties
+ var originalEvent = event;
+ event = jQuery.Event( originalEvent );
+
+ for ( var i = this.props.length, prop; i; ) {
+ prop = this.props[ --i ];
+ event[ prop ] = originalEvent[ prop ];
+ }
+
+ // Fix target property, if necessary
+ if ( !event.target ) {
+ event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
+ }
+
+ // check if target is a textnode (safari)
+ if ( event.target.nodeType === 3 ) {
+ event.target = event.target.parentNode;
+ }
+
+ // Add relatedTarget, if necessary
+ if ( !event.relatedTarget && event.fromElement ) {
+ event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
+ }
+
+ // Calculate pageX/Y if missing and clientX/Y available
+ if ( event.pageX == null && event.clientX != null ) {
+ var doc = document.documentElement, body = document.body;
+ event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
+ event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
+ }
+
+ // Add which for key events
+ if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) {
+ event.which = event.charCode || event.keyCode;
+ }
+
+ // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
+ if ( !event.metaKey && event.ctrlKey ) {
+ event.metaKey = event.ctrlKey;
+ }
+
+ // Add which for click: 1 === left; 2 === middle; 3 === right
+ // Note: button is not normalized, so don't use it
+ if ( !event.which && event.button !== undefined ) {
+ event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
+ }
+
+ return event;
+ },
+
+ // Deprecated, use jQuery.guid instead
+ guid: 1E8,
+
+ // Deprecated, use jQuery.proxy instead
+ proxy: jQuery.proxy,
+
+ special: {
+ ready: {
+ // Make sure the ready event is setup
+ setup: jQuery.bindReady,
+ teardown: jQuery.noop
+ },
+
+ live: {
+ add: function( proxy, data, namespaces, live ) {
+ jQuery.extend( proxy, data || {} );
+
+ proxy.guid += data.selector + data.live;
+ jQuery.event.add( this, data.live, liveHandler, data );
+
+ },
+
+ remove: function( namespaces ) {
+ if ( namespaces.length ) {
+ var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)");
+
+ jQuery.each( (jQuery.data(this, "events").live || {}), function() {
+ if ( name.test(this.type) ) {
+ remove++;
+ }
+ });
+
+ if ( remove < 1 ) {
+ jQuery.event.remove( this, namespaces[0], liveHandler );
+ }
+ }
+ },
+ special: {}
+ },
+ beforeunload: {
+ setup: function( data, namespaces, fn ) {
+ // We only want to do this special case on windows
+ if ( this.setInterval ) {
+ this.onbeforeunload = fn;
+ }
+
+ return false;
+ },
+ teardown: function( namespaces, fn ) {
+ if ( this.onbeforeunload === fn ) {
+ this.onbeforeunload = null;
+ }
+ }
+ }
+ }
+};
+
+jQuery.Event = function( src ) {
+ // Allow instantiation without the 'new' keyword
+ if ( !this.preventDefault ) {
+ return new jQuery.Event( src );
+ }
+
+ // Event object
+ if ( src && src.type ) {
+ this.originalEvent = src;
+ this.type = src.type;
+ // Event type
+ } else {
+ this.type = src;
+ }
+
+ // timeStamp is buggy for some events on Firefox(#3843)
+ // So we won't rely on the native value
+ this.timeStamp = now();
+
+ // Mark it as fixed
+ this[ expando ] = true;
+};
+
+function returnFalse() {
+ return false;
+}
+function returnTrue() {
+ return true;
+}
+
+// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
+// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
+jQuery.Event.prototype = {
+ preventDefault: function() {
+ this.isDefaultPrevented = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+
+ // if preventDefault exists run it on the original event
+ if ( e.preventDefault ) {
+ e.preventDefault();
+ }
+ // otherwise set the returnValue property of the original event to false (IE)
+ e.returnValue = false;
+ },
+ stopPropagation: function() {
+ this.isPropagationStopped = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+ // if stopPropagation exists run it on the original event
+ if ( e.stopPropagation ) {
+ e.stopPropagation();
+ }
+ // otherwise set the cancelBubble property of the original event to true (IE)
+ e.cancelBubble = true;
+ },
+ stopImmediatePropagation: function() {
+ this.isImmediatePropagationStopped = returnTrue;
+ this.stopPropagation();
+ },
+ isDefaultPrevented: returnFalse,
+ isPropagationStopped: returnFalse,
+ isImmediatePropagationStopped: returnFalse
+};
+
+// Checks if an event happened on an element within another element
+// Used in jQuery.event.special.mouseenter and mouseleave handlers
+var withinElement = function( event ) {
+ // Check if mouse(over|out) are still within the same parent element
+ var parent = event.relatedTarget;
+
+ // Traverse up the tree
+ while ( parent && parent !== this ) {
+ // Firefox sometimes assigns relatedTarget a XUL element
+ // which we cannot access the parentNode property of
+ try {
+ parent = parent.parentNode;
+
+ // assuming we've left the element since we most likely mousedover a xul element
+ } catch(e) {
+ break;
+ }
+ }
+
+ if ( parent !== this ) {
+ // set the correct event type
+ event.type = event.data;
+
+ // handle event if we actually just moused on to a non sub-element
+ jQuery.event.handle.apply( this, arguments );
+ }
+
+},
+
+// In case of event delegation, we only need to rename the event.type,
+// liveHandler will take care of the rest.
+delegate = function( event ) {
+ event.type = event.data;
+ jQuery.event.handle.apply( this, arguments );
+};
+
+// Create mouseenter and mouseleave events
+jQuery.each({
+ mouseenter: "mouseover",
+ mouseleave: "mouseout"
+}, function( orig, fix ) {
+ jQuery.event.special[ orig ] = {
+ setup: function( data ) {
+ jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
+ },
+ teardown: function( data ) {
+ jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
+ }
+ };
+});
+
+// submit delegation
+if ( !jQuery.support.submitBubbles ) {
+
+jQuery.event.special.submit = {
+ setup: function( data, namespaces, fn ) {
+ if ( this.nodeName.toLowerCase() !== "form" ) {
+ jQuery.event.add(this, "click.specialSubmit." + fn.guid, function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
+ return trigger( "submit", this, arguments );
+ }
+ });
+
+ jQuery.event.add(this, "keypress.specialSubmit." + fn.guid, function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
+ return trigger( "submit", this, arguments );
+ }
+ });
+
+ } else {
+ return false;
+ }
+ },
+
+ remove: function( namespaces, fn ) {
+ jQuery.event.remove( this, "click.specialSubmit" + (fn ? "."+fn.guid : "") );
+ jQuery.event.remove( this, "keypress.specialSubmit" + (fn ? "."+fn.guid : "") );
+ }
+};
+
+}
+
+// change delegation, happens here so we have bind.
+if ( !jQuery.support.changeBubbles ) {
+
+var formElems = /textarea|input|select/i;
+
+function getVal( elem ) {
+ var type = elem.type, val = elem.value;
+
+ if ( type === "radio" || type === "checkbox" ) {
+ val = elem.checked;
+
+ } else if ( type === "select-multiple" ) {
+ val = elem.selectedIndex > -1 ?
+ jQuery.map( elem.options, function( elem ) {
+ return elem.selected;
+ }).join("-") :
+ "";
+
+ } else if ( elem.nodeName.toLowerCase() === "select" ) {
+ val = elem.selectedIndex;
+ }
+
+ return val;
+}
+
+function testChange( e ) {
+ var elem = e.target, data, val;
+
+ if ( !formElems.test( elem.nodeName ) || elem.readOnly ) {
+ return;
+ }
+
+ data = jQuery.data( elem, "_change_data" );
+ val = getVal(elem);
+
+ if ( val === data ) {
+ return;
+ }
+
+ // the current data will be also retrieved by beforeactivate
+ if ( e.type !== "focusout" || elem.type !== "radio" ) {
+ jQuery.data( elem, "_change_data", val );
+ }
+
+ if ( elem.type !== "select" && (data != null || val) ) {
+ e.type = "change";
+ return jQuery.event.trigger( e, arguments[1], this );
+ }
+}
+
+jQuery.event.special.change = {
+ filters: {
+ focusout: testChange,
+
+ click: function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
+ return testChange.call( this, e );
+ }
+ },
+
+ // Change has to be called before submit
+ // Keydown will be called before keypress, which is used in submit-event delegation
+ keydown: function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
+ (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
+ type === "select-multiple" ) {
+ return testChange.call( this, e );
+ }
+ },
+
+ // Beforeactivate happens also before the previous element is blurred
+ // with this event you can't trigger a change event, but you can store
+ // information/focus[in] is not needed anymore
+ beforeactivate: function( e ) {
+ var elem = e.target;
+
+ if ( elem.nodeName.toLowerCase() === "input" && elem.type === "radio" ) {
+ jQuery.data( elem, "_change_data", getVal(elem) );
+ }
+ }
+ },
+ setup: function( data, namespaces, fn ) {
+ for ( var type in changeFilters ) {
+ jQuery.event.add( this, type + ".specialChange." + fn.guid, changeFilters[type] );
+ }
+
+ return formElems.test( this.nodeName );
+ },
+ remove: function( namespaces, fn ) {
+ for ( var type in changeFilters ) {
+ jQuery.event.remove( this, type + ".specialChange" + (fn ? "."+fn.guid : ""), changeFilters[type] );
+ }
+
+ return formElems.test( this.nodeName );
+ }
+};
+
+var changeFilters = jQuery.event.special.change.filters;
+
+}
+
+function trigger( type, elem, args ) {
+ args[0].type = type;
+ return jQuery.event.handle.apply( elem, args );
+}
+
+// Create "bubbling" focus and blur events
+if ( document.addEventListener ) {
+ jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
+ jQuery.event.special[ fix ] = {
+ setup: function() {
+ this.addEventListener( orig, handler, true );
+ },
+ teardown: function() {
+ this.removeEventListener( orig, handler, true );
+ }
+ };
+
+ function handler( e ) {
+ e = jQuery.event.fix( e );
+ e.type = fix;
+ return jQuery.event.handle.call( this, e );
+ }
+ });
+}
+
+jQuery.each(["bind", "one"], function( i, name ) {
+ jQuery.fn[ name ] = function( type, data, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" ) {
+ for ( var key in type ) {
+ this[ name ](key, data, type[key], fn);
+ }
+ return this;
+ }
+
+ if ( jQuery.isFunction( data ) ) {
+ thisObject = fn;
+ fn = data;
+ data = undefined;
+ }
+
+ var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
+ jQuery( this ).unbind( event, handler );
+ return fn.apply( this, arguments );
+ }) : fn;
+
+ return type === "unload" && name !== "one" ?
+ this.one( type, data, fn, thisObject ) :
+ this.each(function() {
+ jQuery.event.add( this, type, handler, data );
+ });
+ };
+});
+
+jQuery.fn.extend({
+ unbind: function( type, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" && !type.preventDefault ) {
+ for ( var key in type ) {
+ this.unbind(key, type[key]);
+ }
+ return this;
+ }
+
+ return this.each(function() {
+ jQuery.event.remove( this, type, fn );
+ });
+ },
+ trigger: function( type, data ) {
+ return this.each(function() {
+ jQuery.event.trigger( type, data, this );
+ });
+ },
+
+ triggerHandler: function( type, data ) {
+ if ( this[0] ) {
+ var event = jQuery.Event( type );
+ event.preventDefault();
+ event.stopPropagation();
+ jQuery.event.trigger( event, data, this[0] );
+ return event.result;
+ }
+ },
+
+ toggle: function( fn ) {
+ // Save reference to arguments for access in closure
+ var args = arguments, i = 1;
+
+ // link all the functions, so any of them can unbind this click handler
+ while ( i < args.length ) {
+ jQuery.proxy( fn, args[ i++ ] );
+ }
+
+ return this.click( jQuery.proxy( fn, function( event ) {
+ // Figure out which function to execute
+ var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
+ jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
+
+ // Make sure that clicks stop
+ event.preventDefault();
+
+ // and execute the function
+ return args[ lastToggle ].apply( this, arguments ) || false;
+ }));
+ },
+
+ hover: function( fnOver, fnOut ) {
+ return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
+ },
+
+ live: function( type, data, fn ) {
+ if ( jQuery.isFunction( data ) ) {
+ fn = data;
+ data = undefined;
+ }
+
+ jQuery( this.context ).bind( liveConvert( type, this.selector ), {
+ data: data, selector: this.selector, live: type
+ }, fn );
+
+ return this;
+ },
+
+ die: function( type, fn ) {
+ jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null );
+ return this;
+ }
+});
+
+function liveHandler( event ) {
+ var stop = true, elems = [], selectors = [], args = arguments,
+ related, match, fn, elem, j, i, data,
+ live = jQuery.extend({}, jQuery.data( this, "events" ).live);
+
+ for ( j in live ) {
+ fn = live[j];
+ if ( fn.live === event.type ||
+ fn.altLive && jQuery.inArray(event.type, fn.altLive) > -1 ) {
+
+ data = fn.data;
+ if ( !(data.beforeFilter && data.beforeFilter[event.type] &&
+ !data.beforeFilter[event.type](event)) ) {
+ selectors.push( fn.selector );
+ }
+ } else {
+ delete live[j];
+ }
+ }
+
+ match = jQuery( event.target ).closest( selectors, event.currentTarget );
+
+ for ( i = 0, l = match.length; i < l; i++ ) {
+ for ( j in live ) {
+ fn = live[j];
+ elem = match[i].elem;
+ related = null;
+
+ if ( match[i].selector === fn.selector ) {
+ // Those two events require additional checking
+ if ( fn.live === "mouseenter" || fn.live === "mouseleave" ) {
+ related = jQuery( event.relatedTarget ).closest( fn.selector )[0];
+ }
+
+ if ( !related || related !== elem ) {
+ elems.push({ elem: elem, fn: fn });
+ }
+ }
+ }
+ }
+
+ for ( i = 0, l = elems.length; i < l; i++ ) {
+ match = elems[i];
+ event.currentTarget = match.elem;
+ event.data = match.fn.data;
+ if ( match.fn.apply( match.elem, args ) === false ) {
+ stop = false;
+ break;
+ }
+ }
+
+ return stop;
+}
+
+function liveConvert( type, selector ) {
+ return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "&")].join(".");
+}
+
+jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
+ "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
+ "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
+
+ // Handle event binding
+ jQuery.fn[ name ] = function( fn ) {
+ return fn ? this.bind( name, fn ) : this.trigger( name );
+ };
+
+ if ( jQuery.attrFn ) {
+ jQuery.attrFn[ name ] = true;
+ }
+});
+
+// Prevent memory leaks in IE
+// Window isn't included so as not to unbind existing unload events
+// More info:
+// - http://isaacschlueter.com/2006/10/msie-memory-leaks/
+if ( window.attachEvent && !window.addEventListener ) {
+ window.attachEvent("onunload", function() {
+ for ( var id in jQuery.cache ) {
+ if ( jQuery.cache[ id ].handle ) {
+ // Try/Catch is to handle iframes being unloaded, see #4280
+ try {
+ jQuery.event.remove( jQuery.cache[ id ].handle.elem );
+ } catch(e) {}
+ }
+ }
+ });
+}
+/*!
+ * Sizzle CSS Selector Engine - v1.0
+ * Copyright 2009, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ * More information: http://sizzlejs.com/
+ */
+(function(){
+
+var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
+ done = 0,
+ toString = Object.prototype.toString,
+ hasDuplicate = false,
+ baseHasDuplicate = true;
+
+// Here we check if the JavaScript engine is using some sort of
+// optimization where it does not always call our comparision
+// function. If that is the case, discard the hasDuplicate value.
+// Thus far that includes Google Chrome.
+[0, 0].sort(function(){
+ baseHasDuplicate = false;
+ return 0;
+});
+
+var Sizzle = function(selector, context, results, seed) {
+ results = results || [];
+ var origContext = context = context || document;
+
+ if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
+ return [];
+ }
+
+ if ( !selector || typeof selector !== "string" ) {
+ return results;
+ }
+
+ var parts = [], m, set, checkSet, extra, prune = true, contextXML = isXML(context),
+ soFar = selector;
+
+ // Reset the position of the chunker regexp (start from head)
+ while ( (chunker.exec(""), m = chunker.exec(soFar)) !== null ) {
+ soFar = m[3];
+
+ parts.push( m[1] );
+
+ if ( m[2] ) {
+ extra = m[3];
+ break;
+ }
+ }
+
+ if ( parts.length > 1 && origPOS.exec( selector ) ) {
+ if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
+ set = posProcess( parts[0] + parts[1], context );
+ } else {
+ set = Expr.relative[ parts[0] ] ?
+ [ context ] :
+ Sizzle( parts.shift(), context );
+
+ while ( parts.length ) {
+ selector = parts.shift();
+
+ if ( Expr.relative[ selector ] ) {
+ selector += parts.shift();
+ }
+
+ set = posProcess( selector, set );
+ }
+ }
+ } else {
+ // Take a shortcut and set the context if the root selector is an ID
+ // (but not if it'll be faster if the inner selector is an ID)
+ if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
+ Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
+ var ret = Sizzle.find( parts.shift(), context, contextXML );
+ context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];
+ }
+
+ if ( context ) {
+ var ret = seed ?
+ { expr: parts.pop(), set: makeArray(seed) } :
+ Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
+ set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set;
+
+ if ( parts.length > 0 ) {
+ checkSet = makeArray(set);
+ } else {
+ prune = false;
+ }
+
+ while ( parts.length ) {
+ var cur = parts.pop(), pop = cur;
+
+ if ( !Expr.relative[ cur ] ) {
+ cur = "";
+ } else {
+ pop = parts.pop();
+ }
+
+ if ( pop == null ) {
+ pop = context;
+ }
+
+ Expr.relative[ cur ]( checkSet, pop, contextXML );
+ }
+ } else {
+ checkSet = parts = [];
+ }
+ }
+
+ if ( !checkSet ) {
+ checkSet = set;
+ }
+
+ if ( !checkSet ) {
+ throw "Syntax error, unrecognized expression: " + (cur || selector);
+ }
+
+ if ( toString.call(checkSet) === "[object Array]" ) {
+ if ( !prune ) {
+ results.push.apply( results, checkSet );
+ } else if ( context && context.nodeType === 1 ) {
+ for ( var i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {
+ results.push( set[i] );
+ }
+ }
+ } else {
+ for ( var i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
+ results.push( set[i] );
+ }
+ }
+ }
+ } else {
+ makeArray( checkSet, results );
+ }
+
+ if ( extra ) {
+ Sizzle( extra, origContext, results, seed );
+ Sizzle.uniqueSort( results );
+ }
+
+ return results;
+};
+
+Sizzle.uniqueSort = function(results){
+ if ( sortOrder ) {
+ hasDuplicate = baseHasDuplicate;
+ results.sort(sortOrder);
+
+ if ( hasDuplicate ) {
+ for ( var i = 1; i < results.length; i++ ) {
+ if ( results[i] === results[i-1] ) {
+ results.splice(i--, 1);
+ }
+ }
+ }
+ }
+
+ return results;
+};
+
+Sizzle.matches = function(expr, set){
+ return Sizzle(expr, null, null, set);
+};
+
+Sizzle.find = function(expr, context, isXML){
+ var set, match;
+
+ if ( !expr ) {
+ return [];
+ }
+
+ for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
+ var type = Expr.order[i], match;
+
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
+ var left = match[1];
+ match.splice(1,1);
+
+ if ( left.substr( left.length - 1 ) !== "\\" ) {
+ match[1] = (match[1] || "").replace(/\\/g, "");
+ set = Expr.find[ type ]( match, context, isXML );
+ if ( set != null ) {
+ expr = expr.replace( Expr.match[ type ], "" );
+ break;
+ }
+ }
+ }
+ }
+
+ if ( !set ) {
+ set = context.getElementsByTagName("*");
+ }
+
+ return {set: set, expr: expr};
+};
+
+Sizzle.filter = function(expr, set, inplace, not){
+ var old = expr, result = [], curLoop = set, match, anyFound,
+ isXMLFilter = set && set[0] && isXML(set[0]);
+
+ while ( expr && set.length ) {
+ for ( var type in Expr.filter ) {
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
+ var filter = Expr.filter[ type ], found, item, left = match[1];
+ anyFound = false;
+
+ match.splice(1,1);
+
+ if ( left.substr( left.length - 1 ) === "\\" ) {
+ continue;
+ }
+
+ if ( curLoop === result ) {
+ result = [];
+ }
+
+ if ( Expr.preFilter[ type ] ) {
+ match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
+
+ if ( !match ) {
+ anyFound = found = true;
+ } else if ( match === true ) {
+ continue;
+ }
+ }
+
+ if ( match ) {
+ for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
+ if ( item ) {
+ found = filter( item, match, i, curLoop );
+ var pass = not ^ !!found;
+
+ if ( inplace && found != null ) {
+ if ( pass ) {
+ anyFound = true;
+ } else {
+ curLoop[i] = false;
+ }
+ } else if ( pass ) {
+ result.push( item );
+ anyFound = true;
+ }
+ }
+ }
+ }
+
+ if ( found !== undefined ) {
+ if ( !inplace ) {
+ curLoop = result;
+ }
+
+ expr = expr.replace( Expr.match[ type ], "" );
+
+ if ( !anyFound ) {
+ return [];
+ }
+
+ break;
+ }
+ }
+ }
+
+ // Improper expression
+ if ( expr === old ) {
+ if ( anyFound == null ) {
+ throw "Syntax error, unrecognized expression: " + expr;
+ } else {
+ break;
+ }
+ }
+
+ old = expr;
+ }
+
+ return curLoop;
+};
+
+var Expr = Sizzle.selectors = {
+ order: [ "ID", "NAME", "TAG" ],
+ match: {
+ ID: /#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
+ CLASS: /\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
+ NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,
+ ATTR: /\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
+ TAG: /^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,
+ CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
+ POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
+ PSEUDO: /:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
+ },
+ leftMatch: {},
+ attrMap: {
+ "class": "className",
+ "for": "htmlFor"
+ },
+ attrHandle: {
+ href: function(elem){
+ return elem.getAttribute("href");
+ }
+ },
+ relative: {
+ "+": function(checkSet, part){
+ var isPartStr = typeof part === "string",
+ isTag = isPartStr && !/\W/.test(part),
+ isPartStrNotTag = isPartStr && !isTag;
+
+ if ( isTag ) {
+ part = part.toLowerCase();
+ }
+
+ for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
+ if ( (elem = checkSet[i]) ) {
+ while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
+
+ checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
+ elem || false :
+ elem === part;
+ }
+ }
+
+ if ( isPartStrNotTag ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ },
+ ">": function(checkSet, part){
+ var isPartStr = typeof part === "string";
+
+ if ( isPartStr && !/\W/.test(part) ) {
+ part = part.toLowerCase();
+
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ var parent = elem.parentNode;
+ checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
+ }
+ }
+ } else {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ checkSet[i] = isPartStr ?
+ elem.parentNode :
+ elem.parentNode === part;
+ }
+ }
+
+ if ( isPartStr ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ }
+ },
+ "": function(checkSet, part, isXML){
+ var doneName = done++, checkFn = dirCheck;
+
+ if ( typeof part === "string" && !/\W/.test(part) ) {
+ var nodeCheck = part = part.toLowerCase();
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
+ },
+ "~": function(checkSet, part, isXML){
+ var doneName = done++, checkFn = dirCheck;
+
+ if ( typeof part === "string" && !/\W/.test(part) ) {
+ var nodeCheck = part = part.toLowerCase();
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);
+ }
+ },
+ find: {
+ ID: function(match, context, isXML){
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+ return m ? [m] : [];
+ }
+ },
+ NAME: function(match, context){
+ if ( typeof context.getElementsByName !== "undefined" ) {
+ var ret = [], results = context.getElementsByName(match[1]);
+
+ for ( var i = 0, l = results.length; i < l; i++ ) {
+ if ( results[i].getAttribute("name") === match[1] ) {
+ ret.push( results[i] );
+ }
+ }
+
+ return ret.length === 0 ? null : ret;
+ }
+ },
+ TAG: function(match, context){
+ return context.getElementsByTagName(match[1]);
+ }
+ },
+ preFilter: {
+ CLASS: function(match, curLoop, inplace, result, not, isXML){
+ match = " " + match[1].replace(/\\/g, "") + " ";
+
+ if ( isXML ) {
+ return match;
+ }
+
+ for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
+ if ( elem ) {
+ if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) {
+ if ( !inplace ) {
+ result.push( elem );
+ }
+ } else if ( inplace ) {
+ curLoop[i] = false;
+ }
+ }
+ }
+
+ return false;
+ },
+ ID: function(match){
+ return match[1].replace(/\\/g, "");
+ },
+ TAG: function(match, curLoop){
+ return match[1].toLowerCase();
+ },
+ CHILD: function(match){
+ if ( match[1] === "nth" ) {
+ // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
+ var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
+ match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
+ !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
+
+ // calculate the numbers (first)n+(last) including if they are negative
+ match[2] = (test[1] + (test[2] || 1)) - 0;
+ match[3] = test[3] - 0;
+ }
+
+ // TODO: Move to normal caching system
+ match[0] = done++;
+
+ return match;
+ },
+ ATTR: function(match, curLoop, inplace, result, not, isXML){
+ var name = match[1].replace(/\\/g, "");
+
+ if ( !isXML && Expr.attrMap[name] ) {
+ match[1] = Expr.attrMap[name];
+ }
+
+ if ( match[2] === "~=" ) {
+ match[4] = " " + match[4] + " ";
+ }
+
+ return match;
+ },
+ PSEUDO: function(match, curLoop, inplace, result, not){
+ if ( match[1] === "not" ) {
+ // If we're dealing with a complex expression, or a simple one
+ if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
+ match[3] = Sizzle(match[3], null, null, curLoop);
+ } else {
+ var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
+ if ( !inplace ) {
+ result.push.apply( result, ret );
+ }
+ return false;
+ }
+ } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
+ return true;
+ }
+
+ return match;
+ },
+ POS: function(match){
+ match.unshift( true );
+ return match;
+ }
+ },
+ filters: {
+ enabled: function(elem){
+ return elem.disabled === false && elem.type !== "hidden";
+ },
+ disabled: function(elem){
+ return elem.disabled === true;
+ },
+ checked: function(elem){
+ return elem.checked === true;
+ },
+ selected: function(elem){
+ // Accessing this property makes selected-by-default
+ // options in Safari work properly
+ elem.parentNode.selectedIndex;
+ return elem.selected === true;
+ },
+ parent: function(elem){
+ return !!elem.firstChild;
+ },
+ empty: function(elem){
+ return !elem.firstChild;
+ },
+ has: function(elem, i, match){
+ return !!Sizzle( match[3], elem ).length;
+ },
+ header: function(elem){
+ return /h\d/i.test( elem.nodeName );
+ },
+ text: function(elem){
+ return "text" === elem.type;
+ },
+ radio: function(elem){
+ return "radio" === elem.type;
+ },
+ checkbox: function(elem){
+ return "checkbox" === elem.type;
+ },
+ file: function(elem){
+ return "file" === elem.type;
+ },
+ password: function(elem){
+ return "password" === elem.type;
+ },
+ submit: function(elem){
+ return "submit" === elem.type;
+ },
+ image: function(elem){
+ return "image" === elem.type;
+ },
+ reset: function(elem){
+ return "reset" === elem.type;
+ },
+ button: function(elem){
+ return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
+ },
+ input: function(elem){
+ return /input|select|textarea|button/i.test(elem.nodeName);
+ }
+ },
+ setFilters: {
+ first: function(elem, i){
+ return i === 0;
+ },
+ last: function(elem, i, match, array){
+ return i === array.length - 1;
+ },
+ even: function(elem, i){
+ return i % 2 === 0;
+ },
+ odd: function(elem, i){
+ return i % 2 === 1;
+ },
+ lt: function(elem, i, match){
+ return i < match[3] - 0;
+ },
+ gt: function(elem, i, match){
+ return i > match[3] - 0;
+ },
+ nth: function(elem, i, match){
+ return match[3] - 0 === i;
+ },
+ eq: function(elem, i, match){
+ return match[3] - 0 === i;
+ }
+ },
+ filter: {
+ PSEUDO: function(elem, match, i, array){
+ var name = match[1], filter = Expr.filters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+ } else if ( name === "contains" ) {
+ return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
+ } else if ( name === "not" ) {
+ var not = match[3];
+
+ for ( var i = 0, l = not.length; i < l; i++ ) {
+ if ( not[i] === elem ) {
+ return false;
+ }
+ }
+
+ return true;
+ } else {
+ throw "Syntax error, unrecognized expression: " + name;
+ }
+ },
+ CHILD: function(elem, match){
+ var type = match[1], node = elem;
+ switch (type) {
+ case 'only':
+ case 'first':
+ while ( (node = node.previousSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+ if ( type === "first" ) {
+ return true;
+ }
+ node = elem;
+ case 'last':
+ while ( (node = node.nextSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+ return true;
+ case 'nth':
+ var first = match[2], last = match[3];
+
+ if ( first === 1 && last === 0 ) {
+ return true;
+ }
+
+ var doneName = match[0],
+ parent = elem.parentNode;
+
+ if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
+ var count = 0;
+ for ( node = parent.firstChild; node; node = node.nextSibling ) {
+ if ( node.nodeType === 1 ) {
+ node.nodeIndex = ++count;
+ }
+ }
+ parent.sizcache = doneName;
+ }
+
+ var diff = elem.nodeIndex - last;
+ if ( first === 0 ) {
+ return diff === 0;
+ } else {
+ return ( diff % first === 0 && diff / first >= 0 );
+ }
+ }
+ },
+ ID: function(elem, match){
+ return elem.nodeType === 1 && elem.getAttribute("id") === match;
+ },
+ TAG: function(elem, match){
+ return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
+ },
+ CLASS: function(elem, match){
+ return (" " + (elem.className || elem.getAttribute("class")) + " ")
+ .indexOf( match ) > -1;
+ },
+ ATTR: function(elem, match){
+ var name = match[1],
+ result = Expr.attrHandle[ name ] ?
+ Expr.attrHandle[ name ]( elem ) :
+ elem[ name ] != null ?
+ elem[ name ] :
+ elem.getAttribute( name ),
+ value = result + "",
+ type = match[2],
+ check = match[4];
+
+ return result == null ?
+ type === "!=" :
+ type === "=" ?
+ value === check :
+ type === "*=" ?
+ value.indexOf(check) >= 0 :
+ type === "~=" ?
+ (" " + value + " ").indexOf(check) >= 0 :
+ !check ?
+ value && result !== false :
+ type === "!=" ?
+ value !== check :
+ type === "^=" ?
+ value.indexOf(check) === 0 :
+ type === "$=" ?
+ value.substr(value.length - check.length) === check :
+ type === "|=" ?
+ value === check || value.substr(0, check.length + 1) === check + "-" :
+ false;
+ },
+ POS: function(elem, match, i, array){
+ var name = match[2], filter = Expr.setFilters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+ }
+ }
+ }
+};
+
+var origPOS = Expr.match.POS;
+
+for ( var type in Expr.match ) {
+ Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source );
+ Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, function(all, num){
+ return "\\" + (num - 0 + 1);
+ }));
+}
+
+var makeArray = function(array, results) {
+ array = Array.prototype.slice.call( array, 0 );
+
+ if ( results ) {
+ results.push.apply( results, array );
+ return results;
+ }
+
+ return array;
+};
+
+// Perform a simple check to determine if the browser is capable of
+// converting a NodeList to an array using builtin methods.
+try {
+ Array.prototype.slice.call( document.documentElement.childNodes, 0 );
+
+// Provide a fallback method if it does not work
+} catch(e){
+ makeArray = function(array, results) {
+ var ret = results || [];
+
+ if ( toString.call(array) === "[object Array]" ) {
+ Array.prototype.push.apply( ret, array );
+ } else {
+ if ( typeof array.length === "number" ) {
+ for ( var i = 0, l = array.length; i < l; i++ ) {
+ ret.push( array[i] );
+ }
+ } else {
+ for ( var i = 0; array[i]; i++ ) {
+ ret.push( array[i] );
+ }
+ }
+ }
+
+ return ret;
+ };
+}
+
+var sortOrder;
+
+if ( document.documentElement.compareDocumentPosition ) {
+ sortOrder = function( a, b ) {
+ if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.compareDocumentPosition ? -1 : 1;
+ }
+
+ var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+} else if ( "sourceIndex" in document.documentElement ) {
+ sortOrder = function( a, b ) {
+ if ( !a.sourceIndex || !b.sourceIndex ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.sourceIndex ? -1 : 1;
+ }
+
+ var ret = a.sourceIndex - b.sourceIndex;
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+} else if ( document.createRange ) {
+ sortOrder = function( a, b ) {
+ if ( !a.ownerDocument || !b.ownerDocument ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.ownerDocument ? -1 : 1;
+ }
+
+ var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();
+ aRange.setStart(a, 0);
+ aRange.setEnd(a, 0);
+ bRange.setStart(b, 0);
+ bRange.setEnd(b, 0);
+ var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange);
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+}
+
+// Utility function for retreiving the text value of an array of DOM nodes
+function getText( elems ) {
+ var ret = "", elem;
+
+ for ( var i = 0; elems[i]; i++ ) {
+ elem = elems[i];
+
+ // Get the text from text nodes and CDATA nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
+ ret += elem.nodeValue;
+
+ // Traverse everything else, except comment nodes
+ } else if ( elem.nodeType !== 8 ) {
+ ret += getText( elem.childNodes );
+ }
+ }
+
+ return ret;
+}
+
+// Check to see if the browser returns elements by name when
+// querying by getElementById (and provide a workaround)
+(function(){
+ // We're going to inject a fake input element with a specified name
+ var form = document.createElement("div"),
+ id = "script" + (new Date).getTime();
+ form.innerHTML = "<a name='" + id + "'/>";
+
+ // Inject it into the root element, check its status, and remove it quickly
+ var root = document.documentElement;
+ root.insertBefore( form, root.firstChild );
+
+ // The workaround has to do additional checks after a getElementById
+ // Which slows things down for other browsers (hence the branching)
+ if ( document.getElementById( id ) ) {
+ Expr.find.ID = function(match, context, isXML){
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+ return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
+ }
+ };
+
+ Expr.filter.ID = function(elem, match){
+ var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
+ return elem.nodeType === 1 && node && node.nodeValue === match;
+ };
+ }
+
+ root.removeChild( form );
+ root = form = null; // release memory in IE
+})();
+
+(function(){
+ // Check to see if the browser returns only elements
+ // when doing getElementsByTagName("*")
+
+ // Create a fake element
+ var div = document.createElement("div");
+ div.appendChild( document.createComment("") );
+
+ // Make sure no comments are found
+ if ( div.getElementsByTagName("*").length > 0 ) {
+ Expr.find.TAG = function(match, context){
+ var results = context.getElementsByTagName(match[1]);
+
+ // Filter out possible comments
+ if ( match[1] === "*" ) {
+ var tmp = [];
+
+ for ( var i = 0; results[i]; i++ ) {
+ if ( results[i].nodeType === 1 ) {
+ tmp.push( results[i] );
+ }
+ }
+
+ results = tmp;
+ }
+
+ return results;
+ };
+ }
+
+ // Check to see if an attribute returns normalized href attributes
+ div.innerHTML = "<a href='#'></a>";
+ if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
+ div.firstChild.getAttribute("href") !== "#" ) {
+ Expr.attrHandle.href = function(elem){
+ return elem.getAttribute("href", 2);
+ };
+ }
+
+ div = null; // release memory in IE
+})();
+
+if ( document.querySelectorAll ) {
+ (function(){
+ var oldSizzle = Sizzle, div = document.createElement("div");
+ div.innerHTML = "<p class='TEST'></p>";
+
+ // Safari can't handle uppercase or unicode characters when
+ // in quirks mode.
+ if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
+ return;
+ }
+
+ Sizzle = function(query, context, extra, seed){
+ context = context || document;
+
+ // Only use querySelectorAll on non-XML documents
+ // (ID selectors don't work in non-HTML documents)
+ if ( !seed && context.nodeType === 9 && !isXML(context) ) {
+ try {
+ return makeArray( context.querySelectorAll(query), extra );
+ } catch(e){}
+ }
+
+ return oldSizzle(query, context, extra, seed);
+ };
+
+ for ( var prop in oldSizzle ) {
+ Sizzle[ prop ] = oldSizzle[ prop ];
+ }
+
+ div = null; // release memory in IE
+ })();
+}
+
+(function(){
+ var div = document.createElement("div");
+
+ div.innerHTML = "<div class='test e'></div><div class='test'></div>";
+
+ // Opera can't find a second classname (in 9.6)
+ // Also, make sure that getElementsByClassName actually exists
+ if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
+ return;
+ }
+
+ // Safari caches class attributes, doesn't catch changes (in 3.2)
+ div.lastChild.className = "e";
+
+ if ( div.getElementsByClassName("e").length === 1 ) {
+ return;
+ }
+
+ Expr.order.splice(1, 0, "CLASS");
+ Expr.find.CLASS = function(match, context, isXML) {
+ if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
+ return context.getElementsByClassName(match[1]);
+ }
+ };
+
+ div = null; // release memory in IE
+})();
+
+function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ elem = elem[dir];
+ var match = false;
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 && !isXML ){
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+
+ if ( elem.nodeName.toLowerCase() === cur ) {
+ match = elem;
+ break;
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ elem = elem[dir];
+ var match = false;
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 ) {
+ if ( !isXML ) {
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+ if ( typeof cur !== "string" ) {
+ if ( elem === cur ) {
+ match = true;
+ break;
+ }
+
+ } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
+ match = elem;
+ break;
+ }
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+var contains = document.compareDocumentPosition ? function(a, b){
+ return a.compareDocumentPosition(b) & 16;
+} : function(a, b){
+ return a !== b && (a.contains ? a.contains(b) : true);
+};
+
+var isXML = function(elem){
+ // documentElement is verified for cases where it doesn't yet exist
+ // (such as loading iframes in IE - #4833)
+ var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
+ return documentElement ? documentElement.nodeName !== "HTML" : false;
+};
+
+var posProcess = function(selector, context){
+ var tmpSet = [], later = "", match,
+ root = context.nodeType ? [context] : context;
+
+ // Position selectors must be done after the filter
+ // And so must :not(positional) so we move all PSEUDOs to the end
+ while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
+ later += match[0];
+ selector = selector.replace( Expr.match.PSEUDO, "" );
+ }
+
+ selector = Expr.relative[selector] ? selector + "*" : selector;
+
+ for ( var i = 0, l = root.length; i < l; i++ ) {
+ Sizzle( selector, root[i], tmpSet );
+ }
+
+ return Sizzle.filter( later, tmpSet );
+};
+
+// EXPOSE
+jQuery.find = Sizzle;
+jQuery.expr = Sizzle.selectors;
+jQuery.expr[":"] = jQuery.expr.filters;
+jQuery.unique = Sizzle.uniqueSort;
+jQuery.getText = getText;
+jQuery.isXMLDoc = isXML;
+jQuery.contains = contains;
+
+return;
+
+window.Sizzle = Sizzle;
+
+})();
+var runtil = /Until$/,
+ rparentsprev = /^(?:parents|prevUntil|prevAll)/,
+ // Note: This RegExp should be improved, or likely pulled from Sizzle
+ rmultiselector = /,/,
+ slice = Array.prototype.slice;
+
+// Implement the identical functionality for filter and not
+var winnow = function( elements, qualifier, keep ) {
+ if ( jQuery.isFunction( qualifier ) ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ return !!qualifier.call( elem, i, elem ) === keep;
+ });
+
+ } else if ( qualifier.nodeType ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ return (elem === qualifier) === keep;
+ });
+
+ } else if ( typeof qualifier === "string" ) {
+ var filtered = jQuery.grep(elements, function( elem ) {
+ return elem.nodeType === 1;
+ });
+
+ if ( isSimple.test( qualifier ) ) {
+ return jQuery.filter(qualifier, filtered, !keep);
+ } else {
+ qualifier = jQuery.filter( qualifier, elements );
+ }
+ }
+
+ return jQuery.grep(elements, function( elem, i ) {
+ return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
+ });
+};
+
+jQuery.fn.extend({
+ find: function( selector ) {
+ var ret = this.pushStack( "", "find", selector ), length = 0;
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ length = ret.length;
+ jQuery.find( selector, this[i], ret );
+
+ if ( i > 0 ) {
+ // Make sure that the results are unique
+ for ( var n = length; n < ret.length; n++ ) {
+ for ( var r = 0; r < length; r++ ) {
+ if ( ret[r] === ret[n] ) {
+ ret.splice(n--, 1);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return ret;
+ },
+
+ has: function( target ) {
+ var targets = jQuery( target );
+ return this.filter(function() {
+ for ( var i = 0, l = targets.length; i < l; i++ ) {
+ if ( jQuery.contains( this, targets[i] ) ) {
+ return true;
+ }
+ }
+ });
+ },
+
+ not: function( selector ) {
+ return this.pushStack( winnow(this, selector, false), "not", selector);
+ },
+
+ filter: function( selector ) {
+ return this.pushStack( winnow(this, selector, true), "filter", selector );
+ },
+
+ is: function( selector ) {
+ return !!selector && jQuery.filter( selector, this ).length > 0;
+ },
+
+ closest: function( selectors, context ) {
+ if ( jQuery.isArray( selectors ) ) {
+ var ret = [], cur = this[0], match, matches = {}, selector;
+
+ if ( cur && selectors.length ) {
+ for ( var i = 0, l = selectors.length; i < l; i++ ) {
+ selector = selectors[i];
+
+ if ( !matches[selector] ) {
+ matches[selector] = jQuery.expr.match.POS.test( selector ) ?
+ jQuery( selector, context || this.context ) :
+ selector;
+ }
+ }
+
+ while ( cur && cur.ownerDocument && cur !== context ) {
+ for ( selector in matches ) {
+ match = matches[selector];
+
+ if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) {
+ ret.push({ selector: selector, elem: cur });
+ delete matches[selector];
+ }
+ }
+ cur = cur.parentNode;
+ }
+ }
+
+ return ret;
+ }
+
+ var pos = jQuery.expr.match.POS.test( selectors ) ?
+ jQuery( selectors, context || this.context ) : null;
+
+ return this.map(function( i, cur ) {
+ while ( cur && cur.ownerDocument && cur !== context ) {
+ if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selectors) ) {
+ return cur;
+ }
+ cur = cur.parentNode;
+ }
+ return null;
+ });
+ },
+
+ // Determine the position of an element within
+ // the matched set of elements
+ index: function( elem ) {
+ if ( !elem || typeof elem === "string" ) {
+ return jQuery.inArray( this[0],
+ // If it receives a string, the selector is used
+ // If it receives nothing, the siblings are used
+ elem ? jQuery( elem ) : this.parent().children() );
+ }
+ // Locate the position of the desired element
+ return jQuery.inArray(
+ // If it receives a jQuery object, the first element is used
+ elem.jquery ? elem[0] : elem, this );
+ },
+
+ add: function( selector, context ) {
+ var set = typeof selector === "string" ?
+ jQuery( selector, context || this.context ) :
+ jQuery.makeArray( selector ),
+ all = jQuery.merge( this.get(), set );
+
+ return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
+ all :
+ jQuery.unique( all ) );
+ },
+
+ andSelf: function() {
+ return this.add( this.prevObject );
+ }
+});
+
+// A painfully simple check to see if an element is disconnected
+// from a document (should be improved, where feasible).
+function isDisconnected( node ) {
+ return !node || !node.parentNode || node.parentNode.nodeType === 11;
+}
+
+jQuery.each({
+ parent: function( elem ) {
+ var parent = elem.parentNode;
+ return parent && parent.nodeType !== 11 ? parent : null;
+ },
+ parents: function( elem ) {
+ return jQuery.dir( elem, "parentNode" );
+ },
+ parentsUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "parentNode", until );
+ },
+ next: function( elem ) {
+ return jQuery.nth( elem, 2, "nextSibling" );
+ },
+ prev: function( elem ) {
+ return jQuery.nth( elem, 2, "previousSibling" );
+ },
+ nextAll: function( elem ) {
+ return jQuery.dir( elem, "nextSibling" );
+ },
+ prevAll: function( elem ) {
+ return jQuery.dir( elem, "previousSibling" );
+ },
+ nextUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "nextSibling", until );
+ },
+ prevUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "previousSibling", until );
+ },
+ siblings: function( elem ) {
+ return jQuery.sibling( elem.parentNode.firstChild, elem );
+ },
+ children: function( elem ) {
+ return jQuery.sibling( elem.firstChild );
+ },
+ contents: function( elem ) {
+ return jQuery.nodeName( elem, "iframe" ) ?
+ elem.contentDocument || elem.contentWindow.document :
+ jQuery.makeArray( elem.childNodes );
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function( until, selector ) {
+ var ret = jQuery.map( this, fn, until );
+
+ if ( !runtil.test( name ) ) {
+ selector = until;
+ }
+
+ if ( selector && typeof selector === "string" ) {
+ ret = jQuery.filter( selector, ret );
+ }
+
+ ret = this.length > 1 ? jQuery.unique( ret ) : ret;
+
+ if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
+ ret = ret.reverse();
+ }
+
+ return this.pushStack( ret, name, slice.call(arguments).join(",") );
+ };
+});
+
+jQuery.extend({
+ filter: function( expr, elems, not ) {
+ if ( not ) {
+ expr = ":not(" + expr + ")";
+ }
+
+ return jQuery.find.matches(expr, elems);
+ },
+
+ dir: function( elem, dir, until ) {
+ var matched = [], cur = elem[dir];
+ while ( cur && cur.nodeType !== 9 && (until === undefined || !jQuery( cur ).is( until )) ) {
+ if ( cur.nodeType === 1 ) {
+ matched.push( cur );
+ }
+ cur = cur[dir];
+ }
+ return matched;
+ },
+
+ nth: function( cur, result, dir, elem ) {
+ result = result || 1;
+ var num = 0;
+
+ for ( ; cur; cur = cur[dir] ) {
+ if ( cur.nodeType === 1 && ++num === result ) {
+ break;
+ }
+ }
+
+ return cur;
+ },
+
+ sibling: function( n, elem ) {
+ var r = [];
+
+ for ( ; n; n = n.nextSibling ) {
+ if ( n.nodeType === 1 && n !== elem ) {
+ r.push( n );
+ }
+ }
+
+ return r;
+ }
+});
+var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
+ rleadingWhitespace = /^\s+/,
+ rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g,
+ rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,
+ rtagName = /<([\w:]+)/,
+ rtbody = /<tbody/i,
+ rhtml = /<|&\w+;/,
+ fcloseTag = function( all, front, tag ) {
+ return rselfClosing.test( tag ) ?
+ all :
+ front + "></" + tag + ">";
+ },
+ wrapMap = {
+ option: [ 1, "<select multiple='multiple'>", "</select>" ],
+ legend: [ 1, "<fieldset>", "</fieldset>" ],
+ thead: [ 1, "<table>", "</table>" ],
+ tr: [ 2, "<table><tbody>", "</tbody></table>" ],
+ td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
+ col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
+ area: [ 1, "<map>", "</map>" ],
+ _default: [ 0, "", "" ]
+ };
+
+wrapMap.optgroup = wrapMap.option;
+wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
+wrapMap.th = wrapMap.td;
+
+// IE can't serialize <link> and <script> tags normally
+if ( !jQuery.support.htmlSerialize ) {
+ wrapMap._default = [ 1, "div<div>", "</div>" ];
+}
+
+jQuery.fn.extend({
+ text: function( text ) {
+ if ( jQuery.isFunction(text) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ return self.text( text.call(this, i, self.text()) );
+ });
+ }
+
+ if ( typeof text !== "object" && text !== undefined ) {
+ return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
+ }
+
+ return jQuery.getText( this );
+ },
+
+ wrapAll: function( html ) {
+ if ( jQuery.isFunction( html ) ) {
+ return this.each(function(i) {
+ jQuery(this).wrapAll( html.call(this, i) );
+ });
+ }
+
+ if ( this[0] ) {
+ // The elements to wrap the target around
+ var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
+
+ if ( this[0].parentNode ) {
+ wrap.insertBefore( this[0] );
+ }
+
+ wrap.map(function() {
+ var elem = this;
+
+ while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
+ elem = elem.firstChild;
+ }
+
+ return elem;
+ }).append(this);
+ }
+
+ return this;
+ },
+
+ wrapInner: function( html ) {
+ return this.each(function() {
+ var self = jQuery( this ), contents = self.contents();
+
+ if ( contents.length ) {
+ contents.wrapAll( html );
+
+ } else {
+ self.append( html );
+ }
+ });
+ },
+
+ wrap: function( html ) {
+ return this.each(function() {
+ jQuery( this ).wrapAll( html );
+ });
+ },
+
+ unwrap: function() {
+ return this.parent().each(function() {
+ if ( !jQuery.nodeName( this, "body" ) ) {
+ jQuery( this ).replaceWith( this.childNodes );
+ }
+ }).end();
+ },
+
+ append: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 ) {
+ this.appendChild( elem );
+ }
+ });
+ },
+
+ prepend: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 ) {
+ this.insertBefore( elem, this.firstChild );
+ }
+ });
+ },
+
+ before: function() {
+ if ( this[0] && this[0].parentNode ) {
+ return this.domManip(arguments, false, function( elem ) {
+ this.parentNode.insertBefore( elem, this );
+ });
+ } else if ( arguments.length ) {
+ var set = jQuery(arguments[0]);
+ set.push.apply( set, this.toArray() );
+ return this.pushStack( set, "before", arguments );
+ }
+ },
+
+ after: function() {
+ if ( this[0] && this[0].parentNode ) {
+ return this.domManip(arguments, false, function( elem ) {
+ this.parentNode.insertBefore( elem, this.nextSibling );
+ });
+ } else if ( arguments.length ) {
+ var set = this.pushStack( this, "after", arguments );
+ set.push.apply( set, jQuery(arguments[0]).toArray() );
+ return set;
+ }
+ },
+
+ clone: function( events ) {
+ // Do the clone
+ var ret = this.map(function() {
+ if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) {
+ // IE copies events bound via attachEvent when
+ // using cloneNode. Calling detachEvent on the
+ // clone will also remove the events from the orignal
+ // In order to get around this, we use innerHTML.
+ // Unfortunately, this means some modifications to
+ // attributes in IE that are actually only stored
+ // as properties will not be copied (such as the
+ // the name attribute on an input).
+ var html = this.outerHTML, ownerDocument = this.ownerDocument;
+ if ( !html ) {
+ var div = ownerDocument.createElement("div");
+ div.appendChild( this.cloneNode(true) );
+ html = div.innerHTML;
+ }
+
+ return jQuery.clean([html.replace(rinlinejQuery, "")
+ .replace(rleadingWhitespace, "")], ownerDocument)[0];
+ } else {
+ return this.cloneNode(true);
+ }
+ });
+
+ // Copy the events from the original to the clone
+ if ( events === true ) {
+ cloneCopyEvent( this, ret );
+ cloneCopyEvent( this.find("*"), ret.find("*") );
+ }
+
+ // Return the cloned set
+ return ret;
+ },
+
+ html: function( value ) {
+ if ( value === undefined ) {
+ return this[0] && this[0].nodeType === 1 ?
+ this[0].innerHTML.replace(rinlinejQuery, "") :
+ null;
+
+ // See if we can take a shortcut and just use innerHTML
+ } else if ( typeof value === "string" && !/<script/i.test( value ) &&
+ (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
+ !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
+
+ try {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ // Remove element nodes and prevent memory leaks
+ if ( this[i].nodeType === 1 ) {
+ cleanData( this[i].getElementsByTagName("*") );
+ this[i].innerHTML = value;
+ }
+ }
+
+ // If using innerHTML throws an exception, use the fallback method
+ } catch(e) {
+ this.empty().append( value );
+ }
+
+ } else if ( jQuery.isFunction( value ) ) {
+ this.each(function(i){
+ var self = jQuery(this), old = self.html();
+ self.empty().append(function(){
+ return value.call( this, i, old );
+ });
+ });
+
+ } else {
+ this.empty().append( value );
+ }
+
+ return this;
+ },
+
+ replaceWith: function( value ) {
+ if ( this[0] && this[0].parentNode ) {
+ // Make sure that the elements are removed from the DOM before they are inserted
+ // this can help fix replacing a parent with child elements
+ if ( !jQuery.isFunction( value ) ) {
+ value = jQuery( value ).detach();
+ }
+
+ return this.each(function() {
+ var next = this.nextSibling, parent = this.parentNode;
+
+ jQuery(this).remove();
+
+ if ( next ) {
+ jQuery(next).before( value );
+ } else {
+ jQuery(parent).append( value );
+ }
+ });
+ } else {
+ return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value );
+ }
+ },
+
+ detach: function( selector ) {
+ return this.remove( selector, true );
+ },
+
+ domManip: function( args, table, callback ) {
+ var results, first, value = args[0], scripts = [];
+
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ args[0] = value.call(this, i, table ? self.html() : undefined);
+ return self.domManip( args, table, callback );
+ });
+ }
+
+ if ( this[0] ) {
+ // If we're in a fragment, just use that instead of building a new one
+ if ( args[0] && args[0].parentNode && args[0].parentNode.nodeType === 11 ) {
+ results = { fragment: args[0].parentNode };
+ } else {
+ results = buildFragment( args, this, scripts );
+ }
+
+ first = results.fragment.firstChild;
+
+ if ( first ) {
+ table = table && jQuery.nodeName( first, "tr" );
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ callback.call(
+ table ?
+ root(this[i], first) :
+ this[i],
+ results.cacheable || this.length > 1 || i > 0 ?
+ results.fragment.cloneNode(true) :
+ results.fragment
+ );
+ }
+ }
+
+ if ( scripts ) {
+ jQuery.each( scripts, evalScript );
+ }
+ }
+
+ return this;
+
+ function root( elem, cur ) {
+ return jQuery.nodeName(elem, "table") ?
+ (elem.getElementsByTagName("tbody")[0] ||
+ elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
+ elem;
+ }
+ }
+});
+
+function cloneCopyEvent(orig, ret) {
+ var i = 0;
+
+ ret.each(function() {
+ if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) {
+ return;
+ }
+
+ var oldData = jQuery.data( orig[i++] ), curData = jQuery.data( this, oldData ), events = oldData && oldData.events;
+
+ if ( events ) {
+ delete curData.handle;
+ curData.events = {};
+
+ for ( var type in events ) {
+ for ( var handler in events[ type ] ) {
+ jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data );
+ }
+ }
+ }
+ });
+}
+
+function buildFragment( args, nodes, scripts ) {
+ var fragment, cacheable, cached, cacheresults, doc;
+
+ if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) {
+ cacheable = true;
+ cacheresults = jQuery.fragments[ args[0] ];
+ if ( cacheresults ) {
+ if ( cacheresults !== 1 ) {
+ fragment = cacheresults;
+ }
+ cached = true;
+ }
+ }
+
+ if ( !fragment ) {
+ doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
+ fragment = doc.createDocumentFragment();
+ jQuery.clean( args, doc, fragment, scripts );
+ }
+
+ if ( cacheable ) {
+ jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
+ }
+
+ return { fragment: fragment, cacheable: cacheable };
+}
+
+jQuery.fragments = {};
+
+jQuery.each({
+ appendTo: "append",
+ prependTo: "prepend",
+ insertBefore: "before",
+ insertAfter: "after",
+ replaceAll: "replaceWith"
+}, function( name, original ) {
+ jQuery.fn[ name ] = function( selector ) {
+ var ret = [], insert = jQuery( selector );
+
+ for ( var i = 0, l = insert.length; i < l; i++ ) {
+ var elems = (i > 0 ? this.clone(true) : this).get();
+ jQuery.fn[ original ].apply( jQuery(insert[i]), elems );
+ ret = ret.concat( elems );
+ }
+ return this.pushStack( ret, name, insert.selector );
+ };
+});
+
+jQuery.each({
+ // keepData is for internal use only--do not document
+ remove: function( selector, keepData ) {
+ if ( !selector || jQuery.filter( selector, [ this ] ).length ) {
+ if ( !keepData && this.nodeType === 1 ) {
+ cleanData( this.getElementsByTagName("*") );
+ cleanData( [ this ] );
+ }
+
+ if ( this.parentNode ) {
+ this.parentNode.removeChild( this );
+ }
+ }
+ },
+
+ empty: function() {
+ // Remove element nodes and prevent memory leaks
+ if ( this.nodeType === 1 ) {
+ cleanData( this.getElementsByTagName("*") );
+ }
+
+ // Remove any remaining nodes
+ while ( this.firstChild ) {
+ this.removeChild( this.firstChild );
+ }
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function() {
+ return this.each( fn, arguments );
+ };
+});
+
+jQuery.extend({
+ clean: function( elems, context, fragment, scripts ) {
+ context = context || document;
+
+ // !context.createElement fails in IE with an error but returns typeof 'object'
+ if ( typeof context.createElement === "undefined" ) {
+ context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
+ }
+
+ var ret = [];
+
+ jQuery.each(elems, function( i, elem ) {
+ if ( typeof elem === "number" ) {
+ elem += "";
+ }
+
+ if ( !elem ) {
+ return;
+ }
+
+ // Convert html string into DOM nodes
+ if ( typeof elem === "string" && !rhtml.test( elem ) ) {
+ elem = context.createTextNode( elem );
+
+ } else if ( typeof elem === "string" ) {
+ // Fix "XHTML"-style tags in all browsers
+ elem = elem.replace(rxhtmlTag, fcloseTag);
+
+ // Trim whitespace, otherwise indexOf won't work as expected
+ var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
+ wrap = wrapMap[ tag ] || wrapMap._default,
+ depth = wrap[0],
+ div = context.createElement("div");
+
+ // Go to html and back, then peel off extra wrappers
+ div.innerHTML = wrap[1] + elem + wrap[2];
+
+ // Move to the right depth
+ while ( depth-- ) {
+ div = div.lastChild;
+ }
+
+ // Remove IE's autoinserted <tbody> from table fragments
+ if ( !jQuery.support.tbody ) {
+
+ // String was a <table>, *may* have spurious <tbody>
+ var hasBody = rtbody.test(elem),
+ tbody = tag === "table" && !hasBody ?
+ div.firstChild && div.firstChild.childNodes :
+
+ // String was a bare <thead> or <tfoot>
+ wrap[1] === "<table>" && !hasBody ?
+ div.childNodes :
+ [];
+
+ for ( var j = tbody.length - 1; j >= 0 ; --j ) {
+ if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
+ tbody[ j ].parentNode.removeChild( tbody[ j ] );
+ }
+ }
+
+ }
+
+ // IE completely kills leading whitespace when innerHTML is used
+ if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
+ div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
+ }
+
+ elem = jQuery.makeArray( div.childNodes );
+ }
+
+ if ( elem.nodeType ) {
+ ret.push( elem );
+ } else {
+ ret = jQuery.merge( ret, elem );
+ }
+
+ });
+
+ if ( fragment ) {
+ for ( var i = 0; ret[i]; i++ ) {
+ if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
+ scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
+ } else {
+ if ( ret[i].nodeType === 1 ) {
+ ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
+ }
+ fragment.appendChild( ret[i] );
+ }
+ }
+ }
+
+ return ret;
+ }
+});
+
+function cleanData( elems ) {
+ for ( var i = 0, elem, id; (elem = elems[i]) != null; i++ ) {
+ if ( !jQuery.noData[elem.nodeName.toLowerCase()] && (id = elem[expando]) ) {
+ delete jQuery.cache[ id ];
+ }
+ }
+}
+// exclude the following css properties to add px
+var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
+ ralpha = /alpha\([^)]*\)/,
+ ropacity = /opacity=([^)]*)/,
+ rfloat = /float/i,
+ rdashAlpha = /-([a-z])/ig,
+ rupper = /([A-Z])/g,
+ rnumpx = /^-?\d+(?:px)?$/i,
+ rnum = /^-?\d/,
+
+ cssShow = { position: "absolute", visibility: "hidden", display:"block" },
+ cssWidth = [ "Left", "Right" ],
+ cssHeight = [ "Top", "Bottom" ],
+
+ // cache check for defaultView.getComputedStyle
+ getComputedStyle = document.defaultView && document.defaultView.getComputedStyle,
+ // normalize float css property
+ styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat",
+ fcamelCase = function( all, letter ) {
+ return letter.toUpperCase();
+ };
+
+jQuery.fn.css = function( name, value ) {
+ return access( this, name, value, true, function( elem, name, value ) {
+ if ( value === undefined ) {
+ return jQuery.curCSS( elem, name );
+ }
+
+ if ( typeof value === "number" && !rexclude.test(name) ) {
+ value += "px";
+ }
+
+ jQuery.style( elem, name, value );
+ });
+};
+
+jQuery.extend({
+ style: function( elem, name, value ) {
+ // don't set styles on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ // ignore negative width and height values #1599
+ if ( (name === "width" || name === "height") && parseFloat(value) < 0 ) {
+ value = undefined;
+ }
+
+ var style = elem.style || elem, set = value !== undefined;
+
+ // IE uses filters for opacity
+ if ( !jQuery.support.opacity && name === "opacity" ) {
+ if ( set ) {
+ // IE has trouble with opacity if it does not have layout
+ // Force it by setting the zoom level
+ style.zoom = 1;
+
+ // Set the alpha filter to set the opacity
+ var opacity = parseInt( value, 10 ) + "" === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")";
+ var filter = style.filter || jQuery.curCSS( elem, "filter" ) || "";
+ style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : opacity;
+ }
+
+ return style.filter && style.filter.indexOf("opacity=") >= 0 ?
+ (parseFloat( ropacity.exec(style.filter)[1] ) / 100) + "":
+ "";
+ }
+
+ // Make sure we're using the right name for getting the float value
+ if ( rfloat.test( name ) ) {
+ name = styleFloat;
+ }
+
+ name = name.replace(rdashAlpha, fcamelCase);
+
+ if ( set ) {
+ style[ name ] = value;
+ }
+
+ return style[ name ];
+ },
+
+ css: function( elem, name, force, extra ) {
+ if ( name === "width" || name === "height" ) {
+ var val, props = cssShow, which = name === "width" ? cssWidth : cssHeight;
+
+ function getWH() {
+ val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
+
+ if ( extra === "border" ) {
+ return;
+ }
+
+ jQuery.each( which, function() {
+ if ( !extra ) {
+ val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
+ }
+
+ if ( extra === "margin" ) {
+ val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0;
+ } else {
+ val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
+ }
+ });
+ }
+
+ if ( elem.offsetWidth !== 0 ) {
+ getWH();
+ } else {
+ jQuery.swap( elem, props, getWH );
+ }
+
+ return Math.max(0, Math.round(val));
+ }
+
+ return jQuery.curCSS( elem, name, force );
+ },
+
+ curCSS: function( elem, name, force ) {
+ var ret, style = elem.style, filter;
+
+ // IE uses filters for opacity
+ if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) {
+ ret = ropacity.test(elem.currentStyle.filter || "") ?
+ (parseFloat(RegExp.$1) / 100) + "" :
+ "";
+
+ return ret === "" ?
+ "1" :
+ ret;
+ }
+
+ // Make sure we're using the right name for getting the float value
+ if ( rfloat.test( name ) ) {
+ name = styleFloat;
+ }
+
+ if ( !force && style && style[ name ] ) {
+ ret = style[ name ];
+
+ } else if ( getComputedStyle ) {
+
+ // Only "float" is needed here
+ if ( rfloat.test( name ) ) {
+ name = "float";
+ }
+
+ name = name.replace( rupper, "-$1" ).toLowerCase();
+
+ var defaultView = elem.ownerDocument.defaultView;
+
+ if ( !defaultView ) {
+ return null;
+ }
+
+ var computedStyle = defaultView.getComputedStyle( elem, null );
+
+ if ( computedStyle ) {
+ ret = computedStyle.getPropertyValue( name );
+ }
+
+ // We should always get a number back from opacity
+ if ( name === "opacity" && ret === "" ) {
+ ret = "1";
+ }
+
+ } else if ( elem.currentStyle ) {
+ var camelCase = name.replace(rdashAlpha, fcamelCase);
+
+ ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
+
+ // From the awesome hack by Dean Edwards
+ // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
+
+ // If we're not dealing with a regular pixel number
+ // but a number that has a weird ending, we need to convert it to pixels
+ if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
+ // Remember the original values
+ var left = style.left, rsLeft = elem.runtimeStyle.left;
+
+ // Put in the new values to get a computed value out
+ elem.runtimeStyle.left = elem.currentStyle.left;
+ style.left = camelCase === "fontSize" ? "1em" : (ret || 0);
+ ret = style.pixelLeft + "px";
+
+ // Revert the changed values
+ style.left = left;
+ elem.runtimeStyle.left = rsLeft;
+ }
+ }
+
+ return ret;
+ },
+
+ // A method for quickly swapping in/out CSS properties to get correct calculations
+ swap: function( elem, options, callback ) {
+ var old = {};
+
+ // Remember the old values, and insert the new ones
+ for ( var name in options ) {
+ old[ name ] = elem.style[ name ];
+ elem.style[ name ] = options[ name ];
+ }
+
+ callback.call( elem );
+
+ // Revert the old values
+ for ( var name in options ) {
+ elem.style[ name ] = old[ name ];
+ }
+ }
+});
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.hidden = function( elem ) {
+ var width = elem.offsetWidth, height = elem.offsetHeight,
+ skip = elem.nodeName.toLowerCase() === "tr";
+
+ return width === 0 && height === 0 && !skip ?
+ true :
+ width > 0 && height > 0 && !skip ?
+ false :
+ jQuery.curCSS(elem, "display") === "none";
+ };
+
+ jQuery.expr.filters.visible = function( elem ) {
+ return !jQuery.expr.filters.hidden( elem );
+ };
+}
+var jsc = now(),
+ rscript = /<script(.|\s)*?\/script>/gi,
+ rselectTextarea = /select|textarea/i,
+ rinput = /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,
+ jsre = /=\?(&|$)/,
+ rquery = /\?/,
+ rts = /(\?|&)_=.*?(&|$)/,
+ rurl = /^(\w+:)?\/\/([^\/?#]+)/,
+ r20 = /%20/g;
+
+jQuery.fn.extend({
+ // Keep a copy of the old load
+ _load: jQuery.fn.load,
+
+ load: function( url, params, callback ) {
+ if ( typeof url !== "string" ) {
+ return this._load( url );
+
+ // Don't do a request if no elements are being requested
+ } else if ( !this.length ) {
+ return this;
+ }
+
+ var off = url.indexOf(" ");
+ if ( off >= 0 ) {
+ var selector = url.slice(off, url.length);
+ url = url.slice(0, off);
+ }
+
+ // Default to a GET request
+ var type = "GET";
+
+ // If the second parameter was provided
+ if ( params ) {
+ // If it's a function
+ if ( jQuery.isFunction( params ) ) {
+ // We assume that it's the callback
+ callback = params;
+ params = null;
+
+ // Otherwise, build a param string
+ } else if ( typeof params === "object" ) {
+ params = jQuery.param( params, jQuery.ajaxSettings.traditional );
+ type = "POST";
+ }
+ }
+
+ // Request the remote document
+ jQuery.ajax({
+ url: url,
+ type: type,
+ dataType: "html",
+ data: params,
+ context:this,
+ complete: function( res, status ) {
+ // If successful, inject the HTML into all the matched elements
+ if ( status === "success" || status === "notmodified" ) {
+ // See if a selector was specified
+ this.html( selector ?
+ // Create a dummy div to hold the results
+ jQuery("<div />")
+ // inject the contents of the document in, removing the scripts
+ // to avoid any 'Permission Denied' errors in IE
+ .append(res.responseText.replace(rscript, ""))
+
+ // Locate the specified elements
+ .find(selector) :
+
+ // If not, just inject the full result
+ res.responseText );
+ }
+
+ if ( callback ) {
+ this.each( callback, [res.responseText, status, res] );
+ }
+ }
+ });
+
+ return this;
+ },
+
+ serialize: function() {
+ return jQuery.param(this.serializeArray());
+ },
+ serializeArray: function() {
+ return this.map(function() {
+ return this.elements ? jQuery.makeArray(this.elements) : this;
+ })
+ .filter(function() {
+ return this.name && !this.disabled &&
+ (this.checked || rselectTextarea.test(this.nodeName) ||
+ rinput.test(this.type));
+ })
+ .map(function( i, elem ) {
+ var val = jQuery(this).val();
+
+ return val == null ?
+ null :
+ jQuery.isArray(val) ?
+ jQuery.map( val, function( val, i ) {
+ return { name: elem.name, value: val };
+ }) :
+ { name: elem.name, value: val };
+ }).get();
+ }
+});
+
+// Attach a bunch of functions for handling common AJAX events
+jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function( i, o ) {
+ jQuery.fn[o] = function( f ) {
+ return this.bind(o, f);
+ };
+});
+
+jQuery.extend({
+
+ get: function( url, data, callback, type ) {
+ // shift arguments if data argument was omited
+ if ( jQuery.isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = null;
+ }
+
+ return jQuery.ajax({
+ type: "GET",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ getScript: function( url, callback ) {
+ return jQuery.get(url, null, callback, "script");
+ },
+
+ getJSON: function( url, data, callback ) {
+ return jQuery.get(url, data, callback, "json");
+ },
+
+ post: function( url, data, callback, type ) {
+ // shift arguments if data argument was omited
+ if ( jQuery.isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = {};
+ }
+
+ return jQuery.ajax({
+ type: "POST",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ ajaxSetup: function( settings ) {
+ jQuery.extend( jQuery.ajaxSettings, settings );
+ },
+
+ ajaxSettings: {
+ url: location.href,
+ global: true,
+ type: "GET",
+ contentType: "application/x-www-form-urlencoded",
+ processData: true,
+ async: true,
+ /*
+ timeout: 0,
+ data: null,
+ username: null,
+ password: null,
+ traditional: false,
+ */
+ // Create the request object; Microsoft failed to properly
+ // implement the XMLHttpRequest in IE7 (can't request local files),
+ // so we use the ActiveXObject when it is available
+ // This function can be overriden by calling jQuery.ajaxSetup
+ xhr: window.XMLHttpRequest && (window.location.protocol !== "file:" || !window.ActiveXObject) ?
+ function() {
+ return new window.XMLHttpRequest();
+ } :
+ function() {
+ try {
+ return new window.ActiveXObject("Microsoft.XMLHTTP");
+ } catch(e) {}
+ },
+ accepts: {
+ xml: "application/xml, text/xml",
+ html: "text/html",
+ script: "text/javascript, application/javascript",
+ json: "application/json, text/javascript",
+ text: "text/plain",
+ _default: "*/*"
+ }
+ },
+
+ // Last-Modified header cache for next request
+ lastModified: {},
+ etag: {},
+
+ ajax: function( origSettings ) {
+ var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings);
+
+ var jsonp, status, data,
+ callbackContext = s.context || s,
+ type = s.type.toUpperCase();
+
+ // convert data if not already a string
+ if ( s.data && s.processData && typeof s.data !== "string" ) {
+ s.data = jQuery.param( s.data, s.traditional );
+ }
+
+ // Handle JSONP Parameter Callbacks
+ if ( s.dataType === "jsonp" ) {
+ if ( type === "GET" ) {
+ if ( !jsre.test( s.url ) ) {
+ s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?";
+ }
+ } else if ( !s.data || !jsre.test(s.data) ) {
+ s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
+ }
+ s.dataType = "json";
+ }
+
+ // Build temporary JSONP function
+ if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) {
+ jsonp = s.jsonpCallback || ("jsonp" + jsc++);
+
+ // Replace the =? sequence both in the query string and the data
+ if ( s.data ) {
+ s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
+ }
+
+ s.url = s.url.replace(jsre, "=" + jsonp + "$1");
+
+ // We need to make sure
+ // that a JSONP style response is executed properly
+ s.dataType = "script";
+
+ // Handle JSONP-style loading
+ window[ jsonp ] = window[ jsonp ] || function( tmp ) {
+ data = tmp;
+ success();
+ complete();
+ // Garbage collect
+ window[ jsonp ] = undefined;
+
+ try {
+ delete window[ jsonp ];
+ } catch(e) {}
+
+ if ( head ) {
+ head.removeChild( script );
+ }
+ };
+ }
+
+ if ( s.dataType === "script" && s.cache === null ) {
+ s.cache = false;
+ }
+
+ if ( s.cache === false && type === "GET" ) {
+ var ts = now();
+
+ // try replacing _= if it is there
+ var ret = s.url.replace(rts, "$1_=" + ts + "$2");
+
+ // if nothing was replaced, add timestamp to the end
+ s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : "");
+ }
+
+ // If data is available, append data to url for get requests
+ if ( s.data && type === "GET" ) {
+ s.url += (rquery.test(s.url) ? "&" : "?") + s.data;
+ }
+
+ // Watch for a new set of requests
+ if ( s.global && ! jQuery.active++ ) {
+ jQuery.event.trigger( "ajaxStart" );
+ }
+
+ // Matches an absolute URL, and saves the domain
+ var parts = rurl.exec( s.url ),
+ remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host);
+
+ // If we're requesting a remote document
+ // and trying to load JSON or Script with a GET
+ if ( s.dataType === "script" && type === "GET" && remote ) {
+ var head = document.getElementsByTagName("head")[0] || document.documentElement;
+ var script = document.createElement("script");
+ script.src = s.url;
+ if ( s.scriptCharset ) {
+ script.charset = s.scriptCharset;
+ }
+
+ // Handle Script loading
+ if ( !jsonp ) {
+ var done = false;
+
+ // Attach handlers for all browsers
+ script.onload = script.onreadystatechange = function() {
+ if ( !done && (!this.readyState ||
+ this.readyState === "loaded" || this.readyState === "complete") ) {
+ done = true;
+ success();
+ complete();
+
+ // Handle memory leak in IE
+ script.onload = script.onreadystatechange = null;
+ if ( head && script.parentNode ) {
+ head.removeChild( script );
+ }
+ }
+ };
+ }
+
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709 and #4378).
+ head.insertBefore( script, head.firstChild );
+
+ // We handle everything using the script element injection
+ return undefined;
+ }
+
+ var requestDone = false;
+
+ // Create the request object
+ var xhr = s.xhr();
+
+ if ( !xhr ) {
+ return;
+ }
+
+ // Open the socket
+ // Passing null username, generates a login popup on Opera (#2865)
+ if ( s.username ) {
+ xhr.open(type, s.url, s.async, s.username, s.password);
+ } else {
+ xhr.open(type, s.url, s.async);
+ }
+
+ // Need an extra try/catch for cross domain requests in Firefox 3
+ try {
+ // Set the correct header, if data is being sent
+ if ( s.data || origSettings && origSettings.contentType ) {
+ xhr.setRequestHeader("Content-Type", s.contentType);
+ }
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if ( s.ifModified ) {
+ if ( jQuery.lastModified[s.url] ) {
+ xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]);
+ }
+
+ if ( jQuery.etag[s.url] ) {
+ xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]);
+ }
+ }
+
+ // Set header so the called script knows that it's an XMLHttpRequest
+ // Only send the header if it's not a remote XHR
+ if ( !remote ) {
+ xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+ }
+
+ // Set the Accepts header for the server, depending on the dataType
+ xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ?
+ s.accepts[ s.dataType ] + ", */*" :
+ s.accepts._default );
+ } catch(e) {}
+
+ // Allow custom headers/mimetypes and early abort
+ if ( s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false ) {
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active ) {
+ jQuery.event.trigger( "ajaxStop" );
+ }
+
+ // close opended socket
+ xhr.abort();
+ return false;
+ }
+
+ if ( s.global ) {
+ trigger("ajaxSend", [xhr, s]);
+ }
+
+ // Wait for a response to come back
+ var onreadystatechange = xhr.onreadystatechange = function( isTimeout ) {
+ // The request was aborted
+ if ( !xhr || xhr.readyState === 0 ) {
+ // Opera doesn't call onreadystatechange before this point
+ // so we simulate the call
+ if ( !requestDone ) {
+ complete();
+ }
+
+ requestDone = true;
+ if ( xhr ) {
+ xhr.onreadystatechange = jQuery.noop;
+ }
+
+ // The transfer is complete and the data is available, or the request timed out
+ } else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) {
+ requestDone = true;
+ xhr.onreadystatechange = jQuery.noop;
+
+ status = isTimeout === "timeout" ?
+ "timeout" :
+ !jQuery.httpSuccess( xhr ) ?
+ "error" :
+ s.ifModified && jQuery.httpNotModified( xhr, s.url ) ?
+ "notmodified" :
+ "success";
+
+ if ( status === "success" ) {
+ // Watch for, and catch, XML document parse errors
+ try {
+ // process the data (runs the xml through httpData regardless of callback)
+ data = jQuery.httpData( xhr, s.dataType, s );
+ } catch(e) {
+ status = "parsererror";
+ }
+ }
+
+ // Make sure that the request was successful or notmodified
+ if ( status === "success" || status === "notmodified" ) {
+ // JSONP handles its own success callback
+ if ( !jsonp ) {
+ success();
+ }
+ } else {
+ jQuery.handleError(s, xhr, status);
+ }
+
+ // Fire the complete handlers
+ complete();
+
+ if ( isTimeout === "timeout" ) {
+ xhr.abort();
+ }
+
+ // Stop memory leaks
+ if ( s.async ) {
+ xhr = null;
+ }
+ }
+ };
+
+ // Override the abort handler, if we can (IE doesn't allow it, but that's OK)
+ // Opera doesn't fire onreadystatechange at all on abort
+ try {
+ var oldAbort = xhr.abort;
+ xhr.abort = function() {
+ if ( xhr ) {
+ oldAbort.call( xhr );
+ if ( xhr ) {
+ xhr.readyState = 0;
+ }
+ }
+
+ onreadystatechange();
+ };
+ } catch(e) { }
+
+ // Timeout checker
+ if ( s.async && s.timeout > 0 ) {
+ setTimeout(function() {
+ // Check to see if the request is still happening
+ if ( xhr && !requestDone ) {
+ onreadystatechange( "timeout" );
+ }
+ }, s.timeout);
+ }
+
+ // Send the data
+ try {
+ xhr.send( type === "POST" || type === "PUT" || type === "DELETE" ? s.data : null );
+ } catch(e) {
+ jQuery.handleError(s, xhr, null, e);
+ // Fire the complete handlers
+ complete();
+ }
+
+ // firefox 1.5 doesn't fire statechange for sync requests
+ if ( !s.async ) {
+ onreadystatechange();
+ }
+
+ function success() {
+ // If a local callback was specified, fire it and pass it the data
+ if ( s.success ) {
+ s.success.call( callbackContext, data, status, xhr );
+ }
+
+ // Fire the global callback
+ if ( s.global ) {
+ trigger( "ajaxSuccess", [xhr, s] );
+ }
+ }
+
+ function complete() {
+ // Process result
+ if ( s.complete ) {
+ s.complete.call( callbackContext, xhr, status);
+ }
+
+ // The request was completed
+ if ( s.global ) {
+ trigger( "ajaxComplete", [xhr, s] );
+ }
+
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active ) {
+ jQuery.event.trigger( "ajaxStop" );
+ }
+ }
+
+ function trigger(type, args) {
+ (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args);
+ }
+
+ // return XMLHttpRequest to allow aborting the request etc.
+ return xhr;
+ },
+
+ handleError: function( s, xhr, status, e ) {
+ // If a local callback was specified, fire it
+ if ( s.error ) {
+ s.error.call( s.context || window, xhr, status, e );
+ }
+
+ // Fire the global callback
+ if ( s.global ) {
+ (s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] );
+ }
+ },
+
+ // Counter for holding the number of active queries
+ active: 0,
+
+ // Determines if an XMLHttpRequest was successful or not
+ httpSuccess: function( xhr ) {
+ try {
+ // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
+ return !xhr.status && location.protocol === "file:" ||
+ // Opera returns 0 when status is 304
+ ( xhr.status >= 200 && xhr.status < 300 ) ||
+ xhr.status === 304 || xhr.status === 1223 || xhr.status === 0;
+ } catch(e) {}
+
+ return false;
+ },
+
+ // Determines if an XMLHttpRequest returns NotModified
+ httpNotModified: function( xhr, url ) {
+ var lastModified = xhr.getResponseHeader("Last-Modified"),
+ etag = xhr.getResponseHeader("Etag");
+
+ if ( lastModified ) {
+ jQuery.lastModified[url] = lastModified;
+ }
+
+ if ( etag ) {
+ jQuery.etag[url] = etag;
+ }
+
+ // Opera returns 0 when status is 304
+ return xhr.status === 304 || xhr.status === 0;
+ },
+
+ httpData: function( xhr, type, s ) {
+ var ct = xhr.getResponseHeader("content-type") || "",
+ xml = type === "xml" || !type && ct.indexOf("xml") >= 0,
+ data = xml ? xhr.responseXML : xhr.responseText;
+
+ if ( xml && data.documentElement.nodeName === "parsererror" ) {
+ throw "parsererror";
+ }
+
+ // Allow a pre-filtering function to sanitize the response
+ // s is checked to keep backwards compatibility
+ if ( s && s.dataFilter ) {
+ data = s.dataFilter( data, type );
+ }
+
+ // The filter can actually parse the response
+ if ( typeof data === "string" ) {
+ // Get the JavaScript object, if JSON is used.
+ if ( type === "json" || !type && ct.indexOf("json") >= 0 ) {
+ // Make sure the incoming data is actual JSON
+ // Logic borrowed from http://json.org/json2.js
+ if (/^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]")
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ""))) {
+
+ // Try to use the native JSON parser first
+ if ( window.JSON && window.JSON.parse ) {
+ data = window.JSON.parse( data );
+
+ } else {
+ data = (new Function("return " + data))();
+ }
+
+ } else {
+ throw "Invalid JSON: " + data;
+ }
+
+ // If the type is "script", eval it in global context
+ } else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) {
+ jQuery.globalEval( data );
+ }
+ }
+
+ return data;
+ },
+
+ // Serialize an array of form elements or a set of
+ // key/values into a query string
+ param: function( a, traditional ) {
+
+ var s = [];
+
+ // Set traditional to true for jQuery <= 1.3.2 behavior.
+ if ( traditional === undefined ) {
+ traditional = jQuery.ajaxSettings.traditional;
+ }
+
+ function add( key, value ) {
+ // If value is a function, invoke it and return its value
+ value = jQuery.isFunction(value) ? value() : value;
+ s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
+ }
+
+ // If an array was passed in, assume that it is an array of form elements.
+ if ( jQuery.isArray(a) || a.jquery ) {
+ // Serialize the form elements
+ jQuery.each( a, function() {
+ add( this.name, this.value );
+ });
+
+ } else {
+ // If traditional, encode the "old" way (the way 1.3.2 or older
+ // did it), otherwise encode params recursively.
+ jQuery.each( a, function buildParams( prefix, obj ) {
+
+ if ( jQuery.isArray(obj) ) {
+ // Serialize array item.
+ jQuery.each( obj, function( i, v ) {
+ if ( traditional ) {
+ // Treat each array item as a scalar.
+ add( prefix, v );
+ } else {
+ // If array item is non-scalar (array or object), encode its
+ // numeric index to resolve deserialization ambiguity issues.
+ // Note that rack (as of 1.0.0) can't currently deserialize
+ // nested arrays properly, and attempting to do so may cause
+ // a server error. Possible fixes are to modify rack's
+ // deserialization algorithm or to provide an option or flag
+ // to force array serialization to be shallow.
+ buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v );
+ }
+ });
+
+ } else if ( !traditional && obj != null && typeof obj === "object" ) {
+ // Serialize object item.
+ jQuery.each( obj, function( k, v ) {
+ buildParams( prefix + "[" + k + "]", v );
+ });
+
+ } else {
+ // Serialize scalar item.
+ add( prefix, obj );
+ }
+ });
+ }
+
+ // Return the resulting serialization
+ return s.join("&").replace(r20, "+");
+ }
+
+});
+var elemdisplay = {},
+ rfxtypes = /toggle|show|hide/,
+ rfxnum = /^([+-]=)?([\d+-.]+)(.*)$/,
+ timerId,
+ fxAttrs = [
+ // height animations
+ [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
+ // width animations
+ [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
+ // opacity animations
+ [ "opacity" ]
+ ];
+
+jQuery.fn.extend({
+ show: function( speed, callback ) {
+ if ( speed != null ) {
+ return this.animate( genFx("show", 3), speed, callback);
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var old = jQuery.data(this[i], "olddisplay");
+
+ this[i].style.display = old || "";
+
+ if ( jQuery.css(this[i], "display") === "none" ) {
+ var nodeName = this[i].nodeName, display;
+
+ if ( elemdisplay[ nodeName ] ) {
+ display = elemdisplay[ nodeName ];
+
+ } else {
+ var elem = jQuery("<" + nodeName + " />").appendTo("body");
+
+ display = elem.css("display");
+
+ if ( display === "none" ) {
+ display = "block";
+ }
+
+ elem.remove();
+
+ elemdisplay[ nodeName ] = display;
+ }
+
+ jQuery.data(this[i], "olddisplay", display);
+ }
+ }
+
+ // Set the display of the elements in a second loop
+ // to avoid the constant reflow
+ for ( var j = 0, k = this.length; j < k; j++ ) {
+ this[j].style.display = jQuery.data(this[j], "olddisplay") || "";
+ }
+
+ return this;
+ }
+ },
+
+ hide: function( speed, callback ) {
+ if ( speed != null ) {
+ return this.animate( genFx("hide", 3), speed, callback);
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var old = jQuery.data(this[i], "olddisplay");
+ if ( !old && old !== "none" ) {
+ jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display"));
+ }
+ }
+
+ // Set the display of the elements in a second loop
+ // to avoid the constant reflow
+ for ( var j = 0, k = this.length; j < k; j++ ) {
+ this[j].style.display = "none";
+ }
+
+ return this;
+ }
+ },
+
+ // Save the old toggle function
+ _toggle: jQuery.fn.toggle,
+
+ toggle: function( fn, fn2 ) {
+ var bool = typeof fn === "boolean";
+
+ if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
+ this._toggle.apply( this, arguments );
+
+ } else if ( fn == null || bool ) {
+ this.each(function() {
+ var state = bool ? fn : jQuery(this).is(":hidden");
+ jQuery(this)[ state ? "show" : "hide" ]();
+ });
+
+ } else {
+ this.animate(genFx("toggle", 3), fn, fn2);
+ }
+
+ return this;
+ },
+
+ fadeTo: function( speed, to, callback ) {
+ return this.filter(":hidden").css("opacity", 0).show().end()
+ .animate({opacity: to}, speed, callback);
+ },
+
+ animate: function( prop, speed, easing, callback ) {
+ var optall = jQuery.speed(speed, easing, callback);
+
+ if ( jQuery.isEmptyObject( prop ) ) {
+ return this.each( optall.complete );
+ }
+
+ return this[ optall.queue === false ? "each" : "queue" ](function() {
+ var opt = jQuery.extend({}, optall), p,
+ hidden = this.nodeType === 1 && jQuery(this).is(":hidden"),
+ self = this;
+
+ for ( p in prop ) {
+ var name = p.replace(rdashAlpha, fcamelCase);
+
+ if ( p !== name ) {
+ prop[ name ] = prop[ p ];
+ delete prop[ p ];
+ p = name;
+ }
+
+ if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
+ return opt.complete.call(this);
+ }
+
+ if ( ( p === "height" || p === "width" ) && this.style ) {
+ // Store display property
+ opt.display = jQuery.css(this, "display");
+
+ // Make sure that nothing sneaks out
+ opt.overflow = this.style.overflow;
+ }
+
+ if ( jQuery.isArray( prop[p] ) ) {
+ // Create (if needed) and add to specialEasing
+ (opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1];
+ prop[p] = prop[p][0];
+ }
+ }
+
+ if ( opt.overflow != null ) {
+ this.style.overflow = "hidden";
+ }
+
+ opt.curAnim = jQuery.extend({}, prop);
+
+ jQuery.each( prop, function( name, val ) {
+ var e = new jQuery.fx( self, opt, name );
+
+ if ( rfxtypes.test(val) ) {
+ e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop );
+
+ } else {
+ var parts = rfxnum.exec(val),
+ start = e.cur(true) || 0;
+
+ if ( parts ) {
+ var end = parseFloat( parts[2] ),
+ unit = parts[3] || "px";
+
+ // We need to compute starting value
+ if ( unit !== "px" ) {
+ self.style[ name ] = (end || 1) + unit;
+ start = ((end || 1) / e.cur(true)) * start;
+ self.style[ name ] = start + unit;
+ }
+
+ // If a +=/-= token was provided, we're doing a relative animation
+ if ( parts[1] ) {
+ end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
+ }
+
+ e.custom( start, end, unit );
+
+ } else {
+ e.custom( start, val, "" );
+ }
+ }
+ });
+
+ // For JS strict compliance
+ return true;
+ });
+ },
+
+ stop: function( clearQueue, gotoEnd ) {
+ var timers = jQuery.timers;
+
+ if ( clearQueue ) {
+ this.queue([]);
+ }
+
+ this.each(function() {
+ // go in reverse order so anything added to the queue during the loop is ignored
+ for ( var i = timers.length - 1; i >= 0; i-- ) {
+ if ( timers[i].elem === this ) {
+ if (gotoEnd) {
+ // force the next step to be the last
+ timers[i](true);
+ }
+
+ timers.splice(i, 1);
+ }
+ }
+ });
+
+ // start the next in the queue if the last step wasn't forced
+ if ( !gotoEnd ) {
+ this.dequeue();
+ }
+
+ return this;
+ }
+
+});
+
+// Generate shortcuts for custom animations
+jQuery.each({
+ slideDown: genFx("show", 1),
+ slideUp: genFx("hide", 1),
+ slideToggle: genFx("toggle", 1),
+ fadeIn: { opacity: "show" },
+ fadeOut: { opacity: "hide" }
+}, function( name, props ) {
+ jQuery.fn[ name ] = function( speed, callback ) {
+ return this.animate( props, speed, callback );
+ };
+});
+
+jQuery.extend({
+ speed: function( speed, easing, fn ) {
+ var opt = speed && typeof speed === "object" ? speed : {
+ complete: fn || !fn && easing ||
+ jQuery.isFunction( speed ) && speed,
+ duration: speed,
+ easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
+ };
+
+ opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
+ jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default;
+
+ // Queueing
+ opt.old = opt.complete;
+ opt.complete = function() {
+ if ( opt.queue !== false ) {
+ jQuery(this).dequeue();
+ }
+ if ( jQuery.isFunction( opt.old ) ) {
+ opt.old.call( this );
+ }
+ };
+
+ return opt;
+ },
+
+ easing: {
+ linear: function( p, n, firstNum, diff ) {
+ return firstNum + diff * p;
+ },
+ swing: function( p, n, firstNum, diff ) {
+ return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
+ }
+ },
+
+ timers: [],
+
+ fx: function( elem, options, prop ) {
+ this.options = options;
+ this.elem = elem;
+ this.prop = prop;
+
+ if ( !options.orig ) {
+ options.orig = {};
+ }
+ }
+
+});
+
+jQuery.fx.prototype = {
+ // Simple function for setting a style value
+ update: function() {
+ if ( this.options.step ) {
+ this.options.step.call( this.elem, this.now, this );
+ }
+
+ (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
+
+ // Set display property to block for height/width animations
+ if ( ( this.prop === "height" || this.prop === "width" ) && this.elem.style ) {
+ this.elem.style.display = "block";
+ }
+ },
+
+ // Get the current size
+ cur: function( force ) {
+ if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
+ return this.elem[ this.prop ];
+ }
+
+ var r = parseFloat(jQuery.css(this.elem, this.prop, force));
+ return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
+ },
+
+ // Start an animation from one number to another
+ custom: function( from, to, unit ) {
+ this.startTime = now();
+ this.start = from;
+ this.end = to;
+ this.unit = unit || this.unit || "px";
+ this.now = this.start;
+ this.pos = this.state = 0;
+
+ var self = this;
+ function t( gotoEnd ) {
+ return self.step(gotoEnd);
+ }
+
+ t.elem = this.elem;
+
+ if ( t() && jQuery.timers.push(t) && !timerId ) {
+ timerId = setInterval(jQuery.fx.tick, 13);
+ }
+ },
+
+ // Simple 'show' function
+ show: function() {
+ // Remember where we started, so that we can go back to it later
+ this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
+ this.options.show = true;
+
+ // Begin the animation
+ // Make sure that we start at a small width/height to avoid any
+ // flash of content
+ this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
+
+ // Start by showing the element
+ jQuery( this.elem ).show();
+ },
+
+ // Simple 'hide' function
+ hide: function() {
+ // Remember where we started, so that we can go back to it later
+ this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
+ this.options.hide = true;
+
+ // Begin the animation
+ this.custom(this.cur(), 0);
+ },
+
+ // Each step of an animation
+ step: function( gotoEnd ) {
+ var t = now(), done = true;
+
+ if ( gotoEnd || t >= this.options.duration + this.startTime ) {
+ this.now = this.end;
+ this.pos = this.state = 1;
+ this.update();
+
+ this.options.curAnim[ this.prop ] = true;
+
+ for ( var i in this.options.curAnim ) {
+ if ( this.options.curAnim[i] !== true ) {
+ done = false;
+ }
+ }
+
+ if ( done ) {
+ if ( this.options.display != null ) {
+ // Reset the overflow
+ this.elem.style.overflow = this.options.overflow;
+
+ // Reset the display
+ var old = jQuery.data(this.elem, "olddisplay");
+ this.elem.style.display = old ? old : this.options.display;
+
+ if ( jQuery.css(this.elem, "display") === "none" ) {
+ this.elem.style.display = "block";
+ }
+ }
+
+ // Hide the element if the "hide" operation was done
+ if ( this.options.hide ) {
+ jQuery(this.elem).hide();
+ }
+
+ // Reset the properties, if the item has been hidden or shown
+ if ( this.options.hide || this.options.show ) {
+ for ( var p in this.options.curAnim ) {
+ jQuery.style(this.elem, p, this.options.orig[p]);
+ }
+ }
+
+ // Execute the complete function
+ this.options.complete.call( this.elem );
+ }
+
+ return false;
+
+ } else {
+ var n = t - this.startTime;
+ this.state = n / this.options.duration;
+
+ // Perform the easing function, defaults to swing
+ var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop];
+ var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear");
+ this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration);
+ this.now = this.start + ((this.end - this.start) * this.pos);
+
+ // Perform the next step of the animation
+ this.update();
+ }
+
+ return true;
+ }
+};
+
+jQuery.extend( jQuery.fx, {
+ tick: function() {
+ var timers = jQuery.timers;
+
+ for ( var i = 0; i < timers.length; i++ ) {
+ if ( !timers[i]() ) {
+ timers.splice(i--, 1);
+ }
+ }
+
+ if ( !timers.length ) {
+ jQuery.fx.stop();
+ }
+ },
+
+ stop: function() {
+ clearInterval( timerId );
+ timerId = null;
+ },
+
+ speeds: {
+ slow: 600,
+ fast: 200,
+ // Default speed
+ _default: 400
+ },
+
+ step: {
+ opacity: function( fx ) {
+ jQuery.style(fx.elem, "opacity", fx.now);
+ },
+
+ _default: function( fx ) {
+ if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
+ fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
+ } else {
+ fx.elem[ fx.prop ] = fx.now;
+ }
+ }
+ }
+});
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.animated = function( elem ) {
+ return jQuery.grep(jQuery.timers, function( fn ) {
+ return elem === fn.elem;
+ }).length;
+ };
+}
+
+function genFx( type, num ) {
+ var obj = {};
+
+ jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
+ obj[ this ] = type;
+ });
+
+ return obj;
+}
+if ( "getBoundingClientRect" in document.documentElement ) {
+ jQuery.fn.offset = function( options ) {
+ var elem = this[0];
+
+ if ( !elem || !elem.ownerDocument ) {
+ return null;
+ }
+
+ if ( options ) {
+ return this.each(function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ });
+ }
+
+ if ( elem === elem.ownerDocument.body ) {
+ return jQuery.offset.bodyOffset( elem );
+ }
+
+ var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement,
+ clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
+ top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop,
+ left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft;
+
+ return { top: top, left: left };
+ };
+
+} else {
+ jQuery.fn.offset = function( options ) {
+ var elem = this[0];
+
+ if ( !elem || !elem.ownerDocument ) {
+ return null;
+ }
+
+ if ( options ) {
+ return this.each(function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ });
+ }
+
+ if ( elem === elem.ownerDocument.body ) {
+ return jQuery.offset.bodyOffset( elem );
+ }
+
+ jQuery.offset.initialize();
+
+ var offsetParent = elem.offsetParent, prevOffsetParent = elem,
+ doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement,
+ body = doc.body, defaultView = doc.defaultView,
+ prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
+ top = elem.offsetTop, left = elem.offsetLeft;
+
+ while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
+ if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
+ break;
+ }
+
+ computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
+ top -= elem.scrollTop;
+ left -= elem.scrollLeft;
+
+ if ( elem === offsetParent ) {
+ top += elem.offsetTop;
+ left += elem.offsetLeft;
+
+ if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.nodeName)) ) {
+ top += parseFloat( computedStyle.borderTopWidth ) || 0;
+ left += parseFloat( computedStyle.borderLeftWidth ) || 0;
+ }
+
+ prevOffsetParent = offsetParent, offsetParent = elem.offsetParent;
+ }
+
+ if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
+ top += parseFloat( computedStyle.borderTopWidth ) || 0;
+ left += parseFloat( computedStyle.borderLeftWidth ) || 0;
+ }
+
+ prevComputedStyle = computedStyle;
+ }
+
+ if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
+ top += body.offsetTop;
+ left += body.offsetLeft;
+ }
+
+ if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
+ top += Math.max( docElem.scrollTop, body.scrollTop );
+ left += Math.max( docElem.scrollLeft, body.scrollLeft );
+ }
+
+ return { top: top, left: left };
+ };
+}
+
+jQuery.offset = {
+ initialize: function() {
+ var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0,
+ html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
+
+ jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
+
+ container.innerHTML = html;
+ body.insertBefore( container, body.firstChild );
+ innerDiv = container.firstChild;
+ checkDiv = innerDiv.firstChild;
+ td = innerDiv.nextSibling.firstChild.firstChild;
+
+ this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
+ this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
+
+ checkDiv.style.position = "fixed", checkDiv.style.top = "20px";
+ // safari subtracts parent border width here which is 5px
+ this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
+ checkDiv.style.position = checkDiv.style.top = "";
+
+ innerDiv.style.overflow = "hidden", innerDiv.style.position = "relative";
+ this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
+
+ this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
+
+ body.removeChild( container );
+ body = container = innerDiv = checkDiv = table = td = null;
+ jQuery.offset.initialize = jQuery.noop;
+ },
+
+ bodyOffset: function( body ) {
+ var top = body.offsetTop, left = body.offsetLeft;
+
+ jQuery.offset.initialize();
+
+ if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
+ top += parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0;
+ left += parseFloat( jQuery.curCSS(body, "marginLeft", true) ) || 0;
+ }
+
+ return { top: top, left: left };
+ },
+
+ setOffset: function( elem, options, i ) {
+ // set position first, in-case top/left are set even on static elem
+ if ( /static/.test( jQuery.curCSS( elem, "position" ) ) ) {
+ elem.style.position = "relative";
+ }
+ var curElem = jQuery( elem ),
+ curOffset = curElem.offset(),
+ curTop = parseInt( jQuery.curCSS( elem, "top", true ), 10 ) || 0,
+ curLeft = parseInt( jQuery.curCSS( elem, "left", true ), 10 ) || 0;
+
+ if ( jQuery.isFunction( options ) ) {
+ options = options.call( elem, i, curOffset );
+ }
+
+ var props = {
+ top: (options.top - curOffset.top) + curTop,
+ left: (options.left - curOffset.left) + curLeft
+ };
+
+ if ( "using" in options ) {
+ options.using.call( elem, props );
+ } else {
+ curElem.css( props );
+ }
+ }
+};
+
+
+jQuery.fn.extend({
+ position: function() {
+ if ( !this[0] ) {
+ return null;
+ }
+
+ var elem = this[0],
+
+ // Get *real* offsetParent
+ offsetParent = this.offsetParent(),
+
+ // Get correct offsets
+ offset = this.offset(),
+ parentOffset = /^body|html$/i.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
+
+ // Subtract element margins
+ // note: when an element has margin: auto the offsetLeft and marginLeft
+ // are the same in Safari causing offset.left to incorrectly be 0
+ offset.top -= parseFloat( jQuery.curCSS(elem, "marginTop", true) ) || 0;
+ offset.left -= parseFloat( jQuery.curCSS(elem, "marginLeft", true) ) || 0;
+
+ // Add offsetParent borders
+ parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], "borderTopWidth", true) ) || 0;
+ parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], "borderLeftWidth", true) ) || 0;
+
+ // Subtract the two offsets
+ return {
+ top: offset.top - parentOffset.top,
+ left: offset.left - parentOffset.left
+ };
+ },
+
+ offsetParent: function() {
+ return this.map(function() {
+ var offsetParent = this.offsetParent || document.body;
+ while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
+ offsetParent = offsetParent.offsetParent;
+ }
+ return offsetParent;
+ });
+ }
+});
+
+
+// Create scrollLeft and scrollTop methods
+jQuery.each( ["Left", "Top"], function( i, name ) {
+ var method = "scroll" + name;
+
+ jQuery.fn[ method ] = function(val) {
+ var elem = this[0], win;
+
+ if ( !elem ) {
+ return null;
+ }
+
+ if ( val !== undefined ) {
+ // Set the scroll offset
+ return this.each(function() {
+ win = getWindow( this );
+
+ if ( win ) {
+ win.scrollTo(
+ !i ? val : jQuery(win).scrollLeft(),
+ i ? val : jQuery(win).scrollTop()
+ );
+
+ } else {
+ this[ method ] = val;
+ }
+ });
+ } else {
+ win = getWindow( elem );
+
+ // Return the scroll offset
+ return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
+ jQuery.support.boxModel && win.document.documentElement[ method ] ||
+ win.document.body[ method ] :
+ elem[ method ];
+ }
+ };
+});
+
+function getWindow( elem ) {
+ return ("scrollTo" in elem && elem.document) ?
+ elem :
+ elem.nodeType === 9 ?
+ elem.defaultView || elem.parentWindow :
+ false;
+}
+// Create innerHeight, innerWidth, outerHeight and outerWidth methods
+jQuery.each([ "Height", "Width" ], function( i, name ) {
+
+ var type = name.toLowerCase();
+
+ // innerHeight and innerWidth
+ jQuery.fn["inner" + name] = function() {
+ return this[0] ?
+ jQuery.css( this[0], type, false, "padding" ) :
+ null;
+ };
+
+ // outerHeight and outerWidth
+ jQuery.fn["outer" + name] = function( margin ) {
+ return this[0] ?
+ jQuery.css( this[0], type, false, margin ? "margin" : "border" ) :
+ null;
+ };
+
+ jQuery.fn[ type ] = function( size ) {
+ // Get window width or height
+ var elem = this[0];
+ if ( !elem ) {
+ return size == null ? null : this;
+ }
+
+ return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window?
+ // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
+ elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
+ elem.document.body[ "client" + name ] :
+
+ // Get document width or height
+ (elem.nodeType === 9) ? // is it a document
+ // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
+ Math.max(
+ elem.documentElement["client" + name],
+ elem.body["scroll" + name], elem.documentElement["scroll" + name],
+ elem.body["offset" + name], elem.documentElement["offset" + name]
+ ) :
+
+ // Get or set width or height on the element
+ size === undefined ?
+ // Get width or height on the element
+ jQuery.css( elem, type ) :
+
+ // Set the width or height on the element (default to pixels if value is unitless)
+ this.css( type, typeof size === "string" ? size : size + "px" );
+ };
+
+});
+// Expose jQuery to the global object
+window.jQuery = window.$ = jQuery;
+
+})(window);
diff --git a/examples/lessons/6_English_whatsThisLetter/js/jquery.watermarkinput.js b/examples/lessons/6_English_whatsThisLetter/js/jquery.watermarkinput.js
new file mode 100755
index 0000000..fefa670
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/js/jquery.watermarkinput.js
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2007 Josh Bush (digitalbush.com)
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Version: Beta 1
+ * Release: 2007-06-01
+ */
+(function($) {
+ var map=new Array();
+ $.Watermark = {
+ ShowAll:function(){
+ for (var i=0;i<map.length;i++){
+ if(map[i].obj.val()==""){
+ map[i].obj.val(map[i].text);
+ map[i].obj.css("color",map[i].WatermarkColor);
+ }else{
+ map[i].obj.css("color",map[i].DefaultColor);
+ }
+ }
+ },
+ HideAll:function(){
+ for (var i=0;i<map.length;i++){
+ if(map[i].obj.val()==map[i].text)
+ map[i].obj.val("");
+ }
+ }
+ }
+
+ $.fn.Watermark = function(text,color) {
+ if(!color)
+ color="#aaa";
+ return this.each(
+ function(){
+ var input=$(this);
+ var defaultColor=input.css("color");
+ map[map.length]={text:text,obj:input,DefaultColor:defaultColor,WatermarkColor:color};
+ function clearMessage(){
+ if(input.val()==text)
+ input.val("");
+ input.css("color",defaultColor);
+ }
+
+ function insertMessage(){
+ if(input.val().length==0 || input.val()==text){
+ input.val(text);
+ input.css("color",color);
+ }else
+ input.css("color",defaultColor);
+ }
+
+ input.focus(clearMessage);
+ input.blur(insertMessage);
+ input.change(insertMessage);
+
+ insertMessage();
+ }
+ );
+ };
+})(jQuery); \ No newline at end of file
diff --git a/examples/lessons/6_English_whatsThisLetter/js/karma.js b/examples/lessons/6_English_whatsThisLetter/js/karma.js
new file mode 100755
index 0000000..03f027b
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/js/karma.js
@@ -0,0 +1,1018 @@
+/* Documentation Note:
+ * Public methods and properties are commented with /** some text *\/
+ * and private methods and properties are commented with //
+ *
+ * Please leave it that way to keep this documentation sane
+ */
+
+
+/*
+* Karma Framework
+* http://karmaeducation.org
+*
+* Copyright (c) 2009
+* Bryan W Berry bryan@olenepal.org
+* Felipe López Toledo zer.subzero@gmail.com
+*
+* Under MIT License:
+* Permission is hereby granted, free of charge, to any person
+* obtaining a copy of this software and associated documentation
+* files (the "Software"), to deal in the Software without
+* restriction, including without limitation the rights to use,
+* copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following
+* conditions:
+*
+* The above copyright notice and this permission notice shall be
+* included in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+/**
+* @fileOverview Contains karma library
+* @author Bryan Berry <bryan@olenepal.org>
+* @author Felipe Lopez Toledo <zer.subzero@gmail.com>
+*/
+
+
+//common.js modules use exports object
+if(!this.exports) {
+ exports = {};
+}
+
+
+
+/** Checks if the current document type is set to HTML 5, throws
+ * an error otherwise, then initializes the karma object and returns
+ * a reference to that object.
+ * @namespace Global namespace for Karma library
+ * @param {Object} [options={}] options for intializing Karma library
+ * @param {String} [options.locale=''] sets current locale Not Yet Implemented
+ * @param {Array} [options.image=[]] array of images to be converted into a collection
+ * @param {Array} [options.audio=[]] array of audio to be converted into a collection
+ * @param {Array} [options.video=[]] array of videos to be converted into a collection
+ * @param {Array} [options.svg=[]] array of SVG elements to be
+ * converted into a collection. Each SVG element must already exist in the html document
+ * @param {Array} [options.canvas=[]] array of canvas elements
+ * to be converted into a collection. Each canvas element must already exist in the
+ * html document and width and height of each element must be set as attributes
+ * @throws {Error} if the document type declaration is not set to HTML 5, e.g.
+ * <!DOCTYPE html>
+ * @throws {Error} If any of the initialization parameters are invalid values
+ * @returns {Object} Karma.karma -- reference to the initialized Karma library
+ * @example
+ *
+ * var k = Karma({
+ * image: [
+ * {name: "ninja", file: "ninja.png"},
+ * {name: "cowboy", file: "cowboy.png"}
+ * ],
+ * audio: [
+ * {name: "woosh", file: "woosh.ogg"},
+ * {name: "yeehaw", file: "yeehaw.ogg"}
+ * ],
+ * video: [
+ * {name: "attack", file: "attack.ogv"},
+ * {name: "ride", file: "ride.ogv"}
+ * ]
+ * canvas: [
+ * {name: "ninja", domId: "ninjaCanvas"},
+ * {name: "cowboy", domId: "cowboyCanvas"}
+ * ],
+ * svg: [
+ * {name: "ninja", domId: "ninjaSvg"},
+ * {name: "cowboy", domId: "cowboySvg"}
+ * ],
+ * });
+ * Next, call the ready function with a callback to your program code
+ *
+ * k.ready(function () { ... your application code . . . }
+ *
+ * after that you can access each asset like so
+ * k.image.ninja;
+ * k.svg.cowboy;
+ * k.audio.yeehaw.play();
+ * k.canvas.ninja.drawImage(k.image.ninja, 0, 0);
+ *
+ */
+var Karma = exports.Karma = function (options) {
+ Karma._isHtml5(document.doctype.nodeName);
+
+ if ( Karma.karma._initialized === true ) {
+ return Karma.karma;
+ } else {
+ return Karma.karma._init(options);
+ }
+};
+
+
+//helper functions
+
+/**This emulates the Object.create method in ecmascript 5 spec
+ * This isn't a full implementation as it doesn't support
+ * This has the same functionality as Crockford's beget method
+ * and this primary building block for prototypal inheritance in
+ * this library
+ * @param {Object} target that the new object's prototype should point to
+ * @returns {Object} object whose prototype points to target
+ * @example
+ *
+ * var ninja = { weapon : "sword" };
+ * var ninja1 = Karma.create(ninja);
+ * ninja1.sword === "sword"
+ */
+Karma.create = function (target){
+ function F () {};
+ F.prototype = target;
+ return new F();
+};
+
+/** Returns a shallow copy of the passed in object
+ * @param {Object} target to be copied
+ * @returns {Object} a shallow copy of target
+ */
+Karma.clone = function (target){
+ var copy = {};
+ for ( var i in target ) {
+ if(target.hasOwnProperty(i)){
+ copy[i] = target[i];
+ }
+ }
+ return copy;
+};
+
+/** Extends properties of the target object with those of
+ * the source object
+ * @param {Object} target object to be extended
+ * @param {Object} source whose properties will extend target
+ * @returns {Object} target extended by source
+ */
+Karma.objectPlus = function (target, source){
+ for ( var i in source){
+ if (source.hasOwnProperty(i)){
+ target[i] = source[i];
+ }
+ }
+ return target;
+};
+
+/** Creates a new object that is a prototype of the first argument
+ * then extends it with the properties of the second argument
+ * @param {Object} parent1 will be prototype of returned object
+ * @param {Object} parent2 will extend properties of returned object
+ * @returns {Object} object that whose prototype is parent1 and has
+ * been extended with properties of parent2
+ */
+Karma.copyObjectPlus = function (parent1, parent2){
+ function F () {};
+ F.prototype = parent1;
+ var G = new F();
+ return Karma.objectPlus(G, parent2);
+};
+
+//Enables function chaining for a specified list of function names
+//IMPORTANT: use of closures here with "this" and "that" is __very__
+//complicated here
+Karma._makeChain = function (chainingFunctions) {
+ var that = this;
+ var _chainFunction = function ( name ){
+ that[ name ] = function ( ){
+ var type = typeof this.ctx[name];
+ if ( type === "function") {
+ this.ctx[ name ].apply( this.ctx, arguments );
+ }else if ( type === "string" ){
+ this.ctx[ name ] = arguments[0];
+ }else {
+ throw ("wtf?!: impossible to chain " + name + "!");
+ }
+ return this;
+ };
+ };
+
+ for (var i = 0; i < chainingFunctions.length; i++){
+ _chainFunction( chainingFunctions[ i ] );
+ }
+};
+
+//Throws big ugly error if doctype isn't html5
+Karma._isHtml5 = function (doctype){
+ var regex = new RegExp('^html$', 'i');
+ if(!regex.test(doctype)){
+ var errorMsg = "ERROR: The doctype must be set to <!DOCTYPE html> " +
+ "in order to use Karma. Karma require you use html5";
+ var errorElem = document.createElement('div');
+ errorElem.setAttribute('id', 'errorDoctype');
+ errorElem.innerText = errorMsg;
+ document.body.appendChild(errorElem);
+ throw new Error(errorMsg);
+ }
+};
+
+
+/** Stores global settings for the Karma library
+ * @class This object stores the global settings for the Karma library
+ */
+Karma.karma = {
+ /** This is the global locale as passed to Karma(),
+ * such as "en", "es_SP"
+ * @type string
+ * @default undefined
+ */
+ locale : undefined,
+ /** Collection of images with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ image : {},
+ /** Collection of audio with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ audio : {},
+ /** Collection of canvas with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ canvas : {},
+ /** Collection of svgs with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ svg : {},
+ /** Collection of videos with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ video : {},
+ _localized : false,
+ _assetPath : "assets/",
+ _localePath : "",
+ _initialized : false,
+ _statusDiv: undefined,
+ _loaderDiv : undefined,
+ _counters : { total : 0, errors : 0, loaded : 0},
+
+ //init initializes all the assets passed to Karma, that's it
+ //it returns 'this' so it can be used for function chaining
+ _init: function(options) {
+ this._initialized = true;
+
+ //set up message that show count of assets loaded
+ //and has an ordered list to append error messages to
+ var _statusDiv = this._statusDiv = document.createElement('div');
+ this._loaderDiv = this._loaderDiv = document.createElement('div');
+ var errorList = document.createElement('ol');
+
+ _statusDiv.setAttribute('id', 'karma-status');
+ _statusDiv.setAttribute('style', 'position:absolute;');
+ _statusDiv.innerHTML = 'Karma is loading ...';
+ this._loaderDiv.setAttribute('id', 'karma-loader');
+ this._loaderDiv.setAttribute('class', 'status');
+ errorList.setAttribute('id', 'errorList');
+
+ _statusDiv.appendChild(this._loaderDiv);
+ this._statusDiv.appendChild(errorList);
+ document.body.appendChild(_statusDiv);
+
+
+ //chain the functions for kCanvas and kSvg
+ Karma._makeChain.call(Karma.kCanvas,
+ Karma.kCanvas._chainingFunctions);
+ //Karma._makeChain.apply(Karma.kSvg, Karma.kSvg._chainingFunctions);
+
+
+
+ //regular expression that matches the name of aprivate property
+ // the karma object
+ var regexPrivate = new RegExp('^_.*');
+
+ for ( var option in options ) {
+ if (options.hasOwnProperty(option)){
+ if (option === "image" || option === "audio" || option ===
+ "svg" || option === "video" || option === "canvas"){
+
+ if(!(options[option] instanceof Array)){
+ throw new Error("" + option + " must be an array");
+ } else if (options[option].length === 0){
+ continue;
+ }
+ } else if (regexPrivate.test(option)){
+ //don't overwrite a private property of karma object
+ continue;
+ }
+
+ switch (option){
+ case "locale":
+
+ if (this._isValidLocale(options[option])){
+ this.locale = this._normalizeLocale(options[option]);
+ this._localized = true;
+ this._localePath = Karma._computeLocalePath(this.locale);
+ } else {
+ throw new Error("locale provided to karma._init() is invalid");
+ }
+
+ break;
+ case "image":
+ options[option]._type = 'image';
+ Karma._makeImages(options[option]);
+ break;
+ case "audio":
+ options[option]._type = 'audio';
+ Karma._makeAudio(options[option]);
+ break;
+ case "video":
+ options[option]._type = 'video';
+ Karma._makeVideos(options[option]);
+ break;
+ case "svg":
+ options[option]._type = 'svg';
+ Karma._makeSvgs(options[option]);
+ break;
+ case "canvas":
+ options[option]._type = 'canvas';
+ Karma._makeCanvases(options[option]);
+ break;
+ }
+ }
+ }
+
+
+
+ return this;
+ },
+
+ /** Waits until all assets loaded, i.e. ready, then calls callback
+ * @param {Function} [cb] callback function
+ * @returns this
+ * @throws {Error} if Karma.karma is not initialized with the
+ * Karma({ options }) function
+ * @example
+ *
+ * var k = Karma({ . . . your assets here . . . });
+ * k.ready(function(){ .. your code here . . .});
+ *
+ * your code will not be called until all assets have been loaded
+ *
+ */
+ ready : function( cb ) {
+ var that = this;
+ if (Karma.karma._initialized !== true){
+ throw new Error("Karma.karma not initialized");
+ }
+
+ if (this._counters.loaded !== this._counters.total){
+ setTimeout(function(){ that.ready(cb);}, 5);
+ } else if (cb) {
+ //hide the "Karma is loading..." message
+ this._statusDiv.setAttribute('style', 'display:none;');
+
+ cb();
+ } else if (!cb) {
+ //hide the "Karma is loading..." message
+ this._statusDiv.setAttribute('style', 'display:none;');
+
+ //if no options passed, show it works message
+ this._showStarterMessage();
+ }
+
+
+
+
+ return this;
+ },
+
+ //Display Apache-like "It works" message if no options
+ _showStarterMessage : function (){
+ var starterMsg = document.createElement('div');
+ starterMsg.setAttribute('id', 'starterMsg');
+ starterMsg.innerHTML = "<h1>It Works</h1>";
+ document.body.appendChild(starterMsg);
+ },
+
+ //Updates visible counter of how many assets are loaded
+ _updateStatus : function (errorMsg) {
+ var loaded = this._counters.loaded;
+ var total = this._counters.total;
+ var errors = this._counters.errors;
+ this._loaderDiv.innerHTML = "Loaded " + loaded + " / " + total +
+ "" + (errors > 0 ? " Errors [ " + errors +" ]" : '');
+ if (errorMsg) {
+ var liError = document.createElement('li');
+ liError.innerHTML = errorMsg;
+ var errorList = document.getElementById('errorList');
+ errorList.appendChild(liError);
+ }
+ },
+
+ //matches 2 letter country code then optionally
+ //a dash or underscore followed by a country or language identifier
+ //i currently only allow a language identifier 2-3 chars long
+ _isValidLocale : function (locale) {
+ var localeRegex = new RegExp('^[a-zA-Z][a-zA-Z]([-_][a-zA-z]{2,3})?$');
+ return localeRegex.test(locale);
+ },
+
+ _normalizeLocale : function(locale) {
+ var lang = "";
+ var country = "";
+ var divider = "";
+
+ lang = locale.slice(0, 2).toLowerCase();
+ divider = "_";
+ country = locale.slice(3, 6).toUpperCase();
+
+ return locale.length > 2 ? "" + lang + divider + country : lang;
+ },
+
+ // Below are geometry and math helper methods
+
+ /**
+ * Converts a value from degrees to radians.
+ * @param {Number} angle The angle in degrees
+ * @returns {Number} The angle in radians
+ */
+ radians : function( angle ){
+ return ( angle / 180 ) * Math.PI;
+ },
+ /**
+ * Gets the square of the Euclidian (ordinary) distance between 2 points.
+ * @param {Object} Point No. 0
+ * @param {Number} Point0.x
+ * @param {Number} Point0.y
+ * @param {Object} Point No. 1
+ * @param {Number} Point1.x
+ * @param {Number} Point1.y
+ * @returns {Number} The square of the Euclidian distance
+ * @example
+ *
+ * p0 = {x:0, y:1};
+ * p1 = {x:50, y:70};
+ * var d = distance2(p0, p1);
+ *
+ */
+ distance2 : function ( p0, p1 ) {
+ return (p1.x - p0.x) * (p1.x - p0.x) + (p1.y - p1.y) * (p1.y - p1.y);
+ },
+ /**
+ * Gets the Euclidian (ordinary) distance between 2 points.<br>
+ * <b>Warning:</b> It's slower than distance2 function
+ * @param {Object} Point No. 0
+ * @param {Number} Point0.x
+ * @param {Number} Point0.y
+ * @param {Object} Point No. 1
+ * @param {Number} Point1.x
+ * @param {Number} Point1.y
+ * @returns {Number} The Euclidian distance
+ * @example
+ *
+ * p0 = {x:0, y:1};
+ * p1 = {x:50, y:70};
+ * var d = distance2(p0, p1);
+ *
+ */
+ distance : function ( p0, p1 ) {
+ return Math.sqrt( this.distance2( p0, p1 ) );
+ },
+ /** Returns a random number within the range provided
+ * @param {Number} lower limit of the range, lowest number that can be returned
+ * @param {Number} upper limit of the range, highest number that can be returned
+ * @returns {Number} number that is >= lower and <= upper
+ * @example
+ *
+ * var num = rand(0, 10);
+ *
+ * num could be 0, 1, 2, 3 ... or 10
+ *
+ */
+ rand : function ( lower, upper ){
+ return Math.round( Math.random() * (upper - lower) + lower );
+ }
+
+};
+
+/** Prototypal object for images, videos, and audio files but
+ * does not include svg or canvas elements
+ * @class This object is the prototype for images, videos, and audio files but
+ * does not include svg or canvas elements
+ * @ throws {Error} if the individual asset is set to be localized but
+ * the globale locale is not set on the Karma.karma object
+ * @ throws {Error} if the name and file properties are not supplied
+ * @example
+ * kMedia is the prototype object for images, audio, and videos.
+ * These 'media' assets are loaded in a distinctly different way
+ * from the canvas or svg assets. They also have distinctly different
+ * helper methods
+ *
+ * You initialize the kMedia assets by passing an array of objects
+ */
+Karma.kMedia = {
+ /** file location of asset
+ * @type String
+ * @default ""
+ */
+ file : "",
+ /** media object
+ * @type Audio|Image|Video
+ * @default undefined
+ */
+ media : undefined,
+ //actual path to the file
+ _path : "",
+ //if using localized version of this asset
+ _localized : false,
+ //audio, image, or video
+ _type : "",
+ //initializes kMedia instance with values provided by user
+ _init : function (asset) {
+ asset._localized = asset._localized || false;
+ Karma.karma._counters.total++;
+
+ if (asset.name === undefined || asset.file === undefined){
+ throw new Error("properties name and file have to be defined");
+ } else {
+ this.name = asset.name;
+ this.file = asset.file;
+ }
+
+ //_type is a private variable used internally
+ if (asset._type === undefined){
+ throw new Error("the _type property must be set. " +
+ "Blame the karma library authors as this is an internal value");
+ } else {
+ if (Karma._isValidType(asset._type)){
+ this._type = asset._type;
+ switch ( this._type ) {
+ case "image": this.media = new Image();
+ break;
+ case "audio": this.media = new Audio();
+ break;
+ //case "video":
+ //NYI
+ //this.media = new Video();
+ break;
+ default: throw new Error("Media type not supported");
+ }
+
+ } else {
+ throw new Error("the _type property supplied is invalid. " +
+ "Blame the karma library authors as this is an internal value");
+ }
+ }
+
+ if(Karma._isLocalized(asset._localized)){
+ this._localized = asset._localized;
+ this._path = Karma.karma._localePath +
+ this._type + "/";
+ } else {
+ this._path = Karma.karma._assetPath +
+ this._type + "/";
+ }
+
+
+ //IMPORTANT: This one magic line loads the file
+ this.media.src = this.src = this._path + this.file;
+
+ //add event handlers
+ this._addEventHandlers();
+
+ if (this._type === "audio"){
+ this.media.autobuffer = true;
+ this.media.load();
+ }
+
+
+ return this;
+ },
+ //Adds event handlers to update the counters when
+ //the asset is successfully or unsuccessfully loaded
+ _addEventHandlers : function () {
+ var that = this;
+ var loadEvent = "load";
+ //Browser Hack recommended by chromium devs
+ //http://code.google.com/p/chromium/issues/detail?id=20251&q=loading%20audio&colspec=ID%20Stars%20Pri%20Area%20Type%20Status%20Summary%20Modified%20Owner%20Mstone%20OS#c4
+ if (this._type === "audio" || this._type === "video"){
+ loadEvent = "canplaythrough";
+ }
+
+ that.media.addEventListener(
+ loadEvent,
+ function (e) {
+ Karma.karma._counters.loaded++;
+ Karma.karma._updateStatus();
+ that.status = "loaded";}, false);
+
+ that.media.addEventListener(
+ "error",
+ function (e) {
+ Karma.karma._counters.errors++;
+ that.status = "error";
+ var errorMsg = "Error: " + that._type.toUpperCase() +
+ " " + that.name + " cannot be loaded.";
+ Karma.karma._updateStatus(errorMsg);
+ },
+ false);
+ that.media.addEventListener(
+ "abort",
+ function (e) {
+ Karma.karma._counters.total++;
+ that.status = "aborted";
+ var errorMsg = "ABORT: " + that._type.toUpperCase() +
+ " " + that.name + " loading was aborted.";
+ Karma.karma._updateStatus(errorMsg);
+
+ }, false);
+
+ }
+
+};
+
+//determine if it is a valid type of asset
+Karma._isValidType = function (type){
+ return type === "image" ||
+ type === "svg" ||
+ type === "audio" ||
+ type === "video" ||
+ type === "canvas";
+};
+
+Karma._isLocalized = function (boolLocalized) {
+ if (typeof boolLocalized === "boolean" ) {
+ if(boolLocalized === true &&
+ Karma.karma.locale === undefined){
+ throw new Error("You cannot localize a media asset" +
+ " if the global locale for Karma isn't set");
+ } else {
+ return boolLocalized;
+ }
+ } else if (typeof boolLocalized === undefined){
+ return false;
+ } else{
+ throw new Error("This is not a valid value for the localized option");
+ }
+};
+
+Karma._computeLocalePath = function(locale) {
+ return Karma.karma._assetPath + locale + "/";
+};
+
+Karma._makeImages = function (imgConfigs){
+ var makeImage = function (imgConfig){
+ var image = undefined;
+ imgConfig._type = "image";
+ image = Karma.create(Karma.kMedia)._init(imgConfig);
+ Karma.karma.image[imgConfig.name] = image;
+ };
+
+ imgConfigs.forEach(function(imgConfig){ makeImage(imgConfig);});
+
+};
+
+Karma._makeAudio = function (audioConfigs){
+ var makeAudio = function (audioConfig){
+ var audio = undefined;
+ audioConfig._type = "audio";
+ audio = Karma.create(Karma.kMedia)._init(audioConfig);
+ audio.play = function () {
+ //hack to fix the audio "stuttering" problem
+ //more info: https://bugs.launchpad.net/karma/+bug/426108
+ this.media.currentTime = 0.1;
+ this.media.play();
+ };
+ Karma.karma.audio[audioConfig.name] = audio;
+ };
+
+ audioConfigs.forEach(function(audioConfig){ makeAudio(audioConfig);});
+
+};
+
+
+Karma._makeCanvases = function (canvasConfigs){
+ var makeCanvas = function (canvasConfig){
+ var canvas = undefined;
+ canvas = Karma.create(Karma.kCanvas)._init(canvasConfig);
+ Karma.karma.canvas[canvasConfig.name] = canvas;
+ };
+
+ canvasConfigs.forEach(function(canvasConfig){ makeCanvas(canvasConfig);});
+
+};
+
+/** Prototypal object for each canvas element submitted to Karma in the
+ * Karma() method
+ * @throws {Error} if the name and domId for the canvas element are not specified
+ * @thows {Error} if the supplied domId does not match an element in the DOM
+ * @class This object is the prototype for each canvas element submitted to Karma in the
+ * Karma() method
+ */
+Karma.kCanvas = {
+ /** Name of the canvas, used internally by karma.js
+ * @type String
+ * @default ''
+ */
+ name : '',
+ /** Width of canvas element
+ * @type Number
+ * @default 0
+ */
+ width: 0,
+ /** Height of canvas element
+ * @type Number
+ * @default 0
+ */
+ height: 0,
+ /** Whether canvas is visible
+ * @type boolean
+ * @default true
+ */
+ visible: true,
+ /** Element ID for canvas element in html document
+ * @type String
+ * @default undefined
+ */
+ domId: undefined,
+ /** Reference to the DOM element
+ * @type DOMElement
+ * @default undefined
+ */
+ node: undefined,
+ /** The 2 Dimensional Rendering context property for this canvas
+ * @type 2DRenderingContext
+ * @default undefined
+ */
+ ctx: undefined,
+ /** Frames Per Second, I don't know what the purpose of this is,
+ * Felipe made it up
+ * @type Number
+ * @default 24
+ */
+ fps: 24,
+
+ //initializes object with values provides by user
+ _init: function (config) {
+ for (var option in config){
+ if (config.hasOwnProperty(option)){
+ switch (option){
+ case "name":
+ this.name = config[option];
+ break;
+ case "domId":
+ this.domId = config[option];
+ break;
+ case "width":
+ if(!this.height){
+ throw new Error("If you specify a width you must also" +
+ "specify a height");
+ }
+ this.width = config[option];
+ break;
+ case "height":
+ if(!this.width){
+ throw new Error("If you specify a height you must also" +
+ "specify a width");
+ }
+ this.height = parseInt(config.option, 10);
+ break;
+ case "fps":
+ this.fps = parseInt(config.option, 10);
+ break;
+ }
+ }
+ }
+
+ if(this.domId && document.getElementById(this.domId)){
+ this.node = document.getElementById(this.domId);
+ this.ctx = this.node.getContext('2d');
+ } else {
+ throw new Error('you must specify a valid domId that' +
+ 'is in your html page');
+ }
+
+ if(!config.height && !config.width){
+ this.width = parseInt(this.node.getAttribute('width'), 10);
+ this.height = parseInt(this.node.getAttribute('height'), 10);
+ }
+
+ return this;
+ },
+ /** Clear area of canvas element specified by parameters, if no
+ * parameters supplied, clears entire canvas
+ * @param {Number} [x=0] x coordinate, defaults to zero if left blank
+ * @param {Number} [y=0] y coordinate, defaults to zero if left blank
+ * @param {Number} [width=0] width of area to be cleared, defaults
+ * entire width of canvas
+ * @param {Number} [height=0] height of area to be cleared, defaults
+ * entire height of canvas
+ * @returns this
+ * @example
+ *
+ * k.canvas.ninja.clear();
+ * // clears the entire ninja canvas
+ *
+ * k.canvas.ninja.clear(0, 10, 20, 30);
+ * //clears a specific portion of the ninja canvas
+ *
+ */
+ clear : function ( x, y, width, height ) {
+ var that = this;
+ that.ctx.clearRect(
+ x || 0,
+ y || 0,
+ width || that.width,
+ height || that.height
+ );
+ return that;
+ },
+
+ //These are all properties or methods of the canvas element's
+ //2 dimensional context
+ _chainingFunctions : [
+ "globalAlpha", "globalCompositeOperation", "lineWidth", "lineCap",
+ "lineJoin", "miterLimit", "font", "textAlign", "textBaseline", "save",
+ "restore", "scale", "rotate", "translate", "transform", "setTransform",
+ "clearRect", "fillRect", "strokeRect", "beginPath", "closePath",
+ "moveTo", "lineTo", "quadraticCurveTo", "bezierCurveTo", "arcTo",
+ "arc", "rect", "fill", "stroke", "clip", "fillText", "strokeText",
+ "measureText", "isPointInPath", "strokeStyle", "fillStyle",
+ "createLinearGradient", "createRadialGradient", "createPattern",
+ "shadowOffsetX", "shadowOffsetY", "shadowBlur", "shadowColor",
+ //"mozTextStyle", "mozDrawText", "mozMeasureText", "mozPathText",
+ "mozTextAlongPath", "drawImage", "getImageData", "putImageData",
+ "createImageData", "drawWindow"
+ ]
+};
+
+
+
+Karma._makeSvgs = function (svgConfigs){
+ var makeSvg = function (svgConfig){
+ var svg = undefined;
+ svg = Karma.create(Karma.kSvg)._init(svgConfig);
+ Karma.karma.svg[svgConfig.name] = svg;
+ };
+
+ svgConfigs.forEach(function(svgConfig){ makeSvg(svgConfig);});
+
+};
+
+/** Prototypal object for each svg element submitted to Karma in the
+ * Karma() method
+ * @throws {Error} if the name and domId for the svg element are not specified
+ * @thows {Error} if the supplied domId does not match an element in the DOM
+ * @class This object is the prototype for each svg element submitted to Karma in the
+ * Karma() method
+ */
+Karma.kSvg = {
+ /** name of instance, used internally
+ * @typeof string
+ * @default ""
+ */
+ name : "",
+ /** width of element
+ * @type number
+ * @default 0
+ */
+ width: 0,
+ /** height of element
+ * @type number
+ * @default 0
+ */
+ height: 0,
+ /** Status of element, either "loaded" or "error"
+ * @type string
+ * @default ""
+ */
+ status: "",
+ /** Whether canvas is visible
+ * @type boolean
+ * @default true
+ */
+ visible: true,
+ /** Element ID for canvas element in html document
+ * @type String
+ * @default undefined
+ */
+ domId: undefined,
+ /** Reference to the DOM element
+ * @type DOMElement
+ * @default undefined
+ */
+ node: undefined,
+ /** Reference to the SVGDocument
+ * @type SVGDocument
+ * @default undefined
+ */
+ doc: undefined,
+ /** Reference to the root element of the SVG Document
+ * @type DocumentElement
+ * @default undefined
+ */
+ root: undefined,
+ _localized : undefined,
+ _chainingFunctions: [],
+ _init: function (config) {
+ Karma.karma._counters.total++;
+
+ for (var option in config){
+ if (config.hasOwnProperty(option)){
+ switch (option){
+ case "name":
+ this.name = config[option];
+ break;
+ case "domId":
+ this.domId = config[option];
+ break;
+ case "width":
+ if(!this.height){
+ throw new Error("If you specify a width you must also" +
+ "specify a height");
+ }
+ this.width = parseInt(config[option], 10);
+ break;
+ case "height":
+ if(!this.width){
+ throw new Error("If you specify a height you must also" +
+ "specify a width");
+ }
+ this.height = config[option];
+ break;
+ case "fps":
+ this.fps = config[option];
+ break;
+ }
+ }
+ }
+
+ if(this.domId && document.getElementById(this.domId)){
+ this.node = document.getElementById(this.domId);
+ } else {
+ throw new Error('you must specify a valid domId that' +
+ 'is in your html page');
+ }
+
+ if(!config.height && !config.width){
+ this.width = parseInt(this.node.getAttribute('width'), 10);
+ this.height = parseInt(this.node.getAttribute('height'), 10);
+ }
+
+ var that = this;
+ that._addEventHandlers();
+
+ return this;
+
+
+ },
+ _addEventHandlers : function () {
+ var that = this;
+ that.doc = that.node.getSVGDocument();
+ that.node.addEventListener(
+ "load",
+ function (e) {
+ that.doc = that.node.getSVGDocument();
+ that.root = that.doc.documentElement;
+ Karma.karma._counters.loaded++;
+ Karma.karma._updateStatus();
+ that.status = "loaded";
+ }, false);
+
+ that.node.addEventListener(
+ "error",
+ function (e) {
+ Karma.karma._counters.loaded--;
+ Karma.karma._counters.errors++;
+ that.status = "error";
+ var errorMsg = "Error: " + that._type.toUpperCase() +
+ " " + that.name + " cannot be loaded.";
+ Karma.karma._updateStatus(errorMsg);
+ },
+ false);
+ that.node.addEventListener(
+ "abort",
+ function (e) {
+ that.status = "aborted";
+ var errorMsg = "ABORT: " + that._type.toUpperCase() +
+ " " + that.name + " loading was aborted.";
+ Karma.karma._updateStatus(errorMsg);
+
+ }, false);
+
+ }
+};
+
+Karma._makeVideos = function (video){
+
+};
diff --git a/examples/lessons/6_English_whatsThisLetter/js/lesson.js b/examples/lessons/6_English_whatsThisLetter/js/lesson.js
new file mode 100755
index 0000000..d6860e1
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/js/lesson.js
@@ -0,0 +1,263 @@
+$(document).ready(function(){
+ var k = Karma({
+ audio: [{'name':'correct','file':'correct.ogg'},
+ {'name':'incorrect','file':'incorrect.ogg'},
+ {'name':'apple','file':'apple.wav'},
+ {'name':'banana','file':'banana.wav'},
+ {'name':'boat','file':'boat.wav'},
+ {'name':'book','file':'book.wav'},
+ {'name':'bus','file':'bus.wav'},
+ {'name':'cake','file':'cake.wav'},
+ {'name':'car','file':'car.wav'},
+ {'name':'cow','file':'cow.wav'},
+ {'name':'flower','file':'flower.wav'},
+ {'name':'hat','file':'hat.wav'},
+ {'name':'kite','file':'kite.wav'},
+ {'name':'lamp','file':'lamp.wav'},
+ {'name':'pig','file':'pig.wav'},
+ {'name':'pigeon','file':'pigeon.wav'},
+ {'name':'rat','file':'rat.wav'},
+ {'name':'tomato','file':'tomato.wav'},
+ {'name':'tree','file':'tree.wav'}
+ ]});
+
+ k.ready(function(){
+ var i,j,topPos,leftPos; //game is completely based on absolute positioning....
+ var TOTAL_QUES = 10;
+ var TOTAL_OBJECTS = 17;
+ var randObjects = []; //store only ten random objects among TOTAL_OBJECTS
+ var randPositions = []; //store the random absolute positions for each object
+ var randQues = []; //store the turns of the pointer to go i.e questions
+ var objects = ['apple','banana','boat','book','bus','cake',
+ 'car','cow','flower','hat','kite','lamp',
+ 'pig','pigeon','rat','tomato','tree'
+ ];
+ var pointers = ['ladybird','ant'];
+ var pointer; //which pointer to use
+ var currentWord;
+ var randNum; //store the random position of letter in a word
+ var flag_correct;
+
+ var leftPositions = [-20,185,550,800,1025,-20,185,550,800,1025]; //array to store the left positions
+ var topPositions = [5,10,50,60,20,350,360,365,240,340];
+ var pointerStartTop,pointerStartLeft;
+ var pointerStopTop,pointerStopLeft;
+ var currentQuestion,totalCounter,correctCounter;
+
+ var scoreboard = $('#score_box').scoreboard({'layout':'horizontal',
+ 'winningScore': TOTAL_QUES});
+
+ var genRandObjects=function (){
+ randObjects[0] = k.rand(0,TOTAL_OBJECTS-1);
+ for(i=1; i<TOTAL_QUES; i++){
+ do{
+ flag = 0;
+ randObjects[i] = k.rand(0,TOTAL_OBJECTS-1);
+ for(j=0; j<i; j++){
+ if(randObjects[i] === randObjects[j]){
+ flag++;
+ }
+ }
+ }while(flag != 0 ); //end of do while loop
+ }
+ };
+
+ var genRandQues=function (){
+ randQues[0] = k.rand(0,TOTAL_QUES-1);
+ for(i=1; i<TOTAL_QUES; i++){
+ do{
+ flag = 0;
+ randQues[i] = k.rand(0,TOTAL_QUES-1);
+ for(j=0; j<i; j++){
+ if(randQues[i] === randQues[j]){
+ flag++;
+ }
+ }
+ }while(flag != 0 ); //end of do while loop
+ }
+ };
+
+ var generateAbsolutePositions = function(id,topPos,leftPos){
+ var randNumImg = randObjects[id];
+ $('#content').append('<div id="pos'+id+'"></div>');
+ var objCss = {
+ 'position':'absolute',
+ 'top':topPos+'px',
+ 'left':leftPos+'px'
+ };
+ $('#pos'+id).css(objCss).html('<img src="assets/image/'+objects[randNumImg]+'.png" />');
+ };
+
+
+ var showQuestion = function(){
+ //alert('show question');
+ $('#content').append('<div id="questionSection"></div>');
+ $('#questionSection').html('').append('<div id="question">What is this?</div>');
+ $('#questionSection').append("<div id='answers'></div>");
+ currentWord = objects[randObjects[currentQuestion]];
+ $('#answers').append("It's ");
+ if(currentWord[0] === 'a' || currentWord[0] === 'e' ||currentWord[0] === 'i' || currentWord[0] === 'o' || currentWord[0] === 'u'){
+ $('#answers').append('an ');
+ } else{
+ $('#answers').append('a ');
+ }
+ $('#answers').append('<span id="word'+currentQuestion+'" class="objectWord"></span>');
+ $('#answers').append('.');
+
+
+ var wordLength = currentWord.length;
+ randNum = k.rand(0,wordLength-1);
+ //randBoxes[monthId] = randNum;
+ for(var z = 0; z < wordLength; z++){
+ if(z === (randNum)){
+ $('#word'+currentQuestion).append('<input type="text" id="box'+currentQuestion+'" class="blankBox" maxlength="1"/>')
+ $('#box'+currentQuestion).Watermark("?");
+ //insert text box
+ }
+ else{
+ $('#word'+currentQuestion).append(currentWord[z]);
+ }
+ }
+ $('.blankBox').focus();
+ foucs_blur();
+
+
+ };
+
+ var nextQuestion = function(){
+ flag_correct = 1;
+ currentQuestion = randQues[totalCounter];
+ if(totalCounter === 0){
+ pointerStartLeft = k.rand(10,1000);
+ pointerStartTop = k.rand(5,500);
+ } else{
+ pointerStartLeft = pointerStopLeft;
+ pointerStartTop = pointerStopTop;
+ }
+ pointerStopLeft = leftPositions[currentQuestion]+70;
+ pointerStopTop = topPositions[currentQuestion]+70;
+
+ $('#content').append('<div id="wordPointer"></div>');
+
+ var wordPointerCss = {
+ 'position':'absolute',
+ 'top':pointerStartTop+'px',
+ 'left':pointerStartLeft+'px',
+ 'background-color':'#F5F29E'
+ };
+ $('#wordPointer').css(wordPointerCss).addClass('pointerBg').html('<img src="assets/image/'+pointers[pointer]+'.png" />');
+ $('#wordPointer').animate(
+ {top:pointerStopTop+'px',left:pointerStopLeft+'px'},2000,
+ function(ev){ //callback function after the animation is complete
+ //alert('animation complete');
+ showQuestion();
+ }
+ );
+
+ };
+
+ function game(){
+ $('#gameOver').hide();
+ $('#content').removeClass('backOpaque');
+ correctCounter = 0;
+ totalCounter = 0;
+ genRandQues();
+ genRandObjects();
+ pointer = k.rand(0,1);
+
+ //Generate the fixed absolute positions for the random images
+ for(i = 0; i<leftPositions.length;i++){
+ generateAbsolutePositions(i,topPositions[i],leftPositions[i]);
+ }
+
+ nextQuestion();
+ }
+
+ $('#linkStart').click(function(){
+ scoreboard.scoreboard('reset');
+ game();
+ });
+
+ $('#linkPlayAgain').click(function(){
+ scoreboard.scoreboard('reset');
+ game();
+ });
+
+ var delay_gameOver = function(){
+ document.delayForm.delayval.value = 1;
+ $('#questionSection').html('');
+ $('#pos'+currentQuestion).html('');
+ $('#content').addClass('backOpaque');
+ $('#gameOver').show();
+ $('#gameOver').html('');
+ $('#gameOver').append('Game Over !!!');
+ $('#gameOver').append('<div id="gameOverInfo">You got <span class="specialText">'+correctCounter+
+ '</span> correct out of <span class="specialText">'+totalCounter+'</span> questions .</div>');
+
+ };
+
+ var delay_nextQues = function(){
+ document.delayForm.delayval.value = 1;
+ $('#questionSection').html('');
+ $('#pos'+currentQuestion).html('');
+ nextQuestion();
+ };
+
+
+ var checkAnswer = function(){
+
+ if(currentWord[randNum] === $('.blankBox').val()){
+ $('.blankBox').addClass("correct");
+ if(flag_correct === 1){
+ correctCounter++;
+ scoreboard.scoreboard('inc');
+ }
+ k.audio[currentWord].play();
+ totalCounter++;
+ scoreboard.scoreboard('incTotal');
+
+ if(totalCounter === TOTAL_QUES){
+ t=setTimeout(function(){delay_gameOver();},1000);
+ }
+ else{
+
+ t=setTimeout(function(){delay_nextQues();},1000);
+
+ }
+ }
+ else{ //incorrect
+ flag_correct = 0;
+ $('.blankBox').addClass("incorrect");
+ k.audio.incorrect.play();
+
+ }
+ };
+
+ function foucs_blur(){
+ $('input[type="text"]').bind({
+ focus: function() {
+ $(this).removeClass('correct').removeClass('incorrect').addClass("focus");
+ },
+ blur: function(){
+ $(this).removeClass("focus");
+ },
+ keypress: function(event) {
+ if(event.which === 13){
+ checkAnswer();
+ }
+ }
+ });
+ }
+
+ $('#linkHelp').mouseover(function(){
+ $('#help').slideDown(2000);
+ })
+ .mouseout(function(){
+ $('#help').slideUp(2000);
+ });
+
+
+ }); //end of k.ready
+}); //end of document.read
+
+
diff --git a/examples/lessons/6_English_whatsThisLetter/js/lesson.js~ b/examples/lessons/6_English_whatsThisLetter/js/lesson.js~
new file mode 100755
index 0000000..9c6e892
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/js/lesson.js~
@@ -0,0 +1,259 @@
+$(document).ready(function(){
+ var k = Karma({
+ audio: [{'name':'correct','file':'correct.ogg'},
+ {'name':'incorrect','file':'incorrect.ogg'},
+ {'name':'apple','file':'apple.wav'},
+ {'name':'banana','file':'banana.wav'},
+ {'name':'boat','file':'boat.wav'},
+ {'name':'book','file':'book.wav'},
+ {'name':'bus','file':'bus.wav'},
+ {'name':'cake','file':'cake.wav'},
+ {'name':'car','file':'car.wav'},
+ {'name':'cow','file':'cow.wav'},
+ {'name':'flower','file':'flower.wav'},
+ {'name':'hat','file':'hat.wav'},
+ {'name':'kite','file':'kite.wav'},
+ {'name':'lamp','file':'lamp.wav'},
+ {'name':'pig','file':'pig.wav'},
+ {'name':'pigeon','file':'pigeon.wav'},
+ {'name':'rat','file':'rat.wav'},
+ {'name':'tomato','file':'tomato.wav'},
+ {'name':'tree','file':'tree.wav'}
+ ]});
+
+ k.ready(function(){
+ var i,j,topPos,leftPos; //game is completely based on absolute positioning....
+ var TOTAL_QUES = 10;
+ var TOTAL_OBJECTS = 17;
+ var randObjects = []; //store only ten random objects among TOTAL_OBJECTS
+ var randPositions = []; //store the random absolute positions for each object
+ var randQues = []; //store the turns of the pointer to go i.e questions
+ var objects = ['apple','banana','boat','book','bus','cake',
+ 'car','cow','flower','hat','kite','lamp',
+ 'pig','pigeon','rat','tomato','tree'
+ ];
+ var pointers = ['ladybird','ant'];
+ var pointer; //which pointer to use
+ var currentWord;
+ var randNum; //store the random position of letter in a word
+ var flag_correct;
+
+ var leftPositions = [-20,185,550,800,1025,-20,185,550,800,1025]; //array to store the left positions
+ var topPositions = [5,10,50,60,20,350,360,365,240,340];
+ var pointerStartTop,pointerStartLeft;
+ var pointerStopTop,pointerStopLeft;
+ var currentQuestion,totalCounter,correctCounter;
+
+ var scoreboard = $('#score_box').scoreboard({'layout':'horizontal',
+ 'winningScore': TOTAL_QUES});
+
+ var genRandObjects=function (){
+ randObjects[0] = k.rand(0,TOTAL_OBJECTS-1);
+ for(i=1; i<TOTAL_QUES; i++){
+ do{
+ flag = 0;
+ randObjects[i] = k.rand(0,TOTAL_OBJECTS-1);
+ for(j=0; j<i; j++){
+ if(randObjects[i] === randObjects[j]){
+ flag++;
+ }
+ }
+ }while(flag != 0 ); //end of do while loop
+ }
+ };
+
+ var genRandQues=function (){
+ randQues[0] = k.rand(0,TOTAL_QUES-1);
+ for(i=1; i<TOTAL_QUES; i++){
+ do{
+ flag = 0;
+ randQues[i] = k.rand(0,TOTAL_QUES-1);
+ for(j=0; j<i; j++){
+ if(randQues[i] === randQues[j]){
+ flag++;
+ }
+ }
+ }while(flag != 0 ); //end of do while loop
+ }
+ };
+
+ var generateAbsolutePositions = function(id,topPos,leftPos){
+ var randNumImg = randObjects[id];
+ $('#content').append('<div id="pos'+id+'"></div>');
+ var objCss = {
+ 'position':'absolute',
+ 'top':topPos+'px',
+ 'left':leftPos+'px'
+ };
+ $('#pos'+id).css(objCss).html('<img src="assets/image/'+objects[randNumImg]+'.png" />');
+ };
+
+
+ var showQuestion = function(){
+ //alert('show question');
+ $('#content').append('<div id="questionSection"></div>');
+ $('#questionSection').html('').append('<div id="question">What is this?</div>');
+ $('#questionSection').append("<div id='answers'></div>");
+ currentWord = objects[randObjects[currentQuestion]];
+ $('#answers').append("It's ");
+ if(currentWord[0] === 'a' || currentWord[0] === 'e' ||currentWord[0] === 'i' || currentWord[0] === 'o' || currentWord[0] === 'u'){
+ $('#answers').append('an ');
+ } else{
+ $('#answers').append('a ');
+ }
+ $('#answers').append('<span id="word'+currentQuestion+'" class="objectWord"></span>');
+ $('#answers').append('.');
+
+
+ var wordLength = currentWord.length;
+ randNum = k.rand(0,wordLength-1);
+ //randBoxes[monthId] = randNum;
+ for(var z = 0; z < wordLength; z++){
+ if(z === (randNum)){
+ $('#word'+currentQuestion).append('<input type="text" id="box'+currentQuestion+'" class="blankBox" maxlength="1"/>')
+ $('#box'+currentQuestion).Watermark("?");
+ //insert text box
+ }
+ else{
+ $('#word'+currentQuestion).append(currentWord[z]);
+ }
+ }
+ $('.blankBox').focus();
+ foucs_blur();
+
+
+ };
+
+ var nextQuestion = function(){
+ flag_correct = 1;
+ currentQuestion = randQues[totalCounter];
+ if(totalCounter === 0){
+ pointerStartLeft = k.rand(10,1000);
+ pointerStartTop = k.rand(5,500);
+ } else{
+ pointerStartLeft = pointerStopLeft;
+ pointerStartTop = pointerStopTop;
+ }
+ pointerStopLeft = leftPositions[currentQuestion]+70;
+ pointerStopTop = topPositions[currentQuestion]+70;
+
+ $('#content').append('<div id="wordPointer"></div>');
+
+ var wordPointerCss = {
+ 'position':'absolute',
+ 'top':pointerStartTop+'px',
+ 'left':pointerStartLeft+'px',
+ 'background-color':'#F5F29E'
+ };
+ $('#wordPointer').css(wordPointerCss).addClass('pointerBg').html('<img src="assets/image/'+pointers[pointer]+'.png" />');
+ $('#wordPointer').animate(
+ {top:pointerStopTop+'px',left:pointerStopLeft+'px'},2000,
+ function(ev){ //callback function after the animation is complete
+ //alert('animation complete');
+ showQuestion();
+ }
+ );
+
+ };
+
+ function game(){
+ $('#gameOver').hide();
+ $('#content').removeClass('backOpaque');
+ correctCounter = 0;
+ totalCounter = 0;
+ genRandQues();
+ genRandObjects();
+ pointer = k.rand(0,1);
+
+ //Generate the fixed absolute positions for the random images
+ for(i = 0; i<leftPositions.length;i++){
+ generateAbsolutePositions(i,topPositions[i],leftPositions[i]);
+ }
+
+ nextQuestion();
+ }
+
+ $('#linkStart').click(function(){
+ game();
+ });
+
+ $('#linkPlayAgain').click(function(){
+ game();
+ });
+
+ var delay_gameOver = function(){
+ document.delayForm.delayval.value = 1;
+ $('#content').addClass('backOpaque');
+ $('#gameOver').show();
+ $('#gameOver').html('');
+ $('#gameOver').append('Game Over !!!');
+ $('#gameOver').append('<div id="gameOverInfo">You got <span class="specialText">'+correctCounter+
+ '</span> correct out of <span class="specialText">'+totalCounter+'</span> questions .</div>');
+
+ };
+
+ var delay_nextQues = function(){
+ document.delayForm.delayval.value = 1;
+ $('#questionSection').html('');
+ $('#pos'+currentQuestion).html('');
+ nextQuestion();
+ };
+
+
+ var checkAnswer = function(){
+
+ if(currentWord[randNum] === $('.blankBox').val()){
+ $('.blankBox').addClass("correct");
+ if(flag_correct === 1){
+ correctCounter++;
+ scoreboard.scoreboard('inc');
+ }
+ k.audio[currentWord].play();
+ totalCounter++;
+ scoreboard.scoreboard('incTotal');
+
+ if(totalCounter === TOTAL_QUES){
+ t=setTimeout(function(){delay_gameOver();},1000);
+ }
+ else{
+
+ t=setTimeout(function(){delay_nextQues();},1000);
+
+ }
+ }
+ else{ //incorrect
+ flag_correct = 0;
+ $('.blankBox').addClass("incorrect");
+ k.audio.incorrect.play();
+
+ }
+ };
+
+ function foucs_blur(){
+ $('input[type="text"]').bind({
+ focus: function() {
+ $(this).removeClass('correct').removeClass('incorrect').addClass("focus");
+ },
+ blur: function(){
+ $(this).removeClass("focus");
+ },
+ keypress: function(event) {
+ if(event.which === 13){
+ checkAnswer();
+ }
+ }
+ });
+ }
+
+ $('#linkHelp').mouseover(function(){
+ $('#help').slideDown(2000);
+ })
+ .mouseout(function(){
+ $('#help').slideUp(2000);
+ });
+
+
+ }); //end of k.ready
+}); //end of document.read
+
+
diff --git a/examples/lessons/6_English_whatsThisLetter/js/ui.core.js b/examples/lessons/6_English_whatsThisLetter/js/ui.core.js
new file mode 100755
index 0000000..5493e0a
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/js/ui.core.js
@@ -0,0 +1,519 @@
+/*
+ * jQuery UI 1.7.2
+ *
+ * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * http://docs.jquery.com/UI
+ */
+;jQuery.ui || (function($) {
+
+var _remove = $.fn.remove,
+ isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9);
+
+//Helper functions and ui object
+$.ui = {
+ version: "1.7.2",
+
+ // $.ui.plugin is deprecated. Use the proxy pattern instead.
+ plugin: {
+ add: function(module, option, set) {
+ var proto = $.ui[module].prototype;
+ for(var i in set) {
+ proto.plugins[i] = proto.plugins[i] || [];
+ proto.plugins[i].push([option, set[i]]);
+ }
+ },
+ call: function(instance, name, args) {
+ var set = instance.plugins[name];
+ if(!set || !instance.element[0].parentNode) { return; }
+
+ for (var i = 0; i < set.length; i++) {
+ if (instance.options[set[i][0]]) {
+ set[i][1].apply(instance.element, args);
+ }
+ }
+ }
+ },
+
+ contains: function(a, b) {
+ return document.compareDocumentPosition
+ ? a.compareDocumentPosition(b) & 16
+ : a !== b && a.contains(b);
+ },
+
+ hasScroll: function(el, a) {
+
+ //If overflow is hidden, the element might have extra content, but the user wants to hide it
+ if ($(el).css('overflow') == 'hidden') { return false; }
+
+ var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop',
+ has = false;
+
+ if (el[scroll] > 0) { return true; }
+
+ // TODO: determine which cases actually cause this to happen
+ // if the element doesn't have the scroll set, see if it's possible to
+ // set the scroll
+ el[scroll] = 1;
+ has = (el[scroll] > 0);
+ el[scroll] = 0;
+ return has;
+ },
+
+ isOverAxis: function(x, reference, size) {
+ //Determines when x coordinate is over "b" element axis
+ return (x > reference) && (x < (reference + size));
+ },
+
+ isOver: function(y, x, top, left, height, width) {
+ //Determines when x, y coordinates is over "b" element
+ return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width);
+ },
+
+ keyCode: {
+ BACKSPACE: 8,
+ CAPS_LOCK: 20,
+ COMMA: 188,
+ CONTROL: 17,
+ DELETE: 46,
+ DOWN: 40,
+ END: 35,
+ ENTER: 13,
+ ESCAPE: 27,
+ HOME: 36,
+ INSERT: 45,
+ LEFT: 37,
+ NUMPAD_ADD: 107,
+ NUMPAD_DECIMAL: 110,
+ NUMPAD_DIVIDE: 111,
+ NUMPAD_ENTER: 108,
+ NUMPAD_MULTIPLY: 106,
+ NUMPAD_SUBTRACT: 109,
+ PAGE_DOWN: 34,
+ PAGE_UP: 33,
+ PERIOD: 190,
+ RIGHT: 39,
+ SHIFT: 16,
+ SPACE: 32,
+ TAB: 9,
+ UP: 38
+ }
+};
+
+// WAI-ARIA normalization
+if (isFF2) {
+ var attr = $.attr,
+ removeAttr = $.fn.removeAttr,
+ ariaNS = "http://www.w3.org/2005/07/aaa",
+ ariaState = /^aria-/,
+ ariaRole = /^wairole:/;
+
+ $.attr = function(elem, name, value) {
+ var set = value !== undefined;
+
+ return (name == 'role'
+ ? (set
+ ? attr.call(this, elem, name, "wairole:" + value)
+ : (attr.apply(this, arguments) || "").replace(ariaRole, ""))
+ : (ariaState.test(name)
+ ? (set
+ ? elem.setAttributeNS(ariaNS,
+ name.replace(ariaState, "aaa:"), value)
+ : attr.call(this, elem, name.replace(ariaState, "aaa:")))
+ : attr.apply(this, arguments)));
+ };
+
+ $.fn.removeAttr = function(name) {
+ return (ariaState.test(name)
+ ? this.each(function() {
+ this.removeAttributeNS(ariaNS, name.replace(ariaState, ""));
+ }) : removeAttr.call(this, name));
+ };
+}
+
+//jQuery plugins
+$.fn.extend({
+ remove: function() {
+ // Safari has a native remove event which actually removes DOM elements,
+ // so we have to use triggerHandler instead of trigger (#3037).
+ $("*", this).add(this).each(function() {
+ $(this).triggerHandler("remove");
+ });
+ return _remove.apply(this, arguments );
+ },
+
+ enableSelection: function() {
+ return this
+ .attr('unselectable', 'off')
+ .css('MozUserSelect', '')
+ .unbind('selectstart.ui');
+ },
+
+ disableSelection: function() {
+ return this
+ .attr('unselectable', 'on')
+ .css('MozUserSelect', 'none')
+ .bind('selectstart.ui', function() { return false; });
+ },
+
+ scrollParent: function() {
+ var scrollParent;
+ if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
+ scrollParent = this.parents().filter(function() {
+ return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
+ }).eq(0);
+ } else {
+ scrollParent = this.parents().filter(function() {
+ return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
+ }).eq(0);
+ }
+
+ return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
+ }
+});
+
+
+//Additional selectors
+$.extend($.expr[':'], {
+ data: function(elem, i, match) {
+ return !!$.data(elem, match[3]);
+ },
+
+ focusable: function(element) {
+ var nodeName = element.nodeName.toLowerCase(),
+ tabIndex = $.attr(element, 'tabindex');
+ return (/input|select|textarea|button|object/.test(nodeName)
+ ? !element.disabled
+ : 'a' == nodeName || 'area' == nodeName
+ ? element.href || !isNaN(tabIndex)
+ : !isNaN(tabIndex))
+ // the element and all of its ancestors must be visible
+ // the browser may report that the area is hidden
+ && !$(element)['area' == nodeName ? 'parents' : 'closest'](':hidden').length;
+ },
+
+ tabbable: function(element) {
+ var tabIndex = $.attr(element, 'tabindex');
+ return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(':focusable');
+ }
+});
+
+
+// $.widget is a factory to create jQuery plugins
+// taking some boilerplate code out of the plugin code
+function getter(namespace, plugin, method, args) {
+ function getMethods(type) {
+ var methods = $[namespace][plugin][type] || [];
+ return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods);
+ }
+
+ var methods = getMethods('getter');
+ if (args.length == 1 && typeof args[0] == 'string') {
+ methods = methods.concat(getMethods('getterSetter'));
+ }
+ return ($.inArray(method, methods) != -1);
+}
+
+$.widget = function(name, prototype) {
+ var namespace = name.split(".")[0];
+ name = name.split(".")[1];
+
+ // create plugin method
+ $.fn[name] = function(options) {
+ var isMethodCall = (typeof options == 'string'),
+ args = Array.prototype.slice.call(arguments, 1);
+
+ // prevent calls to internal methods
+ if (isMethodCall && options.substring(0, 1) == '_') {
+ return this;
+ }
+
+ // handle getter methods
+ if (isMethodCall && getter(namespace, name, options, args)) {
+ var instance = $.data(this[0], name);
+ return (instance ? instance[options].apply(instance, args)
+ : undefined);
+ }
+
+ // handle initialization and non-getter methods
+ return this.each(function() {
+ var instance = $.data(this, name);
+
+ // constructor
+ (!instance && !isMethodCall &&
+ $.data(this, name, new $[namespace][name](this, options))._init());
+
+ // method call
+ (instance && isMethodCall && $.isFunction(instance[options]) &&
+ instance[options].apply(instance, args));
+ });
+ };
+
+ // create widget constructor
+ $[namespace] = $[namespace] || {};
+ $[namespace][name] = function(element, options) {
+ var self = this;
+
+ this.namespace = namespace;
+ this.widgetName = name;
+ this.widgetEventPrefix = $[namespace][name].eventPrefix || name;
+ this.widgetBaseClass = namespace + '-' + name;
+
+ this.options = $.extend({},
+ $.widget.defaults,
+ $[namespace][name].defaults,
+ $.metadata && $.metadata.get(element)[name],
+ options);
+
+ this.element = $(element)
+ .bind('setData.' + name, function(event, key, value) {
+ if (event.target == element) {
+ return self._setData(key, value);
+ }
+ })
+ .bind('getData.' + name, function(event, key) {
+ if (event.target == element) {
+ return self._getData(key);
+ }
+ })
+ .bind('remove', function() {
+ return self.destroy();
+ });
+ };
+
+ // add widget prototype
+ $[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype);
+
+ // TODO: merge getter and getterSetter properties from widget prototype
+ // and plugin prototype
+ $[namespace][name].getterSetter = 'option';
+};
+
+$.widget.prototype = {
+ _init: function() {},
+ destroy: function() {
+ this.element.removeData(this.widgetName)
+ .removeClass(this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled')
+ .removeAttr('aria-disabled');
+ },
+
+ option: function(key, value) {
+ var options = key,
+ self = this;
+
+ if (typeof key == "string") {
+ if (value === undefined) {
+ return this._getData(key);
+ }
+ options = {};
+ options[key] = value;
+ }
+
+ $.each(options, function(key, value) {
+ self._setData(key, value);
+ });
+ },
+ _getData: function(key) {
+ return this.options[key];
+ },
+ _setData: function(key, value) {
+ this.options[key] = value;
+
+ if (key == 'disabled') {
+ this.element
+ [value ? 'addClass' : 'removeClass'](
+ this.widgetBaseClass + '-disabled' + ' ' +
+ this.namespace + '-state-disabled')
+ .attr("aria-disabled", value);
+ }
+ },
+
+ enable: function() {
+ this._setData('disabled', false);
+ },
+ disable: function() {
+ this._setData('disabled', true);
+ },
+
+ _trigger: function(type, event, data) {
+ var callback = this.options[type],
+ eventName = (type == this.widgetEventPrefix
+ ? type : this.widgetEventPrefix + type);
+
+ event = $.Event(event);
+ event.type = eventName;
+
+ // copy original event properties over to the new event
+ // this would happen if we could call $.event.fix instead of $.Event
+ // but we don't have a way to force an event to be fixed multiple times
+ if (event.originalEvent) {
+ for (var i = $.event.props.length, prop; i;) {
+ prop = $.event.props[--i];
+ event[prop] = event.originalEvent[prop];
+ }
+ }
+
+ this.element.trigger(event, data);
+
+ return !($.isFunction(callback) && callback.call(this.element[0], event, data) === false
+ || event.isDefaultPrevented());
+ }
+};
+
+$.widget.defaults = {
+ disabled: false
+};
+
+
+/** Mouse Interaction Plugin **/
+
+$.ui.mouse = {
+ _mouseInit: function() {
+ var self = this;
+
+ this.element
+ .bind('mousedown.'+this.widgetName, function(event) {
+ return self._mouseDown(event);
+ })
+ .bind('click.'+this.widgetName, function(event) {
+ if(self._preventClickEvent) {
+ self._preventClickEvent = false;
+ event.stopImmediatePropagation();
+ return false;
+ }
+ });
+
+ // Prevent text selection in IE
+ if ($.browser.msie) {
+ this._mouseUnselectable = this.element.attr('unselectable');
+ this.element.attr('unselectable', 'on');
+ }
+
+ this.started = false;
+ },
+
+ // TODO: make sure destroying one instance of mouse doesn't mess with
+ // other instances of mouse
+ _mouseDestroy: function() {
+ this.element.unbind('.'+this.widgetName);
+
+ // Restore text selection in IE
+ ($.browser.msie
+ && this.element.attr('unselectable', this._mouseUnselectable));
+ },
+
+ _mouseDown: function(event) {
+ // don't let more than one widget handle mouseStart
+ // TODO: figure out why we have to use originalEvent
+ event.originalEvent = event.originalEvent || {};
+ if (event.originalEvent.mouseHandled) { return; }
+
+ // we may have missed mouseup (out of window)
+ (this._mouseStarted && this._mouseUp(event));
+
+ this._mouseDownEvent = event;
+
+ var self = this,
+ btnIsLeft = (event.which == 1),
+ elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false);
+ if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
+ return true;
+ }
+
+ this.mouseDelayMet = !this.options.delay;
+ if (!this.mouseDelayMet) {
+ this._mouseDelayTimer = setTimeout(function() {
+ self.mouseDelayMet = true;
+ }, this.options.delay);
+ }
+
+ if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+ this._mouseStarted = (this._mouseStart(event) !== false);
+ if (!this._mouseStarted) {
+ event.preventDefault();
+ return true;
+ }
+ }
+
+ // these delegates are required to keep context
+ this._mouseMoveDelegate = function(event) {
+ return self._mouseMove(event);
+ };
+ this._mouseUpDelegate = function(event) {
+ return self._mouseUp(event);
+ };
+ $(document)
+ .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
+ .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
+
+ // preventDefault() is used to prevent the selection of text here -
+ // however, in Safari, this causes select boxes not to be selectable
+ // anymore, so this fix is needed
+ ($.browser.safari || event.preventDefault());
+
+ event.originalEvent.mouseHandled = true;
+ return true;
+ },
+
+ _mouseMove: function(event) {
+ // IE mouseup check - mouseup happened when mouse was out of window
+ if ($.browser.msie && !event.button) {
+ return this._mouseUp(event);
+ }
+
+ if (this._mouseStarted) {
+ this._mouseDrag(event);
+ return event.preventDefault();
+ }
+
+ if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+ this._mouseStarted =
+ (this._mouseStart(this._mouseDownEvent, event) !== false);
+ (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
+ }
+
+ return !this._mouseStarted;
+ },
+
+ _mouseUp: function(event) {
+ $(document)
+ .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
+ .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
+
+ if (this._mouseStarted) {
+ this._mouseStarted = false;
+ this._preventClickEvent = (event.target == this._mouseDownEvent.target);
+ this._mouseStop(event);
+ }
+
+ return false;
+ },
+
+ _mouseDistanceMet: function(event) {
+ return (Math.max(
+ Math.abs(this._mouseDownEvent.pageX - event.pageX),
+ Math.abs(this._mouseDownEvent.pageY - event.pageY)
+ ) >= this.options.distance
+ );
+ },
+
+ _mouseDelayMet: function(event) {
+ return this.mouseDelayMet;
+ },
+
+ // These are placeholder methods, to be overriden by extending plugin
+ _mouseStart: function(event) {},
+ _mouseDrag: function(event) {},
+ _mouseStop: function(event) {},
+ _mouseCapture: function(event) { return true; }
+};
+
+$.ui.mouse.defaults = {
+ cancel: null,
+ distance: 1,
+ delay: 0
+};
+
+})(jQuery);
diff --git a/examples/lessons/6_English_whatsThisLetter/js/ui.scoreboard.js b/examples/lessons/6_English_whatsThisLetter/js/ui.scoreboard.js
new file mode 100755
index 0000000..53a930a
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisLetter/js/ui.scoreboard.js
@@ -0,0 +1,107 @@
+(function($){
+ $.widget('ui.scoreboard',
+ {
+ getScore : function(){
+ return this._getData('score');
+ },
+ setScore : function(newScore){
+ this._setData('score', parseInt(newScore));
+ this._refresh();
+ },
+ getTotal : function(){
+ return this._getData('total');
+ },
+ setTotal : function(newTotal){
+ this._setData('total', parseInt(newTotal));
+ this._refresh();
+ },
+ reset : function(){
+ this._setData('score', this._getData('initialScore'));
+ this._setData('total', this._getData('initialTotal'));
+ this._refresh();
+ },
+ inc : function(val){
+ var incVal = parseInt(val) || 1;
+ this._setData('score', this._getData('score') + incVal);
+ this._refresh();
+ if(this._getData('winScore') === this._getData('score')){
+ this.element.trigger('winGame');
+ }
+ },
+ incTotal : function(val){
+ var incVal = parseInt(val) || 1;
+ this._setData('total', this._getData('total') + incVal);
+ this._refresh();
+ },
+ dec : function(val){
+ var decVal = parseInt(val) || 1;
+ this._setData('score', this._getData('score') - decVal);
+ this._refresh();
+ },
+ decTotal : function(val){
+ var decVal = parseInt(val) || 1;
+ this._setData('total', this._getData('total') - decVal);
+ this._refresh();
+ },
+ _init : function(){
+
+ var divDisplay = "inline";
+ var score = this.options.score;
+ var total = this.options.total;
+ var layoutId = "h";
+ var self = this;
+
+
+ this._setData('initialScore', parseInt(this.options.score));
+ this._setData('initialTotal', parseInt(this.options.total));
+ this._setData('score', parseInt(this.options.score));
+ this._setData('total', parseInt(this.options.total));
+ this._setData('winScore', parseInt(this.options.winningScore) || 0);
+
+ if(this.options.layout === "vertical"){
+ layoutId = "v";
+ }
+
+ this.evWinGame = document.createEvent('Events');
+
+ this.element.addClass('ui-scoreboard-container-' + layoutId +
+ ' ui-widget ui-widget-content ui-corner-all');
+
+ var clone = $('<div>')
+ .addClass('ui-scoreboard-spacing-' + layoutId);
+ this._scoreText = $("<div>Score</div>")
+ .addClass('ui-scoreboard-spacing-'+ layoutId +
+ ' ui-corner-all ui-scoreboard-text')
+ .appendTo(this.element);
+ this._score = $("<div>" + score + "</div>")
+ .addClass('ui-scoreboard-spacing-' + layoutId +
+ ' ui-scoreboard-number-' + layoutId)
+ .appendTo(this.element);
+ $("<div>Total</div>")
+ .addClass('ui-scoreboard-spacing-' + layoutId +
+ ' ui-corner-all ' +
+ 'ui-scoreboard-text')
+ .appendTo(this.element);
+ this._total = $("<div>" + total + "</div>")
+ .addClass('ui-scoreboard-spacing-' + layoutId +
+ ' ui-scoreboard-number-' + layoutId)
+ .appendTo(this.element);
+ },
+ _refresh : function(){
+ this._score.text(this._getData('score'));
+ this._total.text(this._getData('total'));
+ },
+ destroy : function(){
+ this.element.remove();
+ $.widget.prototype.destroy.apply(this, arguments);
+ }
+
+
+ });
+
+ $.ui.scoreboard.getter = ['getScore', 'getTotal'];
+ $.ui.scoreboard.defaults = {
+ score: 0, total: 0, layout: "horizontal", winningScore: 0
+ };
+
+ })(jQuery); \ No newline at end of file
diff --git a/examples/lessons/6_English_whatsThisWord/assets/audio/apple.wav b/examples/lessons/6_English_whatsThisWord/assets/audio/apple.wav
new file mode 100755
index 0000000..aa15243
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/audio/apple.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/audio/banana.wav b/examples/lessons/6_English_whatsThisWord/assets/audio/banana.wav
new file mode 100755
index 0000000..5066c59
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/audio/banana.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/audio/boat.wav b/examples/lessons/6_English_whatsThisWord/assets/audio/boat.wav
new file mode 100755
index 0000000..5131b2a
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/audio/boat.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/audio/book.wav b/examples/lessons/6_English_whatsThisWord/assets/audio/book.wav
new file mode 100755
index 0000000..dcdb483
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/audio/book.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/audio/bus.wav b/examples/lessons/6_English_whatsThisWord/assets/audio/bus.wav
new file mode 100755
index 0000000..8db7671
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/audio/bus.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/audio/cake.wav b/examples/lessons/6_English_whatsThisWord/assets/audio/cake.wav
new file mode 100755
index 0000000..07e78b6
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/audio/cake.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/audio/car.wav b/examples/lessons/6_English_whatsThisWord/assets/audio/car.wav
new file mode 100755
index 0000000..2733bfc
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/audio/car.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/audio/correct.ogg b/examples/lessons/6_English_whatsThisWord/assets/audio/correct.ogg
new file mode 100755
index 0000000..a0d9e3a
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/audio/correct.ogg
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/audio/cow.wav b/examples/lessons/6_English_whatsThisWord/assets/audio/cow.wav
new file mode 100755
index 0000000..edcece5
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/audio/cow.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/audio/flower.wav b/examples/lessons/6_English_whatsThisWord/assets/audio/flower.wav
new file mode 100755
index 0000000..c8710af
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/audio/flower.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/audio/hat.wav b/examples/lessons/6_English_whatsThisWord/assets/audio/hat.wav
new file mode 100755
index 0000000..62ab73e
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/audio/hat.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/audio/incorrect.ogg b/examples/lessons/6_English_whatsThisWord/assets/audio/incorrect.ogg
new file mode 100755
index 0000000..4805e55
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/audio/incorrect.ogg
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/audio/kite.wav b/examples/lessons/6_English_whatsThisWord/assets/audio/kite.wav
new file mode 100755
index 0000000..6d8c65f
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/audio/kite.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/audio/lamp.wav b/examples/lessons/6_English_whatsThisWord/assets/audio/lamp.wav
new file mode 100755
index 0000000..d174df3
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/audio/lamp.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/audio/pig.wav b/examples/lessons/6_English_whatsThisWord/assets/audio/pig.wav
new file mode 100755
index 0000000..9b45e34
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/audio/pig.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/audio/pigeon.wav b/examples/lessons/6_English_whatsThisWord/assets/audio/pigeon.wav
new file mode 100755
index 0000000..4146930
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/audio/pigeon.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/audio/rat.wav b/examples/lessons/6_English_whatsThisWord/assets/audio/rat.wav
new file mode 100755
index 0000000..9d8723d
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/audio/rat.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/audio/tomato.wav b/examples/lessons/6_English_whatsThisWord/assets/audio/tomato.wav
new file mode 100755
index 0000000..86f1144
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/audio/tomato.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/audio/tree.wav b/examples/lessons/6_English_whatsThisWord/assets/audio/tree.wav
new file mode 100755
index 0000000..3444ed5
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/audio/tree.wav
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/ant.png b/examples/lessons/6_English_whatsThisWord/assets/image/ant.png
new file mode 100755
index 0000000..82a26bb
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/ant.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/apple.png b/examples/lessons/6_English_whatsThisWord/assets/image/apple.png
new file mode 100755
index 0000000..a09c8c5
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/apple.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/banana.png b/examples/lessons/6_English_whatsThisWord/assets/image/banana.png
new file mode 100755
index 0000000..5c1f1a1
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/banana.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/bg_footer.png b/examples/lessons/6_English_whatsThisWord/assets/image/bg_footer.png
new file mode 100755
index 0000000..8982264
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/bg_footer.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/bg_header.png b/examples/lessons/6_English_whatsThisWord/assets/image/bg_header.png
new file mode 100755
index 0000000..98213f7
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/bg_header.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/bg_title_block.png b/examples/lessons/6_English_whatsThisWord/assets/image/bg_title_block.png
new file mode 100755
index 0000000..2c9dacf
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/bg_title_block.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/boat.png b/examples/lessons/6_English_whatsThisWord/assets/image/boat.png
new file mode 100755
index 0000000..cc41d58
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/boat.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/book.png b/examples/lessons/6_English_whatsThisWord/assets/image/book.png
new file mode 100755
index 0000000..ec53795
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/book.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/btn_back.png b/examples/lessons/6_English_whatsThisWord/assets/image/btn_back.png
new file mode 100755
index 0000000..d9fbf14
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/btn_back.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/btn_back_hover.png b/examples/lessons/6_English_whatsThisWord/assets/image/btn_back_hover.png
new file mode 100755
index 0000000..0911fcc
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/btn_back_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/btn_help.png b/examples/lessons/6_English_whatsThisWord/assets/image/btn_help.png
new file mode 100755
index 0000000..6753e9c
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/btn_help.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/btn_help_hover.png b/examples/lessons/6_English_whatsThisWord/assets/image/btn_help_hover.png
new file mode 100755
index 0000000..d3ccd92
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/btn_help_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/btn_next.png b/examples/lessons/6_English_whatsThisWord/assets/image/btn_next.png
new file mode 100755
index 0000000..9d70993
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/btn_next.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/btn_next_hover.png b/examples/lessons/6_English_whatsThisWord/assets/image/btn_next_hover.png
new file mode 100755
index 0000000..2cd4d37
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/btn_next_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/btn_ole.png b/examples/lessons/6_English_whatsThisWord/assets/image/btn_ole.png
new file mode 100755
index 0000000..0e775e9
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/btn_ole.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/btn_ole_hover.png b/examples/lessons/6_English_whatsThisWord/assets/image/btn_ole_hover.png
new file mode 100755
index 0000000..c43c5f7
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/btn_ole_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/btn_play_again.png b/examples/lessons/6_English_whatsThisWord/assets/image/btn_play_again.png
new file mode 100755
index 0000000..3594d18
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/btn_play_again.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/btn_play_again_hover.png b/examples/lessons/6_English_whatsThisWord/assets/image/btn_play_again_hover.png
new file mode 100755
index 0000000..ebb8f8c
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/btn_play_again_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/btn_play_again_mouse_down.png b/examples/lessons/6_English_whatsThisWord/assets/image/btn_play_again_mouse_down.png
new file mode 100755
index 0000000..07d6e45
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/btn_play_again_mouse_down.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/btn_start.png b/examples/lessons/6_English_whatsThisWord/assets/image/btn_start.png
new file mode 100755
index 0000000..32e5f20
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/btn_start.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/btn_start_hover.png b/examples/lessons/6_English_whatsThisWord/assets/image/btn_start_hover.png
new file mode 100755
index 0000000..811ce78
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/btn_start_hover.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/btn_start_mouse_down.png b/examples/lessons/6_English_whatsThisWord/assets/image/btn_start_mouse_down.png
new file mode 100755
index 0000000..5acd43b
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/btn_start_mouse_down.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/bus.png b/examples/lessons/6_English_whatsThisWord/assets/image/bus.png
new file mode 100755
index 0000000..d0db371
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/bus.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/cake.png b/examples/lessons/6_English_whatsThisWord/assets/image/cake.png
new file mode 100755
index 0000000..569e7fd
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/cake.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/car.png b/examples/lessons/6_English_whatsThisWord/assets/image/car.png
new file mode 100755
index 0000000..72b7a47
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/car.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/cow.png b/examples/lessons/6_English_whatsThisWord/assets/image/cow.png
new file mode 100755
index 0000000..205fd8e
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/cow.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/flower.png b/examples/lessons/6_English_whatsThisWord/assets/image/flower.png
new file mode 100755
index 0000000..11ef0e7
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/flower.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/hat.png b/examples/lessons/6_English_whatsThisWord/assets/image/hat.png
new file mode 100755
index 0000000..691ec6d
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/hat.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/help.png b/examples/lessons/6_English_whatsThisWord/assets/image/help.png
new file mode 100755
index 0000000..d8bb5c3
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/help.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/kite.png b/examples/lessons/6_English_whatsThisWord/assets/image/kite.png
new file mode 100755
index 0000000..c07a545
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/kite.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/ladybird.png b/examples/lessons/6_English_whatsThisWord/assets/image/ladybird.png
new file mode 100755
index 0000000..5b40810
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/ladybird.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/lamp.png b/examples/lessons/6_English_whatsThisWord/assets/image/lamp.png
new file mode 100755
index 0000000..ad94f45
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/lamp.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/piegon.png b/examples/lessons/6_English_whatsThisWord/assets/image/piegon.png
new file mode 100755
index 0000000..6c0edd7
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/piegon.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/pig.png b/examples/lessons/6_English_whatsThisWord/assets/image/pig.png
new file mode 100755
index 0000000..c523e35
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/pig.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/rat.png b/examples/lessons/6_English_whatsThisWord/assets/image/rat.png
new file mode 100755
index 0000000..44934a4
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/rat.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/socks.png b/examples/lessons/6_English_whatsThisWord/assets/image/socks.png
new file mode 100755
index 0000000..0e85c41
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/socks.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/title_block_lt.png b/examples/lessons/6_English_whatsThisWord/assets/image/title_block_lt.png
new file mode 100755
index 0000000..4696182
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/title_block_lt.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/title_block_rt.png b/examples/lessons/6_English_whatsThisWord/assets/image/title_block_rt.png
new file mode 100755
index 0000000..37cc44a
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/title_block_rt.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/tomato.png b/examples/lessons/6_English_whatsThisWord/assets/image/tomato.png
new file mode 100755
index 0000000..f92c972
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/tomato.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/assets/image/tree.png b/examples/lessons/6_English_whatsThisWord/assets/image/tree.png
new file mode 100755
index 0000000..d3df317
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/assets/image/tree.png
Binary files differ
diff --git a/examples/lessons/6_English_whatsThisWord/css/lesson.css b/examples/lessons/6_English_whatsThisWord/css/lesson.css
new file mode 100755
index 0000000..764a204
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/css/lesson.css
@@ -0,0 +1,247 @@
+@CHARSET "UTF-8";
+/****** Page Styles ****/
+
+/* Designed for 1200*900 px screen resolution */
+
+body {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 10pt;
+ margin: 0px;
+ background-color: #FFFFCC;
+}
+#header {
+ background-image: url(../assets/image/bg_header.png);
+ background-repeat: repeat-x;
+ height: 75px;
+ width: 100%;
+ position: absolute;
+ left: 0px;
+ top: 0px;
+}
+#topbtn_left {
+ float: left;
+ height: 60px;
+ width: 60px;
+ padding-top: 6px;
+ padding-left: 15px;
+}
+
+
+ .linkBack{
+ width: 60px; height: 59px;
+ background:url(../assets/image/btn_back.png);
+ }
+ .linkBack:hover{
+ background:url(../assets/image/btn_back_hover.png);
+ }
+
+#lesson_title {
+ float: left;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 16pt;
+ font-weight: bold;
+ color: #FFFFFF;
+ margin-left: 10px;
+ background-image: url(../assets/image/bg_title_block.png);
+}
+#topbtn_right {
+ float: right;
+ height: 60px;
+ width: 60px;
+ padding-top: 6px;
+ padding-right: 15px;
+}
+ #linkHelp{
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_help.png);
+ }
+ #linkHelp:hover{
+ background:url(../assets/image/btn_help_hover.png);
+ }
+ #linkOle{
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_ole.png);
+ }
+ #linkOle:hover{
+ background:url(../assets/image/btn_ole_hover.png);
+ }
+ .linkNext{var bindImgCss = {
+ 'float':'left',
+ 'width': '450px',
+ 'height':'40px',
+ 'margin-top':'0.25em',
+ 'text-align':'center',
+ 'padding-bottom':'0.3em'
+ };
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_next.png);
+ }
+ .linkNext:hover{
+ background:url(../assets/image/btn_next_hover.png);
+ }
+#footer {
+ position:relative;
+ background-image: url(../assets/image/bg_footer.png);
+ background-repeat: repeat-x;
+ height: 75px;
+ width: 100%;
+ left: 0px;
+ bottom: 0px;
+}
+#score_box {
+ float: left;
+ padding-left: 5px;
+ padding-top: 0.7em;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #FFFF00;
+ font-size: 16pt;
+ font-weight: bold;
+}
+#botbtn_right {
+ float: right;
+ height: 55px;
+ padding-right: 5px;
+ padding-top: 10px;
+}
+ #linkCheck{
+ margin: 1em 3em 0 0;
+ width: 101px; height: 30px;
+ background-image: url(../assets/image/check.png);
+ }
+
+ #linkStart{
+ width: 251px; height: 55px;
+ background:url(../assets/image/btn_start.png);
+ }
+ #linkStart:hover{
+ background:url(../assets/image/btn_start_hover.png);
+ }
+ #linkStart:active{
+ background:url(../assets/image/btn_start_mouse_down.png);
+ }
+ #linkPlayAgain{
+ width: 251px; height: 55px;
+ background:url(../assets/image/btn_play_again.png);
+ }
+ #linkPlayAgain:hover{
+ background:url(../assets/image/btn_play_again_hover.png);
+ }
+ #linkPlayAgain:active{
+ background:url(../assets/image/btn_play_again_mouse_down.png);
+ }
+#linkNextLesson{
+ position:absolute;
+ bottom: 75px;
+ right: 10px;
+}
+#linkPrevLesson{
+ position:absolute;
+ bottom: 75px;
+ left: 10px;
+}
+
+/**** End of the page style ****/
+
+/**** Game Styles ****/
+
+a{
+ color:#FFFFCC;
+}
+#currentTitle{
+ width: 150px;
+ height: 80px;
+ font:25px/30px "Courier New", Courier, monospace;
+ font-weight: bold;
+ color: red;
+}
+#content{
+ position:relative;
+ margin: 0 auto;
+ margin-top: 75px;
+ width: 1198px;
+ height: 560px;
+
+}
+
+ #questionSection{
+ position:absolute;
+ top: 150px;
+ left: 270px;
+ width: 350px;
+ text-align:center;
+ }
+ #question{
+ position:relative;
+ display:block;
+ margin-top: 0.25em;
+ font: 40px Arial, Helvetica, sans-serif;
+ color: #000;
+ }
+ #answers{
+ position:relative;
+ font: 40px Arial, Helvetica, sans-serif;
+ color: #000;
+ text-align:center;
+ }
+
+ input.blankBox{
+ font: 35px Verdana, Geneva, Arial, Helvetica, sans-serif;
+ height:45px;
+ width: 150px;
+ color:red;
+
+ text-align:center;
+ }
+ .focus {
+ /* border: 2px solid #AA88FF;*/
+ background-color: #FFEEAA;
+ }
+ .correct{
+ background-color: #C0F9F3;
+ }
+ .incorrect{
+ background-color: #FFFF00;
+ }
+ .backOpaque{
+ background-color: #A4A4A4;
+ opacity: 0.2;
+ }
+
+#help{
+ display:none;
+ position:absolute;
+ right: 60px;
+ top: 75px;;
+ width: 256px;
+ height: 600px;
+ background:url(../assets/image/help.png);
+ z-index:40;
+}
+
+
+ #gameOver{
+ opacity: 1;
+ display:none;
+ position:absolute;
+ top:45%;
+ left: 30%;
+ color: blue;
+ text-align:center;
+ font : bold 45px/65px Arial Black, Times New Roman;
+ }
+ #gameOverInfo{
+ margin-top: 35px;
+ text-align:center;
+ font: 20px/25px Helvetica, Geneva, Arial, Verdana, sans-serif;
+ font-weight:bold;
+ color:#FF0000;
+
+ }
+ .specialText{
+ margin-top: 1em;
+ font: 20px/25px Helvetica, Geneva, Arial, Verdana, sans-serif;
+ font-weight:bold;
+ color:#FF9900;
+ border-bottom: 2px dotted #CCC;
+
+ }
diff --git a/examples/lessons/6_English_whatsThisWord/css/ui.scoreboard.css b/examples/lessons/6_English_whatsThisWord/css/ui.scoreboard.css
new file mode 100755
index 0000000..11cdbb5
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/css/ui.scoreboard.css
@@ -0,0 +1,62 @@
+.ui-scoreboard-container-h{
+max-width: 800em;
+max-height: 200px;
+float:left;
+padding-top:0.4em;
+padding-bottom:0.4em;
+}
+
+.ui-scoreboard-spacing-h{
+max-width: 200em;
+max-height: 300em;
+display:inline;
+margin-left:0.2em;
+margin-right:0.4em;
+}
+
+.ui-scoreboard-text{
+font-size:larger;
+text-align: center;
+}
+
+.ui-scoreboard-number-h {
+background-color:black;
+color: white;
+padding-left:0.4em;
+padding-right:0.4em;
+font-size:larger;
+}
+
+.ui-scoreboard-button{
+float:right;
+cursor:pointer;
+}
+
+button .ui-scoreboard-icon{
+float: left;
+margin-right:0.3em;
+}
+.ui-scoreboard-container-v{
+max-width: 200px;
+max-height: 400px;
+float:left;
+padding-top:0.4em;
+padding-bottom:0.4em;
+}
+.ui-scoreboard-spacing-v{
+display:block;
+margin: 0.4em;
+}
+
+.ui-scoreboard-number-v{
+background-color:black;
+color: white;
+width: 1em;
+text-align:center;
+margin-left:auto;
+margin-right: auto;
+padding:0.4em;
+font-size:larger;
+}
+
+
diff --git a/examples/lessons/6_English_whatsThisWord/index.html b/examples/lessons/6_English_whatsThisWord/index.html
new file mode 100755
index 0000000..f822dea
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/index.html
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Class 6 English What This Word</title>
+ <meta name="keywords" content="karma,javascript,html5,sugar,sugarlabs,gsoc,ole,nepal" />
+ <link type="text/css" rel="stylesheet" href="css/ui.scoreboard.css" />
+ <link type="text/css" rel="stylesheet" href="css/lesson.css" />
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <link type="image/ico" rel="icon" href="../../assets/default/image/favicon.ico" />
+ <script type="text/javascript" src="js/jquery-1.4.js"></script>
+ <script type="text/javascript" src="js/ui.core.js"></script>
+ <script type="text/javascript" src="js/ui.scoreboard.js"></script>
+ <script type="text/javascript" src="js/karma.js"></script>
+ <script type="text/javascript" src="js/jquery.watermarkinput.js"></script>
+ <script type="text/javascript" src="js/lesson.js"></script>
+</head>
+<body>
+ <div id="header">
+ <div id="topbtn_left"><a href="#"><div id="linkBackLesson" class="linkBack"></div></a></div>
+ <div id="lesson_title">
+ <img src="assets/image/title_block_lt.png" width="33" height="75" align="absmiddle" />
+ What This Word <span id="currentTitle"></span>
+ <img src="assets/image/title_block_rt.png" width="33" height="75" align="absmiddle" />
+ </div>
+ <div id="topbtn_right"><a href="#"><div id="linkHelp"></div></a></div>
+ <div id="topbtn_right"><a href="http://olenepal.org"><div id="linkOle"></div></a></div>
+ </div>
+
+ <div id="content"></div>
+ <div id="help"></div>
+ <div id="gameOver"></div>
+ <form name="delayForm">
+ <input type="hidden" name="delayval" size="5">
+ </form>
+
+ <div id="footer">
+ <div id="botbtn_right"><a href="#"><div id="linkPlayAgain"></div></a></div>
+ <div id="botbtn_right"><a href="#"><div id="linkStart"></div></a></div>
+ <div id="score_box"></div>
+ </div>
+</body>
+</html>
diff --git a/examples/lessons/6_English_whatsThisWord/js/jquery-1.4.js b/examples/lessons/6_English_whatsThisWord/js/jquery-1.4.js
new file mode 100755
index 0000000..a448490
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/js/jquery-1.4.js
@@ -0,0 +1,5999 @@
+/*!
+ * jQuery JavaScript Library v1.4
+ * http://jquery.com/
+ *
+ * Copyright 2010, John Resig
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://docs.jquery.com/License
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ * Copyright 2010, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ *
+ * Date: Wed Jan 13 15:23:05 2010 -0500
+ */
+(function( window, undefined ) {
+
+// Define a local copy of jQuery
+var jQuery = function( selector, context ) {
+ // The jQuery object is actually just the init constructor 'enhanced'
+ return new jQuery.fn.init( selector, context );
+ },
+
+ // Map over jQuery in case of overwrite
+ _jQuery = window.jQuery,
+
+ // Map over the $ in case of overwrite
+ _$ = window.$,
+
+ // Use the correct document accordingly with window argument (sandbox)
+ document = window.document,
+
+ // A central reference to the root jQuery(document)
+ rootjQuery,
+
+ // A simple way to check for HTML strings or ID strings
+ // (both of which we optimize for)
+ quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,
+
+ // Is it a simple selector
+ isSimple = /^.[^:#\[\.,]*$/,
+
+ // Check if a string has a non-whitespace character in it
+ rnotwhite = /\S/,
+
+ // Used for trimming whitespace
+ rtrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g,
+
+ // Match a standalone tag
+ rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
+
+ // Keep a UserAgent string for use with jQuery.browser
+ userAgent = navigator.userAgent,
+
+ // For matching the engine and version of the browser
+ browserMatch,
+
+ // Has the ready events already been bound?
+ readyBound = false,
+
+ // The functions to execute on DOM ready
+ readyList = [],
+
+ // The ready event handler
+ DOMContentLoaded,
+
+ // Save a reference to some core methods
+ toString = Object.prototype.toString,
+ hasOwnProperty = Object.prototype.hasOwnProperty,
+ push = Array.prototype.push,
+ slice = Array.prototype.slice,
+ indexOf = Array.prototype.indexOf;
+
+jQuery.fn = jQuery.prototype = {
+ init: function( selector, context ) {
+ var match, elem, ret, doc;
+
+ // Handle $(""), $(null), or $(undefined)
+ if ( !selector ) {
+ return this;
+ }
+
+ // Handle $(DOMElement)
+ if ( selector.nodeType ) {
+ this.context = this[0] = selector;
+ this.length = 1;
+ return this;
+ }
+
+ // Handle HTML strings
+ if ( typeof selector === "string" ) {
+ // Are we dealing with HTML string or an ID?
+ match = quickExpr.exec( selector );
+
+ // Verify a match, and that no context was specified for #id
+ if ( match && (match[1] || !context) ) {
+
+ // HANDLE: $(html) -> $(array)
+ if ( match[1] ) {
+ doc = (context ? context.ownerDocument || context : document);
+
+ // If a single string is passed in and it's a single tag
+ // just do a createElement and skip the rest
+ ret = rsingleTag.exec( selector );
+
+ if ( ret ) {
+ if ( jQuery.isPlainObject( context ) ) {
+ selector = [ document.createElement( ret[1] ) ];
+ jQuery.fn.attr.call( selector, context, true );
+
+ } else {
+ selector = [ doc.createElement( ret[1] ) ];
+ }
+
+ } else {
+ ret = buildFragment( [ match[1] ], [ doc ] );
+ selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
+ }
+
+ // HANDLE: $("#id")
+ } else {
+ elem = document.getElementById( match[2] );
+
+ if ( elem ) {
+ // Handle the case where IE and Opera return items
+ // by name instead of ID
+ if ( elem.id !== match[2] ) {
+ return rootjQuery.find( selector );
+ }
+
+ // Otherwise, we inject the element directly into the jQuery object
+ this.length = 1;
+ this[0] = elem;
+ }
+
+ this.context = document;
+ this.selector = selector;
+ return this;
+ }
+
+ // HANDLE: $("TAG")
+ } else if ( !context && /^\w+$/.test( selector ) ) {
+ this.selector = selector;
+ this.context = document;
+ selector = document.getElementsByTagName( selector );
+
+ // HANDLE: $(expr, $(...))
+ } else if ( !context || context.jquery ) {
+ return (context || rootjQuery).find( selector );
+
+ // HANDLE: $(expr, context)
+ // (which is just equivalent to: $(context).find(expr)
+ } else {
+ return jQuery( context ).find( selector );
+ }
+
+ // HANDLE: $(function)
+ // Shortcut for document ready
+ } else if ( jQuery.isFunction( selector ) ) {
+ return rootjQuery.ready( selector );
+ }
+
+ if (selector.selector !== undefined) {
+ this.selector = selector.selector;
+ this.context = selector.context;
+ }
+
+ return jQuery.isArray( selector ) ?
+ this.setArray( selector ) :
+ jQuery.makeArray( selector, this );
+ },
+
+ // Start with an empty selector
+ selector: "",
+
+ // The current version of jQuery being used
+ jquery: "1.4",
+
+ // The default length of a jQuery object is 0
+ length: 0,
+
+ // The number of elements contained in the matched element set
+ size: function() {
+ return this.length;
+ },
+
+ toArray: function() {
+ return slice.call( this, 0 );
+ },
+
+ // Get the Nth element in the matched element set OR
+ // Get the whole matched element set as a clean array
+ get: function( num ) {
+ return num == null ?
+
+ // Return a 'clean' array
+ this.toArray() :
+
+ // Return just the object
+ ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
+ },
+
+ // Take an array of elements and push it onto the stack
+ // (returning the new matched element set)
+ pushStack: function( elems, name, selector ) {
+ // Build a new jQuery matched element set
+ var ret = jQuery( elems || null );
+
+ // Add the old object onto the stack (as a reference)
+ ret.prevObject = this;
+
+ ret.context = this.context;
+
+ if ( name === "find" ) {
+ ret.selector = this.selector + (this.selector ? " " : "") + selector;
+ } else if ( name ) {
+ ret.selector = this.selector + "." + name + "(" + selector + ")";
+ }
+
+ // Return the newly-formed element set
+ return ret;
+ },
+
+ // Force the current matched set of elements to become
+ // the specified array of elements (destroying the stack in the process)
+ // You should use pushStack() in order to do this, but maintain the stack
+ setArray: function( elems ) {
+ // Resetting the length to 0, then using the native Array push
+ // is a super-fast way to populate an object with array-like properties
+ this.length = 0;
+ push.apply( this, elems );
+
+ return this;
+ },
+
+ // Execute a callback for every element in the matched set.
+ // (You can seed the arguments with an array of args, but this is
+ // only used internally.)
+ each: function( callback, args ) {
+ return jQuery.each( this, callback, args );
+ },
+
+ ready: function( fn ) {
+ // Attach the listeners
+ jQuery.bindReady();
+
+ // If the DOM is already ready
+ if ( jQuery.isReady ) {
+ // Execute the function immediately
+ fn.call( document, jQuery );
+
+ // Otherwise, remember the function for later
+ } else if ( readyList ) {
+ // Add the function to the wait list
+ readyList.push( fn );
+ }
+
+ return this;
+ },
+
+ eq: function( i ) {
+ return i === -1 ?
+ this.slice( i ) :
+ this.slice( i, +i + 1 );
+ },
+
+ first: function() {
+ return this.eq( 0 );
+ },
+
+ last: function() {
+ return this.eq( -1 );
+ },
+
+ slice: function() {
+ return this.pushStack( slice.apply( this, arguments ),
+ "slice", slice.call(arguments).join(",") );
+ },
+
+ map: function( callback ) {
+ return this.pushStack( jQuery.map(this, function( elem, i ) {
+ return callback.call( elem, i, elem );
+ }));
+ },
+
+ end: function() {
+ return this.prevObject || jQuery(null);
+ },
+
+ // For internal use only.
+ // Behaves like an Array's method, not like a jQuery method.
+ push: push,
+ sort: [].sort,
+ splice: [].splice
+};
+
+// Give the init function the jQuery prototype for later instantiation
+jQuery.fn.init.prototype = jQuery.fn;
+
+jQuery.extend = jQuery.fn.extend = function() {
+ // copy reference to target object
+ var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy;
+
+ // Handle a deep copy situation
+ if ( typeof target === "boolean" ) {
+ deep = target;
+ target = arguments[1] || {};
+ // skip the boolean and the target
+ i = 2;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
+ target = {};
+ }
+
+ // extend jQuery itself if only one argument is passed
+ if ( length === i ) {
+ target = this;
+ --i;
+ }
+
+ for ( ; i < length; i++ ) {
+ // Only deal with non-null/undefined values
+ if ( (options = arguments[ i ]) != null ) {
+ // Extend the base object
+ for ( name in options ) {
+ src = target[ name ];
+ copy = options[ name ];
+
+ // Prevent never-ending loop
+ if ( target === copy ) {
+ continue;
+ }
+
+ // Recurse if we're merging object literal values or arrays
+ if ( deep && copy && ( jQuery.isPlainObject(copy) || jQuery.isArray(copy) ) ) {
+ var clone = src && ( jQuery.isPlainObject(src) || jQuery.isArray(src) ) ? src
+ : jQuery.isArray(copy) ? [] : {};
+
+ // Never move original objects, clone them
+ target[ name ] = jQuery.extend( deep, clone, copy );
+
+ // Don't bring in undefined values
+ } else if ( copy !== undefined ) {
+ target[ name ] = copy;
+ }
+ }
+ }
+ }
+
+ // Return the modified object
+ return target;
+};
+
+jQuery.extend({
+ noConflict: function( deep ) {
+ window.$ = _$;
+
+ if ( deep ) {
+ window.jQuery = _jQuery;
+ }
+
+ return jQuery;
+ },
+
+ // Is the DOM ready to be used? Set to true once it occurs.
+ isReady: false,
+
+ // Handle when the DOM is ready
+ ready: function() {
+ // Make sure that the DOM is not already loaded
+ if ( !jQuery.isReady ) {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( !document.body ) {
+ return setTimeout( jQuery.ready, 13 );
+ }
+
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If there are functions bound, to execute
+ if ( readyList ) {
+ // Execute all of them
+ var fn, i = 0;
+ while ( (fn = readyList[ i++ ]) ) {
+ fn.call( document, jQuery );
+ }
+
+ // Reset the list of functions
+ readyList = null;
+ }
+
+ // Trigger any bound ready events
+ if ( jQuery.fn.triggerHandler ) {
+ jQuery( document ).triggerHandler( "ready" );
+ }
+ }
+ },
+
+ bindReady: function() {
+ if ( readyBound ) {
+ return;
+ }
+
+ readyBound = true;
+
+ // Catch cases where $(document).ready() is called after the
+ // browser event has already occurred.
+ if ( document.readyState === "complete" ) {
+ return jQuery.ready();
+ }
+
+ // Mozilla, Opera and webkit nightlies currently support this event
+ if ( document.addEventListener ) {
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+
+ // A fallback to window.onload, that will always work
+ window.addEventListener( "load", jQuery.ready, false );
+
+ // If IE event model is used
+ } else if ( document.attachEvent ) {
+ // ensure firing before onload,
+ // maybe late but safe also for iframes
+ document.attachEvent("onreadystatechange", DOMContentLoaded);
+
+ // A fallback to window.onload, that will always work
+ window.attachEvent( "onload", jQuery.ready );
+
+ // If IE and not a frame
+ // continually check to see if the document is ready
+ var toplevel = false;
+
+ try {
+ toplevel = window.frameElement == null;
+ } catch(e) {}
+
+ if ( document.documentElement.doScroll && toplevel ) {
+ doScrollCheck();
+ }
+ }
+ },
+
+ // See test/unit/core.js for details concerning isFunction.
+ // Since version 1.3, DOM methods and functions like alert
+ // aren't supported. They return false on IE (#2968).
+ isFunction: function( obj ) {
+ return toString.call(obj) === "[object Function]";
+ },
+
+ isArray: function( obj ) {
+ return toString.call(obj) === "[object Array]";
+ },
+
+ isPlainObject: function( obj ) {
+ // Must be an Object.
+ // Because of IE, we also have to check the presence of the constructor property.
+ // Make sure that DOM nodes and window objects don't pass through, as well
+ if ( !obj || toString.call(obj) !== "[object Object]" || obj.nodeType || obj.setInterval ) {
+ return false;
+ }
+
+ // Not own constructor property must be Object
+ if ( obj.constructor
+ && !hasOwnProperty.call(obj, "constructor")
+ && !hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf") ) {
+ return false;
+ }
+
+ // Own properties are enumerated firstly, so to speed up,
+ // if last one is own, then all properties are own.
+
+ var key;
+ for ( key in obj ) {}
+
+ return key === undefined || hasOwnProperty.call( obj, key );
+ },
+
+ isEmptyObject: function( obj ) {
+ for ( var name in obj ) {
+ return false;
+ }
+ return true;
+ },
+
+ noop: function() {},
+
+ // Evalulates a script in a global context
+ globalEval: function( data ) {
+ if ( data && rnotwhite.test(data) ) {
+ // Inspired by code by Andrea Giammarchi
+ // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
+ var head = document.getElementsByTagName("head")[0] || document.documentElement,
+ script = document.createElement("script");
+
+ script.type = "text/javascript";
+
+ if ( jQuery.support.scriptEval ) {
+ script.appendChild( document.createTextNode( data ) );
+ } else {
+ script.text = data;
+ }
+
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709).
+ head.insertBefore( script, head.firstChild );
+ head.removeChild( script );
+ }
+ },
+
+ nodeName: function( elem, name ) {
+ return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
+ },
+
+ // args is for internal usage only
+ each: function( object, callback, args ) {
+ var name, i = 0,
+ length = object.length,
+ isObj = length === undefined || jQuery.isFunction(object);
+
+ if ( args ) {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.apply( object[ name ], args ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( ; i < length; ) {
+ if ( callback.apply( object[ i++ ], args ) === false ) {
+ break;
+ }
+ }
+ }
+
+ // A special, fast, case for the most common use of each
+ } else {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( var value = object[0];
+ i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
+ }
+ }
+
+ return object;
+ },
+
+ trim: function( text ) {
+ return (text || "").replace( rtrim, "" );
+ },
+
+ // results is for internal usage only
+ makeArray: function( array, results ) {
+ var ret = results || [];
+
+ if ( array != null ) {
+ // The window, strings (and functions) also have 'length'
+ // The extra typeof function check is to prevent crashes
+ // in Safari 2 (See: #3039)
+ if ( array.length == null || typeof array === "string" || jQuery.isFunction(array) || (typeof array !== "function" && array.setInterval) ) {
+ push.call( ret, array );
+ } else {
+ jQuery.merge( ret, array );
+ }
+ }
+
+ return ret;
+ },
+
+ inArray: function( elem, array ) {
+ if ( array.indexOf ) {
+ return array.indexOf( elem );
+ }
+
+ for ( var i = 0, length = array.length; i < length; i++ ) {
+ if ( array[ i ] === elem ) {
+ return i;
+ }
+ }
+
+ return -1;
+ },
+
+ merge: function( first, second ) {
+ var i = first.length, j = 0;
+
+ if ( typeof second.length === "number" ) {
+ for ( var l = second.length; j < l; j++ ) {
+ first[ i++ ] = second[ j ];
+ }
+ } else {
+ while ( second[j] !== undefined ) {
+ first[ i++ ] = second[ j++ ];
+ }
+ }
+
+ first.length = i;
+
+ return first;
+ },
+
+ grep: function( elems, callback, inv ) {
+ var ret = [];
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ if ( !inv !== !callback( elems[ i ], i ) ) {
+ ret.push( elems[ i ] );
+ }
+ }
+
+ return ret;
+ },
+
+ // arg is for internal usage only
+ map: function( elems, callback, arg ) {
+ var ret = [], value;
+
+ // Go through the array, translating each of the items to their
+ // new value (or values).
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ value = callback( elems[ i ], i, arg );
+
+ if ( value != null ) {
+ ret[ ret.length ] = value;
+ }
+ }
+
+ return ret.concat.apply( [], ret );
+ },
+
+ // A global GUID counter for objects
+ guid: 1,
+
+ proxy: function( fn, proxy, thisObject ) {
+ if ( arguments.length === 2 ) {
+ if ( typeof proxy === "string" ) {
+ thisObject = fn;
+ fn = thisObject[ proxy ];
+ proxy = undefined;
+
+ } else if ( proxy && !jQuery.isFunction( proxy ) ) {
+ thisObject = proxy;
+ proxy = undefined;
+ }
+ }
+
+ if ( !proxy && fn ) {
+ proxy = function() {
+ return fn.apply( thisObject || this, arguments );
+ };
+ }
+
+ // Set the guid of unique handler to the same of original handler, so it can be removed
+ if ( fn ) {
+ proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
+ }
+
+ // So proxy can be declared as an argument
+ return proxy;
+ },
+
+ // Use of jQuery.browser is frowned upon.
+ // More details: http://docs.jquery.com/Utilities/jQuery.browser
+ uaMatch: function( ua ) {
+ var ret = { browser: "" };
+
+ ua = ua.toLowerCase();
+
+ if ( /webkit/.test( ua ) ) {
+ ret = { browser: "webkit", version: /webkit[\/ ]([\w.]+)/ };
+
+ } else if ( /opera/.test( ua ) ) {
+ ret = { browser: "opera", version: /version/.test( ua ) ? /version[\/ ]([\w.]+)/ : /opera[\/ ]([\w.]+)/ };
+
+ } else if ( /msie/.test( ua ) ) {
+ ret = { browser: "msie", version: /msie ([\w.]+)/ };
+
+ } else if ( /mozilla/.test( ua ) && !/compatible/.test( ua ) ) {
+ ret = { browser: "mozilla", version: /rv:([\w.]+)/ };
+ }
+
+ ret.version = (ret.version && ret.version.exec( ua ) || [0, "0"])[1];
+
+ return ret;
+ },
+
+ browser: {}
+});
+
+browserMatch = jQuery.uaMatch( userAgent );
+if ( browserMatch.browser ) {
+ jQuery.browser[ browserMatch.browser ] = true;
+ jQuery.browser.version = browserMatch.version;
+}
+
+// Deprecated, use jQuery.browser.webkit instead
+if ( jQuery.browser.webkit ) {
+ jQuery.browser.safari = true;
+}
+
+if ( indexOf ) {
+ jQuery.inArray = function( elem, array ) {
+ return indexOf.call( array, elem );
+ };
+}
+
+// All jQuery objects should point back to these
+rootjQuery = jQuery(document);
+
+// Cleanup functions for the document ready method
+if ( document.addEventListener ) {
+ DOMContentLoaded = function() {
+ document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+ jQuery.ready();
+ };
+
+} else if ( document.attachEvent ) {
+ DOMContentLoaded = function() {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( document.readyState === "complete" ) {
+ document.detachEvent( "onreadystatechange", DOMContentLoaded );
+ jQuery.ready();
+ }
+ };
+}
+
+// The DOM ready check for Internet Explorer
+function doScrollCheck() {
+ if ( jQuery.isReady ) {
+ return;
+ }
+
+ try {
+ // If IE is used, use the trick by Diego Perini
+ // http://javascript.nwbox.com/IEContentLoaded/
+ document.documentElement.doScroll("left");
+ } catch( error ) {
+ setTimeout( doScrollCheck, 1 );
+ return;
+ }
+
+ // and execute any waiting functions
+ jQuery.ready();
+}
+
+if ( indexOf ) {
+ jQuery.inArray = function( elem, array ) {
+ return indexOf.call( array, elem );
+ };
+}
+
+function evalScript( i, elem ) {
+ if ( elem.src ) {
+ jQuery.ajax({
+ url: elem.src,
+ async: false,
+ dataType: "script"
+ });
+ } else {
+ jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
+ }
+
+ if ( elem.parentNode ) {
+ elem.parentNode.removeChild( elem );
+ }
+}
+
+// Mutifunctional method to get and set values to a collection
+// The value/s can be optionally by executed if its a function
+function access( elems, key, value, exec, fn, pass ) {
+ var length = elems.length;
+
+ // Setting many attributes
+ if ( typeof key === "object" ) {
+ for ( var k in key ) {
+ access( elems, k, key[k], exec, fn, value );
+ }
+ return elems;
+ }
+
+ // Setting one attribute
+ if ( value !== undefined ) {
+ // Optionally, function values get executed if exec is true
+ exec = !pass && exec && jQuery.isFunction(value);
+
+ for ( var i = 0; i < length; i++ ) {
+ fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
+ }
+
+ return elems;
+ }
+
+ // Getting an attribute
+ return length ? fn( elems[0], key ) : null;
+}
+
+function now() {
+ return (new Date).getTime();
+}
+(function() {
+
+ jQuery.support = {};
+
+ var root = document.documentElement,
+ script = document.createElement("script"),
+ div = document.createElement("div"),
+ id = "script" + now();
+
+ div.style.display = "none";
+ div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
+
+ var all = div.getElementsByTagName("*"),
+ a = div.getElementsByTagName("a")[0];
+
+ // Can't get basic test support
+ if ( !all || !all.length || !a ) {
+ return;
+ }
+
+ jQuery.support = {
+ // IE strips leading whitespace when .innerHTML is used
+ leadingWhitespace: div.firstChild.nodeType === 3,
+
+ // Make sure that tbody elements aren't automatically inserted
+ // IE will insert them into empty tables
+ tbody: !div.getElementsByTagName("tbody").length,
+
+ // Make sure that link elements get serialized correctly by innerHTML
+ // This requires a wrapper element in IE
+ htmlSerialize: !!div.getElementsByTagName("link").length,
+
+ // Get the style information from getAttribute
+ // (IE uses .cssText insted)
+ style: /red/.test( a.getAttribute("style") ),
+
+ // Make sure that URLs aren't manipulated
+ // (IE normalizes it by default)
+ hrefNormalized: a.getAttribute("href") === "/a",
+
+ // Make sure that element opacity exists
+ // (IE uses filter instead)
+ // Use a regex to work around a WebKit issue. See #5145
+ opacity: /^0.55$/.test( a.style.opacity ),
+
+ // Verify style float existence
+ // (IE uses styleFloat instead of cssFloat)
+ cssFloat: !!a.style.cssFloat,
+
+ // Make sure that if no value is specified for a checkbox
+ // that it defaults to "on".
+ // (WebKit defaults to "" instead)
+ checkOn: div.getElementsByTagName("input")[0].value === "on",
+
+ // Make sure that a selected-by-default option has a working selected property.
+ // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
+ optSelected: document.createElement("select").appendChild( document.createElement("option") ).selected,
+
+ // Will be defined later
+ scriptEval: false,
+ noCloneEvent: true,
+ boxModel: null
+ };
+
+ script.type = "text/javascript";
+ try {
+ script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
+ } catch(e) {}
+
+ root.insertBefore( script, root.firstChild );
+
+ // Make sure that the execution of code works by injecting a script
+ // tag with appendChild/createTextNode
+ // (IE doesn't support this, fails, and uses .text instead)
+ if ( window[ id ] ) {
+ jQuery.support.scriptEval = true;
+ delete window[ id ];
+ }
+
+ root.removeChild( script );
+
+ if ( div.attachEvent && div.fireEvent ) {
+ div.attachEvent("onclick", function click() {
+ // Cloning a node shouldn't copy over any
+ // bound event handlers (IE does this)
+ jQuery.support.noCloneEvent = false;
+ div.detachEvent("onclick", click);
+ });
+ div.cloneNode(true).fireEvent("onclick");
+ }
+
+ // Figure out if the W3C box model works as expected
+ // document.body must exist before we can do this
+ // TODO: This timeout is temporary until I move ready into core.js.
+ jQuery(function() {
+ var div = document.createElement("div");
+ div.style.width = div.style.paddingLeft = "1px";
+
+ document.body.appendChild( div );
+ jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
+ document.body.removeChild( div ).style.display = 'none';
+ div = null;
+ });
+
+ // Technique from Juriy Zaytsev
+ // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
+ var eventSupported = function( eventName ) {
+ var el = document.createElement("div");
+ eventName = "on" + eventName;
+
+ var isSupported = (eventName in el);
+ if ( !isSupported ) {
+ el.setAttribute(eventName, "return;");
+ isSupported = typeof el[eventName] === "function";
+ }
+ el = null;
+
+ return isSupported;
+ };
+
+ jQuery.support.submitBubbles = eventSupported("submit");
+ jQuery.support.changeBubbles = eventSupported("change");
+
+ // release memory in IE
+ root = script = div = all = a = null;
+})();
+
+jQuery.props = {
+ "for": "htmlFor",
+ "class": "className",
+ readonly: "readOnly",
+ maxlength: "maxLength",
+ cellspacing: "cellSpacing",
+ rowspan: "rowSpan",
+ colspan: "colSpan",
+ tabindex: "tabIndex",
+ usemap: "useMap",
+ frameborder: "frameBorder"
+};
+var expando = "jQuery" + now(), uuid = 0, windowData = {};
+var emptyObject = {};
+
+jQuery.extend({
+ cache: {},
+
+ expando:expando,
+
+ // The following elements throw uncatchable exceptions if you
+ // attempt to add expando properties to them.
+ noData: {
+ "embed": true,
+ "object": true,
+ "applet": true
+ },
+
+ data: function( elem, name, data ) {
+ if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
+ return;
+ }
+
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var id = elem[ expando ], cache = jQuery.cache, thisCache;
+
+ // Handle the case where there's no name immediately
+ if ( !name && !id ) {
+ return null;
+ }
+
+ // Compute a unique ID for the element
+ if ( !id ) {
+ id = ++uuid;
+ }
+
+ // Avoid generating a new cache unless none exists and we
+ // want to manipulate it.
+ if ( typeof name === "object" ) {
+ elem[ expando ] = id;
+ thisCache = cache[ id ] = jQuery.extend(true, {}, name);
+ } else if ( cache[ id ] ) {
+ thisCache = cache[ id ];
+ } else if ( typeof data === "undefined" ) {
+ thisCache = emptyObject;
+ } else {
+ thisCache = cache[ id ] = {};
+ }
+
+ // Prevent overriding the named cache with undefined values
+ if ( data !== undefined ) {
+ elem[ expando ] = id;
+ thisCache[ name ] = data;
+ }
+
+ return typeof name === "string" ? thisCache[ name ] : thisCache;
+ },
+
+ removeData: function( elem, name ) {
+ if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
+ return;
+ }
+
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ];
+
+ // If we want to remove a specific section of the element's data
+ if ( name ) {
+ if ( thisCache ) {
+ // Remove the section of cache data
+ delete thisCache[ name ];
+
+ // If we've removed all the data, remove the element's cache
+ if ( jQuery.isEmptyObject(thisCache) ) {
+ jQuery.removeData( elem );
+ }
+ }
+
+ // Otherwise, we want to remove all of the element's data
+ } else {
+ // Clean up the element expando
+ try {
+ delete elem[ expando ];
+ } catch( e ) {
+ // IE has trouble directly removing the expando
+ // but it's ok with using removeAttribute
+ if ( elem.removeAttribute ) {
+ elem.removeAttribute( expando );
+ }
+ }
+
+ // Completely remove the data cache
+ delete cache[ id ];
+ }
+ }
+});
+
+jQuery.fn.extend({
+ data: function( key, value ) {
+ if ( typeof key === "undefined" && this.length ) {
+ return jQuery.data( this[0] );
+
+ } else if ( typeof key === "object" ) {
+ return this.each(function() {
+ jQuery.data( this, key );
+ });
+ }
+
+ var parts = key.split(".");
+ parts[1] = parts[1] ? "." + parts[1] : "";
+
+ if ( value === undefined ) {
+ var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
+
+ if ( data === undefined && this.length ) {
+ data = jQuery.data( this[0], key );
+ }
+ return data === undefined && parts[1] ?
+ this.data( parts[0] ) :
+ data;
+ } else {
+ return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function() {
+ jQuery.data( this, key, value );
+ });
+ }
+ },
+
+ removeData: function( key ) {
+ return this.each(function() {
+ jQuery.removeData( this, key );
+ });
+ }
+});
+jQuery.extend({
+ queue: function( elem, type, data ) {
+ if ( !elem ) {
+ return;
+ }
+
+ type = (type || "fx") + "queue";
+ var q = jQuery.data( elem, type );
+
+ // Speed up dequeue by getting out quickly if this is just a lookup
+ if ( !data ) {
+ return q || [];
+ }
+
+ if ( !q || jQuery.isArray(data) ) {
+ q = jQuery.data( elem, type, jQuery.makeArray(data) );
+
+ } else {
+ q.push( data );
+ }
+
+ return q;
+ },
+
+ dequeue: function( elem, type ) {
+ type = type || "fx";
+
+ var queue = jQuery.queue( elem, type ), fn = queue.shift();
+
+ // If the fx queue is dequeued, always remove the progress sentinel
+ if ( fn === "inprogress" ) {
+ fn = queue.shift();
+ }
+
+ if ( fn ) {
+ // Add a progress sentinel to prevent the fx queue from being
+ // automatically dequeued
+ if ( type === "fx" ) {
+ queue.unshift("inprogress");
+ }
+
+ fn.call(elem, function() {
+ jQuery.dequeue(elem, type);
+ });
+ }
+ }
+});
+
+jQuery.fn.extend({
+ queue: function( type, data ) {
+ if ( typeof type !== "string" ) {
+ data = type;
+ type = "fx";
+ }
+
+ if ( data === undefined ) {
+ return jQuery.queue( this[0], type );
+ }
+ return this.each(function( i, elem ) {
+ var queue = jQuery.queue( this, type, data );
+
+ if ( type === "fx" && queue[0] !== "inprogress" ) {
+ jQuery.dequeue( this, type );
+ }
+ });
+ },
+ dequeue: function( type ) {
+ return this.each(function() {
+ jQuery.dequeue( this, type );
+ });
+ },
+
+ // Based off of the plugin by Clint Helfers, with permission.
+ // http://blindsignals.com/index.php/2009/07/jquery-delay/
+ delay: function( time, type ) {
+ time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
+ type = type || "fx";
+
+ return this.queue( type, function() {
+ var elem = this;
+ setTimeout(function() {
+ jQuery.dequeue( elem, type );
+ }, time );
+ });
+ },
+
+ clearQueue: function( type ) {
+ return this.queue( type || "fx", [] );
+ }
+});
+var rclass = /[\n\t]/g,
+ rspace = /\s+/,
+ rreturn = /\r/g,
+ rspecialurl = /href|src|style/,
+ rtype = /(button|input)/i,
+ rfocusable = /(button|input|object|select|textarea)/i,
+ rclickable = /^(a|area)$/i,
+ rradiocheck = /radio|checkbox/;
+
+jQuery.fn.extend({
+ attr: function( name, value ) {
+ return access( this, name, value, true, jQuery.attr );
+ },
+
+ removeAttr: function( name, fn ) {
+ return this.each(function(){
+ jQuery.attr( this, name, "" );
+ if ( this.nodeType === 1 ) {
+ this.removeAttribute( name );
+ }
+ });
+ },
+
+ addClass: function( value ) {
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.addClass( value.call(this, i, self.attr("class")) );
+ });
+ }
+
+ if ( value && typeof value === "string" ) {
+ var classNames = (value || "").split( rspace );
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var elem = this[i];
+
+ if ( elem.nodeType === 1 ) {
+ if ( !elem.className ) {
+ elem.className = value;
+
+ } else {
+ var className = " " + elem.className + " ";
+ for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
+ if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
+ elem.className += " " + classNames[c];
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ removeClass: function( value ) {
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.removeClass( value.call(this, i, self.attr("class")) );
+ });
+ }
+
+ if ( (value && typeof value === "string") || value === undefined ) {
+ var classNames = (value || "").split(rspace);
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var elem = this[i];
+
+ if ( elem.nodeType === 1 && elem.className ) {
+ if ( value ) {
+ var className = (" " + elem.className + " ").replace(rclass, " ");
+ for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
+ className = className.replace(" " + classNames[c] + " ", " ");
+ }
+ elem.className = className.substring(1, className.length - 1);
+
+ } else {
+ elem.className = "";
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ toggleClass: function( value, stateVal ) {
+ var type = typeof value, isBool = typeof stateVal === "boolean";
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
+ });
+ }
+
+ return this.each(function() {
+ if ( type === "string" ) {
+ // toggle individual class names
+ var className, i = 0, self = jQuery(this),
+ state = stateVal,
+ classNames = value.split( rspace );
+
+ while ( (className = classNames[ i++ ]) ) {
+ // check each className given, space seperated list
+ state = isBool ? state : !self.hasClass( className );
+ self[ state ? "addClass" : "removeClass" ]( className );
+ }
+
+ } else if ( type === "undefined" || type === "boolean" ) {
+ if ( this.className ) {
+ // store className if set
+ jQuery.data( this, "__className__", this.className );
+ }
+
+ // toggle whole className
+ this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || "";
+ }
+ });
+ },
+
+ hasClass: function( selector ) {
+ var className = " " + selector + " ";
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ val: function( value ) {
+ if ( value === undefined ) {
+ var elem = this[0];
+
+ if ( elem ) {
+ if ( jQuery.nodeName( elem, "option" ) ) {
+ return (elem.attributes.value || {}).specified ? elem.value : elem.text;
+ }
+
+ // We need to handle select boxes special
+ if ( jQuery.nodeName( elem, "select" ) ) {
+ var index = elem.selectedIndex,
+ values = [],
+ options = elem.options,
+ one = elem.type === "select-one";
+
+ // Nothing was selected
+ if ( index < 0 ) {
+ return null;
+ }
+
+ // Loop through all the selected options
+ for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
+ var option = options[ i ];
+
+ if ( option.selected ) {
+ // Get the specifc value for the option
+ value = jQuery(option).val();
+
+ // We don't need an array for one selects
+ if ( one ) {
+ return value;
+ }
+
+ // Multi-Selects return an array
+ values.push( value );
+ }
+ }
+
+ return values;
+ }
+
+ // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
+ if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
+ return elem.getAttribute("value") === null ? "on" : elem.value;
+ }
+
+
+ // Everything else, we just grab the value
+ return (elem.value || "").replace(rreturn, "");
+
+ }
+
+ return undefined;
+ }
+
+ var isFunction = jQuery.isFunction(value);
+
+ return this.each(function(i) {
+ var self = jQuery(this), val = value;
+
+ if ( this.nodeType !== 1 ) {
+ return;
+ }
+
+ if ( isFunction ) {
+ val = value.call(this, i, self.val());
+ }
+
+ // Typecast each time if the value is a Function and the appended
+ // value is therefore different each time.
+ if ( typeof val === "number" ) {
+ val += "";
+ }
+
+ if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
+ this.checked = jQuery.inArray( self.val(), val ) >= 0;
+
+ } else if ( jQuery.nodeName( this, "select" ) ) {
+ var values = jQuery.makeArray(val);
+
+ jQuery( "option", this ).each(function() {
+ this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
+ });
+
+ if ( !values.length ) {
+ this.selectedIndex = -1;
+ }
+
+ } else {
+ this.value = val;
+ }
+ });
+ }
+});
+
+jQuery.extend({
+ attrFn: {
+ val: true,
+ css: true,
+ html: true,
+ text: true,
+ data: true,
+ width: true,
+ height: true,
+ offset: true
+ },
+
+ attr: function( elem, name, value, pass ) {
+ // don't set attributes on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ if ( pass && name in jQuery.attrFn ) {
+ return jQuery(elem)[name](value);
+ }
+
+ var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
+ // Whether we are setting (or getting)
+ set = value !== undefined;
+
+ // Try to normalize/fix the name
+ name = notxml && jQuery.props[ name ] || name;
+
+ // Only do all the following if this is a node (faster for style)
+ if ( elem.nodeType === 1 ) {
+ // These attributes require special treatment
+ var special = rspecialurl.test( name );
+
+ // Safari mis-reports the default selected property of an option
+ // Accessing the parent's selectedIndex property fixes it
+ if ( name === "selected" && !jQuery.support.optSelected ) {
+ var parent = elem.parentNode;
+ if ( parent ) {
+ parent.selectedIndex;
+
+ // Make sure that it also works with optgroups, see #5701
+ if ( parent.parentNode ) {
+ parent.parentNode.selectedIndex;
+ }
+ }
+ }
+
+ // If applicable, access the attribute via the DOM 0 way
+ if ( name in elem && notxml && !special ) {
+ if ( set ) {
+ // We can't allow the type property to be changed (since it causes problems in IE)
+ if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
+ throw "type property can't be changed";
+ }
+
+ elem[ name ] = value;
+ }
+
+ // browsers index elements by id/name on forms, give priority to attributes.
+ if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
+ return elem.getAttributeNode( name ).nodeValue;
+ }
+
+ // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
+ // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
+ if ( name === "tabIndex" ) {
+ var attributeNode = elem.getAttributeNode( "tabIndex" );
+
+ return attributeNode && attributeNode.specified ?
+ attributeNode.value :
+ rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
+ 0 :
+ undefined;
+ }
+
+ return elem[ name ];
+ }
+
+ if ( !jQuery.support.style && notxml && name === "style" ) {
+ if ( set ) {
+ elem.style.cssText = "" + value;
+ }
+
+ return elem.style.cssText;
+ }
+
+ if ( set ) {
+ // convert the value to a string (all browsers do this but IE) see #1070
+ elem.setAttribute( name, "" + value );
+ }
+
+ var attr = !jQuery.support.hrefNormalized && notxml && special ?
+ // Some attributes require a special call on IE
+ elem.getAttribute( name, 2 ) :
+ elem.getAttribute( name );
+
+ // Non-existent attributes return null, we normalize to undefined
+ return attr === null ? undefined : attr;
+ }
+
+ // elem is actually elem.style ... set the style
+ // Using attr for specific style information is now deprecated. Use style insead.
+ return jQuery.style( elem, name, value );
+ }
+});
+var fcleanup = function( nm ) {
+ return nm.replace(/[^\w\s\.\|`]/g, function( ch ) {
+ return "\\" + ch;
+ });
+};
+
+/*
+ * A number of helper functions used for managing events.
+ * Many of the ideas behind this code originated from
+ * Dean Edwards' addEvent library.
+ */
+jQuery.event = {
+
+ // Bind an event to an element
+ // Original by Dean Edwards
+ add: function( elem, types, handler, data ) {
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ // For whatever reason, IE has trouble passing the window object
+ // around, causing it to be cloned in the process
+ if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) {
+ elem = window;
+ }
+
+ // Make sure that the function being executed has a unique ID
+ if ( !handler.guid ) {
+ handler.guid = jQuery.guid++;
+ }
+
+ // if data is passed, bind to handler
+ if ( data !== undefined ) {
+ // Create temporary function pointer to original handler
+ var fn = handler;
+
+ // Create unique handler function, wrapped around original handler
+ handler = jQuery.proxy( fn );
+
+ // Store data in unique handler
+ handler.data = data;
+ }
+
+ // Init the element's event structure
+ var events = jQuery.data( elem, "events" ) || jQuery.data( elem, "events", {} ),
+ handle = jQuery.data( elem, "handle" ), eventHandle;
+
+ if ( !handle ) {
+ eventHandle = function() {
+ // Handle the second event of a trigger and when
+ // an event is called after a page has unloaded
+ return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
+ jQuery.event.handle.apply( eventHandle.elem, arguments ) :
+ undefined;
+ };
+
+ handle = jQuery.data( elem, "handle", eventHandle );
+ }
+
+ // If no handle is found then we must be trying to bind to one of the
+ // banned noData elements
+ if ( !handle ) {
+ return;
+ }
+
+ // Add elem as a property of the handle function
+ // This is to prevent a memory leak with non-native
+ // event in IE.
+ handle.elem = elem;
+
+ // Handle multiple events separated by a space
+ // jQuery(...).bind("mouseover mouseout", fn);
+ types = types.split( /\s+/ );
+ var type, i=0;
+ while ( (type = types[ i++ ]) ) {
+ // Namespaced event handlers
+ var namespaces = type.split(".");
+ type = namespaces.shift();
+ handler.type = namespaces.slice(0).sort().join(".");
+
+ // Get the current list of functions bound to this event
+ var handlers = events[ type ],
+ special = this.special[ type ] || {};
+
+
+
+ // Init the event handler queue
+ if ( !handlers ) {
+ handlers = events[ type ] = {};
+
+ // Check for a special event handler
+ // Only use addEventListener/attachEvent if the special
+ // events handler returns false
+ if ( !special.setup || special.setup.call( elem, data, namespaces, handler) === false ) {
+ // Bind the global event handler to the element
+ if ( elem.addEventListener ) {
+ elem.addEventListener( type, handle, false );
+ } else if ( elem.attachEvent ) {
+ elem.attachEvent( "on" + type, handle );
+ }
+ }
+ }
+
+ if ( special.add ) {
+ var modifiedHandler = special.add.call( elem, handler, data, namespaces, handlers );
+ if ( modifiedHandler && jQuery.isFunction( modifiedHandler ) ) {
+ modifiedHandler.guid = modifiedHandler.guid || handler.guid;
+ handler = modifiedHandler;
+ }
+ }
+
+ // Add the function to the element's handler list
+ handlers[ handler.guid ] = handler;
+
+ // Keep track of which events have been used, for global triggering
+ this.global[ type ] = true;
+ }
+
+ // Nullify elem to prevent memory leaks in IE
+ elem = null;
+ },
+
+ global: {},
+
+ // Detach an event or set of events from an element
+ remove: function( elem, types, handler ) {
+ // don't do events on text and comment nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ var events = jQuery.data( elem, "events" ), ret, type, fn;
+
+ if ( events ) {
+ // Unbind all events for the element
+ if ( types === undefined || (typeof types === "string" && types.charAt(0) === ".") ) {
+ for ( type in events ) {
+ this.remove( elem, type + (types || "") );
+ }
+ } else {
+ // types is actually an event object here
+ if ( types.type ) {
+ handler = types.handler;
+ types = types.type;
+ }
+
+ // Handle multiple events separated by a space
+ // jQuery(...).unbind("mouseover mouseout", fn);
+ types = types.split(/\s+/);
+ var i = 0;
+ while ( (type = types[ i++ ]) ) {
+ // Namespaced event handlers
+ var namespaces = type.split(".");
+ type = namespaces.shift();
+ var all = !namespaces.length,
+ cleaned = jQuery.map( namespaces.slice(0).sort(), fcleanup ),
+ namespace = new RegExp("(^|\\.)" + cleaned.join("\\.(?:.*\\.)?") + "(\\.|$)"),
+ special = this.special[ type ] || {};
+
+ if ( events[ type ] ) {
+ // remove the given handler for the given type
+ if ( handler ) {
+ fn = events[ type ][ handler.guid ];
+ delete events[ type ][ handler.guid ];
+
+ // remove all handlers for the given type
+ } else {
+ for ( var handle in events[ type ] ) {
+ // Handle the removal of namespaced events
+ if ( all || namespace.test( events[ type ][ handle ].type ) ) {
+ delete events[ type ][ handle ];
+ }
+ }
+ }
+
+ if ( special.remove ) {
+ special.remove.call( elem, namespaces, fn);
+ }
+
+ // remove generic event handler if no more handlers exist
+ for ( ret in events[ type ] ) {
+ break;
+ }
+ if ( !ret ) {
+ if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
+ if ( elem.removeEventListener ) {
+ elem.removeEventListener( type, jQuery.data( elem, "handle" ), false );
+ } else if ( elem.detachEvent ) {
+ elem.detachEvent( "on" + type, jQuery.data( elem, "handle" ) );
+ }
+ }
+ ret = null;
+ delete events[ type ];
+ }
+ }
+ }
+ }
+
+ // Remove the expando if it's no longer used
+ for ( ret in events ) {
+ break;
+ }
+ if ( !ret ) {
+ var handle = jQuery.data( elem, "handle" );
+ if ( handle ) {
+ handle.elem = null;
+ }
+ jQuery.removeData( elem, "events" );
+ jQuery.removeData( elem, "handle" );
+ }
+ }
+ },
+
+ // bubbling is internal
+ trigger: function( event, data, elem /*, bubbling */ ) {
+ // Event object or event type
+ var type = event.type || event,
+ bubbling = arguments[3];
+
+ if ( !bubbling ) {
+ event = typeof event === "object" ?
+ // jQuery.Event object
+ event[expando] ? event :
+ // Object literal
+ jQuery.extend( jQuery.Event(type), event ) :
+ // Just the event type (string)
+ jQuery.Event(type);
+
+ if ( type.indexOf("!") >= 0 ) {
+ event.type = type = type.slice(0, -1);
+ event.exclusive = true;
+ }
+
+ // Handle a global trigger
+ if ( !elem ) {
+ // Don't bubble custom events when global (to avoid too much overhead)
+ event.stopPropagation();
+
+ // Only trigger if we've ever bound an event for it
+ if ( this.global[ type ] ) {
+ jQuery.each( jQuery.cache, function() {
+ if ( this.events && this.events[type] ) {
+ jQuery.event.trigger( event, data, this.handle.elem );
+ }
+ });
+ }
+ }
+
+ // Handle triggering a single element
+
+ // don't do events on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ // Clean up in case it is reused
+ event.result = undefined;
+ event.target = elem;
+
+ // Clone the incoming data, if any
+ data = jQuery.makeArray( data );
+ data.unshift( event );
+ }
+
+ event.currentTarget = elem;
+
+ // Trigger the event, it is assumed that "handle" is a function
+ var handle = jQuery.data( elem, "handle" );
+ if ( handle ) {
+ handle.apply( elem, data );
+ }
+
+ var nativeFn, nativeHandler;
+ try {
+ if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
+ nativeFn = elem[ type ];
+ nativeHandler = elem[ "on" + type ];
+ }
+ // prevent IE from throwing an error for some elements with some event types, see #3533
+ } catch (e) {}
+
+ var isClick = jQuery.nodeName(elem, "a") && type === "click";
+
+ // Trigger the native events (except for clicks on links)
+ if ( !bubbling && nativeFn && !event.isDefaultPrevented() && !isClick ) {
+ this.triggered = true;
+ try {
+ elem[ type ]();
+ // prevent IE from throwing an error for some hidden elements
+ } catch (e) {}
+
+ // Handle triggering native .onfoo handlers
+ } else if ( nativeHandler && elem[ "on" + type ].apply( elem, data ) === false ) {
+ event.result = false;
+ }
+
+ this.triggered = false;
+
+ if ( !event.isPropagationStopped() ) {
+ var parent = elem.parentNode || elem.ownerDocument;
+ if ( parent ) {
+ jQuery.event.trigger( event, data, parent, true );
+ }
+ }
+ },
+
+ handle: function( event ) {
+ // returned undefined or false
+ var all, handlers;
+
+ event = arguments[0] = jQuery.event.fix( event || window.event );
+ event.currentTarget = this;
+
+ // Namespaced event handlers
+ var namespaces = event.type.split(".");
+ event.type = namespaces.shift();
+
+ // Cache this now, all = true means, any handler
+ all = !namespaces.length && !event.exclusive;
+
+ var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)");
+
+ handlers = ( jQuery.data(this, "events") || {} )[ event.type ];
+
+ for ( var j in handlers ) {
+ var handler = handlers[ j ];
+
+ // Filter the functions by class
+ if ( all || namespace.test(handler.type) ) {
+ // Pass in a reference to the handler function itself
+ // So that we can later remove it
+ event.handler = handler;
+ event.data = handler.data;
+
+ var ret = handler.apply( this, arguments );
+
+ if ( ret !== undefined ) {
+ event.result = ret;
+ if ( ret === false ) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }
+
+ if ( event.isImmediatePropagationStopped() ) {
+ break;
+ }
+
+ }
+ }
+
+ return event.result;
+ },
+
+ props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
+
+ fix: function( event ) {
+ if ( event[ expando ] ) {
+ return event;
+ }
+
+ // store a copy of the original event object
+ // and "clone" to set read-only properties
+ var originalEvent = event;
+ event = jQuery.Event( originalEvent );
+
+ for ( var i = this.props.length, prop; i; ) {
+ prop = this.props[ --i ];
+ event[ prop ] = originalEvent[ prop ];
+ }
+
+ // Fix target property, if necessary
+ if ( !event.target ) {
+ event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
+ }
+
+ // check if target is a textnode (safari)
+ if ( event.target.nodeType === 3 ) {
+ event.target = event.target.parentNode;
+ }
+
+ // Add relatedTarget, if necessary
+ if ( !event.relatedTarget && event.fromElement ) {
+ event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
+ }
+
+ // Calculate pageX/Y if missing and clientX/Y available
+ if ( event.pageX == null && event.clientX != null ) {
+ var doc = document.documentElement, body = document.body;
+ event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
+ event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
+ }
+
+ // Add which for key events
+ if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) {
+ event.which = event.charCode || event.keyCode;
+ }
+
+ // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
+ if ( !event.metaKey && event.ctrlKey ) {
+ event.metaKey = event.ctrlKey;
+ }
+
+ // Add which for click: 1 === left; 2 === middle; 3 === right
+ // Note: button is not normalized, so don't use it
+ if ( !event.which && event.button !== undefined ) {
+ event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
+ }
+
+ return event;
+ },
+
+ // Deprecated, use jQuery.guid instead
+ guid: 1E8,
+
+ // Deprecated, use jQuery.proxy instead
+ proxy: jQuery.proxy,
+
+ special: {
+ ready: {
+ // Make sure the ready event is setup
+ setup: jQuery.bindReady,
+ teardown: jQuery.noop
+ },
+
+ live: {
+ add: function( proxy, data, namespaces, live ) {
+ jQuery.extend( proxy, data || {} );
+
+ proxy.guid += data.selector + data.live;
+ jQuery.event.add( this, data.live, liveHandler, data );
+
+ },
+
+ remove: function( namespaces ) {
+ if ( namespaces.length ) {
+ var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)");
+
+ jQuery.each( (jQuery.data(this, "events").live || {}), function() {
+ if ( name.test(this.type) ) {
+ remove++;
+ }
+ });
+
+ if ( remove < 1 ) {
+ jQuery.event.remove( this, namespaces[0], liveHandler );
+ }
+ }
+ },
+ special: {}
+ },
+ beforeunload: {
+ setup: function( data, namespaces, fn ) {
+ // We only want to do this special case on windows
+ if ( this.setInterval ) {
+ this.onbeforeunload = fn;
+ }
+
+ return false;
+ },
+ teardown: function( namespaces, fn ) {
+ if ( this.onbeforeunload === fn ) {
+ this.onbeforeunload = null;
+ }
+ }
+ }
+ }
+};
+
+jQuery.Event = function( src ) {
+ // Allow instantiation without the 'new' keyword
+ if ( !this.preventDefault ) {
+ return new jQuery.Event( src );
+ }
+
+ // Event object
+ if ( src && src.type ) {
+ this.originalEvent = src;
+ this.type = src.type;
+ // Event type
+ } else {
+ this.type = src;
+ }
+
+ // timeStamp is buggy for some events on Firefox(#3843)
+ // So we won't rely on the native value
+ this.timeStamp = now();
+
+ // Mark it as fixed
+ this[ expando ] = true;
+};
+
+function returnFalse() {
+ return false;
+}
+function returnTrue() {
+ return true;
+}
+
+// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
+// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
+jQuery.Event.prototype = {
+ preventDefault: function() {
+ this.isDefaultPrevented = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+
+ // if preventDefault exists run it on the original event
+ if ( e.preventDefault ) {
+ e.preventDefault();
+ }
+ // otherwise set the returnValue property of the original event to false (IE)
+ e.returnValue = false;
+ },
+ stopPropagation: function() {
+ this.isPropagationStopped = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+ // if stopPropagation exists run it on the original event
+ if ( e.stopPropagation ) {
+ e.stopPropagation();
+ }
+ // otherwise set the cancelBubble property of the original event to true (IE)
+ e.cancelBubble = true;
+ },
+ stopImmediatePropagation: function() {
+ this.isImmediatePropagationStopped = returnTrue;
+ this.stopPropagation();
+ },
+ isDefaultPrevented: returnFalse,
+ isPropagationStopped: returnFalse,
+ isImmediatePropagationStopped: returnFalse
+};
+
+// Checks if an event happened on an element within another element
+// Used in jQuery.event.special.mouseenter and mouseleave handlers
+var withinElement = function( event ) {
+ // Check if mouse(over|out) are still within the same parent element
+ var parent = event.relatedTarget;
+
+ // Traverse up the tree
+ while ( parent && parent !== this ) {
+ // Firefox sometimes assigns relatedTarget a XUL element
+ // which we cannot access the parentNode property of
+ try {
+ parent = parent.parentNode;
+
+ // assuming we've left the element since we most likely mousedover a xul element
+ } catch(e) {
+ break;
+ }
+ }
+
+ if ( parent !== this ) {
+ // set the correct event type
+ event.type = event.data;
+
+ // handle event if we actually just moused on to a non sub-element
+ jQuery.event.handle.apply( this, arguments );
+ }
+
+},
+
+// In case of event delegation, we only need to rename the event.type,
+// liveHandler will take care of the rest.
+delegate = function( event ) {
+ event.type = event.data;
+ jQuery.event.handle.apply( this, arguments );
+};
+
+// Create mouseenter and mouseleave events
+jQuery.each({
+ mouseenter: "mouseover",
+ mouseleave: "mouseout"
+}, function( orig, fix ) {
+ jQuery.event.special[ orig ] = {
+ setup: function( data ) {
+ jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
+ },
+ teardown: function( data ) {
+ jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
+ }
+ };
+});
+
+// submit delegation
+if ( !jQuery.support.submitBubbles ) {
+
+jQuery.event.special.submit = {
+ setup: function( data, namespaces, fn ) {
+ if ( this.nodeName.toLowerCase() !== "form" ) {
+ jQuery.event.add(this, "click.specialSubmit." + fn.guid, function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
+ return trigger( "submit", this, arguments );
+ }
+ });
+
+ jQuery.event.add(this, "keypress.specialSubmit." + fn.guid, function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
+ return trigger( "submit", this, arguments );
+ }
+ });
+
+ } else {
+ return false;
+ }
+ },
+
+ remove: function( namespaces, fn ) {
+ jQuery.event.remove( this, "click.specialSubmit" + (fn ? "."+fn.guid : "") );
+ jQuery.event.remove( this, "keypress.specialSubmit" + (fn ? "."+fn.guid : "") );
+ }
+};
+
+}
+
+// change delegation, happens here so we have bind.
+if ( !jQuery.support.changeBubbles ) {
+
+var formElems = /textarea|input|select/i;
+
+function getVal( elem ) {
+ var type = elem.type, val = elem.value;
+
+ if ( type === "radio" || type === "checkbox" ) {
+ val = elem.checked;
+
+ } else if ( type === "select-multiple" ) {
+ val = elem.selectedIndex > -1 ?
+ jQuery.map( elem.options, function( elem ) {
+ return elem.selected;
+ }).join("-") :
+ "";
+
+ } else if ( elem.nodeName.toLowerCase() === "select" ) {
+ val = elem.selectedIndex;
+ }
+
+ return val;
+}
+
+function testChange( e ) {
+ var elem = e.target, data, val;
+
+ if ( !formElems.test( elem.nodeName ) || elem.readOnly ) {
+ return;
+ }
+
+ data = jQuery.data( elem, "_change_data" );
+ val = getVal(elem);
+
+ if ( val === data ) {
+ return;
+ }
+
+ // the current data will be also retrieved by beforeactivate
+ if ( e.type !== "focusout" || elem.type !== "radio" ) {
+ jQuery.data( elem, "_change_data", val );
+ }
+
+ if ( elem.type !== "select" && (data != null || val) ) {
+ e.type = "change";
+ return jQuery.event.trigger( e, arguments[1], this );
+ }
+}
+
+jQuery.event.special.change = {
+ filters: {
+ focusout: testChange,
+
+ click: function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
+ return testChange.call( this, e );
+ }
+ },
+
+ // Change has to be called before submit
+ // Keydown will be called before keypress, which is used in submit-event delegation
+ keydown: function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
+ (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
+ type === "select-multiple" ) {
+ return testChange.call( this, e );
+ }
+ },
+
+ // Beforeactivate happens also before the previous element is blurred
+ // with this event you can't trigger a change event, but you can store
+ // information/focus[in] is not needed anymore
+ beforeactivate: function( e ) {
+ var elem = e.target;
+
+ if ( elem.nodeName.toLowerCase() === "input" && elem.type === "radio" ) {
+ jQuery.data( elem, "_change_data", getVal(elem) );
+ }
+ }
+ },
+ setup: function( data, namespaces, fn ) {
+ for ( var type in changeFilters ) {
+ jQuery.event.add( this, type + ".specialChange." + fn.guid, changeFilters[type] );
+ }
+
+ return formElems.test( this.nodeName );
+ },
+ remove: function( namespaces, fn ) {
+ for ( var type in changeFilters ) {
+ jQuery.event.remove( this, type + ".specialChange" + (fn ? "."+fn.guid : ""), changeFilters[type] );
+ }
+
+ return formElems.test( this.nodeName );
+ }
+};
+
+var changeFilters = jQuery.event.special.change.filters;
+
+}
+
+function trigger( type, elem, args ) {
+ args[0].type = type;
+ return jQuery.event.handle.apply( elem, args );
+}
+
+// Create "bubbling" focus and blur events
+if ( document.addEventListener ) {
+ jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
+ jQuery.event.special[ fix ] = {
+ setup: function() {
+ this.addEventListener( orig, handler, true );
+ },
+ teardown: function() {
+ this.removeEventListener( orig, handler, true );
+ }
+ };
+
+ function handler( e ) {
+ e = jQuery.event.fix( e );
+ e.type = fix;
+ return jQuery.event.handle.call( this, e );
+ }
+ });
+}
+
+jQuery.each(["bind", "one"], function( i, name ) {
+ jQuery.fn[ name ] = function( type, data, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" ) {
+ for ( var key in type ) {
+ this[ name ](key, data, type[key], fn);
+ }
+ return this;
+ }
+
+ if ( jQuery.isFunction( data ) ) {
+ thisObject = fn;
+ fn = data;
+ data = undefined;
+ }
+
+ var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
+ jQuery( this ).unbind( event, handler );
+ return fn.apply( this, arguments );
+ }) : fn;
+
+ return type === "unload" && name !== "one" ?
+ this.one( type, data, fn, thisObject ) :
+ this.each(function() {
+ jQuery.event.add( this, type, handler, data );
+ });
+ };
+});
+
+jQuery.fn.extend({
+ unbind: function( type, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" && !type.preventDefault ) {
+ for ( var key in type ) {
+ this.unbind(key, type[key]);
+ }
+ return this;
+ }
+
+ return this.each(function() {
+ jQuery.event.remove( this, type, fn );
+ });
+ },
+ trigger: function( type, data ) {
+ return this.each(function() {
+ jQuery.event.trigger( type, data, this );
+ });
+ },
+
+ triggerHandler: function( type, data ) {
+ if ( this[0] ) {
+ var event = jQuery.Event( type );
+ event.preventDefault();
+ event.stopPropagation();
+ jQuery.event.trigger( event, data, this[0] );
+ return event.result;
+ }
+ },
+
+ toggle: function( fn ) {
+ // Save reference to arguments for access in closure
+ var args = arguments, i = 1;
+
+ // link all the functions, so any of them can unbind this click handler
+ while ( i < args.length ) {
+ jQuery.proxy( fn, args[ i++ ] );
+ }
+
+ return this.click( jQuery.proxy( fn, function( event ) {
+ // Figure out which function to execute
+ var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
+ jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
+
+ // Make sure that clicks stop
+ event.preventDefault();
+
+ // and execute the function
+ return args[ lastToggle ].apply( this, arguments ) || false;
+ }));
+ },
+
+ hover: function( fnOver, fnOut ) {
+ return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
+ },
+
+ live: function( type, data, fn ) {
+ if ( jQuery.isFunction( data ) ) {
+ fn = data;
+ data = undefined;
+ }
+
+ jQuery( this.context ).bind( liveConvert( type, this.selector ), {
+ data: data, selector: this.selector, live: type
+ }, fn );
+
+ return this;
+ },
+
+ die: function( type, fn ) {
+ jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null );
+ return this;
+ }
+});
+
+function liveHandler( event ) {
+ var stop = true, elems = [], selectors = [], args = arguments,
+ related, match, fn, elem, j, i, data,
+ live = jQuery.extend({}, jQuery.data( this, "events" ).live);
+
+ for ( j in live ) {
+ fn = live[j];
+ if ( fn.live === event.type ||
+ fn.altLive && jQuery.inArray(event.type, fn.altLive) > -1 ) {
+
+ data = fn.data;
+ if ( !(data.beforeFilter && data.beforeFilter[event.type] &&
+ !data.beforeFilter[event.type](event)) ) {
+ selectors.push( fn.selector );
+ }
+ } else {
+ delete live[j];
+ }
+ }
+
+ match = jQuery( event.target ).closest( selectors, event.currentTarget );
+
+ for ( i = 0, l = match.length; i < l; i++ ) {
+ for ( j in live ) {
+ fn = live[j];
+ elem = match[i].elem;
+ related = null;
+
+ if ( match[i].selector === fn.selector ) {
+ // Those two events require additional checking
+ if ( fn.live === "mouseenter" || fn.live === "mouseleave" ) {
+ related = jQuery( event.relatedTarget ).closest( fn.selector )[0];
+ }
+
+ if ( !related || related !== elem ) {
+ elems.push({ elem: elem, fn: fn });
+ }
+ }
+ }
+ }
+
+ for ( i = 0, l = elems.length; i < l; i++ ) {
+ match = elems[i];
+ event.currentTarget = match.elem;
+ event.data = match.fn.data;
+ if ( match.fn.apply( match.elem, args ) === false ) {
+ stop = false;
+ break;
+ }
+ }
+
+ return stop;
+}
+
+function liveConvert( type, selector ) {
+ return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "&")].join(".");
+}
+
+jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
+ "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
+ "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
+
+ // Handle event binding
+ jQuery.fn[ name ] = function( fn ) {
+ return fn ? this.bind( name, fn ) : this.trigger( name );
+ };
+
+ if ( jQuery.attrFn ) {
+ jQuery.attrFn[ name ] = true;
+ }
+});
+
+// Prevent memory leaks in IE
+// Window isn't included so as not to unbind existing unload events
+// More info:
+// - http://isaacschlueter.com/2006/10/msie-memory-leaks/
+if ( window.attachEvent && !window.addEventListener ) {
+ window.attachEvent("onunload", function() {
+ for ( var id in jQuery.cache ) {
+ if ( jQuery.cache[ id ].handle ) {
+ // Try/Catch is to handle iframes being unloaded, see #4280
+ try {
+ jQuery.event.remove( jQuery.cache[ id ].handle.elem );
+ } catch(e) {}
+ }
+ }
+ });
+}
+/*!
+ * Sizzle CSS Selector Engine - v1.0
+ * Copyright 2009, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ * More information: http://sizzlejs.com/
+ */
+(function(){
+
+var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
+ done = 0,
+ toString = Object.prototype.toString,
+ hasDuplicate = false,
+ baseHasDuplicate = true;
+
+// Here we check if the JavaScript engine is using some sort of
+// optimization where it does not always call our comparision
+// function. If that is the case, discard the hasDuplicate value.
+// Thus far that includes Google Chrome.
+[0, 0].sort(function(){
+ baseHasDuplicate = false;
+ return 0;
+});
+
+var Sizzle = function(selector, context, results, seed) {
+ results = results || [];
+ var origContext = context = context || document;
+
+ if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
+ return [];
+ }
+
+ if ( !selector || typeof selector !== "string" ) {
+ return results;
+ }
+
+ var parts = [], m, set, checkSet, extra, prune = true, contextXML = isXML(context),
+ soFar = selector;
+
+ // Reset the position of the chunker regexp (start from head)
+ while ( (chunker.exec(""), m = chunker.exec(soFar)) !== null ) {
+ soFar = m[3];
+
+ parts.push( m[1] );
+
+ if ( m[2] ) {
+ extra = m[3];
+ break;
+ }
+ }
+
+ if ( parts.length > 1 && origPOS.exec( selector ) ) {
+ if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
+ set = posProcess( parts[0] + parts[1], context );
+ } else {
+ set = Expr.relative[ parts[0] ] ?
+ [ context ] :
+ Sizzle( parts.shift(), context );
+
+ while ( parts.length ) {
+ selector = parts.shift();
+
+ if ( Expr.relative[ selector ] ) {
+ selector += parts.shift();
+ }
+
+ set = posProcess( selector, set );
+ }
+ }
+ } else {
+ // Take a shortcut and set the context if the root selector is an ID
+ // (but not if it'll be faster if the inner selector is an ID)
+ if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
+ Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
+ var ret = Sizzle.find( parts.shift(), context, contextXML );
+ context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];
+ }
+
+ if ( context ) {
+ var ret = seed ?
+ { expr: parts.pop(), set: makeArray(seed) } :
+ Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
+ set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set;
+
+ if ( parts.length > 0 ) {
+ checkSet = makeArray(set);
+ } else {
+ prune = false;
+ }
+
+ while ( parts.length ) {
+ var cur = parts.pop(), pop = cur;
+
+ if ( !Expr.relative[ cur ] ) {
+ cur = "";
+ } else {
+ pop = parts.pop();
+ }
+
+ if ( pop == null ) {
+ pop = context;
+ }
+
+ Expr.relative[ cur ]( checkSet, pop, contextXML );
+ }
+ } else {
+ checkSet = parts = [];
+ }
+ }
+
+ if ( !checkSet ) {
+ checkSet = set;
+ }
+
+ if ( !checkSet ) {
+ throw "Syntax error, unrecognized expression: " + (cur || selector);
+ }
+
+ if ( toString.call(checkSet) === "[object Array]" ) {
+ if ( !prune ) {
+ results.push.apply( results, checkSet );
+ } else if ( context && context.nodeType === 1 ) {
+ for ( var i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {
+ results.push( set[i] );
+ }
+ }
+ } else {
+ for ( var i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
+ results.push( set[i] );
+ }
+ }
+ }
+ } else {
+ makeArray( checkSet, results );
+ }
+
+ if ( extra ) {
+ Sizzle( extra, origContext, results, seed );
+ Sizzle.uniqueSort( results );
+ }
+
+ return results;
+};
+
+Sizzle.uniqueSort = function(results){
+ if ( sortOrder ) {
+ hasDuplicate = baseHasDuplicate;
+ results.sort(sortOrder);
+
+ if ( hasDuplicate ) {
+ for ( var i = 1; i < results.length; i++ ) {
+ if ( results[i] === results[i-1] ) {
+ results.splice(i--, 1);
+ }
+ }
+ }
+ }
+
+ return results;
+};
+
+Sizzle.matches = function(expr, set){
+ return Sizzle(expr, null, null, set);
+};
+
+Sizzle.find = function(expr, context, isXML){
+ var set, match;
+
+ if ( !expr ) {
+ return [];
+ }
+
+ for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
+ var type = Expr.order[i], match;
+
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
+ var left = match[1];
+ match.splice(1,1);
+
+ if ( left.substr( left.length - 1 ) !== "\\" ) {
+ match[1] = (match[1] || "").replace(/\\/g, "");
+ set = Expr.find[ type ]( match, context, isXML );
+ if ( set != null ) {
+ expr = expr.replace( Expr.match[ type ], "" );
+ break;
+ }
+ }
+ }
+ }
+
+ if ( !set ) {
+ set = context.getElementsByTagName("*");
+ }
+
+ return {set: set, expr: expr};
+};
+
+Sizzle.filter = function(expr, set, inplace, not){
+ var old = expr, result = [], curLoop = set, match, anyFound,
+ isXMLFilter = set && set[0] && isXML(set[0]);
+
+ while ( expr && set.length ) {
+ for ( var type in Expr.filter ) {
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
+ var filter = Expr.filter[ type ], found, item, left = match[1];
+ anyFound = false;
+
+ match.splice(1,1);
+
+ if ( left.substr( left.length - 1 ) === "\\" ) {
+ continue;
+ }
+
+ if ( curLoop === result ) {
+ result = [];
+ }
+
+ if ( Expr.preFilter[ type ] ) {
+ match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
+
+ if ( !match ) {
+ anyFound = found = true;
+ } else if ( match === true ) {
+ continue;
+ }
+ }
+
+ if ( match ) {
+ for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
+ if ( item ) {
+ found = filter( item, match, i, curLoop );
+ var pass = not ^ !!found;
+
+ if ( inplace && found != null ) {
+ if ( pass ) {
+ anyFound = true;
+ } else {
+ curLoop[i] = false;
+ }
+ } else if ( pass ) {
+ result.push( item );
+ anyFound = true;
+ }
+ }
+ }
+ }
+
+ if ( found !== undefined ) {
+ if ( !inplace ) {
+ curLoop = result;
+ }
+
+ expr = expr.replace( Expr.match[ type ], "" );
+
+ if ( !anyFound ) {
+ return [];
+ }
+
+ break;
+ }
+ }
+ }
+
+ // Improper expression
+ if ( expr === old ) {
+ if ( anyFound == null ) {
+ throw "Syntax error, unrecognized expression: " + expr;
+ } else {
+ break;
+ }
+ }
+
+ old = expr;
+ }
+
+ return curLoop;
+};
+
+var Expr = Sizzle.selectors = {
+ order: [ "ID", "NAME", "TAG" ],
+ match: {
+ ID: /#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
+ CLASS: /\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
+ NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,
+ ATTR: /\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
+ TAG: /^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,
+ CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
+ POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
+ PSEUDO: /:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
+ },
+ leftMatch: {},
+ attrMap: {
+ "class": "className",
+ "for": "htmlFor"
+ },
+ attrHandle: {
+ href: function(elem){
+ return elem.getAttribute("href");
+ }
+ },
+ relative: {
+ "+": function(checkSet, part){
+ var isPartStr = typeof part === "string",
+ isTag = isPartStr && !/\W/.test(part),
+ isPartStrNotTag = isPartStr && !isTag;
+
+ if ( isTag ) {
+ part = part.toLowerCase();
+ }
+
+ for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
+ if ( (elem = checkSet[i]) ) {
+ while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
+
+ checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
+ elem || false :
+ elem === part;
+ }
+ }
+
+ if ( isPartStrNotTag ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ },
+ ">": function(checkSet, part){
+ var isPartStr = typeof part === "string";
+
+ if ( isPartStr && !/\W/.test(part) ) {
+ part = part.toLowerCase();
+
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ var parent = elem.parentNode;
+ checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
+ }
+ }
+ } else {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ checkSet[i] = isPartStr ?
+ elem.parentNode :
+ elem.parentNode === part;
+ }
+ }
+
+ if ( isPartStr ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ }
+ },
+ "": function(checkSet, part, isXML){
+ var doneName = done++, checkFn = dirCheck;
+
+ if ( typeof part === "string" && !/\W/.test(part) ) {
+ var nodeCheck = part = part.toLowerCase();
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
+ },
+ "~": function(checkSet, part, isXML){
+ var doneName = done++, checkFn = dirCheck;
+
+ if ( typeof part === "string" && !/\W/.test(part) ) {
+ var nodeCheck = part = part.toLowerCase();
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);
+ }
+ },
+ find: {
+ ID: function(match, context, isXML){
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+ return m ? [m] : [];
+ }
+ },
+ NAME: function(match, context){
+ if ( typeof context.getElementsByName !== "undefined" ) {
+ var ret = [], results = context.getElementsByName(match[1]);
+
+ for ( var i = 0, l = results.length; i < l; i++ ) {
+ if ( results[i].getAttribute("name") === match[1] ) {
+ ret.push( results[i] );
+ }
+ }
+
+ return ret.length === 0 ? null : ret;
+ }
+ },
+ TAG: function(match, context){
+ return context.getElementsByTagName(match[1]);
+ }
+ },
+ preFilter: {
+ CLASS: function(match, curLoop, inplace, result, not, isXML){
+ match = " " + match[1].replace(/\\/g, "") + " ";
+
+ if ( isXML ) {
+ return match;
+ }
+
+ for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
+ if ( elem ) {
+ if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) {
+ if ( !inplace ) {
+ result.push( elem );
+ }
+ } else if ( inplace ) {
+ curLoop[i] = false;
+ }
+ }
+ }
+
+ return false;
+ },
+ ID: function(match){
+ return match[1].replace(/\\/g, "");
+ },
+ TAG: function(match, curLoop){
+ return match[1].toLowerCase();
+ },
+ CHILD: function(match){
+ if ( match[1] === "nth" ) {
+ // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
+ var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
+ match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
+ !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
+
+ // calculate the numbers (first)n+(last) including if they are negative
+ match[2] = (test[1] + (test[2] || 1)) - 0;
+ match[3] = test[3] - 0;
+ }
+
+ // TODO: Move to normal caching system
+ match[0] = done++;
+
+ return match;
+ },
+ ATTR: function(match, curLoop, inplace, result, not, isXML){
+ var name = match[1].replace(/\\/g, "");
+
+ if ( !isXML && Expr.attrMap[name] ) {
+ match[1] = Expr.attrMap[name];
+ }
+
+ if ( match[2] === "~=" ) {
+ match[4] = " " + match[4] + " ";
+ }
+
+ return match;
+ },
+ PSEUDO: function(match, curLoop, inplace, result, not){
+ if ( match[1] === "not" ) {
+ // If we're dealing with a complex expression, or a simple one
+ if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
+ match[3] = Sizzle(match[3], null, null, curLoop);
+ } else {
+ var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
+ if ( !inplace ) {
+ result.push.apply( result, ret );
+ }
+ return false;
+ }
+ } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
+ return true;
+ }
+
+ return match;
+ },
+ POS: function(match){
+ match.unshift( true );
+ return match;
+ }
+ },
+ filters: {
+ enabled: function(elem){
+ return elem.disabled === false && elem.type !== "hidden";
+ },
+ disabled: function(elem){
+ return elem.disabled === true;
+ },
+ checked: function(elem){
+ return elem.checked === true;
+ },
+ selected: function(elem){
+ // Accessing this property makes selected-by-default
+ // options in Safari work properly
+ elem.parentNode.selectedIndex;
+ return elem.selected === true;
+ },
+ parent: function(elem){
+ return !!elem.firstChild;
+ },
+ empty: function(elem){
+ return !elem.firstChild;
+ },
+ has: function(elem, i, match){
+ return !!Sizzle( match[3], elem ).length;
+ },
+ header: function(elem){
+ return /h\d/i.test( elem.nodeName );
+ },
+ text: function(elem){
+ return "text" === elem.type;
+ },
+ radio: function(elem){
+ return "radio" === elem.type;
+ },
+ checkbox: function(elem){
+ return "checkbox" === elem.type;
+ },
+ file: function(elem){
+ return "file" === elem.type;
+ },
+ password: function(elem){
+ return "password" === elem.type;
+ },
+ submit: function(elem){
+ return "submit" === elem.type;
+ },
+ image: function(elem){
+ return "image" === elem.type;
+ },
+ reset: function(elem){
+ return "reset" === elem.type;
+ },
+ button: function(elem){
+ return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
+ },
+ input: function(elem){
+ return /input|select|textarea|button/i.test(elem.nodeName);
+ }
+ },
+ setFilters: {
+ first: function(elem, i){
+ return i === 0;
+ },
+ last: function(elem, i, match, array){
+ return i === array.length - 1;
+ },
+ even: function(elem, i){
+ return i % 2 === 0;
+ },
+ odd: function(elem, i){
+ return i % 2 === 1;
+ },
+ lt: function(elem, i, match){
+ return i < match[3] - 0;
+ },
+ gt: function(elem, i, match){
+ return i > match[3] - 0;
+ },
+ nth: function(elem, i, match){
+ return match[3] - 0 === i;
+ },
+ eq: function(elem, i, match){
+ return match[3] - 0 === i;
+ }
+ },
+ filter: {
+ PSEUDO: function(elem, match, i, array){
+ var name = match[1], filter = Expr.filters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+ } else if ( name === "contains" ) {
+ return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
+ } else if ( name === "not" ) {
+ var not = match[3];
+
+ for ( var i = 0, l = not.length; i < l; i++ ) {
+ if ( not[i] === elem ) {
+ return false;
+ }
+ }
+
+ return true;
+ } else {
+ throw "Syntax error, unrecognized expression: " + name;
+ }
+ },
+ CHILD: function(elem, match){
+ var type = match[1], node = elem;
+ switch (type) {
+ case 'only':
+ case 'first':
+ while ( (node = node.previousSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+ if ( type === "first" ) {
+ return true;
+ }
+ node = elem;
+ case 'last':
+ while ( (node = node.nextSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+ return true;
+ case 'nth':
+ var first = match[2], last = match[3];
+
+ if ( first === 1 && last === 0 ) {
+ return true;
+ }
+
+ var doneName = match[0],
+ parent = elem.parentNode;
+
+ if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
+ var count = 0;
+ for ( node = parent.firstChild; node; node = node.nextSibling ) {
+ if ( node.nodeType === 1 ) {
+ node.nodeIndex = ++count;
+ }
+ }
+ parent.sizcache = doneName;
+ }
+
+ var diff = elem.nodeIndex - last;
+ if ( first === 0 ) {
+ return diff === 0;
+ } else {
+ return ( diff % first === 0 && diff / first >= 0 );
+ }
+ }
+ },
+ ID: function(elem, match){
+ return elem.nodeType === 1 && elem.getAttribute("id") === match;
+ },
+ TAG: function(elem, match){
+ return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
+ },
+ CLASS: function(elem, match){
+ return (" " + (elem.className || elem.getAttribute("class")) + " ")
+ .indexOf( match ) > -1;
+ },
+ ATTR: function(elem, match){
+ var name = match[1],
+ result = Expr.attrHandle[ name ] ?
+ Expr.attrHandle[ name ]( elem ) :
+ elem[ name ] != null ?
+ elem[ name ] :
+ elem.getAttribute( name ),
+ value = result + "",
+ type = match[2],
+ check = match[4];
+
+ return result == null ?
+ type === "!=" :
+ type === "=" ?
+ value === check :
+ type === "*=" ?
+ value.indexOf(check) >= 0 :
+ type === "~=" ?
+ (" " + value + " ").indexOf(check) >= 0 :
+ !check ?
+ value && result !== false :
+ type === "!=" ?
+ value !== check :
+ type === "^=" ?
+ value.indexOf(check) === 0 :
+ type === "$=" ?
+ value.substr(value.length - check.length) === check :
+ type === "|=" ?
+ value === check || value.substr(0, check.length + 1) === check + "-" :
+ false;
+ },
+ POS: function(elem, match, i, array){
+ var name = match[2], filter = Expr.setFilters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+ }
+ }
+ }
+};
+
+var origPOS = Expr.match.POS;
+
+for ( var type in Expr.match ) {
+ Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source );
+ Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, function(all, num){
+ return "\\" + (num - 0 + 1);
+ }));
+}
+
+var makeArray = function(array, results) {
+ array = Array.prototype.slice.call( array, 0 );
+
+ if ( results ) {
+ results.push.apply( results, array );
+ return results;
+ }
+
+ return array;
+};
+
+// Perform a simple check to determine if the browser is capable of
+// converting a NodeList to an array using builtin methods.
+try {
+ Array.prototype.slice.call( document.documentElement.childNodes, 0 );
+
+// Provide a fallback method if it does not work
+} catch(e){
+ makeArray = function(array, results) {
+ var ret = results || [];
+
+ if ( toString.call(array) === "[object Array]" ) {
+ Array.prototype.push.apply( ret, array );
+ } else {
+ if ( typeof array.length === "number" ) {
+ for ( var i = 0, l = array.length; i < l; i++ ) {
+ ret.push( array[i] );
+ }
+ } else {
+ for ( var i = 0; array[i]; i++ ) {
+ ret.push( array[i] );
+ }
+ }
+ }
+
+ return ret;
+ };
+}
+
+var sortOrder;
+
+if ( document.documentElement.compareDocumentPosition ) {
+ sortOrder = function( a, b ) {
+ if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.compareDocumentPosition ? -1 : 1;
+ }
+
+ var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+} else if ( "sourceIndex" in document.documentElement ) {
+ sortOrder = function( a, b ) {
+ if ( !a.sourceIndex || !b.sourceIndex ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.sourceIndex ? -1 : 1;
+ }
+
+ var ret = a.sourceIndex - b.sourceIndex;
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+} else if ( document.createRange ) {
+ sortOrder = function( a, b ) {
+ if ( !a.ownerDocument || !b.ownerDocument ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.ownerDocument ? -1 : 1;
+ }
+
+ var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();
+ aRange.setStart(a, 0);
+ aRange.setEnd(a, 0);
+ bRange.setStart(b, 0);
+ bRange.setEnd(b, 0);
+ var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange);
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+}
+
+// Utility function for retreiving the text value of an array of DOM nodes
+function getText( elems ) {
+ var ret = "", elem;
+
+ for ( var i = 0; elems[i]; i++ ) {
+ elem = elems[i];
+
+ // Get the text from text nodes and CDATA nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
+ ret += elem.nodeValue;
+
+ // Traverse everything else, except comment nodes
+ } else if ( elem.nodeType !== 8 ) {
+ ret += getText( elem.childNodes );
+ }
+ }
+
+ return ret;
+}
+
+// Check to see if the browser returns elements by name when
+// querying by getElementById (and provide a workaround)
+(function(){
+ // We're going to inject a fake input element with a specified name
+ var form = document.createElement("div"),
+ id = "script" + (new Date).getTime();
+ form.innerHTML = "<a name='" + id + "'/>";
+
+ // Inject it into the root element, check its status, and remove it quickly
+ var root = document.documentElement;
+ root.insertBefore( form, root.firstChild );
+
+ // The workaround has to do additional checks after a getElementById
+ // Which slows things down for other browsers (hence the branching)
+ if ( document.getElementById( id ) ) {
+ Expr.find.ID = function(match, context, isXML){
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+ return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
+ }
+ };
+
+ Expr.filter.ID = function(elem, match){
+ var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
+ return elem.nodeType === 1 && node && node.nodeValue === match;
+ };
+ }
+
+ root.removeChild( form );
+ root = form = null; // release memory in IE
+})();
+
+(function(){
+ // Check to see if the browser returns only elements
+ // when doing getElementsByTagName("*")
+
+ // Create a fake element
+ var div = document.createElement("div");
+ div.appendChild( document.createComment("") );
+
+ // Make sure no comments are found
+ if ( div.getElementsByTagName("*").length > 0 ) {
+ Expr.find.TAG = function(match, context){
+ var results = context.getElementsByTagName(match[1]);
+
+ // Filter out possible comments
+ if ( match[1] === "*" ) {
+ var tmp = [];
+
+ for ( var i = 0; results[i]; i++ ) {
+ if ( results[i].nodeType === 1 ) {
+ tmp.push( results[i] );
+ }
+ }
+
+ results = tmp;
+ }
+
+ return results;
+ };
+ }
+
+ // Check to see if an attribute returns normalized href attributes
+ div.innerHTML = "<a href='#'></a>";
+ if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
+ div.firstChild.getAttribute("href") !== "#" ) {
+ Expr.attrHandle.href = function(elem){
+ return elem.getAttribute("href", 2);
+ };
+ }
+
+ div = null; // release memory in IE
+})();
+
+if ( document.querySelectorAll ) {
+ (function(){
+ var oldSizzle = Sizzle, div = document.createElement("div");
+ div.innerHTML = "<p class='TEST'></p>";
+
+ // Safari can't handle uppercase or unicode characters when
+ // in quirks mode.
+ if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
+ return;
+ }
+
+ Sizzle = function(query, context, extra, seed){
+ context = context || document;
+
+ // Only use querySelectorAll on non-XML documents
+ // (ID selectors don't work in non-HTML documents)
+ if ( !seed && context.nodeType === 9 && !isXML(context) ) {
+ try {
+ return makeArray( context.querySelectorAll(query), extra );
+ } catch(e){}
+ }
+
+ return oldSizzle(query, context, extra, seed);
+ };
+
+ for ( var prop in oldSizzle ) {
+ Sizzle[ prop ] = oldSizzle[ prop ];
+ }
+
+ div = null; // release memory in IE
+ })();
+}
+
+(function(){
+ var div = document.createElement("div");
+
+ div.innerHTML = "<div class='test e'></div><div class='test'></div>";
+
+ // Opera can't find a second classname (in 9.6)
+ // Also, make sure that getElementsByClassName actually exists
+ if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
+ return;
+ }
+
+ // Safari caches class attributes, doesn't catch changes (in 3.2)
+ div.lastChild.className = "e";
+
+ if ( div.getElementsByClassName("e").length === 1 ) {
+ return;
+ }
+
+ Expr.order.splice(1, 0, "CLASS");
+ Expr.find.CLASS = function(match, context, isXML) {
+ if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
+ return context.getElementsByClassName(match[1]);
+ }
+ };
+
+ div = null; // release memory in IE
+})();
+
+function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ elem = elem[dir];
+ var match = false;
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 && !isXML ){
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+
+ if ( elem.nodeName.toLowerCase() === cur ) {
+ match = elem;
+ break;
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ elem = elem[dir];
+ var match = false;
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 ) {
+ if ( !isXML ) {
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+ if ( typeof cur !== "string" ) {
+ if ( elem === cur ) {
+ match = true;
+ break;
+ }
+
+ } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
+ match = elem;
+ break;
+ }
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+var contains = document.compareDocumentPosition ? function(a, b){
+ return a.compareDocumentPosition(b) & 16;
+} : function(a, b){
+ return a !== b && (a.contains ? a.contains(b) : true);
+};
+
+var isXML = function(elem){
+ // documentElement is verified for cases where it doesn't yet exist
+ // (such as loading iframes in IE - #4833)
+ var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
+ return documentElement ? documentElement.nodeName !== "HTML" : false;
+};
+
+var posProcess = function(selector, context){
+ var tmpSet = [], later = "", match,
+ root = context.nodeType ? [context] : context;
+
+ // Position selectors must be done after the filter
+ // And so must :not(positional) so we move all PSEUDOs to the end
+ while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
+ later += match[0];
+ selector = selector.replace( Expr.match.PSEUDO, "" );
+ }
+
+ selector = Expr.relative[selector] ? selector + "*" : selector;
+
+ for ( var i = 0, l = root.length; i < l; i++ ) {
+ Sizzle( selector, root[i], tmpSet );
+ }
+
+ return Sizzle.filter( later, tmpSet );
+};
+
+// EXPOSE
+jQuery.find = Sizzle;
+jQuery.expr = Sizzle.selectors;
+jQuery.expr[":"] = jQuery.expr.filters;
+jQuery.unique = Sizzle.uniqueSort;
+jQuery.getText = getText;
+jQuery.isXMLDoc = isXML;
+jQuery.contains = contains;
+
+return;
+
+window.Sizzle = Sizzle;
+
+})();
+var runtil = /Until$/,
+ rparentsprev = /^(?:parents|prevUntil|prevAll)/,
+ // Note: This RegExp should be improved, or likely pulled from Sizzle
+ rmultiselector = /,/,
+ slice = Array.prototype.slice;
+
+// Implement the identical functionality for filter and not
+var winnow = function( elements, qualifier, keep ) {
+ if ( jQuery.isFunction( qualifier ) ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ return !!qualifier.call( elem, i, elem ) === keep;
+ });
+
+ } else if ( qualifier.nodeType ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ return (elem === qualifier) === keep;
+ });
+
+ } else if ( typeof qualifier === "string" ) {
+ var filtered = jQuery.grep(elements, function( elem ) {
+ return elem.nodeType === 1;
+ });
+
+ if ( isSimple.test( qualifier ) ) {
+ return jQuery.filter(qualifier, filtered, !keep);
+ } else {
+ qualifier = jQuery.filter( qualifier, elements );
+ }
+ }
+
+ return jQuery.grep(elements, function( elem, i ) {
+ return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
+ });
+};
+
+jQuery.fn.extend({
+ find: function( selector ) {
+ var ret = this.pushStack( "", "find", selector ), length = 0;
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ length = ret.length;
+ jQuery.find( selector, this[i], ret );
+
+ if ( i > 0 ) {
+ // Make sure that the results are unique
+ for ( var n = length; n < ret.length; n++ ) {
+ for ( var r = 0; r < length; r++ ) {
+ if ( ret[r] === ret[n] ) {
+ ret.splice(n--, 1);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return ret;
+ },
+
+ has: function( target ) {
+ var targets = jQuery( target );
+ return this.filter(function() {
+ for ( var i = 0, l = targets.length; i < l; i++ ) {
+ if ( jQuery.contains( this, targets[i] ) ) {
+ return true;
+ }
+ }
+ });
+ },
+
+ not: function( selector ) {
+ return this.pushStack( winnow(this, selector, false), "not", selector);
+ },
+
+ filter: function( selector ) {
+ return this.pushStack( winnow(this, selector, true), "filter", selector );
+ },
+
+ is: function( selector ) {
+ return !!selector && jQuery.filter( selector, this ).length > 0;
+ },
+
+ closest: function( selectors, context ) {
+ if ( jQuery.isArray( selectors ) ) {
+ var ret = [], cur = this[0], match, matches = {}, selector;
+
+ if ( cur && selectors.length ) {
+ for ( var i = 0, l = selectors.length; i < l; i++ ) {
+ selector = selectors[i];
+
+ if ( !matches[selector] ) {
+ matches[selector] = jQuery.expr.match.POS.test( selector ) ?
+ jQuery( selector, context || this.context ) :
+ selector;
+ }
+ }
+
+ while ( cur && cur.ownerDocument && cur !== context ) {
+ for ( selector in matches ) {
+ match = matches[selector];
+
+ if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) {
+ ret.push({ selector: selector, elem: cur });
+ delete matches[selector];
+ }
+ }
+ cur = cur.parentNode;
+ }
+ }
+
+ return ret;
+ }
+
+ var pos = jQuery.expr.match.POS.test( selectors ) ?
+ jQuery( selectors, context || this.context ) : null;
+
+ return this.map(function( i, cur ) {
+ while ( cur && cur.ownerDocument && cur !== context ) {
+ if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selectors) ) {
+ return cur;
+ }
+ cur = cur.parentNode;
+ }
+ return null;
+ });
+ },
+
+ // Determine the position of an element within
+ // the matched set of elements
+ index: function( elem ) {
+ if ( !elem || typeof elem === "string" ) {
+ return jQuery.inArray( this[0],
+ // If it receives a string, the selector is used
+ // If it receives nothing, the siblings are used
+ elem ? jQuery( elem ) : this.parent().children() );
+ }
+ // Locate the position of the desired element
+ return jQuery.inArray(
+ // If it receives a jQuery object, the first element is used
+ elem.jquery ? elem[0] : elem, this );
+ },
+
+ add: function( selector, context ) {
+ var set = typeof selector === "string" ?
+ jQuery( selector, context || this.context ) :
+ jQuery.makeArray( selector ),
+ all = jQuery.merge( this.get(), set );
+
+ return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
+ all :
+ jQuery.unique( all ) );
+ },
+
+ andSelf: function() {
+ return this.add( this.prevObject );
+ }
+});
+
+// A painfully simple check to see if an element is disconnected
+// from a document (should be improved, where feasible).
+function isDisconnected( node ) {
+ return !node || !node.parentNode || node.parentNode.nodeType === 11;
+}
+
+jQuery.each({
+ parent: function( elem ) {
+ var parent = elem.parentNode;
+ return parent && parent.nodeType !== 11 ? parent : null;
+ },
+ parents: function( elem ) {
+ return jQuery.dir( elem, "parentNode" );
+ },
+ parentsUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "parentNode", until );
+ },
+ next: function( elem ) {
+ return jQuery.nth( elem, 2, "nextSibling" );
+ },
+ prev: function( elem ) {
+ return jQuery.nth( elem, 2, "previousSibling" );
+ },
+ nextAll: function( elem ) {
+ return jQuery.dir( elem, "nextSibling" );
+ },
+ prevAll: function( elem ) {
+ return jQuery.dir( elem, "previousSibling" );
+ },
+ nextUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "nextSibling", until );
+ },
+ prevUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "previousSibling", until );
+ },
+ siblings: function( elem ) {
+ return jQuery.sibling( elem.parentNode.firstChild, elem );
+ },
+ children: function( elem ) {
+ return jQuery.sibling( elem.firstChild );
+ },
+ contents: function( elem ) {
+ return jQuery.nodeName( elem, "iframe" ) ?
+ elem.contentDocument || elem.contentWindow.document :
+ jQuery.makeArray( elem.childNodes );
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function( until, selector ) {
+ var ret = jQuery.map( this, fn, until );
+
+ if ( !runtil.test( name ) ) {
+ selector = until;
+ }
+
+ if ( selector && typeof selector === "string" ) {
+ ret = jQuery.filter( selector, ret );
+ }
+
+ ret = this.length > 1 ? jQuery.unique( ret ) : ret;
+
+ if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
+ ret = ret.reverse();
+ }
+
+ return this.pushStack( ret, name, slice.call(arguments).join(",") );
+ };
+});
+
+jQuery.extend({
+ filter: function( expr, elems, not ) {
+ if ( not ) {
+ expr = ":not(" + expr + ")";
+ }
+
+ return jQuery.find.matches(expr, elems);
+ },
+
+ dir: function( elem, dir, until ) {
+ var matched = [], cur = elem[dir];
+ while ( cur && cur.nodeType !== 9 && (until === undefined || !jQuery( cur ).is( until )) ) {
+ if ( cur.nodeType === 1 ) {
+ matched.push( cur );
+ }
+ cur = cur[dir];
+ }
+ return matched;
+ },
+
+ nth: function( cur, result, dir, elem ) {
+ result = result || 1;
+ var num = 0;
+
+ for ( ; cur; cur = cur[dir] ) {
+ if ( cur.nodeType === 1 && ++num === result ) {
+ break;
+ }
+ }
+
+ return cur;
+ },
+
+ sibling: function( n, elem ) {
+ var r = [];
+
+ for ( ; n; n = n.nextSibling ) {
+ if ( n.nodeType === 1 && n !== elem ) {
+ r.push( n );
+ }
+ }
+
+ return r;
+ }
+});
+var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
+ rleadingWhitespace = /^\s+/,
+ rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g,
+ rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,
+ rtagName = /<([\w:]+)/,
+ rtbody = /<tbody/i,
+ rhtml = /<|&\w+;/,
+ fcloseTag = function( all, front, tag ) {
+ return rselfClosing.test( tag ) ?
+ all :
+ front + "></" + tag + ">";
+ },
+ wrapMap = {
+ option: [ 1, "<select multiple='multiple'>", "</select>" ],
+ legend: [ 1, "<fieldset>", "</fieldset>" ],
+ thead: [ 1, "<table>", "</table>" ],
+ tr: [ 2, "<table><tbody>", "</tbody></table>" ],
+ td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
+ col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
+ area: [ 1, "<map>", "</map>" ],
+ _default: [ 0, "", "" ]
+ };
+
+wrapMap.optgroup = wrapMap.option;
+wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
+wrapMap.th = wrapMap.td;
+
+// IE can't serialize <link> and <script> tags normally
+if ( !jQuery.support.htmlSerialize ) {
+ wrapMap._default = [ 1, "div<div>", "</div>" ];
+}
+
+jQuery.fn.extend({
+ text: function( text ) {
+ if ( jQuery.isFunction(text) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ return self.text( text.call(this, i, self.text()) );
+ });
+ }
+
+ if ( typeof text !== "object" && text !== undefined ) {
+ return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
+ }
+
+ return jQuery.getText( this );
+ },
+
+ wrapAll: function( html ) {
+ if ( jQuery.isFunction( html ) ) {
+ return this.each(function(i) {
+ jQuery(this).wrapAll( html.call(this, i) );
+ });
+ }
+
+ if ( this[0] ) {
+ // The elements to wrap the target around
+ var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
+
+ if ( this[0].parentNode ) {
+ wrap.insertBefore( this[0] );
+ }
+
+ wrap.map(function() {
+ var elem = this;
+
+ while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
+ elem = elem.firstChild;
+ }
+
+ return elem;
+ }).append(this);
+ }
+
+ return this;
+ },
+
+ wrapInner: function( html ) {
+ return this.each(function() {
+ var self = jQuery( this ), contents = self.contents();
+
+ if ( contents.length ) {
+ contents.wrapAll( html );
+
+ } else {
+ self.append( html );
+ }
+ });
+ },
+
+ wrap: function( html ) {
+ return this.each(function() {
+ jQuery( this ).wrapAll( html );
+ });
+ },
+
+ unwrap: function() {
+ return this.parent().each(function() {
+ if ( !jQuery.nodeName( this, "body" ) ) {
+ jQuery( this ).replaceWith( this.childNodes );
+ }
+ }).end();
+ },
+
+ append: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 ) {
+ this.appendChild( elem );
+ }
+ });
+ },
+
+ prepend: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 ) {
+ this.insertBefore( elem, this.firstChild );
+ }
+ });
+ },
+
+ before: function() {
+ if ( this[0] && this[0].parentNode ) {
+ return this.domManip(arguments, false, function( elem ) {
+ this.parentNode.insertBefore( elem, this );
+ });
+ } else if ( arguments.length ) {
+ var set = jQuery(arguments[0]);
+ set.push.apply( set, this.toArray() );
+ return this.pushStack( set, "before", arguments );
+ }
+ },
+
+ after: function() {
+ if ( this[0] && this[0].parentNode ) {
+ return this.domManip(arguments, false, function( elem ) {
+ this.parentNode.insertBefore( elem, this.nextSibling );
+ });
+ } else if ( arguments.length ) {
+ var set = this.pushStack( this, "after", arguments );
+ set.push.apply( set, jQuery(arguments[0]).toArray() );
+ return set;
+ }
+ },
+
+ clone: function( events ) {
+ // Do the clone
+ var ret = this.map(function() {
+ if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) {
+ // IE copies events bound via attachEvent when
+ // using cloneNode. Calling detachEvent on the
+ // clone will also remove the events from the orignal
+ // In order to get around this, we use innerHTML.
+ // Unfortunately, this means some modifications to
+ // attributes in IE that are actually only stored
+ // as properties will not be copied (such as the
+ // the name attribute on an input).
+ var html = this.outerHTML, ownerDocument = this.ownerDocument;
+ if ( !html ) {
+ var div = ownerDocument.createElement("div");
+ div.appendChild( this.cloneNode(true) );
+ html = div.innerHTML;
+ }
+
+ return jQuery.clean([html.replace(rinlinejQuery, "")
+ .replace(rleadingWhitespace, "")], ownerDocument)[0];
+ } else {
+ return this.cloneNode(true);
+ }
+ });
+
+ // Copy the events from the original to the clone
+ if ( events === true ) {
+ cloneCopyEvent( this, ret );
+ cloneCopyEvent( this.find("*"), ret.find("*") );
+ }
+
+ // Return the cloned set
+ return ret;
+ },
+
+ html: function( value ) {
+ if ( value === undefined ) {
+ return this[0] && this[0].nodeType === 1 ?
+ this[0].innerHTML.replace(rinlinejQuery, "") :
+ null;
+
+ // See if we can take a shortcut and just use innerHTML
+ } else if ( typeof value === "string" && !/<script/i.test( value ) &&
+ (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
+ !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
+
+ try {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ // Remove element nodes and prevent memory leaks
+ if ( this[i].nodeType === 1 ) {
+ cleanData( this[i].getElementsByTagName("*") );
+ this[i].innerHTML = value;
+ }
+ }
+
+ // If using innerHTML throws an exception, use the fallback method
+ } catch(e) {
+ this.empty().append( value );
+ }
+
+ } else if ( jQuery.isFunction( value ) ) {
+ this.each(function(i){
+ var self = jQuery(this), old = self.html();
+ self.empty().append(function(){
+ return value.call( this, i, old );
+ });
+ });
+
+ } else {
+ this.empty().append( value );
+ }
+
+ return this;
+ },
+
+ replaceWith: function( value ) {
+ if ( this[0] && this[0].parentNode ) {
+ // Make sure that the elements are removed from the DOM before they are inserted
+ // this can help fix replacing a parent with child elements
+ if ( !jQuery.isFunction( value ) ) {
+ value = jQuery( value ).detach();
+ }
+
+ return this.each(function() {
+ var next = this.nextSibling, parent = this.parentNode;
+
+ jQuery(this).remove();
+
+ if ( next ) {
+ jQuery(next).before( value );
+ } else {
+ jQuery(parent).append( value );
+ }
+ });
+ } else {
+ return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value );
+ }
+ },
+
+ detach: function( selector ) {
+ return this.remove( selector, true );
+ },
+
+ domManip: function( args, table, callback ) {
+ var results, first, value = args[0], scripts = [];
+
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ args[0] = value.call(this, i, table ? self.html() : undefined);
+ return self.domManip( args, table, callback );
+ });
+ }
+
+ if ( this[0] ) {
+ // If we're in a fragment, just use that instead of building a new one
+ if ( args[0] && args[0].parentNode && args[0].parentNode.nodeType === 11 ) {
+ results = { fragment: args[0].parentNode };
+ } else {
+ results = buildFragment( args, this, scripts );
+ }
+
+ first = results.fragment.firstChild;
+
+ if ( first ) {
+ table = table && jQuery.nodeName( first, "tr" );
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ callback.call(
+ table ?
+ root(this[i], first) :
+ this[i],
+ results.cacheable || this.length > 1 || i > 0 ?
+ results.fragment.cloneNode(true) :
+ results.fragment
+ );
+ }
+ }
+
+ if ( scripts ) {
+ jQuery.each( scripts, evalScript );
+ }
+ }
+
+ return this;
+
+ function root( elem, cur ) {
+ return jQuery.nodeName(elem, "table") ?
+ (elem.getElementsByTagName("tbody")[0] ||
+ elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
+ elem;
+ }
+ }
+});
+
+function cloneCopyEvent(orig, ret) {
+ var i = 0;
+
+ ret.each(function() {
+ if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) {
+ return;
+ }
+
+ var oldData = jQuery.data( orig[i++] ), curData = jQuery.data( this, oldData ), events = oldData && oldData.events;
+
+ if ( events ) {
+ delete curData.handle;
+ curData.events = {};
+
+ for ( var type in events ) {
+ for ( var handler in events[ type ] ) {
+ jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data );
+ }
+ }
+ }
+ });
+}
+
+function buildFragment( args, nodes, scripts ) {
+ var fragment, cacheable, cached, cacheresults, doc;
+
+ if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) {
+ cacheable = true;
+ cacheresults = jQuery.fragments[ args[0] ];
+ if ( cacheresults ) {
+ if ( cacheresults !== 1 ) {
+ fragment = cacheresults;
+ }
+ cached = true;
+ }
+ }
+
+ if ( !fragment ) {
+ doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
+ fragment = doc.createDocumentFragment();
+ jQuery.clean( args, doc, fragment, scripts );
+ }
+
+ if ( cacheable ) {
+ jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
+ }
+
+ return { fragment: fragment, cacheable: cacheable };
+}
+
+jQuery.fragments = {};
+
+jQuery.each({
+ appendTo: "append",
+ prependTo: "prepend",
+ insertBefore: "before",
+ insertAfter: "after",
+ replaceAll: "replaceWith"
+}, function( name, original ) {
+ jQuery.fn[ name ] = function( selector ) {
+ var ret = [], insert = jQuery( selector );
+
+ for ( var i = 0, l = insert.length; i < l; i++ ) {
+ var elems = (i > 0 ? this.clone(true) : this).get();
+ jQuery.fn[ original ].apply( jQuery(insert[i]), elems );
+ ret = ret.concat( elems );
+ }
+ return this.pushStack( ret, name, insert.selector );
+ };
+});
+
+jQuery.each({
+ // keepData is for internal use only--do not document
+ remove: function( selector, keepData ) {
+ if ( !selector || jQuery.filter( selector, [ this ] ).length ) {
+ if ( !keepData && this.nodeType === 1 ) {
+ cleanData( this.getElementsByTagName("*") );
+ cleanData( [ this ] );
+ }
+
+ if ( this.parentNode ) {
+ this.parentNode.removeChild( this );
+ }
+ }
+ },
+
+ empty: function() {
+ // Remove element nodes and prevent memory leaks
+ if ( this.nodeType === 1 ) {
+ cleanData( this.getElementsByTagName("*") );
+ }
+
+ // Remove any remaining nodes
+ while ( this.firstChild ) {
+ this.removeChild( this.firstChild );
+ }
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function() {
+ return this.each( fn, arguments );
+ };
+});
+
+jQuery.extend({
+ clean: function( elems, context, fragment, scripts ) {
+ context = context || document;
+
+ // !context.createElement fails in IE with an error but returns typeof 'object'
+ if ( typeof context.createElement === "undefined" ) {
+ context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
+ }
+
+ var ret = [];
+
+ jQuery.each(elems, function( i, elem ) {
+ if ( typeof elem === "number" ) {
+ elem += "";
+ }
+
+ if ( !elem ) {
+ return;
+ }
+
+ // Convert html string into DOM nodes
+ if ( typeof elem === "string" && !rhtml.test( elem ) ) {
+ elem = context.createTextNode( elem );
+
+ } else if ( typeof elem === "string" ) {
+ // Fix "XHTML"-style tags in all browsers
+ elem = elem.replace(rxhtmlTag, fcloseTag);
+
+ // Trim whitespace, otherwise indexOf won't work as expected
+ var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
+ wrap = wrapMap[ tag ] || wrapMap._default,
+ depth = wrap[0],
+ div = context.createElement("div");
+
+ // Go to html and back, then peel off extra wrappers
+ div.innerHTML = wrap[1] + elem + wrap[2];
+
+ // Move to the right depth
+ while ( depth-- ) {
+ div = div.lastChild;
+ }
+
+ // Remove IE's autoinserted <tbody> from table fragments
+ if ( !jQuery.support.tbody ) {
+
+ // String was a <table>, *may* have spurious <tbody>
+ var hasBody = rtbody.test(elem),
+ tbody = tag === "table" && !hasBody ?
+ div.firstChild && div.firstChild.childNodes :
+
+ // String was a bare <thead> or <tfoot>
+ wrap[1] === "<table>" && !hasBody ?
+ div.childNodes :
+ [];
+
+ for ( var j = tbody.length - 1; j >= 0 ; --j ) {
+ if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
+ tbody[ j ].parentNode.removeChild( tbody[ j ] );
+ }
+ }
+
+ }
+
+ // IE completely kills leading whitespace when innerHTML is used
+ if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
+ div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
+ }
+
+ elem = jQuery.makeArray( div.childNodes );
+ }
+
+ if ( elem.nodeType ) {
+ ret.push( elem );
+ } else {
+ ret = jQuery.merge( ret, elem );
+ }
+
+ });
+
+ if ( fragment ) {
+ for ( var i = 0; ret[i]; i++ ) {
+ if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
+ scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
+ } else {
+ if ( ret[i].nodeType === 1 ) {
+ ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
+ }
+ fragment.appendChild( ret[i] );
+ }
+ }
+ }
+
+ return ret;
+ }
+});
+
+function cleanData( elems ) {
+ for ( var i = 0, elem, id; (elem = elems[i]) != null; i++ ) {
+ if ( !jQuery.noData[elem.nodeName.toLowerCase()] && (id = elem[expando]) ) {
+ delete jQuery.cache[ id ];
+ }
+ }
+}
+// exclude the following css properties to add px
+var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
+ ralpha = /alpha\([^)]*\)/,
+ ropacity = /opacity=([^)]*)/,
+ rfloat = /float/i,
+ rdashAlpha = /-([a-z])/ig,
+ rupper = /([A-Z])/g,
+ rnumpx = /^-?\d+(?:px)?$/i,
+ rnum = /^-?\d/,
+
+ cssShow = { position: "absolute", visibility: "hidden", display:"block" },
+ cssWidth = [ "Left", "Right" ],
+ cssHeight = [ "Top", "Bottom" ],
+
+ // cache check for defaultView.getComputedStyle
+ getComputedStyle = document.defaultView && document.defaultView.getComputedStyle,
+ // normalize float css property
+ styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat",
+ fcamelCase = function( all, letter ) {
+ return letter.toUpperCase();
+ };
+
+jQuery.fn.css = function( name, value ) {
+ return access( this, name, value, true, function( elem, name, value ) {
+ if ( value === undefined ) {
+ return jQuery.curCSS( elem, name );
+ }
+
+ if ( typeof value === "number" && !rexclude.test(name) ) {
+ value += "px";
+ }
+
+ jQuery.style( elem, name, value );
+ });
+};
+
+jQuery.extend({
+ style: function( elem, name, value ) {
+ // don't set styles on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ // ignore negative width and height values #1599
+ if ( (name === "width" || name === "height") && parseFloat(value) < 0 ) {
+ value = undefined;
+ }
+
+ var style = elem.style || elem, set = value !== undefined;
+
+ // IE uses filters for opacity
+ if ( !jQuery.support.opacity && name === "opacity" ) {
+ if ( set ) {
+ // IE has trouble with opacity if it does not have layout
+ // Force it by setting the zoom level
+ style.zoom = 1;
+
+ // Set the alpha filter to set the opacity
+ var opacity = parseInt( value, 10 ) + "" === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")";
+ var filter = style.filter || jQuery.curCSS( elem, "filter" ) || "";
+ style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : opacity;
+ }
+
+ return style.filter && style.filter.indexOf("opacity=") >= 0 ?
+ (parseFloat( ropacity.exec(style.filter)[1] ) / 100) + "":
+ "";
+ }
+
+ // Make sure we're using the right name for getting the float value
+ if ( rfloat.test( name ) ) {
+ name = styleFloat;
+ }
+
+ name = name.replace(rdashAlpha, fcamelCase);
+
+ if ( set ) {
+ style[ name ] = value;
+ }
+
+ return style[ name ];
+ },
+
+ css: function( elem, name, force, extra ) {
+ if ( name === "width" || name === "height" ) {
+ var val, props = cssShow, which = name === "width" ? cssWidth : cssHeight;
+
+ function getWH() {
+ val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
+
+ if ( extra === "border" ) {
+ return;
+ }
+
+ jQuery.each( which, function() {
+ if ( !extra ) {
+ val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
+ }
+
+ if ( extra === "margin" ) {
+ val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0;
+ } else {
+ val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
+ }
+ });
+ }
+
+ if ( elem.offsetWidth !== 0 ) {
+ getWH();
+ } else {
+ jQuery.swap( elem, props, getWH );
+ }
+
+ return Math.max(0, Math.round(val));
+ }
+
+ return jQuery.curCSS( elem, name, force );
+ },
+
+ curCSS: function( elem, name, force ) {
+ var ret, style = elem.style, filter;
+
+ // IE uses filters for opacity
+ if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) {
+ ret = ropacity.test(elem.currentStyle.filter || "") ?
+ (parseFloat(RegExp.$1) / 100) + "" :
+ "";
+
+ return ret === "" ?
+ "1" :
+ ret;
+ }
+
+ // Make sure we're using the right name for getting the float value
+ if ( rfloat.test( name ) ) {
+ name = styleFloat;
+ }
+
+ if ( !force && style && style[ name ] ) {
+ ret = style[ name ];
+
+ } else if ( getComputedStyle ) {
+
+ // Only "float" is needed here
+ if ( rfloat.test( name ) ) {
+ name = "float";
+ }
+
+ name = name.replace( rupper, "-$1" ).toLowerCase();
+
+ var defaultView = elem.ownerDocument.defaultView;
+
+ if ( !defaultView ) {
+ return null;
+ }
+
+ var computedStyle = defaultView.getComputedStyle( elem, null );
+
+ if ( computedStyle ) {
+ ret = computedStyle.getPropertyValue( name );
+ }
+
+ // We should always get a number back from opacity
+ if ( name === "opacity" && ret === "" ) {
+ ret = "1";
+ }
+
+ } else if ( elem.currentStyle ) {
+ var camelCase = name.replace(rdashAlpha, fcamelCase);
+
+ ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
+
+ // From the awesome hack by Dean Edwards
+ // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
+
+ // If we're not dealing with a regular pixel number
+ // but a number that has a weird ending, we need to convert it to pixels
+ if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
+ // Remember the original values
+ var left = style.left, rsLeft = elem.runtimeStyle.left;
+
+ // Put in the new values to get a computed value out
+ elem.runtimeStyle.left = elem.currentStyle.left;
+ style.left = camelCase === "fontSize" ? "1em" : (ret || 0);
+ ret = style.pixelLeft + "px";
+
+ // Revert the changed values
+ style.left = left;
+ elem.runtimeStyle.left = rsLeft;
+ }
+ }
+
+ return ret;
+ },
+
+ // A method for quickly swapping in/out CSS properties to get correct calculations
+ swap: function( elem, options, callback ) {
+ var old = {};
+
+ // Remember the old values, and insert the new ones
+ for ( var name in options ) {
+ old[ name ] = elem.style[ name ];
+ elem.style[ name ] = options[ name ];
+ }
+
+ callback.call( elem );
+
+ // Revert the old values
+ for ( var name in options ) {
+ elem.style[ name ] = old[ name ];
+ }
+ }
+});
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.hidden = function( elem ) {
+ var width = elem.offsetWidth, height = elem.offsetHeight,
+ skip = elem.nodeName.toLowerCase() === "tr";
+
+ return width === 0 && height === 0 && !skip ?
+ true :
+ width > 0 && height > 0 && !skip ?
+ false :
+ jQuery.curCSS(elem, "display") === "none";
+ };
+
+ jQuery.expr.filters.visible = function( elem ) {
+ return !jQuery.expr.filters.hidden( elem );
+ };
+}
+var jsc = now(),
+ rscript = /<script(.|\s)*?\/script>/gi,
+ rselectTextarea = /select|textarea/i,
+ rinput = /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,
+ jsre = /=\?(&|$)/,
+ rquery = /\?/,
+ rts = /(\?|&)_=.*?(&|$)/,
+ rurl = /^(\w+:)?\/\/([^\/?#]+)/,
+ r20 = /%20/g;
+
+jQuery.fn.extend({
+ // Keep a copy of the old load
+ _load: jQuery.fn.load,
+
+ load: function( url, params, callback ) {
+ if ( typeof url !== "string" ) {
+ return this._load( url );
+
+ // Don't do a request if no elements are being requested
+ } else if ( !this.length ) {
+ return this;
+ }
+
+ var off = url.indexOf(" ");
+ if ( off >= 0 ) {
+ var selector = url.slice(off, url.length);
+ url = url.slice(0, off);
+ }
+
+ // Default to a GET request
+ var type = "GET";
+
+ // If the second parameter was provided
+ if ( params ) {
+ // If it's a function
+ if ( jQuery.isFunction( params ) ) {
+ // We assume that it's the callback
+ callback = params;
+ params = null;
+
+ // Otherwise, build a param string
+ } else if ( typeof params === "object" ) {
+ params = jQuery.param( params, jQuery.ajaxSettings.traditional );
+ type = "POST";
+ }
+ }
+
+ // Request the remote document
+ jQuery.ajax({
+ url: url,
+ type: type,
+ dataType: "html",
+ data: params,
+ context:this,
+ complete: function( res, status ) {
+ // If successful, inject the HTML into all the matched elements
+ if ( status === "success" || status === "notmodified" ) {
+ // See if a selector was specified
+ this.html( selector ?
+ // Create a dummy div to hold the results
+ jQuery("<div />")
+ // inject the contents of the document in, removing the scripts
+ // to avoid any 'Permission Denied' errors in IE
+ .append(res.responseText.replace(rscript, ""))
+
+ // Locate the specified elements
+ .find(selector) :
+
+ // If not, just inject the full result
+ res.responseText );
+ }
+
+ if ( callback ) {
+ this.each( callback, [res.responseText, status, res] );
+ }
+ }
+ });
+
+ return this;
+ },
+
+ serialize: function() {
+ return jQuery.param(this.serializeArray());
+ },
+ serializeArray: function() {
+ return this.map(function() {
+ return this.elements ? jQuery.makeArray(this.elements) : this;
+ })
+ .filter(function() {
+ return this.name && !this.disabled &&
+ (this.checked || rselectTextarea.test(this.nodeName) ||
+ rinput.test(this.type));
+ })
+ .map(function( i, elem ) {
+ var val = jQuery(this).val();
+
+ return val == null ?
+ null :
+ jQuery.isArray(val) ?
+ jQuery.map( val, function( val, i ) {
+ return { name: elem.name, value: val };
+ }) :
+ { name: elem.name, value: val };
+ }).get();
+ }
+});
+
+// Attach a bunch of functions for handling common AJAX events
+jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function( i, o ) {
+ jQuery.fn[o] = function( f ) {
+ return this.bind(o, f);
+ };
+});
+
+jQuery.extend({
+
+ get: function( url, data, callback, type ) {
+ // shift arguments if data argument was omited
+ if ( jQuery.isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = null;
+ }
+
+ return jQuery.ajax({
+ type: "GET",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ getScript: function( url, callback ) {
+ return jQuery.get(url, null, callback, "script");
+ },
+
+ getJSON: function( url, data, callback ) {
+ return jQuery.get(url, data, callback, "json");
+ },
+
+ post: function( url, data, callback, type ) {
+ // shift arguments if data argument was omited
+ if ( jQuery.isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = {};
+ }
+
+ return jQuery.ajax({
+ type: "POST",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ ajaxSetup: function( settings ) {
+ jQuery.extend( jQuery.ajaxSettings, settings );
+ },
+
+ ajaxSettings: {
+ url: location.href,
+ global: true,
+ type: "GET",
+ contentType: "application/x-www-form-urlencoded",
+ processData: true,
+ async: true,
+ /*
+ timeout: 0,
+ data: null,
+ username: null,
+ password: null,
+ traditional: false,
+ */
+ // Create the request object; Microsoft failed to properly
+ // implement the XMLHttpRequest in IE7 (can't request local files),
+ // so we use the ActiveXObject when it is available
+ // This function can be overriden by calling jQuery.ajaxSetup
+ xhr: window.XMLHttpRequest && (window.location.protocol !== "file:" || !window.ActiveXObject) ?
+ function() {
+ return new window.XMLHttpRequest();
+ } :
+ function() {
+ try {
+ return new window.ActiveXObject("Microsoft.XMLHTTP");
+ } catch(e) {}
+ },
+ accepts: {
+ xml: "application/xml, text/xml",
+ html: "text/html",
+ script: "text/javascript, application/javascript",
+ json: "application/json, text/javascript",
+ text: "text/plain",
+ _default: "*/*"
+ }
+ },
+
+ // Last-Modified header cache for next request
+ lastModified: {},
+ etag: {},
+
+ ajax: function( origSettings ) {
+ var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings);
+
+ var jsonp, status, data,
+ callbackContext = s.context || s,
+ type = s.type.toUpperCase();
+
+ // convert data if not already a string
+ if ( s.data && s.processData && typeof s.data !== "string" ) {
+ s.data = jQuery.param( s.data, s.traditional );
+ }
+
+ // Handle JSONP Parameter Callbacks
+ if ( s.dataType === "jsonp" ) {
+ if ( type === "GET" ) {
+ if ( !jsre.test( s.url ) ) {
+ s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?";
+ }
+ } else if ( !s.data || !jsre.test(s.data) ) {
+ s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
+ }
+ s.dataType = "json";
+ }
+
+ // Build temporary JSONP function
+ if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) {
+ jsonp = s.jsonpCallback || ("jsonp" + jsc++);
+
+ // Replace the =? sequence both in the query string and the data
+ if ( s.data ) {
+ s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
+ }
+
+ s.url = s.url.replace(jsre, "=" + jsonp + "$1");
+
+ // We need to make sure
+ // that a JSONP style response is executed properly
+ s.dataType = "script";
+
+ // Handle JSONP-style loading
+ window[ jsonp ] = window[ jsonp ] || function( tmp ) {
+ data = tmp;
+ success();
+ complete();
+ // Garbage collect
+ window[ jsonp ] = undefined;
+
+ try {
+ delete window[ jsonp ];
+ } catch(e) {}
+
+ if ( head ) {
+ head.removeChild( script );
+ }
+ };
+ }
+
+ if ( s.dataType === "script" && s.cache === null ) {
+ s.cache = false;
+ }
+
+ if ( s.cache === false && type === "GET" ) {
+ var ts = now();
+
+ // try replacing _= if it is there
+ var ret = s.url.replace(rts, "$1_=" + ts + "$2");
+
+ // if nothing was replaced, add timestamp to the end
+ s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : "");
+ }
+
+ // If data is available, append data to url for get requests
+ if ( s.data && type === "GET" ) {
+ s.url += (rquery.test(s.url) ? "&" : "?") + s.data;
+ }
+
+ // Watch for a new set of requests
+ if ( s.global && ! jQuery.active++ ) {
+ jQuery.event.trigger( "ajaxStart" );
+ }
+
+ // Matches an absolute URL, and saves the domain
+ var parts = rurl.exec( s.url ),
+ remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host);
+
+ // If we're requesting a remote document
+ // and trying to load JSON or Script with a GET
+ if ( s.dataType === "script" && type === "GET" && remote ) {
+ var head = document.getElementsByTagName("head")[0] || document.documentElement;
+ var script = document.createElement("script");
+ script.src = s.url;
+ if ( s.scriptCharset ) {
+ script.charset = s.scriptCharset;
+ }
+
+ // Handle Script loading
+ if ( !jsonp ) {
+ var done = false;
+
+ // Attach handlers for all browsers
+ script.onload = script.onreadystatechange = function() {
+ if ( !done && (!this.readyState ||
+ this.readyState === "loaded" || this.readyState === "complete") ) {
+ done = true;
+ success();
+ complete();
+
+ // Handle memory leak in IE
+ script.onload = script.onreadystatechange = null;
+ if ( head && script.parentNode ) {
+ head.removeChild( script );
+ }
+ }
+ };
+ }
+
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709 and #4378).
+ head.insertBefore( script, head.firstChild );
+
+ // We handle everything using the script element injection
+ return undefined;
+ }
+
+ var requestDone = false;
+
+ // Create the request object
+ var xhr = s.xhr();
+
+ if ( !xhr ) {
+ return;
+ }
+
+ // Open the socket
+ // Passing null username, generates a login popup on Opera (#2865)
+ if ( s.username ) {
+ xhr.open(type, s.url, s.async, s.username, s.password);
+ } else {
+ xhr.open(type, s.url, s.async);
+ }
+
+ // Need an extra try/catch for cross domain requests in Firefox 3
+ try {
+ // Set the correct header, if data is being sent
+ if ( s.data || origSettings && origSettings.contentType ) {
+ xhr.setRequestHeader("Content-Type", s.contentType);
+ }
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if ( s.ifModified ) {
+ if ( jQuery.lastModified[s.url] ) {
+ xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]);
+ }
+
+ if ( jQuery.etag[s.url] ) {
+ xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]);
+ }
+ }
+
+ // Set header so the called script knows that it's an XMLHttpRequest
+ // Only send the header if it's not a remote XHR
+ if ( !remote ) {
+ xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+ }
+
+ // Set the Accepts header for the server, depending on the dataType
+ xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ?
+ s.accepts[ s.dataType ] + ", */*" :
+ s.accepts._default );
+ } catch(e) {}
+
+ // Allow custom headers/mimetypes and early abort
+ if ( s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false ) {
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active ) {
+ jQuery.event.trigger( "ajaxStop" );
+ }
+
+ // close opended socket
+ xhr.abort();
+ return false;
+ }
+
+ if ( s.global ) {
+ trigger("ajaxSend", [xhr, s]);
+ }
+
+ // Wait for a response to come back
+ var onreadystatechange = xhr.onreadystatechange = function( isTimeout ) {
+ // The request was aborted
+ if ( !xhr || xhr.readyState === 0 ) {
+ // Opera doesn't call onreadystatechange before this point
+ // so we simulate the call
+ if ( !requestDone ) {
+ complete();
+ }
+
+ requestDone = true;
+ if ( xhr ) {
+ xhr.onreadystatechange = jQuery.noop;
+ }
+
+ // The transfer is complete and the data is available, or the request timed out
+ } else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) {
+ requestDone = true;
+ xhr.onreadystatechange = jQuery.noop;
+
+ status = isTimeout === "timeout" ?
+ "timeout" :
+ !jQuery.httpSuccess( xhr ) ?
+ "error" :
+ s.ifModified && jQuery.httpNotModified( xhr, s.url ) ?
+ "notmodified" :
+ "success";
+
+ if ( status === "success" ) {
+ // Watch for, and catch, XML document parse errors
+ try {
+ // process the data (runs the xml through httpData regardless of callback)
+ data = jQuery.httpData( xhr, s.dataType, s );
+ } catch(e) {
+ status = "parsererror";
+ }
+ }
+
+ // Make sure that the request was successful or notmodified
+ if ( status === "success" || status === "notmodified" ) {
+ // JSONP handles its own success callback
+ if ( !jsonp ) {
+ success();
+ }
+ } else {
+ jQuery.handleError(s, xhr, status);
+ }
+
+ // Fire the complete handlers
+ complete();
+
+ if ( isTimeout === "timeout" ) {
+ xhr.abort();
+ }
+
+ // Stop memory leaks
+ if ( s.async ) {
+ xhr = null;
+ }
+ }
+ };
+
+ // Override the abort handler, if we can (IE doesn't allow it, but that's OK)
+ // Opera doesn't fire onreadystatechange at all on abort
+ try {
+ var oldAbort = xhr.abort;
+ xhr.abort = function() {
+ if ( xhr ) {
+ oldAbort.call( xhr );
+ if ( xhr ) {
+ xhr.readyState = 0;
+ }
+ }
+
+ onreadystatechange();
+ };
+ } catch(e) { }
+
+ // Timeout checker
+ if ( s.async && s.timeout > 0 ) {
+ setTimeout(function() {
+ // Check to see if the request is still happening
+ if ( xhr && !requestDone ) {
+ onreadystatechange( "timeout" );
+ }
+ }, s.timeout);
+ }
+
+ // Send the data
+ try {
+ xhr.send( type === "POST" || type === "PUT" || type === "DELETE" ? s.data : null );
+ } catch(e) {
+ jQuery.handleError(s, xhr, null, e);
+ // Fire the complete handlers
+ complete();
+ }
+
+ // firefox 1.5 doesn't fire statechange for sync requests
+ if ( !s.async ) {
+ onreadystatechange();
+ }
+
+ function success() {
+ // If a local callback was specified, fire it and pass it the data
+ if ( s.success ) {
+ s.success.call( callbackContext, data, status, xhr );
+ }
+
+ // Fire the global callback
+ if ( s.global ) {
+ trigger( "ajaxSuccess", [xhr, s] );
+ }
+ }
+
+ function complete() {
+ // Process result
+ if ( s.complete ) {
+ s.complete.call( callbackContext, xhr, status);
+ }
+
+ // The request was completed
+ if ( s.global ) {
+ trigger( "ajaxComplete", [xhr, s] );
+ }
+
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active ) {
+ jQuery.event.trigger( "ajaxStop" );
+ }
+ }
+
+ function trigger(type, args) {
+ (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args);
+ }
+
+ // return XMLHttpRequest to allow aborting the request etc.
+ return xhr;
+ },
+
+ handleError: function( s, xhr, status, e ) {
+ // If a local callback was specified, fire it
+ if ( s.error ) {
+ s.error.call( s.context || window, xhr, status, e );
+ }
+
+ // Fire the global callback
+ if ( s.global ) {
+ (s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] );
+ }
+ },
+
+ // Counter for holding the number of active queries
+ active: 0,
+
+ // Determines if an XMLHttpRequest was successful or not
+ httpSuccess: function( xhr ) {
+ try {
+ // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
+ return !xhr.status && location.protocol === "file:" ||
+ // Opera returns 0 when status is 304
+ ( xhr.status >= 200 && xhr.status < 300 ) ||
+ xhr.status === 304 || xhr.status === 1223 || xhr.status === 0;
+ } catch(e) {}
+
+ return false;
+ },
+
+ // Determines if an XMLHttpRequest returns NotModified
+ httpNotModified: function( xhr, url ) {
+ var lastModified = xhr.getResponseHeader("Last-Modified"),
+ etag = xhr.getResponseHeader("Etag");
+
+ if ( lastModified ) {
+ jQuery.lastModified[url] = lastModified;
+ }
+
+ if ( etag ) {
+ jQuery.etag[url] = etag;
+ }
+
+ // Opera returns 0 when status is 304
+ return xhr.status === 304 || xhr.status === 0;
+ },
+
+ httpData: function( xhr, type, s ) {
+ var ct = xhr.getResponseHeader("content-type") || "",
+ xml = type === "xml" || !type && ct.indexOf("xml") >= 0,
+ data = xml ? xhr.responseXML : xhr.responseText;
+
+ if ( xml && data.documentElement.nodeName === "parsererror" ) {
+ throw "parsererror";
+ }
+
+ // Allow a pre-filtering function to sanitize the response
+ // s is checked to keep backwards compatibility
+ if ( s && s.dataFilter ) {
+ data = s.dataFilter( data, type );
+ }
+
+ // The filter can actually parse the response
+ if ( typeof data === "string" ) {
+ // Get the JavaScript object, if JSON is used.
+ if ( type === "json" || !type && ct.indexOf("json") >= 0 ) {
+ // Make sure the incoming data is actual JSON
+ // Logic borrowed from http://json.org/json2.js
+ if (/^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]")
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ""))) {
+
+ // Try to use the native JSON parser first
+ if ( window.JSON && window.JSON.parse ) {
+ data = window.JSON.parse( data );
+
+ } else {
+ data = (new Function("return " + data))();
+ }
+
+ } else {
+ throw "Invalid JSON: " + data;
+ }
+
+ // If the type is "script", eval it in global context
+ } else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) {
+ jQuery.globalEval( data );
+ }
+ }
+
+ return data;
+ },
+
+ // Serialize an array of form elements or a set of
+ // key/values into a query string
+ param: function( a, traditional ) {
+
+ var s = [];
+
+ // Set traditional to true for jQuery <= 1.3.2 behavior.
+ if ( traditional === undefined ) {
+ traditional = jQuery.ajaxSettings.traditional;
+ }
+
+ function add( key, value ) {
+ // If value is a function, invoke it and return its value
+ value = jQuery.isFunction(value) ? value() : value;
+ s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
+ }
+
+ // If an array was passed in, assume that it is an array of form elements.
+ if ( jQuery.isArray(a) || a.jquery ) {
+ // Serialize the form elements
+ jQuery.each( a, function() {
+ add( this.name, this.value );
+ });
+
+ } else {
+ // If traditional, encode the "old" way (the way 1.3.2 or older
+ // did it), otherwise encode params recursively.
+ jQuery.each( a, function buildParams( prefix, obj ) {
+
+ if ( jQuery.isArray(obj) ) {
+ // Serialize array item.
+ jQuery.each( obj, function( i, v ) {
+ if ( traditional ) {
+ // Treat each array item as a scalar.
+ add( prefix, v );
+ } else {
+ // If array item is non-scalar (array or object), encode its
+ // numeric index to resolve deserialization ambiguity issues.
+ // Note that rack (as of 1.0.0) can't currently deserialize
+ // nested arrays properly, and attempting to do so may cause
+ // a server error. Possible fixes are to modify rack's
+ // deserialization algorithm or to provide an option or flag
+ // to force array serialization to be shallow.
+ buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v );
+ }
+ });
+
+ } else if ( !traditional && obj != null && typeof obj === "object" ) {
+ // Serialize object item.
+ jQuery.each( obj, function( k, v ) {
+ buildParams( prefix + "[" + k + "]", v );
+ });
+
+ } else {
+ // Serialize scalar item.
+ add( prefix, obj );
+ }
+ });
+ }
+
+ // Return the resulting serialization
+ return s.join("&").replace(r20, "+");
+ }
+
+});
+var elemdisplay = {},
+ rfxtypes = /toggle|show|hide/,
+ rfxnum = /^([+-]=)?([\d+-.]+)(.*)$/,
+ timerId,
+ fxAttrs = [
+ // height animations
+ [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
+ // width animations
+ [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
+ // opacity animations
+ [ "opacity" ]
+ ];
+
+jQuery.fn.extend({
+ show: function( speed, callback ) {
+ if ( speed != null ) {
+ return this.animate( genFx("show", 3), speed, callback);
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var old = jQuery.data(this[i], "olddisplay");
+
+ this[i].style.display = old || "";
+
+ if ( jQuery.css(this[i], "display") === "none" ) {
+ var nodeName = this[i].nodeName, display;
+
+ if ( elemdisplay[ nodeName ] ) {
+ display = elemdisplay[ nodeName ];
+
+ } else {
+ var elem = jQuery("<" + nodeName + " />").appendTo("body");
+
+ display = elem.css("display");
+
+ if ( display === "none" ) {
+ display = "block";
+ }
+
+ elem.remove();
+
+ elemdisplay[ nodeName ] = display;
+ }
+
+ jQuery.data(this[i], "olddisplay", display);
+ }
+ }
+
+ // Set the display of the elements in a second loop
+ // to avoid the constant reflow
+ for ( var j = 0, k = this.length; j < k; j++ ) {
+ this[j].style.display = jQuery.data(this[j], "olddisplay") || "";
+ }
+
+ return this;
+ }
+ },
+
+ hide: function( speed, callback ) {
+ if ( speed != null ) {
+ return this.animate( genFx("hide", 3), speed, callback);
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var old = jQuery.data(this[i], "olddisplay");
+ if ( !old && old !== "none" ) {
+ jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display"));
+ }
+ }
+
+ // Set the display of the elements in a second loop
+ // to avoid the constant reflow
+ for ( var j = 0, k = this.length; j < k; j++ ) {
+ this[j].style.display = "none";
+ }
+
+ return this;
+ }
+ },
+
+ // Save the old toggle function
+ _toggle: jQuery.fn.toggle,
+
+ toggle: function( fn, fn2 ) {
+ var bool = typeof fn === "boolean";
+
+ if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
+ this._toggle.apply( this, arguments );
+
+ } else if ( fn == null || bool ) {
+ this.each(function() {
+ var state = bool ? fn : jQuery(this).is(":hidden");
+ jQuery(this)[ state ? "show" : "hide" ]();
+ });
+
+ } else {
+ this.animate(genFx("toggle", 3), fn, fn2);
+ }
+
+ return this;
+ },
+
+ fadeTo: function( speed, to, callback ) {
+ return this.filter(":hidden").css("opacity", 0).show().end()
+ .animate({opacity: to}, speed, callback);
+ },
+
+ animate: function( prop, speed, easing, callback ) {
+ var optall = jQuery.speed(speed, easing, callback);
+
+ if ( jQuery.isEmptyObject( prop ) ) {
+ return this.each( optall.complete );
+ }
+
+ return this[ optall.queue === false ? "each" : "queue" ](function() {
+ var opt = jQuery.extend({}, optall), p,
+ hidden = this.nodeType === 1 && jQuery(this).is(":hidden"),
+ self = this;
+
+ for ( p in prop ) {
+ var name = p.replace(rdashAlpha, fcamelCase);
+
+ if ( p !== name ) {
+ prop[ name ] = prop[ p ];
+ delete prop[ p ];
+ p = name;
+ }
+
+ if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
+ return opt.complete.call(this);
+ }
+
+ if ( ( p === "height" || p === "width" ) && this.style ) {
+ // Store display property
+ opt.display = jQuery.css(this, "display");
+
+ // Make sure that nothing sneaks out
+ opt.overflow = this.style.overflow;
+ }
+
+ if ( jQuery.isArray( prop[p] ) ) {
+ // Create (if needed) and add to specialEasing
+ (opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1];
+ prop[p] = prop[p][0];
+ }
+ }
+
+ if ( opt.overflow != null ) {
+ this.style.overflow = "hidden";
+ }
+
+ opt.curAnim = jQuery.extend({}, prop);
+
+ jQuery.each( prop, function( name, val ) {
+ var e = new jQuery.fx( self, opt, name );
+
+ if ( rfxtypes.test(val) ) {
+ e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop );
+
+ } else {
+ var parts = rfxnum.exec(val),
+ start = e.cur(true) || 0;
+
+ if ( parts ) {
+ var end = parseFloat( parts[2] ),
+ unit = parts[3] || "px";
+
+ // We need to compute starting value
+ if ( unit !== "px" ) {
+ self.style[ name ] = (end || 1) + unit;
+ start = ((end || 1) / e.cur(true)) * start;
+ self.style[ name ] = start + unit;
+ }
+
+ // If a +=/-= token was provided, we're doing a relative animation
+ if ( parts[1] ) {
+ end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
+ }
+
+ e.custom( start, end, unit );
+
+ } else {
+ e.custom( start, val, "" );
+ }
+ }
+ });
+
+ // For JS strict compliance
+ return true;
+ });
+ },
+
+ stop: function( clearQueue, gotoEnd ) {
+ var timers = jQuery.timers;
+
+ if ( clearQueue ) {
+ this.queue([]);
+ }
+
+ this.each(function() {
+ // go in reverse order so anything added to the queue during the loop is ignored
+ for ( var i = timers.length - 1; i >= 0; i-- ) {
+ if ( timers[i].elem === this ) {
+ if (gotoEnd) {
+ // force the next step to be the last
+ timers[i](true);
+ }
+
+ timers.splice(i, 1);
+ }
+ }
+ });
+
+ // start the next in the queue if the last step wasn't forced
+ if ( !gotoEnd ) {
+ this.dequeue();
+ }
+
+ return this;
+ }
+
+});
+
+// Generate shortcuts for custom animations
+jQuery.each({
+ slideDown: genFx("show", 1),
+ slideUp: genFx("hide", 1),
+ slideToggle: genFx("toggle", 1),
+ fadeIn: { opacity: "show" },
+ fadeOut: { opacity: "hide" }
+}, function( name, props ) {
+ jQuery.fn[ name ] = function( speed, callback ) {
+ return this.animate( props, speed, callback );
+ };
+});
+
+jQuery.extend({
+ speed: function( speed, easing, fn ) {
+ var opt = speed && typeof speed === "object" ? speed : {
+ complete: fn || !fn && easing ||
+ jQuery.isFunction( speed ) && speed,
+ duration: speed,
+ easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
+ };
+
+ opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
+ jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default;
+
+ // Queueing
+ opt.old = opt.complete;
+ opt.complete = function() {
+ if ( opt.queue !== false ) {
+ jQuery(this).dequeue();
+ }
+ if ( jQuery.isFunction( opt.old ) ) {
+ opt.old.call( this );
+ }
+ };
+
+ return opt;
+ },
+
+ easing: {
+ linear: function( p, n, firstNum, diff ) {
+ return firstNum + diff * p;
+ },
+ swing: function( p, n, firstNum, diff ) {
+ return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
+ }
+ },
+
+ timers: [],
+
+ fx: function( elem, options, prop ) {
+ this.options = options;
+ this.elem = elem;
+ this.prop = prop;
+
+ if ( !options.orig ) {
+ options.orig = {};
+ }
+ }
+
+});
+
+jQuery.fx.prototype = {
+ // Simple function for setting a style value
+ update: function() {
+ if ( this.options.step ) {
+ this.options.step.call( this.elem, this.now, this );
+ }
+
+ (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
+
+ // Set display property to block for height/width animations
+ if ( ( this.prop === "height" || this.prop === "width" ) && this.elem.style ) {
+ this.elem.style.display = "block";
+ }
+ },
+
+ // Get the current size
+ cur: function( force ) {
+ if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
+ return this.elem[ this.prop ];
+ }
+
+ var r = parseFloat(jQuery.css(this.elem, this.prop, force));
+ return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
+ },
+
+ // Start an animation from one number to another
+ custom: function( from, to, unit ) {
+ this.startTime = now();
+ this.start = from;
+ this.end = to;
+ this.unit = unit || this.unit || "px";
+ this.now = this.start;
+ this.pos = this.state = 0;
+
+ var self = this;
+ function t( gotoEnd ) {
+ return self.step(gotoEnd);
+ }
+
+ t.elem = this.elem;
+
+ if ( t() && jQuery.timers.push(t) && !timerId ) {
+ timerId = setInterval(jQuery.fx.tick, 13);
+ }
+ },
+
+ // Simple 'show' function
+ show: function() {
+ // Remember where we started, so that we can go back to it later
+ this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
+ this.options.show = true;
+
+ // Begin the animation
+ // Make sure that we start at a small width/height to avoid any
+ // flash of content
+ this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
+
+ // Start by showing the element
+ jQuery( this.elem ).show();
+ },
+
+ // Simple 'hide' function
+ hide: function() {
+ // Remember where we started, so that we can go back to it later
+ this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
+ this.options.hide = true;
+
+ // Begin the animation
+ this.custom(this.cur(), 0);
+ },
+
+ // Each step of an animation
+ step: function( gotoEnd ) {
+ var t = now(), done = true;
+
+ if ( gotoEnd || t >= this.options.duration + this.startTime ) {
+ this.now = this.end;
+ this.pos = this.state = 1;
+ this.update();
+
+ this.options.curAnim[ this.prop ] = true;
+
+ for ( var i in this.options.curAnim ) {
+ if ( this.options.curAnim[i] !== true ) {
+ done = false;
+ }
+ }
+
+ if ( done ) {
+ if ( this.options.display != null ) {
+ // Reset the overflow
+ this.elem.style.overflow = this.options.overflow;
+
+ // Reset the display
+ var old = jQuery.data(this.elem, "olddisplay");
+ this.elem.style.display = old ? old : this.options.display;
+
+ if ( jQuery.css(this.elem, "display") === "none" ) {
+ this.elem.style.display = "block";
+ }
+ }
+
+ // Hide the element if the "hide" operation was done
+ if ( this.options.hide ) {
+ jQuery(this.elem).hide();
+ }
+
+ // Reset the properties, if the item has been hidden or shown
+ if ( this.options.hide || this.options.show ) {
+ for ( var p in this.options.curAnim ) {
+ jQuery.style(this.elem, p, this.options.orig[p]);
+ }
+ }
+
+ // Execute the complete function
+ this.options.complete.call( this.elem );
+ }
+
+ return false;
+
+ } else {
+ var n = t - this.startTime;
+ this.state = n / this.options.duration;
+
+ // Perform the easing function, defaults to swing
+ var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop];
+ var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear");
+ this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration);
+ this.now = this.start + ((this.end - this.start) * this.pos);
+
+ // Perform the next step of the animation
+ this.update();
+ }
+
+ return true;
+ }
+};
+
+jQuery.extend( jQuery.fx, {
+ tick: function() {
+ var timers = jQuery.timers;
+
+ for ( var i = 0; i < timers.length; i++ ) {
+ if ( !timers[i]() ) {
+ timers.splice(i--, 1);
+ }
+ }
+
+ if ( !timers.length ) {
+ jQuery.fx.stop();
+ }
+ },
+
+ stop: function() {
+ clearInterval( timerId );
+ timerId = null;
+ },
+
+ speeds: {
+ slow: 600,
+ fast: 200,
+ // Default speed
+ _default: 400
+ },
+
+ step: {
+ opacity: function( fx ) {
+ jQuery.style(fx.elem, "opacity", fx.now);
+ },
+
+ _default: function( fx ) {
+ if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
+ fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
+ } else {
+ fx.elem[ fx.prop ] = fx.now;
+ }
+ }
+ }
+});
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.animated = function( elem ) {
+ return jQuery.grep(jQuery.timers, function( fn ) {
+ return elem === fn.elem;
+ }).length;
+ };
+}
+
+function genFx( type, num ) {
+ var obj = {};
+
+ jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
+ obj[ this ] = type;
+ });
+
+ return obj;
+}
+if ( "getBoundingClientRect" in document.documentElement ) {
+ jQuery.fn.offset = function( options ) {
+ var elem = this[0];
+
+ if ( !elem || !elem.ownerDocument ) {
+ return null;
+ }
+
+ if ( options ) {
+ return this.each(function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ });
+ }
+
+ if ( elem === elem.ownerDocument.body ) {
+ return jQuery.offset.bodyOffset( elem );
+ }
+
+ var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement,
+ clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
+ top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop,
+ left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft;
+
+ return { top: top, left: left };
+ };
+
+} else {
+ jQuery.fn.offset = function( options ) {
+ var elem = this[0];
+
+ if ( !elem || !elem.ownerDocument ) {
+ return null;
+ }
+
+ if ( options ) {
+ return this.each(function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ });
+ }
+
+ if ( elem === elem.ownerDocument.body ) {
+ return jQuery.offset.bodyOffset( elem );
+ }
+
+ jQuery.offset.initialize();
+
+ var offsetParent = elem.offsetParent, prevOffsetParent = elem,
+ doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement,
+ body = doc.body, defaultView = doc.defaultView,
+ prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
+ top = elem.offsetTop, left = elem.offsetLeft;
+
+ while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
+ if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
+ break;
+ }
+
+ computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
+ top -= elem.scrollTop;
+ left -= elem.scrollLeft;
+
+ if ( elem === offsetParent ) {
+ top += elem.offsetTop;
+ left += elem.offsetLeft;
+
+ if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.nodeName)) ) {
+ top += parseFloat( computedStyle.borderTopWidth ) || 0;
+ left += parseFloat( computedStyle.borderLeftWidth ) || 0;
+ }
+
+ prevOffsetParent = offsetParent, offsetParent = elem.offsetParent;
+ }
+
+ if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
+ top += parseFloat( computedStyle.borderTopWidth ) || 0;
+ left += parseFloat( computedStyle.borderLeftWidth ) || 0;
+ }
+
+ prevComputedStyle = computedStyle;
+ }
+
+ if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
+ top += body.offsetTop;
+ left += body.offsetLeft;
+ }
+
+ if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
+ top += Math.max( docElem.scrollTop, body.scrollTop );
+ left += Math.max( docElem.scrollLeft, body.scrollLeft );
+ }
+
+ return { top: top, left: left };
+ };
+}
+
+jQuery.offset = {
+ initialize: function() {
+ var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0,
+ html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
+
+ jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
+
+ container.innerHTML = html;
+ body.insertBefore( container, body.firstChild );
+ innerDiv = container.firstChild;
+ checkDiv = innerDiv.firstChild;
+ td = innerDiv.nextSibling.firstChild.firstChild;
+
+ this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
+ this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
+
+ checkDiv.style.position = "fixed", checkDiv.style.top = "20px";
+ // safari subtracts parent border width here which is 5px
+ this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
+ checkDiv.style.position = checkDiv.style.top = "";
+
+ innerDiv.style.overflow = "hidden", innerDiv.style.position = "relative";
+ this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
+
+ this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
+
+ body.removeChild( container );
+ body = container = innerDiv = checkDiv = table = td = null;
+ jQuery.offset.initialize = jQuery.noop;
+ },
+
+ bodyOffset: function( body ) {
+ var top = body.offsetTop, left = body.offsetLeft;
+
+ jQuery.offset.initialize();
+
+ if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
+ top += parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0;
+ left += parseFloat( jQuery.curCSS(body, "marginLeft", true) ) || 0;
+ }
+
+ return { top: top, left: left };
+ },
+
+ setOffset: function( elem, options, i ) {
+ // set position first, in-case top/left are set even on static elem
+ if ( /static/.test( jQuery.curCSS( elem, "position" ) ) ) {
+ elem.style.position = "relative";
+ }
+ var curElem = jQuery( elem ),
+ curOffset = curElem.offset(),
+ curTop = parseInt( jQuery.curCSS( elem, "top", true ), 10 ) || 0,
+ curLeft = parseInt( jQuery.curCSS( elem, "left", true ), 10 ) || 0;
+
+ if ( jQuery.isFunction( options ) ) {
+ options = options.call( elem, i, curOffset );
+ }
+
+ var props = {
+ top: (options.top - curOffset.top) + curTop,
+ left: (options.left - curOffset.left) + curLeft
+ };
+
+ if ( "using" in options ) {
+ options.using.call( elem, props );
+ } else {
+ curElem.css( props );
+ }
+ }
+};
+
+
+jQuery.fn.extend({
+ position: function() {
+ if ( !this[0] ) {
+ return null;
+ }
+
+ var elem = this[0],
+
+ // Get *real* offsetParent
+ offsetParent = this.offsetParent(),
+
+ // Get correct offsets
+ offset = this.offset(),
+ parentOffset = /^body|html$/i.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
+
+ // Subtract element margins
+ // note: when an element has margin: auto the offsetLeft and marginLeft
+ // are the same in Safari causing offset.left to incorrectly be 0
+ offset.top -= parseFloat( jQuery.curCSS(elem, "marginTop", true) ) || 0;
+ offset.left -= parseFloat( jQuery.curCSS(elem, "marginLeft", true) ) || 0;
+
+ // Add offsetParent borders
+ parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], "borderTopWidth", true) ) || 0;
+ parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], "borderLeftWidth", true) ) || 0;
+
+ // Subtract the two offsets
+ return {
+ top: offset.top - parentOffset.top,
+ left: offset.left - parentOffset.left
+ };
+ },
+
+ offsetParent: function() {
+ return this.map(function() {
+ var offsetParent = this.offsetParent || document.body;
+ while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
+ offsetParent = offsetParent.offsetParent;
+ }
+ return offsetParent;
+ });
+ }
+});
+
+
+// Create scrollLeft and scrollTop methods
+jQuery.each( ["Left", "Top"], function( i, name ) {
+ var method = "scroll" + name;
+
+ jQuery.fn[ method ] = function(val) {
+ var elem = this[0], win;
+
+ if ( !elem ) {
+ return null;
+ }
+
+ if ( val !== undefined ) {
+ // Set the scroll offset
+ return this.each(function() {
+ win = getWindow( this );
+
+ if ( win ) {
+ win.scrollTo(
+ !i ? val : jQuery(win).scrollLeft(),
+ i ? val : jQuery(win).scrollTop()
+ );
+
+ } else {
+ this[ method ] = val;
+ }
+ });
+ } else {
+ win = getWindow( elem );
+
+ // Return the scroll offset
+ return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
+ jQuery.support.boxModel && win.document.documentElement[ method ] ||
+ win.document.body[ method ] :
+ elem[ method ];
+ }
+ };
+});
+
+function getWindow( elem ) {
+ return ("scrollTo" in elem && elem.document) ?
+ elem :
+ elem.nodeType === 9 ?
+ elem.defaultView || elem.parentWindow :
+ false;
+}
+// Create innerHeight, innerWidth, outerHeight and outerWidth methods
+jQuery.each([ "Height", "Width" ], function( i, name ) {
+
+ var type = name.toLowerCase();
+
+ // innerHeight and innerWidth
+ jQuery.fn["inner" + name] = function() {
+ return this[0] ?
+ jQuery.css( this[0], type, false, "padding" ) :
+ null;
+ };
+
+ // outerHeight and outerWidth
+ jQuery.fn["outer" + name] = function( margin ) {
+ return this[0] ?
+ jQuery.css( this[0], type, false, margin ? "margin" : "border" ) :
+ null;
+ };
+
+ jQuery.fn[ type ] = function( size ) {
+ // Get window width or height
+ var elem = this[0];
+ if ( !elem ) {
+ return size == null ? null : this;
+ }
+
+ return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window?
+ // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
+ elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
+ elem.document.body[ "client" + name ] :
+
+ // Get document width or height
+ (elem.nodeType === 9) ? // is it a document
+ // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
+ Math.max(
+ elem.documentElement["client" + name],
+ elem.body["scroll" + name], elem.documentElement["scroll" + name],
+ elem.body["offset" + name], elem.documentElement["offset" + name]
+ ) :
+
+ // Get or set width or height on the element
+ size === undefined ?
+ // Get width or height on the element
+ jQuery.css( elem, type ) :
+
+ // Set the width or height on the element (default to pixels if value is unitless)
+ this.css( type, typeof size === "string" ? size : size + "px" );
+ };
+
+});
+// Expose jQuery to the global object
+window.jQuery = window.$ = jQuery;
+
+})(window);
diff --git a/examples/lessons/6_English_whatsThisWord/js/jquery.watermarkinput.js b/examples/lessons/6_English_whatsThisWord/js/jquery.watermarkinput.js
new file mode 100755
index 0000000..fefa670
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/js/jquery.watermarkinput.js
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2007 Josh Bush (digitalbush.com)
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Version: Beta 1
+ * Release: 2007-06-01
+ */
+(function($) {
+ var map=new Array();
+ $.Watermark = {
+ ShowAll:function(){
+ for (var i=0;i<map.length;i++){
+ if(map[i].obj.val()==""){
+ map[i].obj.val(map[i].text);
+ map[i].obj.css("color",map[i].WatermarkColor);
+ }else{
+ map[i].obj.css("color",map[i].DefaultColor);
+ }
+ }
+ },
+ HideAll:function(){
+ for (var i=0;i<map.length;i++){
+ if(map[i].obj.val()==map[i].text)
+ map[i].obj.val("");
+ }
+ }
+ }
+
+ $.fn.Watermark = function(text,color) {
+ if(!color)
+ color="#aaa";
+ return this.each(
+ function(){
+ var input=$(this);
+ var defaultColor=input.css("color");
+ map[map.length]={text:text,obj:input,DefaultColor:defaultColor,WatermarkColor:color};
+ function clearMessage(){
+ if(input.val()==text)
+ input.val("");
+ input.css("color",defaultColor);
+ }
+
+ function insertMessage(){
+ if(input.val().length==0 || input.val()==text){
+ input.val(text);
+ input.css("color",color);
+ }else
+ input.css("color",defaultColor);
+ }
+
+ input.focus(clearMessage);
+ input.blur(insertMessage);
+ input.change(insertMessage);
+
+ insertMessage();
+ }
+ );
+ };
+})(jQuery); \ No newline at end of file
diff --git a/examples/lessons/6_English_whatsThisWord/js/karma.js b/examples/lessons/6_English_whatsThisWord/js/karma.js
new file mode 100755
index 0000000..03f027b
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/js/karma.js
@@ -0,0 +1,1018 @@
+/* Documentation Note:
+ * Public methods and properties are commented with /** some text *\/
+ * and private methods and properties are commented with //
+ *
+ * Please leave it that way to keep this documentation sane
+ */
+
+
+/*
+* Karma Framework
+* http://karmaeducation.org
+*
+* Copyright (c) 2009
+* Bryan W Berry bryan@olenepal.org
+* Felipe López Toledo zer.subzero@gmail.com
+*
+* Under MIT License:
+* Permission is hereby granted, free of charge, to any person
+* obtaining a copy of this software and associated documentation
+* files (the "Software"), to deal in the Software without
+* restriction, including without limitation the rights to use,
+* copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following
+* conditions:
+*
+* The above copyright notice and this permission notice shall be
+* included in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+/**
+* @fileOverview Contains karma library
+* @author Bryan Berry <bryan@olenepal.org>
+* @author Felipe Lopez Toledo <zer.subzero@gmail.com>
+*/
+
+
+//common.js modules use exports object
+if(!this.exports) {
+ exports = {};
+}
+
+
+
+/** Checks if the current document type is set to HTML 5, throws
+ * an error otherwise, then initializes the karma object and returns
+ * a reference to that object.
+ * @namespace Global namespace for Karma library
+ * @param {Object} [options={}] options for intializing Karma library
+ * @param {String} [options.locale=''] sets current locale Not Yet Implemented
+ * @param {Array} [options.image=[]] array of images to be converted into a collection
+ * @param {Array} [options.audio=[]] array of audio to be converted into a collection
+ * @param {Array} [options.video=[]] array of videos to be converted into a collection
+ * @param {Array} [options.svg=[]] array of SVG elements to be
+ * converted into a collection. Each SVG element must already exist in the html document
+ * @param {Array} [options.canvas=[]] array of canvas elements
+ * to be converted into a collection. Each canvas element must already exist in the
+ * html document and width and height of each element must be set as attributes
+ * @throws {Error} if the document type declaration is not set to HTML 5, e.g.
+ * <!DOCTYPE html>
+ * @throws {Error} If any of the initialization parameters are invalid values
+ * @returns {Object} Karma.karma -- reference to the initialized Karma library
+ * @example
+ *
+ * var k = Karma({
+ * image: [
+ * {name: "ninja", file: "ninja.png"},
+ * {name: "cowboy", file: "cowboy.png"}
+ * ],
+ * audio: [
+ * {name: "woosh", file: "woosh.ogg"},
+ * {name: "yeehaw", file: "yeehaw.ogg"}
+ * ],
+ * video: [
+ * {name: "attack", file: "attack.ogv"},
+ * {name: "ride", file: "ride.ogv"}
+ * ]
+ * canvas: [
+ * {name: "ninja", domId: "ninjaCanvas"},
+ * {name: "cowboy", domId: "cowboyCanvas"}
+ * ],
+ * svg: [
+ * {name: "ninja", domId: "ninjaSvg"},
+ * {name: "cowboy", domId: "cowboySvg"}
+ * ],
+ * });
+ * Next, call the ready function with a callback to your program code
+ *
+ * k.ready(function () { ... your application code . . . }
+ *
+ * after that you can access each asset like so
+ * k.image.ninja;
+ * k.svg.cowboy;
+ * k.audio.yeehaw.play();
+ * k.canvas.ninja.drawImage(k.image.ninja, 0, 0);
+ *
+ */
+var Karma = exports.Karma = function (options) {
+ Karma._isHtml5(document.doctype.nodeName);
+
+ if ( Karma.karma._initialized === true ) {
+ return Karma.karma;
+ } else {
+ return Karma.karma._init(options);
+ }
+};
+
+
+//helper functions
+
+/**This emulates the Object.create method in ecmascript 5 spec
+ * This isn't a full implementation as it doesn't support
+ * This has the same functionality as Crockford's beget method
+ * and this primary building block for prototypal inheritance in
+ * this library
+ * @param {Object} target that the new object's prototype should point to
+ * @returns {Object} object whose prototype points to target
+ * @example
+ *
+ * var ninja = { weapon : "sword" };
+ * var ninja1 = Karma.create(ninja);
+ * ninja1.sword === "sword"
+ */
+Karma.create = function (target){
+ function F () {};
+ F.prototype = target;
+ return new F();
+};
+
+/** Returns a shallow copy of the passed in object
+ * @param {Object} target to be copied
+ * @returns {Object} a shallow copy of target
+ */
+Karma.clone = function (target){
+ var copy = {};
+ for ( var i in target ) {
+ if(target.hasOwnProperty(i)){
+ copy[i] = target[i];
+ }
+ }
+ return copy;
+};
+
+/** Extends properties of the target object with those of
+ * the source object
+ * @param {Object} target object to be extended
+ * @param {Object} source whose properties will extend target
+ * @returns {Object} target extended by source
+ */
+Karma.objectPlus = function (target, source){
+ for ( var i in source){
+ if (source.hasOwnProperty(i)){
+ target[i] = source[i];
+ }
+ }
+ return target;
+};
+
+/** Creates a new object that is a prototype of the first argument
+ * then extends it with the properties of the second argument
+ * @param {Object} parent1 will be prototype of returned object
+ * @param {Object} parent2 will extend properties of returned object
+ * @returns {Object} object that whose prototype is parent1 and has
+ * been extended with properties of parent2
+ */
+Karma.copyObjectPlus = function (parent1, parent2){
+ function F () {};
+ F.prototype = parent1;
+ var G = new F();
+ return Karma.objectPlus(G, parent2);
+};
+
+//Enables function chaining for a specified list of function names
+//IMPORTANT: use of closures here with "this" and "that" is __very__
+//complicated here
+Karma._makeChain = function (chainingFunctions) {
+ var that = this;
+ var _chainFunction = function ( name ){
+ that[ name ] = function ( ){
+ var type = typeof this.ctx[name];
+ if ( type === "function") {
+ this.ctx[ name ].apply( this.ctx, arguments );
+ }else if ( type === "string" ){
+ this.ctx[ name ] = arguments[0];
+ }else {
+ throw ("wtf?!: impossible to chain " + name + "!");
+ }
+ return this;
+ };
+ };
+
+ for (var i = 0; i < chainingFunctions.length; i++){
+ _chainFunction( chainingFunctions[ i ] );
+ }
+};
+
+//Throws big ugly error if doctype isn't html5
+Karma._isHtml5 = function (doctype){
+ var regex = new RegExp('^html$', 'i');
+ if(!regex.test(doctype)){
+ var errorMsg = "ERROR: The doctype must be set to <!DOCTYPE html> " +
+ "in order to use Karma. Karma require you use html5";
+ var errorElem = document.createElement('div');
+ errorElem.setAttribute('id', 'errorDoctype');
+ errorElem.innerText = errorMsg;
+ document.body.appendChild(errorElem);
+ throw new Error(errorMsg);
+ }
+};
+
+
+/** Stores global settings for the Karma library
+ * @class This object stores the global settings for the Karma library
+ */
+Karma.karma = {
+ /** This is the global locale as passed to Karma(),
+ * such as "en", "es_SP"
+ * @type string
+ * @default undefined
+ */
+ locale : undefined,
+ /** Collection of images with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ image : {},
+ /** Collection of audio with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ audio : {},
+ /** Collection of canvas with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ canvas : {},
+ /** Collection of svgs with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ svg : {},
+ /** Collection of videos with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ video : {},
+ _localized : false,
+ _assetPath : "assets/",
+ _localePath : "",
+ _initialized : false,
+ _statusDiv: undefined,
+ _loaderDiv : undefined,
+ _counters : { total : 0, errors : 0, loaded : 0},
+
+ //init initializes all the assets passed to Karma, that's it
+ //it returns 'this' so it can be used for function chaining
+ _init: function(options) {
+ this._initialized = true;
+
+ //set up message that show count of assets loaded
+ //and has an ordered list to append error messages to
+ var _statusDiv = this._statusDiv = document.createElement('div');
+ this._loaderDiv = this._loaderDiv = document.createElement('div');
+ var errorList = document.createElement('ol');
+
+ _statusDiv.setAttribute('id', 'karma-status');
+ _statusDiv.setAttribute('style', 'position:absolute;');
+ _statusDiv.innerHTML = 'Karma is loading ...';
+ this._loaderDiv.setAttribute('id', 'karma-loader');
+ this._loaderDiv.setAttribute('class', 'status');
+ errorList.setAttribute('id', 'errorList');
+
+ _statusDiv.appendChild(this._loaderDiv);
+ this._statusDiv.appendChild(errorList);
+ document.body.appendChild(_statusDiv);
+
+
+ //chain the functions for kCanvas and kSvg
+ Karma._makeChain.call(Karma.kCanvas,
+ Karma.kCanvas._chainingFunctions);
+ //Karma._makeChain.apply(Karma.kSvg, Karma.kSvg._chainingFunctions);
+
+
+
+ //regular expression that matches the name of aprivate property
+ // the karma object
+ var regexPrivate = new RegExp('^_.*');
+
+ for ( var option in options ) {
+ if (options.hasOwnProperty(option)){
+ if (option === "image" || option === "audio" || option ===
+ "svg" || option === "video" || option === "canvas"){
+
+ if(!(options[option] instanceof Array)){
+ throw new Error("" + option + " must be an array");
+ } else if (options[option].length === 0){
+ continue;
+ }
+ } else if (regexPrivate.test(option)){
+ //don't overwrite a private property of karma object
+ continue;
+ }
+
+ switch (option){
+ case "locale":
+
+ if (this._isValidLocale(options[option])){
+ this.locale = this._normalizeLocale(options[option]);
+ this._localized = true;
+ this._localePath = Karma._computeLocalePath(this.locale);
+ } else {
+ throw new Error("locale provided to karma._init() is invalid");
+ }
+
+ break;
+ case "image":
+ options[option]._type = 'image';
+ Karma._makeImages(options[option]);
+ break;
+ case "audio":
+ options[option]._type = 'audio';
+ Karma._makeAudio(options[option]);
+ break;
+ case "video":
+ options[option]._type = 'video';
+ Karma._makeVideos(options[option]);
+ break;
+ case "svg":
+ options[option]._type = 'svg';
+ Karma._makeSvgs(options[option]);
+ break;
+ case "canvas":
+ options[option]._type = 'canvas';
+ Karma._makeCanvases(options[option]);
+ break;
+ }
+ }
+ }
+
+
+
+ return this;
+ },
+
+ /** Waits until all assets loaded, i.e. ready, then calls callback
+ * @param {Function} [cb] callback function
+ * @returns this
+ * @throws {Error} if Karma.karma is not initialized with the
+ * Karma({ options }) function
+ * @example
+ *
+ * var k = Karma({ . . . your assets here . . . });
+ * k.ready(function(){ .. your code here . . .});
+ *
+ * your code will not be called until all assets have been loaded
+ *
+ */
+ ready : function( cb ) {
+ var that = this;
+ if (Karma.karma._initialized !== true){
+ throw new Error("Karma.karma not initialized");
+ }
+
+ if (this._counters.loaded !== this._counters.total){
+ setTimeout(function(){ that.ready(cb);}, 5);
+ } else if (cb) {
+ //hide the "Karma is loading..." message
+ this._statusDiv.setAttribute('style', 'display:none;');
+
+ cb();
+ } else if (!cb) {
+ //hide the "Karma is loading..." message
+ this._statusDiv.setAttribute('style', 'display:none;');
+
+ //if no options passed, show it works message
+ this._showStarterMessage();
+ }
+
+
+
+
+ return this;
+ },
+
+ //Display Apache-like "It works" message if no options
+ _showStarterMessage : function (){
+ var starterMsg = document.createElement('div');
+ starterMsg.setAttribute('id', 'starterMsg');
+ starterMsg.innerHTML = "<h1>It Works</h1>";
+ document.body.appendChild(starterMsg);
+ },
+
+ //Updates visible counter of how many assets are loaded
+ _updateStatus : function (errorMsg) {
+ var loaded = this._counters.loaded;
+ var total = this._counters.total;
+ var errors = this._counters.errors;
+ this._loaderDiv.innerHTML = "Loaded " + loaded + " / " + total +
+ "" + (errors > 0 ? " Errors [ " + errors +" ]" : '');
+ if (errorMsg) {
+ var liError = document.createElement('li');
+ liError.innerHTML = errorMsg;
+ var errorList = document.getElementById('errorList');
+ errorList.appendChild(liError);
+ }
+ },
+
+ //matches 2 letter country code then optionally
+ //a dash or underscore followed by a country or language identifier
+ //i currently only allow a language identifier 2-3 chars long
+ _isValidLocale : function (locale) {
+ var localeRegex = new RegExp('^[a-zA-Z][a-zA-Z]([-_][a-zA-z]{2,3})?$');
+ return localeRegex.test(locale);
+ },
+
+ _normalizeLocale : function(locale) {
+ var lang = "";
+ var country = "";
+ var divider = "";
+
+ lang = locale.slice(0, 2).toLowerCase();
+ divider = "_";
+ country = locale.slice(3, 6).toUpperCase();
+
+ return locale.length > 2 ? "" + lang + divider + country : lang;
+ },
+
+ // Below are geometry and math helper methods
+
+ /**
+ * Converts a value from degrees to radians.
+ * @param {Number} angle The angle in degrees
+ * @returns {Number} The angle in radians
+ */
+ radians : function( angle ){
+ return ( angle / 180 ) * Math.PI;
+ },
+ /**
+ * Gets the square of the Euclidian (ordinary) distance between 2 points.
+ * @param {Object} Point No. 0
+ * @param {Number} Point0.x
+ * @param {Number} Point0.y
+ * @param {Object} Point No. 1
+ * @param {Number} Point1.x
+ * @param {Number} Point1.y
+ * @returns {Number} The square of the Euclidian distance
+ * @example
+ *
+ * p0 = {x:0, y:1};
+ * p1 = {x:50, y:70};
+ * var d = distance2(p0, p1);
+ *
+ */
+ distance2 : function ( p0, p1 ) {
+ return (p1.x - p0.x) * (p1.x - p0.x) + (p1.y - p1.y) * (p1.y - p1.y);
+ },
+ /**
+ * Gets the Euclidian (ordinary) distance between 2 points.<br>
+ * <b>Warning:</b> It's slower than distance2 function
+ * @param {Object} Point No. 0
+ * @param {Number} Point0.x
+ * @param {Number} Point0.y
+ * @param {Object} Point No. 1
+ * @param {Number} Point1.x
+ * @param {Number} Point1.y
+ * @returns {Number} The Euclidian distance
+ * @example
+ *
+ * p0 = {x:0, y:1};
+ * p1 = {x:50, y:70};
+ * var d = distance2(p0, p1);
+ *
+ */
+ distance : function ( p0, p1 ) {
+ return Math.sqrt( this.distance2( p0, p1 ) );
+ },
+ /** Returns a random number within the range provided
+ * @param {Number} lower limit of the range, lowest number that can be returned
+ * @param {Number} upper limit of the range, highest number that can be returned
+ * @returns {Number} number that is >= lower and <= upper
+ * @example
+ *
+ * var num = rand(0, 10);
+ *
+ * num could be 0, 1, 2, 3 ... or 10
+ *
+ */
+ rand : function ( lower, upper ){
+ return Math.round( Math.random() * (upper - lower) + lower );
+ }
+
+};
+
+/** Prototypal object for images, videos, and audio files but
+ * does not include svg or canvas elements
+ * @class This object is the prototype for images, videos, and audio files but
+ * does not include svg or canvas elements
+ * @ throws {Error} if the individual asset is set to be localized but
+ * the globale locale is not set on the Karma.karma object
+ * @ throws {Error} if the name and file properties are not supplied
+ * @example
+ * kMedia is the prototype object for images, audio, and videos.
+ * These 'media' assets are loaded in a distinctly different way
+ * from the canvas or svg assets. They also have distinctly different
+ * helper methods
+ *
+ * You initialize the kMedia assets by passing an array of objects
+ */
+Karma.kMedia = {
+ /** file location of asset
+ * @type String
+ * @default ""
+ */
+ file : "",
+ /** media object
+ * @type Audio|Image|Video
+ * @default undefined
+ */
+ media : undefined,
+ //actual path to the file
+ _path : "",
+ //if using localized version of this asset
+ _localized : false,
+ //audio, image, or video
+ _type : "",
+ //initializes kMedia instance with values provided by user
+ _init : function (asset) {
+ asset._localized = asset._localized || false;
+ Karma.karma._counters.total++;
+
+ if (asset.name === undefined || asset.file === undefined){
+ throw new Error("properties name and file have to be defined");
+ } else {
+ this.name = asset.name;
+ this.file = asset.file;
+ }
+
+ //_type is a private variable used internally
+ if (asset._type === undefined){
+ throw new Error("the _type property must be set. " +
+ "Blame the karma library authors as this is an internal value");
+ } else {
+ if (Karma._isValidType(asset._type)){
+ this._type = asset._type;
+ switch ( this._type ) {
+ case "image": this.media = new Image();
+ break;
+ case "audio": this.media = new Audio();
+ break;
+ //case "video":
+ //NYI
+ //this.media = new Video();
+ break;
+ default: throw new Error("Media type not supported");
+ }
+
+ } else {
+ throw new Error("the _type property supplied is invalid. " +
+ "Blame the karma library authors as this is an internal value");
+ }
+ }
+
+ if(Karma._isLocalized(asset._localized)){
+ this._localized = asset._localized;
+ this._path = Karma.karma._localePath +
+ this._type + "/";
+ } else {
+ this._path = Karma.karma._assetPath +
+ this._type + "/";
+ }
+
+
+ //IMPORTANT: This one magic line loads the file
+ this.media.src = this.src = this._path + this.file;
+
+ //add event handlers
+ this._addEventHandlers();
+
+ if (this._type === "audio"){
+ this.media.autobuffer = true;
+ this.media.load();
+ }
+
+
+ return this;
+ },
+ //Adds event handlers to update the counters when
+ //the asset is successfully or unsuccessfully loaded
+ _addEventHandlers : function () {
+ var that = this;
+ var loadEvent = "load";
+ //Browser Hack recommended by chromium devs
+ //http://code.google.com/p/chromium/issues/detail?id=20251&q=loading%20audio&colspec=ID%20Stars%20Pri%20Area%20Type%20Status%20Summary%20Modified%20Owner%20Mstone%20OS#c4
+ if (this._type === "audio" || this._type === "video"){
+ loadEvent = "canplaythrough";
+ }
+
+ that.media.addEventListener(
+ loadEvent,
+ function (e) {
+ Karma.karma._counters.loaded++;
+ Karma.karma._updateStatus();
+ that.status = "loaded";}, false);
+
+ that.media.addEventListener(
+ "error",
+ function (e) {
+ Karma.karma._counters.errors++;
+ that.status = "error";
+ var errorMsg = "Error: " + that._type.toUpperCase() +
+ " " + that.name + " cannot be loaded.";
+ Karma.karma._updateStatus(errorMsg);
+ },
+ false);
+ that.media.addEventListener(
+ "abort",
+ function (e) {
+ Karma.karma._counters.total++;
+ that.status = "aborted";
+ var errorMsg = "ABORT: " + that._type.toUpperCase() +
+ " " + that.name + " loading was aborted.";
+ Karma.karma._updateStatus(errorMsg);
+
+ }, false);
+
+ }
+
+};
+
+//determine if it is a valid type of asset
+Karma._isValidType = function (type){
+ return type === "image" ||
+ type === "svg" ||
+ type === "audio" ||
+ type === "video" ||
+ type === "canvas";
+};
+
+Karma._isLocalized = function (boolLocalized) {
+ if (typeof boolLocalized === "boolean" ) {
+ if(boolLocalized === true &&
+ Karma.karma.locale === undefined){
+ throw new Error("You cannot localize a media asset" +
+ " if the global locale for Karma isn't set");
+ } else {
+ return boolLocalized;
+ }
+ } else if (typeof boolLocalized === undefined){
+ return false;
+ } else{
+ throw new Error("This is not a valid value for the localized option");
+ }
+};
+
+Karma._computeLocalePath = function(locale) {
+ return Karma.karma._assetPath + locale + "/";
+};
+
+Karma._makeImages = function (imgConfigs){
+ var makeImage = function (imgConfig){
+ var image = undefined;
+ imgConfig._type = "image";
+ image = Karma.create(Karma.kMedia)._init(imgConfig);
+ Karma.karma.image[imgConfig.name] = image;
+ };
+
+ imgConfigs.forEach(function(imgConfig){ makeImage(imgConfig);});
+
+};
+
+Karma._makeAudio = function (audioConfigs){
+ var makeAudio = function (audioConfig){
+ var audio = undefined;
+ audioConfig._type = "audio";
+ audio = Karma.create(Karma.kMedia)._init(audioConfig);
+ audio.play = function () {
+ //hack to fix the audio "stuttering" problem
+ //more info: https://bugs.launchpad.net/karma/+bug/426108
+ this.media.currentTime = 0.1;
+ this.media.play();
+ };
+ Karma.karma.audio[audioConfig.name] = audio;
+ };
+
+ audioConfigs.forEach(function(audioConfig){ makeAudio(audioConfig);});
+
+};
+
+
+Karma._makeCanvases = function (canvasConfigs){
+ var makeCanvas = function (canvasConfig){
+ var canvas = undefined;
+ canvas = Karma.create(Karma.kCanvas)._init(canvasConfig);
+ Karma.karma.canvas[canvasConfig.name] = canvas;
+ };
+
+ canvasConfigs.forEach(function(canvasConfig){ makeCanvas(canvasConfig);});
+
+};
+
+/** Prototypal object for each canvas element submitted to Karma in the
+ * Karma() method
+ * @throws {Error} if the name and domId for the canvas element are not specified
+ * @thows {Error} if the supplied domId does not match an element in the DOM
+ * @class This object is the prototype for each canvas element submitted to Karma in the
+ * Karma() method
+ */
+Karma.kCanvas = {
+ /** Name of the canvas, used internally by karma.js
+ * @type String
+ * @default ''
+ */
+ name : '',
+ /** Width of canvas element
+ * @type Number
+ * @default 0
+ */
+ width: 0,
+ /** Height of canvas element
+ * @type Number
+ * @default 0
+ */
+ height: 0,
+ /** Whether canvas is visible
+ * @type boolean
+ * @default true
+ */
+ visible: true,
+ /** Element ID for canvas element in html document
+ * @type String
+ * @default undefined
+ */
+ domId: undefined,
+ /** Reference to the DOM element
+ * @type DOMElement
+ * @default undefined
+ */
+ node: undefined,
+ /** The 2 Dimensional Rendering context property for this canvas
+ * @type 2DRenderingContext
+ * @default undefined
+ */
+ ctx: undefined,
+ /** Frames Per Second, I don't know what the purpose of this is,
+ * Felipe made it up
+ * @type Number
+ * @default 24
+ */
+ fps: 24,
+
+ //initializes object with values provides by user
+ _init: function (config) {
+ for (var option in config){
+ if (config.hasOwnProperty(option)){
+ switch (option){
+ case "name":
+ this.name = config[option];
+ break;
+ case "domId":
+ this.domId = config[option];
+ break;
+ case "width":
+ if(!this.height){
+ throw new Error("If you specify a width you must also" +
+ "specify a height");
+ }
+ this.width = config[option];
+ break;
+ case "height":
+ if(!this.width){
+ throw new Error("If you specify a height you must also" +
+ "specify a width");
+ }
+ this.height = parseInt(config.option, 10);
+ break;
+ case "fps":
+ this.fps = parseInt(config.option, 10);
+ break;
+ }
+ }
+ }
+
+ if(this.domId && document.getElementById(this.domId)){
+ this.node = document.getElementById(this.domId);
+ this.ctx = this.node.getContext('2d');
+ } else {
+ throw new Error('you must specify a valid domId that' +
+ 'is in your html page');
+ }
+
+ if(!config.height && !config.width){
+ this.width = parseInt(this.node.getAttribute('width'), 10);
+ this.height = parseInt(this.node.getAttribute('height'), 10);
+ }
+
+ return this;
+ },
+ /** Clear area of canvas element specified by parameters, if no
+ * parameters supplied, clears entire canvas
+ * @param {Number} [x=0] x coordinate, defaults to zero if left blank
+ * @param {Number} [y=0] y coordinate, defaults to zero if left blank
+ * @param {Number} [width=0] width of area to be cleared, defaults
+ * entire width of canvas
+ * @param {Number} [height=0] height of area to be cleared, defaults
+ * entire height of canvas
+ * @returns this
+ * @example
+ *
+ * k.canvas.ninja.clear();
+ * // clears the entire ninja canvas
+ *
+ * k.canvas.ninja.clear(0, 10, 20, 30);
+ * //clears a specific portion of the ninja canvas
+ *
+ */
+ clear : function ( x, y, width, height ) {
+ var that = this;
+ that.ctx.clearRect(
+ x || 0,
+ y || 0,
+ width || that.width,
+ height || that.height
+ );
+ return that;
+ },
+
+ //These are all properties or methods of the canvas element's
+ //2 dimensional context
+ _chainingFunctions : [
+ "globalAlpha", "globalCompositeOperation", "lineWidth", "lineCap",
+ "lineJoin", "miterLimit", "font", "textAlign", "textBaseline", "save",
+ "restore", "scale", "rotate", "translate", "transform", "setTransform",
+ "clearRect", "fillRect", "strokeRect", "beginPath", "closePath",
+ "moveTo", "lineTo", "quadraticCurveTo", "bezierCurveTo", "arcTo",
+ "arc", "rect", "fill", "stroke", "clip", "fillText", "strokeText",
+ "measureText", "isPointInPath", "strokeStyle", "fillStyle",
+ "createLinearGradient", "createRadialGradient", "createPattern",
+ "shadowOffsetX", "shadowOffsetY", "shadowBlur", "shadowColor",
+ //"mozTextStyle", "mozDrawText", "mozMeasureText", "mozPathText",
+ "mozTextAlongPath", "drawImage", "getImageData", "putImageData",
+ "createImageData", "drawWindow"
+ ]
+};
+
+
+
+Karma._makeSvgs = function (svgConfigs){
+ var makeSvg = function (svgConfig){
+ var svg = undefined;
+ svg = Karma.create(Karma.kSvg)._init(svgConfig);
+ Karma.karma.svg[svgConfig.name] = svg;
+ };
+
+ svgConfigs.forEach(function(svgConfig){ makeSvg(svgConfig);});
+
+};
+
+/** Prototypal object for each svg element submitted to Karma in the
+ * Karma() method
+ * @throws {Error} if the name and domId for the svg element are not specified
+ * @thows {Error} if the supplied domId does not match an element in the DOM
+ * @class This object is the prototype for each svg element submitted to Karma in the
+ * Karma() method
+ */
+Karma.kSvg = {
+ /** name of instance, used internally
+ * @typeof string
+ * @default ""
+ */
+ name : "",
+ /** width of element
+ * @type number
+ * @default 0
+ */
+ width: 0,
+ /** height of element
+ * @type number
+ * @default 0
+ */
+ height: 0,
+ /** Status of element, either "loaded" or "error"
+ * @type string
+ * @default ""
+ */
+ status: "",
+ /** Whether canvas is visible
+ * @type boolean
+ * @default true
+ */
+ visible: true,
+ /** Element ID for canvas element in html document
+ * @type String
+ * @default undefined
+ */
+ domId: undefined,
+ /** Reference to the DOM element
+ * @type DOMElement
+ * @default undefined
+ */
+ node: undefined,
+ /** Reference to the SVGDocument
+ * @type SVGDocument
+ * @default undefined
+ */
+ doc: undefined,
+ /** Reference to the root element of the SVG Document
+ * @type DocumentElement
+ * @default undefined
+ */
+ root: undefined,
+ _localized : undefined,
+ _chainingFunctions: [],
+ _init: function (config) {
+ Karma.karma._counters.total++;
+
+ for (var option in config){
+ if (config.hasOwnProperty(option)){
+ switch (option){
+ case "name":
+ this.name = config[option];
+ break;
+ case "domId":
+ this.domId = config[option];
+ break;
+ case "width":
+ if(!this.height){
+ throw new Error("If you specify a width you must also" +
+ "specify a height");
+ }
+ this.width = parseInt(config[option], 10);
+ break;
+ case "height":
+ if(!this.width){
+ throw new Error("If you specify a height you must also" +
+ "specify a width");
+ }
+ this.height = config[option];
+ break;
+ case "fps":
+ this.fps = config[option];
+ break;
+ }
+ }
+ }
+
+ if(this.domId && document.getElementById(this.domId)){
+ this.node = document.getElementById(this.domId);
+ } else {
+ throw new Error('you must specify a valid domId that' +
+ 'is in your html page');
+ }
+
+ if(!config.height && !config.width){
+ this.width = parseInt(this.node.getAttribute('width'), 10);
+ this.height = parseInt(this.node.getAttribute('height'), 10);
+ }
+
+ var that = this;
+ that._addEventHandlers();
+
+ return this;
+
+
+ },
+ _addEventHandlers : function () {
+ var that = this;
+ that.doc = that.node.getSVGDocument();
+ that.node.addEventListener(
+ "load",
+ function (e) {
+ that.doc = that.node.getSVGDocument();
+ that.root = that.doc.documentElement;
+ Karma.karma._counters.loaded++;
+ Karma.karma._updateStatus();
+ that.status = "loaded";
+ }, false);
+
+ that.node.addEventListener(
+ "error",
+ function (e) {
+ Karma.karma._counters.loaded--;
+ Karma.karma._counters.errors++;
+ that.status = "error";
+ var errorMsg = "Error: " + that._type.toUpperCase() +
+ " " + that.name + " cannot be loaded.";
+ Karma.karma._updateStatus(errorMsg);
+ },
+ false);
+ that.node.addEventListener(
+ "abort",
+ function (e) {
+ that.status = "aborted";
+ var errorMsg = "ABORT: " + that._type.toUpperCase() +
+ " " + that.name + " loading was aborted.";
+ Karma.karma._updateStatus(errorMsg);
+
+ }, false);
+
+ }
+};
+
+Karma._makeVideos = function (video){
+
+};
diff --git a/examples/lessons/6_English_whatsThisWord/js/lesson.js b/examples/lessons/6_English_whatsThisWord/js/lesson.js
new file mode 100755
index 0000000..26a2635
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/js/lesson.js
@@ -0,0 +1,249 @@
+$(document).ready(function(){
+ var k = Karma({
+ audio: [{'name':'correct','file':'correct.ogg'},
+ {'name':'incorrect','file':'incorrect.ogg'},
+ {'name':'apple','file':'apple.wav'},
+ {'name':'banana','file':'banana.wav'},
+ {'name':'boat','file':'boat.wav'},
+ {'name':'book','file':'book.wav'},
+ {'name':'bus','file':'bus.wav'},
+ {'name':'cake','file':'cake.wav'},
+ {'name':'car','file':'car.wav'},
+ {'name':'cow','file':'cow.wav'},
+ {'name':'flower','file':'flower.wav'},
+ {'name':'hat','file':'hat.wav'},
+ {'name':'kite','file':'kite.wav'},
+ {'name':'lamp','file':'lamp.wav'},
+ {'name':'pig','file':'pig.wav'},
+ {'name':'pigeon','file':'pigeon.wav'},
+ {'name':'rat','file':'rat.wav'},
+ {'name':'tomato','file':'tomato.wav'},
+ {'name':'tree','file':'tree.wav'}
+ ]});
+
+ k.ready(function(){
+ var i,j,topPos,leftPos; //game is completely based on absolute positioning....
+ var TOTAL_QUES = 10;
+ var TOTAL_OBJECTS = 17;
+ var randObjects = []; //store only ten random objects among TOTAL_OBJECTS
+ var randPositions = []; //store the random absolute positions for each object
+ var randQues = []; //store the turns of the pointer to go i.e questions
+ var objects = ['apple','banana','boat','book','bus','cake',
+ 'car','cow','flower','hat','kite','lamp',
+ 'pig','pigeon','rat','tomato','tree'
+ ];
+ var pointers = ['ladybird','ant'];
+ var pointer; //which pointer to use
+ var currentWord;
+ var flag_correct;
+
+ var leftPositions = [-20,185,550,800,1025,-20,185,550,800,1025]; //array to store the left positions
+ var topPositions = [5,10,50,60,20,350,360,365,240,340];
+ var pointerStartTop,pointerStartLeft;
+ var pointerStopTop,pointerStopLeft;
+ var currentQuestion,totalCounter,correctCounter;
+
+ var scoreboard = $('#score_box').scoreboard({'layout':'horizontal',
+ 'winningScore': TOTAL_QUES});
+
+ var genRandObjects=function (){
+ randObjects[0] = k.rand(0,TOTAL_OBJECTS-1);
+ for(i=1; i<TOTAL_QUES; i++){
+ do{
+ flag = 0;
+ randObjects[i] = k.rand(0,TOTAL_OBJECTS-1);
+ for(j=0; j<i; j++){
+ if(randObjects[i] === randObjects[j]){
+ flag++;
+ }
+ }
+ }while(flag != 0 ); //end of do while loop
+ }
+ };
+
+ var genRandQues=function (){
+ randQues[0] = k.rand(0,TOTAL_QUES-1);
+ for(i=1; i<TOTAL_QUES; i++){
+ do{
+ flag = 0;
+ randQues[i] = k.rand(0,TOTAL_QUES-1);
+ for(j=0; j<i; j++){
+ if(randQues[i] === randQues[j]){
+ flag++;
+ }
+ }
+ }while(flag != 0 ); //end of do while loop
+ }
+ };
+
+ var generateAbsolutePositions = function(id,topPos,leftPos){
+ var randNumImg = randObjects[id];
+ $('#content').append('<div id="pos'+id+'"></div>');
+ var objCss = {
+ 'position':'absolute',
+ 'top':topPos+'px',
+ 'left':leftPos+'px'
+ };
+ $('#pos'+id).css(objCss).html('<img src="assets/image/'+objects[randNumImg]+'.png" />');
+ };
+
+
+ var showQuestion = function(){
+ //alert('show question');
+ $('#content').append('<div id="questionSection"></div>');
+ $('#questionSection').html('').append('<div id="question">What is this?</div>');
+ $('#questionSection').append("<div id='answers'></div>");
+ currentWord = objects[randObjects[currentQuestion]];
+ $('#answers').append("It's ");
+ if(currentWord[0] === 'a' || currentWord[0] === 'e' ||currentWord[0] === 'i' || currentWord[0] === 'o' || currentWord[0] === 'u'){
+ $('#answers').append('an ');
+ } else{
+ $('#answers').append('a ');
+ }
+ $('#answers').append('<span id="word'+currentQuestion+'" class="objectWord"></span>');
+ $('#answers').append('.');
+
+ $('#word'+currentQuestion).append('<input type="text" id="box'+currentQuestion+'" class="blankBox"/>')
+ $('#box'+currentQuestion).Watermark("?");
+ $('.blankBox').focus();
+ foucs_blur();
+
+
+ };
+
+ var nextQuestion = function(){
+ flag_correct = 1;
+ currentQuestion = randQues[totalCounter];
+ if(totalCounter === 0){
+ pointerStartLeft = k.rand(10,1000);
+ pointerStartTop = k.rand(5,500);
+ } else{
+ pointerStartLeft = pointerStopLeft;
+ pointerStartTop = pointerStopTop;
+ }
+ pointerStopLeft = leftPositions[currentQuestion]+70;
+ pointerStopTop = topPositions[currentQuestion]+70;
+
+ $('#content').append('<div id="wordPointer"></div>');
+
+ var wordPointerCss = {
+ 'position':'absolute',
+ 'top':pointerStartTop+'px',
+ 'left':pointerStartLeft+'px',
+ 'background-color':'#F5F29E'
+ };
+ $('#wordPointer').css(wordPointerCss).addClass('pointerBg').html('<img src="assets/image/'+pointers[pointer]+'.png" />');
+ $('#wordPointer').animate(
+ {top:pointerStopTop+'px',left:pointerStopLeft+'px'},2000,
+ function(ev){ //callback function after the animation is complete
+ //alert('animation complete');
+ showQuestion();
+ }
+ );
+
+ };
+
+ function game(){
+ $('#gameOver').hide();
+ $('#content').removeClass('backOpaque');
+ correctCounter = 0;
+ totalCounter = 0;
+ genRandQues();
+ genRandObjects();
+ pointer = k.rand(0,1);
+
+ //Generate the fixed absolute positions for the random images
+ for(i = 0; i<leftPositions.length;i++){
+ generateAbsolutePositions(i,topPositions[i],leftPositions[i]);
+ }
+
+ nextQuestion();
+ }
+
+ $('#linkStart').click(function(){
+ game();
+ });
+
+ $('#linkPlayAgain').click(function(){
+ game();
+ });
+
+ var delay_gameOver = function(){
+ document.delayForm.delayval.value = 1;
+ $('#questionSection').html('');
+ $('#pos'+currentQuestion).html('');
+ $('#content').addClass('backOpaque');
+ $('#gameOver').show();
+ $('#gameOver').html('');
+ $('#gameOver').append('Game Over !!!');
+ $('#gameOver').append('<div id="gameOverInfo">You got <span class="specialText">'+correctCounter+
+ '</span> correct out of <span class="specialText">'+totalCounter+'</span> questions .</div>');
+
+ };
+
+ var delay_nextQues = function(){
+ document.delayForm.delayval.value = 1;
+ $('#questionSection').html('');
+ $('#pos'+currentQuestion).html('');
+ nextQuestion();
+ };
+
+
+ var checkAnswer = function(){
+
+ if(currentWord === $('.blankBox').val()){
+ $('.blankBox').addClass("correct");
+ if(flag_correct === 1){
+ correctCounter++;
+ scoreboard.scoreboard('inc');
+ }
+ k.audio[currentWord].play();
+ totalCounter++;
+ scoreboard.scoreboard('incTotal');
+
+ if(totalCounter === TOTAL_QUES){
+ t=setTimeout(function(){delay_gameOver();},1000);
+ }
+ else{
+
+ t=setTimeout(function(){delay_nextQues();},1000);
+
+ }
+ }
+ else{ //incorrect
+ flag_correct = 0;
+ $('.blankBox').addClass("incorrect");
+ k.audio.incorrect.play();
+
+ }
+ };
+
+ function foucs_blur(){
+ $('input[type="text"]').bind({
+ focus: function() {
+ $(this).removeClass('correct').removeClass('incorrect').addClass("focus");
+ },
+ blur: function(){
+ $(this).removeClass("focus");
+ },
+ keypress: function(event) {
+ if(event.which === 13){
+ checkAnswer();
+ }
+ }
+ });
+ }
+
+ $('#linkHelp').mouseover(function(){
+ $('#help').slideDown(2000);
+ })
+ .mouseout(function(){
+ $('#help').slideUp(2000);
+ });
+
+ game();
+
+ }); //end of k.ready
+}); //end of document.read
+
+
diff --git a/examples/lessons/6_English_whatsThisWord/js/lesson.js~ b/examples/lessons/6_English_whatsThisWord/js/lesson.js~
new file mode 100755
index 0000000..9c6e892
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/js/lesson.js~
@@ -0,0 +1,259 @@
+$(document).ready(function(){
+ var k = Karma({
+ audio: [{'name':'correct','file':'correct.ogg'},
+ {'name':'incorrect','file':'incorrect.ogg'},
+ {'name':'apple','file':'apple.wav'},
+ {'name':'banana','file':'banana.wav'},
+ {'name':'boat','file':'boat.wav'},
+ {'name':'book','file':'book.wav'},
+ {'name':'bus','file':'bus.wav'},
+ {'name':'cake','file':'cake.wav'},
+ {'name':'car','file':'car.wav'},
+ {'name':'cow','file':'cow.wav'},
+ {'name':'flower','file':'flower.wav'},
+ {'name':'hat','file':'hat.wav'},
+ {'name':'kite','file':'kite.wav'},
+ {'name':'lamp','file':'lamp.wav'},
+ {'name':'pig','file':'pig.wav'},
+ {'name':'pigeon','file':'pigeon.wav'},
+ {'name':'rat','file':'rat.wav'},
+ {'name':'tomato','file':'tomato.wav'},
+ {'name':'tree','file':'tree.wav'}
+ ]});
+
+ k.ready(function(){
+ var i,j,topPos,leftPos; //game is completely based on absolute positioning....
+ var TOTAL_QUES = 10;
+ var TOTAL_OBJECTS = 17;
+ var randObjects = []; //store only ten random objects among TOTAL_OBJECTS
+ var randPositions = []; //store the random absolute positions for each object
+ var randQues = []; //store the turns of the pointer to go i.e questions
+ var objects = ['apple','banana','boat','book','bus','cake',
+ 'car','cow','flower','hat','kite','lamp',
+ 'pig','pigeon','rat','tomato','tree'
+ ];
+ var pointers = ['ladybird','ant'];
+ var pointer; //which pointer to use
+ var currentWord;
+ var randNum; //store the random position of letter in a word
+ var flag_correct;
+
+ var leftPositions = [-20,185,550,800,1025,-20,185,550,800,1025]; //array to store the left positions
+ var topPositions = [5,10,50,60,20,350,360,365,240,340];
+ var pointerStartTop,pointerStartLeft;
+ var pointerStopTop,pointerStopLeft;
+ var currentQuestion,totalCounter,correctCounter;
+
+ var scoreboard = $('#score_box').scoreboard({'layout':'horizontal',
+ 'winningScore': TOTAL_QUES});
+
+ var genRandObjects=function (){
+ randObjects[0] = k.rand(0,TOTAL_OBJECTS-1);
+ for(i=1; i<TOTAL_QUES; i++){
+ do{
+ flag = 0;
+ randObjects[i] = k.rand(0,TOTAL_OBJECTS-1);
+ for(j=0; j<i; j++){
+ if(randObjects[i] === randObjects[j]){
+ flag++;
+ }
+ }
+ }while(flag != 0 ); //end of do while loop
+ }
+ };
+
+ var genRandQues=function (){
+ randQues[0] = k.rand(0,TOTAL_QUES-1);
+ for(i=1; i<TOTAL_QUES; i++){
+ do{
+ flag = 0;
+ randQues[i] = k.rand(0,TOTAL_QUES-1);
+ for(j=0; j<i; j++){
+ if(randQues[i] === randQues[j]){
+ flag++;
+ }
+ }
+ }while(flag != 0 ); //end of do while loop
+ }
+ };
+
+ var generateAbsolutePositions = function(id,topPos,leftPos){
+ var randNumImg = randObjects[id];
+ $('#content').append('<div id="pos'+id+'"></div>');
+ var objCss = {
+ 'position':'absolute',
+ 'top':topPos+'px',
+ 'left':leftPos+'px'
+ };
+ $('#pos'+id).css(objCss).html('<img src="assets/image/'+objects[randNumImg]+'.png" />');
+ };
+
+
+ var showQuestion = function(){
+ //alert('show question');
+ $('#content').append('<div id="questionSection"></div>');
+ $('#questionSection').html('').append('<div id="question">What is this?</div>');
+ $('#questionSection').append("<div id='answers'></div>");
+ currentWord = objects[randObjects[currentQuestion]];
+ $('#answers').append("It's ");
+ if(currentWord[0] === 'a' || currentWord[0] === 'e' ||currentWord[0] === 'i' || currentWord[0] === 'o' || currentWord[0] === 'u'){
+ $('#answers').append('an ');
+ } else{
+ $('#answers').append('a ');
+ }
+ $('#answers').append('<span id="word'+currentQuestion+'" class="objectWord"></span>');
+ $('#answers').append('.');
+
+
+ var wordLength = currentWord.length;
+ randNum = k.rand(0,wordLength-1);
+ //randBoxes[monthId] = randNum;
+ for(var z = 0; z < wordLength; z++){
+ if(z === (randNum)){
+ $('#word'+currentQuestion).append('<input type="text" id="box'+currentQuestion+'" class="blankBox" maxlength="1"/>')
+ $('#box'+currentQuestion).Watermark("?");
+ //insert text box
+ }
+ else{
+ $('#word'+currentQuestion).append(currentWord[z]);
+ }
+ }
+ $('.blankBox').focus();
+ foucs_blur();
+
+
+ };
+
+ var nextQuestion = function(){
+ flag_correct = 1;
+ currentQuestion = randQues[totalCounter];
+ if(totalCounter === 0){
+ pointerStartLeft = k.rand(10,1000);
+ pointerStartTop = k.rand(5,500);
+ } else{
+ pointerStartLeft = pointerStopLeft;
+ pointerStartTop = pointerStopTop;
+ }
+ pointerStopLeft = leftPositions[currentQuestion]+70;
+ pointerStopTop = topPositions[currentQuestion]+70;
+
+ $('#content').append('<div id="wordPointer"></div>');
+
+ var wordPointerCss = {
+ 'position':'absolute',
+ 'top':pointerStartTop+'px',
+ 'left':pointerStartLeft+'px',
+ 'background-color':'#F5F29E'
+ };
+ $('#wordPointer').css(wordPointerCss).addClass('pointerBg').html('<img src="assets/image/'+pointers[pointer]+'.png" />');
+ $('#wordPointer').animate(
+ {top:pointerStopTop+'px',left:pointerStopLeft+'px'},2000,
+ function(ev){ //callback function after the animation is complete
+ //alert('animation complete');
+ showQuestion();
+ }
+ );
+
+ };
+
+ function game(){
+ $('#gameOver').hide();
+ $('#content').removeClass('backOpaque');
+ correctCounter = 0;
+ totalCounter = 0;
+ genRandQues();
+ genRandObjects();
+ pointer = k.rand(0,1);
+
+ //Generate the fixed absolute positions for the random images
+ for(i = 0; i<leftPositions.length;i++){
+ generateAbsolutePositions(i,topPositions[i],leftPositions[i]);
+ }
+
+ nextQuestion();
+ }
+
+ $('#linkStart').click(function(){
+ game();
+ });
+
+ $('#linkPlayAgain').click(function(){
+ game();
+ });
+
+ var delay_gameOver = function(){
+ document.delayForm.delayval.value = 1;
+ $('#content').addClass('backOpaque');
+ $('#gameOver').show();
+ $('#gameOver').html('');
+ $('#gameOver').append('Game Over !!!');
+ $('#gameOver').append('<div id="gameOverInfo">You got <span class="specialText">'+correctCounter+
+ '</span> correct out of <span class="specialText">'+totalCounter+'</span> questions .</div>');
+
+ };
+
+ var delay_nextQues = function(){
+ document.delayForm.delayval.value = 1;
+ $('#questionSection').html('');
+ $('#pos'+currentQuestion).html('');
+ nextQuestion();
+ };
+
+
+ var checkAnswer = function(){
+
+ if(currentWord[randNum] === $('.blankBox').val()){
+ $('.blankBox').addClass("correct");
+ if(flag_correct === 1){
+ correctCounter++;
+ scoreboard.scoreboard('inc');
+ }
+ k.audio[currentWord].play();
+ totalCounter++;
+ scoreboard.scoreboard('incTotal');
+
+ if(totalCounter === TOTAL_QUES){
+ t=setTimeout(function(){delay_gameOver();},1000);
+ }
+ else{
+
+ t=setTimeout(function(){delay_nextQues();},1000);
+
+ }
+ }
+ else{ //incorrect
+ flag_correct = 0;
+ $('.blankBox').addClass("incorrect");
+ k.audio.incorrect.play();
+
+ }
+ };
+
+ function foucs_blur(){
+ $('input[type="text"]').bind({
+ focus: function() {
+ $(this).removeClass('correct').removeClass('incorrect').addClass("focus");
+ },
+ blur: function(){
+ $(this).removeClass("focus");
+ },
+ keypress: function(event) {
+ if(event.which === 13){
+ checkAnswer();
+ }
+ }
+ });
+ }
+
+ $('#linkHelp').mouseover(function(){
+ $('#help').slideDown(2000);
+ })
+ .mouseout(function(){
+ $('#help').slideUp(2000);
+ });
+
+
+ }); //end of k.ready
+}); //end of document.read
+
+
diff --git a/examples/lessons/6_English_whatsThisWord/js/ui.core.js b/examples/lessons/6_English_whatsThisWord/js/ui.core.js
new file mode 100755
index 0000000..5493e0a
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/js/ui.core.js
@@ -0,0 +1,519 @@
+/*
+ * jQuery UI 1.7.2
+ *
+ * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * http://docs.jquery.com/UI
+ */
+;jQuery.ui || (function($) {
+
+var _remove = $.fn.remove,
+ isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9);
+
+//Helper functions and ui object
+$.ui = {
+ version: "1.7.2",
+
+ // $.ui.plugin is deprecated. Use the proxy pattern instead.
+ plugin: {
+ add: function(module, option, set) {
+ var proto = $.ui[module].prototype;
+ for(var i in set) {
+ proto.plugins[i] = proto.plugins[i] || [];
+ proto.plugins[i].push([option, set[i]]);
+ }
+ },
+ call: function(instance, name, args) {
+ var set = instance.plugins[name];
+ if(!set || !instance.element[0].parentNode) { return; }
+
+ for (var i = 0; i < set.length; i++) {
+ if (instance.options[set[i][0]]) {
+ set[i][1].apply(instance.element, args);
+ }
+ }
+ }
+ },
+
+ contains: function(a, b) {
+ return document.compareDocumentPosition
+ ? a.compareDocumentPosition(b) & 16
+ : a !== b && a.contains(b);
+ },
+
+ hasScroll: function(el, a) {
+
+ //If overflow is hidden, the element might have extra content, but the user wants to hide it
+ if ($(el).css('overflow') == 'hidden') { return false; }
+
+ var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop',
+ has = false;
+
+ if (el[scroll] > 0) { return true; }
+
+ // TODO: determine which cases actually cause this to happen
+ // if the element doesn't have the scroll set, see if it's possible to
+ // set the scroll
+ el[scroll] = 1;
+ has = (el[scroll] > 0);
+ el[scroll] = 0;
+ return has;
+ },
+
+ isOverAxis: function(x, reference, size) {
+ //Determines when x coordinate is over "b" element axis
+ return (x > reference) && (x < (reference + size));
+ },
+
+ isOver: function(y, x, top, left, height, width) {
+ //Determines when x, y coordinates is over "b" element
+ return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width);
+ },
+
+ keyCode: {
+ BACKSPACE: 8,
+ CAPS_LOCK: 20,
+ COMMA: 188,
+ CONTROL: 17,
+ DELETE: 46,
+ DOWN: 40,
+ END: 35,
+ ENTER: 13,
+ ESCAPE: 27,
+ HOME: 36,
+ INSERT: 45,
+ LEFT: 37,
+ NUMPAD_ADD: 107,
+ NUMPAD_DECIMAL: 110,
+ NUMPAD_DIVIDE: 111,
+ NUMPAD_ENTER: 108,
+ NUMPAD_MULTIPLY: 106,
+ NUMPAD_SUBTRACT: 109,
+ PAGE_DOWN: 34,
+ PAGE_UP: 33,
+ PERIOD: 190,
+ RIGHT: 39,
+ SHIFT: 16,
+ SPACE: 32,
+ TAB: 9,
+ UP: 38
+ }
+};
+
+// WAI-ARIA normalization
+if (isFF2) {
+ var attr = $.attr,
+ removeAttr = $.fn.removeAttr,
+ ariaNS = "http://www.w3.org/2005/07/aaa",
+ ariaState = /^aria-/,
+ ariaRole = /^wairole:/;
+
+ $.attr = function(elem, name, value) {
+ var set = value !== undefined;
+
+ return (name == 'role'
+ ? (set
+ ? attr.call(this, elem, name, "wairole:" + value)
+ : (attr.apply(this, arguments) || "").replace(ariaRole, ""))
+ : (ariaState.test(name)
+ ? (set
+ ? elem.setAttributeNS(ariaNS,
+ name.replace(ariaState, "aaa:"), value)
+ : attr.call(this, elem, name.replace(ariaState, "aaa:")))
+ : attr.apply(this, arguments)));
+ };
+
+ $.fn.removeAttr = function(name) {
+ return (ariaState.test(name)
+ ? this.each(function() {
+ this.removeAttributeNS(ariaNS, name.replace(ariaState, ""));
+ }) : removeAttr.call(this, name));
+ };
+}
+
+//jQuery plugins
+$.fn.extend({
+ remove: function() {
+ // Safari has a native remove event which actually removes DOM elements,
+ // so we have to use triggerHandler instead of trigger (#3037).
+ $("*", this).add(this).each(function() {
+ $(this).triggerHandler("remove");
+ });
+ return _remove.apply(this, arguments );
+ },
+
+ enableSelection: function() {
+ return this
+ .attr('unselectable', 'off')
+ .css('MozUserSelect', '')
+ .unbind('selectstart.ui');
+ },
+
+ disableSelection: function() {
+ return this
+ .attr('unselectable', 'on')
+ .css('MozUserSelect', 'none')
+ .bind('selectstart.ui', function() { return false; });
+ },
+
+ scrollParent: function() {
+ var scrollParent;
+ if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
+ scrollParent = this.parents().filter(function() {
+ return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
+ }).eq(0);
+ } else {
+ scrollParent = this.parents().filter(function() {
+ return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
+ }).eq(0);
+ }
+
+ return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
+ }
+});
+
+
+//Additional selectors
+$.extend($.expr[':'], {
+ data: function(elem, i, match) {
+ return !!$.data(elem, match[3]);
+ },
+
+ focusable: function(element) {
+ var nodeName = element.nodeName.toLowerCase(),
+ tabIndex = $.attr(element, 'tabindex');
+ return (/input|select|textarea|button|object/.test(nodeName)
+ ? !element.disabled
+ : 'a' == nodeName || 'area' == nodeName
+ ? element.href || !isNaN(tabIndex)
+ : !isNaN(tabIndex))
+ // the element and all of its ancestors must be visible
+ // the browser may report that the area is hidden
+ && !$(element)['area' == nodeName ? 'parents' : 'closest'](':hidden').length;
+ },
+
+ tabbable: function(element) {
+ var tabIndex = $.attr(element, 'tabindex');
+ return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(':focusable');
+ }
+});
+
+
+// $.widget is a factory to create jQuery plugins
+// taking some boilerplate code out of the plugin code
+function getter(namespace, plugin, method, args) {
+ function getMethods(type) {
+ var methods = $[namespace][plugin][type] || [];
+ return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods);
+ }
+
+ var methods = getMethods('getter');
+ if (args.length == 1 && typeof args[0] == 'string') {
+ methods = methods.concat(getMethods('getterSetter'));
+ }
+ return ($.inArray(method, methods) != -1);
+}
+
+$.widget = function(name, prototype) {
+ var namespace = name.split(".")[0];
+ name = name.split(".")[1];
+
+ // create plugin method
+ $.fn[name] = function(options) {
+ var isMethodCall = (typeof options == 'string'),
+ args = Array.prototype.slice.call(arguments, 1);
+
+ // prevent calls to internal methods
+ if (isMethodCall && options.substring(0, 1) == '_') {
+ return this;
+ }
+
+ // handle getter methods
+ if (isMethodCall && getter(namespace, name, options, args)) {
+ var instance = $.data(this[0], name);
+ return (instance ? instance[options].apply(instance, args)
+ : undefined);
+ }
+
+ // handle initialization and non-getter methods
+ return this.each(function() {
+ var instance = $.data(this, name);
+
+ // constructor
+ (!instance && !isMethodCall &&
+ $.data(this, name, new $[namespace][name](this, options))._init());
+
+ // method call
+ (instance && isMethodCall && $.isFunction(instance[options]) &&
+ instance[options].apply(instance, args));
+ });
+ };
+
+ // create widget constructor
+ $[namespace] = $[namespace] || {};
+ $[namespace][name] = function(element, options) {
+ var self = this;
+
+ this.namespace = namespace;
+ this.widgetName = name;
+ this.widgetEventPrefix = $[namespace][name].eventPrefix || name;
+ this.widgetBaseClass = namespace + '-' + name;
+
+ this.options = $.extend({},
+ $.widget.defaults,
+ $[namespace][name].defaults,
+ $.metadata && $.metadata.get(element)[name],
+ options);
+
+ this.element = $(element)
+ .bind('setData.' + name, function(event, key, value) {
+ if (event.target == element) {
+ return self._setData(key, value);
+ }
+ })
+ .bind('getData.' + name, function(event, key) {
+ if (event.target == element) {
+ return self._getData(key);
+ }
+ })
+ .bind('remove', function() {
+ return self.destroy();
+ });
+ };
+
+ // add widget prototype
+ $[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype);
+
+ // TODO: merge getter and getterSetter properties from widget prototype
+ // and plugin prototype
+ $[namespace][name].getterSetter = 'option';
+};
+
+$.widget.prototype = {
+ _init: function() {},
+ destroy: function() {
+ this.element.removeData(this.widgetName)
+ .removeClass(this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled')
+ .removeAttr('aria-disabled');
+ },
+
+ option: function(key, value) {
+ var options = key,
+ self = this;
+
+ if (typeof key == "string") {
+ if (value === undefined) {
+ return this._getData(key);
+ }
+ options = {};
+ options[key] = value;
+ }
+
+ $.each(options, function(key, value) {
+ self._setData(key, value);
+ });
+ },
+ _getData: function(key) {
+ return this.options[key];
+ },
+ _setData: function(key, value) {
+ this.options[key] = value;
+
+ if (key == 'disabled') {
+ this.element
+ [value ? 'addClass' : 'removeClass'](
+ this.widgetBaseClass + '-disabled' + ' ' +
+ this.namespace + '-state-disabled')
+ .attr("aria-disabled", value);
+ }
+ },
+
+ enable: function() {
+ this._setData('disabled', false);
+ },
+ disable: function() {
+ this._setData('disabled', true);
+ },
+
+ _trigger: function(type, event, data) {
+ var callback = this.options[type],
+ eventName = (type == this.widgetEventPrefix
+ ? type : this.widgetEventPrefix + type);
+
+ event = $.Event(event);
+ event.type = eventName;
+
+ // copy original event properties over to the new event
+ // this would happen if we could call $.event.fix instead of $.Event
+ // but we don't have a way to force an event to be fixed multiple times
+ if (event.originalEvent) {
+ for (var i = $.event.props.length, prop; i;) {
+ prop = $.event.props[--i];
+ event[prop] = event.originalEvent[prop];
+ }
+ }
+
+ this.element.trigger(event, data);
+
+ return !($.isFunction(callback) && callback.call(this.element[0], event, data) === false
+ || event.isDefaultPrevented());
+ }
+};
+
+$.widget.defaults = {
+ disabled: false
+};
+
+
+/** Mouse Interaction Plugin **/
+
+$.ui.mouse = {
+ _mouseInit: function() {
+ var self = this;
+
+ this.element
+ .bind('mousedown.'+this.widgetName, function(event) {
+ return self._mouseDown(event);
+ })
+ .bind('click.'+this.widgetName, function(event) {
+ if(self._preventClickEvent) {
+ self._preventClickEvent = false;
+ event.stopImmediatePropagation();
+ return false;
+ }
+ });
+
+ // Prevent text selection in IE
+ if ($.browser.msie) {
+ this._mouseUnselectable = this.element.attr('unselectable');
+ this.element.attr('unselectable', 'on');
+ }
+
+ this.started = false;
+ },
+
+ // TODO: make sure destroying one instance of mouse doesn't mess with
+ // other instances of mouse
+ _mouseDestroy: function() {
+ this.element.unbind('.'+this.widgetName);
+
+ // Restore text selection in IE
+ ($.browser.msie
+ && this.element.attr('unselectable', this._mouseUnselectable));
+ },
+
+ _mouseDown: function(event) {
+ // don't let more than one widget handle mouseStart
+ // TODO: figure out why we have to use originalEvent
+ event.originalEvent = event.originalEvent || {};
+ if (event.originalEvent.mouseHandled) { return; }
+
+ // we may have missed mouseup (out of window)
+ (this._mouseStarted && this._mouseUp(event));
+
+ this._mouseDownEvent = event;
+
+ var self = this,
+ btnIsLeft = (event.which == 1),
+ elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false);
+ if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
+ return true;
+ }
+
+ this.mouseDelayMet = !this.options.delay;
+ if (!this.mouseDelayMet) {
+ this._mouseDelayTimer = setTimeout(function() {
+ self.mouseDelayMet = true;
+ }, this.options.delay);
+ }
+
+ if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+ this._mouseStarted = (this._mouseStart(event) !== false);
+ if (!this._mouseStarted) {
+ event.preventDefault();
+ return true;
+ }
+ }
+
+ // these delegates are required to keep context
+ this._mouseMoveDelegate = function(event) {
+ return self._mouseMove(event);
+ };
+ this._mouseUpDelegate = function(event) {
+ return self._mouseUp(event);
+ };
+ $(document)
+ .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
+ .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
+
+ // preventDefault() is used to prevent the selection of text here -
+ // however, in Safari, this causes select boxes not to be selectable
+ // anymore, so this fix is needed
+ ($.browser.safari || event.preventDefault());
+
+ event.originalEvent.mouseHandled = true;
+ return true;
+ },
+
+ _mouseMove: function(event) {
+ // IE mouseup check - mouseup happened when mouse was out of window
+ if ($.browser.msie && !event.button) {
+ return this._mouseUp(event);
+ }
+
+ if (this._mouseStarted) {
+ this._mouseDrag(event);
+ return event.preventDefault();
+ }
+
+ if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+ this._mouseStarted =
+ (this._mouseStart(this._mouseDownEvent, event) !== false);
+ (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
+ }
+
+ return !this._mouseStarted;
+ },
+
+ _mouseUp: function(event) {
+ $(document)
+ .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
+ .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
+
+ if (this._mouseStarted) {
+ this._mouseStarted = false;
+ this._preventClickEvent = (event.target == this._mouseDownEvent.target);
+ this._mouseStop(event);
+ }
+
+ return false;
+ },
+
+ _mouseDistanceMet: function(event) {
+ return (Math.max(
+ Math.abs(this._mouseDownEvent.pageX - event.pageX),
+ Math.abs(this._mouseDownEvent.pageY - event.pageY)
+ ) >= this.options.distance
+ );
+ },
+
+ _mouseDelayMet: function(event) {
+ return this.mouseDelayMet;
+ },
+
+ // These are placeholder methods, to be overriden by extending plugin
+ _mouseStart: function(event) {},
+ _mouseDrag: function(event) {},
+ _mouseStop: function(event) {},
+ _mouseCapture: function(event) { return true; }
+};
+
+$.ui.mouse.defaults = {
+ cancel: null,
+ distance: 1,
+ delay: 0
+};
+
+})(jQuery);
diff --git a/examples/lessons/6_English_whatsThisWord/js/ui.scoreboard.js b/examples/lessons/6_English_whatsThisWord/js/ui.scoreboard.js
new file mode 100755
index 0000000..53a930a
--- /dev/null
+++ b/examples/lessons/6_English_whatsThisWord/js/ui.scoreboard.js
@@ -0,0 +1,107 @@
+(function($){
+ $.widget('ui.scoreboard',
+ {
+ getScore : function(){
+ return this._getData('score');
+ },
+ setScore : function(newScore){
+ this._setData('score', parseInt(newScore));
+ this._refresh();
+ },
+ getTotal : function(){
+ return this._getData('total');
+ },
+ setTotal : function(newTotal){
+ this._setData('total', parseInt(newTotal));
+ this._refresh();
+ },
+ reset : function(){
+ this._setData('score', this._getData('initialScore'));
+ this._setData('total', this._getData('initialTotal'));
+ this._refresh();
+ },
+ inc : function(val){
+ var incVal = parseInt(val) || 1;
+ this._setData('score', this._getData('score') + incVal);
+ this._refresh();
+ if(this._getData('winScore') === this._getData('score')){
+ this.element.trigger('winGame');
+ }
+ },
+ incTotal : function(val){
+ var incVal = parseInt(val) || 1;
+ this._setData('total', this._getData('total') + incVal);
+ this._refresh();
+ },
+ dec : function(val){
+ var decVal = parseInt(val) || 1;
+ this._setData('score', this._getData('score') - decVal);
+ this._refresh();
+ },
+ decTotal : function(val){
+ var decVal = parseInt(val) || 1;
+ this._setData('total', this._getData('total') - decVal);
+ this._refresh();
+ },
+ _init : function(){
+
+ var divDisplay = "inline";
+ var score = this.options.score;
+ var total = this.options.total;
+ var layoutId = "h";
+ var self = this;
+
+
+ this._setData('initialScore', parseInt(this.options.score));
+ this._setData('initialTotal', parseInt(this.options.total));
+ this._setData('score', parseInt(this.options.score));
+ this._setData('total', parseInt(this.options.total));
+ this._setData('winScore', parseInt(this.options.winningScore) || 0);
+
+ if(this.options.layout === "vertical"){
+ layoutId = "v";
+ }
+
+ this.evWinGame = document.createEvent('Events');
+
+ this.element.addClass('ui-scoreboard-container-' + layoutId +
+ ' ui-widget ui-widget-content ui-corner-all');
+
+ var clone = $('<div>')
+ .addClass('ui-scoreboard-spacing-' + layoutId);
+ this._scoreText = $("<div>Score</div>")
+ .addClass('ui-scoreboard-spacing-'+ layoutId +
+ ' ui-corner-all ui-scoreboard-text')
+ .appendTo(this.element);
+ this._score = $("<div>" + score + "</div>")
+ .addClass('ui-scoreboard-spacing-' + layoutId +
+ ' ui-scoreboard-number-' + layoutId)
+ .appendTo(this.element);
+ $("<div>Total</div>")
+ .addClass('ui-scoreboard-spacing-' + layoutId +
+ ' ui-corner-all ' +
+ 'ui-scoreboard-text')
+ .appendTo(this.element);
+ this._total = $("<div>" + total + "</div>")
+ .addClass('ui-scoreboard-spacing-' + layoutId +
+ ' ui-scoreboard-number-' + layoutId)
+ .appendTo(this.element);
+ },
+ _refresh : function(){
+ this._score.text(this._getData('score'));
+ this._total.text(this._getData('total'));
+ },
+ destroy : function(){
+ this.element.remove();
+ $.widget.prototype.destroy.apply(this, arguments);
+ }
+
+
+ });
+
+ $.ui.scoreboard.getter = ['getScore', 'getTotal'];
+ $.ui.scoreboard.defaults = {
+ score: 0, total: 0, layout: "horizontal", winningScore: 0
+ };
+
+ })(jQuery); \ No newline at end of file
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/audio/correct.wav b/examples/lessons/6_Maths_AddSubtract/assets/audio/correct.wav
new file mode 100755
index 0000000..a49ba33
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/audio/correct.wav
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/audio/incorrect.wav b/examples/lessons/6_Maths_AddSubtract/assets/audio/incorrect.wav
new file mode 100755
index 0000000..906c6a3
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/audio/incorrect.wav
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/bg_footer.png b/examples/lessons/6_Maths_AddSubtract/assets/image/bg_footer.png
new file mode 100755
index 0000000..8982264
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/bg_footer.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/bg_header.png b/examples/lessons/6_Maths_AddSubtract/assets/image/bg_header.png
new file mode 100755
index 0000000..98213f7
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/bg_header.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/bg_title_block.png b/examples/lessons/6_Maths_AddSubtract/assets/image/bg_title_block.png
new file mode 100755
index 0000000..2c9dacf
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/bg_title_block.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/btn_back.png b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_back.png
new file mode 100755
index 0000000..d9fbf14
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_back.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/btn_back_hover.png b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_back_hover.png
new file mode 100755
index 0000000..0911fcc
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_back_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/btn_help.png b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_help.png
new file mode 100755
index 0000000..6753e9c
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_help.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/btn_help_hover.png b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_help_hover.png
new file mode 100755
index 0000000..d3ccd92
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_help_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/btn_next.png b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_next.png
new file mode 100755
index 0000000..9d70993
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_next.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/btn_next_hover.png b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_next_hover.png
new file mode 100755
index 0000000..2cd4d37
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_next_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/btn_ole.png b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_ole.png
new file mode 100755
index 0000000..0e775e9
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_ole.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/btn_ole_hover.png b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_ole_hover.png
new file mode 100755
index 0000000..c43c5f7
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_ole_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/btn_play_again.png b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_play_again.png
new file mode 100755
index 0000000..3594d18
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_play_again.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/btn_play_again_hover.png b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_play_again_hover.png
new file mode 100755
index 0000000..ebb8f8c
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_play_again_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/btn_play_again_mouse_down.png b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_play_again_mouse_down.png
new file mode 100755
index 0000000..07d6e45
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_play_again_mouse_down.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/btn_start.png b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_start.png
new file mode 100755
index 0000000..32e5f20
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_start.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/btn_start_hover.png b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_start_hover.png
new file mode 100755
index 0000000..811ce78
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_start_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/btn_start_mouse_down.png b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_start_mouse_down.png
new file mode 100755
index 0000000..5acd43b
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/btn_start_mouse_down.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/check.png b/examples/lessons/6_Maths_AddSubtract/assets/image/check.png
new file mode 100755
index 0000000..bd0afcb
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/check.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/correct.png b/examples/lessons/6_Maths_AddSubtract/assets/image/correct.png
new file mode 100755
index 0000000..f0e6699
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/correct.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/help.png b/examples/lessons/6_Maths_AddSubtract/assets/image/help.png
new file mode 100755
index 0000000..ae50162
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/help.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/image1.png b/examples/lessons/6_Maths_AddSubtract/assets/image/image1.png
new file mode 100755
index 0000000..d40c626
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/image1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/image2.png b/examples/lessons/6_Maths_AddSubtract/assets/image/image2.png
new file mode 100755
index 0000000..a09d579
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/image2.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/image3.png b/examples/lessons/6_Maths_AddSubtract/assets/image/image3.png
new file mode 100755
index 0000000..7dfe911
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/image3.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/incorrect.png b/examples/lessons/6_Maths_AddSubtract/assets/image/incorrect.png
new file mode 100755
index 0000000..62cbbef
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/incorrect.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img0.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img0.png
new file mode 100755
index 0000000..ad5d81c
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img0.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img1.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img1.png
new file mode 100755
index 0000000..2b881cd
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img10.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img10.png
new file mode 100755
index 0000000..8753799
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img10.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img11.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img11.png
new file mode 100755
index 0000000..dd5ae22
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img11.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img12.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img12.png
new file mode 100755
index 0000000..0f4f18d
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img12.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img13.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img13.png
new file mode 100755
index 0000000..ba75502
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img13.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img14.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img14.png
new file mode 100755
index 0000000..16ecd7e
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img14.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img15.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img15.png
new file mode 100755
index 0000000..04b16c9
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img15.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img2.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img2.png
new file mode 100755
index 0000000..135c34d
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img2.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img3.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img3.png
new file mode 100755
index 0000000..a151c7d
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img3.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img4.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img4.png
new file mode 100755
index 0000000..845939d
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img4.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img5.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img5.png
new file mode 100755
index 0000000..2bf4138
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img5.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img6.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img6.png
new file mode 100755
index 0000000..9502f19
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img6.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img7.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img7.png
new file mode 100755
index 0000000..8d706c8
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img7.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img8.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img8.png
new file mode 100755
index 0000000..506456a
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img8.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img9.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img9.png
new file mode 100755
index 0000000..97dbe5d
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level1Img9.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img0.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img0.png
new file mode 100755
index 0000000..9ddd2fb
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img0.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img1.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img1.png
new file mode 100755
index 0000000..6674006
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img10.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img10.png
new file mode 100755
index 0000000..ba3a27d
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img10.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img11.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img11.png
new file mode 100755
index 0000000..0809b80
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img11.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img12.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img12.png
new file mode 100755
index 0000000..123401e
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img12.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img13.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img13.png
new file mode 100755
index 0000000..cabfb55
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img13.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img14.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img14.png
new file mode 100755
index 0000000..bab1f4f
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img14.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img15.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img15.png
new file mode 100755
index 0000000..b63119d
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img15.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img2.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img2.png
new file mode 100755
index 0000000..7d0d82d
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img2.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img3.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img3.png
new file mode 100755
index 0000000..45b213a
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img3.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img4.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img4.png
new file mode 100755
index 0000000..a3e2b2a
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img4.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img5.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img5.png
new file mode 100755
index 0000000..e49ffae
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img5.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img6.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img6.png
new file mode 100755
index 0000000..0065f5d
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img6.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img7.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img7.png
new file mode 100755
index 0000000..64e8498
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img7.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img8.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img8.png
new file mode 100755
index 0000000..83b2678
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img8.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img9.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img9.png
new file mode 100755
index 0000000..3003a81
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level2Img9.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img0.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img0.png
new file mode 100755
index 0000000..62a082a
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img0.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img1.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img1.png
new file mode 100755
index 0000000..e230115
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img10.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img10.png
new file mode 100755
index 0000000..49d8235
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img10.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img11.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img11.png
new file mode 100755
index 0000000..cbbf9c6
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img11.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img12.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img12.png
new file mode 100755
index 0000000..d0618fb
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img12.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img13.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img13.png
new file mode 100755
index 0000000..d3623e7
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img13.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img14.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img14.png
new file mode 100755
index 0000000..152789a
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img14.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img15.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img15.png
new file mode 100755
index 0000000..c5403da
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img15.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img2.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img2.png
new file mode 100755
index 0000000..71bffe2
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img2.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img3.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img3.png
new file mode 100755
index 0000000..facf01b
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img3.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img4.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img4.png
new file mode 100755
index 0000000..722c3ae
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img4.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img5.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img5.png
new file mode 100755
index 0000000..a8c3a3a
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img5.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img6.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img6.png
new file mode 100755
index 0000000..df37c20
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img6.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img7.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img7.png
new file mode 100755
index 0000000..4cfeaa2
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img7.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img8.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img8.png
new file mode 100755
index 0000000..b4a3921
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img8.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img9.png b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img9.png
new file mode 100755
index 0000000..12806a2
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/level3Img9.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/levelDown.png b/examples/lessons/6_Maths_AddSubtract/assets/image/levelDown.png
new file mode 100755
index 0000000..6e0387b
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/levelDown.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/levelUp.png b/examples/lessons/6_Maths_AddSubtract/assets/image/levelUp.png
new file mode 100755
index 0000000..efd163f
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/levelUp.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/picClock.png b/examples/lessons/6_Maths_AddSubtract/assets/image/picClock.png
new file mode 100755
index 0000000..63e50e2
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/picClock.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/title_block_lt.png b/examples/lessons/6_Maths_AddSubtract/assets/image/title_block_lt.png
new file mode 100755
index 0000000..4696182
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/title_block_lt.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/assets/image/title_block_rt.png b/examples/lessons/6_Maths_AddSubtract/assets/image/title_block_rt.png
new file mode 100755
index 0000000..37cc44a
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/assets/image/title_block_rt.png
Binary files differ
diff --git a/examples/lessons/6_Maths_AddSubtract/css/lesson.css b/examples/lessons/6_Maths_AddSubtract/css/lesson.css
new file mode 100755
index 0000000..7ba7642
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/css/lesson.css
@@ -0,0 +1,332 @@
+@CHARSET "UTF-8";
+/****** Page Styles ****/
+
+/* Designed for 1200*900 px screen resolution */
+
+body {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 10pt;
+ margin: 0px;
+ background-color: #FFFFCC;
+}
+#header {
+ background-image: url(../assets/image/bg_header.png);
+ background-repeat: repeat-x;
+ height: 75px;
+ width: 100%;
+ position: absolute;
+ left: 0px;
+ top: 0px;
+}
+#topbtn_left {
+ float: left;
+ height: 60px;
+ width: 60px;
+ padding-top: 6px;
+ padding-left: 15px;
+}
+
+
+ .linkBack{
+ width: 60px; height: 59px;
+ background:url(../assets/image/btn_back.png);
+ }
+ .linkBack:hover{
+ background:url(../assets/image/btn_back_hover.png);
+ }
+
+#lesson_title {
+ float: left;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 16pt;
+ font-weight: bold;
+ color: #FFFFFF;
+ margin-left: 10px;
+ background-image: url(../assets/image/bg_title_block.png);
+}
+#topbtn_right {
+ float: right;
+ height: 60px;
+ width: 60px;
+ padding-top: 6px;
+ padding-right: 15px;
+}
+ #linkHelp{
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_help.png);
+ }
+ #linkHelp:hover{
+ background:url(../assets/image/btn_help_hover.png);
+ }
+ #linkOle{
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_ole.png);
+ }
+ #linkOle:hover{
+ background:url(../assets/image/btn_ole_hover.png);
+ }
+ .linkNext{var bindImgCss = {
+ 'float':'left',
+ 'width': '450px',
+ 'height':'40px',
+ 'margin-top':'0.25em',
+ 'text-align':'center',
+ 'padding-bottom':'0.3em'
+ };
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_next.png);
+ }
+ .linkNext:hover{
+ background:url(../assets/image/btn_next_hover.png);
+ }
+#footer {
+ position:relative;
+ background-image: url(../assets/image/bg_footer.png);
+ background-repeat: repeat-x;
+ height: 75px;
+ width: 100%;
+ left: 0px;
+ bottom: 0px;
+}
+#score_box {
+ float: left;
+ padding-left: 5px;
+ padding-top: 0.7em;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #FFFF00;
+ font-size: 16pt;
+ font-weight: bold;
+}
+#botbtn_right {
+ float: right;
+ height: 55px;
+ padding-right: 5px;
+ padding-top: 10px;
+}
+ #linkCheck{
+ margin: 1em 3em 0 0;
+ width: 101px; height: 30px;
+ background-image: url(../assets/image/check.png);
+ }
+
+ #linkStart{
+ width: 251px; height: 55px;
+ background:url(../assets/image/btn_start.png);
+ }
+ #linkStart:hover{
+ background:url(../assets/image/btn_start_hover.png);
+ }
+ #linkStart:active{
+ background:url(../assets/image/btn_start_mouse_down.png);
+ }
+ #linkPlayAgain{
+ width: 251px; height: 55px;
+ background:url(../assets/image/btn_play_again.png);
+ }
+ #linkPlayAgain:hover{
+ background:url(../assets/image/btn_play_again_hover.png);
+ }
+ #linkPlayAgain:active{
+ background:url(../assets/image/btn_play_again_mouse_down.png);
+ }
+
+
+#timerBar {
+ position: absolute;
+ left: 30%;
+ bottom: 25%;
+ width: 140px;
+ height:35px;
+ padding-left: 10px;
+ padding-top: 0px;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #FFFF00;
+ font-size: 16pt;
+ font-weight: bold;
+ }
+
+ .timerBoxes{ /* Show the timer running after the game has began.... */
+ float:right;
+ width: 80px;
+ height: 35px;
+ border: 2px dotted green;
+ padding-left: 0.5em;
+ color: blue;
+ text-align:center;
+ font : bold 25px Arial Black, Times New Roman;
+ background: #ACC;
+ }
+
+#linkNextLesson{
+ position:absolute;
+ bottom: 75px;
+ right: 10px;
+}
+#linkPrevLesson{
+ position:absolute;
+ bottom: 75px;
+ left: 10px;
+}
+
+/**** End of the page style ****/
+
+/**** Game Styles ****/
+
+a{
+ color:#FFFFCC;
+}
+#currentTitle{
+ width: 150px;
+ height: 80px;
+ font:25px/30px "Courier New", Courier, monospace;
+ font-weight: bold;
+ color: red;
+}
+#content{
+ position:relative;
+ margin: 0 auto;
+ margin-top: 80px;
+ width: 1198px;
+ height: 555px;
+}
+ #imageDisplayBox{
+ margin: 5px auto;
+ width: 600px;
+ height: 400px;
+ border: 1px solid #AFEF45;
+ }
+ .default{
+ float:left;
+ width: 148px;
+ height: 98px;
+ background-color:#C4FFC4;
+ border: 1px solid #AFEF45;
+ }
+ .correct{
+ float:left;
+ width: 69px;
+ height: 48px;
+ background-color:#A6E4FE;
+ border: 2px solid #F9F900;
+ }
+
+
+ #questionSection{
+ margin: 1em auto;
+ width: 50em;
+ height: 6em;
+ font: 20px/25px Verdana, Geneva, Arial, Helvetica, sans-serif;
+ font-weight:bolder;
+ text-align:center;
+ }
+ #questionInfo{
+ text-align:center;
+ width: 28em;
+ height: 2em;
+ margin: 0.5em auto;
+ }
+ .numberBox{
+ float:left;
+ width: 2em;
+ height: 1em;
+ padding: 0.1em;
+ }
+ .clickBox{
+ margin: 0 1.5em;
+ float:left;
+ width: 2em;
+ height: 1.2em;
+ padding: 0.1em;
+ border: 2px solid #000;
+ cursor:pointer;
+ }
+ #checkAnswer{
+ float:left;
+ width:64px;
+ height:64px;
+ border: 2px solid re;
+ }
+
+ #levelShow{
+ position:fixed;
+ top: 35%;
+ right:10%;
+ width: 50px;
+ height: 150px;
+ }
+ .levelImages{
+ float:left;
+ width: 48px;
+ height:48px;
+ cursor:pointer;
+ }
+ .levelText{
+ float:left;
+ width: 48px;
+ height:48px;
+ margin-top: .7em;
+ font: 20px/25px Verdana, Geneva, Arial, Helvetica, sans-serif;
+ font-weight:bolder;
+ }
+
+
+ #gameInformation{
+ position:absolute;
+ top: 70%;
+ right:0%;
+ width: 250px;
+ height: 150px;
+ font: 25px/30px Verdana, Geneva, Arial, Helvetica, sans-serif;
+ font-weight:bolder;
+ color: red;
+ }
+ /**** Page Classes ***/
+
+ .float-left{
+ float:left;
+ }
+ .yellow{
+ background-color: yellow;
+ }
+ .clicked{
+ background-color: #FF9900;
+ }
+
+#help{
+ display:none;
+ position:absolute;
+ right: 60px;
+ top: 75px;;
+ width: 256px;
+ height: 600px;
+ background:url(../assets/image/help.png);
+ z-index:40;
+}
+
+
+ #gameOver{
+ opacity: 1;
+ display:none;
+ position:absolute;
+ top:45%;
+ left: 30%;
+ color: blue;
+ text-align:center;
+ font : bold 45px/65px Arial Black, Times New Roman;
+ }
+ #gameOverInfo{
+ margin-top: 35px;
+ text-align:center;
+ font: 20px/25px Helvetica, Geneva, Arial, Verdana, sans-serif;
+ font-weight:bold;
+ color:#FF0000;
+
+ }
+ .specialText{
+ margin-top: 1em;
+ font: 20px/25px Helvetica, Geneva, Arial, Verdana, sans-serif;
+ font-weight:bold;
+ color:#FF9900;
+ border-bottom: 2px dotted #CCC;
+
+ }
diff --git a/examples/lessons/6_Maths_AddSubtract/css/ui.scoreboard.css b/examples/lessons/6_Maths_AddSubtract/css/ui.scoreboard.css
new file mode 100755
index 0000000..11cdbb5
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/css/ui.scoreboard.css
@@ -0,0 +1,62 @@
+.ui-scoreboard-container-h{
+max-width: 800em;
+max-height: 200px;
+float:left;
+padding-top:0.4em;
+padding-bottom:0.4em;
+}
+
+.ui-scoreboard-spacing-h{
+max-width: 200em;
+max-height: 300em;
+display:inline;
+margin-left:0.2em;
+margin-right:0.4em;
+}
+
+.ui-scoreboard-text{
+font-size:larger;
+text-align: center;
+}
+
+.ui-scoreboard-number-h {
+background-color:black;
+color: white;
+padding-left:0.4em;
+padding-right:0.4em;
+font-size:larger;
+}
+
+.ui-scoreboard-button{
+float:right;
+cursor:pointer;
+}
+
+button .ui-scoreboard-icon{
+float: left;
+margin-right:0.3em;
+}
+.ui-scoreboard-container-v{
+max-width: 200px;
+max-height: 400px;
+float:left;
+padding-top:0.4em;
+padding-bottom:0.4em;
+}
+.ui-scoreboard-spacing-v{
+display:block;
+margin: 0.4em;
+}
+
+.ui-scoreboard-number-v{
+background-color:black;
+color: white;
+width: 1em;
+text-align:center;
+margin-left:auto;
+margin-right: auto;
+padding:0.4em;
+font-size:larger;
+}
+
+
diff --git a/examples/lessons/6_Maths_AddSubtract/index.html b/examples/lessons/6_Maths_AddSubtract/index.html
new file mode 100755
index 0000000..00caf40
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/index.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Class 6 Maths Add Subtract</title>
+ <meta name="keywords" content="karma,javascript,html5,sugar,sugarlabs,gsoc,ole,nepal" />
+ <link type="text/css" rel="stylesheet" href="css/ui.scoreboard.css" />
+ <link type="text/css" rel="stylesheet" href="css/lesson.css" />
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <link type="image/ico" rel="icon" href="../../assets/default/image/favicon.ico" />
+ <script type="text/javascript" src="js/jquery-1.4.js"></script>
+ <script type="text/javascript" src="js/ui.core.js"></script>
+ <script type="text/javascript" src="js/ui.scoreboard.js"></script>
+ <script type="text/javascript" src="js/karma.js"></script>
+ <script type="text/javascript" src="js/jquery.watermarkinput.js"></script>
+ <script type="text/javascript" src="js/lesson.js"></script>
+</head>
+<body>
+ <div id="header">
+ <div id="topbtn_left"><a href="#"><div id="linkBackLesson" class="linkBack"></div></a></div>
+ <div id="lesson_title">
+ <img src="assets/image/title_block_lt.png" width="33" height="75" align="absmiddle" />
+ Add Subtract || <span id="currentTitle">जोड घटाउ अभ्यास </span>
+ <img src="assets/image/title_block_rt.png" width="33" height="75" align="absmiddle" />
+ </div>
+ <div id="topbtn_right"><a href="#"><div id="linkHelp"></div></a></div>
+ <div id="topbtn_right"><a href="http://olenepal.org"><div id="linkOle"></div></a></div>
+ </div>
+
+ <div id="content"></div>
+ <div id="help"></div>
+ <div id="gameOver"></div>
+ <form name="delayForm">
+ <input type="hidden" name="delayval" size="5">
+ </form>
+
+ <div id="footer">
+ <div id="botbtn_right"><a href="#"><div id="linkPlayAgain"></div></a></div>
+ <div id="botbtn_right"><a href="#"><div id="linkStart"></div></a></div>
+ <div id="botbtn_right"><a href="#"><div id="linkCheck"></div></a></div>
+ <div id="score_box"></div>
+ <div id ="timerBar">
+ <img src="assets/image/picClock.png" />
+ <div id="timerBox1" class="timerBoxes"></div>
+ </div>
+ </div>
+</body>
+</html>
diff --git a/examples/lessons/6_Maths_AddSubtract/js/jquery-1.4.js b/examples/lessons/6_Maths_AddSubtract/js/jquery-1.4.js
new file mode 100755
index 0000000..a448490
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/js/jquery-1.4.js
@@ -0,0 +1,5999 @@
+/*!
+ * jQuery JavaScript Library v1.4
+ * http://jquery.com/
+ *
+ * Copyright 2010, John Resig
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://docs.jquery.com/License
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ * Copyright 2010, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ *
+ * Date: Wed Jan 13 15:23:05 2010 -0500
+ */
+(function( window, undefined ) {
+
+// Define a local copy of jQuery
+var jQuery = function( selector, context ) {
+ // The jQuery object is actually just the init constructor 'enhanced'
+ return new jQuery.fn.init( selector, context );
+ },
+
+ // Map over jQuery in case of overwrite
+ _jQuery = window.jQuery,
+
+ // Map over the $ in case of overwrite
+ _$ = window.$,
+
+ // Use the correct document accordingly with window argument (sandbox)
+ document = window.document,
+
+ // A central reference to the root jQuery(document)
+ rootjQuery,
+
+ // A simple way to check for HTML strings or ID strings
+ // (both of which we optimize for)
+ quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,
+
+ // Is it a simple selector
+ isSimple = /^.[^:#\[\.,]*$/,
+
+ // Check if a string has a non-whitespace character in it
+ rnotwhite = /\S/,
+
+ // Used for trimming whitespace
+ rtrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g,
+
+ // Match a standalone tag
+ rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
+
+ // Keep a UserAgent string for use with jQuery.browser
+ userAgent = navigator.userAgent,
+
+ // For matching the engine and version of the browser
+ browserMatch,
+
+ // Has the ready events already been bound?
+ readyBound = false,
+
+ // The functions to execute on DOM ready
+ readyList = [],
+
+ // The ready event handler
+ DOMContentLoaded,
+
+ // Save a reference to some core methods
+ toString = Object.prototype.toString,
+ hasOwnProperty = Object.prototype.hasOwnProperty,
+ push = Array.prototype.push,
+ slice = Array.prototype.slice,
+ indexOf = Array.prototype.indexOf;
+
+jQuery.fn = jQuery.prototype = {
+ init: function( selector, context ) {
+ var match, elem, ret, doc;
+
+ // Handle $(""), $(null), or $(undefined)
+ if ( !selector ) {
+ return this;
+ }
+
+ // Handle $(DOMElement)
+ if ( selector.nodeType ) {
+ this.context = this[0] = selector;
+ this.length = 1;
+ return this;
+ }
+
+ // Handle HTML strings
+ if ( typeof selector === "string" ) {
+ // Are we dealing with HTML string or an ID?
+ match = quickExpr.exec( selector );
+
+ // Verify a match, and that no context was specified for #id
+ if ( match && (match[1] || !context) ) {
+
+ // HANDLE: $(html) -> $(array)
+ if ( match[1] ) {
+ doc = (context ? context.ownerDocument || context : document);
+
+ // If a single string is passed in and it's a single tag
+ // just do a createElement and skip the rest
+ ret = rsingleTag.exec( selector );
+
+ if ( ret ) {
+ if ( jQuery.isPlainObject( context ) ) {
+ selector = [ document.createElement( ret[1] ) ];
+ jQuery.fn.attr.call( selector, context, true );
+
+ } else {
+ selector = [ doc.createElement( ret[1] ) ];
+ }
+
+ } else {
+ ret = buildFragment( [ match[1] ], [ doc ] );
+ selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
+ }
+
+ // HANDLE: $("#id")
+ } else {
+ elem = document.getElementById( match[2] );
+
+ if ( elem ) {
+ // Handle the case where IE and Opera return items
+ // by name instead of ID
+ if ( elem.id !== match[2] ) {
+ return rootjQuery.find( selector );
+ }
+
+ // Otherwise, we inject the element directly into the jQuery object
+ this.length = 1;
+ this[0] = elem;
+ }
+
+ this.context = document;
+ this.selector = selector;
+ return this;
+ }
+
+ // HANDLE: $("TAG")
+ } else if ( !context && /^\w+$/.test( selector ) ) {
+ this.selector = selector;
+ this.context = document;
+ selector = document.getElementsByTagName( selector );
+
+ // HANDLE: $(expr, $(...))
+ } else if ( !context || context.jquery ) {
+ return (context || rootjQuery).find( selector );
+
+ // HANDLE: $(expr, context)
+ // (which is just equivalent to: $(context).find(expr)
+ } else {
+ return jQuery( context ).find( selector );
+ }
+
+ // HANDLE: $(function)
+ // Shortcut for document ready
+ } else if ( jQuery.isFunction( selector ) ) {
+ return rootjQuery.ready( selector );
+ }
+
+ if (selector.selector !== undefined) {
+ this.selector = selector.selector;
+ this.context = selector.context;
+ }
+
+ return jQuery.isArray( selector ) ?
+ this.setArray( selector ) :
+ jQuery.makeArray( selector, this );
+ },
+
+ // Start with an empty selector
+ selector: "",
+
+ // The current version of jQuery being used
+ jquery: "1.4",
+
+ // The default length of a jQuery object is 0
+ length: 0,
+
+ // The number of elements contained in the matched element set
+ size: function() {
+ return this.length;
+ },
+
+ toArray: function() {
+ return slice.call( this, 0 );
+ },
+
+ // Get the Nth element in the matched element set OR
+ // Get the whole matched element set as a clean array
+ get: function( num ) {
+ return num == null ?
+
+ // Return a 'clean' array
+ this.toArray() :
+
+ // Return just the object
+ ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
+ },
+
+ // Take an array of elements and push it onto the stack
+ // (returning the new matched element set)
+ pushStack: function( elems, name, selector ) {
+ // Build a new jQuery matched element set
+ var ret = jQuery( elems || null );
+
+ // Add the old object onto the stack (as a reference)
+ ret.prevObject = this;
+
+ ret.context = this.context;
+
+ if ( name === "find" ) {
+ ret.selector = this.selector + (this.selector ? " " : "") + selector;
+ } else if ( name ) {
+ ret.selector = this.selector + "." + name + "(" + selector + ")";
+ }
+
+ // Return the newly-formed element set
+ return ret;
+ },
+
+ // Force the current matched set of elements to become
+ // the specified array of elements (destroying the stack in the process)
+ // You should use pushStack() in order to do this, but maintain the stack
+ setArray: function( elems ) {
+ // Resetting the length to 0, then using the native Array push
+ // is a super-fast way to populate an object with array-like properties
+ this.length = 0;
+ push.apply( this, elems );
+
+ return this;
+ },
+
+ // Execute a callback for every element in the matched set.
+ // (You can seed the arguments with an array of args, but this is
+ // only used internally.)
+ each: function( callback, args ) {
+ return jQuery.each( this, callback, args );
+ },
+
+ ready: function( fn ) {
+ // Attach the listeners
+ jQuery.bindReady();
+
+ // If the DOM is already ready
+ if ( jQuery.isReady ) {
+ // Execute the function immediately
+ fn.call( document, jQuery );
+
+ // Otherwise, remember the function for later
+ } else if ( readyList ) {
+ // Add the function to the wait list
+ readyList.push( fn );
+ }
+
+ return this;
+ },
+
+ eq: function( i ) {
+ return i === -1 ?
+ this.slice( i ) :
+ this.slice( i, +i + 1 );
+ },
+
+ first: function() {
+ return this.eq( 0 );
+ },
+
+ last: function() {
+ return this.eq( -1 );
+ },
+
+ slice: function() {
+ return this.pushStack( slice.apply( this, arguments ),
+ "slice", slice.call(arguments).join(",") );
+ },
+
+ map: function( callback ) {
+ return this.pushStack( jQuery.map(this, function( elem, i ) {
+ return callback.call( elem, i, elem );
+ }));
+ },
+
+ end: function() {
+ return this.prevObject || jQuery(null);
+ },
+
+ // For internal use only.
+ // Behaves like an Array's method, not like a jQuery method.
+ push: push,
+ sort: [].sort,
+ splice: [].splice
+};
+
+// Give the init function the jQuery prototype for later instantiation
+jQuery.fn.init.prototype = jQuery.fn;
+
+jQuery.extend = jQuery.fn.extend = function() {
+ // copy reference to target object
+ var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy;
+
+ // Handle a deep copy situation
+ if ( typeof target === "boolean" ) {
+ deep = target;
+ target = arguments[1] || {};
+ // skip the boolean and the target
+ i = 2;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
+ target = {};
+ }
+
+ // extend jQuery itself if only one argument is passed
+ if ( length === i ) {
+ target = this;
+ --i;
+ }
+
+ for ( ; i < length; i++ ) {
+ // Only deal with non-null/undefined values
+ if ( (options = arguments[ i ]) != null ) {
+ // Extend the base object
+ for ( name in options ) {
+ src = target[ name ];
+ copy = options[ name ];
+
+ // Prevent never-ending loop
+ if ( target === copy ) {
+ continue;
+ }
+
+ // Recurse if we're merging object literal values or arrays
+ if ( deep && copy && ( jQuery.isPlainObject(copy) || jQuery.isArray(copy) ) ) {
+ var clone = src && ( jQuery.isPlainObject(src) || jQuery.isArray(src) ) ? src
+ : jQuery.isArray(copy) ? [] : {};
+
+ // Never move original objects, clone them
+ target[ name ] = jQuery.extend( deep, clone, copy );
+
+ // Don't bring in undefined values
+ } else if ( copy !== undefined ) {
+ target[ name ] = copy;
+ }
+ }
+ }
+ }
+
+ // Return the modified object
+ return target;
+};
+
+jQuery.extend({
+ noConflict: function( deep ) {
+ window.$ = _$;
+
+ if ( deep ) {
+ window.jQuery = _jQuery;
+ }
+
+ return jQuery;
+ },
+
+ // Is the DOM ready to be used? Set to true once it occurs.
+ isReady: false,
+
+ // Handle when the DOM is ready
+ ready: function() {
+ // Make sure that the DOM is not already loaded
+ if ( !jQuery.isReady ) {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( !document.body ) {
+ return setTimeout( jQuery.ready, 13 );
+ }
+
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If there are functions bound, to execute
+ if ( readyList ) {
+ // Execute all of them
+ var fn, i = 0;
+ while ( (fn = readyList[ i++ ]) ) {
+ fn.call( document, jQuery );
+ }
+
+ // Reset the list of functions
+ readyList = null;
+ }
+
+ // Trigger any bound ready events
+ if ( jQuery.fn.triggerHandler ) {
+ jQuery( document ).triggerHandler( "ready" );
+ }
+ }
+ },
+
+ bindReady: function() {
+ if ( readyBound ) {
+ return;
+ }
+
+ readyBound = true;
+
+ // Catch cases where $(document).ready() is called after the
+ // browser event has already occurred.
+ if ( document.readyState === "complete" ) {
+ return jQuery.ready();
+ }
+
+ // Mozilla, Opera and webkit nightlies currently support this event
+ if ( document.addEventListener ) {
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+
+ // A fallback to window.onload, that will always work
+ window.addEventListener( "load", jQuery.ready, false );
+
+ // If IE event model is used
+ } else if ( document.attachEvent ) {
+ // ensure firing before onload,
+ // maybe late but safe also for iframes
+ document.attachEvent("onreadystatechange", DOMContentLoaded);
+
+ // A fallback to window.onload, that will always work
+ window.attachEvent( "onload", jQuery.ready );
+
+ // If IE and not a frame
+ // continually check to see if the document is ready
+ var toplevel = false;
+
+ try {
+ toplevel = window.frameElement == null;
+ } catch(e) {}
+
+ if ( document.documentElement.doScroll && toplevel ) {
+ doScrollCheck();
+ }
+ }
+ },
+
+ // See test/unit/core.js for details concerning isFunction.
+ // Since version 1.3, DOM methods and functions like alert
+ // aren't supported. They return false on IE (#2968).
+ isFunction: function( obj ) {
+ return toString.call(obj) === "[object Function]";
+ },
+
+ isArray: function( obj ) {
+ return toString.call(obj) === "[object Array]";
+ },
+
+ isPlainObject: function( obj ) {
+ // Must be an Object.
+ // Because of IE, we also have to check the presence of the constructor property.
+ // Make sure that DOM nodes and window objects don't pass through, as well
+ if ( !obj || toString.call(obj) !== "[object Object]" || obj.nodeType || obj.setInterval ) {
+ return false;
+ }
+
+ // Not own constructor property must be Object
+ if ( obj.constructor
+ && !hasOwnProperty.call(obj, "constructor")
+ && !hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf") ) {
+ return false;
+ }
+
+ // Own properties are enumerated firstly, so to speed up,
+ // if last one is own, then all properties are own.
+
+ var key;
+ for ( key in obj ) {}
+
+ return key === undefined || hasOwnProperty.call( obj, key );
+ },
+
+ isEmptyObject: function( obj ) {
+ for ( var name in obj ) {
+ return false;
+ }
+ return true;
+ },
+
+ noop: function() {},
+
+ // Evalulates a script in a global context
+ globalEval: function( data ) {
+ if ( data && rnotwhite.test(data) ) {
+ // Inspired by code by Andrea Giammarchi
+ // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
+ var head = document.getElementsByTagName("head")[0] || document.documentElement,
+ script = document.createElement("script");
+
+ script.type = "text/javascript";
+
+ if ( jQuery.support.scriptEval ) {
+ script.appendChild( document.createTextNode( data ) );
+ } else {
+ script.text = data;
+ }
+
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709).
+ head.insertBefore( script, head.firstChild );
+ head.removeChild( script );
+ }
+ },
+
+ nodeName: function( elem, name ) {
+ return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
+ },
+
+ // args is for internal usage only
+ each: function( object, callback, args ) {
+ var name, i = 0,
+ length = object.length,
+ isObj = length === undefined || jQuery.isFunction(object);
+
+ if ( args ) {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.apply( object[ name ], args ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( ; i < length; ) {
+ if ( callback.apply( object[ i++ ], args ) === false ) {
+ break;
+ }
+ }
+ }
+
+ // A special, fast, case for the most common use of each
+ } else {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( var value = object[0];
+ i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
+ }
+ }
+
+ return object;
+ },
+
+ trim: function( text ) {
+ return (text || "").replace( rtrim, "" );
+ },
+
+ // results is for internal usage only
+ makeArray: function( array, results ) {
+ var ret = results || [];
+
+ if ( array != null ) {
+ // The window, strings (and functions) also have 'length'
+ // The extra typeof function check is to prevent crashes
+ // in Safari 2 (See: #3039)
+ if ( array.length == null || typeof array === "string" || jQuery.isFunction(array) || (typeof array !== "function" && array.setInterval) ) {
+ push.call( ret, array );
+ } else {
+ jQuery.merge( ret, array );
+ }
+ }
+
+ return ret;
+ },
+
+ inArray: function( elem, array ) {
+ if ( array.indexOf ) {
+ return array.indexOf( elem );
+ }
+
+ for ( var i = 0, length = array.length; i < length; i++ ) {
+ if ( array[ i ] === elem ) {
+ return i;
+ }
+ }
+
+ return -1;
+ },
+
+ merge: function( first, second ) {
+ var i = first.length, j = 0;
+
+ if ( typeof second.length === "number" ) {
+ for ( var l = second.length; j < l; j++ ) {
+ first[ i++ ] = second[ j ];
+ }
+ } else {
+ while ( second[j] !== undefined ) {
+ first[ i++ ] = second[ j++ ];
+ }
+ }
+
+ first.length = i;
+
+ return first;
+ },
+
+ grep: function( elems, callback, inv ) {
+ var ret = [];
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ if ( !inv !== !callback( elems[ i ], i ) ) {
+ ret.push( elems[ i ] );
+ }
+ }
+
+ return ret;
+ },
+
+ // arg is for internal usage only
+ map: function( elems, callback, arg ) {
+ var ret = [], value;
+
+ // Go through the array, translating each of the items to their
+ // new value (or values).
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ value = callback( elems[ i ], i, arg );
+
+ if ( value != null ) {
+ ret[ ret.length ] = value;
+ }
+ }
+
+ return ret.concat.apply( [], ret );
+ },
+
+ // A global GUID counter for objects
+ guid: 1,
+
+ proxy: function( fn, proxy, thisObject ) {
+ if ( arguments.length === 2 ) {
+ if ( typeof proxy === "string" ) {
+ thisObject = fn;
+ fn = thisObject[ proxy ];
+ proxy = undefined;
+
+ } else if ( proxy && !jQuery.isFunction( proxy ) ) {
+ thisObject = proxy;
+ proxy = undefined;
+ }
+ }
+
+ if ( !proxy && fn ) {
+ proxy = function() {
+ return fn.apply( thisObject || this, arguments );
+ };
+ }
+
+ // Set the guid of unique handler to the same of original handler, so it can be removed
+ if ( fn ) {
+ proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
+ }
+
+ // So proxy can be declared as an argument
+ return proxy;
+ },
+
+ // Use of jQuery.browser is frowned upon.
+ // More details: http://docs.jquery.com/Utilities/jQuery.browser
+ uaMatch: function( ua ) {
+ var ret = { browser: "" };
+
+ ua = ua.toLowerCase();
+
+ if ( /webkit/.test( ua ) ) {
+ ret = { browser: "webkit", version: /webkit[\/ ]([\w.]+)/ };
+
+ } else if ( /opera/.test( ua ) ) {
+ ret = { browser: "opera", version: /version/.test( ua ) ? /version[\/ ]([\w.]+)/ : /opera[\/ ]([\w.]+)/ };
+
+ } else if ( /msie/.test( ua ) ) {
+ ret = { browser: "msie", version: /msie ([\w.]+)/ };
+
+ } else if ( /mozilla/.test( ua ) && !/compatible/.test( ua ) ) {
+ ret = { browser: "mozilla", version: /rv:([\w.]+)/ };
+ }
+
+ ret.version = (ret.version && ret.version.exec( ua ) || [0, "0"])[1];
+
+ return ret;
+ },
+
+ browser: {}
+});
+
+browserMatch = jQuery.uaMatch( userAgent );
+if ( browserMatch.browser ) {
+ jQuery.browser[ browserMatch.browser ] = true;
+ jQuery.browser.version = browserMatch.version;
+}
+
+// Deprecated, use jQuery.browser.webkit instead
+if ( jQuery.browser.webkit ) {
+ jQuery.browser.safari = true;
+}
+
+if ( indexOf ) {
+ jQuery.inArray = function( elem, array ) {
+ return indexOf.call( array, elem );
+ };
+}
+
+// All jQuery objects should point back to these
+rootjQuery = jQuery(document);
+
+// Cleanup functions for the document ready method
+if ( document.addEventListener ) {
+ DOMContentLoaded = function() {
+ document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+ jQuery.ready();
+ };
+
+} else if ( document.attachEvent ) {
+ DOMContentLoaded = function() {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( document.readyState === "complete" ) {
+ document.detachEvent( "onreadystatechange", DOMContentLoaded );
+ jQuery.ready();
+ }
+ };
+}
+
+// The DOM ready check for Internet Explorer
+function doScrollCheck() {
+ if ( jQuery.isReady ) {
+ return;
+ }
+
+ try {
+ // If IE is used, use the trick by Diego Perini
+ // http://javascript.nwbox.com/IEContentLoaded/
+ document.documentElement.doScroll("left");
+ } catch( error ) {
+ setTimeout( doScrollCheck, 1 );
+ return;
+ }
+
+ // and execute any waiting functions
+ jQuery.ready();
+}
+
+if ( indexOf ) {
+ jQuery.inArray = function( elem, array ) {
+ return indexOf.call( array, elem );
+ };
+}
+
+function evalScript( i, elem ) {
+ if ( elem.src ) {
+ jQuery.ajax({
+ url: elem.src,
+ async: false,
+ dataType: "script"
+ });
+ } else {
+ jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
+ }
+
+ if ( elem.parentNode ) {
+ elem.parentNode.removeChild( elem );
+ }
+}
+
+// Mutifunctional method to get and set values to a collection
+// The value/s can be optionally by executed if its a function
+function access( elems, key, value, exec, fn, pass ) {
+ var length = elems.length;
+
+ // Setting many attributes
+ if ( typeof key === "object" ) {
+ for ( var k in key ) {
+ access( elems, k, key[k], exec, fn, value );
+ }
+ return elems;
+ }
+
+ // Setting one attribute
+ if ( value !== undefined ) {
+ // Optionally, function values get executed if exec is true
+ exec = !pass && exec && jQuery.isFunction(value);
+
+ for ( var i = 0; i < length; i++ ) {
+ fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
+ }
+
+ return elems;
+ }
+
+ // Getting an attribute
+ return length ? fn( elems[0], key ) : null;
+}
+
+function now() {
+ return (new Date).getTime();
+}
+(function() {
+
+ jQuery.support = {};
+
+ var root = document.documentElement,
+ script = document.createElement("script"),
+ div = document.createElement("div"),
+ id = "script" + now();
+
+ div.style.display = "none";
+ div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
+
+ var all = div.getElementsByTagName("*"),
+ a = div.getElementsByTagName("a")[0];
+
+ // Can't get basic test support
+ if ( !all || !all.length || !a ) {
+ return;
+ }
+
+ jQuery.support = {
+ // IE strips leading whitespace when .innerHTML is used
+ leadingWhitespace: div.firstChild.nodeType === 3,
+
+ // Make sure that tbody elements aren't automatically inserted
+ // IE will insert them into empty tables
+ tbody: !div.getElementsByTagName("tbody").length,
+
+ // Make sure that link elements get serialized correctly by innerHTML
+ // This requires a wrapper element in IE
+ htmlSerialize: !!div.getElementsByTagName("link").length,
+
+ // Get the style information from getAttribute
+ // (IE uses .cssText insted)
+ style: /red/.test( a.getAttribute("style") ),
+
+ // Make sure that URLs aren't manipulated
+ // (IE normalizes it by default)
+ hrefNormalized: a.getAttribute("href") === "/a",
+
+ // Make sure that element opacity exists
+ // (IE uses filter instead)
+ // Use a regex to work around a WebKit issue. See #5145
+ opacity: /^0.55$/.test( a.style.opacity ),
+
+ // Verify style float existence
+ // (IE uses styleFloat instead of cssFloat)
+ cssFloat: !!a.style.cssFloat,
+
+ // Make sure that if no value is specified for a checkbox
+ // that it defaults to "on".
+ // (WebKit defaults to "" instead)
+ checkOn: div.getElementsByTagName("input")[0].value === "on",
+
+ // Make sure that a selected-by-default option has a working selected property.
+ // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
+ optSelected: document.createElement("select").appendChild( document.createElement("option") ).selected,
+
+ // Will be defined later
+ scriptEval: false,
+ noCloneEvent: true,
+ boxModel: null
+ };
+
+ script.type = "text/javascript";
+ try {
+ script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
+ } catch(e) {}
+
+ root.insertBefore( script, root.firstChild );
+
+ // Make sure that the execution of code works by injecting a script
+ // tag with appendChild/createTextNode
+ // (IE doesn't support this, fails, and uses .text instead)
+ if ( window[ id ] ) {
+ jQuery.support.scriptEval = true;
+ delete window[ id ];
+ }
+
+ root.removeChild( script );
+
+ if ( div.attachEvent && div.fireEvent ) {
+ div.attachEvent("onclick", function click() {
+ // Cloning a node shouldn't copy over any
+ // bound event handlers (IE does this)
+ jQuery.support.noCloneEvent = false;
+ div.detachEvent("onclick", click);
+ });
+ div.cloneNode(true).fireEvent("onclick");
+ }
+
+ // Figure out if the W3C box model works as expected
+ // document.body must exist before we can do this
+ // TODO: This timeout is temporary until I move ready into core.js.
+ jQuery(function() {
+ var div = document.createElement("div");
+ div.style.width = div.style.paddingLeft = "1px";
+
+ document.body.appendChild( div );
+ jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
+ document.body.removeChild( div ).style.display = 'none';
+ div = null;
+ });
+
+ // Technique from Juriy Zaytsev
+ // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
+ var eventSupported = function( eventName ) {
+ var el = document.createElement("div");
+ eventName = "on" + eventName;
+
+ var isSupported = (eventName in el);
+ if ( !isSupported ) {
+ el.setAttribute(eventName, "return;");
+ isSupported = typeof el[eventName] === "function";
+ }
+ el = null;
+
+ return isSupported;
+ };
+
+ jQuery.support.submitBubbles = eventSupported("submit");
+ jQuery.support.changeBubbles = eventSupported("change");
+
+ // release memory in IE
+ root = script = div = all = a = null;
+})();
+
+jQuery.props = {
+ "for": "htmlFor",
+ "class": "className",
+ readonly: "readOnly",
+ maxlength: "maxLength",
+ cellspacing: "cellSpacing",
+ rowspan: "rowSpan",
+ colspan: "colSpan",
+ tabindex: "tabIndex",
+ usemap: "useMap",
+ frameborder: "frameBorder"
+};
+var expando = "jQuery" + now(), uuid = 0, windowData = {};
+var emptyObject = {};
+
+jQuery.extend({
+ cache: {},
+
+ expando:expando,
+
+ // The following elements throw uncatchable exceptions if you
+ // attempt to add expando properties to them.
+ noData: {
+ "embed": true,
+ "object": true,
+ "applet": true
+ },
+
+ data: function( elem, name, data ) {
+ if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
+ return;
+ }
+
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var id = elem[ expando ], cache = jQuery.cache, thisCache;
+
+ // Handle the case where there's no name immediately
+ if ( !name && !id ) {
+ return null;
+ }
+
+ // Compute a unique ID for the element
+ if ( !id ) {
+ id = ++uuid;
+ }
+
+ // Avoid generating a new cache unless none exists and we
+ // want to manipulate it.
+ if ( typeof name === "object" ) {
+ elem[ expando ] = id;
+ thisCache = cache[ id ] = jQuery.extend(true, {}, name);
+ } else if ( cache[ id ] ) {
+ thisCache = cache[ id ];
+ } else if ( typeof data === "undefined" ) {
+ thisCache = emptyObject;
+ } else {
+ thisCache = cache[ id ] = {};
+ }
+
+ // Prevent overriding the named cache with undefined values
+ if ( data !== undefined ) {
+ elem[ expando ] = id;
+ thisCache[ name ] = data;
+ }
+
+ return typeof name === "string" ? thisCache[ name ] : thisCache;
+ },
+
+ removeData: function( elem, name ) {
+ if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
+ return;
+ }
+
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ];
+
+ // If we want to remove a specific section of the element's data
+ if ( name ) {
+ if ( thisCache ) {
+ // Remove the section of cache data
+ delete thisCache[ name ];
+
+ // If we've removed all the data, remove the element's cache
+ if ( jQuery.isEmptyObject(thisCache) ) {
+ jQuery.removeData( elem );
+ }
+ }
+
+ // Otherwise, we want to remove all of the element's data
+ } else {
+ // Clean up the element expando
+ try {
+ delete elem[ expando ];
+ } catch( e ) {
+ // IE has trouble directly removing the expando
+ // but it's ok with using removeAttribute
+ if ( elem.removeAttribute ) {
+ elem.removeAttribute( expando );
+ }
+ }
+
+ // Completely remove the data cache
+ delete cache[ id ];
+ }
+ }
+});
+
+jQuery.fn.extend({
+ data: function( key, value ) {
+ if ( typeof key === "undefined" && this.length ) {
+ return jQuery.data( this[0] );
+
+ } else if ( typeof key === "object" ) {
+ return this.each(function() {
+ jQuery.data( this, key );
+ });
+ }
+
+ var parts = key.split(".");
+ parts[1] = parts[1] ? "." + parts[1] : "";
+
+ if ( value === undefined ) {
+ var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
+
+ if ( data === undefined && this.length ) {
+ data = jQuery.data( this[0], key );
+ }
+ return data === undefined && parts[1] ?
+ this.data( parts[0] ) :
+ data;
+ } else {
+ return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function() {
+ jQuery.data( this, key, value );
+ });
+ }
+ },
+
+ removeData: function( key ) {
+ return this.each(function() {
+ jQuery.removeData( this, key );
+ });
+ }
+});
+jQuery.extend({
+ queue: function( elem, type, data ) {
+ if ( !elem ) {
+ return;
+ }
+
+ type = (type || "fx") + "queue";
+ var q = jQuery.data( elem, type );
+
+ // Speed up dequeue by getting out quickly if this is just a lookup
+ if ( !data ) {
+ return q || [];
+ }
+
+ if ( !q || jQuery.isArray(data) ) {
+ q = jQuery.data( elem, type, jQuery.makeArray(data) );
+
+ } else {
+ q.push( data );
+ }
+
+ return q;
+ },
+
+ dequeue: function( elem, type ) {
+ type = type || "fx";
+
+ var queue = jQuery.queue( elem, type ), fn = queue.shift();
+
+ // If the fx queue is dequeued, always remove the progress sentinel
+ if ( fn === "inprogress" ) {
+ fn = queue.shift();
+ }
+
+ if ( fn ) {
+ // Add a progress sentinel to prevent the fx queue from being
+ // automatically dequeued
+ if ( type === "fx" ) {
+ queue.unshift("inprogress");
+ }
+
+ fn.call(elem, function() {
+ jQuery.dequeue(elem, type);
+ });
+ }
+ }
+});
+
+jQuery.fn.extend({
+ queue: function( type, data ) {
+ if ( typeof type !== "string" ) {
+ data = type;
+ type = "fx";
+ }
+
+ if ( data === undefined ) {
+ return jQuery.queue( this[0], type );
+ }
+ return this.each(function( i, elem ) {
+ var queue = jQuery.queue( this, type, data );
+
+ if ( type === "fx" && queue[0] !== "inprogress" ) {
+ jQuery.dequeue( this, type );
+ }
+ });
+ },
+ dequeue: function( type ) {
+ return this.each(function() {
+ jQuery.dequeue( this, type );
+ });
+ },
+
+ // Based off of the plugin by Clint Helfers, with permission.
+ // http://blindsignals.com/index.php/2009/07/jquery-delay/
+ delay: function( time, type ) {
+ time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
+ type = type || "fx";
+
+ return this.queue( type, function() {
+ var elem = this;
+ setTimeout(function() {
+ jQuery.dequeue( elem, type );
+ }, time );
+ });
+ },
+
+ clearQueue: function( type ) {
+ return this.queue( type || "fx", [] );
+ }
+});
+var rclass = /[\n\t]/g,
+ rspace = /\s+/,
+ rreturn = /\r/g,
+ rspecialurl = /href|src|style/,
+ rtype = /(button|input)/i,
+ rfocusable = /(button|input|object|select|textarea)/i,
+ rclickable = /^(a|area)$/i,
+ rradiocheck = /radio|checkbox/;
+
+jQuery.fn.extend({
+ attr: function( name, value ) {
+ return access( this, name, value, true, jQuery.attr );
+ },
+
+ removeAttr: function( name, fn ) {
+ return this.each(function(){
+ jQuery.attr( this, name, "" );
+ if ( this.nodeType === 1 ) {
+ this.removeAttribute( name );
+ }
+ });
+ },
+
+ addClass: function( value ) {
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.addClass( value.call(this, i, self.attr("class")) );
+ });
+ }
+
+ if ( value && typeof value === "string" ) {
+ var classNames = (value || "").split( rspace );
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var elem = this[i];
+
+ if ( elem.nodeType === 1 ) {
+ if ( !elem.className ) {
+ elem.className = value;
+
+ } else {
+ var className = " " + elem.className + " ";
+ for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
+ if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
+ elem.className += " " + classNames[c];
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ removeClass: function( value ) {
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.removeClass( value.call(this, i, self.attr("class")) );
+ });
+ }
+
+ if ( (value && typeof value === "string") || value === undefined ) {
+ var classNames = (value || "").split(rspace);
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var elem = this[i];
+
+ if ( elem.nodeType === 1 && elem.className ) {
+ if ( value ) {
+ var className = (" " + elem.className + " ").replace(rclass, " ");
+ for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
+ className = className.replace(" " + classNames[c] + " ", " ");
+ }
+ elem.className = className.substring(1, className.length - 1);
+
+ } else {
+ elem.className = "";
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ toggleClass: function( value, stateVal ) {
+ var type = typeof value, isBool = typeof stateVal === "boolean";
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
+ });
+ }
+
+ return this.each(function() {
+ if ( type === "string" ) {
+ // toggle individual class names
+ var className, i = 0, self = jQuery(this),
+ state = stateVal,
+ classNames = value.split( rspace );
+
+ while ( (className = classNames[ i++ ]) ) {
+ // check each className given, space seperated list
+ state = isBool ? state : !self.hasClass( className );
+ self[ state ? "addClass" : "removeClass" ]( className );
+ }
+
+ } else if ( type === "undefined" || type === "boolean" ) {
+ if ( this.className ) {
+ // store className if set
+ jQuery.data( this, "__className__", this.className );
+ }
+
+ // toggle whole className
+ this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || "";
+ }
+ });
+ },
+
+ hasClass: function( selector ) {
+ var className = " " + selector + " ";
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ val: function( value ) {
+ if ( value === undefined ) {
+ var elem = this[0];
+
+ if ( elem ) {
+ if ( jQuery.nodeName( elem, "option" ) ) {
+ return (elem.attributes.value || {}).specified ? elem.value : elem.text;
+ }
+
+ // We need to handle select boxes special
+ if ( jQuery.nodeName( elem, "select" ) ) {
+ var index = elem.selectedIndex,
+ values = [],
+ options = elem.options,
+ one = elem.type === "select-one";
+
+ // Nothing was selected
+ if ( index < 0 ) {
+ return null;
+ }
+
+ // Loop through all the selected options
+ for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
+ var option = options[ i ];
+
+ if ( option.selected ) {
+ // Get the specifc value for the option
+ value = jQuery(option).val();
+
+ // We don't need an array for one selects
+ if ( one ) {
+ return value;
+ }
+
+ // Multi-Selects return an array
+ values.push( value );
+ }
+ }
+
+ return values;
+ }
+
+ // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
+ if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
+ return elem.getAttribute("value") === null ? "on" : elem.value;
+ }
+
+
+ // Everything else, we just grab the value
+ return (elem.value || "").replace(rreturn, "");
+
+ }
+
+ return undefined;
+ }
+
+ var isFunction = jQuery.isFunction(value);
+
+ return this.each(function(i) {
+ var self = jQuery(this), val = value;
+
+ if ( this.nodeType !== 1 ) {
+ return;
+ }
+
+ if ( isFunction ) {
+ val = value.call(this, i, self.val());
+ }
+
+ // Typecast each time if the value is a Function and the appended
+ // value is therefore different each time.
+ if ( typeof val === "number" ) {
+ val += "";
+ }
+
+ if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
+ this.checked = jQuery.inArray( self.val(), val ) >= 0;
+
+ } else if ( jQuery.nodeName( this, "select" ) ) {
+ var values = jQuery.makeArray(val);
+
+ jQuery( "option", this ).each(function() {
+ this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
+ });
+
+ if ( !values.length ) {
+ this.selectedIndex = -1;
+ }
+
+ } else {
+ this.value = val;
+ }
+ });
+ }
+});
+
+jQuery.extend({
+ attrFn: {
+ val: true,
+ css: true,
+ html: true,
+ text: true,
+ data: true,
+ width: true,
+ height: true,
+ offset: true
+ },
+
+ attr: function( elem, name, value, pass ) {
+ // don't set attributes on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ if ( pass && name in jQuery.attrFn ) {
+ return jQuery(elem)[name](value);
+ }
+
+ var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
+ // Whether we are setting (or getting)
+ set = value !== undefined;
+
+ // Try to normalize/fix the name
+ name = notxml && jQuery.props[ name ] || name;
+
+ // Only do all the following if this is a node (faster for style)
+ if ( elem.nodeType === 1 ) {
+ // These attributes require special treatment
+ var special = rspecialurl.test( name );
+
+ // Safari mis-reports the default selected property of an option
+ // Accessing the parent's selectedIndex property fixes it
+ if ( name === "selected" && !jQuery.support.optSelected ) {
+ var parent = elem.parentNode;
+ if ( parent ) {
+ parent.selectedIndex;
+
+ // Make sure that it also works with optgroups, see #5701
+ if ( parent.parentNode ) {
+ parent.parentNode.selectedIndex;
+ }
+ }
+ }
+
+ // If applicable, access the attribute via the DOM 0 way
+ if ( name in elem && notxml && !special ) {
+ if ( set ) {
+ // We can't allow the type property to be changed (since it causes problems in IE)
+ if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
+ throw "type property can't be changed";
+ }
+
+ elem[ name ] = value;
+ }
+
+ // browsers index elements by id/name on forms, give priority to attributes.
+ if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
+ return elem.getAttributeNode( name ).nodeValue;
+ }
+
+ // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
+ // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
+ if ( name === "tabIndex" ) {
+ var attributeNode = elem.getAttributeNode( "tabIndex" );
+
+ return attributeNode && attributeNode.specified ?
+ attributeNode.value :
+ rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
+ 0 :
+ undefined;
+ }
+
+ return elem[ name ];
+ }
+
+ if ( !jQuery.support.style && notxml && name === "style" ) {
+ if ( set ) {
+ elem.style.cssText = "" + value;
+ }
+
+ return elem.style.cssText;
+ }
+
+ if ( set ) {
+ // convert the value to a string (all browsers do this but IE) see #1070
+ elem.setAttribute( name, "" + value );
+ }
+
+ var attr = !jQuery.support.hrefNormalized && notxml && special ?
+ // Some attributes require a special call on IE
+ elem.getAttribute( name, 2 ) :
+ elem.getAttribute( name );
+
+ // Non-existent attributes return null, we normalize to undefined
+ return attr === null ? undefined : attr;
+ }
+
+ // elem is actually elem.style ... set the style
+ // Using attr for specific style information is now deprecated. Use style insead.
+ return jQuery.style( elem, name, value );
+ }
+});
+var fcleanup = function( nm ) {
+ return nm.replace(/[^\w\s\.\|`]/g, function( ch ) {
+ return "\\" + ch;
+ });
+};
+
+/*
+ * A number of helper functions used for managing events.
+ * Many of the ideas behind this code originated from
+ * Dean Edwards' addEvent library.
+ */
+jQuery.event = {
+
+ // Bind an event to an element
+ // Original by Dean Edwards
+ add: function( elem, types, handler, data ) {
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ // For whatever reason, IE has trouble passing the window object
+ // around, causing it to be cloned in the process
+ if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) {
+ elem = window;
+ }
+
+ // Make sure that the function being executed has a unique ID
+ if ( !handler.guid ) {
+ handler.guid = jQuery.guid++;
+ }
+
+ // if data is passed, bind to handler
+ if ( data !== undefined ) {
+ // Create temporary function pointer to original handler
+ var fn = handler;
+
+ // Create unique handler function, wrapped around original handler
+ handler = jQuery.proxy( fn );
+
+ // Store data in unique handler
+ handler.data = data;
+ }
+
+ // Init the element's event structure
+ var events = jQuery.data( elem, "events" ) || jQuery.data( elem, "events", {} ),
+ handle = jQuery.data( elem, "handle" ), eventHandle;
+
+ if ( !handle ) {
+ eventHandle = function() {
+ // Handle the second event of a trigger and when
+ // an event is called after a page has unloaded
+ return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
+ jQuery.event.handle.apply( eventHandle.elem, arguments ) :
+ undefined;
+ };
+
+ handle = jQuery.data( elem, "handle", eventHandle );
+ }
+
+ // If no handle is found then we must be trying to bind to one of the
+ // banned noData elements
+ if ( !handle ) {
+ return;
+ }
+
+ // Add elem as a property of the handle function
+ // This is to prevent a memory leak with non-native
+ // event in IE.
+ handle.elem = elem;
+
+ // Handle multiple events separated by a space
+ // jQuery(...).bind("mouseover mouseout", fn);
+ types = types.split( /\s+/ );
+ var type, i=0;
+ while ( (type = types[ i++ ]) ) {
+ // Namespaced event handlers
+ var namespaces = type.split(".");
+ type = namespaces.shift();
+ handler.type = namespaces.slice(0).sort().join(".");
+
+ // Get the current list of functions bound to this event
+ var handlers = events[ type ],
+ special = this.special[ type ] || {};
+
+
+
+ // Init the event handler queue
+ if ( !handlers ) {
+ handlers = events[ type ] = {};
+
+ // Check for a special event handler
+ // Only use addEventListener/attachEvent if the special
+ // events handler returns false
+ if ( !special.setup || special.setup.call( elem, data, namespaces, handler) === false ) {
+ // Bind the global event handler to the element
+ if ( elem.addEventListener ) {
+ elem.addEventListener( type, handle, false );
+ } else if ( elem.attachEvent ) {
+ elem.attachEvent( "on" + type, handle );
+ }
+ }
+ }
+
+ if ( special.add ) {
+ var modifiedHandler = special.add.call( elem, handler, data, namespaces, handlers );
+ if ( modifiedHandler && jQuery.isFunction( modifiedHandler ) ) {
+ modifiedHandler.guid = modifiedHandler.guid || handler.guid;
+ handler = modifiedHandler;
+ }
+ }
+
+ // Add the function to the element's handler list
+ handlers[ handler.guid ] = handler;
+
+ // Keep track of which events have been used, for global triggering
+ this.global[ type ] = true;
+ }
+
+ // Nullify elem to prevent memory leaks in IE
+ elem = null;
+ },
+
+ global: {},
+
+ // Detach an event or set of events from an element
+ remove: function( elem, types, handler ) {
+ // don't do events on text and comment nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ var events = jQuery.data( elem, "events" ), ret, type, fn;
+
+ if ( events ) {
+ // Unbind all events for the element
+ if ( types === undefined || (typeof types === "string" && types.charAt(0) === ".") ) {
+ for ( type in events ) {
+ this.remove( elem, type + (types || "") );
+ }
+ } else {
+ // types is actually an event object here
+ if ( types.type ) {
+ handler = types.handler;
+ types = types.type;
+ }
+
+ // Handle multiple events separated by a space
+ // jQuery(...).unbind("mouseover mouseout", fn);
+ types = types.split(/\s+/);
+ var i = 0;
+ while ( (type = types[ i++ ]) ) {
+ // Namespaced event handlers
+ var namespaces = type.split(".");
+ type = namespaces.shift();
+ var all = !namespaces.length,
+ cleaned = jQuery.map( namespaces.slice(0).sort(), fcleanup ),
+ namespace = new RegExp("(^|\\.)" + cleaned.join("\\.(?:.*\\.)?") + "(\\.|$)"),
+ special = this.special[ type ] || {};
+
+ if ( events[ type ] ) {
+ // remove the given handler for the given type
+ if ( handler ) {
+ fn = events[ type ][ handler.guid ];
+ delete events[ type ][ handler.guid ];
+
+ // remove all handlers for the given type
+ } else {
+ for ( var handle in events[ type ] ) {
+ // Handle the removal of namespaced events
+ if ( all || namespace.test( events[ type ][ handle ].type ) ) {
+ delete events[ type ][ handle ];
+ }
+ }
+ }
+
+ if ( special.remove ) {
+ special.remove.call( elem, namespaces, fn);
+ }
+
+ // remove generic event handler if no more handlers exist
+ for ( ret in events[ type ] ) {
+ break;
+ }
+ if ( !ret ) {
+ if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
+ if ( elem.removeEventListener ) {
+ elem.removeEventListener( type, jQuery.data( elem, "handle" ), false );
+ } else if ( elem.detachEvent ) {
+ elem.detachEvent( "on" + type, jQuery.data( elem, "handle" ) );
+ }
+ }
+ ret = null;
+ delete events[ type ];
+ }
+ }
+ }
+ }
+
+ // Remove the expando if it's no longer used
+ for ( ret in events ) {
+ break;
+ }
+ if ( !ret ) {
+ var handle = jQuery.data( elem, "handle" );
+ if ( handle ) {
+ handle.elem = null;
+ }
+ jQuery.removeData( elem, "events" );
+ jQuery.removeData( elem, "handle" );
+ }
+ }
+ },
+
+ // bubbling is internal
+ trigger: function( event, data, elem /*, bubbling */ ) {
+ // Event object or event type
+ var type = event.type || event,
+ bubbling = arguments[3];
+
+ if ( !bubbling ) {
+ event = typeof event === "object" ?
+ // jQuery.Event object
+ event[expando] ? event :
+ // Object literal
+ jQuery.extend( jQuery.Event(type), event ) :
+ // Just the event type (string)
+ jQuery.Event(type);
+
+ if ( type.indexOf("!") >= 0 ) {
+ event.type = type = type.slice(0, -1);
+ event.exclusive = true;
+ }
+
+ // Handle a global trigger
+ if ( !elem ) {
+ // Don't bubble custom events when global (to avoid too much overhead)
+ event.stopPropagation();
+
+ // Only trigger if we've ever bound an event for it
+ if ( this.global[ type ] ) {
+ jQuery.each( jQuery.cache, function() {
+ if ( this.events && this.events[type] ) {
+ jQuery.event.trigger( event, data, this.handle.elem );
+ }
+ });
+ }
+ }
+
+ // Handle triggering a single element
+
+ // don't do events on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ // Clean up in case it is reused
+ event.result = undefined;
+ event.target = elem;
+
+ // Clone the incoming data, if any
+ data = jQuery.makeArray( data );
+ data.unshift( event );
+ }
+
+ event.currentTarget = elem;
+
+ // Trigger the event, it is assumed that "handle" is a function
+ var handle = jQuery.data( elem, "handle" );
+ if ( handle ) {
+ handle.apply( elem, data );
+ }
+
+ var nativeFn, nativeHandler;
+ try {
+ if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
+ nativeFn = elem[ type ];
+ nativeHandler = elem[ "on" + type ];
+ }
+ // prevent IE from throwing an error for some elements with some event types, see #3533
+ } catch (e) {}
+
+ var isClick = jQuery.nodeName(elem, "a") && type === "click";
+
+ // Trigger the native events (except for clicks on links)
+ if ( !bubbling && nativeFn && !event.isDefaultPrevented() && !isClick ) {
+ this.triggered = true;
+ try {
+ elem[ type ]();
+ // prevent IE from throwing an error for some hidden elements
+ } catch (e) {}
+
+ // Handle triggering native .onfoo handlers
+ } else if ( nativeHandler && elem[ "on" + type ].apply( elem, data ) === false ) {
+ event.result = false;
+ }
+
+ this.triggered = false;
+
+ if ( !event.isPropagationStopped() ) {
+ var parent = elem.parentNode || elem.ownerDocument;
+ if ( parent ) {
+ jQuery.event.trigger( event, data, parent, true );
+ }
+ }
+ },
+
+ handle: function( event ) {
+ // returned undefined or false
+ var all, handlers;
+
+ event = arguments[0] = jQuery.event.fix( event || window.event );
+ event.currentTarget = this;
+
+ // Namespaced event handlers
+ var namespaces = event.type.split(".");
+ event.type = namespaces.shift();
+
+ // Cache this now, all = true means, any handler
+ all = !namespaces.length && !event.exclusive;
+
+ var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)");
+
+ handlers = ( jQuery.data(this, "events") || {} )[ event.type ];
+
+ for ( var j in handlers ) {
+ var handler = handlers[ j ];
+
+ // Filter the functions by class
+ if ( all || namespace.test(handler.type) ) {
+ // Pass in a reference to the handler function itself
+ // So that we can later remove it
+ event.handler = handler;
+ event.data = handler.data;
+
+ var ret = handler.apply( this, arguments );
+
+ if ( ret !== undefined ) {
+ event.result = ret;
+ if ( ret === false ) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }
+
+ if ( event.isImmediatePropagationStopped() ) {
+ break;
+ }
+
+ }
+ }
+
+ return event.result;
+ },
+
+ props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
+
+ fix: function( event ) {
+ if ( event[ expando ] ) {
+ return event;
+ }
+
+ // store a copy of the original event object
+ // and "clone" to set read-only properties
+ var originalEvent = event;
+ event = jQuery.Event( originalEvent );
+
+ for ( var i = this.props.length, prop; i; ) {
+ prop = this.props[ --i ];
+ event[ prop ] = originalEvent[ prop ];
+ }
+
+ // Fix target property, if necessary
+ if ( !event.target ) {
+ event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
+ }
+
+ // check if target is a textnode (safari)
+ if ( event.target.nodeType === 3 ) {
+ event.target = event.target.parentNode;
+ }
+
+ // Add relatedTarget, if necessary
+ if ( !event.relatedTarget && event.fromElement ) {
+ event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
+ }
+
+ // Calculate pageX/Y if missing and clientX/Y available
+ if ( event.pageX == null && event.clientX != null ) {
+ var doc = document.documentElement, body = document.body;
+ event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
+ event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
+ }
+
+ // Add which for key events
+ if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) {
+ event.which = event.charCode || event.keyCode;
+ }
+
+ // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
+ if ( !event.metaKey && event.ctrlKey ) {
+ event.metaKey = event.ctrlKey;
+ }
+
+ // Add which for click: 1 === left; 2 === middle; 3 === right
+ // Note: button is not normalized, so don't use it
+ if ( !event.which && event.button !== undefined ) {
+ event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
+ }
+
+ return event;
+ },
+
+ // Deprecated, use jQuery.guid instead
+ guid: 1E8,
+
+ // Deprecated, use jQuery.proxy instead
+ proxy: jQuery.proxy,
+
+ special: {
+ ready: {
+ // Make sure the ready event is setup
+ setup: jQuery.bindReady,
+ teardown: jQuery.noop
+ },
+
+ live: {
+ add: function( proxy, data, namespaces, live ) {
+ jQuery.extend( proxy, data || {} );
+
+ proxy.guid += data.selector + data.live;
+ jQuery.event.add( this, data.live, liveHandler, data );
+
+ },
+
+ remove: function( namespaces ) {
+ if ( namespaces.length ) {
+ var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)");
+
+ jQuery.each( (jQuery.data(this, "events").live || {}), function() {
+ if ( name.test(this.type) ) {
+ remove++;
+ }
+ });
+
+ if ( remove < 1 ) {
+ jQuery.event.remove( this, namespaces[0], liveHandler );
+ }
+ }
+ },
+ special: {}
+ },
+ beforeunload: {
+ setup: function( data, namespaces, fn ) {
+ // We only want to do this special case on windows
+ if ( this.setInterval ) {
+ this.onbeforeunload = fn;
+ }
+
+ return false;
+ },
+ teardown: function( namespaces, fn ) {
+ if ( this.onbeforeunload === fn ) {
+ this.onbeforeunload = null;
+ }
+ }
+ }
+ }
+};
+
+jQuery.Event = function( src ) {
+ // Allow instantiation without the 'new' keyword
+ if ( !this.preventDefault ) {
+ return new jQuery.Event( src );
+ }
+
+ // Event object
+ if ( src && src.type ) {
+ this.originalEvent = src;
+ this.type = src.type;
+ // Event type
+ } else {
+ this.type = src;
+ }
+
+ // timeStamp is buggy for some events on Firefox(#3843)
+ // So we won't rely on the native value
+ this.timeStamp = now();
+
+ // Mark it as fixed
+ this[ expando ] = true;
+};
+
+function returnFalse() {
+ return false;
+}
+function returnTrue() {
+ return true;
+}
+
+// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
+// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
+jQuery.Event.prototype = {
+ preventDefault: function() {
+ this.isDefaultPrevented = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+
+ // if preventDefault exists run it on the original event
+ if ( e.preventDefault ) {
+ e.preventDefault();
+ }
+ // otherwise set the returnValue property of the original event to false (IE)
+ e.returnValue = false;
+ },
+ stopPropagation: function() {
+ this.isPropagationStopped = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+ // if stopPropagation exists run it on the original event
+ if ( e.stopPropagation ) {
+ e.stopPropagation();
+ }
+ // otherwise set the cancelBubble property of the original event to true (IE)
+ e.cancelBubble = true;
+ },
+ stopImmediatePropagation: function() {
+ this.isImmediatePropagationStopped = returnTrue;
+ this.stopPropagation();
+ },
+ isDefaultPrevented: returnFalse,
+ isPropagationStopped: returnFalse,
+ isImmediatePropagationStopped: returnFalse
+};
+
+// Checks if an event happened on an element within another element
+// Used in jQuery.event.special.mouseenter and mouseleave handlers
+var withinElement = function( event ) {
+ // Check if mouse(over|out) are still within the same parent element
+ var parent = event.relatedTarget;
+
+ // Traverse up the tree
+ while ( parent && parent !== this ) {
+ // Firefox sometimes assigns relatedTarget a XUL element
+ // which we cannot access the parentNode property of
+ try {
+ parent = parent.parentNode;
+
+ // assuming we've left the element since we most likely mousedover a xul element
+ } catch(e) {
+ break;
+ }
+ }
+
+ if ( parent !== this ) {
+ // set the correct event type
+ event.type = event.data;
+
+ // handle event if we actually just moused on to a non sub-element
+ jQuery.event.handle.apply( this, arguments );
+ }
+
+},
+
+// In case of event delegation, we only need to rename the event.type,
+// liveHandler will take care of the rest.
+delegate = function( event ) {
+ event.type = event.data;
+ jQuery.event.handle.apply( this, arguments );
+};
+
+// Create mouseenter and mouseleave events
+jQuery.each({
+ mouseenter: "mouseover",
+ mouseleave: "mouseout"
+}, function( orig, fix ) {
+ jQuery.event.special[ orig ] = {
+ setup: function( data ) {
+ jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
+ },
+ teardown: function( data ) {
+ jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
+ }
+ };
+});
+
+// submit delegation
+if ( !jQuery.support.submitBubbles ) {
+
+jQuery.event.special.submit = {
+ setup: function( data, namespaces, fn ) {
+ if ( this.nodeName.toLowerCase() !== "form" ) {
+ jQuery.event.add(this, "click.specialSubmit." + fn.guid, function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
+ return trigger( "submit", this, arguments );
+ }
+ });
+
+ jQuery.event.add(this, "keypress.specialSubmit." + fn.guid, function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
+ return trigger( "submit", this, arguments );
+ }
+ });
+
+ } else {
+ return false;
+ }
+ },
+
+ remove: function( namespaces, fn ) {
+ jQuery.event.remove( this, "click.specialSubmit" + (fn ? "."+fn.guid : "") );
+ jQuery.event.remove( this, "keypress.specialSubmit" + (fn ? "."+fn.guid : "") );
+ }
+};
+
+}
+
+// change delegation, happens here so we have bind.
+if ( !jQuery.support.changeBubbles ) {
+
+var formElems = /textarea|input|select/i;
+
+function getVal( elem ) {
+ var type = elem.type, val = elem.value;
+
+ if ( type === "radio" || type === "checkbox" ) {
+ val = elem.checked;
+
+ } else if ( type === "select-multiple" ) {
+ val = elem.selectedIndex > -1 ?
+ jQuery.map( elem.options, function( elem ) {
+ return elem.selected;
+ }).join("-") :
+ "";
+
+ } else if ( elem.nodeName.toLowerCase() === "select" ) {
+ val = elem.selectedIndex;
+ }
+
+ return val;
+}
+
+function testChange( e ) {
+ var elem = e.target, data, val;
+
+ if ( !formElems.test( elem.nodeName ) || elem.readOnly ) {
+ return;
+ }
+
+ data = jQuery.data( elem, "_change_data" );
+ val = getVal(elem);
+
+ if ( val === data ) {
+ return;
+ }
+
+ // the current data will be also retrieved by beforeactivate
+ if ( e.type !== "focusout" || elem.type !== "radio" ) {
+ jQuery.data( elem, "_change_data", val );
+ }
+
+ if ( elem.type !== "select" && (data != null || val) ) {
+ e.type = "change";
+ return jQuery.event.trigger( e, arguments[1], this );
+ }
+}
+
+jQuery.event.special.change = {
+ filters: {
+ focusout: testChange,
+
+ click: function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
+ return testChange.call( this, e );
+ }
+ },
+
+ // Change has to be called before submit
+ // Keydown will be called before keypress, which is used in submit-event delegation
+ keydown: function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
+ (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
+ type === "select-multiple" ) {
+ return testChange.call( this, e );
+ }
+ },
+
+ // Beforeactivate happens also before the previous element is blurred
+ // with this event you can't trigger a change event, but you can store
+ // information/focus[in] is not needed anymore
+ beforeactivate: function( e ) {
+ var elem = e.target;
+
+ if ( elem.nodeName.toLowerCase() === "input" && elem.type === "radio" ) {
+ jQuery.data( elem, "_change_data", getVal(elem) );
+ }
+ }
+ },
+ setup: function( data, namespaces, fn ) {
+ for ( var type in changeFilters ) {
+ jQuery.event.add( this, type + ".specialChange." + fn.guid, changeFilters[type] );
+ }
+
+ return formElems.test( this.nodeName );
+ },
+ remove: function( namespaces, fn ) {
+ for ( var type in changeFilters ) {
+ jQuery.event.remove( this, type + ".specialChange" + (fn ? "."+fn.guid : ""), changeFilters[type] );
+ }
+
+ return formElems.test( this.nodeName );
+ }
+};
+
+var changeFilters = jQuery.event.special.change.filters;
+
+}
+
+function trigger( type, elem, args ) {
+ args[0].type = type;
+ return jQuery.event.handle.apply( elem, args );
+}
+
+// Create "bubbling" focus and blur events
+if ( document.addEventListener ) {
+ jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
+ jQuery.event.special[ fix ] = {
+ setup: function() {
+ this.addEventListener( orig, handler, true );
+ },
+ teardown: function() {
+ this.removeEventListener( orig, handler, true );
+ }
+ };
+
+ function handler( e ) {
+ e = jQuery.event.fix( e );
+ e.type = fix;
+ return jQuery.event.handle.call( this, e );
+ }
+ });
+}
+
+jQuery.each(["bind", "one"], function( i, name ) {
+ jQuery.fn[ name ] = function( type, data, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" ) {
+ for ( var key in type ) {
+ this[ name ](key, data, type[key], fn);
+ }
+ return this;
+ }
+
+ if ( jQuery.isFunction( data ) ) {
+ thisObject = fn;
+ fn = data;
+ data = undefined;
+ }
+
+ var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
+ jQuery( this ).unbind( event, handler );
+ return fn.apply( this, arguments );
+ }) : fn;
+
+ return type === "unload" && name !== "one" ?
+ this.one( type, data, fn, thisObject ) :
+ this.each(function() {
+ jQuery.event.add( this, type, handler, data );
+ });
+ };
+});
+
+jQuery.fn.extend({
+ unbind: function( type, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" && !type.preventDefault ) {
+ for ( var key in type ) {
+ this.unbind(key, type[key]);
+ }
+ return this;
+ }
+
+ return this.each(function() {
+ jQuery.event.remove( this, type, fn );
+ });
+ },
+ trigger: function( type, data ) {
+ return this.each(function() {
+ jQuery.event.trigger( type, data, this );
+ });
+ },
+
+ triggerHandler: function( type, data ) {
+ if ( this[0] ) {
+ var event = jQuery.Event( type );
+ event.preventDefault();
+ event.stopPropagation();
+ jQuery.event.trigger( event, data, this[0] );
+ return event.result;
+ }
+ },
+
+ toggle: function( fn ) {
+ // Save reference to arguments for access in closure
+ var args = arguments, i = 1;
+
+ // link all the functions, so any of them can unbind this click handler
+ while ( i < args.length ) {
+ jQuery.proxy( fn, args[ i++ ] );
+ }
+
+ return this.click( jQuery.proxy( fn, function( event ) {
+ // Figure out which function to execute
+ var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
+ jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
+
+ // Make sure that clicks stop
+ event.preventDefault();
+
+ // and execute the function
+ return args[ lastToggle ].apply( this, arguments ) || false;
+ }));
+ },
+
+ hover: function( fnOver, fnOut ) {
+ return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
+ },
+
+ live: function( type, data, fn ) {
+ if ( jQuery.isFunction( data ) ) {
+ fn = data;
+ data = undefined;
+ }
+
+ jQuery( this.context ).bind( liveConvert( type, this.selector ), {
+ data: data, selector: this.selector, live: type
+ }, fn );
+
+ return this;
+ },
+
+ die: function( type, fn ) {
+ jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null );
+ return this;
+ }
+});
+
+function liveHandler( event ) {
+ var stop = true, elems = [], selectors = [], args = arguments,
+ related, match, fn, elem, j, i, data,
+ live = jQuery.extend({}, jQuery.data( this, "events" ).live);
+
+ for ( j in live ) {
+ fn = live[j];
+ if ( fn.live === event.type ||
+ fn.altLive && jQuery.inArray(event.type, fn.altLive) > -1 ) {
+
+ data = fn.data;
+ if ( !(data.beforeFilter && data.beforeFilter[event.type] &&
+ !data.beforeFilter[event.type](event)) ) {
+ selectors.push( fn.selector );
+ }
+ } else {
+ delete live[j];
+ }
+ }
+
+ match = jQuery( event.target ).closest( selectors, event.currentTarget );
+
+ for ( i = 0, l = match.length; i < l; i++ ) {
+ for ( j in live ) {
+ fn = live[j];
+ elem = match[i].elem;
+ related = null;
+
+ if ( match[i].selector === fn.selector ) {
+ // Those two events require additional checking
+ if ( fn.live === "mouseenter" || fn.live === "mouseleave" ) {
+ related = jQuery( event.relatedTarget ).closest( fn.selector )[0];
+ }
+
+ if ( !related || related !== elem ) {
+ elems.push({ elem: elem, fn: fn });
+ }
+ }
+ }
+ }
+
+ for ( i = 0, l = elems.length; i < l; i++ ) {
+ match = elems[i];
+ event.currentTarget = match.elem;
+ event.data = match.fn.data;
+ if ( match.fn.apply( match.elem, args ) === false ) {
+ stop = false;
+ break;
+ }
+ }
+
+ return stop;
+}
+
+function liveConvert( type, selector ) {
+ return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "&")].join(".");
+}
+
+jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
+ "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
+ "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
+
+ // Handle event binding
+ jQuery.fn[ name ] = function( fn ) {
+ return fn ? this.bind( name, fn ) : this.trigger( name );
+ };
+
+ if ( jQuery.attrFn ) {
+ jQuery.attrFn[ name ] = true;
+ }
+});
+
+// Prevent memory leaks in IE
+// Window isn't included so as not to unbind existing unload events
+// More info:
+// - http://isaacschlueter.com/2006/10/msie-memory-leaks/
+if ( window.attachEvent && !window.addEventListener ) {
+ window.attachEvent("onunload", function() {
+ for ( var id in jQuery.cache ) {
+ if ( jQuery.cache[ id ].handle ) {
+ // Try/Catch is to handle iframes being unloaded, see #4280
+ try {
+ jQuery.event.remove( jQuery.cache[ id ].handle.elem );
+ } catch(e) {}
+ }
+ }
+ });
+}
+/*!
+ * Sizzle CSS Selector Engine - v1.0
+ * Copyright 2009, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ * More information: http://sizzlejs.com/
+ */
+(function(){
+
+var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
+ done = 0,
+ toString = Object.prototype.toString,
+ hasDuplicate = false,
+ baseHasDuplicate = true;
+
+// Here we check if the JavaScript engine is using some sort of
+// optimization where it does not always call our comparision
+// function. If that is the case, discard the hasDuplicate value.
+// Thus far that includes Google Chrome.
+[0, 0].sort(function(){
+ baseHasDuplicate = false;
+ return 0;
+});
+
+var Sizzle = function(selector, context, results, seed) {
+ results = results || [];
+ var origContext = context = context || document;
+
+ if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
+ return [];
+ }
+
+ if ( !selector || typeof selector !== "string" ) {
+ return results;
+ }
+
+ var parts = [], m, set, checkSet, extra, prune = true, contextXML = isXML(context),
+ soFar = selector;
+
+ // Reset the position of the chunker regexp (start from head)
+ while ( (chunker.exec(""), m = chunker.exec(soFar)) !== null ) {
+ soFar = m[3];
+
+ parts.push( m[1] );
+
+ if ( m[2] ) {
+ extra = m[3];
+ break;
+ }
+ }
+
+ if ( parts.length > 1 && origPOS.exec( selector ) ) {
+ if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
+ set = posProcess( parts[0] + parts[1], context );
+ } else {
+ set = Expr.relative[ parts[0] ] ?
+ [ context ] :
+ Sizzle( parts.shift(), context );
+
+ while ( parts.length ) {
+ selector = parts.shift();
+
+ if ( Expr.relative[ selector ] ) {
+ selector += parts.shift();
+ }
+
+ set = posProcess( selector, set );
+ }
+ }
+ } else {
+ // Take a shortcut and set the context if the root selector is an ID
+ // (but not if it'll be faster if the inner selector is an ID)
+ if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
+ Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
+ var ret = Sizzle.find( parts.shift(), context, contextXML );
+ context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];
+ }
+
+ if ( context ) {
+ var ret = seed ?
+ { expr: parts.pop(), set: makeArray(seed) } :
+ Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
+ set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set;
+
+ if ( parts.length > 0 ) {
+ checkSet = makeArray(set);
+ } else {
+ prune = false;
+ }
+
+ while ( parts.length ) {
+ var cur = parts.pop(), pop = cur;
+
+ if ( !Expr.relative[ cur ] ) {
+ cur = "";
+ } else {
+ pop = parts.pop();
+ }
+
+ if ( pop == null ) {
+ pop = context;
+ }
+
+ Expr.relative[ cur ]( checkSet, pop, contextXML );
+ }
+ } else {
+ checkSet = parts = [];
+ }
+ }
+
+ if ( !checkSet ) {
+ checkSet = set;
+ }
+
+ if ( !checkSet ) {
+ throw "Syntax error, unrecognized expression: " + (cur || selector);
+ }
+
+ if ( toString.call(checkSet) === "[object Array]" ) {
+ if ( !prune ) {
+ results.push.apply( results, checkSet );
+ } else if ( context && context.nodeType === 1 ) {
+ for ( var i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {
+ results.push( set[i] );
+ }
+ }
+ } else {
+ for ( var i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
+ results.push( set[i] );
+ }
+ }
+ }
+ } else {
+ makeArray( checkSet, results );
+ }
+
+ if ( extra ) {
+ Sizzle( extra, origContext, results, seed );
+ Sizzle.uniqueSort( results );
+ }
+
+ return results;
+};
+
+Sizzle.uniqueSort = function(results){
+ if ( sortOrder ) {
+ hasDuplicate = baseHasDuplicate;
+ results.sort(sortOrder);
+
+ if ( hasDuplicate ) {
+ for ( var i = 1; i < results.length; i++ ) {
+ if ( results[i] === results[i-1] ) {
+ results.splice(i--, 1);
+ }
+ }
+ }
+ }
+
+ return results;
+};
+
+Sizzle.matches = function(expr, set){
+ return Sizzle(expr, null, null, set);
+};
+
+Sizzle.find = function(expr, context, isXML){
+ var set, match;
+
+ if ( !expr ) {
+ return [];
+ }
+
+ for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
+ var type = Expr.order[i], match;
+
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
+ var left = match[1];
+ match.splice(1,1);
+
+ if ( left.substr( left.length - 1 ) !== "\\" ) {
+ match[1] = (match[1] || "").replace(/\\/g, "");
+ set = Expr.find[ type ]( match, context, isXML );
+ if ( set != null ) {
+ expr = expr.replace( Expr.match[ type ], "" );
+ break;
+ }
+ }
+ }
+ }
+
+ if ( !set ) {
+ set = context.getElementsByTagName("*");
+ }
+
+ return {set: set, expr: expr};
+};
+
+Sizzle.filter = function(expr, set, inplace, not){
+ var old = expr, result = [], curLoop = set, match, anyFound,
+ isXMLFilter = set && set[0] && isXML(set[0]);
+
+ while ( expr && set.length ) {
+ for ( var type in Expr.filter ) {
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
+ var filter = Expr.filter[ type ], found, item, left = match[1];
+ anyFound = false;
+
+ match.splice(1,1);
+
+ if ( left.substr( left.length - 1 ) === "\\" ) {
+ continue;
+ }
+
+ if ( curLoop === result ) {
+ result = [];
+ }
+
+ if ( Expr.preFilter[ type ] ) {
+ match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
+
+ if ( !match ) {
+ anyFound = found = true;
+ } else if ( match === true ) {
+ continue;
+ }
+ }
+
+ if ( match ) {
+ for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
+ if ( item ) {
+ found = filter( item, match, i, curLoop );
+ var pass = not ^ !!found;
+
+ if ( inplace && found != null ) {
+ if ( pass ) {
+ anyFound = true;
+ } else {
+ curLoop[i] = false;
+ }
+ } else if ( pass ) {
+ result.push( item );
+ anyFound = true;
+ }
+ }
+ }
+ }
+
+ if ( found !== undefined ) {
+ if ( !inplace ) {
+ curLoop = result;
+ }
+
+ expr = expr.replace( Expr.match[ type ], "" );
+
+ if ( !anyFound ) {
+ return [];
+ }
+
+ break;
+ }
+ }
+ }
+
+ // Improper expression
+ if ( expr === old ) {
+ if ( anyFound == null ) {
+ throw "Syntax error, unrecognized expression: " + expr;
+ } else {
+ break;
+ }
+ }
+
+ old = expr;
+ }
+
+ return curLoop;
+};
+
+var Expr = Sizzle.selectors = {
+ order: [ "ID", "NAME", "TAG" ],
+ match: {
+ ID: /#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
+ CLASS: /\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
+ NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,
+ ATTR: /\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
+ TAG: /^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,
+ CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
+ POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
+ PSEUDO: /:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
+ },
+ leftMatch: {},
+ attrMap: {
+ "class": "className",
+ "for": "htmlFor"
+ },
+ attrHandle: {
+ href: function(elem){
+ return elem.getAttribute("href");
+ }
+ },
+ relative: {
+ "+": function(checkSet, part){
+ var isPartStr = typeof part === "string",
+ isTag = isPartStr && !/\W/.test(part),
+ isPartStrNotTag = isPartStr && !isTag;
+
+ if ( isTag ) {
+ part = part.toLowerCase();
+ }
+
+ for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
+ if ( (elem = checkSet[i]) ) {
+ while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
+
+ checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
+ elem || false :
+ elem === part;
+ }
+ }
+
+ if ( isPartStrNotTag ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ },
+ ">": function(checkSet, part){
+ var isPartStr = typeof part === "string";
+
+ if ( isPartStr && !/\W/.test(part) ) {
+ part = part.toLowerCase();
+
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ var parent = elem.parentNode;
+ checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
+ }
+ }
+ } else {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ checkSet[i] = isPartStr ?
+ elem.parentNode :
+ elem.parentNode === part;
+ }
+ }
+
+ if ( isPartStr ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ }
+ },
+ "": function(checkSet, part, isXML){
+ var doneName = done++, checkFn = dirCheck;
+
+ if ( typeof part === "string" && !/\W/.test(part) ) {
+ var nodeCheck = part = part.toLowerCase();
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
+ },
+ "~": function(checkSet, part, isXML){
+ var doneName = done++, checkFn = dirCheck;
+
+ if ( typeof part === "string" && !/\W/.test(part) ) {
+ var nodeCheck = part = part.toLowerCase();
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);
+ }
+ },
+ find: {
+ ID: function(match, context, isXML){
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+ return m ? [m] : [];
+ }
+ },
+ NAME: function(match, context){
+ if ( typeof context.getElementsByName !== "undefined" ) {
+ var ret = [], results = context.getElementsByName(match[1]);
+
+ for ( var i = 0, l = results.length; i < l; i++ ) {
+ if ( results[i].getAttribute("name") === match[1] ) {
+ ret.push( results[i] );
+ }
+ }
+
+ return ret.length === 0 ? null : ret;
+ }
+ },
+ TAG: function(match, context){
+ return context.getElementsByTagName(match[1]);
+ }
+ },
+ preFilter: {
+ CLASS: function(match, curLoop, inplace, result, not, isXML){
+ match = " " + match[1].replace(/\\/g, "") + " ";
+
+ if ( isXML ) {
+ return match;
+ }
+
+ for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
+ if ( elem ) {
+ if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) {
+ if ( !inplace ) {
+ result.push( elem );
+ }
+ } else if ( inplace ) {
+ curLoop[i] = false;
+ }
+ }
+ }
+
+ return false;
+ },
+ ID: function(match){
+ return match[1].replace(/\\/g, "");
+ },
+ TAG: function(match, curLoop){
+ return match[1].toLowerCase();
+ },
+ CHILD: function(match){
+ if ( match[1] === "nth" ) {
+ // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
+ var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
+ match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
+ !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
+
+ // calculate the numbers (first)n+(last) including if they are negative
+ match[2] = (test[1] + (test[2] || 1)) - 0;
+ match[3] = test[3] - 0;
+ }
+
+ // TODO: Move to normal caching system
+ match[0] = done++;
+
+ return match;
+ },
+ ATTR: function(match, curLoop, inplace, result, not, isXML){
+ var name = match[1].replace(/\\/g, "");
+
+ if ( !isXML && Expr.attrMap[name] ) {
+ match[1] = Expr.attrMap[name];
+ }
+
+ if ( match[2] === "~=" ) {
+ match[4] = " " + match[4] + " ";
+ }
+
+ return match;
+ },
+ PSEUDO: function(match, curLoop, inplace, result, not){
+ if ( match[1] === "not" ) {
+ // If we're dealing with a complex expression, or a simple one
+ if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
+ match[3] = Sizzle(match[3], null, null, curLoop);
+ } else {
+ var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
+ if ( !inplace ) {
+ result.push.apply( result, ret );
+ }
+ return false;
+ }
+ } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
+ return true;
+ }
+
+ return match;
+ },
+ POS: function(match){
+ match.unshift( true );
+ return match;
+ }
+ },
+ filters: {
+ enabled: function(elem){
+ return elem.disabled === false && elem.type !== "hidden";
+ },
+ disabled: function(elem){
+ return elem.disabled === true;
+ },
+ checked: function(elem){
+ return elem.checked === true;
+ },
+ selected: function(elem){
+ // Accessing this property makes selected-by-default
+ // options in Safari work properly
+ elem.parentNode.selectedIndex;
+ return elem.selected === true;
+ },
+ parent: function(elem){
+ return !!elem.firstChild;
+ },
+ empty: function(elem){
+ return !elem.firstChild;
+ },
+ has: function(elem, i, match){
+ return !!Sizzle( match[3], elem ).length;
+ },
+ header: function(elem){
+ return /h\d/i.test( elem.nodeName );
+ },
+ text: function(elem){
+ return "text" === elem.type;
+ },
+ radio: function(elem){
+ return "radio" === elem.type;
+ },
+ checkbox: function(elem){
+ return "checkbox" === elem.type;
+ },
+ file: function(elem){
+ return "file" === elem.type;
+ },
+ password: function(elem){
+ return "password" === elem.type;
+ },
+ submit: function(elem){
+ return "submit" === elem.type;
+ },
+ image: function(elem){
+ return "image" === elem.type;
+ },
+ reset: function(elem){
+ return "reset" === elem.type;
+ },
+ button: function(elem){
+ return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
+ },
+ input: function(elem){
+ return /input|select|textarea|button/i.test(elem.nodeName);
+ }
+ },
+ setFilters: {
+ first: function(elem, i){
+ return i === 0;
+ },
+ last: function(elem, i, match, array){
+ return i === array.length - 1;
+ },
+ even: function(elem, i){
+ return i % 2 === 0;
+ },
+ odd: function(elem, i){
+ return i % 2 === 1;
+ },
+ lt: function(elem, i, match){
+ return i < match[3] - 0;
+ },
+ gt: function(elem, i, match){
+ return i > match[3] - 0;
+ },
+ nth: function(elem, i, match){
+ return match[3] - 0 === i;
+ },
+ eq: function(elem, i, match){
+ return match[3] - 0 === i;
+ }
+ },
+ filter: {
+ PSEUDO: function(elem, match, i, array){
+ var name = match[1], filter = Expr.filters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+ } else if ( name === "contains" ) {
+ return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
+ } else if ( name === "not" ) {
+ var not = match[3];
+
+ for ( var i = 0, l = not.length; i < l; i++ ) {
+ if ( not[i] === elem ) {
+ return false;
+ }
+ }
+
+ return true;
+ } else {
+ throw "Syntax error, unrecognized expression: " + name;
+ }
+ },
+ CHILD: function(elem, match){
+ var type = match[1], node = elem;
+ switch (type) {
+ case 'only':
+ case 'first':
+ while ( (node = node.previousSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+ if ( type === "first" ) {
+ return true;
+ }
+ node = elem;
+ case 'last':
+ while ( (node = node.nextSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+ return true;
+ case 'nth':
+ var first = match[2], last = match[3];
+
+ if ( first === 1 && last === 0 ) {
+ return true;
+ }
+
+ var doneName = match[0],
+ parent = elem.parentNode;
+
+ if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
+ var count = 0;
+ for ( node = parent.firstChild; node; node = node.nextSibling ) {
+ if ( node.nodeType === 1 ) {
+ node.nodeIndex = ++count;
+ }
+ }
+ parent.sizcache = doneName;
+ }
+
+ var diff = elem.nodeIndex - last;
+ if ( first === 0 ) {
+ return diff === 0;
+ } else {
+ return ( diff % first === 0 && diff / first >= 0 );
+ }
+ }
+ },
+ ID: function(elem, match){
+ return elem.nodeType === 1 && elem.getAttribute("id") === match;
+ },
+ TAG: function(elem, match){
+ return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
+ },
+ CLASS: function(elem, match){
+ return (" " + (elem.className || elem.getAttribute("class")) + " ")
+ .indexOf( match ) > -1;
+ },
+ ATTR: function(elem, match){
+ var name = match[1],
+ result = Expr.attrHandle[ name ] ?
+ Expr.attrHandle[ name ]( elem ) :
+ elem[ name ] != null ?
+ elem[ name ] :
+ elem.getAttribute( name ),
+ value = result + "",
+ type = match[2],
+ check = match[4];
+
+ return result == null ?
+ type === "!=" :
+ type === "=" ?
+ value === check :
+ type === "*=" ?
+ value.indexOf(check) >= 0 :
+ type === "~=" ?
+ (" " + value + " ").indexOf(check) >= 0 :
+ !check ?
+ value && result !== false :
+ type === "!=" ?
+ value !== check :
+ type === "^=" ?
+ value.indexOf(check) === 0 :
+ type === "$=" ?
+ value.substr(value.length - check.length) === check :
+ type === "|=" ?
+ value === check || value.substr(0, check.length + 1) === check + "-" :
+ false;
+ },
+ POS: function(elem, match, i, array){
+ var name = match[2], filter = Expr.setFilters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+ }
+ }
+ }
+};
+
+var origPOS = Expr.match.POS;
+
+for ( var type in Expr.match ) {
+ Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source );
+ Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, function(all, num){
+ return "\\" + (num - 0 + 1);
+ }));
+}
+
+var makeArray = function(array, results) {
+ array = Array.prototype.slice.call( array, 0 );
+
+ if ( results ) {
+ results.push.apply( results, array );
+ return results;
+ }
+
+ return array;
+};
+
+// Perform a simple check to determine if the browser is capable of
+// converting a NodeList to an array using builtin methods.
+try {
+ Array.prototype.slice.call( document.documentElement.childNodes, 0 );
+
+// Provide a fallback method if it does not work
+} catch(e){
+ makeArray = function(array, results) {
+ var ret = results || [];
+
+ if ( toString.call(array) === "[object Array]" ) {
+ Array.prototype.push.apply( ret, array );
+ } else {
+ if ( typeof array.length === "number" ) {
+ for ( var i = 0, l = array.length; i < l; i++ ) {
+ ret.push( array[i] );
+ }
+ } else {
+ for ( var i = 0; array[i]; i++ ) {
+ ret.push( array[i] );
+ }
+ }
+ }
+
+ return ret;
+ };
+}
+
+var sortOrder;
+
+if ( document.documentElement.compareDocumentPosition ) {
+ sortOrder = function( a, b ) {
+ if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.compareDocumentPosition ? -1 : 1;
+ }
+
+ var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+} else if ( "sourceIndex" in document.documentElement ) {
+ sortOrder = function( a, b ) {
+ if ( !a.sourceIndex || !b.sourceIndex ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.sourceIndex ? -1 : 1;
+ }
+
+ var ret = a.sourceIndex - b.sourceIndex;
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+} else if ( document.createRange ) {
+ sortOrder = function( a, b ) {
+ if ( !a.ownerDocument || !b.ownerDocument ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.ownerDocument ? -1 : 1;
+ }
+
+ var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();
+ aRange.setStart(a, 0);
+ aRange.setEnd(a, 0);
+ bRange.setStart(b, 0);
+ bRange.setEnd(b, 0);
+ var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange);
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+}
+
+// Utility function for retreiving the text value of an array of DOM nodes
+function getText( elems ) {
+ var ret = "", elem;
+
+ for ( var i = 0; elems[i]; i++ ) {
+ elem = elems[i];
+
+ // Get the text from text nodes and CDATA nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
+ ret += elem.nodeValue;
+
+ // Traverse everything else, except comment nodes
+ } else if ( elem.nodeType !== 8 ) {
+ ret += getText( elem.childNodes );
+ }
+ }
+
+ return ret;
+}
+
+// Check to see if the browser returns elements by name when
+// querying by getElementById (and provide a workaround)
+(function(){
+ // We're going to inject a fake input element with a specified name
+ var form = document.createElement("div"),
+ id = "script" + (new Date).getTime();
+ form.innerHTML = "<a name='" + id + "'/>";
+
+ // Inject it into the root element, check its status, and remove it quickly
+ var root = document.documentElement;
+ root.insertBefore( form, root.firstChild );
+
+ // The workaround has to do additional checks after a getElementById
+ // Which slows things down for other browsers (hence the branching)
+ if ( document.getElementById( id ) ) {
+ Expr.find.ID = function(match, context, isXML){
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+ return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
+ }
+ };
+
+ Expr.filter.ID = function(elem, match){
+ var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
+ return elem.nodeType === 1 && node && node.nodeValue === match;
+ };
+ }
+
+ root.removeChild( form );
+ root = form = null; // release memory in IE
+})();
+
+(function(){
+ // Check to see if the browser returns only elements
+ // when doing getElementsByTagName("*")
+
+ // Create a fake element
+ var div = document.createElement("div");
+ div.appendChild( document.createComment("") );
+
+ // Make sure no comments are found
+ if ( div.getElementsByTagName("*").length > 0 ) {
+ Expr.find.TAG = function(match, context){
+ var results = context.getElementsByTagName(match[1]);
+
+ // Filter out possible comments
+ if ( match[1] === "*" ) {
+ var tmp = [];
+
+ for ( var i = 0; results[i]; i++ ) {
+ if ( results[i].nodeType === 1 ) {
+ tmp.push( results[i] );
+ }
+ }
+
+ results = tmp;
+ }
+
+ return results;
+ };
+ }
+
+ // Check to see if an attribute returns normalized href attributes
+ div.innerHTML = "<a href='#'></a>";
+ if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
+ div.firstChild.getAttribute("href") !== "#" ) {
+ Expr.attrHandle.href = function(elem){
+ return elem.getAttribute("href", 2);
+ };
+ }
+
+ div = null; // release memory in IE
+})();
+
+if ( document.querySelectorAll ) {
+ (function(){
+ var oldSizzle = Sizzle, div = document.createElement("div");
+ div.innerHTML = "<p class='TEST'></p>";
+
+ // Safari can't handle uppercase or unicode characters when
+ // in quirks mode.
+ if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
+ return;
+ }
+
+ Sizzle = function(query, context, extra, seed){
+ context = context || document;
+
+ // Only use querySelectorAll on non-XML documents
+ // (ID selectors don't work in non-HTML documents)
+ if ( !seed && context.nodeType === 9 && !isXML(context) ) {
+ try {
+ return makeArray( context.querySelectorAll(query), extra );
+ } catch(e){}
+ }
+
+ return oldSizzle(query, context, extra, seed);
+ };
+
+ for ( var prop in oldSizzle ) {
+ Sizzle[ prop ] = oldSizzle[ prop ];
+ }
+
+ div = null; // release memory in IE
+ })();
+}
+
+(function(){
+ var div = document.createElement("div");
+
+ div.innerHTML = "<div class='test e'></div><div class='test'></div>";
+
+ // Opera can't find a second classname (in 9.6)
+ // Also, make sure that getElementsByClassName actually exists
+ if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
+ return;
+ }
+
+ // Safari caches class attributes, doesn't catch changes (in 3.2)
+ div.lastChild.className = "e";
+
+ if ( div.getElementsByClassName("e").length === 1 ) {
+ return;
+ }
+
+ Expr.order.splice(1, 0, "CLASS");
+ Expr.find.CLASS = function(match, context, isXML) {
+ if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
+ return context.getElementsByClassName(match[1]);
+ }
+ };
+
+ div = null; // release memory in IE
+})();
+
+function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ elem = elem[dir];
+ var match = false;
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 && !isXML ){
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+
+ if ( elem.nodeName.toLowerCase() === cur ) {
+ match = elem;
+ break;
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ elem = elem[dir];
+ var match = false;
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 ) {
+ if ( !isXML ) {
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+ if ( typeof cur !== "string" ) {
+ if ( elem === cur ) {
+ match = true;
+ break;
+ }
+
+ } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
+ match = elem;
+ break;
+ }
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+var contains = document.compareDocumentPosition ? function(a, b){
+ return a.compareDocumentPosition(b) & 16;
+} : function(a, b){
+ return a !== b && (a.contains ? a.contains(b) : true);
+};
+
+var isXML = function(elem){
+ // documentElement is verified for cases where it doesn't yet exist
+ // (such as loading iframes in IE - #4833)
+ var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
+ return documentElement ? documentElement.nodeName !== "HTML" : false;
+};
+
+var posProcess = function(selector, context){
+ var tmpSet = [], later = "", match,
+ root = context.nodeType ? [context] : context;
+
+ // Position selectors must be done after the filter
+ // And so must :not(positional) so we move all PSEUDOs to the end
+ while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
+ later += match[0];
+ selector = selector.replace( Expr.match.PSEUDO, "" );
+ }
+
+ selector = Expr.relative[selector] ? selector + "*" : selector;
+
+ for ( var i = 0, l = root.length; i < l; i++ ) {
+ Sizzle( selector, root[i], tmpSet );
+ }
+
+ return Sizzle.filter( later, tmpSet );
+};
+
+// EXPOSE
+jQuery.find = Sizzle;
+jQuery.expr = Sizzle.selectors;
+jQuery.expr[":"] = jQuery.expr.filters;
+jQuery.unique = Sizzle.uniqueSort;
+jQuery.getText = getText;
+jQuery.isXMLDoc = isXML;
+jQuery.contains = contains;
+
+return;
+
+window.Sizzle = Sizzle;
+
+})();
+var runtil = /Until$/,
+ rparentsprev = /^(?:parents|prevUntil|prevAll)/,
+ // Note: This RegExp should be improved, or likely pulled from Sizzle
+ rmultiselector = /,/,
+ slice = Array.prototype.slice;
+
+// Implement the identical functionality for filter and not
+var winnow = function( elements, qualifier, keep ) {
+ if ( jQuery.isFunction( qualifier ) ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ return !!qualifier.call( elem, i, elem ) === keep;
+ });
+
+ } else if ( qualifier.nodeType ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ return (elem === qualifier) === keep;
+ });
+
+ } else if ( typeof qualifier === "string" ) {
+ var filtered = jQuery.grep(elements, function( elem ) {
+ return elem.nodeType === 1;
+ });
+
+ if ( isSimple.test( qualifier ) ) {
+ return jQuery.filter(qualifier, filtered, !keep);
+ } else {
+ qualifier = jQuery.filter( qualifier, elements );
+ }
+ }
+
+ return jQuery.grep(elements, function( elem, i ) {
+ return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
+ });
+};
+
+jQuery.fn.extend({
+ find: function( selector ) {
+ var ret = this.pushStack( "", "find", selector ), length = 0;
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ length = ret.length;
+ jQuery.find( selector, this[i], ret );
+
+ if ( i > 0 ) {
+ // Make sure that the results are unique
+ for ( var n = length; n < ret.length; n++ ) {
+ for ( var r = 0; r < length; r++ ) {
+ if ( ret[r] === ret[n] ) {
+ ret.splice(n--, 1);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return ret;
+ },
+
+ has: function( target ) {
+ var targets = jQuery( target );
+ return this.filter(function() {
+ for ( var i = 0, l = targets.length; i < l; i++ ) {
+ if ( jQuery.contains( this, targets[i] ) ) {
+ return true;
+ }
+ }
+ });
+ },
+
+ not: function( selector ) {
+ return this.pushStack( winnow(this, selector, false), "not", selector);
+ },
+
+ filter: function( selector ) {
+ return this.pushStack( winnow(this, selector, true), "filter", selector );
+ },
+
+ is: function( selector ) {
+ return !!selector && jQuery.filter( selector, this ).length > 0;
+ },
+
+ closest: function( selectors, context ) {
+ if ( jQuery.isArray( selectors ) ) {
+ var ret = [], cur = this[0], match, matches = {}, selector;
+
+ if ( cur && selectors.length ) {
+ for ( var i = 0, l = selectors.length; i < l; i++ ) {
+ selector = selectors[i];
+
+ if ( !matches[selector] ) {
+ matches[selector] = jQuery.expr.match.POS.test( selector ) ?
+ jQuery( selector, context || this.context ) :
+ selector;
+ }
+ }
+
+ while ( cur && cur.ownerDocument && cur !== context ) {
+ for ( selector in matches ) {
+ match = matches[selector];
+
+ if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) {
+ ret.push({ selector: selector, elem: cur });
+ delete matches[selector];
+ }
+ }
+ cur = cur.parentNode;
+ }
+ }
+
+ return ret;
+ }
+
+ var pos = jQuery.expr.match.POS.test( selectors ) ?
+ jQuery( selectors, context || this.context ) : null;
+
+ return this.map(function( i, cur ) {
+ while ( cur && cur.ownerDocument && cur !== context ) {
+ if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selectors) ) {
+ return cur;
+ }
+ cur = cur.parentNode;
+ }
+ return null;
+ });
+ },
+
+ // Determine the position of an element within
+ // the matched set of elements
+ index: function( elem ) {
+ if ( !elem || typeof elem === "string" ) {
+ return jQuery.inArray( this[0],
+ // If it receives a string, the selector is used
+ // If it receives nothing, the siblings are used
+ elem ? jQuery( elem ) : this.parent().children() );
+ }
+ // Locate the position of the desired element
+ return jQuery.inArray(
+ // If it receives a jQuery object, the first element is used
+ elem.jquery ? elem[0] : elem, this );
+ },
+
+ add: function( selector, context ) {
+ var set = typeof selector === "string" ?
+ jQuery( selector, context || this.context ) :
+ jQuery.makeArray( selector ),
+ all = jQuery.merge( this.get(), set );
+
+ return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
+ all :
+ jQuery.unique( all ) );
+ },
+
+ andSelf: function() {
+ return this.add( this.prevObject );
+ }
+});
+
+// A painfully simple check to see if an element is disconnected
+// from a document (should be improved, where feasible).
+function isDisconnected( node ) {
+ return !node || !node.parentNode || node.parentNode.nodeType === 11;
+}
+
+jQuery.each({
+ parent: function( elem ) {
+ var parent = elem.parentNode;
+ return parent && parent.nodeType !== 11 ? parent : null;
+ },
+ parents: function( elem ) {
+ return jQuery.dir( elem, "parentNode" );
+ },
+ parentsUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "parentNode", until );
+ },
+ next: function( elem ) {
+ return jQuery.nth( elem, 2, "nextSibling" );
+ },
+ prev: function( elem ) {
+ return jQuery.nth( elem, 2, "previousSibling" );
+ },
+ nextAll: function( elem ) {
+ return jQuery.dir( elem, "nextSibling" );
+ },
+ prevAll: function( elem ) {
+ return jQuery.dir( elem, "previousSibling" );
+ },
+ nextUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "nextSibling", until );
+ },
+ prevUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "previousSibling", until );
+ },
+ siblings: function( elem ) {
+ return jQuery.sibling( elem.parentNode.firstChild, elem );
+ },
+ children: function( elem ) {
+ return jQuery.sibling( elem.firstChild );
+ },
+ contents: function( elem ) {
+ return jQuery.nodeName( elem, "iframe" ) ?
+ elem.contentDocument || elem.contentWindow.document :
+ jQuery.makeArray( elem.childNodes );
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function( until, selector ) {
+ var ret = jQuery.map( this, fn, until );
+
+ if ( !runtil.test( name ) ) {
+ selector = until;
+ }
+
+ if ( selector && typeof selector === "string" ) {
+ ret = jQuery.filter( selector, ret );
+ }
+
+ ret = this.length > 1 ? jQuery.unique( ret ) : ret;
+
+ if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
+ ret = ret.reverse();
+ }
+
+ return this.pushStack( ret, name, slice.call(arguments).join(",") );
+ };
+});
+
+jQuery.extend({
+ filter: function( expr, elems, not ) {
+ if ( not ) {
+ expr = ":not(" + expr + ")";
+ }
+
+ return jQuery.find.matches(expr, elems);
+ },
+
+ dir: function( elem, dir, until ) {
+ var matched = [], cur = elem[dir];
+ while ( cur && cur.nodeType !== 9 && (until === undefined || !jQuery( cur ).is( until )) ) {
+ if ( cur.nodeType === 1 ) {
+ matched.push( cur );
+ }
+ cur = cur[dir];
+ }
+ return matched;
+ },
+
+ nth: function( cur, result, dir, elem ) {
+ result = result || 1;
+ var num = 0;
+
+ for ( ; cur; cur = cur[dir] ) {
+ if ( cur.nodeType === 1 && ++num === result ) {
+ break;
+ }
+ }
+
+ return cur;
+ },
+
+ sibling: function( n, elem ) {
+ var r = [];
+
+ for ( ; n; n = n.nextSibling ) {
+ if ( n.nodeType === 1 && n !== elem ) {
+ r.push( n );
+ }
+ }
+
+ return r;
+ }
+});
+var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
+ rleadingWhitespace = /^\s+/,
+ rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g,
+ rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,
+ rtagName = /<([\w:]+)/,
+ rtbody = /<tbody/i,
+ rhtml = /<|&\w+;/,
+ fcloseTag = function( all, front, tag ) {
+ return rselfClosing.test( tag ) ?
+ all :
+ front + "></" + tag + ">";
+ },
+ wrapMap = {
+ option: [ 1, "<select multiple='multiple'>", "</select>" ],
+ legend: [ 1, "<fieldset>", "</fieldset>" ],
+ thead: [ 1, "<table>", "</table>" ],
+ tr: [ 2, "<table><tbody>", "</tbody></table>" ],
+ td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
+ col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
+ area: [ 1, "<map>", "</map>" ],
+ _default: [ 0, "", "" ]
+ };
+
+wrapMap.optgroup = wrapMap.option;
+wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
+wrapMap.th = wrapMap.td;
+
+// IE can't serialize <link> and <script> tags normally
+if ( !jQuery.support.htmlSerialize ) {
+ wrapMap._default = [ 1, "div<div>", "</div>" ];
+}
+
+jQuery.fn.extend({
+ text: function( text ) {
+ if ( jQuery.isFunction(text) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ return self.text( text.call(this, i, self.text()) );
+ });
+ }
+
+ if ( typeof text !== "object" && text !== undefined ) {
+ return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
+ }
+
+ return jQuery.getText( this );
+ },
+
+ wrapAll: function( html ) {
+ if ( jQuery.isFunction( html ) ) {
+ return this.each(function(i) {
+ jQuery(this).wrapAll( html.call(this, i) );
+ });
+ }
+
+ if ( this[0] ) {
+ // The elements to wrap the target around
+ var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
+
+ if ( this[0].parentNode ) {
+ wrap.insertBefore( this[0] );
+ }
+
+ wrap.map(function() {
+ var elem = this;
+
+ while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
+ elem = elem.firstChild;
+ }
+
+ return elem;
+ }).append(this);
+ }
+
+ return this;
+ },
+
+ wrapInner: function( html ) {
+ return this.each(function() {
+ var self = jQuery( this ), contents = self.contents();
+
+ if ( contents.length ) {
+ contents.wrapAll( html );
+
+ } else {
+ self.append( html );
+ }
+ });
+ },
+
+ wrap: function( html ) {
+ return this.each(function() {
+ jQuery( this ).wrapAll( html );
+ });
+ },
+
+ unwrap: function() {
+ return this.parent().each(function() {
+ if ( !jQuery.nodeName( this, "body" ) ) {
+ jQuery( this ).replaceWith( this.childNodes );
+ }
+ }).end();
+ },
+
+ append: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 ) {
+ this.appendChild( elem );
+ }
+ });
+ },
+
+ prepend: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 ) {
+ this.insertBefore( elem, this.firstChild );
+ }
+ });
+ },
+
+ before: function() {
+ if ( this[0] && this[0].parentNode ) {
+ return this.domManip(arguments, false, function( elem ) {
+ this.parentNode.insertBefore( elem, this );
+ });
+ } else if ( arguments.length ) {
+ var set = jQuery(arguments[0]);
+ set.push.apply( set, this.toArray() );
+ return this.pushStack( set, "before", arguments );
+ }
+ },
+
+ after: function() {
+ if ( this[0] && this[0].parentNode ) {
+ return this.domManip(arguments, false, function( elem ) {
+ this.parentNode.insertBefore( elem, this.nextSibling );
+ });
+ } else if ( arguments.length ) {
+ var set = this.pushStack( this, "after", arguments );
+ set.push.apply( set, jQuery(arguments[0]).toArray() );
+ return set;
+ }
+ },
+
+ clone: function( events ) {
+ // Do the clone
+ var ret = this.map(function() {
+ if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) {
+ // IE copies events bound via attachEvent when
+ // using cloneNode. Calling detachEvent on the
+ // clone will also remove the events from the orignal
+ // In order to get around this, we use innerHTML.
+ // Unfortunately, this means some modifications to
+ // attributes in IE that are actually only stored
+ // as properties will not be copied (such as the
+ // the name attribute on an input).
+ var html = this.outerHTML, ownerDocument = this.ownerDocument;
+ if ( !html ) {
+ var div = ownerDocument.createElement("div");
+ div.appendChild( this.cloneNode(true) );
+ html = div.innerHTML;
+ }
+
+ return jQuery.clean([html.replace(rinlinejQuery, "")
+ .replace(rleadingWhitespace, "")], ownerDocument)[0];
+ } else {
+ return this.cloneNode(true);
+ }
+ });
+
+ // Copy the events from the original to the clone
+ if ( events === true ) {
+ cloneCopyEvent( this, ret );
+ cloneCopyEvent( this.find("*"), ret.find("*") );
+ }
+
+ // Return the cloned set
+ return ret;
+ },
+
+ html: function( value ) {
+ if ( value === undefined ) {
+ return this[0] && this[0].nodeType === 1 ?
+ this[0].innerHTML.replace(rinlinejQuery, "") :
+ null;
+
+ // See if we can take a shortcut and just use innerHTML
+ } else if ( typeof value === "string" && !/<script/i.test( value ) &&
+ (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
+ !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
+
+ try {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ // Remove element nodes and prevent memory leaks
+ if ( this[i].nodeType === 1 ) {
+ cleanData( this[i].getElementsByTagName("*") );
+ this[i].innerHTML = value;
+ }
+ }
+
+ // If using innerHTML throws an exception, use the fallback method
+ } catch(e) {
+ this.empty().append( value );
+ }
+
+ } else if ( jQuery.isFunction( value ) ) {
+ this.each(function(i){
+ var self = jQuery(this), old = self.html();
+ self.empty().append(function(){
+ return value.call( this, i, old );
+ });
+ });
+
+ } else {
+ this.empty().append( value );
+ }
+
+ return this;
+ },
+
+ replaceWith: function( value ) {
+ if ( this[0] && this[0].parentNode ) {
+ // Make sure that the elements are removed from the DOM before they are inserted
+ // this can help fix replacing a parent with child elements
+ if ( !jQuery.isFunction( value ) ) {
+ value = jQuery( value ).detach();
+ }
+
+ return this.each(function() {
+ var next = this.nextSibling, parent = this.parentNode;
+
+ jQuery(this).remove();
+
+ if ( next ) {
+ jQuery(next).before( value );
+ } else {
+ jQuery(parent).append( value );
+ }
+ });
+ } else {
+ return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value );
+ }
+ },
+
+ detach: function( selector ) {
+ return this.remove( selector, true );
+ },
+
+ domManip: function( args, table, callback ) {
+ var results, first, value = args[0], scripts = [];
+
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ args[0] = value.call(this, i, table ? self.html() : undefined);
+ return self.domManip( args, table, callback );
+ });
+ }
+
+ if ( this[0] ) {
+ // If we're in a fragment, just use that instead of building a new one
+ if ( args[0] && args[0].parentNode && args[0].parentNode.nodeType === 11 ) {
+ results = { fragment: args[0].parentNode };
+ } else {
+ results = buildFragment( args, this, scripts );
+ }
+
+ first = results.fragment.firstChild;
+
+ if ( first ) {
+ table = table && jQuery.nodeName( first, "tr" );
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ callback.call(
+ table ?
+ root(this[i], first) :
+ this[i],
+ results.cacheable || this.length > 1 || i > 0 ?
+ results.fragment.cloneNode(true) :
+ results.fragment
+ );
+ }
+ }
+
+ if ( scripts ) {
+ jQuery.each( scripts, evalScript );
+ }
+ }
+
+ return this;
+
+ function root( elem, cur ) {
+ return jQuery.nodeName(elem, "table") ?
+ (elem.getElementsByTagName("tbody")[0] ||
+ elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
+ elem;
+ }
+ }
+});
+
+function cloneCopyEvent(orig, ret) {
+ var i = 0;
+
+ ret.each(function() {
+ if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) {
+ return;
+ }
+
+ var oldData = jQuery.data( orig[i++] ), curData = jQuery.data( this, oldData ), events = oldData && oldData.events;
+
+ if ( events ) {
+ delete curData.handle;
+ curData.events = {};
+
+ for ( var type in events ) {
+ for ( var handler in events[ type ] ) {
+ jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data );
+ }
+ }
+ }
+ });
+}
+
+function buildFragment( args, nodes, scripts ) {
+ var fragment, cacheable, cached, cacheresults, doc;
+
+ if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) {
+ cacheable = true;
+ cacheresults = jQuery.fragments[ args[0] ];
+ if ( cacheresults ) {
+ if ( cacheresults !== 1 ) {
+ fragment = cacheresults;
+ }
+ cached = true;
+ }
+ }
+
+ if ( !fragment ) {
+ doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
+ fragment = doc.createDocumentFragment();
+ jQuery.clean( args, doc, fragment, scripts );
+ }
+
+ if ( cacheable ) {
+ jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
+ }
+
+ return { fragment: fragment, cacheable: cacheable };
+}
+
+jQuery.fragments = {};
+
+jQuery.each({
+ appendTo: "append",
+ prependTo: "prepend",
+ insertBefore: "before",
+ insertAfter: "after",
+ replaceAll: "replaceWith"
+}, function( name, original ) {
+ jQuery.fn[ name ] = function( selector ) {
+ var ret = [], insert = jQuery( selector );
+
+ for ( var i = 0, l = insert.length; i < l; i++ ) {
+ var elems = (i > 0 ? this.clone(true) : this).get();
+ jQuery.fn[ original ].apply( jQuery(insert[i]), elems );
+ ret = ret.concat( elems );
+ }
+ return this.pushStack( ret, name, insert.selector );
+ };
+});
+
+jQuery.each({
+ // keepData is for internal use only--do not document
+ remove: function( selector, keepData ) {
+ if ( !selector || jQuery.filter( selector, [ this ] ).length ) {
+ if ( !keepData && this.nodeType === 1 ) {
+ cleanData( this.getElementsByTagName("*") );
+ cleanData( [ this ] );
+ }
+
+ if ( this.parentNode ) {
+ this.parentNode.removeChild( this );
+ }
+ }
+ },
+
+ empty: function() {
+ // Remove element nodes and prevent memory leaks
+ if ( this.nodeType === 1 ) {
+ cleanData( this.getElementsByTagName("*") );
+ }
+
+ // Remove any remaining nodes
+ while ( this.firstChild ) {
+ this.removeChild( this.firstChild );
+ }
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function() {
+ return this.each( fn, arguments );
+ };
+});
+
+jQuery.extend({
+ clean: function( elems, context, fragment, scripts ) {
+ context = context || document;
+
+ // !context.createElement fails in IE with an error but returns typeof 'object'
+ if ( typeof context.createElement === "undefined" ) {
+ context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
+ }
+
+ var ret = [];
+
+ jQuery.each(elems, function( i, elem ) {
+ if ( typeof elem === "number" ) {
+ elem += "";
+ }
+
+ if ( !elem ) {
+ return;
+ }
+
+ // Convert html string into DOM nodes
+ if ( typeof elem === "string" && !rhtml.test( elem ) ) {
+ elem = context.createTextNode( elem );
+
+ } else if ( typeof elem === "string" ) {
+ // Fix "XHTML"-style tags in all browsers
+ elem = elem.replace(rxhtmlTag, fcloseTag);
+
+ // Trim whitespace, otherwise indexOf won't work as expected
+ var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
+ wrap = wrapMap[ tag ] || wrapMap._default,
+ depth = wrap[0],
+ div = context.createElement("div");
+
+ // Go to html and back, then peel off extra wrappers
+ div.innerHTML = wrap[1] + elem + wrap[2];
+
+ // Move to the right depth
+ while ( depth-- ) {
+ div = div.lastChild;
+ }
+
+ // Remove IE's autoinserted <tbody> from table fragments
+ if ( !jQuery.support.tbody ) {
+
+ // String was a <table>, *may* have spurious <tbody>
+ var hasBody = rtbody.test(elem),
+ tbody = tag === "table" && !hasBody ?
+ div.firstChild && div.firstChild.childNodes :
+
+ // String was a bare <thead> or <tfoot>
+ wrap[1] === "<table>" && !hasBody ?
+ div.childNodes :
+ [];
+
+ for ( var j = tbody.length - 1; j >= 0 ; --j ) {
+ if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
+ tbody[ j ].parentNode.removeChild( tbody[ j ] );
+ }
+ }
+
+ }
+
+ // IE completely kills leading whitespace when innerHTML is used
+ if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
+ div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
+ }
+
+ elem = jQuery.makeArray( div.childNodes );
+ }
+
+ if ( elem.nodeType ) {
+ ret.push( elem );
+ } else {
+ ret = jQuery.merge( ret, elem );
+ }
+
+ });
+
+ if ( fragment ) {
+ for ( var i = 0; ret[i]; i++ ) {
+ if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
+ scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
+ } else {
+ if ( ret[i].nodeType === 1 ) {
+ ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
+ }
+ fragment.appendChild( ret[i] );
+ }
+ }
+ }
+
+ return ret;
+ }
+});
+
+function cleanData( elems ) {
+ for ( var i = 0, elem, id; (elem = elems[i]) != null; i++ ) {
+ if ( !jQuery.noData[elem.nodeName.toLowerCase()] && (id = elem[expando]) ) {
+ delete jQuery.cache[ id ];
+ }
+ }
+}
+// exclude the following css properties to add px
+var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
+ ralpha = /alpha\([^)]*\)/,
+ ropacity = /opacity=([^)]*)/,
+ rfloat = /float/i,
+ rdashAlpha = /-([a-z])/ig,
+ rupper = /([A-Z])/g,
+ rnumpx = /^-?\d+(?:px)?$/i,
+ rnum = /^-?\d/,
+
+ cssShow = { position: "absolute", visibility: "hidden", display:"block" },
+ cssWidth = [ "Left", "Right" ],
+ cssHeight = [ "Top", "Bottom" ],
+
+ // cache check for defaultView.getComputedStyle
+ getComputedStyle = document.defaultView && document.defaultView.getComputedStyle,
+ // normalize float css property
+ styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat",
+ fcamelCase = function( all, letter ) {
+ return letter.toUpperCase();
+ };
+
+jQuery.fn.css = function( name, value ) {
+ return access( this, name, value, true, function( elem, name, value ) {
+ if ( value === undefined ) {
+ return jQuery.curCSS( elem, name );
+ }
+
+ if ( typeof value === "number" && !rexclude.test(name) ) {
+ value += "px";
+ }
+
+ jQuery.style( elem, name, value );
+ });
+};
+
+jQuery.extend({
+ style: function( elem, name, value ) {
+ // don't set styles on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ // ignore negative width and height values #1599
+ if ( (name === "width" || name === "height") && parseFloat(value) < 0 ) {
+ value = undefined;
+ }
+
+ var style = elem.style || elem, set = value !== undefined;
+
+ // IE uses filters for opacity
+ if ( !jQuery.support.opacity && name === "opacity" ) {
+ if ( set ) {
+ // IE has trouble with opacity if it does not have layout
+ // Force it by setting the zoom level
+ style.zoom = 1;
+
+ // Set the alpha filter to set the opacity
+ var opacity = parseInt( value, 10 ) + "" === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")";
+ var filter = style.filter || jQuery.curCSS( elem, "filter" ) || "";
+ style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : opacity;
+ }
+
+ return style.filter && style.filter.indexOf("opacity=") >= 0 ?
+ (parseFloat( ropacity.exec(style.filter)[1] ) / 100) + "":
+ "";
+ }
+
+ // Make sure we're using the right name for getting the float value
+ if ( rfloat.test( name ) ) {
+ name = styleFloat;
+ }
+
+ name = name.replace(rdashAlpha, fcamelCase);
+
+ if ( set ) {
+ style[ name ] = value;
+ }
+
+ return style[ name ];
+ },
+
+ css: function( elem, name, force, extra ) {
+ if ( name === "width" || name === "height" ) {
+ var val, props = cssShow, which = name === "width" ? cssWidth : cssHeight;
+
+ function getWH() {
+ val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
+
+ if ( extra === "border" ) {
+ return;
+ }
+
+ jQuery.each( which, function() {
+ if ( !extra ) {
+ val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
+ }
+
+ if ( extra === "margin" ) {
+ val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0;
+ } else {
+ val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
+ }
+ });
+ }
+
+ if ( elem.offsetWidth !== 0 ) {
+ getWH();
+ } else {
+ jQuery.swap( elem, props, getWH );
+ }
+
+ return Math.max(0, Math.round(val));
+ }
+
+ return jQuery.curCSS( elem, name, force );
+ },
+
+ curCSS: function( elem, name, force ) {
+ var ret, style = elem.style, filter;
+
+ // IE uses filters for opacity
+ if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) {
+ ret = ropacity.test(elem.currentStyle.filter || "") ?
+ (parseFloat(RegExp.$1) / 100) + "" :
+ "";
+
+ return ret === "" ?
+ "1" :
+ ret;
+ }
+
+ // Make sure we're using the right name for getting the float value
+ if ( rfloat.test( name ) ) {
+ name = styleFloat;
+ }
+
+ if ( !force && style && style[ name ] ) {
+ ret = style[ name ];
+
+ } else if ( getComputedStyle ) {
+
+ // Only "float" is needed here
+ if ( rfloat.test( name ) ) {
+ name = "float";
+ }
+
+ name = name.replace( rupper, "-$1" ).toLowerCase();
+
+ var defaultView = elem.ownerDocument.defaultView;
+
+ if ( !defaultView ) {
+ return null;
+ }
+
+ var computedStyle = defaultView.getComputedStyle( elem, null );
+
+ if ( computedStyle ) {
+ ret = computedStyle.getPropertyValue( name );
+ }
+
+ // We should always get a number back from opacity
+ if ( name === "opacity" && ret === "" ) {
+ ret = "1";
+ }
+
+ } else if ( elem.currentStyle ) {
+ var camelCase = name.replace(rdashAlpha, fcamelCase);
+
+ ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
+
+ // From the awesome hack by Dean Edwards
+ // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
+
+ // If we're not dealing with a regular pixel number
+ // but a number that has a weird ending, we need to convert it to pixels
+ if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
+ // Remember the original values
+ var left = style.left, rsLeft = elem.runtimeStyle.left;
+
+ // Put in the new values to get a computed value out
+ elem.runtimeStyle.left = elem.currentStyle.left;
+ style.left = camelCase === "fontSize" ? "1em" : (ret || 0);
+ ret = style.pixelLeft + "px";
+
+ // Revert the changed values
+ style.left = left;
+ elem.runtimeStyle.left = rsLeft;
+ }
+ }
+
+ return ret;
+ },
+
+ // A method for quickly swapping in/out CSS properties to get correct calculations
+ swap: function( elem, options, callback ) {
+ var old = {};
+
+ // Remember the old values, and insert the new ones
+ for ( var name in options ) {
+ old[ name ] = elem.style[ name ];
+ elem.style[ name ] = options[ name ];
+ }
+
+ callback.call( elem );
+
+ // Revert the old values
+ for ( var name in options ) {
+ elem.style[ name ] = old[ name ];
+ }
+ }
+});
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.hidden = function( elem ) {
+ var width = elem.offsetWidth, height = elem.offsetHeight,
+ skip = elem.nodeName.toLowerCase() === "tr";
+
+ return width === 0 && height === 0 && !skip ?
+ true :
+ width > 0 && height > 0 && !skip ?
+ false :
+ jQuery.curCSS(elem, "display") === "none";
+ };
+
+ jQuery.expr.filters.visible = function( elem ) {
+ return !jQuery.expr.filters.hidden( elem );
+ };
+}
+var jsc = now(),
+ rscript = /<script(.|\s)*?\/script>/gi,
+ rselectTextarea = /select|textarea/i,
+ rinput = /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,
+ jsre = /=\?(&|$)/,
+ rquery = /\?/,
+ rts = /(\?|&)_=.*?(&|$)/,
+ rurl = /^(\w+:)?\/\/([^\/?#]+)/,
+ r20 = /%20/g;
+
+jQuery.fn.extend({
+ // Keep a copy of the old load
+ _load: jQuery.fn.load,
+
+ load: function( url, params, callback ) {
+ if ( typeof url !== "string" ) {
+ return this._load( url );
+
+ // Don't do a request if no elements are being requested
+ } else if ( !this.length ) {
+ return this;
+ }
+
+ var off = url.indexOf(" ");
+ if ( off >= 0 ) {
+ var selector = url.slice(off, url.length);
+ url = url.slice(0, off);
+ }
+
+ // Default to a GET request
+ var type = "GET";
+
+ // If the second parameter was provided
+ if ( params ) {
+ // If it's a function
+ if ( jQuery.isFunction( params ) ) {
+ // We assume that it's the callback
+ callback = params;
+ params = null;
+
+ // Otherwise, build a param string
+ } else if ( typeof params === "object" ) {
+ params = jQuery.param( params, jQuery.ajaxSettings.traditional );
+ type = "POST";
+ }
+ }
+
+ // Request the remote document
+ jQuery.ajax({
+ url: url,
+ type: type,
+ dataType: "html",
+ data: params,
+ context:this,
+ complete: function( res, status ) {
+ // If successful, inject the HTML into all the matched elements
+ if ( status === "success" || status === "notmodified" ) {
+ // See if a selector was specified
+ this.html( selector ?
+ // Create a dummy div to hold the results
+ jQuery("<div />")
+ // inject the contents of the document in, removing the scripts
+ // to avoid any 'Permission Denied' errors in IE
+ .append(res.responseText.replace(rscript, ""))
+
+ // Locate the specified elements
+ .find(selector) :
+
+ // If not, just inject the full result
+ res.responseText );
+ }
+
+ if ( callback ) {
+ this.each( callback, [res.responseText, status, res] );
+ }
+ }
+ });
+
+ return this;
+ },
+
+ serialize: function() {
+ return jQuery.param(this.serializeArray());
+ },
+ serializeArray: function() {
+ return this.map(function() {
+ return this.elements ? jQuery.makeArray(this.elements) : this;
+ })
+ .filter(function() {
+ return this.name && !this.disabled &&
+ (this.checked || rselectTextarea.test(this.nodeName) ||
+ rinput.test(this.type));
+ })
+ .map(function( i, elem ) {
+ var val = jQuery(this).val();
+
+ return val == null ?
+ null :
+ jQuery.isArray(val) ?
+ jQuery.map( val, function( val, i ) {
+ return { name: elem.name, value: val };
+ }) :
+ { name: elem.name, value: val };
+ }).get();
+ }
+});
+
+// Attach a bunch of functions for handling common AJAX events
+jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function( i, o ) {
+ jQuery.fn[o] = function( f ) {
+ return this.bind(o, f);
+ };
+});
+
+jQuery.extend({
+
+ get: function( url, data, callback, type ) {
+ // shift arguments if data argument was omited
+ if ( jQuery.isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = null;
+ }
+
+ return jQuery.ajax({
+ type: "GET",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ getScript: function( url, callback ) {
+ return jQuery.get(url, null, callback, "script");
+ },
+
+ getJSON: function( url, data, callback ) {
+ return jQuery.get(url, data, callback, "json");
+ },
+
+ post: function( url, data, callback, type ) {
+ // shift arguments if data argument was omited
+ if ( jQuery.isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = {};
+ }
+
+ return jQuery.ajax({
+ type: "POST",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ ajaxSetup: function( settings ) {
+ jQuery.extend( jQuery.ajaxSettings, settings );
+ },
+
+ ajaxSettings: {
+ url: location.href,
+ global: true,
+ type: "GET",
+ contentType: "application/x-www-form-urlencoded",
+ processData: true,
+ async: true,
+ /*
+ timeout: 0,
+ data: null,
+ username: null,
+ password: null,
+ traditional: false,
+ */
+ // Create the request object; Microsoft failed to properly
+ // implement the XMLHttpRequest in IE7 (can't request local files),
+ // so we use the ActiveXObject when it is available
+ // This function can be overriden by calling jQuery.ajaxSetup
+ xhr: window.XMLHttpRequest && (window.location.protocol !== "file:" || !window.ActiveXObject) ?
+ function() {
+ return new window.XMLHttpRequest();
+ } :
+ function() {
+ try {
+ return new window.ActiveXObject("Microsoft.XMLHTTP");
+ } catch(e) {}
+ },
+ accepts: {
+ xml: "application/xml, text/xml",
+ html: "text/html",
+ script: "text/javascript, application/javascript",
+ json: "application/json, text/javascript",
+ text: "text/plain",
+ _default: "*/*"
+ }
+ },
+
+ // Last-Modified header cache for next request
+ lastModified: {},
+ etag: {},
+
+ ajax: function( origSettings ) {
+ var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings);
+
+ var jsonp, status, data,
+ callbackContext = s.context || s,
+ type = s.type.toUpperCase();
+
+ // convert data if not already a string
+ if ( s.data && s.processData && typeof s.data !== "string" ) {
+ s.data = jQuery.param( s.data, s.traditional );
+ }
+
+ // Handle JSONP Parameter Callbacks
+ if ( s.dataType === "jsonp" ) {
+ if ( type === "GET" ) {
+ if ( !jsre.test( s.url ) ) {
+ s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?";
+ }
+ } else if ( !s.data || !jsre.test(s.data) ) {
+ s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
+ }
+ s.dataType = "json";
+ }
+
+ // Build temporary JSONP function
+ if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) {
+ jsonp = s.jsonpCallback || ("jsonp" + jsc++);
+
+ // Replace the =? sequence both in the query string and the data
+ if ( s.data ) {
+ s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
+ }
+
+ s.url = s.url.replace(jsre, "=" + jsonp + "$1");
+
+ // We need to make sure
+ // that a JSONP style response is executed properly
+ s.dataType = "script";
+
+ // Handle JSONP-style loading
+ window[ jsonp ] = window[ jsonp ] || function( tmp ) {
+ data = tmp;
+ success();
+ complete();
+ // Garbage collect
+ window[ jsonp ] = undefined;
+
+ try {
+ delete window[ jsonp ];
+ } catch(e) {}
+
+ if ( head ) {
+ head.removeChild( script );
+ }
+ };
+ }
+
+ if ( s.dataType === "script" && s.cache === null ) {
+ s.cache = false;
+ }
+
+ if ( s.cache === false && type === "GET" ) {
+ var ts = now();
+
+ // try replacing _= if it is there
+ var ret = s.url.replace(rts, "$1_=" + ts + "$2");
+
+ // if nothing was replaced, add timestamp to the end
+ s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : "");
+ }
+
+ // If data is available, append data to url for get requests
+ if ( s.data && type === "GET" ) {
+ s.url += (rquery.test(s.url) ? "&" : "?") + s.data;
+ }
+
+ // Watch for a new set of requests
+ if ( s.global && ! jQuery.active++ ) {
+ jQuery.event.trigger( "ajaxStart" );
+ }
+
+ // Matches an absolute URL, and saves the domain
+ var parts = rurl.exec( s.url ),
+ remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host);
+
+ // If we're requesting a remote document
+ // and trying to load JSON or Script with a GET
+ if ( s.dataType === "script" && type === "GET" && remote ) {
+ var head = document.getElementsByTagName("head")[0] || document.documentElement;
+ var script = document.createElement("script");
+ script.src = s.url;
+ if ( s.scriptCharset ) {
+ script.charset = s.scriptCharset;
+ }
+
+ // Handle Script loading
+ if ( !jsonp ) {
+ var done = false;
+
+ // Attach handlers for all browsers
+ script.onload = script.onreadystatechange = function() {
+ if ( !done && (!this.readyState ||
+ this.readyState === "loaded" || this.readyState === "complete") ) {
+ done = true;
+ success();
+ complete();
+
+ // Handle memory leak in IE
+ script.onload = script.onreadystatechange = null;
+ if ( head && script.parentNode ) {
+ head.removeChild( script );
+ }
+ }
+ };
+ }
+
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709 and #4378).
+ head.insertBefore( script, head.firstChild );
+
+ // We handle everything using the script element injection
+ return undefined;
+ }
+
+ var requestDone = false;
+
+ // Create the request object
+ var xhr = s.xhr();
+
+ if ( !xhr ) {
+ return;
+ }
+
+ // Open the socket
+ // Passing null username, generates a login popup on Opera (#2865)
+ if ( s.username ) {
+ xhr.open(type, s.url, s.async, s.username, s.password);
+ } else {
+ xhr.open(type, s.url, s.async);
+ }
+
+ // Need an extra try/catch for cross domain requests in Firefox 3
+ try {
+ // Set the correct header, if data is being sent
+ if ( s.data || origSettings && origSettings.contentType ) {
+ xhr.setRequestHeader("Content-Type", s.contentType);
+ }
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if ( s.ifModified ) {
+ if ( jQuery.lastModified[s.url] ) {
+ xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]);
+ }
+
+ if ( jQuery.etag[s.url] ) {
+ xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]);
+ }
+ }
+
+ // Set header so the called script knows that it's an XMLHttpRequest
+ // Only send the header if it's not a remote XHR
+ if ( !remote ) {
+ xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+ }
+
+ // Set the Accepts header for the server, depending on the dataType
+ xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ?
+ s.accepts[ s.dataType ] + ", */*" :
+ s.accepts._default );
+ } catch(e) {}
+
+ // Allow custom headers/mimetypes and early abort
+ if ( s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false ) {
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active ) {
+ jQuery.event.trigger( "ajaxStop" );
+ }
+
+ // close opended socket
+ xhr.abort();
+ return false;
+ }
+
+ if ( s.global ) {
+ trigger("ajaxSend", [xhr, s]);
+ }
+
+ // Wait for a response to come back
+ var onreadystatechange = xhr.onreadystatechange = function( isTimeout ) {
+ // The request was aborted
+ if ( !xhr || xhr.readyState === 0 ) {
+ // Opera doesn't call onreadystatechange before this point
+ // so we simulate the call
+ if ( !requestDone ) {
+ complete();
+ }
+
+ requestDone = true;
+ if ( xhr ) {
+ xhr.onreadystatechange = jQuery.noop;
+ }
+
+ // The transfer is complete and the data is available, or the request timed out
+ } else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) {
+ requestDone = true;
+ xhr.onreadystatechange = jQuery.noop;
+
+ status = isTimeout === "timeout" ?
+ "timeout" :
+ !jQuery.httpSuccess( xhr ) ?
+ "error" :
+ s.ifModified && jQuery.httpNotModified( xhr, s.url ) ?
+ "notmodified" :
+ "success";
+
+ if ( status === "success" ) {
+ // Watch for, and catch, XML document parse errors
+ try {
+ // process the data (runs the xml through httpData regardless of callback)
+ data = jQuery.httpData( xhr, s.dataType, s );
+ } catch(e) {
+ status = "parsererror";
+ }
+ }
+
+ // Make sure that the request was successful or notmodified
+ if ( status === "success" || status === "notmodified" ) {
+ // JSONP handles its own success callback
+ if ( !jsonp ) {
+ success();
+ }
+ } else {
+ jQuery.handleError(s, xhr, status);
+ }
+
+ // Fire the complete handlers
+ complete();
+
+ if ( isTimeout === "timeout" ) {
+ xhr.abort();
+ }
+
+ // Stop memory leaks
+ if ( s.async ) {
+ xhr = null;
+ }
+ }
+ };
+
+ // Override the abort handler, if we can (IE doesn't allow it, but that's OK)
+ // Opera doesn't fire onreadystatechange at all on abort
+ try {
+ var oldAbort = xhr.abort;
+ xhr.abort = function() {
+ if ( xhr ) {
+ oldAbort.call( xhr );
+ if ( xhr ) {
+ xhr.readyState = 0;
+ }
+ }
+
+ onreadystatechange();
+ };
+ } catch(e) { }
+
+ // Timeout checker
+ if ( s.async && s.timeout > 0 ) {
+ setTimeout(function() {
+ // Check to see if the request is still happening
+ if ( xhr && !requestDone ) {
+ onreadystatechange( "timeout" );
+ }
+ }, s.timeout);
+ }
+
+ // Send the data
+ try {
+ xhr.send( type === "POST" || type === "PUT" || type === "DELETE" ? s.data : null );
+ } catch(e) {
+ jQuery.handleError(s, xhr, null, e);
+ // Fire the complete handlers
+ complete();
+ }
+
+ // firefox 1.5 doesn't fire statechange for sync requests
+ if ( !s.async ) {
+ onreadystatechange();
+ }
+
+ function success() {
+ // If a local callback was specified, fire it and pass it the data
+ if ( s.success ) {
+ s.success.call( callbackContext, data, status, xhr );
+ }
+
+ // Fire the global callback
+ if ( s.global ) {
+ trigger( "ajaxSuccess", [xhr, s] );
+ }
+ }
+
+ function complete() {
+ // Process result
+ if ( s.complete ) {
+ s.complete.call( callbackContext, xhr, status);
+ }
+
+ // The request was completed
+ if ( s.global ) {
+ trigger( "ajaxComplete", [xhr, s] );
+ }
+
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active ) {
+ jQuery.event.trigger( "ajaxStop" );
+ }
+ }
+
+ function trigger(type, args) {
+ (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args);
+ }
+
+ // return XMLHttpRequest to allow aborting the request etc.
+ return xhr;
+ },
+
+ handleError: function( s, xhr, status, e ) {
+ // If a local callback was specified, fire it
+ if ( s.error ) {
+ s.error.call( s.context || window, xhr, status, e );
+ }
+
+ // Fire the global callback
+ if ( s.global ) {
+ (s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] );
+ }
+ },
+
+ // Counter for holding the number of active queries
+ active: 0,
+
+ // Determines if an XMLHttpRequest was successful or not
+ httpSuccess: function( xhr ) {
+ try {
+ // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
+ return !xhr.status && location.protocol === "file:" ||
+ // Opera returns 0 when status is 304
+ ( xhr.status >= 200 && xhr.status < 300 ) ||
+ xhr.status === 304 || xhr.status === 1223 || xhr.status === 0;
+ } catch(e) {}
+
+ return false;
+ },
+
+ // Determines if an XMLHttpRequest returns NotModified
+ httpNotModified: function( xhr, url ) {
+ var lastModified = xhr.getResponseHeader("Last-Modified"),
+ etag = xhr.getResponseHeader("Etag");
+
+ if ( lastModified ) {
+ jQuery.lastModified[url] = lastModified;
+ }
+
+ if ( etag ) {
+ jQuery.etag[url] = etag;
+ }
+
+ // Opera returns 0 when status is 304
+ return xhr.status === 304 || xhr.status === 0;
+ },
+
+ httpData: function( xhr, type, s ) {
+ var ct = xhr.getResponseHeader("content-type") || "",
+ xml = type === "xml" || !type && ct.indexOf("xml") >= 0,
+ data = xml ? xhr.responseXML : xhr.responseText;
+
+ if ( xml && data.documentElement.nodeName === "parsererror" ) {
+ throw "parsererror";
+ }
+
+ // Allow a pre-filtering function to sanitize the response
+ // s is checked to keep backwards compatibility
+ if ( s && s.dataFilter ) {
+ data = s.dataFilter( data, type );
+ }
+
+ // The filter can actually parse the response
+ if ( typeof data === "string" ) {
+ // Get the JavaScript object, if JSON is used.
+ if ( type === "json" || !type && ct.indexOf("json") >= 0 ) {
+ // Make sure the incoming data is actual JSON
+ // Logic borrowed from http://json.org/json2.js
+ if (/^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]")
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ""))) {
+
+ // Try to use the native JSON parser first
+ if ( window.JSON && window.JSON.parse ) {
+ data = window.JSON.parse( data );
+
+ } else {
+ data = (new Function("return " + data))();
+ }
+
+ } else {
+ throw "Invalid JSON: " + data;
+ }
+
+ // If the type is "script", eval it in global context
+ } else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) {
+ jQuery.globalEval( data );
+ }
+ }
+
+ return data;
+ },
+
+ // Serialize an array of form elements or a set of
+ // key/values into a query string
+ param: function( a, traditional ) {
+
+ var s = [];
+
+ // Set traditional to true for jQuery <= 1.3.2 behavior.
+ if ( traditional === undefined ) {
+ traditional = jQuery.ajaxSettings.traditional;
+ }
+
+ function add( key, value ) {
+ // If value is a function, invoke it and return its value
+ value = jQuery.isFunction(value) ? value() : value;
+ s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
+ }
+
+ // If an array was passed in, assume that it is an array of form elements.
+ if ( jQuery.isArray(a) || a.jquery ) {
+ // Serialize the form elements
+ jQuery.each( a, function() {
+ add( this.name, this.value );
+ });
+
+ } else {
+ // If traditional, encode the "old" way (the way 1.3.2 or older
+ // did it), otherwise encode params recursively.
+ jQuery.each( a, function buildParams( prefix, obj ) {
+
+ if ( jQuery.isArray(obj) ) {
+ // Serialize array item.
+ jQuery.each( obj, function( i, v ) {
+ if ( traditional ) {
+ // Treat each array item as a scalar.
+ add( prefix, v );
+ } else {
+ // If array item is non-scalar (array or object), encode its
+ // numeric index to resolve deserialization ambiguity issues.
+ // Note that rack (as of 1.0.0) can't currently deserialize
+ // nested arrays properly, and attempting to do so may cause
+ // a server error. Possible fixes are to modify rack's
+ // deserialization algorithm or to provide an option or flag
+ // to force array serialization to be shallow.
+ buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v );
+ }
+ });
+
+ } else if ( !traditional && obj != null && typeof obj === "object" ) {
+ // Serialize object item.
+ jQuery.each( obj, function( k, v ) {
+ buildParams( prefix + "[" + k + "]", v );
+ });
+
+ } else {
+ // Serialize scalar item.
+ add( prefix, obj );
+ }
+ });
+ }
+
+ // Return the resulting serialization
+ return s.join("&").replace(r20, "+");
+ }
+
+});
+var elemdisplay = {},
+ rfxtypes = /toggle|show|hide/,
+ rfxnum = /^([+-]=)?([\d+-.]+)(.*)$/,
+ timerId,
+ fxAttrs = [
+ // height animations
+ [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
+ // width animations
+ [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
+ // opacity animations
+ [ "opacity" ]
+ ];
+
+jQuery.fn.extend({
+ show: function( speed, callback ) {
+ if ( speed != null ) {
+ return this.animate( genFx("show", 3), speed, callback);
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var old = jQuery.data(this[i], "olddisplay");
+
+ this[i].style.display = old || "";
+
+ if ( jQuery.css(this[i], "display") === "none" ) {
+ var nodeName = this[i].nodeName, display;
+
+ if ( elemdisplay[ nodeName ] ) {
+ display = elemdisplay[ nodeName ];
+
+ } else {
+ var elem = jQuery("<" + nodeName + " />").appendTo("body");
+
+ display = elem.css("display");
+
+ if ( display === "none" ) {
+ display = "block";
+ }
+
+ elem.remove();
+
+ elemdisplay[ nodeName ] = display;
+ }
+
+ jQuery.data(this[i], "olddisplay", display);
+ }
+ }
+
+ // Set the display of the elements in a second loop
+ // to avoid the constant reflow
+ for ( var j = 0, k = this.length; j < k; j++ ) {
+ this[j].style.display = jQuery.data(this[j], "olddisplay") || "";
+ }
+
+ return this;
+ }
+ },
+
+ hide: function( speed, callback ) {
+ if ( speed != null ) {
+ return this.animate( genFx("hide", 3), speed, callback);
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var old = jQuery.data(this[i], "olddisplay");
+ if ( !old && old !== "none" ) {
+ jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display"));
+ }
+ }
+
+ // Set the display of the elements in a second loop
+ // to avoid the constant reflow
+ for ( var j = 0, k = this.length; j < k; j++ ) {
+ this[j].style.display = "none";
+ }
+
+ return this;
+ }
+ },
+
+ // Save the old toggle function
+ _toggle: jQuery.fn.toggle,
+
+ toggle: function( fn, fn2 ) {
+ var bool = typeof fn === "boolean";
+
+ if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
+ this._toggle.apply( this, arguments );
+
+ } else if ( fn == null || bool ) {
+ this.each(function() {
+ var state = bool ? fn : jQuery(this).is(":hidden");
+ jQuery(this)[ state ? "show" : "hide" ]();
+ });
+
+ } else {
+ this.animate(genFx("toggle", 3), fn, fn2);
+ }
+
+ return this;
+ },
+
+ fadeTo: function( speed, to, callback ) {
+ return this.filter(":hidden").css("opacity", 0).show().end()
+ .animate({opacity: to}, speed, callback);
+ },
+
+ animate: function( prop, speed, easing, callback ) {
+ var optall = jQuery.speed(speed, easing, callback);
+
+ if ( jQuery.isEmptyObject( prop ) ) {
+ return this.each( optall.complete );
+ }
+
+ return this[ optall.queue === false ? "each" : "queue" ](function() {
+ var opt = jQuery.extend({}, optall), p,
+ hidden = this.nodeType === 1 && jQuery(this).is(":hidden"),
+ self = this;
+
+ for ( p in prop ) {
+ var name = p.replace(rdashAlpha, fcamelCase);
+
+ if ( p !== name ) {
+ prop[ name ] = prop[ p ];
+ delete prop[ p ];
+ p = name;
+ }
+
+ if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
+ return opt.complete.call(this);
+ }
+
+ if ( ( p === "height" || p === "width" ) && this.style ) {
+ // Store display property
+ opt.display = jQuery.css(this, "display");
+
+ // Make sure that nothing sneaks out
+ opt.overflow = this.style.overflow;
+ }
+
+ if ( jQuery.isArray( prop[p] ) ) {
+ // Create (if needed) and add to specialEasing
+ (opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1];
+ prop[p] = prop[p][0];
+ }
+ }
+
+ if ( opt.overflow != null ) {
+ this.style.overflow = "hidden";
+ }
+
+ opt.curAnim = jQuery.extend({}, prop);
+
+ jQuery.each( prop, function( name, val ) {
+ var e = new jQuery.fx( self, opt, name );
+
+ if ( rfxtypes.test(val) ) {
+ e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop );
+
+ } else {
+ var parts = rfxnum.exec(val),
+ start = e.cur(true) || 0;
+
+ if ( parts ) {
+ var end = parseFloat( parts[2] ),
+ unit = parts[3] || "px";
+
+ // We need to compute starting value
+ if ( unit !== "px" ) {
+ self.style[ name ] = (end || 1) + unit;
+ start = ((end || 1) / e.cur(true)) * start;
+ self.style[ name ] = start + unit;
+ }
+
+ // If a +=/-= token was provided, we're doing a relative animation
+ if ( parts[1] ) {
+ end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
+ }
+
+ e.custom( start, end, unit );
+
+ } else {
+ e.custom( start, val, "" );
+ }
+ }
+ });
+
+ // For JS strict compliance
+ return true;
+ });
+ },
+
+ stop: function( clearQueue, gotoEnd ) {
+ var timers = jQuery.timers;
+
+ if ( clearQueue ) {
+ this.queue([]);
+ }
+
+ this.each(function() {
+ // go in reverse order so anything added to the queue during the loop is ignored
+ for ( var i = timers.length - 1; i >= 0; i-- ) {
+ if ( timers[i].elem === this ) {
+ if (gotoEnd) {
+ // force the next step to be the last
+ timers[i](true);
+ }
+
+ timers.splice(i, 1);
+ }
+ }
+ });
+
+ // start the next in the queue if the last step wasn't forced
+ if ( !gotoEnd ) {
+ this.dequeue();
+ }
+
+ return this;
+ }
+
+});
+
+// Generate shortcuts for custom animations
+jQuery.each({
+ slideDown: genFx("show", 1),
+ slideUp: genFx("hide", 1),
+ slideToggle: genFx("toggle", 1),
+ fadeIn: { opacity: "show" },
+ fadeOut: { opacity: "hide" }
+}, function( name, props ) {
+ jQuery.fn[ name ] = function( speed, callback ) {
+ return this.animate( props, speed, callback );
+ };
+});
+
+jQuery.extend({
+ speed: function( speed, easing, fn ) {
+ var opt = speed && typeof speed === "object" ? speed : {
+ complete: fn || !fn && easing ||
+ jQuery.isFunction( speed ) && speed,
+ duration: speed,
+ easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
+ };
+
+ opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
+ jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default;
+
+ // Queueing
+ opt.old = opt.complete;
+ opt.complete = function() {
+ if ( opt.queue !== false ) {
+ jQuery(this).dequeue();
+ }
+ if ( jQuery.isFunction( opt.old ) ) {
+ opt.old.call( this );
+ }
+ };
+
+ return opt;
+ },
+
+ easing: {
+ linear: function( p, n, firstNum, diff ) {
+ return firstNum + diff * p;
+ },
+ swing: function( p, n, firstNum, diff ) {
+ return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
+ }
+ },
+
+ timers: [],
+
+ fx: function( elem, options, prop ) {
+ this.options = options;
+ this.elem = elem;
+ this.prop = prop;
+
+ if ( !options.orig ) {
+ options.orig = {};
+ }
+ }
+
+});
+
+jQuery.fx.prototype = {
+ // Simple function for setting a style value
+ update: function() {
+ if ( this.options.step ) {
+ this.options.step.call( this.elem, this.now, this );
+ }
+
+ (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
+
+ // Set display property to block for height/width animations
+ if ( ( this.prop === "height" || this.prop === "width" ) && this.elem.style ) {
+ this.elem.style.display = "block";
+ }
+ },
+
+ // Get the current size
+ cur: function( force ) {
+ if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
+ return this.elem[ this.prop ];
+ }
+
+ var r = parseFloat(jQuery.css(this.elem, this.prop, force));
+ return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
+ },
+
+ // Start an animation from one number to another
+ custom: function( from, to, unit ) {
+ this.startTime = now();
+ this.start = from;
+ this.end = to;
+ this.unit = unit || this.unit || "px";
+ this.now = this.start;
+ this.pos = this.state = 0;
+
+ var self = this;
+ function t( gotoEnd ) {
+ return self.step(gotoEnd);
+ }
+
+ t.elem = this.elem;
+
+ if ( t() && jQuery.timers.push(t) && !timerId ) {
+ timerId = setInterval(jQuery.fx.tick, 13);
+ }
+ },
+
+ // Simple 'show' function
+ show: function() {
+ // Remember where we started, so that we can go back to it later
+ this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
+ this.options.show = true;
+
+ // Begin the animation
+ // Make sure that we start at a small width/height to avoid any
+ // flash of content
+ this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
+
+ // Start by showing the element
+ jQuery( this.elem ).show();
+ },
+
+ // Simple 'hide' function
+ hide: function() {
+ // Remember where we started, so that we can go back to it later
+ this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
+ this.options.hide = true;
+
+ // Begin the animation
+ this.custom(this.cur(), 0);
+ },
+
+ // Each step of an animation
+ step: function( gotoEnd ) {
+ var t = now(), done = true;
+
+ if ( gotoEnd || t >= this.options.duration + this.startTime ) {
+ this.now = this.end;
+ this.pos = this.state = 1;
+ this.update();
+
+ this.options.curAnim[ this.prop ] = true;
+
+ for ( var i in this.options.curAnim ) {
+ if ( this.options.curAnim[i] !== true ) {
+ done = false;
+ }
+ }
+
+ if ( done ) {
+ if ( this.options.display != null ) {
+ // Reset the overflow
+ this.elem.style.overflow = this.options.overflow;
+
+ // Reset the display
+ var old = jQuery.data(this.elem, "olddisplay");
+ this.elem.style.display = old ? old : this.options.display;
+
+ if ( jQuery.css(this.elem, "display") === "none" ) {
+ this.elem.style.display = "block";
+ }
+ }
+
+ // Hide the element if the "hide" operation was done
+ if ( this.options.hide ) {
+ jQuery(this.elem).hide();
+ }
+
+ // Reset the properties, if the item has been hidden or shown
+ if ( this.options.hide || this.options.show ) {
+ for ( var p in this.options.curAnim ) {
+ jQuery.style(this.elem, p, this.options.orig[p]);
+ }
+ }
+
+ // Execute the complete function
+ this.options.complete.call( this.elem );
+ }
+
+ return false;
+
+ } else {
+ var n = t - this.startTime;
+ this.state = n / this.options.duration;
+
+ // Perform the easing function, defaults to swing
+ var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop];
+ var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear");
+ this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration);
+ this.now = this.start + ((this.end - this.start) * this.pos);
+
+ // Perform the next step of the animation
+ this.update();
+ }
+
+ return true;
+ }
+};
+
+jQuery.extend( jQuery.fx, {
+ tick: function() {
+ var timers = jQuery.timers;
+
+ for ( var i = 0; i < timers.length; i++ ) {
+ if ( !timers[i]() ) {
+ timers.splice(i--, 1);
+ }
+ }
+
+ if ( !timers.length ) {
+ jQuery.fx.stop();
+ }
+ },
+
+ stop: function() {
+ clearInterval( timerId );
+ timerId = null;
+ },
+
+ speeds: {
+ slow: 600,
+ fast: 200,
+ // Default speed
+ _default: 400
+ },
+
+ step: {
+ opacity: function( fx ) {
+ jQuery.style(fx.elem, "opacity", fx.now);
+ },
+
+ _default: function( fx ) {
+ if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
+ fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
+ } else {
+ fx.elem[ fx.prop ] = fx.now;
+ }
+ }
+ }
+});
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.animated = function( elem ) {
+ return jQuery.grep(jQuery.timers, function( fn ) {
+ return elem === fn.elem;
+ }).length;
+ };
+}
+
+function genFx( type, num ) {
+ var obj = {};
+
+ jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
+ obj[ this ] = type;
+ });
+
+ return obj;
+}
+if ( "getBoundingClientRect" in document.documentElement ) {
+ jQuery.fn.offset = function( options ) {
+ var elem = this[0];
+
+ if ( !elem || !elem.ownerDocument ) {
+ return null;
+ }
+
+ if ( options ) {
+ return this.each(function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ });
+ }
+
+ if ( elem === elem.ownerDocument.body ) {
+ return jQuery.offset.bodyOffset( elem );
+ }
+
+ var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement,
+ clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
+ top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop,
+ left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft;
+
+ return { top: top, left: left };
+ };
+
+} else {
+ jQuery.fn.offset = function( options ) {
+ var elem = this[0];
+
+ if ( !elem || !elem.ownerDocument ) {
+ return null;
+ }
+
+ if ( options ) {
+ return this.each(function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ });
+ }
+
+ if ( elem === elem.ownerDocument.body ) {
+ return jQuery.offset.bodyOffset( elem );
+ }
+
+ jQuery.offset.initialize();
+
+ var offsetParent = elem.offsetParent, prevOffsetParent = elem,
+ doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement,
+ body = doc.body, defaultView = doc.defaultView,
+ prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
+ top = elem.offsetTop, left = elem.offsetLeft;
+
+ while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
+ if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
+ break;
+ }
+
+ computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
+ top -= elem.scrollTop;
+ left -= elem.scrollLeft;
+
+ if ( elem === offsetParent ) {
+ top += elem.offsetTop;
+ left += elem.offsetLeft;
+
+ if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.nodeName)) ) {
+ top += parseFloat( computedStyle.borderTopWidth ) || 0;
+ left += parseFloat( computedStyle.borderLeftWidth ) || 0;
+ }
+
+ prevOffsetParent = offsetParent, offsetParent = elem.offsetParent;
+ }
+
+ if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
+ top += parseFloat( computedStyle.borderTopWidth ) || 0;
+ left += parseFloat( computedStyle.borderLeftWidth ) || 0;
+ }
+
+ prevComputedStyle = computedStyle;
+ }
+
+ if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
+ top += body.offsetTop;
+ left += body.offsetLeft;
+ }
+
+ if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
+ top += Math.max( docElem.scrollTop, body.scrollTop );
+ left += Math.max( docElem.scrollLeft, body.scrollLeft );
+ }
+
+ return { top: top, left: left };
+ };
+}
+
+jQuery.offset = {
+ initialize: function() {
+ var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0,
+ html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
+
+ jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
+
+ container.innerHTML = html;
+ body.insertBefore( container, body.firstChild );
+ innerDiv = container.firstChild;
+ checkDiv = innerDiv.firstChild;
+ td = innerDiv.nextSibling.firstChild.firstChild;
+
+ this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
+ this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
+
+ checkDiv.style.position = "fixed", checkDiv.style.top = "20px";
+ // safari subtracts parent border width here which is 5px
+ this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
+ checkDiv.style.position = checkDiv.style.top = "";
+
+ innerDiv.style.overflow = "hidden", innerDiv.style.position = "relative";
+ this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
+
+ this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
+
+ body.removeChild( container );
+ body = container = innerDiv = checkDiv = table = td = null;
+ jQuery.offset.initialize = jQuery.noop;
+ },
+
+ bodyOffset: function( body ) {
+ var top = body.offsetTop, left = body.offsetLeft;
+
+ jQuery.offset.initialize();
+
+ if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
+ top += parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0;
+ left += parseFloat( jQuery.curCSS(body, "marginLeft", true) ) || 0;
+ }
+
+ return { top: top, left: left };
+ },
+
+ setOffset: function( elem, options, i ) {
+ // set position first, in-case top/left are set even on static elem
+ if ( /static/.test( jQuery.curCSS( elem, "position" ) ) ) {
+ elem.style.position = "relative";
+ }
+ var curElem = jQuery( elem ),
+ curOffset = curElem.offset(),
+ curTop = parseInt( jQuery.curCSS( elem, "top", true ), 10 ) || 0,
+ curLeft = parseInt( jQuery.curCSS( elem, "left", true ), 10 ) || 0;
+
+ if ( jQuery.isFunction( options ) ) {
+ options = options.call( elem, i, curOffset );
+ }
+
+ var props = {
+ top: (options.top - curOffset.top) + curTop,
+ left: (options.left - curOffset.left) + curLeft
+ };
+
+ if ( "using" in options ) {
+ options.using.call( elem, props );
+ } else {
+ curElem.css( props );
+ }
+ }
+};
+
+
+jQuery.fn.extend({
+ position: function() {
+ if ( !this[0] ) {
+ return null;
+ }
+
+ var elem = this[0],
+
+ // Get *real* offsetParent
+ offsetParent = this.offsetParent(),
+
+ // Get correct offsets
+ offset = this.offset(),
+ parentOffset = /^body|html$/i.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
+
+ // Subtract element margins
+ // note: when an element has margin: auto the offsetLeft and marginLeft
+ // are the same in Safari causing offset.left to incorrectly be 0
+ offset.top -= parseFloat( jQuery.curCSS(elem, "marginTop", true) ) || 0;
+ offset.left -= parseFloat( jQuery.curCSS(elem, "marginLeft", true) ) || 0;
+
+ // Add offsetParent borders
+ parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], "borderTopWidth", true) ) || 0;
+ parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], "borderLeftWidth", true) ) || 0;
+
+ // Subtract the two offsets
+ return {
+ top: offset.top - parentOffset.top,
+ left: offset.left - parentOffset.left
+ };
+ },
+
+ offsetParent: function() {
+ return this.map(function() {
+ var offsetParent = this.offsetParent || document.body;
+ while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
+ offsetParent = offsetParent.offsetParent;
+ }
+ return offsetParent;
+ });
+ }
+});
+
+
+// Create scrollLeft and scrollTop methods
+jQuery.each( ["Left", "Top"], function( i, name ) {
+ var method = "scroll" + name;
+
+ jQuery.fn[ method ] = function(val) {
+ var elem = this[0], win;
+
+ if ( !elem ) {
+ return null;
+ }
+
+ if ( val !== undefined ) {
+ // Set the scroll offset
+ return this.each(function() {
+ win = getWindow( this );
+
+ if ( win ) {
+ win.scrollTo(
+ !i ? val : jQuery(win).scrollLeft(),
+ i ? val : jQuery(win).scrollTop()
+ );
+
+ } else {
+ this[ method ] = val;
+ }
+ });
+ } else {
+ win = getWindow( elem );
+
+ // Return the scroll offset
+ return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
+ jQuery.support.boxModel && win.document.documentElement[ method ] ||
+ win.document.body[ method ] :
+ elem[ method ];
+ }
+ };
+});
+
+function getWindow( elem ) {
+ return ("scrollTo" in elem && elem.document) ?
+ elem :
+ elem.nodeType === 9 ?
+ elem.defaultView || elem.parentWindow :
+ false;
+}
+// Create innerHeight, innerWidth, outerHeight and outerWidth methods
+jQuery.each([ "Height", "Width" ], function( i, name ) {
+
+ var type = name.toLowerCase();
+
+ // innerHeight and innerWidth
+ jQuery.fn["inner" + name] = function() {
+ return this[0] ?
+ jQuery.css( this[0], type, false, "padding" ) :
+ null;
+ };
+
+ // outerHeight and outerWidth
+ jQuery.fn["outer" + name] = function( margin ) {
+ return this[0] ?
+ jQuery.css( this[0], type, false, margin ? "margin" : "border" ) :
+ null;
+ };
+
+ jQuery.fn[ type ] = function( size ) {
+ // Get window width or height
+ var elem = this[0];
+ if ( !elem ) {
+ return size == null ? null : this;
+ }
+
+ return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window?
+ // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
+ elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
+ elem.document.body[ "client" + name ] :
+
+ // Get document width or height
+ (elem.nodeType === 9) ? // is it a document
+ // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
+ Math.max(
+ elem.documentElement["client" + name],
+ elem.body["scroll" + name], elem.documentElement["scroll" + name],
+ elem.body["offset" + name], elem.documentElement["offset" + name]
+ ) :
+
+ // Get or set width or height on the element
+ size === undefined ?
+ // Get width or height on the element
+ jQuery.css( elem, type ) :
+
+ // Set the width or height on the element (default to pixels if value is unitless)
+ this.css( type, typeof size === "string" ? size : size + "px" );
+ };
+
+});
+// Expose jQuery to the global object
+window.jQuery = window.$ = jQuery;
+
+})(window);
diff --git a/examples/lessons/6_Maths_AddSubtract/js/jquery.watermarkinput.js b/examples/lessons/6_Maths_AddSubtract/js/jquery.watermarkinput.js
new file mode 100755
index 0000000..fefa670
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/js/jquery.watermarkinput.js
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2007 Josh Bush (digitalbush.com)
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Version: Beta 1
+ * Release: 2007-06-01
+ */
+(function($) {
+ var map=new Array();
+ $.Watermark = {
+ ShowAll:function(){
+ for (var i=0;i<map.length;i++){
+ if(map[i].obj.val()==""){
+ map[i].obj.val(map[i].text);
+ map[i].obj.css("color",map[i].WatermarkColor);
+ }else{
+ map[i].obj.css("color",map[i].DefaultColor);
+ }
+ }
+ },
+ HideAll:function(){
+ for (var i=0;i<map.length;i++){
+ if(map[i].obj.val()==map[i].text)
+ map[i].obj.val("");
+ }
+ }
+ }
+
+ $.fn.Watermark = function(text,color) {
+ if(!color)
+ color="#aaa";
+ return this.each(
+ function(){
+ var input=$(this);
+ var defaultColor=input.css("color");
+ map[map.length]={text:text,obj:input,DefaultColor:defaultColor,WatermarkColor:color};
+ function clearMessage(){
+ if(input.val()==text)
+ input.val("");
+ input.css("color",defaultColor);
+ }
+
+ function insertMessage(){
+ if(input.val().length==0 || input.val()==text){
+ input.val(text);
+ input.css("color",color);
+ }else
+ input.css("color",defaultColor);
+ }
+
+ input.focus(clearMessage);
+ input.blur(insertMessage);
+ input.change(insertMessage);
+
+ insertMessage();
+ }
+ );
+ };
+})(jQuery); \ No newline at end of file
diff --git a/examples/lessons/6_Maths_AddSubtract/js/karma.js b/examples/lessons/6_Maths_AddSubtract/js/karma.js
new file mode 100755
index 0000000..03f027b
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/js/karma.js
@@ -0,0 +1,1018 @@
+/* Documentation Note:
+ * Public methods and properties are commented with /** some text *\/
+ * and private methods and properties are commented with //
+ *
+ * Please leave it that way to keep this documentation sane
+ */
+
+
+/*
+* Karma Framework
+* http://karmaeducation.org
+*
+* Copyright (c) 2009
+* Bryan W Berry bryan@olenepal.org
+* Felipe López Toledo zer.subzero@gmail.com
+*
+* Under MIT License:
+* Permission is hereby granted, free of charge, to any person
+* obtaining a copy of this software and associated documentation
+* files (the "Software"), to deal in the Software without
+* restriction, including without limitation the rights to use,
+* copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following
+* conditions:
+*
+* The above copyright notice and this permission notice shall be
+* included in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+/**
+* @fileOverview Contains karma library
+* @author Bryan Berry <bryan@olenepal.org>
+* @author Felipe Lopez Toledo <zer.subzero@gmail.com>
+*/
+
+
+//common.js modules use exports object
+if(!this.exports) {
+ exports = {};
+}
+
+
+
+/** Checks if the current document type is set to HTML 5, throws
+ * an error otherwise, then initializes the karma object and returns
+ * a reference to that object.
+ * @namespace Global namespace for Karma library
+ * @param {Object} [options={}] options for intializing Karma library
+ * @param {String} [options.locale=''] sets current locale Not Yet Implemented
+ * @param {Array} [options.image=[]] array of images to be converted into a collection
+ * @param {Array} [options.audio=[]] array of audio to be converted into a collection
+ * @param {Array} [options.video=[]] array of videos to be converted into a collection
+ * @param {Array} [options.svg=[]] array of SVG elements to be
+ * converted into a collection. Each SVG element must already exist in the html document
+ * @param {Array} [options.canvas=[]] array of canvas elements
+ * to be converted into a collection. Each canvas element must already exist in the
+ * html document and width and height of each element must be set as attributes
+ * @throws {Error} if the document type declaration is not set to HTML 5, e.g.
+ * <!DOCTYPE html>
+ * @throws {Error} If any of the initialization parameters are invalid values
+ * @returns {Object} Karma.karma -- reference to the initialized Karma library
+ * @example
+ *
+ * var k = Karma({
+ * image: [
+ * {name: "ninja", file: "ninja.png"},
+ * {name: "cowboy", file: "cowboy.png"}
+ * ],
+ * audio: [
+ * {name: "woosh", file: "woosh.ogg"},
+ * {name: "yeehaw", file: "yeehaw.ogg"}
+ * ],
+ * video: [
+ * {name: "attack", file: "attack.ogv"},
+ * {name: "ride", file: "ride.ogv"}
+ * ]
+ * canvas: [
+ * {name: "ninja", domId: "ninjaCanvas"},
+ * {name: "cowboy", domId: "cowboyCanvas"}
+ * ],
+ * svg: [
+ * {name: "ninja", domId: "ninjaSvg"},
+ * {name: "cowboy", domId: "cowboySvg"}
+ * ],
+ * });
+ * Next, call the ready function with a callback to your program code
+ *
+ * k.ready(function () { ... your application code . . . }
+ *
+ * after that you can access each asset like so
+ * k.image.ninja;
+ * k.svg.cowboy;
+ * k.audio.yeehaw.play();
+ * k.canvas.ninja.drawImage(k.image.ninja, 0, 0);
+ *
+ */
+var Karma = exports.Karma = function (options) {
+ Karma._isHtml5(document.doctype.nodeName);
+
+ if ( Karma.karma._initialized === true ) {
+ return Karma.karma;
+ } else {
+ return Karma.karma._init(options);
+ }
+};
+
+
+//helper functions
+
+/**This emulates the Object.create method in ecmascript 5 spec
+ * This isn't a full implementation as it doesn't support
+ * This has the same functionality as Crockford's beget method
+ * and this primary building block for prototypal inheritance in
+ * this library
+ * @param {Object} target that the new object's prototype should point to
+ * @returns {Object} object whose prototype points to target
+ * @example
+ *
+ * var ninja = { weapon : "sword" };
+ * var ninja1 = Karma.create(ninja);
+ * ninja1.sword === "sword"
+ */
+Karma.create = function (target){
+ function F () {};
+ F.prototype = target;
+ return new F();
+};
+
+/** Returns a shallow copy of the passed in object
+ * @param {Object} target to be copied
+ * @returns {Object} a shallow copy of target
+ */
+Karma.clone = function (target){
+ var copy = {};
+ for ( var i in target ) {
+ if(target.hasOwnProperty(i)){
+ copy[i] = target[i];
+ }
+ }
+ return copy;
+};
+
+/** Extends properties of the target object with those of
+ * the source object
+ * @param {Object} target object to be extended
+ * @param {Object} source whose properties will extend target
+ * @returns {Object} target extended by source
+ */
+Karma.objectPlus = function (target, source){
+ for ( var i in source){
+ if (source.hasOwnProperty(i)){
+ target[i] = source[i];
+ }
+ }
+ return target;
+};
+
+/** Creates a new object that is a prototype of the first argument
+ * then extends it with the properties of the second argument
+ * @param {Object} parent1 will be prototype of returned object
+ * @param {Object} parent2 will extend properties of returned object
+ * @returns {Object} object that whose prototype is parent1 and has
+ * been extended with properties of parent2
+ */
+Karma.copyObjectPlus = function (parent1, parent2){
+ function F () {};
+ F.prototype = parent1;
+ var G = new F();
+ return Karma.objectPlus(G, parent2);
+};
+
+//Enables function chaining for a specified list of function names
+//IMPORTANT: use of closures here with "this" and "that" is __very__
+//complicated here
+Karma._makeChain = function (chainingFunctions) {
+ var that = this;
+ var _chainFunction = function ( name ){
+ that[ name ] = function ( ){
+ var type = typeof this.ctx[name];
+ if ( type === "function") {
+ this.ctx[ name ].apply( this.ctx, arguments );
+ }else if ( type === "string" ){
+ this.ctx[ name ] = arguments[0];
+ }else {
+ throw ("wtf?!: impossible to chain " + name + "!");
+ }
+ return this;
+ };
+ };
+
+ for (var i = 0; i < chainingFunctions.length; i++){
+ _chainFunction( chainingFunctions[ i ] );
+ }
+};
+
+//Throws big ugly error if doctype isn't html5
+Karma._isHtml5 = function (doctype){
+ var regex = new RegExp('^html$', 'i');
+ if(!regex.test(doctype)){
+ var errorMsg = "ERROR: The doctype must be set to <!DOCTYPE html> " +
+ "in order to use Karma. Karma require you use html5";
+ var errorElem = document.createElement('div');
+ errorElem.setAttribute('id', 'errorDoctype');
+ errorElem.innerText = errorMsg;
+ document.body.appendChild(errorElem);
+ throw new Error(errorMsg);
+ }
+};
+
+
+/** Stores global settings for the Karma library
+ * @class This object stores the global settings for the Karma library
+ */
+Karma.karma = {
+ /** This is the global locale as passed to Karma(),
+ * such as "en", "es_SP"
+ * @type string
+ * @default undefined
+ */
+ locale : undefined,
+ /** Collection of images with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ image : {},
+ /** Collection of audio with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ audio : {},
+ /** Collection of canvas with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ canvas : {},
+ /** Collection of svgs with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ svg : {},
+ /** Collection of videos with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ video : {},
+ _localized : false,
+ _assetPath : "assets/",
+ _localePath : "",
+ _initialized : false,
+ _statusDiv: undefined,
+ _loaderDiv : undefined,
+ _counters : { total : 0, errors : 0, loaded : 0},
+
+ //init initializes all the assets passed to Karma, that's it
+ //it returns 'this' so it can be used for function chaining
+ _init: function(options) {
+ this._initialized = true;
+
+ //set up message that show count of assets loaded
+ //and has an ordered list to append error messages to
+ var _statusDiv = this._statusDiv = document.createElement('div');
+ this._loaderDiv = this._loaderDiv = document.createElement('div');
+ var errorList = document.createElement('ol');
+
+ _statusDiv.setAttribute('id', 'karma-status');
+ _statusDiv.setAttribute('style', 'position:absolute;');
+ _statusDiv.innerHTML = 'Karma is loading ...';
+ this._loaderDiv.setAttribute('id', 'karma-loader');
+ this._loaderDiv.setAttribute('class', 'status');
+ errorList.setAttribute('id', 'errorList');
+
+ _statusDiv.appendChild(this._loaderDiv);
+ this._statusDiv.appendChild(errorList);
+ document.body.appendChild(_statusDiv);
+
+
+ //chain the functions for kCanvas and kSvg
+ Karma._makeChain.call(Karma.kCanvas,
+ Karma.kCanvas._chainingFunctions);
+ //Karma._makeChain.apply(Karma.kSvg, Karma.kSvg._chainingFunctions);
+
+
+
+ //regular expression that matches the name of aprivate property
+ // the karma object
+ var regexPrivate = new RegExp('^_.*');
+
+ for ( var option in options ) {
+ if (options.hasOwnProperty(option)){
+ if (option === "image" || option === "audio" || option ===
+ "svg" || option === "video" || option === "canvas"){
+
+ if(!(options[option] instanceof Array)){
+ throw new Error("" + option + " must be an array");
+ } else if (options[option].length === 0){
+ continue;
+ }
+ } else if (regexPrivate.test(option)){
+ //don't overwrite a private property of karma object
+ continue;
+ }
+
+ switch (option){
+ case "locale":
+
+ if (this._isValidLocale(options[option])){
+ this.locale = this._normalizeLocale(options[option]);
+ this._localized = true;
+ this._localePath = Karma._computeLocalePath(this.locale);
+ } else {
+ throw new Error("locale provided to karma._init() is invalid");
+ }
+
+ break;
+ case "image":
+ options[option]._type = 'image';
+ Karma._makeImages(options[option]);
+ break;
+ case "audio":
+ options[option]._type = 'audio';
+ Karma._makeAudio(options[option]);
+ break;
+ case "video":
+ options[option]._type = 'video';
+ Karma._makeVideos(options[option]);
+ break;
+ case "svg":
+ options[option]._type = 'svg';
+ Karma._makeSvgs(options[option]);
+ break;
+ case "canvas":
+ options[option]._type = 'canvas';
+ Karma._makeCanvases(options[option]);
+ break;
+ }
+ }
+ }
+
+
+
+ return this;
+ },
+
+ /** Waits until all assets loaded, i.e. ready, then calls callback
+ * @param {Function} [cb] callback function
+ * @returns this
+ * @throws {Error} if Karma.karma is not initialized with the
+ * Karma({ options }) function
+ * @example
+ *
+ * var k = Karma({ . . . your assets here . . . });
+ * k.ready(function(){ .. your code here . . .});
+ *
+ * your code will not be called until all assets have been loaded
+ *
+ */
+ ready : function( cb ) {
+ var that = this;
+ if (Karma.karma._initialized !== true){
+ throw new Error("Karma.karma not initialized");
+ }
+
+ if (this._counters.loaded !== this._counters.total){
+ setTimeout(function(){ that.ready(cb);}, 5);
+ } else if (cb) {
+ //hide the "Karma is loading..." message
+ this._statusDiv.setAttribute('style', 'display:none;');
+
+ cb();
+ } else if (!cb) {
+ //hide the "Karma is loading..." message
+ this._statusDiv.setAttribute('style', 'display:none;');
+
+ //if no options passed, show it works message
+ this._showStarterMessage();
+ }
+
+
+
+
+ return this;
+ },
+
+ //Display Apache-like "It works" message if no options
+ _showStarterMessage : function (){
+ var starterMsg = document.createElement('div');
+ starterMsg.setAttribute('id', 'starterMsg');
+ starterMsg.innerHTML = "<h1>It Works</h1>";
+ document.body.appendChild(starterMsg);
+ },
+
+ //Updates visible counter of how many assets are loaded
+ _updateStatus : function (errorMsg) {
+ var loaded = this._counters.loaded;
+ var total = this._counters.total;
+ var errors = this._counters.errors;
+ this._loaderDiv.innerHTML = "Loaded " + loaded + " / " + total +
+ "" + (errors > 0 ? " Errors [ " + errors +" ]" : '');
+ if (errorMsg) {
+ var liError = document.createElement('li');
+ liError.innerHTML = errorMsg;
+ var errorList = document.getElementById('errorList');
+ errorList.appendChild(liError);
+ }
+ },
+
+ //matches 2 letter country code then optionally
+ //a dash or underscore followed by a country or language identifier
+ //i currently only allow a language identifier 2-3 chars long
+ _isValidLocale : function (locale) {
+ var localeRegex = new RegExp('^[a-zA-Z][a-zA-Z]([-_][a-zA-z]{2,3})?$');
+ return localeRegex.test(locale);
+ },
+
+ _normalizeLocale : function(locale) {
+ var lang = "";
+ var country = "";
+ var divider = "";
+
+ lang = locale.slice(0, 2).toLowerCase();
+ divider = "_";
+ country = locale.slice(3, 6).toUpperCase();
+
+ return locale.length > 2 ? "" + lang + divider + country : lang;
+ },
+
+ // Below are geometry and math helper methods
+
+ /**
+ * Converts a value from degrees to radians.
+ * @param {Number} angle The angle in degrees
+ * @returns {Number} The angle in radians
+ */
+ radians : function( angle ){
+ return ( angle / 180 ) * Math.PI;
+ },
+ /**
+ * Gets the square of the Euclidian (ordinary) distance between 2 points.
+ * @param {Object} Point No. 0
+ * @param {Number} Point0.x
+ * @param {Number} Point0.y
+ * @param {Object} Point No. 1
+ * @param {Number} Point1.x
+ * @param {Number} Point1.y
+ * @returns {Number} The square of the Euclidian distance
+ * @example
+ *
+ * p0 = {x:0, y:1};
+ * p1 = {x:50, y:70};
+ * var d = distance2(p0, p1);
+ *
+ */
+ distance2 : function ( p0, p1 ) {
+ return (p1.x - p0.x) * (p1.x - p0.x) + (p1.y - p1.y) * (p1.y - p1.y);
+ },
+ /**
+ * Gets the Euclidian (ordinary) distance between 2 points.<br>
+ * <b>Warning:</b> It's slower than distance2 function
+ * @param {Object} Point No. 0
+ * @param {Number} Point0.x
+ * @param {Number} Point0.y
+ * @param {Object} Point No. 1
+ * @param {Number} Point1.x
+ * @param {Number} Point1.y
+ * @returns {Number} The Euclidian distance
+ * @example
+ *
+ * p0 = {x:0, y:1};
+ * p1 = {x:50, y:70};
+ * var d = distance2(p0, p1);
+ *
+ */
+ distance : function ( p0, p1 ) {
+ return Math.sqrt( this.distance2( p0, p1 ) );
+ },
+ /** Returns a random number within the range provided
+ * @param {Number} lower limit of the range, lowest number that can be returned
+ * @param {Number} upper limit of the range, highest number that can be returned
+ * @returns {Number} number that is >= lower and <= upper
+ * @example
+ *
+ * var num = rand(0, 10);
+ *
+ * num could be 0, 1, 2, 3 ... or 10
+ *
+ */
+ rand : function ( lower, upper ){
+ return Math.round( Math.random() * (upper - lower) + lower );
+ }
+
+};
+
+/** Prototypal object for images, videos, and audio files but
+ * does not include svg or canvas elements
+ * @class This object is the prototype for images, videos, and audio files but
+ * does not include svg or canvas elements
+ * @ throws {Error} if the individual asset is set to be localized but
+ * the globale locale is not set on the Karma.karma object
+ * @ throws {Error} if the name and file properties are not supplied
+ * @example
+ * kMedia is the prototype object for images, audio, and videos.
+ * These 'media' assets are loaded in a distinctly different way
+ * from the canvas or svg assets. They also have distinctly different
+ * helper methods
+ *
+ * You initialize the kMedia assets by passing an array of objects
+ */
+Karma.kMedia = {
+ /** file location of asset
+ * @type String
+ * @default ""
+ */
+ file : "",
+ /** media object
+ * @type Audio|Image|Video
+ * @default undefined
+ */
+ media : undefined,
+ //actual path to the file
+ _path : "",
+ //if using localized version of this asset
+ _localized : false,
+ //audio, image, or video
+ _type : "",
+ //initializes kMedia instance with values provided by user
+ _init : function (asset) {
+ asset._localized = asset._localized || false;
+ Karma.karma._counters.total++;
+
+ if (asset.name === undefined || asset.file === undefined){
+ throw new Error("properties name and file have to be defined");
+ } else {
+ this.name = asset.name;
+ this.file = asset.file;
+ }
+
+ //_type is a private variable used internally
+ if (asset._type === undefined){
+ throw new Error("the _type property must be set. " +
+ "Blame the karma library authors as this is an internal value");
+ } else {
+ if (Karma._isValidType(asset._type)){
+ this._type = asset._type;
+ switch ( this._type ) {
+ case "image": this.media = new Image();
+ break;
+ case "audio": this.media = new Audio();
+ break;
+ //case "video":
+ //NYI
+ //this.media = new Video();
+ break;
+ default: throw new Error("Media type not supported");
+ }
+
+ } else {
+ throw new Error("the _type property supplied is invalid. " +
+ "Blame the karma library authors as this is an internal value");
+ }
+ }
+
+ if(Karma._isLocalized(asset._localized)){
+ this._localized = asset._localized;
+ this._path = Karma.karma._localePath +
+ this._type + "/";
+ } else {
+ this._path = Karma.karma._assetPath +
+ this._type + "/";
+ }
+
+
+ //IMPORTANT: This one magic line loads the file
+ this.media.src = this.src = this._path + this.file;
+
+ //add event handlers
+ this._addEventHandlers();
+
+ if (this._type === "audio"){
+ this.media.autobuffer = true;
+ this.media.load();
+ }
+
+
+ return this;
+ },
+ //Adds event handlers to update the counters when
+ //the asset is successfully or unsuccessfully loaded
+ _addEventHandlers : function () {
+ var that = this;
+ var loadEvent = "load";
+ //Browser Hack recommended by chromium devs
+ //http://code.google.com/p/chromium/issues/detail?id=20251&q=loading%20audio&colspec=ID%20Stars%20Pri%20Area%20Type%20Status%20Summary%20Modified%20Owner%20Mstone%20OS#c4
+ if (this._type === "audio" || this._type === "video"){
+ loadEvent = "canplaythrough";
+ }
+
+ that.media.addEventListener(
+ loadEvent,
+ function (e) {
+ Karma.karma._counters.loaded++;
+ Karma.karma._updateStatus();
+ that.status = "loaded";}, false);
+
+ that.media.addEventListener(
+ "error",
+ function (e) {
+ Karma.karma._counters.errors++;
+ that.status = "error";
+ var errorMsg = "Error: " + that._type.toUpperCase() +
+ " " + that.name + " cannot be loaded.";
+ Karma.karma._updateStatus(errorMsg);
+ },
+ false);
+ that.media.addEventListener(
+ "abort",
+ function (e) {
+ Karma.karma._counters.total++;
+ that.status = "aborted";
+ var errorMsg = "ABORT: " + that._type.toUpperCase() +
+ " " + that.name + " loading was aborted.";
+ Karma.karma._updateStatus(errorMsg);
+
+ }, false);
+
+ }
+
+};
+
+//determine if it is a valid type of asset
+Karma._isValidType = function (type){
+ return type === "image" ||
+ type === "svg" ||
+ type === "audio" ||
+ type === "video" ||
+ type === "canvas";
+};
+
+Karma._isLocalized = function (boolLocalized) {
+ if (typeof boolLocalized === "boolean" ) {
+ if(boolLocalized === true &&
+ Karma.karma.locale === undefined){
+ throw new Error("You cannot localize a media asset" +
+ " if the global locale for Karma isn't set");
+ } else {
+ return boolLocalized;
+ }
+ } else if (typeof boolLocalized === undefined){
+ return false;
+ } else{
+ throw new Error("This is not a valid value for the localized option");
+ }
+};
+
+Karma._computeLocalePath = function(locale) {
+ return Karma.karma._assetPath + locale + "/";
+};
+
+Karma._makeImages = function (imgConfigs){
+ var makeImage = function (imgConfig){
+ var image = undefined;
+ imgConfig._type = "image";
+ image = Karma.create(Karma.kMedia)._init(imgConfig);
+ Karma.karma.image[imgConfig.name] = image;
+ };
+
+ imgConfigs.forEach(function(imgConfig){ makeImage(imgConfig);});
+
+};
+
+Karma._makeAudio = function (audioConfigs){
+ var makeAudio = function (audioConfig){
+ var audio = undefined;
+ audioConfig._type = "audio";
+ audio = Karma.create(Karma.kMedia)._init(audioConfig);
+ audio.play = function () {
+ //hack to fix the audio "stuttering" problem
+ //more info: https://bugs.launchpad.net/karma/+bug/426108
+ this.media.currentTime = 0.1;
+ this.media.play();
+ };
+ Karma.karma.audio[audioConfig.name] = audio;
+ };
+
+ audioConfigs.forEach(function(audioConfig){ makeAudio(audioConfig);});
+
+};
+
+
+Karma._makeCanvases = function (canvasConfigs){
+ var makeCanvas = function (canvasConfig){
+ var canvas = undefined;
+ canvas = Karma.create(Karma.kCanvas)._init(canvasConfig);
+ Karma.karma.canvas[canvasConfig.name] = canvas;
+ };
+
+ canvasConfigs.forEach(function(canvasConfig){ makeCanvas(canvasConfig);});
+
+};
+
+/** Prototypal object for each canvas element submitted to Karma in the
+ * Karma() method
+ * @throws {Error} if the name and domId for the canvas element are not specified
+ * @thows {Error} if the supplied domId does not match an element in the DOM
+ * @class This object is the prototype for each canvas element submitted to Karma in the
+ * Karma() method
+ */
+Karma.kCanvas = {
+ /** Name of the canvas, used internally by karma.js
+ * @type String
+ * @default ''
+ */
+ name : '',
+ /** Width of canvas element
+ * @type Number
+ * @default 0
+ */
+ width: 0,
+ /** Height of canvas element
+ * @type Number
+ * @default 0
+ */
+ height: 0,
+ /** Whether canvas is visible
+ * @type boolean
+ * @default true
+ */
+ visible: true,
+ /** Element ID for canvas element in html document
+ * @type String
+ * @default undefined
+ */
+ domId: undefined,
+ /** Reference to the DOM element
+ * @type DOMElement
+ * @default undefined
+ */
+ node: undefined,
+ /** The 2 Dimensional Rendering context property for this canvas
+ * @type 2DRenderingContext
+ * @default undefined
+ */
+ ctx: undefined,
+ /** Frames Per Second, I don't know what the purpose of this is,
+ * Felipe made it up
+ * @type Number
+ * @default 24
+ */
+ fps: 24,
+
+ //initializes object with values provides by user
+ _init: function (config) {
+ for (var option in config){
+ if (config.hasOwnProperty(option)){
+ switch (option){
+ case "name":
+ this.name = config[option];
+ break;
+ case "domId":
+ this.domId = config[option];
+ break;
+ case "width":
+ if(!this.height){
+ throw new Error("If you specify a width you must also" +
+ "specify a height");
+ }
+ this.width = config[option];
+ break;
+ case "height":
+ if(!this.width){
+ throw new Error("If you specify a height you must also" +
+ "specify a width");
+ }
+ this.height = parseInt(config.option, 10);
+ break;
+ case "fps":
+ this.fps = parseInt(config.option, 10);
+ break;
+ }
+ }
+ }
+
+ if(this.domId && document.getElementById(this.domId)){
+ this.node = document.getElementById(this.domId);
+ this.ctx = this.node.getContext('2d');
+ } else {
+ throw new Error('you must specify a valid domId that' +
+ 'is in your html page');
+ }
+
+ if(!config.height && !config.width){
+ this.width = parseInt(this.node.getAttribute('width'), 10);
+ this.height = parseInt(this.node.getAttribute('height'), 10);
+ }
+
+ return this;
+ },
+ /** Clear area of canvas element specified by parameters, if no
+ * parameters supplied, clears entire canvas
+ * @param {Number} [x=0] x coordinate, defaults to zero if left blank
+ * @param {Number} [y=0] y coordinate, defaults to zero if left blank
+ * @param {Number} [width=0] width of area to be cleared, defaults
+ * entire width of canvas
+ * @param {Number} [height=0] height of area to be cleared, defaults
+ * entire height of canvas
+ * @returns this
+ * @example
+ *
+ * k.canvas.ninja.clear();
+ * // clears the entire ninja canvas
+ *
+ * k.canvas.ninja.clear(0, 10, 20, 30);
+ * //clears a specific portion of the ninja canvas
+ *
+ */
+ clear : function ( x, y, width, height ) {
+ var that = this;
+ that.ctx.clearRect(
+ x || 0,
+ y || 0,
+ width || that.width,
+ height || that.height
+ );
+ return that;
+ },
+
+ //These are all properties or methods of the canvas element's
+ //2 dimensional context
+ _chainingFunctions : [
+ "globalAlpha", "globalCompositeOperation", "lineWidth", "lineCap",
+ "lineJoin", "miterLimit", "font", "textAlign", "textBaseline", "save",
+ "restore", "scale", "rotate", "translate", "transform", "setTransform",
+ "clearRect", "fillRect", "strokeRect", "beginPath", "closePath",
+ "moveTo", "lineTo", "quadraticCurveTo", "bezierCurveTo", "arcTo",
+ "arc", "rect", "fill", "stroke", "clip", "fillText", "strokeText",
+ "measureText", "isPointInPath", "strokeStyle", "fillStyle",
+ "createLinearGradient", "createRadialGradient", "createPattern",
+ "shadowOffsetX", "shadowOffsetY", "shadowBlur", "shadowColor",
+ //"mozTextStyle", "mozDrawText", "mozMeasureText", "mozPathText",
+ "mozTextAlongPath", "drawImage", "getImageData", "putImageData",
+ "createImageData", "drawWindow"
+ ]
+};
+
+
+
+Karma._makeSvgs = function (svgConfigs){
+ var makeSvg = function (svgConfig){
+ var svg = undefined;
+ svg = Karma.create(Karma.kSvg)._init(svgConfig);
+ Karma.karma.svg[svgConfig.name] = svg;
+ };
+
+ svgConfigs.forEach(function(svgConfig){ makeSvg(svgConfig);});
+
+};
+
+/** Prototypal object for each svg element submitted to Karma in the
+ * Karma() method
+ * @throws {Error} if the name and domId for the svg element are not specified
+ * @thows {Error} if the supplied domId does not match an element in the DOM
+ * @class This object is the prototype for each svg element submitted to Karma in the
+ * Karma() method
+ */
+Karma.kSvg = {
+ /** name of instance, used internally
+ * @typeof string
+ * @default ""
+ */
+ name : "",
+ /** width of element
+ * @type number
+ * @default 0
+ */
+ width: 0,
+ /** height of element
+ * @type number
+ * @default 0
+ */
+ height: 0,
+ /** Status of element, either "loaded" or "error"
+ * @type string
+ * @default ""
+ */
+ status: "",
+ /** Whether canvas is visible
+ * @type boolean
+ * @default true
+ */
+ visible: true,
+ /** Element ID for canvas element in html document
+ * @type String
+ * @default undefined
+ */
+ domId: undefined,
+ /** Reference to the DOM element
+ * @type DOMElement
+ * @default undefined
+ */
+ node: undefined,
+ /** Reference to the SVGDocument
+ * @type SVGDocument
+ * @default undefined
+ */
+ doc: undefined,
+ /** Reference to the root element of the SVG Document
+ * @type DocumentElement
+ * @default undefined
+ */
+ root: undefined,
+ _localized : undefined,
+ _chainingFunctions: [],
+ _init: function (config) {
+ Karma.karma._counters.total++;
+
+ for (var option in config){
+ if (config.hasOwnProperty(option)){
+ switch (option){
+ case "name":
+ this.name = config[option];
+ break;
+ case "domId":
+ this.domId = config[option];
+ break;
+ case "width":
+ if(!this.height){
+ throw new Error("If you specify a width you must also" +
+ "specify a height");
+ }
+ this.width = parseInt(config[option], 10);
+ break;
+ case "height":
+ if(!this.width){
+ throw new Error("If you specify a height you must also" +
+ "specify a width");
+ }
+ this.height = config[option];
+ break;
+ case "fps":
+ this.fps = config[option];
+ break;
+ }
+ }
+ }
+
+ if(this.domId && document.getElementById(this.domId)){
+ this.node = document.getElementById(this.domId);
+ } else {
+ throw new Error('you must specify a valid domId that' +
+ 'is in your html page');
+ }
+
+ if(!config.height && !config.width){
+ this.width = parseInt(this.node.getAttribute('width'), 10);
+ this.height = parseInt(this.node.getAttribute('height'), 10);
+ }
+
+ var that = this;
+ that._addEventHandlers();
+
+ return this;
+
+
+ },
+ _addEventHandlers : function () {
+ var that = this;
+ that.doc = that.node.getSVGDocument();
+ that.node.addEventListener(
+ "load",
+ function (e) {
+ that.doc = that.node.getSVGDocument();
+ that.root = that.doc.documentElement;
+ Karma.karma._counters.loaded++;
+ Karma.karma._updateStatus();
+ that.status = "loaded";
+ }, false);
+
+ that.node.addEventListener(
+ "error",
+ function (e) {
+ Karma.karma._counters.loaded--;
+ Karma.karma._counters.errors++;
+ that.status = "error";
+ var errorMsg = "Error: " + that._type.toUpperCase() +
+ " " + that.name + " cannot be loaded.";
+ Karma.karma._updateStatus(errorMsg);
+ },
+ false);
+ that.node.addEventListener(
+ "abort",
+ function (e) {
+ that.status = "aborted";
+ var errorMsg = "ABORT: " + that._type.toUpperCase() +
+ " " + that.name + " loading was aborted.";
+ Karma.karma._updateStatus(errorMsg);
+
+ }, false);
+
+ }
+};
+
+Karma._makeVideos = function (video){
+
+};
diff --git a/examples/lessons/6_Maths_AddSubtract/js/lesson.js b/examples/lessons/6_Maths_AddSubtract/js/lesson.js
new file mode 100755
index 0000000..9668719
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/js/lesson.js
@@ -0,0 +1,301 @@
+$(document).ready(function(){
+ var k = Karma({
+ audio: [{'name':'correct','file':'correct.wav'},
+ {'name':'incorrect','file':'incorrect.wav'},
+ ]});
+
+ k.ready(function(){
+ var i,j,s,t;
+ var checked;
+ var TOTAL_QUES = 16;
+ var TOTAL_LEVEL = 3;
+ var currentLevel;
+ var click1Counter;
+ var click2Counter;
+ var correctAns;
+ var flag_correct;
+ var flag_start = 0; //for play again but not to throw error
+ var totalCounter;
+ var correctCounter;
+ var randNumbers = [];
+ var randImg = [];
+ var signs = ['+','-'];
+ var correctSigns = []; //array to store the correct signs
+
+ var nepaliNumbers = ['०','१','२','३','४','५','६',' ७','८','९'];
+ var scoreboard = $('#score_box').scoreboard({'layout':'horizontal',
+ 'winningScore': TOTAL_QUES});
+ var clickValues = []; //store the clicks couting index 0 for click 1st and index 1 for 2nd clickbox
+
+ var checkTime = function(timePara){
+ if (timePara<10 ){
+ timePara="00" + timePara;
+ }
+ else if (timePara<100 ){
+ timePara="0" + timePara;
+ }
+ return timePara;
+ };
+
+ var stopTimer = function(){
+ s = 0;
+ clearTimeout(t);
+ };
+ var startTimer = function(){
+ s = 0;
+ s=checkTime(s);
+ $('#timerBox1').html(s);
+ increaseTime();
+ };
+
+
+ var increaseTime = function(){
+ s++;
+ s=checkTime(s);
+ $('#timerBox1').html(s);
+ if(s === 300){
+ play = 0;
+ $('#gameInformation').html('!!! फेरी खेलौ बटन मा क्लिक गर !!! ');
+ }else{
+ t=setTimeout(function(){increaseTime();},1000);
+ }
+
+ };
+
+ var genRandImages=function (){correctCounter = 0;
+ randImg[0] = k.rand(0,TOTAL_QUES-1);
+ for(i=1; i<TOTAL_QUES; i++){
+ do{
+ flag = 0;
+ randImg[i] = k.rand(0,TOTAL_QUES-1);
+ for(j=0; j<i; j++){
+ if(randImg[i] === randImg[j]){
+ flag++;
+ }
+ }
+ }while(flag != 0 ); //end of do while loop
+ }
+ };
+
+ var convertIntoNepali = function(num){ //convert the english number sent as string to Nepali
+ var convertedNum = '';
+ for(i = 0;i<num.length;i++){
+ convertedNum += nepaliNumbers[num[i]];
+ }
+ return convertedNum;
+ };
+
+
+ var nextQuestion = function(){
+ flag_correct = 1;
+ var num1,num2,num3;
+ clickValues = [0,0];
+ click1Counter = 0;
+ click2Counter = 0;
+ $('#questionInfo').html('').append('<div id="checkAnswer"></div>');
+ $('#questionInfo').append('<div id="number1" class="numberBox"></div>');
+ $('#questionInfo').append('<div id="click0" class="clickBox yellow"></div>');
+ $('#questionInfo').append('<div id="number2" class="numberBox"></div>');
+ $('#questionInfo').append('<div id="click1" class="clickBox yellow"></div>');
+ $('#questionInfo').append('<div id="number3" class="numberBox"></div>');
+ $('#questionInfo').append('<div id="equals" class="numberBox"></div>');
+ $('#questionInfo').append('<div id="total" class="numberBox"></div>');
+ $('.clickBox').append('#');
+ $('#equals').append('=');
+
+ //Generate 3 random numbers
+
+ var startNum; //1-10 for level 1 1-20 for level 2 and 1-30 for level 3
+ var endNum; //Variables for the level numbers to set the difficulty levels
+
+ startNum = (currentLevel+1);
+ endNum = (currentLevel+1)*10;
+
+ num1 = k.rand(startNum,endNum);
+ num2 = k.rand(startNum,endNum);
+ num3 = k.rand(startNum,endNum);
+
+ var total;
+ var randSign;
+ do{
+ randSign = k.rand(0,1);
+ correctSigns[0] = signs[randSign];
+ if(randSign === 0){
+ total = num1 + num2;
+ }
+ else{
+ total = num1 - num2;
+ }
+ randSign = k.rand(0,1);
+ correctSigns[1] = signs[randSign];
+ if(randSign === 0){
+ total = total+num3;
+ }
+ else{
+ total = total-num3;
+ }
+ }while(total < 0);
+ correctAns = total;
+ // alert(num1 +' '+signs[randSign]+ num2 +' '+signs[randSign]+' '+num3 +' = '+ num1+signs[randSign]+num2);
+
+ $('#number1').append(convertIntoNepali(''+num1+''));
+ $('#number2').append(convertIntoNepali(''+num2+''));
+ $('#number3').append(convertIntoNepali(''+num3+''));
+
+ $('#total').append(convertIntoNepali(''+total+''));
+
+ $('.clickBox').click(function(){
+ var clickedBox = $(this).attr('id');
+ var clickId = parseInt(clickedBox.substring(5));
+ if(click1Counter === 2){
+ click1Counter = 0;
+ }
+ if(click2Counter === 2){
+ click2Counter = 0;
+ }
+
+ if(clickId === 0){
+ clickValues[clickId] = click1Counter;
+ if(click1Counter === 0){
+ $(this).html('+');
+ }else{
+ $(this).html('-');
+ }
+ click1Counter++;
+ }
+ else{
+ clickValues[clickId] = click2Counter;
+ if(click2Counter === 0){
+ $(this).html('+');
+ }else{
+ $(this).html('-');
+ }
+ click2Counter++;
+ }
+ });
+ levelControl();
+ };
+
+ var startLevel = function(){
+ checked = 0;
+ scoreboard.scoreboard('reset');
+ genRandImages();
+ stopTimer();
+ startTimer();
+ level = currentLevel+1;
+ totalCounter = 0;
+ correctCounter = 0;
+ $('#content').html('').append('<div id="imageDisplayBox"></div>');
+ for(var i = 0; i< TOTAL_QUES; i++){
+ $('#imageDisplayBox').append('<div id="img'+i+'"></div>');
+ $('#img'+i).html('<img class="float-left" src="assets/image/level'+level+'Img'+i+'.png" />').html(''); //preloads the images
+ $('#img'+i).addClass('default');
+ }
+
+ $('#content').append('<div id="questionSection"></div>');
+ $('#questionSection').append('तलका कोठामा "+" वा "-" जुन ठिक हुन्छ राख र "पक्का हो" थिच । ');
+ $('#questionSection').append('<div id="questionInfo"></div>');
+ $('#content').append('<div id="levelShow"></div>');
+ $('#levelShow').append('<img id="levelUp" class="levelImages" src="assets/image/levelUp.png"/>');
+ $('#levelShow').append('<div class="levelText">तह '+convertIntoNepali(''+level+'')+'</div>');
+ $('#levelShow').append('<img id="levelDown" class="levelImages" src="assets/image/levelDown.png"/>');
+ $('#content').append('<div id="gameInformation"></div>');
+ $('#gameInformation').html('');
+ nextQuestion();
+ };
+
+
+ function game(){
+ currentLevel = 0;
+ startLevel();
+ };
+
+ var delayShow = function(){
+ document.delayForm.delayval.value = 1;
+ $('#checkAnswer').html('');
+ if(checked === 1 && currentLevel <3){
+ currentLevel++;
+ startLevel();
+ }else if(checked === 0){
+ nextQuestion();
+ }
+ };
+
+ function levelControl(){
+ $('.levelImages').click(function(){
+ var clickedLevel = $(this).attr('id');
+ var clickedLevel = clickedLevel.substring(5);
+ if(clickedLevel === 'Up'){
+ if(currentLevel != 2){
+ currentLevel++;
+ startLevel();
+ }
+ }else{
+ if(currentLevel != 0){
+ currentLevel--;
+ startLevel();
+ }
+ }
+ });
+ }
+
+ $('#linkCheck').click(function(){
+ var signFst = $('#click0').text();
+ var sign2nd = $('#click1').text();
+ if(signFst === correctSigns[0] && sign2nd === correctSigns[1]){
+ k.audio.correct.play();
+ $('#checkAnswer').html('<img src="assets/image/correct.png" />');
+ $('#img'+randImg[totalCounter]).html('<img class="float-left" src="assets/image/level'+level+'Img'+randImg[totalCounter]+'.png" />')
+ if(flag_correct === 1){
+ scoreboard.scoreboard('inc');
+ correctCounter++;
+ }
+ }
+ else{
+ $('#checkAnswer').html('<img src="assets/image/incorrect.png" />');
+ k.audio.incorrect.play();
+ flag_correct = 0;
+ }
+ scoreboard.scoreboard('incTotal');
+ totalCounter++;
+
+ if(totalCounter === TOTAL_QUES){
+ $('#checkAnswer').html('');
+ if(correctCounter === totalCounter){
+ $('#gameInformation').html('!!! बधाई छ तिमीले सबै प्रश्नको जवाफ दियौ !!! ');
+ checked = 1;
+ }else{
+ $('#gameInformation').html('!!! फेरी खेलौ बटन मा क्लिक गर !!! ');
+ checked = 2;
+ }
+ stopTimer();
+ }
+ t=setTimeout(function(){delayShow();},1000);
+
+
+
+
+ });
+
+ $('#linkHelp').mouseover(function(){
+ $('#help').slideDown(2000);
+ })
+ .mouseout(function(){
+ $('#help').slideUp(2000);
+ });
+
+ $('#linkStart').click(function(){
+ flag_start = 1;
+ game();
+ });
+
+ $('#linkPlayAgain').click(function(){
+ if(flag_start === 1){
+ startLevel();
+ }
+ });
+
+ }); //end of k.ready
+}); //end of document.read
+
+
diff --git a/examples/lessons/6_Maths_AddSubtract/js/ui.core.js b/examples/lessons/6_Maths_AddSubtract/js/ui.core.js
new file mode 100755
index 0000000..5493e0a
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/js/ui.core.js
@@ -0,0 +1,519 @@
+/*
+ * jQuery UI 1.7.2
+ *
+ * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * http://docs.jquery.com/UI
+ */
+;jQuery.ui || (function($) {
+
+var _remove = $.fn.remove,
+ isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9);
+
+//Helper functions and ui object
+$.ui = {
+ version: "1.7.2",
+
+ // $.ui.plugin is deprecated. Use the proxy pattern instead.
+ plugin: {
+ add: function(module, option, set) {
+ var proto = $.ui[module].prototype;
+ for(var i in set) {
+ proto.plugins[i] = proto.plugins[i] || [];
+ proto.plugins[i].push([option, set[i]]);
+ }
+ },
+ call: function(instance, name, args) {
+ var set = instance.plugins[name];
+ if(!set || !instance.element[0].parentNode) { return; }
+
+ for (var i = 0; i < set.length; i++) {
+ if (instance.options[set[i][0]]) {
+ set[i][1].apply(instance.element, args);
+ }
+ }
+ }
+ },
+
+ contains: function(a, b) {
+ return document.compareDocumentPosition
+ ? a.compareDocumentPosition(b) & 16
+ : a !== b && a.contains(b);
+ },
+
+ hasScroll: function(el, a) {
+
+ //If overflow is hidden, the element might have extra content, but the user wants to hide it
+ if ($(el).css('overflow') == 'hidden') { return false; }
+
+ var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop',
+ has = false;
+
+ if (el[scroll] > 0) { return true; }
+
+ // TODO: determine which cases actually cause this to happen
+ // if the element doesn't have the scroll set, see if it's possible to
+ // set the scroll
+ el[scroll] = 1;
+ has = (el[scroll] > 0);
+ el[scroll] = 0;
+ return has;
+ },
+
+ isOverAxis: function(x, reference, size) {
+ //Determines when x coordinate is over "b" element axis
+ return (x > reference) && (x < (reference + size));
+ },
+
+ isOver: function(y, x, top, left, height, width) {
+ //Determines when x, y coordinates is over "b" element
+ return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width);
+ },
+
+ keyCode: {
+ BACKSPACE: 8,
+ CAPS_LOCK: 20,
+ COMMA: 188,
+ CONTROL: 17,
+ DELETE: 46,
+ DOWN: 40,
+ END: 35,
+ ENTER: 13,
+ ESCAPE: 27,
+ HOME: 36,
+ INSERT: 45,
+ LEFT: 37,
+ NUMPAD_ADD: 107,
+ NUMPAD_DECIMAL: 110,
+ NUMPAD_DIVIDE: 111,
+ NUMPAD_ENTER: 108,
+ NUMPAD_MULTIPLY: 106,
+ NUMPAD_SUBTRACT: 109,
+ PAGE_DOWN: 34,
+ PAGE_UP: 33,
+ PERIOD: 190,
+ RIGHT: 39,
+ SHIFT: 16,
+ SPACE: 32,
+ TAB: 9,
+ UP: 38
+ }
+};
+
+// WAI-ARIA normalization
+if (isFF2) {
+ var attr = $.attr,
+ removeAttr = $.fn.removeAttr,
+ ariaNS = "http://www.w3.org/2005/07/aaa",
+ ariaState = /^aria-/,
+ ariaRole = /^wairole:/;
+
+ $.attr = function(elem, name, value) {
+ var set = value !== undefined;
+
+ return (name == 'role'
+ ? (set
+ ? attr.call(this, elem, name, "wairole:" + value)
+ : (attr.apply(this, arguments) || "").replace(ariaRole, ""))
+ : (ariaState.test(name)
+ ? (set
+ ? elem.setAttributeNS(ariaNS,
+ name.replace(ariaState, "aaa:"), value)
+ : attr.call(this, elem, name.replace(ariaState, "aaa:")))
+ : attr.apply(this, arguments)));
+ };
+
+ $.fn.removeAttr = function(name) {
+ return (ariaState.test(name)
+ ? this.each(function() {
+ this.removeAttributeNS(ariaNS, name.replace(ariaState, ""));
+ }) : removeAttr.call(this, name));
+ };
+}
+
+//jQuery plugins
+$.fn.extend({
+ remove: function() {
+ // Safari has a native remove event which actually removes DOM elements,
+ // so we have to use triggerHandler instead of trigger (#3037).
+ $("*", this).add(this).each(function() {
+ $(this).triggerHandler("remove");
+ });
+ return _remove.apply(this, arguments );
+ },
+
+ enableSelection: function() {
+ return this
+ .attr('unselectable', 'off')
+ .css('MozUserSelect', '')
+ .unbind('selectstart.ui');
+ },
+
+ disableSelection: function() {
+ return this
+ .attr('unselectable', 'on')
+ .css('MozUserSelect', 'none')
+ .bind('selectstart.ui', function() { return false; });
+ },
+
+ scrollParent: function() {
+ var scrollParent;
+ if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
+ scrollParent = this.parents().filter(function() {
+ return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
+ }).eq(0);
+ } else {
+ scrollParent = this.parents().filter(function() {
+ return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
+ }).eq(0);
+ }
+
+ return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
+ }
+});
+
+
+//Additional selectors
+$.extend($.expr[':'], {
+ data: function(elem, i, match) {
+ return !!$.data(elem, match[3]);
+ },
+
+ focusable: function(element) {
+ var nodeName = element.nodeName.toLowerCase(),
+ tabIndex = $.attr(element, 'tabindex');
+ return (/input|select|textarea|button|object/.test(nodeName)
+ ? !element.disabled
+ : 'a' == nodeName || 'area' == nodeName
+ ? element.href || !isNaN(tabIndex)
+ : !isNaN(tabIndex))
+ // the element and all of its ancestors must be visible
+ // the browser may report that the area is hidden
+ && !$(element)['area' == nodeName ? 'parents' : 'closest'](':hidden').length;
+ },
+
+ tabbable: function(element) {
+ var tabIndex = $.attr(element, 'tabindex');
+ return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(':focusable');
+ }
+});
+
+
+// $.widget is a factory to create jQuery plugins
+// taking some boilerplate code out of the plugin code
+function getter(namespace, plugin, method, args) {
+ function getMethods(type) {
+ var methods = $[namespace][plugin][type] || [];
+ return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods);
+ }
+
+ var methods = getMethods('getter');
+ if (args.length == 1 && typeof args[0] == 'string') {
+ methods = methods.concat(getMethods('getterSetter'));
+ }
+ return ($.inArray(method, methods) != -1);
+}
+
+$.widget = function(name, prototype) {
+ var namespace = name.split(".")[0];
+ name = name.split(".")[1];
+
+ // create plugin method
+ $.fn[name] = function(options) {
+ var isMethodCall = (typeof options == 'string'),
+ args = Array.prototype.slice.call(arguments, 1);
+
+ // prevent calls to internal methods
+ if (isMethodCall && options.substring(0, 1) == '_') {
+ return this;
+ }
+
+ // handle getter methods
+ if (isMethodCall && getter(namespace, name, options, args)) {
+ var instance = $.data(this[0], name);
+ return (instance ? instance[options].apply(instance, args)
+ : undefined);
+ }
+
+ // handle initialization and non-getter methods
+ return this.each(function() {
+ var instance = $.data(this, name);
+
+ // constructor
+ (!instance && !isMethodCall &&
+ $.data(this, name, new $[namespace][name](this, options))._init());
+
+ // method call
+ (instance && isMethodCall && $.isFunction(instance[options]) &&
+ instance[options].apply(instance, args));
+ });
+ };
+
+ // create widget constructor
+ $[namespace] = $[namespace] || {};
+ $[namespace][name] = function(element, options) {
+ var self = this;
+
+ this.namespace = namespace;
+ this.widgetName = name;
+ this.widgetEventPrefix = $[namespace][name].eventPrefix || name;
+ this.widgetBaseClass = namespace + '-' + name;
+
+ this.options = $.extend({},
+ $.widget.defaults,
+ $[namespace][name].defaults,
+ $.metadata && $.metadata.get(element)[name],
+ options);
+
+ this.element = $(element)
+ .bind('setData.' + name, function(event, key, value) {
+ if (event.target == element) {
+ return self._setData(key, value);
+ }
+ })
+ .bind('getData.' + name, function(event, key) {
+ if (event.target == element) {
+ return self._getData(key);
+ }
+ })
+ .bind('remove', function() {
+ return self.destroy();
+ });
+ };
+
+ // add widget prototype
+ $[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype);
+
+ // TODO: merge getter and getterSetter properties from widget prototype
+ // and plugin prototype
+ $[namespace][name].getterSetter = 'option';
+};
+
+$.widget.prototype = {
+ _init: function() {},
+ destroy: function() {
+ this.element.removeData(this.widgetName)
+ .removeClass(this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled')
+ .removeAttr('aria-disabled');
+ },
+
+ option: function(key, value) {
+ var options = key,
+ self = this;
+
+ if (typeof key == "string") {
+ if (value === undefined) {
+ return this._getData(key);
+ }
+ options = {};
+ options[key] = value;
+ }
+
+ $.each(options, function(key, value) {
+ self._setData(key, value);
+ });
+ },
+ _getData: function(key) {
+ return this.options[key];
+ },
+ _setData: function(key, value) {
+ this.options[key] = value;
+
+ if (key == 'disabled') {
+ this.element
+ [value ? 'addClass' : 'removeClass'](
+ this.widgetBaseClass + '-disabled' + ' ' +
+ this.namespace + '-state-disabled')
+ .attr("aria-disabled", value);
+ }
+ },
+
+ enable: function() {
+ this._setData('disabled', false);
+ },
+ disable: function() {
+ this._setData('disabled', true);
+ },
+
+ _trigger: function(type, event, data) {
+ var callback = this.options[type],
+ eventName = (type == this.widgetEventPrefix
+ ? type : this.widgetEventPrefix + type);
+
+ event = $.Event(event);
+ event.type = eventName;
+
+ // copy original event properties over to the new event
+ // this would happen if we could call $.event.fix instead of $.Event
+ // but we don't have a way to force an event to be fixed multiple times
+ if (event.originalEvent) {
+ for (var i = $.event.props.length, prop; i;) {
+ prop = $.event.props[--i];
+ event[prop] = event.originalEvent[prop];
+ }
+ }
+
+ this.element.trigger(event, data);
+
+ return !($.isFunction(callback) && callback.call(this.element[0], event, data) === false
+ || event.isDefaultPrevented());
+ }
+};
+
+$.widget.defaults = {
+ disabled: false
+};
+
+
+/** Mouse Interaction Plugin **/
+
+$.ui.mouse = {
+ _mouseInit: function() {
+ var self = this;
+
+ this.element
+ .bind('mousedown.'+this.widgetName, function(event) {
+ return self._mouseDown(event);
+ })
+ .bind('click.'+this.widgetName, function(event) {
+ if(self._preventClickEvent) {
+ self._preventClickEvent = false;
+ event.stopImmediatePropagation();
+ return false;
+ }
+ });
+
+ // Prevent text selection in IE
+ if ($.browser.msie) {
+ this._mouseUnselectable = this.element.attr('unselectable');
+ this.element.attr('unselectable', 'on');
+ }
+
+ this.started = false;
+ },
+
+ // TODO: make sure destroying one instance of mouse doesn't mess with
+ // other instances of mouse
+ _mouseDestroy: function() {
+ this.element.unbind('.'+this.widgetName);
+
+ // Restore text selection in IE
+ ($.browser.msie
+ && this.element.attr('unselectable', this._mouseUnselectable));
+ },
+
+ _mouseDown: function(event) {
+ // don't let more than one widget handle mouseStart
+ // TODO: figure out why we have to use originalEvent
+ event.originalEvent = event.originalEvent || {};
+ if (event.originalEvent.mouseHandled) { return; }
+
+ // we may have missed mouseup (out of window)
+ (this._mouseStarted && this._mouseUp(event));
+
+ this._mouseDownEvent = event;
+
+ var self = this,
+ btnIsLeft = (event.which == 1),
+ elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false);
+ if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
+ return true;
+ }
+
+ this.mouseDelayMet = !this.options.delay;
+ if (!this.mouseDelayMet) {
+ this._mouseDelayTimer = setTimeout(function() {
+ self.mouseDelayMet = true;
+ }, this.options.delay);
+ }
+
+ if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+ this._mouseStarted = (this._mouseStart(event) !== false);
+ if (!this._mouseStarted) {
+ event.preventDefault();
+ return true;
+ }
+ }
+
+ // these delegates are required to keep context
+ this._mouseMoveDelegate = function(event) {
+ return self._mouseMove(event);
+ };
+ this._mouseUpDelegate = function(event) {
+ return self._mouseUp(event);
+ };
+ $(document)
+ .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
+ .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
+
+ // preventDefault() is used to prevent the selection of text here -
+ // however, in Safari, this causes select boxes not to be selectable
+ // anymore, so this fix is needed
+ ($.browser.safari || event.preventDefault());
+
+ event.originalEvent.mouseHandled = true;
+ return true;
+ },
+
+ _mouseMove: function(event) {
+ // IE mouseup check - mouseup happened when mouse was out of window
+ if ($.browser.msie && !event.button) {
+ return this._mouseUp(event);
+ }
+
+ if (this._mouseStarted) {
+ this._mouseDrag(event);
+ return event.preventDefault();
+ }
+
+ if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+ this._mouseStarted =
+ (this._mouseStart(this._mouseDownEvent, event) !== false);
+ (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
+ }
+
+ return !this._mouseStarted;
+ },
+
+ _mouseUp: function(event) {
+ $(document)
+ .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
+ .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
+
+ if (this._mouseStarted) {
+ this._mouseStarted = false;
+ this._preventClickEvent = (event.target == this._mouseDownEvent.target);
+ this._mouseStop(event);
+ }
+
+ return false;
+ },
+
+ _mouseDistanceMet: function(event) {
+ return (Math.max(
+ Math.abs(this._mouseDownEvent.pageX - event.pageX),
+ Math.abs(this._mouseDownEvent.pageY - event.pageY)
+ ) >= this.options.distance
+ );
+ },
+
+ _mouseDelayMet: function(event) {
+ return this.mouseDelayMet;
+ },
+
+ // These are placeholder methods, to be overriden by extending plugin
+ _mouseStart: function(event) {},
+ _mouseDrag: function(event) {},
+ _mouseStop: function(event) {},
+ _mouseCapture: function(event) { return true; }
+};
+
+$.ui.mouse.defaults = {
+ cancel: null,
+ distance: 1,
+ delay: 0
+};
+
+})(jQuery);
diff --git a/examples/lessons/6_Maths_AddSubtract/js/ui.scoreboard.js b/examples/lessons/6_Maths_AddSubtract/js/ui.scoreboard.js
new file mode 100755
index 0000000..53a930a
--- /dev/null
+++ b/examples/lessons/6_Maths_AddSubtract/js/ui.scoreboard.js
@@ -0,0 +1,107 @@
+(function($){
+ $.widget('ui.scoreboard',
+ {
+ getScore : function(){
+ return this._getData('score');
+ },
+ setScore : function(newScore){
+ this._setData('score', parseInt(newScore));
+ this._refresh();
+ },
+ getTotal : function(){
+ return this._getData('total');
+ },
+ setTotal : function(newTotal){
+ this._setData('total', parseInt(newTotal));
+ this._refresh();
+ },
+ reset : function(){
+ this._setData('score', this._getData('initialScore'));
+ this._setData('total', this._getData('initialTotal'));
+ this._refresh();
+ },
+ inc : function(val){
+ var incVal = parseInt(val) || 1;
+ this._setData('score', this._getData('score') + incVal);
+ this._refresh();
+ if(this._getData('winScore') === this._getData('score')){
+ this.element.trigger('winGame');
+ }
+ },
+ incTotal : function(val){
+ var incVal = parseInt(val) || 1;
+ this._setData('total', this._getData('total') + incVal);
+ this._refresh();
+ },
+ dec : function(val){
+ var decVal = parseInt(val) || 1;
+ this._setData('score', this._getData('score') - decVal);
+ this._refresh();
+ },
+ decTotal : function(val){
+ var decVal = parseInt(val) || 1;
+ this._setData('total', this._getData('total') - decVal);
+ this._refresh();
+ },
+ _init : function(){
+
+ var divDisplay = "inline";
+ var score = this.options.score;
+ var total = this.options.total;
+ var layoutId = "h";
+ var self = this;
+
+
+ this._setData('initialScore', parseInt(this.options.score));
+ this._setData('initialTotal', parseInt(this.options.total));
+ this._setData('score', parseInt(this.options.score));
+ this._setData('total', parseInt(this.options.total));
+ this._setData('winScore', parseInt(this.options.winningScore) || 0);
+
+ if(this.options.layout === "vertical"){
+ layoutId = "v";
+ }
+
+ this.evWinGame = document.createEvent('Events');
+
+ this.element.addClass('ui-scoreboard-container-' + layoutId +
+ ' ui-widget ui-widget-content ui-corner-all');
+
+ var clone = $('<div>')
+ .addClass('ui-scoreboard-spacing-' + layoutId);
+ this._scoreText = $("<div>Score</div>")
+ .addClass('ui-scoreboard-spacing-'+ layoutId +
+ ' ui-corner-all ui-scoreboard-text')
+ .appendTo(this.element);
+ this._score = $("<div>" + score + "</div>")
+ .addClass('ui-scoreboard-spacing-' + layoutId +
+ ' ui-scoreboard-number-' + layoutId)
+ .appendTo(this.element);
+ $("<div>Total</div>")
+ .addClass('ui-scoreboard-spacing-' + layoutId +
+ ' ui-corner-all ' +
+ 'ui-scoreboard-text')
+ .appendTo(this.element);
+ this._total = $("<div>" + total + "</div>")
+ .addClass('ui-scoreboard-spacing-' + layoutId +
+ ' ui-scoreboard-number-' + layoutId)
+ .appendTo(this.element);
+ },
+ _refresh : function(){
+ this._score.text(this._getData('score'));
+ this._total.text(this._getData('total'));
+ },
+ destroy : function(){
+ this.element.remove();
+ $.widget.prototype.destroy.apply(this, arguments);
+ }
+
+
+ });
+
+ $.ui.scoreboard.getter = ['getScore', 'getTotal'];
+ $.ui.scoreboard.defaults = {
+ score: 0, total: 0, layout: "horizontal", winningScore: 0
+ };
+
+ })(jQuery); \ No newline at end of file
diff --git a/examples/lessons/6_Maths_complexAddition/assets/audio/correct.ogg b/examples/lessons/6_Maths_complexAddition/assets/audio/correct.ogg
new file mode 100755
index 0000000..a0d9e3a
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/audio/correct.ogg
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/audio/correct.wav b/examples/lessons/6_Maths_complexAddition/assets/audio/correct.wav
new file mode 100755
index 0000000..a49ba33
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/audio/correct.wav
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/audio/incorrect.ogg b/examples/lessons/6_Maths_complexAddition/assets/audio/incorrect.ogg
new file mode 100755
index 0000000..4805e55
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/audio/incorrect.ogg
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/audio/incorrect.wav b/examples/lessons/6_Maths_complexAddition/assets/audio/incorrect.wav
new file mode 100755
index 0000000..906c6a3
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/audio/incorrect.wav
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/background.png b/examples/lessons/6_Maths_complexAddition/assets/image/background.png
new file mode 100755
index 0000000..88ad480
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/background.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/bg_footer.png b/examples/lessons/6_Maths_complexAddition/assets/image/bg_footer.png
new file mode 100755
index 0000000..8982264
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/bg_footer.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/bg_header.png b/examples/lessons/6_Maths_complexAddition/assets/image/bg_header.png
new file mode 100755
index 0000000..98213f7
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/bg_header.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/bg_title_block.png b/examples/lessons/6_Maths_complexAddition/assets/image/bg_title_block.png
new file mode 100755
index 0000000..2c9dacf
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/bg_title_block.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/blueBoy0.png b/examples/lessons/6_Maths_complexAddition/assets/image/blueBoy0.png
new file mode 100755
index 0000000..86c0215
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/blueBoy0.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/blueBoy1.png b/examples/lessons/6_Maths_complexAddition/assets/image/blueBoy1.png
new file mode 100755
index 0000000..0e447b5
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/blueBoy1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/blueBoy2.png b/examples/lessons/6_Maths_complexAddition/assets/image/blueBoy2.png
new file mode 100755
index 0000000..c635b03
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/blueBoy2.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/blueBoy3.png b/examples/lessons/6_Maths_complexAddition/assets/image/blueBoy3.png
new file mode 100755
index 0000000..af7e6ab
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/blueBoy3.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/blueNumPlus.png b/examples/lessons/6_Maths_complexAddition/assets/image/blueNumPlus.png
new file mode 100755
index 0000000..22dffe0
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/blueNumPlus.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/blueRing.png b/examples/lessons/6_Maths_complexAddition/assets/image/blueRing.png
new file mode 100755
index 0000000..690900c
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/blueRing.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/blueTotal.png b/examples/lessons/6_Maths_complexAddition/assets/image/blueTotal.png
new file mode 100755
index 0000000..316c6c3
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/blueTotal.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/btn_back.png b/examples/lessons/6_Maths_complexAddition/assets/image/btn_back.png
new file mode 100755
index 0000000..d9fbf14
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/btn_back.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/btn_back_hover.png b/examples/lessons/6_Maths_complexAddition/assets/image/btn_back_hover.png
new file mode 100755
index 0000000..0911fcc
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/btn_back_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/btn_help.png b/examples/lessons/6_Maths_complexAddition/assets/image/btn_help.png
new file mode 100755
index 0000000..6753e9c
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/btn_help.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/btn_help_hover.png b/examples/lessons/6_Maths_complexAddition/assets/image/btn_help_hover.png
new file mode 100755
index 0000000..d3ccd92
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/btn_help_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/btn_next.png b/examples/lessons/6_Maths_complexAddition/assets/image/btn_next.png
new file mode 100755
index 0000000..9d70993
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/btn_next.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/btn_next_hover.png b/examples/lessons/6_Maths_complexAddition/assets/image/btn_next_hover.png
new file mode 100755
index 0000000..2cd4d37
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/btn_next_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/btn_ole.png b/examples/lessons/6_Maths_complexAddition/assets/image/btn_ole.png
new file mode 100755
index 0000000..0e775e9
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/btn_ole.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/btn_ole_hover.png b/examples/lessons/6_Maths_complexAddition/assets/image/btn_ole_hover.png
new file mode 100755
index 0000000..c43c5f7
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/btn_ole_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/btn_play_again.png b/examples/lessons/6_Maths_complexAddition/assets/image/btn_play_again.png
new file mode 100755
index 0000000..3594d18
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/btn_play_again.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/btn_play_again_hover.png b/examples/lessons/6_Maths_complexAddition/assets/image/btn_play_again_hover.png
new file mode 100755
index 0000000..ebb8f8c
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/btn_play_again_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/btn_play_again_mouse_down.png b/examples/lessons/6_Maths_complexAddition/assets/image/btn_play_again_mouse_down.png
new file mode 100755
index 0000000..07d6e45
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/btn_play_again_mouse_down.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/btn_start.png b/examples/lessons/6_Maths_complexAddition/assets/image/btn_start.png
new file mode 100755
index 0000000..32e5f20
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/btn_start.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/btn_start_hover.png b/examples/lessons/6_Maths_complexAddition/assets/image/btn_start_hover.png
new file mode 100755
index 0000000..811ce78
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/btn_start_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/btn_start_mouse_down.png b/examples/lessons/6_Maths_complexAddition/assets/image/btn_start_mouse_down.png
new file mode 100755
index 0000000..5acd43b
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/btn_start_mouse_down.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/help.png b/examples/lessons/6_Maths_complexAddition/assets/image/help.png
new file mode 100755
index 0000000..7a82e1d
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/help.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/imgNumContainer.png b/examples/lessons/6_Maths_complexAddition/assets/image/imgNumContainer.png
new file mode 100755
index 0000000..52cc997
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/imgNumContainer.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/redGirl0.png b/examples/lessons/6_Maths_complexAddition/assets/image/redGirl0.png
new file mode 100755
index 0000000..2ebc5e5
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/redGirl0.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/redGirl1.png b/examples/lessons/6_Maths_complexAddition/assets/image/redGirl1.png
new file mode 100755
index 0000000..58e8d2f
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/redGirl1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/redGirl2.png b/examples/lessons/6_Maths_complexAddition/assets/image/redGirl2.png
new file mode 100755
index 0000000..9dedceb
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/redGirl2.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/redGirl3.png b/examples/lessons/6_Maths_complexAddition/assets/image/redGirl3.png
new file mode 100755
index 0000000..8d58a42
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/redGirl3.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/redNumPlus.png b/examples/lessons/6_Maths_complexAddition/assets/image/redNumPlus.png
new file mode 100755
index 0000000..105e308
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/redNumPlus.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/redRing.png b/examples/lessons/6_Maths_complexAddition/assets/image/redRing.png
new file mode 100755
index 0000000..400065b
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/redRing.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/redTotal.png b/examples/lessons/6_Maths_complexAddition/assets/image/redTotal.png
new file mode 100755
index 0000000..2d55e88
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/redTotal.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/scoreBox.png b/examples/lessons/6_Maths_complexAddition/assets/image/scoreBox.png
new file mode 100755
index 0000000..c99e32f
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/scoreBox.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/title.png b/examples/lessons/6_Maths_complexAddition/assets/image/title.png
new file mode 100755
index 0000000..5fcfa82
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/title.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/title_block_lt.png b/examples/lessons/6_Maths_complexAddition/assets/image/title_block_lt.png
new file mode 100755
index 0000000..4696182
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/title_block_lt.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/title_block_rt.png b/examples/lessons/6_Maths_complexAddition/assets/image/title_block_rt.png
new file mode 100755
index 0000000..37cc44a
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/title_block_rt.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/assets/image/totalCorrect.png b/examples/lessons/6_Maths_complexAddition/assets/image/totalCorrect.png
new file mode 100755
index 0000000..69cad74
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/assets/image/totalCorrect.png
Binary files differ
diff --git a/examples/lessons/6_Maths_complexAddition/css/lesson.css b/examples/lessons/6_Maths_complexAddition/css/lesson.css
new file mode 100755
index 0000000..e27f93b
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/css/lesson.css
@@ -0,0 +1,225 @@
+@CHARSET "UTF-8";
+/****** Page Styles ****/
+
+/* Designed for 1200*900 px screen resolution */
+
+body {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 10pt;
+ margin: 0px;
+ background-color: #FFFFCC;
+}
+#header {
+ background-image: url(../assets/image/bg_header.png);
+ background-repeat: repeat-x;
+ height: 75px;
+ width: 100%;
+ position: absolute;
+ left: 0px;
+ top: 0px;
+}
+#topbtn_left {
+ float: left;
+ height: 60px;
+ width: 60px;
+ padding-top: 6px;
+ padding-left: 15px;
+}
+
+
+ .linkBack{
+ width: 60px; height: 59px;
+ background:url(../assets/image/btn_back.png);
+ }
+ .linkBack:hover{
+ background:url(../assets/image/btn_back_hover.png);
+ }
+
+#lesson_title {
+ float: left;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 16pt;
+ font-weight: bold;
+ color: #FFFFFF;
+ margin-left: 10px;
+ background-image: url(../assets/image/bg_title_block.png);
+}
+#topbtn_right {
+ float: right;
+ height: 60px;
+ width: 60px;
+ padding-top: 6px;
+ padding-right: 15px;
+}
+ #linkHelp{
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_help.png);
+ }
+ #linkHelp:hover{
+ background:url(../assets/image/btn_help_hover.png);
+ }
+ #linkOle{
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_ole.png);
+ }
+ #linkOle:hover{
+ background:url(../assets/image/btn_ole_hover.png);
+ }
+ .linkNext{var bindImgCss = {
+ 'float':'left',
+ 'width': '450px',
+ 'height':'40px',
+ 'margin-top':'0.25em',
+ 'text-align':'center',
+ 'padding-bottom':'0.3em'
+ };
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_next.png);
+ }
+ .linkNext:hover{
+ background:url(../assets/image/btn_next_hover.png);
+ }
+#footer {
+ position:relative;
+ background-image: url(../assets/image/bg_footer.png);
+ background-repeat: repeat-x;
+ height: 75px;
+ width: 100%;
+ left: 0px;
+ bottom: 0px;
+}
+#score_box {
+ float: left;
+ padding-left: 5px;
+ padding-top: 0.7em;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #FFFF00;
+ font-size: 16pt;
+ font-weight: bold;
+}
+#botbtn_right {
+ float: right;
+ height: 55px;
+ padding-right: 5px;
+ padding-top: 10px;
+}
+ #linkCheck{
+ margin: 1em 3em 0 0;
+ width: 101px; height: 30px;
+ background-image: url(../assets/image/check.png);
+ }
+
+ #linkStart{
+ width: 251px; height: 55px;
+ background:url(../assets/image/btn_start.png);
+ }
+ #linkStart:hover{
+ background:url(../assets/image/btn_start_hover.png);
+ }
+ #linkStart:active{
+ background:url(../assets/image/btn_start_mouse_down.png);
+ }
+ #linkPlayAgain{
+ width: 251px; height: 55px;
+ background:url(../assets/image/btn_play_again.png);
+ }
+ #linkPlayAgain:hover{
+ background:url(../assets/image/btn_play_again_hover.png);
+ }
+ #linkPlayAgain:active{
+ background:url(../assets/image/btn_play_again_mouse_down.png);
+ }
+#linkNextLesson{
+ position:absolute;
+ bottom: 75px;
+ right: 10px;
+}
+#linkPrevLesson{
+ position:absolute;
+ bottom: 75px;
+ left: 10px;
+}
+
+/**** End of the page style ****/
+
+/**** Game Styles ****/
+
+a{
+ color:#FFFFCC;
+}
+#currentTitle{
+ width: 150px;
+ height: 80px;
+ font:25px/30px "Courier New", Courier, monospace;
+ font-weight: bold;
+ color: red;
+}
+#content{
+ position:relative;
+ margin: 0 auto;
+ margin-top: 75px;
+ width: 1198px;
+ height: 560px;
+ background: url(../assets/image/background.png) no-repeat center;
+}
+
+
+ input.blankBox{
+ font: 30px/35px Verdana, Geneva, Arial, Helvetica, sans-serif;
+ height:33px;
+ width: 130px;
+ text-align:center;
+
+ }
+ .focus {
+
+ background-color: #FFEEAA;
+ }
+ .correct{
+ background-color: #C0F9F3;
+ }
+ .incorrect{
+ background-color: #FFFF00;
+ }
+ .backOpaque{
+ background-color: #A4A4A4;
+ opacity: 0.2;
+ }
+
+#help{
+ display:none;
+ position:absolute;
+ right: 60px;
+ top: 75px;;
+ width: 256px;
+ height: 600px;
+ background:url(../assets/image/help.png);
+ z-index:40;
+}
+
+
+ #gameOver{
+ opacity: 1;
+ position:absolute;
+ top:60%;
+ left: 25%;
+ color: blue;
+ text-align:center;
+ font : bold 45px/65px Arial Black, Times New Roman;
+ }
+ #gameOverInfo{
+ margin-top: 35px;
+ text-align:center;
+ font: 20px/25px Helvetica, Geneva, Arial, Verdana, sans-serif;
+ font-weight:bold;
+ color:#FF0000;
+
+ }
+ .specialText{
+ margin-top: 1em;
+ font: 20px/25px Helvetica, Geneva, Arial, Verdana, sans-serif;
+ font-weight:bold;
+ color:#FF9900;
+ border-bottom: 2px dotted #CCC;
+
+ }
diff --git a/examples/lessons/6_Maths_complexAddition/index.html b/examples/lessons/6_Maths_complexAddition/index.html
new file mode 100755
index 0000000..91499dc
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/index.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Class 6 Maths Complex Addition</title>
+ <meta name="keywords" content="karma,javascript,html5,sugar,sugarlabs,gsoc,ole,nepal" />
+ <link type="text/css" rel="stylesheet" href="css/lesson.css" />
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <link type="image/ico" rel="icon" href="../../assets/default/image/favicon.ico" />
+ <script type="text/javascript" src="js/jquery-1.4.js"></script>
+ <script type="text/javascript" src="js/karma.js"></script>
+ <script type="text/javascript" src="js/lesson.js"></script>
+</head>
+<body>
+ <div id="header">
+ <div id="topbtn_left"><a href="#"><div id="linkBackLesson" class="linkBack"></div></a></div>
+ <div id="lesson_title">
+ <img src="assets/image/title_block_lt.png" width="33" height="75" align="absmiddle" />
+ Complex Addition <span id="currentTitle"></span>
+ <img src="assets/image/title_block_rt.png" width="33" height="75" align="absmiddle" />
+ </div>
+ <div id="topbtn_right"><a href="#"><div id="linkHelp"></div></a></div>
+ <div id="topbtn_right"><a href="http://olenepal.org"><div id="linkOle"></div></a></div>
+ </div>
+
+ <div id="content"></div>
+ <div id="help"></div>
+ <div id="gameOver"></div>
+ <form name="delayForm">
+ <input type="hidden" name="delayval" size="5">
+ </form>
+
+ <div id="footer">
+ <div id="botbtn_right"><a href="#"><div id="linkPlayAgain"></div></a></div>
+ <div id="botbtn_right"><a href="#"><div id="linkStart"></div></a></div>
+ <div id="score_box"></div>
+ <div id ="timer"></div>
+ </div>
+</body>
+</html>
diff --git a/examples/lessons/6_Maths_complexAddition/js/jquery-1.4.js b/examples/lessons/6_Maths_complexAddition/js/jquery-1.4.js
new file mode 100755
index 0000000..a448490
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/js/jquery-1.4.js
@@ -0,0 +1,5999 @@
+/*!
+ * jQuery JavaScript Library v1.4
+ * http://jquery.com/
+ *
+ * Copyright 2010, John Resig
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://docs.jquery.com/License
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ * Copyright 2010, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ *
+ * Date: Wed Jan 13 15:23:05 2010 -0500
+ */
+(function( window, undefined ) {
+
+// Define a local copy of jQuery
+var jQuery = function( selector, context ) {
+ // The jQuery object is actually just the init constructor 'enhanced'
+ return new jQuery.fn.init( selector, context );
+ },
+
+ // Map over jQuery in case of overwrite
+ _jQuery = window.jQuery,
+
+ // Map over the $ in case of overwrite
+ _$ = window.$,
+
+ // Use the correct document accordingly with window argument (sandbox)
+ document = window.document,
+
+ // A central reference to the root jQuery(document)
+ rootjQuery,
+
+ // A simple way to check for HTML strings or ID strings
+ // (both of which we optimize for)
+ quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,
+
+ // Is it a simple selector
+ isSimple = /^.[^:#\[\.,]*$/,
+
+ // Check if a string has a non-whitespace character in it
+ rnotwhite = /\S/,
+
+ // Used for trimming whitespace
+ rtrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g,
+
+ // Match a standalone tag
+ rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
+
+ // Keep a UserAgent string for use with jQuery.browser
+ userAgent = navigator.userAgent,
+
+ // For matching the engine and version of the browser
+ browserMatch,
+
+ // Has the ready events already been bound?
+ readyBound = false,
+
+ // The functions to execute on DOM ready
+ readyList = [],
+
+ // The ready event handler
+ DOMContentLoaded,
+
+ // Save a reference to some core methods
+ toString = Object.prototype.toString,
+ hasOwnProperty = Object.prototype.hasOwnProperty,
+ push = Array.prototype.push,
+ slice = Array.prototype.slice,
+ indexOf = Array.prototype.indexOf;
+
+jQuery.fn = jQuery.prototype = {
+ init: function( selector, context ) {
+ var match, elem, ret, doc;
+
+ // Handle $(""), $(null), or $(undefined)
+ if ( !selector ) {
+ return this;
+ }
+
+ // Handle $(DOMElement)
+ if ( selector.nodeType ) {
+ this.context = this[0] = selector;
+ this.length = 1;
+ return this;
+ }
+
+ // Handle HTML strings
+ if ( typeof selector === "string" ) {
+ // Are we dealing with HTML string or an ID?
+ match = quickExpr.exec( selector );
+
+ // Verify a match, and that no context was specified for #id
+ if ( match && (match[1] || !context) ) {
+
+ // HANDLE: $(html) -> $(array)
+ if ( match[1] ) {
+ doc = (context ? context.ownerDocument || context : document);
+
+ // If a single string is passed in and it's a single tag
+ // just do a createElement and skip the rest
+ ret = rsingleTag.exec( selector );
+
+ if ( ret ) {
+ if ( jQuery.isPlainObject( context ) ) {
+ selector = [ document.createElement( ret[1] ) ];
+ jQuery.fn.attr.call( selector, context, true );
+
+ } else {
+ selector = [ doc.createElement( ret[1] ) ];
+ }
+
+ } else {
+ ret = buildFragment( [ match[1] ], [ doc ] );
+ selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
+ }
+
+ // HANDLE: $("#id")
+ } else {
+ elem = document.getElementById( match[2] );
+
+ if ( elem ) {
+ // Handle the case where IE and Opera return items
+ // by name instead of ID
+ if ( elem.id !== match[2] ) {
+ return rootjQuery.find( selector );
+ }
+
+ // Otherwise, we inject the element directly into the jQuery object
+ this.length = 1;
+ this[0] = elem;
+ }
+
+ this.context = document;
+ this.selector = selector;
+ return this;
+ }
+
+ // HANDLE: $("TAG")
+ } else if ( !context && /^\w+$/.test( selector ) ) {
+ this.selector = selector;
+ this.context = document;
+ selector = document.getElementsByTagName( selector );
+
+ // HANDLE: $(expr, $(...))
+ } else if ( !context || context.jquery ) {
+ return (context || rootjQuery).find( selector );
+
+ // HANDLE: $(expr, context)
+ // (which is just equivalent to: $(context).find(expr)
+ } else {
+ return jQuery( context ).find( selector );
+ }
+
+ // HANDLE: $(function)
+ // Shortcut for document ready
+ } else if ( jQuery.isFunction( selector ) ) {
+ return rootjQuery.ready( selector );
+ }
+
+ if (selector.selector !== undefined) {
+ this.selector = selector.selector;
+ this.context = selector.context;
+ }
+
+ return jQuery.isArray( selector ) ?
+ this.setArray( selector ) :
+ jQuery.makeArray( selector, this );
+ },
+
+ // Start with an empty selector
+ selector: "",
+
+ // The current version of jQuery being used
+ jquery: "1.4",
+
+ // The default length of a jQuery object is 0
+ length: 0,
+
+ // The number of elements contained in the matched element set
+ size: function() {
+ return this.length;
+ },
+
+ toArray: function() {
+ return slice.call( this, 0 );
+ },
+
+ // Get the Nth element in the matched element set OR
+ // Get the whole matched element set as a clean array
+ get: function( num ) {
+ return num == null ?
+
+ // Return a 'clean' array
+ this.toArray() :
+
+ // Return just the object
+ ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
+ },
+
+ // Take an array of elements and push it onto the stack
+ // (returning the new matched element set)
+ pushStack: function( elems, name, selector ) {
+ // Build a new jQuery matched element set
+ var ret = jQuery( elems || null );
+
+ // Add the old object onto the stack (as a reference)
+ ret.prevObject = this;
+
+ ret.context = this.context;
+
+ if ( name === "find" ) {
+ ret.selector = this.selector + (this.selector ? " " : "") + selector;
+ } else if ( name ) {
+ ret.selector = this.selector + "." + name + "(" + selector + ")";
+ }
+
+ // Return the newly-formed element set
+ return ret;
+ },
+
+ // Force the current matched set of elements to become
+ // the specified array of elements (destroying the stack in the process)
+ // You should use pushStack() in order to do this, but maintain the stack
+ setArray: function( elems ) {
+ // Resetting the length to 0, then using the native Array push
+ // is a super-fast way to populate an object with array-like properties
+ this.length = 0;
+ push.apply( this, elems );
+
+ return this;
+ },
+
+ // Execute a callback for every element in the matched set.
+ // (You can seed the arguments with an array of args, but this is
+ // only used internally.)
+ each: function( callback, args ) {
+ return jQuery.each( this, callback, args );
+ },
+
+ ready: function( fn ) {
+ // Attach the listeners
+ jQuery.bindReady();
+
+ // If the DOM is already ready
+ if ( jQuery.isReady ) {
+ // Execute the function immediately
+ fn.call( document, jQuery );
+
+ // Otherwise, remember the function for later
+ } else if ( readyList ) {
+ // Add the function to the wait list
+ readyList.push( fn );
+ }
+
+ return this;
+ },
+
+ eq: function( i ) {
+ return i === -1 ?
+ this.slice( i ) :
+ this.slice( i, +i + 1 );
+ },
+
+ first: function() {
+ return this.eq( 0 );
+ },
+
+ last: function() {
+ return this.eq( -1 );
+ },
+
+ slice: function() {
+ return this.pushStack( slice.apply( this, arguments ),
+ "slice", slice.call(arguments).join(",") );
+ },
+
+ map: function( callback ) {
+ return this.pushStack( jQuery.map(this, function( elem, i ) {
+ return callback.call( elem, i, elem );
+ }));
+ },
+
+ end: function() {
+ return this.prevObject || jQuery(null);
+ },
+
+ // For internal use only.
+ // Behaves like an Array's method, not like a jQuery method.
+ push: push,
+ sort: [].sort,
+ splice: [].splice
+};
+
+// Give the init function the jQuery prototype for later instantiation
+jQuery.fn.init.prototype = jQuery.fn;
+
+jQuery.extend = jQuery.fn.extend = function() {
+ // copy reference to target object
+ var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy;
+
+ // Handle a deep copy situation
+ if ( typeof target === "boolean" ) {
+ deep = target;
+ target = arguments[1] || {};
+ // skip the boolean and the target
+ i = 2;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
+ target = {};
+ }
+
+ // extend jQuery itself if only one argument is passed
+ if ( length === i ) {
+ target = this;
+ --i;
+ }
+
+ for ( ; i < length; i++ ) {
+ // Only deal with non-null/undefined values
+ if ( (options = arguments[ i ]) != null ) {
+ // Extend the base object
+ for ( name in options ) {
+ src = target[ name ];
+ copy = options[ name ];
+
+ // Prevent never-ending loop
+ if ( target === copy ) {
+ continue;
+ }
+
+ // Recurse if we're merging object literal values or arrays
+ if ( deep && copy && ( jQuery.isPlainObject(copy) || jQuery.isArray(copy) ) ) {
+ var clone = src && ( jQuery.isPlainObject(src) || jQuery.isArray(src) ) ? src
+ : jQuery.isArray(copy) ? [] : {};
+
+ // Never move original objects, clone them
+ target[ name ] = jQuery.extend( deep, clone, copy );
+
+ // Don't bring in undefined values
+ } else if ( copy !== undefined ) {
+ target[ name ] = copy;
+ }
+ }
+ }
+ }
+
+ // Return the modified object
+ return target;
+};
+
+jQuery.extend({
+ noConflict: function( deep ) {
+ window.$ = _$;
+
+ if ( deep ) {
+ window.jQuery = _jQuery;
+ }
+
+ return jQuery;
+ },
+
+ // Is the DOM ready to be used? Set to true once it occurs.
+ isReady: false,
+
+ // Handle when the DOM is ready
+ ready: function() {
+ // Make sure that the DOM is not already loaded
+ if ( !jQuery.isReady ) {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( !document.body ) {
+ return setTimeout( jQuery.ready, 13 );
+ }
+
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If there are functions bound, to execute
+ if ( readyList ) {
+ // Execute all of them
+ var fn, i = 0;
+ while ( (fn = readyList[ i++ ]) ) {
+ fn.call( document, jQuery );
+ }
+
+ // Reset the list of functions
+ readyList = null;
+ }
+
+ // Trigger any bound ready events
+ if ( jQuery.fn.triggerHandler ) {
+ jQuery( document ).triggerHandler( "ready" );
+ }
+ }
+ },
+
+ bindReady: function() {
+ if ( readyBound ) {
+ return;
+ }
+
+ readyBound = true;
+
+ // Catch cases where $(document).ready() is called after the
+ // browser event has already occurred.
+ if ( document.readyState === "complete" ) {
+ return jQuery.ready();
+ }
+
+ // Mozilla, Opera and webkit nightlies currently support this event
+ if ( document.addEventListener ) {
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+
+ // A fallback to window.onload, that will always work
+ window.addEventListener( "load", jQuery.ready, false );
+
+ // If IE event model is used
+ } else if ( document.attachEvent ) {
+ // ensure firing before onload,
+ // maybe late but safe also for iframes
+ document.attachEvent("onreadystatechange", DOMContentLoaded);
+
+ // A fallback to window.onload, that will always work
+ window.attachEvent( "onload", jQuery.ready );
+
+ // If IE and not a frame
+ // continually check to see if the document is ready
+ var toplevel = false;
+
+ try {
+ toplevel = window.frameElement == null;
+ } catch(e) {}
+
+ if ( document.documentElement.doScroll && toplevel ) {
+ doScrollCheck();
+ }
+ }
+ },
+
+ // See test/unit/core.js for details concerning isFunction.
+ // Since version 1.3, DOM methods and functions like alert
+ // aren't supported. They return false on IE (#2968).
+ isFunction: function( obj ) {
+ return toString.call(obj) === "[object Function]";
+ },
+
+ isArray: function( obj ) {
+ return toString.call(obj) === "[object Array]";
+ },
+
+ isPlainObject: function( obj ) {
+ // Must be an Object.
+ // Because of IE, we also have to check the presence of the constructor property.
+ // Make sure that DOM nodes and window objects don't pass through, as well
+ if ( !obj || toString.call(obj) !== "[object Object]" || obj.nodeType || obj.setInterval ) {
+ return false;
+ }
+
+ // Not own constructor property must be Object
+ if ( obj.constructor
+ && !hasOwnProperty.call(obj, "constructor")
+ && !hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf") ) {
+ return false;
+ }
+
+ // Own properties are enumerated firstly, so to speed up,
+ // if last one is own, then all properties are own.
+
+ var key;
+ for ( key in obj ) {}
+
+ return key === undefined || hasOwnProperty.call( obj, key );
+ },
+
+ isEmptyObject: function( obj ) {
+ for ( var name in obj ) {
+ return false;
+ }
+ return true;
+ },
+
+ noop: function() {},
+
+ // Evalulates a script in a global context
+ globalEval: function( data ) {
+ if ( data && rnotwhite.test(data) ) {
+ // Inspired by code by Andrea Giammarchi
+ // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
+ var head = document.getElementsByTagName("head")[0] || document.documentElement,
+ script = document.createElement("script");
+
+ script.type = "text/javascript";
+
+ if ( jQuery.support.scriptEval ) {
+ script.appendChild( document.createTextNode( data ) );
+ } else {
+ script.text = data;
+ }
+
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709).
+ head.insertBefore( script, head.firstChild );
+ head.removeChild( script );
+ }
+ },
+
+ nodeName: function( elem, name ) {
+ return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
+ },
+
+ // args is for internal usage only
+ each: function( object, callback, args ) {
+ var name, i = 0,
+ length = object.length,
+ isObj = length === undefined || jQuery.isFunction(object);
+
+ if ( args ) {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.apply( object[ name ], args ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( ; i < length; ) {
+ if ( callback.apply( object[ i++ ], args ) === false ) {
+ break;
+ }
+ }
+ }
+
+ // A special, fast, case for the most common use of each
+ } else {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( var value = object[0];
+ i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
+ }
+ }
+
+ return object;
+ },
+
+ trim: function( text ) {
+ return (text || "").replace( rtrim, "" );
+ },
+
+ // results is for internal usage only
+ makeArray: function( array, results ) {
+ var ret = results || [];
+
+ if ( array != null ) {
+ // The window, strings (and functions) also have 'length'
+ // The extra typeof function check is to prevent crashes
+ // in Safari 2 (See: #3039)
+ if ( array.length == null || typeof array === "string" || jQuery.isFunction(array) || (typeof array !== "function" && array.setInterval) ) {
+ push.call( ret, array );
+ } else {
+ jQuery.merge( ret, array );
+ }
+ }
+
+ return ret;
+ },
+
+ inArray: function( elem, array ) {
+ if ( array.indexOf ) {
+ return array.indexOf( elem );
+ }
+
+ for ( var i = 0, length = array.length; i < length; i++ ) {
+ if ( array[ i ] === elem ) {
+ return i;
+ }
+ }
+
+ return -1;
+ },
+
+ merge: function( first, second ) {
+ var i = first.length, j = 0;
+
+ if ( typeof second.length === "number" ) {
+ for ( var l = second.length; j < l; j++ ) {
+ first[ i++ ] = second[ j ];
+ }
+ } else {
+ while ( second[j] !== undefined ) {
+ first[ i++ ] = second[ j++ ];
+ }
+ }
+
+ first.length = i;
+
+ return first;
+ },
+
+ grep: function( elems, callback, inv ) {
+ var ret = [];
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ if ( !inv !== !callback( elems[ i ], i ) ) {
+ ret.push( elems[ i ] );
+ }
+ }
+
+ return ret;
+ },
+
+ // arg is for internal usage only
+ map: function( elems, callback, arg ) {
+ var ret = [], value;
+
+ // Go through the array, translating each of the items to their
+ // new value (or values).
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ value = callback( elems[ i ], i, arg );
+
+ if ( value != null ) {
+ ret[ ret.length ] = value;
+ }
+ }
+
+ return ret.concat.apply( [], ret );
+ },
+
+ // A global GUID counter for objects
+ guid: 1,
+
+ proxy: function( fn, proxy, thisObject ) {
+ if ( arguments.length === 2 ) {
+ if ( typeof proxy === "string" ) {
+ thisObject = fn;
+ fn = thisObject[ proxy ];
+ proxy = undefined;
+
+ } else if ( proxy && !jQuery.isFunction( proxy ) ) {
+ thisObject = proxy;
+ proxy = undefined;
+ }
+ }
+
+ if ( !proxy && fn ) {
+ proxy = function() {
+ return fn.apply( thisObject || this, arguments );
+ };
+ }
+
+ // Set the guid of unique handler to the same of original handler, so it can be removed
+ if ( fn ) {
+ proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
+ }
+
+ // So proxy can be declared as an argument
+ return proxy;
+ },
+
+ // Use of jQuery.browser is frowned upon.
+ // More details: http://docs.jquery.com/Utilities/jQuery.browser
+ uaMatch: function( ua ) {
+ var ret = { browser: "" };
+
+ ua = ua.toLowerCase();
+
+ if ( /webkit/.test( ua ) ) {
+ ret = { browser: "webkit", version: /webkit[\/ ]([\w.]+)/ };
+
+ } else if ( /opera/.test( ua ) ) {
+ ret = { browser: "opera", version: /version/.test( ua ) ? /version[\/ ]([\w.]+)/ : /opera[\/ ]([\w.]+)/ };
+
+ } else if ( /msie/.test( ua ) ) {
+ ret = { browser: "msie", version: /msie ([\w.]+)/ };
+
+ } else if ( /mozilla/.test( ua ) && !/compatible/.test( ua ) ) {
+ ret = { browser: "mozilla", version: /rv:([\w.]+)/ };
+ }
+
+ ret.version = (ret.version && ret.version.exec( ua ) || [0, "0"])[1];
+
+ return ret;
+ },
+
+ browser: {}
+});
+
+browserMatch = jQuery.uaMatch( userAgent );
+if ( browserMatch.browser ) {
+ jQuery.browser[ browserMatch.browser ] = true;
+ jQuery.browser.version = browserMatch.version;
+}
+
+// Deprecated, use jQuery.browser.webkit instead
+if ( jQuery.browser.webkit ) {
+ jQuery.browser.safari = true;
+}
+
+if ( indexOf ) {
+ jQuery.inArray = function( elem, array ) {
+ return indexOf.call( array, elem );
+ };
+}
+
+// All jQuery objects should point back to these
+rootjQuery = jQuery(document);
+
+// Cleanup functions for the document ready method
+if ( document.addEventListener ) {
+ DOMContentLoaded = function() {
+ document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+ jQuery.ready();
+ };
+
+} else if ( document.attachEvent ) {
+ DOMContentLoaded = function() {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( document.readyState === "complete" ) {
+ document.detachEvent( "onreadystatechange", DOMContentLoaded );
+ jQuery.ready();
+ }
+ };
+}
+
+// The DOM ready check for Internet Explorer
+function doScrollCheck() {
+ if ( jQuery.isReady ) {
+ return;
+ }
+
+ try {
+ // If IE is used, use the trick by Diego Perini
+ // http://javascript.nwbox.com/IEContentLoaded/
+ document.documentElement.doScroll("left");
+ } catch( error ) {
+ setTimeout( doScrollCheck, 1 );
+ return;
+ }
+
+ // and execute any waiting functions
+ jQuery.ready();
+}
+
+if ( indexOf ) {
+ jQuery.inArray = function( elem, array ) {
+ return indexOf.call( array, elem );
+ };
+}
+
+function evalScript( i, elem ) {
+ if ( elem.src ) {
+ jQuery.ajax({
+ url: elem.src,
+ async: false,
+ dataType: "script"
+ });
+ } else {
+ jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
+ }
+
+ if ( elem.parentNode ) {
+ elem.parentNode.removeChild( elem );
+ }
+}
+
+// Mutifunctional method to get and set values to a collection
+// The value/s can be optionally by executed if its a function
+function access( elems, key, value, exec, fn, pass ) {
+ var length = elems.length;
+
+ // Setting many attributes
+ if ( typeof key === "object" ) {
+ for ( var k in key ) {
+ access( elems, k, key[k], exec, fn, value );
+ }
+ return elems;
+ }
+
+ // Setting one attribute
+ if ( value !== undefined ) {
+ // Optionally, function values get executed if exec is true
+ exec = !pass && exec && jQuery.isFunction(value);
+
+ for ( var i = 0; i < length; i++ ) {
+ fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
+ }
+
+ return elems;
+ }
+
+ // Getting an attribute
+ return length ? fn( elems[0], key ) : null;
+}
+
+function now() {
+ return (new Date).getTime();
+}
+(function() {
+
+ jQuery.support = {};
+
+ var root = document.documentElement,
+ script = document.createElement("script"),
+ div = document.createElement("div"),
+ id = "script" + now();
+
+ div.style.display = "none";
+ div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
+
+ var all = div.getElementsByTagName("*"),
+ a = div.getElementsByTagName("a")[0];
+
+ // Can't get basic test support
+ if ( !all || !all.length || !a ) {
+ return;
+ }
+
+ jQuery.support = {
+ // IE strips leading whitespace when .innerHTML is used
+ leadingWhitespace: div.firstChild.nodeType === 3,
+
+ // Make sure that tbody elements aren't automatically inserted
+ // IE will insert them into empty tables
+ tbody: !div.getElementsByTagName("tbody").length,
+
+ // Make sure that link elements get serialized correctly by innerHTML
+ // This requires a wrapper element in IE
+ htmlSerialize: !!div.getElementsByTagName("link").length,
+
+ // Get the style information from getAttribute
+ // (IE uses .cssText insted)
+ style: /red/.test( a.getAttribute("style") ),
+
+ // Make sure that URLs aren't manipulated
+ // (IE normalizes it by default)
+ hrefNormalized: a.getAttribute("href") === "/a",
+
+ // Make sure that element opacity exists
+ // (IE uses filter instead)
+ // Use a regex to work around a WebKit issue. See #5145
+ opacity: /^0.55$/.test( a.style.opacity ),
+
+ // Verify style float existence
+ // (IE uses styleFloat instead of cssFloat)
+ cssFloat: !!a.style.cssFloat,
+
+ // Make sure that if no value is specified for a checkbox
+ // that it defaults to "on".
+ // (WebKit defaults to "" instead)
+ checkOn: div.getElementsByTagName("input")[0].value === "on",
+
+ // Make sure that a selected-by-default option has a working selected property.
+ // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
+ optSelected: document.createElement("select").appendChild( document.createElement("option") ).selected,
+
+ // Will be defined later
+ scriptEval: false,
+ noCloneEvent: true,
+ boxModel: null
+ };
+
+ script.type = "text/javascript";
+ try {
+ script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
+ } catch(e) {}
+
+ root.insertBefore( script, root.firstChild );
+
+ // Make sure that the execution of code works by injecting a script
+ // tag with appendChild/createTextNode
+ // (IE doesn't support this, fails, and uses .text instead)
+ if ( window[ id ] ) {
+ jQuery.support.scriptEval = true;
+ delete window[ id ];
+ }
+
+ root.removeChild( script );
+
+ if ( div.attachEvent && div.fireEvent ) {
+ div.attachEvent("onclick", function click() {
+ // Cloning a node shouldn't copy over any
+ // bound event handlers (IE does this)
+ jQuery.support.noCloneEvent = false;
+ div.detachEvent("onclick", click);
+ });
+ div.cloneNode(true).fireEvent("onclick");
+ }
+
+ // Figure out if the W3C box model works as expected
+ // document.body must exist before we can do this
+ // TODO: This timeout is temporary until I move ready into core.js.
+ jQuery(function() {
+ var div = document.createElement("div");
+ div.style.width = div.style.paddingLeft = "1px";
+
+ document.body.appendChild( div );
+ jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
+ document.body.removeChild( div ).style.display = 'none';
+ div = null;
+ });
+
+ // Technique from Juriy Zaytsev
+ // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
+ var eventSupported = function( eventName ) {
+ var el = document.createElement("div");
+ eventName = "on" + eventName;
+
+ var isSupported = (eventName in el);
+ if ( !isSupported ) {
+ el.setAttribute(eventName, "return;");
+ isSupported = typeof el[eventName] === "function";
+ }
+ el = null;
+
+ return isSupported;
+ };
+
+ jQuery.support.submitBubbles = eventSupported("submit");
+ jQuery.support.changeBubbles = eventSupported("change");
+
+ // release memory in IE
+ root = script = div = all = a = null;
+})();
+
+jQuery.props = {
+ "for": "htmlFor",
+ "class": "className",
+ readonly: "readOnly",
+ maxlength: "maxLength",
+ cellspacing: "cellSpacing",
+ rowspan: "rowSpan",
+ colspan: "colSpan",
+ tabindex: "tabIndex",
+ usemap: "useMap",
+ frameborder: "frameBorder"
+};
+var expando = "jQuery" + now(), uuid = 0, windowData = {};
+var emptyObject = {};
+
+jQuery.extend({
+ cache: {},
+
+ expando:expando,
+
+ // The following elements throw uncatchable exceptions if you
+ // attempt to add expando properties to them.
+ noData: {
+ "embed": true,
+ "object": true,
+ "applet": true
+ },
+
+ data: function( elem, name, data ) {
+ if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
+ return;
+ }
+
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var id = elem[ expando ], cache = jQuery.cache, thisCache;
+
+ // Handle the case where there's no name immediately
+ if ( !name && !id ) {
+ return null;
+ }
+
+ // Compute a unique ID for the element
+ if ( !id ) {
+ id = ++uuid;
+ }
+
+ // Avoid generating a new cache unless none exists and we
+ // want to manipulate it.
+ if ( typeof name === "object" ) {
+ elem[ expando ] = id;
+ thisCache = cache[ id ] = jQuery.extend(true, {}, name);
+ } else if ( cache[ id ] ) {
+ thisCache = cache[ id ];
+ } else if ( typeof data === "undefined" ) {
+ thisCache = emptyObject;
+ } else {
+ thisCache = cache[ id ] = {};
+ }
+
+ // Prevent overriding the named cache with undefined values
+ if ( data !== undefined ) {
+ elem[ expando ] = id;
+ thisCache[ name ] = data;
+ }
+
+ return typeof name === "string" ? thisCache[ name ] : thisCache;
+ },
+
+ removeData: function( elem, name ) {
+ if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
+ return;
+ }
+
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ];
+
+ // If we want to remove a specific section of the element's data
+ if ( name ) {
+ if ( thisCache ) {
+ // Remove the section of cache data
+ delete thisCache[ name ];
+
+ // If we've removed all the data, remove the element's cache
+ if ( jQuery.isEmptyObject(thisCache) ) {
+ jQuery.removeData( elem );
+ }
+ }
+
+ // Otherwise, we want to remove all of the element's data
+ } else {
+ // Clean up the element expando
+ try {
+ delete elem[ expando ];
+ } catch( e ) {
+ // IE has trouble directly removing the expando
+ // but it's ok with using removeAttribute
+ if ( elem.removeAttribute ) {
+ elem.removeAttribute( expando );
+ }
+ }
+
+ // Completely remove the data cache
+ delete cache[ id ];
+ }
+ }
+});
+
+jQuery.fn.extend({
+ data: function( key, value ) {
+ if ( typeof key === "undefined" && this.length ) {
+ return jQuery.data( this[0] );
+
+ } else if ( typeof key === "object" ) {
+ return this.each(function() {
+ jQuery.data( this, key );
+ });
+ }
+
+ var parts = key.split(".");
+ parts[1] = parts[1] ? "." + parts[1] : "";
+
+ if ( value === undefined ) {
+ var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
+
+ if ( data === undefined && this.length ) {
+ data = jQuery.data( this[0], key );
+ }
+ return data === undefined && parts[1] ?
+ this.data( parts[0] ) :
+ data;
+ } else {
+ return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function() {
+ jQuery.data( this, key, value );
+ });
+ }
+ },
+
+ removeData: function( key ) {
+ return this.each(function() {
+ jQuery.removeData( this, key );
+ });
+ }
+});
+jQuery.extend({
+ queue: function( elem, type, data ) {
+ if ( !elem ) {
+ return;
+ }
+
+ type = (type || "fx") + "queue";
+ var q = jQuery.data( elem, type );
+
+ // Speed up dequeue by getting out quickly if this is just a lookup
+ if ( !data ) {
+ return q || [];
+ }
+
+ if ( !q || jQuery.isArray(data) ) {
+ q = jQuery.data( elem, type, jQuery.makeArray(data) );
+
+ } else {
+ q.push( data );
+ }
+
+ return q;
+ },
+
+ dequeue: function( elem, type ) {
+ type = type || "fx";
+
+ var queue = jQuery.queue( elem, type ), fn = queue.shift();
+
+ // If the fx queue is dequeued, always remove the progress sentinel
+ if ( fn === "inprogress" ) {
+ fn = queue.shift();
+ }
+
+ if ( fn ) {
+ // Add a progress sentinel to prevent the fx queue from being
+ // automatically dequeued
+ if ( type === "fx" ) {
+ queue.unshift("inprogress");
+ }
+
+ fn.call(elem, function() {
+ jQuery.dequeue(elem, type);
+ });
+ }
+ }
+});
+
+jQuery.fn.extend({
+ queue: function( type, data ) {
+ if ( typeof type !== "string" ) {
+ data = type;
+ type = "fx";
+ }
+
+ if ( data === undefined ) {
+ return jQuery.queue( this[0], type );
+ }
+ return this.each(function( i, elem ) {
+ var queue = jQuery.queue( this, type, data );
+
+ if ( type === "fx" && queue[0] !== "inprogress" ) {
+ jQuery.dequeue( this, type );
+ }
+ });
+ },
+ dequeue: function( type ) {
+ return this.each(function() {
+ jQuery.dequeue( this, type );
+ });
+ },
+
+ // Based off of the plugin by Clint Helfers, with permission.
+ // http://blindsignals.com/index.php/2009/07/jquery-delay/
+ delay: function( time, type ) {
+ time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
+ type = type || "fx";
+
+ return this.queue( type, function() {
+ var elem = this;
+ setTimeout(function() {
+ jQuery.dequeue( elem, type );
+ }, time );
+ });
+ },
+
+ clearQueue: function( type ) {
+ return this.queue( type || "fx", [] );
+ }
+});
+var rclass = /[\n\t]/g,
+ rspace = /\s+/,
+ rreturn = /\r/g,
+ rspecialurl = /href|src|style/,
+ rtype = /(button|input)/i,
+ rfocusable = /(button|input|object|select|textarea)/i,
+ rclickable = /^(a|area)$/i,
+ rradiocheck = /radio|checkbox/;
+
+jQuery.fn.extend({
+ attr: function( name, value ) {
+ return access( this, name, value, true, jQuery.attr );
+ },
+
+ removeAttr: function( name, fn ) {
+ return this.each(function(){
+ jQuery.attr( this, name, "" );
+ if ( this.nodeType === 1 ) {
+ this.removeAttribute( name );
+ }
+ });
+ },
+
+ addClass: function( value ) {
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.addClass( value.call(this, i, self.attr("class")) );
+ });
+ }
+
+ if ( value && typeof value === "string" ) {
+ var classNames = (value || "").split( rspace );
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var elem = this[i];
+
+ if ( elem.nodeType === 1 ) {
+ if ( !elem.className ) {
+ elem.className = value;
+
+ } else {
+ var className = " " + elem.className + " ";
+ for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
+ if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
+ elem.className += " " + classNames[c];
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ removeClass: function( value ) {
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.removeClass( value.call(this, i, self.attr("class")) );
+ });
+ }
+
+ if ( (value && typeof value === "string") || value === undefined ) {
+ var classNames = (value || "").split(rspace);
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var elem = this[i];
+
+ if ( elem.nodeType === 1 && elem.className ) {
+ if ( value ) {
+ var className = (" " + elem.className + " ").replace(rclass, " ");
+ for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
+ className = className.replace(" " + classNames[c] + " ", " ");
+ }
+ elem.className = className.substring(1, className.length - 1);
+
+ } else {
+ elem.className = "";
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ toggleClass: function( value, stateVal ) {
+ var type = typeof value, isBool = typeof stateVal === "boolean";
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
+ });
+ }
+
+ return this.each(function() {
+ if ( type === "string" ) {
+ // toggle individual class names
+ var className, i = 0, self = jQuery(this),
+ state = stateVal,
+ classNames = value.split( rspace );
+
+ while ( (className = classNames[ i++ ]) ) {
+ // check each className given, space seperated list
+ state = isBool ? state : !self.hasClass( className );
+ self[ state ? "addClass" : "removeClass" ]( className );
+ }
+
+ } else if ( type === "undefined" || type === "boolean" ) {
+ if ( this.className ) {
+ // store className if set
+ jQuery.data( this, "__className__", this.className );
+ }
+
+ // toggle whole className
+ this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || "";
+ }
+ });
+ },
+
+ hasClass: function( selector ) {
+ var className = " " + selector + " ";
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ val: function( value ) {
+ if ( value === undefined ) {
+ var elem = this[0];
+
+ if ( elem ) {
+ if ( jQuery.nodeName( elem, "option" ) ) {
+ return (elem.attributes.value || {}).specified ? elem.value : elem.text;
+ }
+
+ // We need to handle select boxes special
+ if ( jQuery.nodeName( elem, "select" ) ) {
+ var index = elem.selectedIndex,
+ values = [],
+ options = elem.options,
+ one = elem.type === "select-one";
+
+ // Nothing was selected
+ if ( index < 0 ) {
+ return null;
+ }
+
+ // Loop through all the selected options
+ for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
+ var option = options[ i ];
+
+ if ( option.selected ) {
+ // Get the specifc value for the option
+ value = jQuery(option).val();
+
+ // We don't need an array for one selects
+ if ( one ) {
+ return value;
+ }
+
+ // Multi-Selects return an array
+ values.push( value );
+ }
+ }
+
+ return values;
+ }
+
+ // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
+ if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
+ return elem.getAttribute("value") === null ? "on" : elem.value;
+ }
+
+
+ // Everything else, we just grab the value
+ return (elem.value || "").replace(rreturn, "");
+
+ }
+
+ return undefined;
+ }
+
+ var isFunction = jQuery.isFunction(value);
+
+ return this.each(function(i) {
+ var self = jQuery(this), val = value;
+
+ if ( this.nodeType !== 1 ) {
+ return;
+ }
+
+ if ( isFunction ) {
+ val = value.call(this, i, self.val());
+ }
+
+ // Typecast each time if the value is a Function and the appended
+ // value is therefore different each time.
+ if ( typeof val === "number" ) {
+ val += "";
+ }
+
+ if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
+ this.checked = jQuery.inArray( self.val(), val ) >= 0;
+
+ } else if ( jQuery.nodeName( this, "select" ) ) {
+ var values = jQuery.makeArray(val);
+
+ jQuery( "option", this ).each(function() {
+ this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
+ });
+
+ if ( !values.length ) {
+ this.selectedIndex = -1;
+ }
+
+ } else {
+ this.value = val;
+ }
+ });
+ }
+});
+
+jQuery.extend({
+ attrFn: {
+ val: true,
+ css: true,
+ html: true,
+ text: true,
+ data: true,
+ width: true,
+ height: true,
+ offset: true
+ },
+
+ attr: function( elem, name, value, pass ) {
+ // don't set attributes on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ if ( pass && name in jQuery.attrFn ) {
+ return jQuery(elem)[name](value);
+ }
+
+ var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
+ // Whether we are setting (or getting)
+ set = value !== undefined;
+
+ // Try to normalize/fix the name
+ name = notxml && jQuery.props[ name ] || name;
+
+ // Only do all the following if this is a node (faster for style)
+ if ( elem.nodeType === 1 ) {
+ // These attributes require special treatment
+ var special = rspecialurl.test( name );
+
+ // Safari mis-reports the default selected property of an option
+ // Accessing the parent's selectedIndex property fixes it
+ if ( name === "selected" && !jQuery.support.optSelected ) {
+ var parent = elem.parentNode;
+ if ( parent ) {
+ parent.selectedIndex;
+
+ // Make sure that it also works with optgroups, see #5701
+ if ( parent.parentNode ) {
+ parent.parentNode.selectedIndex;
+ }
+ }
+ }
+
+ // If applicable, access the attribute via the DOM 0 way
+ if ( name in elem && notxml && !special ) {
+ if ( set ) {
+ // We can't allow the type property to be changed (since it causes problems in IE)
+ if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
+ throw "type property can't be changed";
+ }
+
+ elem[ name ] = value;
+ }
+
+ // browsers index elements by id/name on forms, give priority to attributes.
+ if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
+ return elem.getAttributeNode( name ).nodeValue;
+ }
+
+ // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
+ // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
+ if ( name === "tabIndex" ) {
+ var attributeNode = elem.getAttributeNode( "tabIndex" );
+
+ return attributeNode && attributeNode.specified ?
+ attributeNode.value :
+ rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
+ 0 :
+ undefined;
+ }
+
+ return elem[ name ];
+ }
+
+ if ( !jQuery.support.style && notxml && name === "style" ) {
+ if ( set ) {
+ elem.style.cssText = "" + value;
+ }
+
+ return elem.style.cssText;
+ }
+
+ if ( set ) {
+ // convert the value to a string (all browsers do this but IE) see #1070
+ elem.setAttribute( name, "" + value );
+ }
+
+ var attr = !jQuery.support.hrefNormalized && notxml && special ?
+ // Some attributes require a special call on IE
+ elem.getAttribute( name, 2 ) :
+ elem.getAttribute( name );
+
+ // Non-existent attributes return null, we normalize to undefined
+ return attr === null ? undefined : attr;
+ }
+
+ // elem is actually elem.style ... set the style
+ // Using attr for specific style information is now deprecated. Use style insead.
+ return jQuery.style( elem, name, value );
+ }
+});
+var fcleanup = function( nm ) {
+ return nm.replace(/[^\w\s\.\|`]/g, function( ch ) {
+ return "\\" + ch;
+ });
+};
+
+/*
+ * A number of helper functions used for managing events.
+ * Many of the ideas behind this code originated from
+ * Dean Edwards' addEvent library.
+ */
+jQuery.event = {
+
+ // Bind an event to an element
+ // Original by Dean Edwards
+ add: function( elem, types, handler, data ) {
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ // For whatever reason, IE has trouble passing the window object
+ // around, causing it to be cloned in the process
+ if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) {
+ elem = window;
+ }
+
+ // Make sure that the function being executed has a unique ID
+ if ( !handler.guid ) {
+ handler.guid = jQuery.guid++;
+ }
+
+ // if data is passed, bind to handler
+ if ( data !== undefined ) {
+ // Create temporary function pointer to original handler
+ var fn = handler;
+
+ // Create unique handler function, wrapped around original handler
+ handler = jQuery.proxy( fn );
+
+ // Store data in unique handler
+ handler.data = data;
+ }
+
+ // Init the element's event structure
+ var events = jQuery.data( elem, "events" ) || jQuery.data( elem, "events", {} ),
+ handle = jQuery.data( elem, "handle" ), eventHandle;
+
+ if ( !handle ) {
+ eventHandle = function() {
+ // Handle the second event of a trigger and when
+ // an event is called after a page has unloaded
+ return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
+ jQuery.event.handle.apply( eventHandle.elem, arguments ) :
+ undefined;
+ };
+
+ handle = jQuery.data( elem, "handle", eventHandle );
+ }
+
+ // If no handle is found then we must be trying to bind to one of the
+ // banned noData elements
+ if ( !handle ) {
+ return;
+ }
+
+ // Add elem as a property of the handle function
+ // This is to prevent a memory leak with non-native
+ // event in IE.
+ handle.elem = elem;
+
+ // Handle multiple events separated by a space
+ // jQuery(...).bind("mouseover mouseout", fn);
+ types = types.split( /\s+/ );
+ var type, i=0;
+ while ( (type = types[ i++ ]) ) {
+ // Namespaced event handlers
+ var namespaces = type.split(".");
+ type = namespaces.shift();
+ handler.type = namespaces.slice(0).sort().join(".");
+
+ // Get the current list of functions bound to this event
+ var handlers = events[ type ],
+ special = this.special[ type ] || {};
+
+
+
+ // Init the event handler queue
+ if ( !handlers ) {
+ handlers = events[ type ] = {};
+
+ // Check for a special event handler
+ // Only use addEventListener/attachEvent if the special
+ // events handler returns false
+ if ( !special.setup || special.setup.call( elem, data, namespaces, handler) === false ) {
+ // Bind the global event handler to the element
+ if ( elem.addEventListener ) {
+ elem.addEventListener( type, handle, false );
+ } else if ( elem.attachEvent ) {
+ elem.attachEvent( "on" + type, handle );
+ }
+ }
+ }
+
+ if ( special.add ) {
+ var modifiedHandler = special.add.call( elem, handler, data, namespaces, handlers );
+ if ( modifiedHandler && jQuery.isFunction( modifiedHandler ) ) {
+ modifiedHandler.guid = modifiedHandler.guid || handler.guid;
+ handler = modifiedHandler;
+ }
+ }
+
+ // Add the function to the element's handler list
+ handlers[ handler.guid ] = handler;
+
+ // Keep track of which events have been used, for global triggering
+ this.global[ type ] = true;
+ }
+
+ // Nullify elem to prevent memory leaks in IE
+ elem = null;
+ },
+
+ global: {},
+
+ // Detach an event or set of events from an element
+ remove: function( elem, types, handler ) {
+ // don't do events on text and comment nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ var events = jQuery.data( elem, "events" ), ret, type, fn;
+
+ if ( events ) {
+ // Unbind all events for the element
+ if ( types === undefined || (typeof types === "string" && types.charAt(0) === ".") ) {
+ for ( type in events ) {
+ this.remove( elem, type + (types || "") );
+ }
+ } else {
+ // types is actually an event object here
+ if ( types.type ) {
+ handler = types.handler;
+ types = types.type;
+ }
+
+ // Handle multiple events separated by a space
+ // jQuery(...).unbind("mouseover mouseout", fn);
+ types = types.split(/\s+/);
+ var i = 0;
+ while ( (type = types[ i++ ]) ) {
+ // Namespaced event handlers
+ var namespaces = type.split(".");
+ type = namespaces.shift();
+ var all = !namespaces.length,
+ cleaned = jQuery.map( namespaces.slice(0).sort(), fcleanup ),
+ namespace = new RegExp("(^|\\.)" + cleaned.join("\\.(?:.*\\.)?") + "(\\.|$)"),
+ special = this.special[ type ] || {};
+
+ if ( events[ type ] ) {
+ // remove the given handler for the given type
+ if ( handler ) {
+ fn = events[ type ][ handler.guid ];
+ delete events[ type ][ handler.guid ];
+
+ // remove all handlers for the given type
+ } else {
+ for ( var handle in events[ type ] ) {
+ // Handle the removal of namespaced events
+ if ( all || namespace.test( events[ type ][ handle ].type ) ) {
+ delete events[ type ][ handle ];
+ }
+ }
+ }
+
+ if ( special.remove ) {
+ special.remove.call( elem, namespaces, fn);
+ }
+
+ // remove generic event handler if no more handlers exist
+ for ( ret in events[ type ] ) {
+ break;
+ }
+ if ( !ret ) {
+ if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
+ if ( elem.removeEventListener ) {
+ elem.removeEventListener( type, jQuery.data( elem, "handle" ), false );
+ } else if ( elem.detachEvent ) {
+ elem.detachEvent( "on" + type, jQuery.data( elem, "handle" ) );
+ }
+ }
+ ret = null;
+ delete events[ type ];
+ }
+ }
+ }
+ }
+
+ // Remove the expando if it's no longer used
+ for ( ret in events ) {
+ break;
+ }
+ if ( !ret ) {
+ var handle = jQuery.data( elem, "handle" );
+ if ( handle ) {
+ handle.elem = null;
+ }
+ jQuery.removeData( elem, "events" );
+ jQuery.removeData( elem, "handle" );
+ }
+ }
+ },
+
+ // bubbling is internal
+ trigger: function( event, data, elem /*, bubbling */ ) {
+ // Event object or event type
+ var type = event.type || event,
+ bubbling = arguments[3];
+
+ if ( !bubbling ) {
+ event = typeof event === "object" ?
+ // jQuery.Event object
+ event[expando] ? event :
+ // Object literal
+ jQuery.extend( jQuery.Event(type), event ) :
+ // Just the event type (string)
+ jQuery.Event(type);
+
+ if ( type.indexOf("!") >= 0 ) {
+ event.type = type = type.slice(0, -1);
+ event.exclusive = true;
+ }
+
+ // Handle a global trigger
+ if ( !elem ) {
+ // Don't bubble custom events when global (to avoid too much overhead)
+ event.stopPropagation();
+
+ // Only trigger if we've ever bound an event for it
+ if ( this.global[ type ] ) {
+ jQuery.each( jQuery.cache, function() {
+ if ( this.events && this.events[type] ) {
+ jQuery.event.trigger( event, data, this.handle.elem );
+ }
+ });
+ }
+ }
+
+ // Handle triggering a single element
+
+ // don't do events on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ // Clean up in case it is reused
+ event.result = undefined;
+ event.target = elem;
+
+ // Clone the incoming data, if any
+ data = jQuery.makeArray( data );
+ data.unshift( event );
+ }
+
+ event.currentTarget = elem;
+
+ // Trigger the event, it is assumed that "handle" is a function
+ var handle = jQuery.data( elem, "handle" );
+ if ( handle ) {
+ handle.apply( elem, data );
+ }
+
+ var nativeFn, nativeHandler;
+ try {
+ if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
+ nativeFn = elem[ type ];
+ nativeHandler = elem[ "on" + type ];
+ }
+ // prevent IE from throwing an error for some elements with some event types, see #3533
+ } catch (e) {}
+
+ var isClick = jQuery.nodeName(elem, "a") && type === "click";
+
+ // Trigger the native events (except for clicks on links)
+ if ( !bubbling && nativeFn && !event.isDefaultPrevented() && !isClick ) {
+ this.triggered = true;
+ try {
+ elem[ type ]();
+ // prevent IE from throwing an error for some hidden elements
+ } catch (e) {}
+
+ // Handle triggering native .onfoo handlers
+ } else if ( nativeHandler && elem[ "on" + type ].apply( elem, data ) === false ) {
+ event.result = false;
+ }
+
+ this.triggered = false;
+
+ if ( !event.isPropagationStopped() ) {
+ var parent = elem.parentNode || elem.ownerDocument;
+ if ( parent ) {
+ jQuery.event.trigger( event, data, parent, true );
+ }
+ }
+ },
+
+ handle: function( event ) {
+ // returned undefined or false
+ var all, handlers;
+
+ event = arguments[0] = jQuery.event.fix( event || window.event );
+ event.currentTarget = this;
+
+ // Namespaced event handlers
+ var namespaces = event.type.split(".");
+ event.type = namespaces.shift();
+
+ // Cache this now, all = true means, any handler
+ all = !namespaces.length && !event.exclusive;
+
+ var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)");
+
+ handlers = ( jQuery.data(this, "events") || {} )[ event.type ];
+
+ for ( var j in handlers ) {
+ var handler = handlers[ j ];
+
+ // Filter the functions by class
+ if ( all || namespace.test(handler.type) ) {
+ // Pass in a reference to the handler function itself
+ // So that we can later remove it
+ event.handler = handler;
+ event.data = handler.data;
+
+ var ret = handler.apply( this, arguments );
+
+ if ( ret !== undefined ) {
+ event.result = ret;
+ if ( ret === false ) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }
+
+ if ( event.isImmediatePropagationStopped() ) {
+ break;
+ }
+
+ }
+ }
+
+ return event.result;
+ },
+
+ props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
+
+ fix: function( event ) {
+ if ( event[ expando ] ) {
+ return event;
+ }
+
+ // store a copy of the original event object
+ // and "clone" to set read-only properties
+ var originalEvent = event;
+ event = jQuery.Event( originalEvent );
+
+ for ( var i = this.props.length, prop; i; ) {
+ prop = this.props[ --i ];
+ event[ prop ] = originalEvent[ prop ];
+ }
+
+ // Fix target property, if necessary
+ if ( !event.target ) {
+ event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
+ }
+
+ // check if target is a textnode (safari)
+ if ( event.target.nodeType === 3 ) {
+ event.target = event.target.parentNode;
+ }
+
+ // Add relatedTarget, if necessary
+ if ( !event.relatedTarget && event.fromElement ) {
+ event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
+ }
+
+ // Calculate pageX/Y if missing and clientX/Y available
+ if ( event.pageX == null && event.clientX != null ) {
+ var doc = document.documentElement, body = document.body;
+ event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
+ event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
+ }
+
+ // Add which for key events
+ if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) {
+ event.which = event.charCode || event.keyCode;
+ }
+
+ // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
+ if ( !event.metaKey && event.ctrlKey ) {
+ event.metaKey = event.ctrlKey;
+ }
+
+ // Add which for click: 1 === left; 2 === middle; 3 === right
+ // Note: button is not normalized, so don't use it
+ if ( !event.which && event.button !== undefined ) {
+ event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
+ }
+
+ return event;
+ },
+
+ // Deprecated, use jQuery.guid instead
+ guid: 1E8,
+
+ // Deprecated, use jQuery.proxy instead
+ proxy: jQuery.proxy,
+
+ special: {
+ ready: {
+ // Make sure the ready event is setup
+ setup: jQuery.bindReady,
+ teardown: jQuery.noop
+ },
+
+ live: {
+ add: function( proxy, data, namespaces, live ) {
+ jQuery.extend( proxy, data || {} );
+
+ proxy.guid += data.selector + data.live;
+ jQuery.event.add( this, data.live, liveHandler, data );
+
+ },
+
+ remove: function( namespaces ) {
+ if ( namespaces.length ) {
+ var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)");
+
+ jQuery.each( (jQuery.data(this, "events").live || {}), function() {
+ if ( name.test(this.type) ) {
+ remove++;
+ }
+ });
+
+ if ( remove < 1 ) {
+ jQuery.event.remove( this, namespaces[0], liveHandler );
+ }
+ }
+ },
+ special: {}
+ },
+ beforeunload: {
+ setup: function( data, namespaces, fn ) {
+ // We only want to do this special case on windows
+ if ( this.setInterval ) {
+ this.onbeforeunload = fn;
+ }
+
+ return false;
+ },
+ teardown: function( namespaces, fn ) {
+ if ( this.onbeforeunload === fn ) {
+ this.onbeforeunload = null;
+ }
+ }
+ }
+ }
+};
+
+jQuery.Event = function( src ) {
+ // Allow instantiation without the 'new' keyword
+ if ( !this.preventDefault ) {
+ return new jQuery.Event( src );
+ }
+
+ // Event object
+ if ( src && src.type ) {
+ this.originalEvent = src;
+ this.type = src.type;
+ // Event type
+ } else {
+ this.type = src;
+ }
+
+ // timeStamp is buggy for some events on Firefox(#3843)
+ // So we won't rely on the native value
+ this.timeStamp = now();
+
+ // Mark it as fixed
+ this[ expando ] = true;
+};
+
+function returnFalse() {
+ return false;
+}
+function returnTrue() {
+ return true;
+}
+
+// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
+// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
+jQuery.Event.prototype = {
+ preventDefault: function() {
+ this.isDefaultPrevented = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+
+ // if preventDefault exists run it on the original event
+ if ( e.preventDefault ) {
+ e.preventDefault();
+ }
+ // otherwise set the returnValue property of the original event to false (IE)
+ e.returnValue = false;
+ },
+ stopPropagation: function() {
+ this.isPropagationStopped = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+ // if stopPropagation exists run it on the original event
+ if ( e.stopPropagation ) {
+ e.stopPropagation();
+ }
+ // otherwise set the cancelBubble property of the original event to true (IE)
+ e.cancelBubble = true;
+ },
+ stopImmediatePropagation: function() {
+ this.isImmediatePropagationStopped = returnTrue;
+ this.stopPropagation();
+ },
+ isDefaultPrevented: returnFalse,
+ isPropagationStopped: returnFalse,
+ isImmediatePropagationStopped: returnFalse
+};
+
+// Checks if an event happened on an element within another element
+// Used in jQuery.event.special.mouseenter and mouseleave handlers
+var withinElement = function( event ) {
+ // Check if mouse(over|out) are still within the same parent element
+ var parent = event.relatedTarget;
+
+ // Traverse up the tree
+ while ( parent && parent !== this ) {
+ // Firefox sometimes assigns relatedTarget a XUL element
+ // which we cannot access the parentNode property of
+ try {
+ parent = parent.parentNode;
+
+ // assuming we've left the element since we most likely mousedover a xul element
+ } catch(e) {
+ break;
+ }
+ }
+
+ if ( parent !== this ) {
+ // set the correct event type
+ event.type = event.data;
+
+ // handle event if we actually just moused on to a non sub-element
+ jQuery.event.handle.apply( this, arguments );
+ }
+
+},
+
+// In case of event delegation, we only need to rename the event.type,
+// liveHandler will take care of the rest.
+delegate = function( event ) {
+ event.type = event.data;
+ jQuery.event.handle.apply( this, arguments );
+};
+
+// Create mouseenter and mouseleave events
+jQuery.each({
+ mouseenter: "mouseover",
+ mouseleave: "mouseout"
+}, function( orig, fix ) {
+ jQuery.event.special[ orig ] = {
+ setup: function( data ) {
+ jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
+ },
+ teardown: function( data ) {
+ jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
+ }
+ };
+});
+
+// submit delegation
+if ( !jQuery.support.submitBubbles ) {
+
+jQuery.event.special.submit = {
+ setup: function( data, namespaces, fn ) {
+ if ( this.nodeName.toLowerCase() !== "form" ) {
+ jQuery.event.add(this, "click.specialSubmit." + fn.guid, function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
+ return trigger( "submit", this, arguments );
+ }
+ });
+
+ jQuery.event.add(this, "keypress.specialSubmit." + fn.guid, function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
+ return trigger( "submit", this, arguments );
+ }
+ });
+
+ } else {
+ return false;
+ }
+ },
+
+ remove: function( namespaces, fn ) {
+ jQuery.event.remove( this, "click.specialSubmit" + (fn ? "."+fn.guid : "") );
+ jQuery.event.remove( this, "keypress.specialSubmit" + (fn ? "."+fn.guid : "") );
+ }
+};
+
+}
+
+// change delegation, happens here so we have bind.
+if ( !jQuery.support.changeBubbles ) {
+
+var formElems = /textarea|input|select/i;
+
+function getVal( elem ) {
+ var type = elem.type, val = elem.value;
+
+ if ( type === "radio" || type === "checkbox" ) {
+ val = elem.checked;
+
+ } else if ( type === "select-multiple" ) {
+ val = elem.selectedIndex > -1 ?
+ jQuery.map( elem.options, function( elem ) {
+ return elem.selected;
+ }).join("-") :
+ "";
+
+ } else if ( elem.nodeName.toLowerCase() === "select" ) {
+ val = elem.selectedIndex;
+ }
+
+ return val;
+}
+
+function testChange( e ) {
+ var elem = e.target, data, val;
+
+ if ( !formElems.test( elem.nodeName ) || elem.readOnly ) {
+ return;
+ }
+
+ data = jQuery.data( elem, "_change_data" );
+ val = getVal(elem);
+
+ if ( val === data ) {
+ return;
+ }
+
+ // the current data will be also retrieved by beforeactivate
+ if ( e.type !== "focusout" || elem.type !== "radio" ) {
+ jQuery.data( elem, "_change_data", val );
+ }
+
+ if ( elem.type !== "select" && (data != null || val) ) {
+ e.type = "change";
+ return jQuery.event.trigger( e, arguments[1], this );
+ }
+}
+
+jQuery.event.special.change = {
+ filters: {
+ focusout: testChange,
+
+ click: function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
+ return testChange.call( this, e );
+ }
+ },
+
+ // Change has to be called before submit
+ // Keydown will be called before keypress, which is used in submit-event delegation
+ keydown: function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
+ (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
+ type === "select-multiple" ) {
+ return testChange.call( this, e );
+ }
+ },
+
+ // Beforeactivate happens also before the previous element is blurred
+ // with this event you can't trigger a change event, but you can store
+ // information/focus[in] is not needed anymore
+ beforeactivate: function( e ) {
+ var elem = e.target;
+
+ if ( elem.nodeName.toLowerCase() === "input" && elem.type === "radio" ) {
+ jQuery.data( elem, "_change_data", getVal(elem) );
+ }
+ }
+ },
+ setup: function( data, namespaces, fn ) {
+ for ( var type in changeFilters ) {
+ jQuery.event.add( this, type + ".specialChange." + fn.guid, changeFilters[type] );
+ }
+
+ return formElems.test( this.nodeName );
+ },
+ remove: function( namespaces, fn ) {
+ for ( var type in changeFilters ) {
+ jQuery.event.remove( this, type + ".specialChange" + (fn ? "."+fn.guid : ""), changeFilters[type] );
+ }
+
+ return formElems.test( this.nodeName );
+ }
+};
+
+var changeFilters = jQuery.event.special.change.filters;
+
+}
+
+function trigger( type, elem, args ) {
+ args[0].type = type;
+ return jQuery.event.handle.apply( elem, args );
+}
+
+// Create "bubbling" focus and blur events
+if ( document.addEventListener ) {
+ jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
+ jQuery.event.special[ fix ] = {
+ setup: function() {
+ this.addEventListener( orig, handler, true );
+ },
+ teardown: function() {
+ this.removeEventListener( orig, handler, true );
+ }
+ };
+
+ function handler( e ) {
+ e = jQuery.event.fix( e );
+ e.type = fix;
+ return jQuery.event.handle.call( this, e );
+ }
+ });
+}
+
+jQuery.each(["bind", "one"], function( i, name ) {
+ jQuery.fn[ name ] = function( type, data, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" ) {
+ for ( var key in type ) {
+ this[ name ](key, data, type[key], fn);
+ }
+ return this;
+ }
+
+ if ( jQuery.isFunction( data ) ) {
+ thisObject = fn;
+ fn = data;
+ data = undefined;
+ }
+
+ var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
+ jQuery( this ).unbind( event, handler );
+ return fn.apply( this, arguments );
+ }) : fn;
+
+ return type === "unload" && name !== "one" ?
+ this.one( type, data, fn, thisObject ) :
+ this.each(function() {
+ jQuery.event.add( this, type, handler, data );
+ });
+ };
+});
+
+jQuery.fn.extend({
+ unbind: function( type, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" && !type.preventDefault ) {
+ for ( var key in type ) {
+ this.unbind(key, type[key]);
+ }
+ return this;
+ }
+
+ return this.each(function() {
+ jQuery.event.remove( this, type, fn );
+ });
+ },
+ trigger: function( type, data ) {
+ return this.each(function() {
+ jQuery.event.trigger( type, data, this );
+ });
+ },
+
+ triggerHandler: function( type, data ) {
+ if ( this[0] ) {
+ var event = jQuery.Event( type );
+ event.preventDefault();
+ event.stopPropagation();
+ jQuery.event.trigger( event, data, this[0] );
+ return event.result;
+ }
+ },
+
+ toggle: function( fn ) {
+ // Save reference to arguments for access in closure
+ var args = arguments, i = 1;
+
+ // link all the functions, so any of them can unbind this click handler
+ while ( i < args.length ) {
+ jQuery.proxy( fn, args[ i++ ] );
+ }
+
+ return this.click( jQuery.proxy( fn, function( event ) {
+ // Figure out which function to execute
+ var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
+ jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
+
+ // Make sure that clicks stop
+ event.preventDefault();
+
+ // and execute the function
+ return args[ lastToggle ].apply( this, arguments ) || false;
+ }));
+ },
+
+ hover: function( fnOver, fnOut ) {
+ return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
+ },
+
+ live: function( type, data, fn ) {
+ if ( jQuery.isFunction( data ) ) {
+ fn = data;
+ data = undefined;
+ }
+
+ jQuery( this.context ).bind( liveConvert( type, this.selector ), {
+ data: data, selector: this.selector, live: type
+ }, fn );
+
+ return this;
+ },
+
+ die: function( type, fn ) {
+ jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null );
+ return this;
+ }
+});
+
+function liveHandler( event ) {
+ var stop = true, elems = [], selectors = [], args = arguments,
+ related, match, fn, elem, j, i, data,
+ live = jQuery.extend({}, jQuery.data( this, "events" ).live);
+
+ for ( j in live ) {
+ fn = live[j];
+ if ( fn.live === event.type ||
+ fn.altLive && jQuery.inArray(event.type, fn.altLive) > -1 ) {
+
+ data = fn.data;
+ if ( !(data.beforeFilter && data.beforeFilter[event.type] &&
+ !data.beforeFilter[event.type](event)) ) {
+ selectors.push( fn.selector );
+ }
+ } else {
+ delete live[j];
+ }
+ }
+
+ match = jQuery( event.target ).closest( selectors, event.currentTarget );
+
+ for ( i = 0, l = match.length; i < l; i++ ) {
+ for ( j in live ) {
+ fn = live[j];
+ elem = match[i].elem;
+ related = null;
+
+ if ( match[i].selector === fn.selector ) {
+ // Those two events require additional checking
+ if ( fn.live === "mouseenter" || fn.live === "mouseleave" ) {
+ related = jQuery( event.relatedTarget ).closest( fn.selector )[0];
+ }
+
+ if ( !related || related !== elem ) {
+ elems.push({ elem: elem, fn: fn });
+ }
+ }
+ }
+ }
+
+ for ( i = 0, l = elems.length; i < l; i++ ) {
+ match = elems[i];
+ event.currentTarget = match.elem;
+ event.data = match.fn.data;
+ if ( match.fn.apply( match.elem, args ) === false ) {
+ stop = false;
+ break;
+ }
+ }
+
+ return stop;
+}
+
+function liveConvert( type, selector ) {
+ return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "&")].join(".");
+}
+
+jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
+ "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
+ "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
+
+ // Handle event binding
+ jQuery.fn[ name ] = function( fn ) {
+ return fn ? this.bind( name, fn ) : this.trigger( name );
+ };
+
+ if ( jQuery.attrFn ) {
+ jQuery.attrFn[ name ] = true;
+ }
+});
+
+// Prevent memory leaks in IE
+// Window isn't included so as not to unbind existing unload events
+// More info:
+// - http://isaacschlueter.com/2006/10/msie-memory-leaks/
+if ( window.attachEvent && !window.addEventListener ) {
+ window.attachEvent("onunload", function() {
+ for ( var id in jQuery.cache ) {
+ if ( jQuery.cache[ id ].handle ) {
+ // Try/Catch is to handle iframes being unloaded, see #4280
+ try {
+ jQuery.event.remove( jQuery.cache[ id ].handle.elem );
+ } catch(e) {}
+ }
+ }
+ });
+}
+/*!
+ * Sizzle CSS Selector Engine - v1.0
+ * Copyright 2009, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ * More information: http://sizzlejs.com/
+ */
+(function(){
+
+var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
+ done = 0,
+ toString = Object.prototype.toString,
+ hasDuplicate = false,
+ baseHasDuplicate = true;
+
+// Here we check if the JavaScript engine is using some sort of
+// optimization where it does not always call our comparision
+// function. If that is the case, discard the hasDuplicate value.
+// Thus far that includes Google Chrome.
+[0, 0].sort(function(){
+ baseHasDuplicate = false;
+ return 0;
+});
+
+var Sizzle = function(selector, context, results, seed) {
+ results = results || [];
+ var origContext = context = context || document;
+
+ if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
+ return [];
+ }
+
+ if ( !selector || typeof selector !== "string" ) {
+ return results;
+ }
+
+ var parts = [], m, set, checkSet, extra, prune = true, contextXML = isXML(context),
+ soFar = selector;
+
+ // Reset the position of the chunker regexp (start from head)
+ while ( (chunker.exec(""), m = chunker.exec(soFar)) !== null ) {
+ soFar = m[3];
+
+ parts.push( m[1] );
+
+ if ( m[2] ) {
+ extra = m[3];
+ break;
+ }
+ }
+
+ if ( parts.length > 1 && origPOS.exec( selector ) ) {
+ if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
+ set = posProcess( parts[0] + parts[1], context );
+ } else {
+ set = Expr.relative[ parts[0] ] ?
+ [ context ] :
+ Sizzle( parts.shift(), context );
+
+ while ( parts.length ) {
+ selector = parts.shift();
+
+ if ( Expr.relative[ selector ] ) {
+ selector += parts.shift();
+ }
+
+ set = posProcess( selector, set );
+ }
+ }
+ } else {
+ // Take a shortcut and set the context if the root selector is an ID
+ // (but not if it'll be faster if the inner selector is an ID)
+ if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
+ Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
+ var ret = Sizzle.find( parts.shift(), context, contextXML );
+ context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];
+ }
+
+ if ( context ) {
+ var ret = seed ?
+ { expr: parts.pop(), set: makeArray(seed) } :
+ Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
+ set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set;
+
+ if ( parts.length > 0 ) {
+ checkSet = makeArray(set);
+ } else {
+ prune = false;
+ }
+
+ while ( parts.length ) {
+ var cur = parts.pop(), pop = cur;
+
+ if ( !Expr.relative[ cur ] ) {
+ cur = "";
+ } else {
+ pop = parts.pop();
+ }
+
+ if ( pop == null ) {
+ pop = context;
+ }
+
+ Expr.relative[ cur ]( checkSet, pop, contextXML );
+ }
+ } else {
+ checkSet = parts = [];
+ }
+ }
+
+ if ( !checkSet ) {
+ checkSet = set;
+ }
+
+ if ( !checkSet ) {
+ throw "Syntax error, unrecognized expression: " + (cur || selector);
+ }
+
+ if ( toString.call(checkSet) === "[object Array]" ) {
+ if ( !prune ) {
+ results.push.apply( results, checkSet );
+ } else if ( context && context.nodeType === 1 ) {
+ for ( var i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {
+ results.push( set[i] );
+ }
+ }
+ } else {
+ for ( var i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
+ results.push( set[i] );
+ }
+ }
+ }
+ } else {
+ makeArray( checkSet, results );
+ }
+
+ if ( extra ) {
+ Sizzle( extra, origContext, results, seed );
+ Sizzle.uniqueSort( results );
+ }
+
+ return results;
+};
+
+Sizzle.uniqueSort = function(results){
+ if ( sortOrder ) {
+ hasDuplicate = baseHasDuplicate;
+ results.sort(sortOrder);
+
+ if ( hasDuplicate ) {
+ for ( var i = 1; i < results.length; i++ ) {
+ if ( results[i] === results[i-1] ) {
+ results.splice(i--, 1);
+ }
+ }
+ }
+ }
+
+ return results;
+};
+
+Sizzle.matches = function(expr, set){
+ return Sizzle(expr, null, null, set);
+};
+
+Sizzle.find = function(expr, context, isXML){
+ var set, match;
+
+ if ( !expr ) {
+ return [];
+ }
+
+ for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
+ var type = Expr.order[i], match;
+
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
+ var left = match[1];
+ match.splice(1,1);
+
+ if ( left.substr( left.length - 1 ) !== "\\" ) {
+ match[1] = (match[1] || "").replace(/\\/g, "");
+ set = Expr.find[ type ]( match, context, isXML );
+ if ( set != null ) {
+ expr = expr.replace( Expr.match[ type ], "" );
+ break;
+ }
+ }
+ }
+ }
+
+ if ( !set ) {
+ set = context.getElementsByTagName("*");
+ }
+
+ return {set: set, expr: expr};
+};
+
+Sizzle.filter = function(expr, set, inplace, not){
+ var old = expr, result = [], curLoop = set, match, anyFound,
+ isXMLFilter = set && set[0] && isXML(set[0]);
+
+ while ( expr && set.length ) {
+ for ( var type in Expr.filter ) {
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
+ var filter = Expr.filter[ type ], found, item, left = match[1];
+ anyFound = false;
+
+ match.splice(1,1);
+
+ if ( left.substr( left.length - 1 ) === "\\" ) {
+ continue;
+ }
+
+ if ( curLoop === result ) {
+ result = [];
+ }
+
+ if ( Expr.preFilter[ type ] ) {
+ match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
+
+ if ( !match ) {
+ anyFound = found = true;
+ } else if ( match === true ) {
+ continue;
+ }
+ }
+
+ if ( match ) {
+ for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
+ if ( item ) {
+ found = filter( item, match, i, curLoop );
+ var pass = not ^ !!found;
+
+ if ( inplace && found != null ) {
+ if ( pass ) {
+ anyFound = true;
+ } else {
+ curLoop[i] = false;
+ }
+ } else if ( pass ) {
+ result.push( item );
+ anyFound = true;
+ }
+ }
+ }
+ }
+
+ if ( found !== undefined ) {
+ if ( !inplace ) {
+ curLoop = result;
+ }
+
+ expr = expr.replace( Expr.match[ type ], "" );
+
+ if ( !anyFound ) {
+ return [];
+ }
+
+ break;
+ }
+ }
+ }
+
+ // Improper expression
+ if ( expr === old ) {
+ if ( anyFound == null ) {
+ throw "Syntax error, unrecognized expression: " + expr;
+ } else {
+ break;
+ }
+ }
+
+ old = expr;
+ }
+
+ return curLoop;
+};
+
+var Expr = Sizzle.selectors = {
+ order: [ "ID", "NAME", "TAG" ],
+ match: {
+ ID: /#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
+ CLASS: /\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
+ NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,
+ ATTR: /\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
+ TAG: /^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,
+ CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
+ POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
+ PSEUDO: /:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
+ },
+ leftMatch: {},
+ attrMap: {
+ "class": "className",
+ "for": "htmlFor"
+ },
+ attrHandle: {
+ href: function(elem){
+ return elem.getAttribute("href");
+ }
+ },
+ relative: {
+ "+": function(checkSet, part){
+ var isPartStr = typeof part === "string",
+ isTag = isPartStr && !/\W/.test(part),
+ isPartStrNotTag = isPartStr && !isTag;
+
+ if ( isTag ) {
+ part = part.toLowerCase();
+ }
+
+ for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
+ if ( (elem = checkSet[i]) ) {
+ while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
+
+ checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
+ elem || false :
+ elem === part;
+ }
+ }
+
+ if ( isPartStrNotTag ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ },
+ ">": function(checkSet, part){
+ var isPartStr = typeof part === "string";
+
+ if ( isPartStr && !/\W/.test(part) ) {
+ part = part.toLowerCase();
+
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ var parent = elem.parentNode;
+ checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
+ }
+ }
+ } else {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ checkSet[i] = isPartStr ?
+ elem.parentNode :
+ elem.parentNode === part;
+ }
+ }
+
+ if ( isPartStr ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ }
+ },
+ "": function(checkSet, part, isXML){
+ var doneName = done++, checkFn = dirCheck;
+
+ if ( typeof part === "string" && !/\W/.test(part) ) {
+ var nodeCheck = part = part.toLowerCase();
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
+ },
+ "~": function(checkSet, part, isXML){
+ var doneName = done++, checkFn = dirCheck;
+
+ if ( typeof part === "string" && !/\W/.test(part) ) {
+ var nodeCheck = part = part.toLowerCase();
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);
+ }
+ },
+ find: {
+ ID: function(match, context, isXML){
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+ return m ? [m] : [];
+ }
+ },
+ NAME: function(match, context){
+ if ( typeof context.getElementsByName !== "undefined" ) {
+ var ret = [], results = context.getElementsByName(match[1]);
+
+ for ( var i = 0, l = results.length; i < l; i++ ) {
+ if ( results[i].getAttribute("name") === match[1] ) {
+ ret.push( results[i] );
+ }
+ }
+
+ return ret.length === 0 ? null : ret;
+ }
+ },
+ TAG: function(match, context){
+ return context.getElementsByTagName(match[1]);
+ }
+ },
+ preFilter: {
+ CLASS: function(match, curLoop, inplace, result, not, isXML){
+ match = " " + match[1].replace(/\\/g, "") + " ";
+
+ if ( isXML ) {
+ return match;
+ }
+
+ for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
+ if ( elem ) {
+ if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) {
+ if ( !inplace ) {
+ result.push( elem );
+ }
+ } else if ( inplace ) {
+ curLoop[i] = false;
+ }
+ }
+ }
+
+ return false;
+ },
+ ID: function(match){
+ return match[1].replace(/\\/g, "");
+ },
+ TAG: function(match, curLoop){
+ return match[1].toLowerCase();
+ },
+ CHILD: function(match){
+ if ( match[1] === "nth" ) {
+ // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
+ var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
+ match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
+ !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
+
+ // calculate the numbers (first)n+(last) including if they are negative
+ match[2] = (test[1] + (test[2] || 1)) - 0;
+ match[3] = test[3] - 0;
+ }
+
+ // TODO: Move to normal caching system
+ match[0] = done++;
+
+ return match;
+ },
+ ATTR: function(match, curLoop, inplace, result, not, isXML){
+ var name = match[1].replace(/\\/g, "");
+
+ if ( !isXML && Expr.attrMap[name] ) {
+ match[1] = Expr.attrMap[name];
+ }
+
+ if ( match[2] === "~=" ) {
+ match[4] = " " + match[4] + " ";
+ }
+
+ return match;
+ },
+ PSEUDO: function(match, curLoop, inplace, result, not){
+ if ( match[1] === "not" ) {
+ // If we're dealing with a complex expression, or a simple one
+ if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
+ match[3] = Sizzle(match[3], null, null, curLoop);
+ } else {
+ var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
+ if ( !inplace ) {
+ result.push.apply( result, ret );
+ }
+ return false;
+ }
+ } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
+ return true;
+ }
+
+ return match;
+ },
+ POS: function(match){
+ match.unshift( true );
+ return match;
+ }
+ },
+ filters: {
+ enabled: function(elem){
+ return elem.disabled === false && elem.type !== "hidden";
+ },
+ disabled: function(elem){
+ return elem.disabled === true;
+ },
+ checked: function(elem){
+ return elem.checked === true;
+ },
+ selected: function(elem){
+ // Accessing this property makes selected-by-default
+ // options in Safari work properly
+ elem.parentNode.selectedIndex;
+ return elem.selected === true;
+ },
+ parent: function(elem){
+ return !!elem.firstChild;
+ },
+ empty: function(elem){
+ return !elem.firstChild;
+ },
+ has: function(elem, i, match){
+ return !!Sizzle( match[3], elem ).length;
+ },
+ header: function(elem){
+ return /h\d/i.test( elem.nodeName );
+ },
+ text: function(elem){
+ return "text" === elem.type;
+ },
+ radio: function(elem){
+ return "radio" === elem.type;
+ },
+ checkbox: function(elem){
+ return "checkbox" === elem.type;
+ },
+ file: function(elem){
+ return "file" === elem.type;
+ },
+ password: function(elem){
+ return "password" === elem.type;
+ },
+ submit: function(elem){
+ return "submit" === elem.type;
+ },
+ image: function(elem){
+ return "image" === elem.type;
+ },
+ reset: function(elem){
+ return "reset" === elem.type;
+ },
+ button: function(elem){
+ return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
+ },
+ input: function(elem){
+ return /input|select|textarea|button/i.test(elem.nodeName);
+ }
+ },
+ setFilters: {
+ first: function(elem, i){
+ return i === 0;
+ },
+ last: function(elem, i, match, array){
+ return i === array.length - 1;
+ },
+ even: function(elem, i){
+ return i % 2 === 0;
+ },
+ odd: function(elem, i){
+ return i % 2 === 1;
+ },
+ lt: function(elem, i, match){
+ return i < match[3] - 0;
+ },
+ gt: function(elem, i, match){
+ return i > match[3] - 0;
+ },
+ nth: function(elem, i, match){
+ return match[3] - 0 === i;
+ },
+ eq: function(elem, i, match){
+ return match[3] - 0 === i;
+ }
+ },
+ filter: {
+ PSEUDO: function(elem, match, i, array){
+ var name = match[1], filter = Expr.filters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+ } else if ( name === "contains" ) {
+ return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
+ } else if ( name === "not" ) {
+ var not = match[3];
+
+ for ( var i = 0, l = not.length; i < l; i++ ) {
+ if ( not[i] === elem ) {
+ return false;
+ }
+ }
+
+ return true;
+ } else {
+ throw "Syntax error, unrecognized expression: " + name;
+ }
+ },
+ CHILD: function(elem, match){
+ var type = match[1], node = elem;
+ switch (type) {
+ case 'only':
+ case 'first':
+ while ( (node = node.previousSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+ if ( type === "first" ) {
+ return true;
+ }
+ node = elem;
+ case 'last':
+ while ( (node = node.nextSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+ return true;
+ case 'nth':
+ var first = match[2], last = match[3];
+
+ if ( first === 1 && last === 0 ) {
+ return true;
+ }
+
+ var doneName = match[0],
+ parent = elem.parentNode;
+
+ if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
+ var count = 0;
+ for ( node = parent.firstChild; node; node = node.nextSibling ) {
+ if ( node.nodeType === 1 ) {
+ node.nodeIndex = ++count;
+ }
+ }
+ parent.sizcache = doneName;
+ }
+
+ var diff = elem.nodeIndex - last;
+ if ( first === 0 ) {
+ return diff === 0;
+ } else {
+ return ( diff % first === 0 && diff / first >= 0 );
+ }
+ }
+ },
+ ID: function(elem, match){
+ return elem.nodeType === 1 && elem.getAttribute("id") === match;
+ },
+ TAG: function(elem, match){
+ return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
+ },
+ CLASS: function(elem, match){
+ return (" " + (elem.className || elem.getAttribute("class")) + " ")
+ .indexOf( match ) > -1;
+ },
+ ATTR: function(elem, match){
+ var name = match[1],
+ result = Expr.attrHandle[ name ] ?
+ Expr.attrHandle[ name ]( elem ) :
+ elem[ name ] != null ?
+ elem[ name ] :
+ elem.getAttribute( name ),
+ value = result + "",
+ type = match[2],
+ check = match[4];
+
+ return result == null ?
+ type === "!=" :
+ type === "=" ?
+ value === check :
+ type === "*=" ?
+ value.indexOf(check) >= 0 :
+ type === "~=" ?
+ (" " + value + " ").indexOf(check) >= 0 :
+ !check ?
+ value && result !== false :
+ type === "!=" ?
+ value !== check :
+ type === "^=" ?
+ value.indexOf(check) === 0 :
+ type === "$=" ?
+ value.substr(value.length - check.length) === check :
+ type === "|=" ?
+ value === check || value.substr(0, check.length + 1) === check + "-" :
+ false;
+ },
+ POS: function(elem, match, i, array){
+ var name = match[2], filter = Expr.setFilters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+ }
+ }
+ }
+};
+
+var origPOS = Expr.match.POS;
+
+for ( var type in Expr.match ) {
+ Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source );
+ Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, function(all, num){
+ return "\\" + (num - 0 + 1);
+ }));
+}
+
+var makeArray = function(array, results) {
+ array = Array.prototype.slice.call( array, 0 );
+
+ if ( results ) {
+ results.push.apply( results, array );
+ return results;
+ }
+
+ return array;
+};
+
+// Perform a simple check to determine if the browser is capable of
+// converting a NodeList to an array using builtin methods.
+try {
+ Array.prototype.slice.call( document.documentElement.childNodes, 0 );
+
+// Provide a fallback method if it does not work
+} catch(e){
+ makeArray = function(array, results) {
+ var ret = results || [];
+
+ if ( toString.call(array) === "[object Array]" ) {
+ Array.prototype.push.apply( ret, array );
+ } else {
+ if ( typeof array.length === "number" ) {
+ for ( var i = 0, l = array.length; i < l; i++ ) {
+ ret.push( array[i] );
+ }
+ } else {
+ for ( var i = 0; array[i]; i++ ) {
+ ret.push( array[i] );
+ }
+ }
+ }
+
+ return ret;
+ };
+}
+
+var sortOrder;
+
+if ( document.documentElement.compareDocumentPosition ) {
+ sortOrder = function( a, b ) {
+ if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.compareDocumentPosition ? -1 : 1;
+ }
+
+ var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+} else if ( "sourceIndex" in document.documentElement ) {
+ sortOrder = function( a, b ) {
+ if ( !a.sourceIndex || !b.sourceIndex ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.sourceIndex ? -1 : 1;
+ }
+
+ var ret = a.sourceIndex - b.sourceIndex;
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+} else if ( document.createRange ) {
+ sortOrder = function( a, b ) {
+ if ( !a.ownerDocument || !b.ownerDocument ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.ownerDocument ? -1 : 1;
+ }
+
+ var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();
+ aRange.setStart(a, 0);
+ aRange.setEnd(a, 0);
+ bRange.setStart(b, 0);
+ bRange.setEnd(b, 0);
+ var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange);
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+}
+
+// Utility function for retreiving the text value of an array of DOM nodes
+function getText( elems ) {
+ var ret = "", elem;
+
+ for ( var i = 0; elems[i]; i++ ) {
+ elem = elems[i];
+
+ // Get the text from text nodes and CDATA nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
+ ret += elem.nodeValue;
+
+ // Traverse everything else, except comment nodes
+ } else if ( elem.nodeType !== 8 ) {
+ ret += getText( elem.childNodes );
+ }
+ }
+
+ return ret;
+}
+
+// Check to see if the browser returns elements by name when
+// querying by getElementById (and provide a workaround)
+(function(){
+ // We're going to inject a fake input element with a specified name
+ var form = document.createElement("div"),
+ id = "script" + (new Date).getTime();
+ form.innerHTML = "<a name='" + id + "'/>";
+
+ // Inject it into the root element, check its status, and remove it quickly
+ var root = document.documentElement;
+ root.insertBefore( form, root.firstChild );
+
+ // The workaround has to do additional checks after a getElementById
+ // Which slows things down for other browsers (hence the branching)
+ if ( document.getElementById( id ) ) {
+ Expr.find.ID = function(match, context, isXML){
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+ return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
+ }
+ };
+
+ Expr.filter.ID = function(elem, match){
+ var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
+ return elem.nodeType === 1 && node && node.nodeValue === match;
+ };
+ }
+
+ root.removeChild( form );
+ root = form = null; // release memory in IE
+})();
+
+(function(){
+ // Check to see if the browser returns only elements
+ // when doing getElementsByTagName("*")
+
+ // Create a fake element
+ var div = document.createElement("div");
+ div.appendChild( document.createComment("") );
+
+ // Make sure no comments are found
+ if ( div.getElementsByTagName("*").length > 0 ) {
+ Expr.find.TAG = function(match, context){
+ var results = context.getElementsByTagName(match[1]);
+
+ // Filter out possible comments
+ if ( match[1] === "*" ) {
+ var tmp = [];
+
+ for ( var i = 0; results[i]; i++ ) {
+ if ( results[i].nodeType === 1 ) {
+ tmp.push( results[i] );
+ }
+ }
+
+ results = tmp;
+ }
+
+ return results;
+ };
+ }
+
+ // Check to see if an attribute returns normalized href attributes
+ div.innerHTML = "<a href='#'></a>";
+ if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
+ div.firstChild.getAttribute("href") !== "#" ) {
+ Expr.attrHandle.href = function(elem){
+ return elem.getAttribute("href", 2);
+ };
+ }
+
+ div = null; // release memory in IE
+})();
+
+if ( document.querySelectorAll ) {
+ (function(){
+ var oldSizzle = Sizzle, div = document.createElement("div");
+ div.innerHTML = "<p class='TEST'></p>";
+
+ // Safari can't handle uppercase or unicode characters when
+ // in quirks mode.
+ if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
+ return;
+ }
+
+ Sizzle = function(query, context, extra, seed){
+ context = context || document;
+
+ // Only use querySelectorAll on non-XML documents
+ // (ID selectors don't work in non-HTML documents)
+ if ( !seed && context.nodeType === 9 && !isXML(context) ) {
+ try {
+ return makeArray( context.querySelectorAll(query), extra );
+ } catch(e){}
+ }
+
+ return oldSizzle(query, context, extra, seed);
+ };
+
+ for ( var prop in oldSizzle ) {
+ Sizzle[ prop ] = oldSizzle[ prop ];
+ }
+
+ div = null; // release memory in IE
+ })();
+}
+
+(function(){
+ var div = document.createElement("div");
+
+ div.innerHTML = "<div class='test e'></div><div class='test'></div>";
+
+ // Opera can't find a second classname (in 9.6)
+ // Also, make sure that getElementsByClassName actually exists
+ if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
+ return;
+ }
+
+ // Safari caches class attributes, doesn't catch changes (in 3.2)
+ div.lastChild.className = "e";
+
+ if ( div.getElementsByClassName("e").length === 1 ) {
+ return;
+ }
+
+ Expr.order.splice(1, 0, "CLASS");
+ Expr.find.CLASS = function(match, context, isXML) {
+ if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
+ return context.getElementsByClassName(match[1]);
+ }
+ };
+
+ div = null; // release memory in IE
+})();
+
+function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ elem = elem[dir];
+ var match = false;
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 && !isXML ){
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+
+ if ( elem.nodeName.toLowerCase() === cur ) {
+ match = elem;
+ break;
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ elem = elem[dir];
+ var match = false;
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 ) {
+ if ( !isXML ) {
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+ if ( typeof cur !== "string" ) {
+ if ( elem === cur ) {
+ match = true;
+ break;
+ }
+
+ } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
+ match = elem;
+ break;
+ }
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+var contains = document.compareDocumentPosition ? function(a, b){
+ return a.compareDocumentPosition(b) & 16;
+} : function(a, b){
+ return a !== b && (a.contains ? a.contains(b) : true);
+};
+
+var isXML = function(elem){
+ // documentElement is verified for cases where it doesn't yet exist
+ // (such as loading iframes in IE - #4833)
+ var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
+ return documentElement ? documentElement.nodeName !== "HTML" : false;
+};
+
+var posProcess = function(selector, context){
+ var tmpSet = [], later = "", match,
+ root = context.nodeType ? [context] : context;
+
+ // Position selectors must be done after the filter
+ // And so must :not(positional) so we move all PSEUDOs to the end
+ while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
+ later += match[0];
+ selector = selector.replace( Expr.match.PSEUDO, "" );
+ }
+
+ selector = Expr.relative[selector] ? selector + "*" : selector;
+
+ for ( var i = 0, l = root.length; i < l; i++ ) {
+ Sizzle( selector, root[i], tmpSet );
+ }
+
+ return Sizzle.filter( later, tmpSet );
+};
+
+// EXPOSE
+jQuery.find = Sizzle;
+jQuery.expr = Sizzle.selectors;
+jQuery.expr[":"] = jQuery.expr.filters;
+jQuery.unique = Sizzle.uniqueSort;
+jQuery.getText = getText;
+jQuery.isXMLDoc = isXML;
+jQuery.contains = contains;
+
+return;
+
+window.Sizzle = Sizzle;
+
+})();
+var runtil = /Until$/,
+ rparentsprev = /^(?:parents|prevUntil|prevAll)/,
+ // Note: This RegExp should be improved, or likely pulled from Sizzle
+ rmultiselector = /,/,
+ slice = Array.prototype.slice;
+
+// Implement the identical functionality for filter and not
+var winnow = function( elements, qualifier, keep ) {
+ if ( jQuery.isFunction( qualifier ) ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ return !!qualifier.call( elem, i, elem ) === keep;
+ });
+
+ } else if ( qualifier.nodeType ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ return (elem === qualifier) === keep;
+ });
+
+ } else if ( typeof qualifier === "string" ) {
+ var filtered = jQuery.grep(elements, function( elem ) {
+ return elem.nodeType === 1;
+ });
+
+ if ( isSimple.test( qualifier ) ) {
+ return jQuery.filter(qualifier, filtered, !keep);
+ } else {
+ qualifier = jQuery.filter( qualifier, elements );
+ }
+ }
+
+ return jQuery.grep(elements, function( elem, i ) {
+ return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
+ });
+};
+
+jQuery.fn.extend({
+ find: function( selector ) {
+ var ret = this.pushStack( "", "find", selector ), length = 0;
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ length = ret.length;
+ jQuery.find( selector, this[i], ret );
+
+ if ( i > 0 ) {
+ // Make sure that the results are unique
+ for ( var n = length; n < ret.length; n++ ) {
+ for ( var r = 0; r < length; r++ ) {
+ if ( ret[r] === ret[n] ) {
+ ret.splice(n--, 1);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return ret;
+ },
+
+ has: function( target ) {
+ var targets = jQuery( target );
+ return this.filter(function() {
+ for ( var i = 0, l = targets.length; i < l; i++ ) {
+ if ( jQuery.contains( this, targets[i] ) ) {
+ return true;
+ }
+ }
+ });
+ },
+
+ not: function( selector ) {
+ return this.pushStack( winnow(this, selector, false), "not", selector);
+ },
+
+ filter: function( selector ) {
+ return this.pushStack( winnow(this, selector, true), "filter", selector );
+ },
+
+ is: function( selector ) {
+ return !!selector && jQuery.filter( selector, this ).length > 0;
+ },
+
+ closest: function( selectors, context ) {
+ if ( jQuery.isArray( selectors ) ) {
+ var ret = [], cur = this[0], match, matches = {}, selector;
+
+ if ( cur && selectors.length ) {
+ for ( var i = 0, l = selectors.length; i < l; i++ ) {
+ selector = selectors[i];
+
+ if ( !matches[selector] ) {
+ matches[selector] = jQuery.expr.match.POS.test( selector ) ?
+ jQuery( selector, context || this.context ) :
+ selector;
+ }
+ }
+
+ while ( cur && cur.ownerDocument && cur !== context ) {
+ for ( selector in matches ) {
+ match = matches[selector];
+
+ if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) {
+ ret.push({ selector: selector, elem: cur });
+ delete matches[selector];
+ }
+ }
+ cur = cur.parentNode;
+ }
+ }
+
+ return ret;
+ }
+
+ var pos = jQuery.expr.match.POS.test( selectors ) ?
+ jQuery( selectors, context || this.context ) : null;
+
+ return this.map(function( i, cur ) {
+ while ( cur && cur.ownerDocument && cur !== context ) {
+ if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selectors) ) {
+ return cur;
+ }
+ cur = cur.parentNode;
+ }
+ return null;
+ });
+ },
+
+ // Determine the position of an element within
+ // the matched set of elements
+ index: function( elem ) {
+ if ( !elem || typeof elem === "string" ) {
+ return jQuery.inArray( this[0],
+ // If it receives a string, the selector is used
+ // If it receives nothing, the siblings are used
+ elem ? jQuery( elem ) : this.parent().children() );
+ }
+ // Locate the position of the desired element
+ return jQuery.inArray(
+ // If it receives a jQuery object, the first element is used
+ elem.jquery ? elem[0] : elem, this );
+ },
+
+ add: function( selector, context ) {
+ var set = typeof selector === "string" ?
+ jQuery( selector, context || this.context ) :
+ jQuery.makeArray( selector ),
+ all = jQuery.merge( this.get(), set );
+
+ return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
+ all :
+ jQuery.unique( all ) );
+ },
+
+ andSelf: function() {
+ return this.add( this.prevObject );
+ }
+});
+
+// A painfully simple check to see if an element is disconnected
+// from a document (should be improved, where feasible).
+function isDisconnected( node ) {
+ return !node || !node.parentNode || node.parentNode.nodeType === 11;
+}
+
+jQuery.each({
+ parent: function( elem ) {
+ var parent = elem.parentNode;
+ return parent && parent.nodeType !== 11 ? parent : null;
+ },
+ parents: function( elem ) {
+ return jQuery.dir( elem, "parentNode" );
+ },
+ parentsUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "parentNode", until );
+ },
+ next: function( elem ) {
+ return jQuery.nth( elem, 2, "nextSibling" );
+ },
+ prev: function( elem ) {
+ return jQuery.nth( elem, 2, "previousSibling" );
+ },
+ nextAll: function( elem ) {
+ return jQuery.dir( elem, "nextSibling" );
+ },
+ prevAll: function( elem ) {
+ return jQuery.dir( elem, "previousSibling" );
+ },
+ nextUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "nextSibling", until );
+ },
+ prevUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "previousSibling", until );
+ },
+ siblings: function( elem ) {
+ return jQuery.sibling( elem.parentNode.firstChild, elem );
+ },
+ children: function( elem ) {
+ return jQuery.sibling( elem.firstChild );
+ },
+ contents: function( elem ) {
+ return jQuery.nodeName( elem, "iframe" ) ?
+ elem.contentDocument || elem.contentWindow.document :
+ jQuery.makeArray( elem.childNodes );
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function( until, selector ) {
+ var ret = jQuery.map( this, fn, until );
+
+ if ( !runtil.test( name ) ) {
+ selector = until;
+ }
+
+ if ( selector && typeof selector === "string" ) {
+ ret = jQuery.filter( selector, ret );
+ }
+
+ ret = this.length > 1 ? jQuery.unique( ret ) : ret;
+
+ if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
+ ret = ret.reverse();
+ }
+
+ return this.pushStack( ret, name, slice.call(arguments).join(",") );
+ };
+});
+
+jQuery.extend({
+ filter: function( expr, elems, not ) {
+ if ( not ) {
+ expr = ":not(" + expr + ")";
+ }
+
+ return jQuery.find.matches(expr, elems);
+ },
+
+ dir: function( elem, dir, until ) {
+ var matched = [], cur = elem[dir];
+ while ( cur && cur.nodeType !== 9 && (until === undefined || !jQuery( cur ).is( until )) ) {
+ if ( cur.nodeType === 1 ) {
+ matched.push( cur );
+ }
+ cur = cur[dir];
+ }
+ return matched;
+ },
+
+ nth: function( cur, result, dir, elem ) {
+ result = result || 1;
+ var num = 0;
+
+ for ( ; cur; cur = cur[dir] ) {
+ if ( cur.nodeType === 1 && ++num === result ) {
+ break;
+ }
+ }
+
+ return cur;
+ },
+
+ sibling: function( n, elem ) {
+ var r = [];
+
+ for ( ; n; n = n.nextSibling ) {
+ if ( n.nodeType === 1 && n !== elem ) {
+ r.push( n );
+ }
+ }
+
+ return r;
+ }
+});
+var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
+ rleadingWhitespace = /^\s+/,
+ rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g,
+ rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,
+ rtagName = /<([\w:]+)/,
+ rtbody = /<tbody/i,
+ rhtml = /<|&\w+;/,
+ fcloseTag = function( all, front, tag ) {
+ return rselfClosing.test( tag ) ?
+ all :
+ front + "></" + tag + ">";
+ },
+ wrapMap = {
+ option: [ 1, "<select multiple='multiple'>", "</select>" ],
+ legend: [ 1, "<fieldset>", "</fieldset>" ],
+ thead: [ 1, "<table>", "</table>" ],
+ tr: [ 2, "<table><tbody>", "</tbody></table>" ],
+ td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
+ col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
+ area: [ 1, "<map>", "</map>" ],
+ _default: [ 0, "", "" ]
+ };
+
+wrapMap.optgroup = wrapMap.option;
+wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
+wrapMap.th = wrapMap.td;
+
+// IE can't serialize <link> and <script> tags normally
+if ( !jQuery.support.htmlSerialize ) {
+ wrapMap._default = [ 1, "div<div>", "</div>" ];
+}
+
+jQuery.fn.extend({
+ text: function( text ) {
+ if ( jQuery.isFunction(text) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ return self.text( text.call(this, i, self.text()) );
+ });
+ }
+
+ if ( typeof text !== "object" && text !== undefined ) {
+ return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
+ }
+
+ return jQuery.getText( this );
+ },
+
+ wrapAll: function( html ) {
+ if ( jQuery.isFunction( html ) ) {
+ return this.each(function(i) {
+ jQuery(this).wrapAll( html.call(this, i) );
+ });
+ }
+
+ if ( this[0] ) {
+ // The elements to wrap the target around
+ var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
+
+ if ( this[0].parentNode ) {
+ wrap.insertBefore( this[0] );
+ }
+
+ wrap.map(function() {
+ var elem = this;
+
+ while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
+ elem = elem.firstChild;
+ }
+
+ return elem;
+ }).append(this);
+ }
+
+ return this;
+ },
+
+ wrapInner: function( html ) {
+ return this.each(function() {
+ var self = jQuery( this ), contents = self.contents();
+
+ if ( contents.length ) {
+ contents.wrapAll( html );
+
+ } else {
+ self.append( html );
+ }
+ });
+ },
+
+ wrap: function( html ) {
+ return this.each(function() {
+ jQuery( this ).wrapAll( html );
+ });
+ },
+
+ unwrap: function() {
+ return this.parent().each(function() {
+ if ( !jQuery.nodeName( this, "body" ) ) {
+ jQuery( this ).replaceWith( this.childNodes );
+ }
+ }).end();
+ },
+
+ append: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 ) {
+ this.appendChild( elem );
+ }
+ });
+ },
+
+ prepend: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 ) {
+ this.insertBefore( elem, this.firstChild );
+ }
+ });
+ },
+
+ before: function() {
+ if ( this[0] && this[0].parentNode ) {
+ return this.domManip(arguments, false, function( elem ) {
+ this.parentNode.insertBefore( elem, this );
+ });
+ } else if ( arguments.length ) {
+ var set = jQuery(arguments[0]);
+ set.push.apply( set, this.toArray() );
+ return this.pushStack( set, "before", arguments );
+ }
+ },
+
+ after: function() {
+ if ( this[0] && this[0].parentNode ) {
+ return this.domManip(arguments, false, function( elem ) {
+ this.parentNode.insertBefore( elem, this.nextSibling );
+ });
+ } else if ( arguments.length ) {
+ var set = this.pushStack( this, "after", arguments );
+ set.push.apply( set, jQuery(arguments[0]).toArray() );
+ return set;
+ }
+ },
+
+ clone: function( events ) {
+ // Do the clone
+ var ret = this.map(function() {
+ if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) {
+ // IE copies events bound via attachEvent when
+ // using cloneNode. Calling detachEvent on the
+ // clone will also remove the events from the orignal
+ // In order to get around this, we use innerHTML.
+ // Unfortunately, this means some modifications to
+ // attributes in IE that are actually only stored
+ // as properties will not be copied (such as the
+ // the name attribute on an input).
+ var html = this.outerHTML, ownerDocument = this.ownerDocument;
+ if ( !html ) {
+ var div = ownerDocument.createElement("div");
+ div.appendChild( this.cloneNode(true) );
+ html = div.innerHTML;
+ }
+
+ return jQuery.clean([html.replace(rinlinejQuery, "")
+ .replace(rleadingWhitespace, "")], ownerDocument)[0];
+ } else {
+ return this.cloneNode(true);
+ }
+ });
+
+ // Copy the events from the original to the clone
+ if ( events === true ) {
+ cloneCopyEvent( this, ret );
+ cloneCopyEvent( this.find("*"), ret.find("*") );
+ }
+
+ // Return the cloned set
+ return ret;
+ },
+
+ html: function( value ) {
+ if ( value === undefined ) {
+ return this[0] && this[0].nodeType === 1 ?
+ this[0].innerHTML.replace(rinlinejQuery, "") :
+ null;
+
+ // See if we can take a shortcut and just use innerHTML
+ } else if ( typeof value === "string" && !/<script/i.test( value ) &&
+ (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
+ !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
+
+ try {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ // Remove element nodes and prevent memory leaks
+ if ( this[i].nodeType === 1 ) {
+ cleanData( this[i].getElementsByTagName("*") );
+ this[i].innerHTML = value;
+ }
+ }
+
+ // If using innerHTML throws an exception, use the fallback method
+ } catch(e) {
+ this.empty().append( value );
+ }
+
+ } else if ( jQuery.isFunction( value ) ) {
+ this.each(function(i){
+ var self = jQuery(this), old = self.html();
+ self.empty().append(function(){
+ return value.call( this, i, old );
+ });
+ });
+
+ } else {
+ this.empty().append( value );
+ }
+
+ return this;
+ },
+
+ replaceWith: function( value ) {
+ if ( this[0] && this[0].parentNode ) {
+ // Make sure that the elements are removed from the DOM before they are inserted
+ // this can help fix replacing a parent with child elements
+ if ( !jQuery.isFunction( value ) ) {
+ value = jQuery( value ).detach();
+ }
+
+ return this.each(function() {
+ var next = this.nextSibling, parent = this.parentNode;
+
+ jQuery(this).remove();
+
+ if ( next ) {
+ jQuery(next).before( value );
+ } else {
+ jQuery(parent).append( value );
+ }
+ });
+ } else {
+ return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value );
+ }
+ },
+
+ detach: function( selector ) {
+ return this.remove( selector, true );
+ },
+
+ domManip: function( args, table, callback ) {
+ var results, first, value = args[0], scripts = [];
+
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ args[0] = value.call(this, i, table ? self.html() : undefined);
+ return self.domManip( args, table, callback );
+ });
+ }
+
+ if ( this[0] ) {
+ // If we're in a fragment, just use that instead of building a new one
+ if ( args[0] && args[0].parentNode && args[0].parentNode.nodeType === 11 ) {
+ results = { fragment: args[0].parentNode };
+ } else {
+ results = buildFragment( args, this, scripts );
+ }
+
+ first = results.fragment.firstChild;
+
+ if ( first ) {
+ table = table && jQuery.nodeName( first, "tr" );
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ callback.call(
+ table ?
+ root(this[i], first) :
+ this[i],
+ results.cacheable || this.length > 1 || i > 0 ?
+ results.fragment.cloneNode(true) :
+ results.fragment
+ );
+ }
+ }
+
+ if ( scripts ) {
+ jQuery.each( scripts, evalScript );
+ }
+ }
+
+ return this;
+
+ function root( elem, cur ) {
+ return jQuery.nodeName(elem, "table") ?
+ (elem.getElementsByTagName("tbody")[0] ||
+ elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
+ elem;
+ }
+ }
+});
+
+function cloneCopyEvent(orig, ret) {
+ var i = 0;
+
+ ret.each(function() {
+ if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) {
+ return;
+ }
+
+ var oldData = jQuery.data( orig[i++] ), curData = jQuery.data( this, oldData ), events = oldData && oldData.events;
+
+ if ( events ) {
+ delete curData.handle;
+ curData.events = {};
+
+ for ( var type in events ) {
+ for ( var handler in events[ type ] ) {
+ jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data );
+ }
+ }
+ }
+ });
+}
+
+function buildFragment( args, nodes, scripts ) {
+ var fragment, cacheable, cached, cacheresults, doc;
+
+ if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) {
+ cacheable = true;
+ cacheresults = jQuery.fragments[ args[0] ];
+ if ( cacheresults ) {
+ if ( cacheresults !== 1 ) {
+ fragment = cacheresults;
+ }
+ cached = true;
+ }
+ }
+
+ if ( !fragment ) {
+ doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
+ fragment = doc.createDocumentFragment();
+ jQuery.clean( args, doc, fragment, scripts );
+ }
+
+ if ( cacheable ) {
+ jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
+ }
+
+ return { fragment: fragment, cacheable: cacheable };
+}
+
+jQuery.fragments = {};
+
+jQuery.each({
+ appendTo: "append",
+ prependTo: "prepend",
+ insertBefore: "before",
+ insertAfter: "after",
+ replaceAll: "replaceWith"
+}, function( name, original ) {
+ jQuery.fn[ name ] = function( selector ) {
+ var ret = [], insert = jQuery( selector );
+
+ for ( var i = 0, l = insert.length; i < l; i++ ) {
+ var elems = (i > 0 ? this.clone(true) : this).get();
+ jQuery.fn[ original ].apply( jQuery(insert[i]), elems );
+ ret = ret.concat( elems );
+ }
+ return this.pushStack( ret, name, insert.selector );
+ };
+});
+
+jQuery.each({
+ // keepData is for internal use only--do not document
+ remove: function( selector, keepData ) {
+ if ( !selector || jQuery.filter( selector, [ this ] ).length ) {
+ if ( !keepData && this.nodeType === 1 ) {
+ cleanData( this.getElementsByTagName("*") );
+ cleanData( [ this ] );
+ }
+
+ if ( this.parentNode ) {
+ this.parentNode.removeChild( this );
+ }
+ }
+ },
+
+ empty: function() {
+ // Remove element nodes and prevent memory leaks
+ if ( this.nodeType === 1 ) {
+ cleanData( this.getElementsByTagName("*") );
+ }
+
+ // Remove any remaining nodes
+ while ( this.firstChild ) {
+ this.removeChild( this.firstChild );
+ }
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function() {
+ return this.each( fn, arguments );
+ };
+});
+
+jQuery.extend({
+ clean: function( elems, context, fragment, scripts ) {
+ context = context || document;
+
+ // !context.createElement fails in IE with an error but returns typeof 'object'
+ if ( typeof context.createElement === "undefined" ) {
+ context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
+ }
+
+ var ret = [];
+
+ jQuery.each(elems, function( i, elem ) {
+ if ( typeof elem === "number" ) {
+ elem += "";
+ }
+
+ if ( !elem ) {
+ return;
+ }
+
+ // Convert html string into DOM nodes
+ if ( typeof elem === "string" && !rhtml.test( elem ) ) {
+ elem = context.createTextNode( elem );
+
+ } else if ( typeof elem === "string" ) {
+ // Fix "XHTML"-style tags in all browsers
+ elem = elem.replace(rxhtmlTag, fcloseTag);
+
+ // Trim whitespace, otherwise indexOf won't work as expected
+ var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
+ wrap = wrapMap[ tag ] || wrapMap._default,
+ depth = wrap[0],
+ div = context.createElement("div");
+
+ // Go to html and back, then peel off extra wrappers
+ div.innerHTML = wrap[1] + elem + wrap[2];
+
+ // Move to the right depth
+ while ( depth-- ) {
+ div = div.lastChild;
+ }
+
+ // Remove IE's autoinserted <tbody> from table fragments
+ if ( !jQuery.support.tbody ) {
+
+ // String was a <table>, *may* have spurious <tbody>
+ var hasBody = rtbody.test(elem),
+ tbody = tag === "table" && !hasBody ?
+ div.firstChild && div.firstChild.childNodes :
+
+ // String was a bare <thead> or <tfoot>
+ wrap[1] === "<table>" && !hasBody ?
+ div.childNodes :
+ [];
+
+ for ( var j = tbody.length - 1; j >= 0 ; --j ) {
+ if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
+ tbody[ j ].parentNode.removeChild( tbody[ j ] );
+ }
+ }
+
+ }
+
+ // IE completely kills leading whitespace when innerHTML is used
+ if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
+ div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
+ }
+
+ elem = jQuery.makeArray( div.childNodes );
+ }
+
+ if ( elem.nodeType ) {
+ ret.push( elem );
+ } else {
+ ret = jQuery.merge( ret, elem );
+ }
+
+ });
+
+ if ( fragment ) {
+ for ( var i = 0; ret[i]; i++ ) {
+ if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
+ scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
+ } else {
+ if ( ret[i].nodeType === 1 ) {
+ ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
+ }
+ fragment.appendChild( ret[i] );
+ }
+ }
+ }
+
+ return ret;
+ }
+});
+
+function cleanData( elems ) {
+ for ( var i = 0, elem, id; (elem = elems[i]) != null; i++ ) {
+ if ( !jQuery.noData[elem.nodeName.toLowerCase()] && (id = elem[expando]) ) {
+ delete jQuery.cache[ id ];
+ }
+ }
+}
+// exclude the following css properties to add px
+var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
+ ralpha = /alpha\([^)]*\)/,
+ ropacity = /opacity=([^)]*)/,
+ rfloat = /float/i,
+ rdashAlpha = /-([a-z])/ig,
+ rupper = /([A-Z])/g,
+ rnumpx = /^-?\d+(?:px)?$/i,
+ rnum = /^-?\d/,
+
+ cssShow = { position: "absolute", visibility: "hidden", display:"block" },
+ cssWidth = [ "Left", "Right" ],
+ cssHeight = [ "Top", "Bottom" ],
+
+ // cache check for defaultView.getComputedStyle
+ getComputedStyle = document.defaultView && document.defaultView.getComputedStyle,
+ // normalize float css property
+ styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat",
+ fcamelCase = function( all, letter ) {
+ return letter.toUpperCase();
+ };
+
+jQuery.fn.css = function( name, value ) {
+ return access( this, name, value, true, function( elem, name, value ) {
+ if ( value === undefined ) {
+ return jQuery.curCSS( elem, name );
+ }
+
+ if ( typeof value === "number" && !rexclude.test(name) ) {
+ value += "px";
+ }
+
+ jQuery.style( elem, name, value );
+ });
+};
+
+jQuery.extend({
+ style: function( elem, name, value ) {
+ // don't set styles on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ // ignore negative width and height values #1599
+ if ( (name === "width" || name === "height") && parseFloat(value) < 0 ) {
+ value = undefined;
+ }
+
+ var style = elem.style || elem, set = value !== undefined;
+
+ // IE uses filters for opacity
+ if ( !jQuery.support.opacity && name === "opacity" ) {
+ if ( set ) {
+ // IE has trouble with opacity if it does not have layout
+ // Force it by setting the zoom level
+ style.zoom = 1;
+
+ // Set the alpha filter to set the opacity
+ var opacity = parseInt( value, 10 ) + "" === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")";
+ var filter = style.filter || jQuery.curCSS( elem, "filter" ) || "";
+ style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : opacity;
+ }
+
+ return style.filter && style.filter.indexOf("opacity=") >= 0 ?
+ (parseFloat( ropacity.exec(style.filter)[1] ) / 100) + "":
+ "";
+ }
+
+ // Make sure we're using the right name for getting the float value
+ if ( rfloat.test( name ) ) {
+ name = styleFloat;
+ }
+
+ name = name.replace(rdashAlpha, fcamelCase);
+
+ if ( set ) {
+ style[ name ] = value;
+ }
+
+ return style[ name ];
+ },
+
+ css: function( elem, name, force, extra ) {
+ if ( name === "width" || name === "height" ) {
+ var val, props = cssShow, which = name === "width" ? cssWidth : cssHeight;
+
+ function getWH() {
+ val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
+
+ if ( extra === "border" ) {
+ return;
+ }
+
+ jQuery.each( which, function() {
+ if ( !extra ) {
+ val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
+ }
+
+ if ( extra === "margin" ) {
+ val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0;
+ } else {
+ val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
+ }
+ });
+ }
+
+ if ( elem.offsetWidth !== 0 ) {
+ getWH();
+ } else {
+ jQuery.swap( elem, props, getWH );
+ }
+
+ return Math.max(0, Math.round(val));
+ }
+
+ return jQuery.curCSS( elem, name, force );
+ },
+
+ curCSS: function( elem, name, force ) {
+ var ret, style = elem.style, filter;
+
+ // IE uses filters for opacity
+ if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) {
+ ret = ropacity.test(elem.currentStyle.filter || "") ?
+ (parseFloat(RegExp.$1) / 100) + "" :
+ "";
+
+ return ret === "" ?
+ "1" :
+ ret;
+ }
+
+ // Make sure we're using the right name for getting the float value
+ if ( rfloat.test( name ) ) {
+ name = styleFloat;
+ }
+
+ if ( !force && style && style[ name ] ) {
+ ret = style[ name ];
+
+ } else if ( getComputedStyle ) {
+
+ // Only "float" is needed here
+ if ( rfloat.test( name ) ) {
+ name = "float";
+ }
+
+ name = name.replace( rupper, "-$1" ).toLowerCase();
+
+ var defaultView = elem.ownerDocument.defaultView;
+
+ if ( !defaultView ) {
+ return null;
+ }
+
+ var computedStyle = defaultView.getComputedStyle( elem, null );
+
+ if ( computedStyle ) {
+ ret = computedStyle.getPropertyValue( name );
+ }
+
+ // We should always get a number back from opacity
+ if ( name === "opacity" && ret === "" ) {
+ ret = "1";
+ }
+
+ } else if ( elem.currentStyle ) {
+ var camelCase = name.replace(rdashAlpha, fcamelCase);
+
+ ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
+
+ // From the awesome hack by Dean Edwards
+ // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
+
+ // If we're not dealing with a regular pixel number
+ // but a number that has a weird ending, we need to convert it to pixels
+ if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
+ // Remember the original values
+ var left = style.left, rsLeft = elem.runtimeStyle.left;
+
+ // Put in the new values to get a computed value out
+ elem.runtimeStyle.left = elem.currentStyle.left;
+ style.left = camelCase === "fontSize" ? "1em" : (ret || 0);
+ ret = style.pixelLeft + "px";
+
+ // Revert the changed values
+ style.left = left;
+ elem.runtimeStyle.left = rsLeft;
+ }
+ }
+
+ return ret;
+ },
+
+ // A method for quickly swapping in/out CSS properties to get correct calculations
+ swap: function( elem, options, callback ) {
+ var old = {};
+
+ // Remember the old values, and insert the new ones
+ for ( var name in options ) {
+ old[ name ] = elem.style[ name ];
+ elem.style[ name ] = options[ name ];
+ }
+
+ callback.call( elem );
+
+ // Revert the old values
+ for ( var name in options ) {
+ elem.style[ name ] = old[ name ];
+ }
+ }
+});
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.hidden = function( elem ) {
+ var width = elem.offsetWidth, height = elem.offsetHeight,
+ skip = elem.nodeName.toLowerCase() === "tr";
+
+ return width === 0 && height === 0 && !skip ?
+ true :
+ width > 0 && height > 0 && !skip ?
+ false :
+ jQuery.curCSS(elem, "display") === "none";
+ };
+
+ jQuery.expr.filters.visible = function( elem ) {
+ return !jQuery.expr.filters.hidden( elem );
+ };
+}
+var jsc = now(),
+ rscript = /<script(.|\s)*?\/script>/gi,
+ rselectTextarea = /select|textarea/i,
+ rinput = /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,
+ jsre = /=\?(&|$)/,
+ rquery = /\?/,
+ rts = /(\?|&)_=.*?(&|$)/,
+ rurl = /^(\w+:)?\/\/([^\/?#]+)/,
+ r20 = /%20/g;
+
+jQuery.fn.extend({
+ // Keep a copy of the old load
+ _load: jQuery.fn.load,
+
+ load: function( url, params, callback ) {
+ if ( typeof url !== "string" ) {
+ return this._load( url );
+
+ // Don't do a request if no elements are being requested
+ } else if ( !this.length ) {
+ return this;
+ }
+
+ var off = url.indexOf(" ");
+ if ( off >= 0 ) {
+ var selector = url.slice(off, url.length);
+ url = url.slice(0, off);
+ }
+
+ // Default to a GET request
+ var type = "GET";
+
+ // If the second parameter was provided
+ if ( params ) {
+ // If it's a function
+ if ( jQuery.isFunction( params ) ) {
+ // We assume that it's the callback
+ callback = params;
+ params = null;
+
+ // Otherwise, build a param string
+ } else if ( typeof params === "object" ) {
+ params = jQuery.param( params, jQuery.ajaxSettings.traditional );
+ type = "POST";
+ }
+ }
+
+ // Request the remote document
+ jQuery.ajax({
+ url: url,
+ type: type,
+ dataType: "html",
+ data: params,
+ context:this,
+ complete: function( res, status ) {
+ // If successful, inject the HTML into all the matched elements
+ if ( status === "success" || status === "notmodified" ) {
+ // See if a selector was specified
+ this.html( selector ?
+ // Create a dummy div to hold the results
+ jQuery("<div />")
+ // inject the contents of the document in, removing the scripts
+ // to avoid any 'Permission Denied' errors in IE
+ .append(res.responseText.replace(rscript, ""))
+
+ // Locate the specified elements
+ .find(selector) :
+
+ // If not, just inject the full result
+ res.responseText );
+ }
+
+ if ( callback ) {
+ this.each( callback, [res.responseText, status, res] );
+ }
+ }
+ });
+
+ return this;
+ },
+
+ serialize: function() {
+ return jQuery.param(this.serializeArray());
+ },
+ serializeArray: function() {
+ return this.map(function() {
+ return this.elements ? jQuery.makeArray(this.elements) : this;
+ })
+ .filter(function() {
+ return this.name && !this.disabled &&
+ (this.checked || rselectTextarea.test(this.nodeName) ||
+ rinput.test(this.type));
+ })
+ .map(function( i, elem ) {
+ var val = jQuery(this).val();
+
+ return val == null ?
+ null :
+ jQuery.isArray(val) ?
+ jQuery.map( val, function( val, i ) {
+ return { name: elem.name, value: val };
+ }) :
+ { name: elem.name, value: val };
+ }).get();
+ }
+});
+
+// Attach a bunch of functions for handling common AJAX events
+jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function( i, o ) {
+ jQuery.fn[o] = function( f ) {
+ return this.bind(o, f);
+ };
+});
+
+jQuery.extend({
+
+ get: function( url, data, callback, type ) {
+ // shift arguments if data argument was omited
+ if ( jQuery.isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = null;
+ }
+
+ return jQuery.ajax({
+ type: "GET",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ getScript: function( url, callback ) {
+ return jQuery.get(url, null, callback, "script");
+ },
+
+ getJSON: function( url, data, callback ) {
+ return jQuery.get(url, data, callback, "json");
+ },
+
+ post: function( url, data, callback, type ) {
+ // shift arguments if data argument was omited
+ if ( jQuery.isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = {};
+ }
+
+ return jQuery.ajax({
+ type: "POST",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ ajaxSetup: function( settings ) {
+ jQuery.extend( jQuery.ajaxSettings, settings );
+ },
+
+ ajaxSettings: {
+ url: location.href,
+ global: true,
+ type: "GET",
+ contentType: "application/x-www-form-urlencoded",
+ processData: true,
+ async: true,
+ /*
+ timeout: 0,
+ data: null,
+ username: null,
+ password: null,
+ traditional: false,
+ */
+ // Create the request object; Microsoft failed to properly
+ // implement the XMLHttpRequest in IE7 (can't request local files),
+ // so we use the ActiveXObject when it is available
+ // This function can be overriden by calling jQuery.ajaxSetup
+ xhr: window.XMLHttpRequest && (window.location.protocol !== "file:" || !window.ActiveXObject) ?
+ function() {
+ return new window.XMLHttpRequest();
+ } :
+ function() {
+ try {
+ return new window.ActiveXObject("Microsoft.XMLHTTP");
+ } catch(e) {}
+ },
+ accepts: {
+ xml: "application/xml, text/xml",
+ html: "text/html",
+ script: "text/javascript, application/javascript",
+ json: "application/json, text/javascript",
+ text: "text/plain",
+ _default: "*/*"
+ }
+ },
+
+ // Last-Modified header cache for next request
+ lastModified: {},
+ etag: {},
+
+ ajax: function( origSettings ) {
+ var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings);
+
+ var jsonp, status, data,
+ callbackContext = s.context || s,
+ type = s.type.toUpperCase();
+
+ // convert data if not already a string
+ if ( s.data && s.processData && typeof s.data !== "string" ) {
+ s.data = jQuery.param( s.data, s.traditional );
+ }
+
+ // Handle JSONP Parameter Callbacks
+ if ( s.dataType === "jsonp" ) {
+ if ( type === "GET" ) {
+ if ( !jsre.test( s.url ) ) {
+ s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?";
+ }
+ } else if ( !s.data || !jsre.test(s.data) ) {
+ s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
+ }
+ s.dataType = "json";
+ }
+
+ // Build temporary JSONP function
+ if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) {
+ jsonp = s.jsonpCallback || ("jsonp" + jsc++);
+
+ // Replace the =? sequence both in the query string and the data
+ if ( s.data ) {
+ s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
+ }
+
+ s.url = s.url.replace(jsre, "=" + jsonp + "$1");
+
+ // We need to make sure
+ // that a JSONP style response is executed properly
+ s.dataType = "script";
+
+ // Handle JSONP-style loading
+ window[ jsonp ] = window[ jsonp ] || function( tmp ) {
+ data = tmp;
+ success();
+ complete();
+ // Garbage collect
+ window[ jsonp ] = undefined;
+
+ try {
+ delete window[ jsonp ];
+ } catch(e) {}
+
+ if ( head ) {
+ head.removeChild( script );
+ }
+ };
+ }
+
+ if ( s.dataType === "script" && s.cache === null ) {
+ s.cache = false;
+ }
+
+ if ( s.cache === false && type === "GET" ) {
+ var ts = now();
+
+ // try replacing _= if it is there
+ var ret = s.url.replace(rts, "$1_=" + ts + "$2");
+
+ // if nothing was replaced, add timestamp to the end
+ s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : "");
+ }
+
+ // If data is available, append data to url for get requests
+ if ( s.data && type === "GET" ) {
+ s.url += (rquery.test(s.url) ? "&" : "?") + s.data;
+ }
+
+ // Watch for a new set of requests
+ if ( s.global && ! jQuery.active++ ) {
+ jQuery.event.trigger( "ajaxStart" );
+ }
+
+ // Matches an absolute URL, and saves the domain
+ var parts = rurl.exec( s.url ),
+ remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host);
+
+ // If we're requesting a remote document
+ // and trying to load JSON or Script with a GET
+ if ( s.dataType === "script" && type === "GET" && remote ) {
+ var head = document.getElementsByTagName("head")[0] || document.documentElement;
+ var script = document.createElement("script");
+ script.src = s.url;
+ if ( s.scriptCharset ) {
+ script.charset = s.scriptCharset;
+ }
+
+ // Handle Script loading
+ if ( !jsonp ) {
+ var done = false;
+
+ // Attach handlers for all browsers
+ script.onload = script.onreadystatechange = function() {
+ if ( !done && (!this.readyState ||
+ this.readyState === "loaded" || this.readyState === "complete") ) {
+ done = true;
+ success();
+ complete();
+
+ // Handle memory leak in IE
+ script.onload = script.onreadystatechange = null;
+ if ( head && script.parentNode ) {
+ head.removeChild( script );
+ }
+ }
+ };
+ }
+
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709 and #4378).
+ head.insertBefore( script, head.firstChild );
+
+ // We handle everything using the script element injection
+ return undefined;
+ }
+
+ var requestDone = false;
+
+ // Create the request object
+ var xhr = s.xhr();
+
+ if ( !xhr ) {
+ return;
+ }
+
+ // Open the socket
+ // Passing null username, generates a login popup on Opera (#2865)
+ if ( s.username ) {
+ xhr.open(type, s.url, s.async, s.username, s.password);
+ } else {
+ xhr.open(type, s.url, s.async);
+ }
+
+ // Need an extra try/catch for cross domain requests in Firefox 3
+ try {
+ // Set the correct header, if data is being sent
+ if ( s.data || origSettings && origSettings.contentType ) {
+ xhr.setRequestHeader("Content-Type", s.contentType);
+ }
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if ( s.ifModified ) {
+ if ( jQuery.lastModified[s.url] ) {
+ xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]);
+ }
+
+ if ( jQuery.etag[s.url] ) {
+ xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]);
+ }
+ }
+
+ // Set header so the called script knows that it's an XMLHttpRequest
+ // Only send the header if it's not a remote XHR
+ if ( !remote ) {
+ xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+ }
+
+ // Set the Accepts header for the server, depending on the dataType
+ xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ?
+ s.accepts[ s.dataType ] + ", */*" :
+ s.accepts._default );
+ } catch(e) {}
+
+ // Allow custom headers/mimetypes and early abort
+ if ( s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false ) {
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active ) {
+ jQuery.event.trigger( "ajaxStop" );
+ }
+
+ // close opended socket
+ xhr.abort();
+ return false;
+ }
+
+ if ( s.global ) {
+ trigger("ajaxSend", [xhr, s]);
+ }
+
+ // Wait for a response to come back
+ var onreadystatechange = xhr.onreadystatechange = function( isTimeout ) {
+ // The request was aborted
+ if ( !xhr || xhr.readyState === 0 ) {
+ // Opera doesn't call onreadystatechange before this point
+ // so we simulate the call
+ if ( !requestDone ) {
+ complete();
+ }
+
+ requestDone = true;
+ if ( xhr ) {
+ xhr.onreadystatechange = jQuery.noop;
+ }
+
+ // The transfer is complete and the data is available, or the request timed out
+ } else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) {
+ requestDone = true;
+ xhr.onreadystatechange = jQuery.noop;
+
+ status = isTimeout === "timeout" ?
+ "timeout" :
+ !jQuery.httpSuccess( xhr ) ?
+ "error" :
+ s.ifModified && jQuery.httpNotModified( xhr, s.url ) ?
+ "notmodified" :
+ "success";
+
+ if ( status === "success" ) {
+ // Watch for, and catch, XML document parse errors
+ try {
+ // process the data (runs the xml through httpData regardless of callback)
+ data = jQuery.httpData( xhr, s.dataType, s );
+ } catch(e) {
+ status = "parsererror";
+ }
+ }
+
+ // Make sure that the request was successful or notmodified
+ if ( status === "success" || status === "notmodified" ) {
+ // JSONP handles its own success callback
+ if ( !jsonp ) {
+ success();
+ }
+ } else {
+ jQuery.handleError(s, xhr, status);
+ }
+
+ // Fire the complete handlers
+ complete();
+
+ if ( isTimeout === "timeout" ) {
+ xhr.abort();
+ }
+
+ // Stop memory leaks
+ if ( s.async ) {
+ xhr = null;
+ }
+ }
+ };
+
+ // Override the abort handler, if we can (IE doesn't allow it, but that's OK)
+ // Opera doesn't fire onreadystatechange at all on abort
+ try {
+ var oldAbort = xhr.abort;
+ xhr.abort = function() {
+ if ( xhr ) {
+ oldAbort.call( xhr );
+ if ( xhr ) {
+ xhr.readyState = 0;
+ }
+ }
+
+ onreadystatechange();
+ };
+ } catch(e) { }
+
+ // Timeout checker
+ if ( s.async && s.timeout > 0 ) {
+ setTimeout(function() {
+ // Check to see if the request is still happening
+ if ( xhr && !requestDone ) {
+ onreadystatechange( "timeout" );
+ }
+ }, s.timeout);
+ }
+
+ // Send the data
+ try {
+ xhr.send( type === "POST" || type === "PUT" || type === "DELETE" ? s.data : null );
+ } catch(e) {
+ jQuery.handleError(s, xhr, null, e);
+ // Fire the complete handlers
+ complete();
+ }
+
+ // firefox 1.5 doesn't fire statechange for sync requests
+ if ( !s.async ) {
+ onreadystatechange();
+ }
+
+ function success() {
+ // If a local callback was specified, fire it and pass it the data
+ if ( s.success ) {
+ s.success.call( callbackContext, data, status, xhr );
+ }
+
+ // Fire the global callback
+ if ( s.global ) {
+ trigger( "ajaxSuccess", [xhr, s] );
+ }
+ }
+
+ function complete() {
+ // Process result
+ if ( s.complete ) {
+ s.complete.call( callbackContext, xhr, status);
+ }
+
+ // The request was completed
+ if ( s.global ) {
+ trigger( "ajaxComplete", [xhr, s] );
+ }
+
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active ) {
+ jQuery.event.trigger( "ajaxStop" );
+ }
+ }
+
+ function trigger(type, args) {
+ (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args);
+ }
+
+ // return XMLHttpRequest to allow aborting the request etc.
+ return xhr;
+ },
+
+ handleError: function( s, xhr, status, e ) {
+ // If a local callback was specified, fire it
+ if ( s.error ) {
+ s.error.call( s.context || window, xhr, status, e );
+ }
+
+ // Fire the global callback
+ if ( s.global ) {
+ (s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] );
+ }
+ },
+
+ // Counter for holding the number of active queries
+ active: 0,
+
+ // Determines if an XMLHttpRequest was successful or not
+ httpSuccess: function( xhr ) {
+ try {
+ // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
+ return !xhr.status && location.protocol === "file:" ||
+ // Opera returns 0 when status is 304
+ ( xhr.status >= 200 && xhr.status < 300 ) ||
+ xhr.status === 304 || xhr.status === 1223 || xhr.status === 0;
+ } catch(e) {}
+
+ return false;
+ },
+
+ // Determines if an XMLHttpRequest returns NotModified
+ httpNotModified: function( xhr, url ) {
+ var lastModified = xhr.getResponseHeader("Last-Modified"),
+ etag = xhr.getResponseHeader("Etag");
+
+ if ( lastModified ) {
+ jQuery.lastModified[url] = lastModified;
+ }
+
+ if ( etag ) {
+ jQuery.etag[url] = etag;
+ }
+
+ // Opera returns 0 when status is 304
+ return xhr.status === 304 || xhr.status === 0;
+ },
+
+ httpData: function( xhr, type, s ) {
+ var ct = xhr.getResponseHeader("content-type") || "",
+ xml = type === "xml" || !type && ct.indexOf("xml") >= 0,
+ data = xml ? xhr.responseXML : xhr.responseText;
+
+ if ( xml && data.documentElement.nodeName === "parsererror" ) {
+ throw "parsererror";
+ }
+
+ // Allow a pre-filtering function to sanitize the response
+ // s is checked to keep backwards compatibility
+ if ( s && s.dataFilter ) {
+ data = s.dataFilter( data, type );
+ }
+
+ // The filter can actually parse the response
+ if ( typeof data === "string" ) {
+ // Get the JavaScript object, if JSON is used.
+ if ( type === "json" || !type && ct.indexOf("json") >= 0 ) {
+ // Make sure the incoming data is actual JSON
+ // Logic borrowed from http://json.org/json2.js
+ if (/^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]")
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ""))) {
+
+ // Try to use the native JSON parser first
+ if ( window.JSON && window.JSON.parse ) {
+ data = window.JSON.parse( data );
+
+ } else {
+ data = (new Function("return " + data))();
+ }
+
+ } else {
+ throw "Invalid JSON: " + data;
+ }
+
+ // If the type is "script", eval it in global context
+ } else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) {
+ jQuery.globalEval( data );
+ }
+ }
+
+ return data;
+ },
+
+ // Serialize an array of form elements or a set of
+ // key/values into a query string
+ param: function( a, traditional ) {
+
+ var s = [];
+
+ // Set traditional to true for jQuery <= 1.3.2 behavior.
+ if ( traditional === undefined ) {
+ traditional = jQuery.ajaxSettings.traditional;
+ }
+
+ function add( key, value ) {
+ // If value is a function, invoke it and return its value
+ value = jQuery.isFunction(value) ? value() : value;
+ s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
+ }
+
+ // If an array was passed in, assume that it is an array of form elements.
+ if ( jQuery.isArray(a) || a.jquery ) {
+ // Serialize the form elements
+ jQuery.each( a, function() {
+ add( this.name, this.value );
+ });
+
+ } else {
+ // If traditional, encode the "old" way (the way 1.3.2 or older
+ // did it), otherwise encode params recursively.
+ jQuery.each( a, function buildParams( prefix, obj ) {
+
+ if ( jQuery.isArray(obj) ) {
+ // Serialize array item.
+ jQuery.each( obj, function( i, v ) {
+ if ( traditional ) {
+ // Treat each array item as a scalar.
+ add( prefix, v );
+ } else {
+ // If array item is non-scalar (array or object), encode its
+ // numeric index to resolve deserialization ambiguity issues.
+ // Note that rack (as of 1.0.0) can't currently deserialize
+ // nested arrays properly, and attempting to do so may cause
+ // a server error. Possible fixes are to modify rack's
+ // deserialization algorithm or to provide an option or flag
+ // to force array serialization to be shallow.
+ buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v );
+ }
+ });
+
+ } else if ( !traditional && obj != null && typeof obj === "object" ) {
+ // Serialize object item.
+ jQuery.each( obj, function( k, v ) {
+ buildParams( prefix + "[" + k + "]", v );
+ });
+
+ } else {
+ // Serialize scalar item.
+ add( prefix, obj );
+ }
+ });
+ }
+
+ // Return the resulting serialization
+ return s.join("&").replace(r20, "+");
+ }
+
+});
+var elemdisplay = {},
+ rfxtypes = /toggle|show|hide/,
+ rfxnum = /^([+-]=)?([\d+-.]+)(.*)$/,
+ timerId,
+ fxAttrs = [
+ // height animations
+ [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
+ // width animations
+ [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
+ // opacity animations
+ [ "opacity" ]
+ ];
+
+jQuery.fn.extend({
+ show: function( speed, callback ) {
+ if ( speed != null ) {
+ return this.animate( genFx("show", 3), speed, callback);
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var old = jQuery.data(this[i], "olddisplay");
+
+ this[i].style.display = old || "";
+
+ if ( jQuery.css(this[i], "display") === "none" ) {
+ var nodeName = this[i].nodeName, display;
+
+ if ( elemdisplay[ nodeName ] ) {
+ display = elemdisplay[ nodeName ];
+
+ } else {
+ var elem = jQuery("<" + nodeName + " />").appendTo("body");
+
+ display = elem.css("display");
+
+ if ( display === "none" ) {
+ display = "block";
+ }
+
+ elem.remove();
+
+ elemdisplay[ nodeName ] = display;
+ }
+
+ jQuery.data(this[i], "olddisplay", display);
+ }
+ }
+
+ // Set the display of the elements in a second loop
+ // to avoid the constant reflow
+ for ( var j = 0, k = this.length; j < k; j++ ) {
+ this[j].style.display = jQuery.data(this[j], "olddisplay") || "";
+ }
+
+ return this;
+ }
+ },
+
+ hide: function( speed, callback ) {
+ if ( speed != null ) {
+ return this.animate( genFx("hide", 3), speed, callback);
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var old = jQuery.data(this[i], "olddisplay");
+ if ( !old && old !== "none" ) {
+ jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display"));
+ }
+ }
+
+ // Set the display of the elements in a second loop
+ // to avoid the constant reflow
+ for ( var j = 0, k = this.length; j < k; j++ ) {
+ this[j].style.display = "none";
+ }
+
+ return this;
+ }
+ },
+
+ // Save the old toggle function
+ _toggle: jQuery.fn.toggle,
+
+ toggle: function( fn, fn2 ) {
+ var bool = typeof fn === "boolean";
+
+ if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
+ this._toggle.apply( this, arguments );
+
+ } else if ( fn == null || bool ) {
+ this.each(function() {
+ var state = bool ? fn : jQuery(this).is(":hidden");
+ jQuery(this)[ state ? "show" : "hide" ]();
+ });
+
+ } else {
+ this.animate(genFx("toggle", 3), fn, fn2);
+ }
+
+ return this;
+ },
+
+ fadeTo: function( speed, to, callback ) {
+ return this.filter(":hidden").css("opacity", 0).show().end()
+ .animate({opacity: to}, speed, callback);
+ },
+
+ animate: function( prop, speed, easing, callback ) {
+ var optall = jQuery.speed(speed, easing, callback);
+
+ if ( jQuery.isEmptyObject( prop ) ) {
+ return this.each( optall.complete );
+ }
+
+ return this[ optall.queue === false ? "each" : "queue" ](function() {
+ var opt = jQuery.extend({}, optall), p,
+ hidden = this.nodeType === 1 && jQuery(this).is(":hidden"),
+ self = this;
+
+ for ( p in prop ) {
+ var name = p.replace(rdashAlpha, fcamelCase);
+
+ if ( p !== name ) {
+ prop[ name ] = prop[ p ];
+ delete prop[ p ];
+ p = name;
+ }
+
+ if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
+ return opt.complete.call(this);
+ }
+
+ if ( ( p === "height" || p === "width" ) && this.style ) {
+ // Store display property
+ opt.display = jQuery.css(this, "display");
+
+ // Make sure that nothing sneaks out
+ opt.overflow = this.style.overflow;
+ }
+
+ if ( jQuery.isArray( prop[p] ) ) {
+ // Create (if needed) and add to specialEasing
+ (opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1];
+ prop[p] = prop[p][0];
+ }
+ }
+
+ if ( opt.overflow != null ) {
+ this.style.overflow = "hidden";
+ }
+
+ opt.curAnim = jQuery.extend({}, prop);
+
+ jQuery.each( prop, function( name, val ) {
+ var e = new jQuery.fx( self, opt, name );
+
+ if ( rfxtypes.test(val) ) {
+ e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop );
+
+ } else {
+ var parts = rfxnum.exec(val),
+ start = e.cur(true) || 0;
+
+ if ( parts ) {
+ var end = parseFloat( parts[2] ),
+ unit = parts[3] || "px";
+
+ // We need to compute starting value
+ if ( unit !== "px" ) {
+ self.style[ name ] = (end || 1) + unit;
+ start = ((end || 1) / e.cur(true)) * start;
+ self.style[ name ] = start + unit;
+ }
+
+ // If a +=/-= token was provided, we're doing a relative animation
+ if ( parts[1] ) {
+ end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
+ }
+
+ e.custom( start, end, unit );
+
+ } else {
+ e.custom( start, val, "" );
+ }
+ }
+ });
+
+ // For JS strict compliance
+ return true;
+ });
+ },
+
+ stop: function( clearQueue, gotoEnd ) {
+ var timers = jQuery.timers;
+
+ if ( clearQueue ) {
+ this.queue([]);
+ }
+
+ this.each(function() {
+ // go in reverse order so anything added to the queue during the loop is ignored
+ for ( var i = timers.length - 1; i >= 0; i-- ) {
+ if ( timers[i].elem === this ) {
+ if (gotoEnd) {
+ // force the next step to be the last
+ timers[i](true);
+ }
+
+ timers.splice(i, 1);
+ }
+ }
+ });
+
+ // start the next in the queue if the last step wasn't forced
+ if ( !gotoEnd ) {
+ this.dequeue();
+ }
+
+ return this;
+ }
+
+});
+
+// Generate shortcuts for custom animations
+jQuery.each({
+ slideDown: genFx("show", 1),
+ slideUp: genFx("hide", 1),
+ slideToggle: genFx("toggle", 1),
+ fadeIn: { opacity: "show" },
+ fadeOut: { opacity: "hide" }
+}, function( name, props ) {
+ jQuery.fn[ name ] = function( speed, callback ) {
+ return this.animate( props, speed, callback );
+ };
+});
+
+jQuery.extend({
+ speed: function( speed, easing, fn ) {
+ var opt = speed && typeof speed === "object" ? speed : {
+ complete: fn || !fn && easing ||
+ jQuery.isFunction( speed ) && speed,
+ duration: speed,
+ easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
+ };
+
+ opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
+ jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default;
+
+ // Queueing
+ opt.old = opt.complete;
+ opt.complete = function() {
+ if ( opt.queue !== false ) {
+ jQuery(this).dequeue();
+ }
+ if ( jQuery.isFunction( opt.old ) ) {
+ opt.old.call( this );
+ }
+ };
+
+ return opt;
+ },
+
+ easing: {
+ linear: function( p, n, firstNum, diff ) {
+ return firstNum + diff * p;
+ },
+ swing: function( p, n, firstNum, diff ) {
+ return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
+ }
+ },
+
+ timers: [],
+
+ fx: function( elem, options, prop ) {
+ this.options = options;
+ this.elem = elem;
+ this.prop = prop;
+
+ if ( !options.orig ) {
+ options.orig = {};
+ }
+ }
+
+});
+
+jQuery.fx.prototype = {
+ // Simple function for setting a style value
+ update: function() {
+ if ( this.options.step ) {
+ this.options.step.call( this.elem, this.now, this );
+ }
+
+ (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
+
+ // Set display property to block for height/width animations
+ if ( ( this.prop === "height" || this.prop === "width" ) && this.elem.style ) {
+ this.elem.style.display = "block";
+ }
+ },
+
+ // Get the current size
+ cur: function( force ) {
+ if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
+ return this.elem[ this.prop ];
+ }
+
+ var r = parseFloat(jQuery.css(this.elem, this.prop, force));
+ return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
+ },
+
+ // Start an animation from one number to another
+ custom: function( from, to, unit ) {
+ this.startTime = now();
+ this.start = from;
+ this.end = to;
+ this.unit = unit || this.unit || "px";
+ this.now = this.start;
+ this.pos = this.state = 0;
+
+ var self = this;
+ function t( gotoEnd ) {
+ return self.step(gotoEnd);
+ }
+
+ t.elem = this.elem;
+
+ if ( t() && jQuery.timers.push(t) && !timerId ) {
+ timerId = setInterval(jQuery.fx.tick, 13);
+ }
+ },
+
+ // Simple 'show' function
+ show: function() {
+ // Remember where we started, so that we can go back to it later
+ this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
+ this.options.show = true;
+
+ // Begin the animation
+ // Make sure that we start at a small width/height to avoid any
+ // flash of content
+ this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
+
+ // Start by showing the element
+ jQuery( this.elem ).show();
+ },
+
+ // Simple 'hide' function
+ hide: function() {
+ // Remember where we started, so that we can go back to it later
+ this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
+ this.options.hide = true;
+
+ // Begin the animation
+ this.custom(this.cur(), 0);
+ },
+
+ // Each step of an animation
+ step: function( gotoEnd ) {
+ var t = now(), done = true;
+
+ if ( gotoEnd || t >= this.options.duration + this.startTime ) {
+ this.now = this.end;
+ this.pos = this.state = 1;
+ this.update();
+
+ this.options.curAnim[ this.prop ] = true;
+
+ for ( var i in this.options.curAnim ) {
+ if ( this.options.curAnim[i] !== true ) {
+ done = false;
+ }
+ }
+
+ if ( done ) {
+ if ( this.options.display != null ) {
+ // Reset the overflow
+ this.elem.style.overflow = this.options.overflow;
+
+ // Reset the display
+ var old = jQuery.data(this.elem, "olddisplay");
+ this.elem.style.display = old ? old : this.options.display;
+
+ if ( jQuery.css(this.elem, "display") === "none" ) {
+ this.elem.style.display = "block";
+ }
+ }
+
+ // Hide the element if the "hide" operation was done
+ if ( this.options.hide ) {
+ jQuery(this.elem).hide();
+ }
+
+ // Reset the properties, if the item has been hidden or shown
+ if ( this.options.hide || this.options.show ) {
+ for ( var p in this.options.curAnim ) {
+ jQuery.style(this.elem, p, this.options.orig[p]);
+ }
+ }
+
+ // Execute the complete function
+ this.options.complete.call( this.elem );
+ }
+
+ return false;
+
+ } else {
+ var n = t - this.startTime;
+ this.state = n / this.options.duration;
+
+ // Perform the easing function, defaults to swing
+ var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop];
+ var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear");
+ this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration);
+ this.now = this.start + ((this.end - this.start) * this.pos);
+
+ // Perform the next step of the animation
+ this.update();
+ }
+
+ return true;
+ }
+};
+
+jQuery.extend( jQuery.fx, {
+ tick: function() {
+ var timers = jQuery.timers;
+
+ for ( var i = 0; i < timers.length; i++ ) {
+ if ( !timers[i]() ) {
+ timers.splice(i--, 1);
+ }
+ }
+
+ if ( !timers.length ) {
+ jQuery.fx.stop();
+ }
+ },
+
+ stop: function() {
+ clearInterval( timerId );
+ timerId = null;
+ },
+
+ speeds: {
+ slow: 600,
+ fast: 200,
+ // Default speed
+ _default: 400
+ },
+
+ step: {
+ opacity: function( fx ) {
+ jQuery.style(fx.elem, "opacity", fx.now);
+ },
+
+ _default: function( fx ) {
+ if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
+ fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
+ } else {
+ fx.elem[ fx.prop ] = fx.now;
+ }
+ }
+ }
+});
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.animated = function( elem ) {
+ return jQuery.grep(jQuery.timers, function( fn ) {
+ return elem === fn.elem;
+ }).length;
+ };
+}
+
+function genFx( type, num ) {
+ var obj = {};
+
+ jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
+ obj[ this ] = type;
+ });
+
+ return obj;
+}
+if ( "getBoundingClientRect" in document.documentElement ) {
+ jQuery.fn.offset = function( options ) {
+ var elem = this[0];
+
+ if ( !elem || !elem.ownerDocument ) {
+ return null;
+ }
+
+ if ( options ) {
+ return this.each(function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ });
+ }
+
+ if ( elem === elem.ownerDocument.body ) {
+ return jQuery.offset.bodyOffset( elem );
+ }
+
+ var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement,
+ clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
+ top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop,
+ left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft;
+
+ return { top: top, left: left };
+ };
+
+} else {
+ jQuery.fn.offset = function( options ) {
+ var elem = this[0];
+
+ if ( !elem || !elem.ownerDocument ) {
+ return null;
+ }
+
+ if ( options ) {
+ return this.each(function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ });
+ }
+
+ if ( elem === elem.ownerDocument.body ) {
+ return jQuery.offset.bodyOffset( elem );
+ }
+
+ jQuery.offset.initialize();
+
+ var offsetParent = elem.offsetParent, prevOffsetParent = elem,
+ doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement,
+ body = doc.body, defaultView = doc.defaultView,
+ prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
+ top = elem.offsetTop, left = elem.offsetLeft;
+
+ while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
+ if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
+ break;
+ }
+
+ computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
+ top -= elem.scrollTop;
+ left -= elem.scrollLeft;
+
+ if ( elem === offsetParent ) {
+ top += elem.offsetTop;
+ left += elem.offsetLeft;
+
+ if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.nodeName)) ) {
+ top += parseFloat( computedStyle.borderTopWidth ) || 0;
+ left += parseFloat( computedStyle.borderLeftWidth ) || 0;
+ }
+
+ prevOffsetParent = offsetParent, offsetParent = elem.offsetParent;
+ }
+
+ if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
+ top += parseFloat( computedStyle.borderTopWidth ) || 0;
+ left += parseFloat( computedStyle.borderLeftWidth ) || 0;
+ }
+
+ prevComputedStyle = computedStyle;
+ }
+
+ if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
+ top += body.offsetTop;
+ left += body.offsetLeft;
+ }
+
+ if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
+ top += Math.max( docElem.scrollTop, body.scrollTop );
+ left += Math.max( docElem.scrollLeft, body.scrollLeft );
+ }
+
+ return { top: top, left: left };
+ };
+}
+
+jQuery.offset = {
+ initialize: function() {
+ var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0,
+ html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
+
+ jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
+
+ container.innerHTML = html;
+ body.insertBefore( container, body.firstChild );
+ innerDiv = container.firstChild;
+ checkDiv = innerDiv.firstChild;
+ td = innerDiv.nextSibling.firstChild.firstChild;
+
+ this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
+ this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
+
+ checkDiv.style.position = "fixed", checkDiv.style.top = "20px";
+ // safari subtracts parent border width here which is 5px
+ this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
+ checkDiv.style.position = checkDiv.style.top = "";
+
+ innerDiv.style.overflow = "hidden", innerDiv.style.position = "relative";
+ this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
+
+ this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
+
+ body.removeChild( container );
+ body = container = innerDiv = checkDiv = table = td = null;
+ jQuery.offset.initialize = jQuery.noop;
+ },
+
+ bodyOffset: function( body ) {
+ var top = body.offsetTop, left = body.offsetLeft;
+
+ jQuery.offset.initialize();
+
+ if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
+ top += parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0;
+ left += parseFloat( jQuery.curCSS(body, "marginLeft", true) ) || 0;
+ }
+
+ return { top: top, left: left };
+ },
+
+ setOffset: function( elem, options, i ) {
+ // set position first, in-case top/left are set even on static elem
+ if ( /static/.test( jQuery.curCSS( elem, "position" ) ) ) {
+ elem.style.position = "relative";
+ }
+ var curElem = jQuery( elem ),
+ curOffset = curElem.offset(),
+ curTop = parseInt( jQuery.curCSS( elem, "top", true ), 10 ) || 0,
+ curLeft = parseInt( jQuery.curCSS( elem, "left", true ), 10 ) || 0;
+
+ if ( jQuery.isFunction( options ) ) {
+ options = options.call( elem, i, curOffset );
+ }
+
+ var props = {
+ top: (options.top - curOffset.top) + curTop,
+ left: (options.left - curOffset.left) + curLeft
+ };
+
+ if ( "using" in options ) {
+ options.using.call( elem, props );
+ } else {
+ curElem.css( props );
+ }
+ }
+};
+
+
+jQuery.fn.extend({
+ position: function() {
+ if ( !this[0] ) {
+ return null;
+ }
+
+ var elem = this[0],
+
+ // Get *real* offsetParent
+ offsetParent = this.offsetParent(),
+
+ // Get correct offsets
+ offset = this.offset(),
+ parentOffset = /^body|html$/i.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
+
+ // Subtract element margins
+ // note: when an element has margin: auto the offsetLeft and marginLeft
+ // are the same in Safari causing offset.left to incorrectly be 0
+ offset.top -= parseFloat( jQuery.curCSS(elem, "marginTop", true) ) || 0;
+ offset.left -= parseFloat( jQuery.curCSS(elem, "marginLeft", true) ) || 0;
+
+ // Add offsetParent borders
+ parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], "borderTopWidth", true) ) || 0;
+ parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], "borderLeftWidth", true) ) || 0;
+
+ // Subtract the two offsets
+ return {
+ top: offset.top - parentOffset.top,
+ left: offset.left - parentOffset.left
+ };
+ },
+
+ offsetParent: function() {
+ return this.map(function() {
+ var offsetParent = this.offsetParent || document.body;
+ while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
+ offsetParent = offsetParent.offsetParent;
+ }
+ return offsetParent;
+ });
+ }
+});
+
+
+// Create scrollLeft and scrollTop methods
+jQuery.each( ["Left", "Top"], function( i, name ) {
+ var method = "scroll" + name;
+
+ jQuery.fn[ method ] = function(val) {
+ var elem = this[0], win;
+
+ if ( !elem ) {
+ return null;
+ }
+
+ if ( val !== undefined ) {
+ // Set the scroll offset
+ return this.each(function() {
+ win = getWindow( this );
+
+ if ( win ) {
+ win.scrollTo(
+ !i ? val : jQuery(win).scrollLeft(),
+ i ? val : jQuery(win).scrollTop()
+ );
+
+ } else {
+ this[ method ] = val;
+ }
+ });
+ } else {
+ win = getWindow( elem );
+
+ // Return the scroll offset
+ return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
+ jQuery.support.boxModel && win.document.documentElement[ method ] ||
+ win.document.body[ method ] :
+ elem[ method ];
+ }
+ };
+});
+
+function getWindow( elem ) {
+ return ("scrollTo" in elem && elem.document) ?
+ elem :
+ elem.nodeType === 9 ?
+ elem.defaultView || elem.parentWindow :
+ false;
+}
+// Create innerHeight, innerWidth, outerHeight and outerWidth methods
+jQuery.each([ "Height", "Width" ], function( i, name ) {
+
+ var type = name.toLowerCase();
+
+ // innerHeight and innerWidth
+ jQuery.fn["inner" + name] = function() {
+ return this[0] ?
+ jQuery.css( this[0], type, false, "padding" ) :
+ null;
+ };
+
+ // outerHeight and outerWidth
+ jQuery.fn["outer" + name] = function( margin ) {
+ return this[0] ?
+ jQuery.css( this[0], type, false, margin ? "margin" : "border" ) :
+ null;
+ };
+
+ jQuery.fn[ type ] = function( size ) {
+ // Get window width or height
+ var elem = this[0];
+ if ( !elem ) {
+ return size == null ? null : this;
+ }
+
+ return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window?
+ // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
+ elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
+ elem.document.body[ "client" + name ] :
+
+ // Get document width or height
+ (elem.nodeType === 9) ? // is it a document
+ // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
+ Math.max(
+ elem.documentElement["client" + name],
+ elem.body["scroll" + name], elem.documentElement["scroll" + name],
+ elem.body["offset" + name], elem.documentElement["offset" + name]
+ ) :
+
+ // Get or set width or height on the element
+ size === undefined ?
+ // Get width or height on the element
+ jQuery.css( elem, type ) :
+
+ // Set the width or height on the element (default to pixels if value is unitless)
+ this.css( type, typeof size === "string" ? size : size + "px" );
+ };
+
+});
+// Expose jQuery to the global object
+window.jQuery = window.$ = jQuery;
+
+})(window);
diff --git a/examples/lessons/6_Maths_complexAddition/js/karma.js b/examples/lessons/6_Maths_complexAddition/js/karma.js
new file mode 100755
index 0000000..03f027b
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/js/karma.js
@@ -0,0 +1,1018 @@
+/* Documentation Note:
+ * Public methods and properties are commented with /** some text *\/
+ * and private methods and properties are commented with //
+ *
+ * Please leave it that way to keep this documentation sane
+ */
+
+
+/*
+* Karma Framework
+* http://karmaeducation.org
+*
+* Copyright (c) 2009
+* Bryan W Berry bryan@olenepal.org
+* Felipe López Toledo zer.subzero@gmail.com
+*
+* Under MIT License:
+* Permission is hereby granted, free of charge, to any person
+* obtaining a copy of this software and associated documentation
+* files (the "Software"), to deal in the Software without
+* restriction, including without limitation the rights to use,
+* copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following
+* conditions:
+*
+* The above copyright notice and this permission notice shall be
+* included in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+/**
+* @fileOverview Contains karma library
+* @author Bryan Berry <bryan@olenepal.org>
+* @author Felipe Lopez Toledo <zer.subzero@gmail.com>
+*/
+
+
+//common.js modules use exports object
+if(!this.exports) {
+ exports = {};
+}
+
+
+
+/** Checks if the current document type is set to HTML 5, throws
+ * an error otherwise, then initializes the karma object and returns
+ * a reference to that object.
+ * @namespace Global namespace for Karma library
+ * @param {Object} [options={}] options for intializing Karma library
+ * @param {String} [options.locale=''] sets current locale Not Yet Implemented
+ * @param {Array} [options.image=[]] array of images to be converted into a collection
+ * @param {Array} [options.audio=[]] array of audio to be converted into a collection
+ * @param {Array} [options.video=[]] array of videos to be converted into a collection
+ * @param {Array} [options.svg=[]] array of SVG elements to be
+ * converted into a collection. Each SVG element must already exist in the html document
+ * @param {Array} [options.canvas=[]] array of canvas elements
+ * to be converted into a collection. Each canvas element must already exist in the
+ * html document and width and height of each element must be set as attributes
+ * @throws {Error} if the document type declaration is not set to HTML 5, e.g.
+ * <!DOCTYPE html>
+ * @throws {Error} If any of the initialization parameters are invalid values
+ * @returns {Object} Karma.karma -- reference to the initialized Karma library
+ * @example
+ *
+ * var k = Karma({
+ * image: [
+ * {name: "ninja", file: "ninja.png"},
+ * {name: "cowboy", file: "cowboy.png"}
+ * ],
+ * audio: [
+ * {name: "woosh", file: "woosh.ogg"},
+ * {name: "yeehaw", file: "yeehaw.ogg"}
+ * ],
+ * video: [
+ * {name: "attack", file: "attack.ogv"},
+ * {name: "ride", file: "ride.ogv"}
+ * ]
+ * canvas: [
+ * {name: "ninja", domId: "ninjaCanvas"},
+ * {name: "cowboy", domId: "cowboyCanvas"}
+ * ],
+ * svg: [
+ * {name: "ninja", domId: "ninjaSvg"},
+ * {name: "cowboy", domId: "cowboySvg"}
+ * ],
+ * });
+ * Next, call the ready function with a callback to your program code
+ *
+ * k.ready(function () { ... your application code . . . }
+ *
+ * after that you can access each asset like so
+ * k.image.ninja;
+ * k.svg.cowboy;
+ * k.audio.yeehaw.play();
+ * k.canvas.ninja.drawImage(k.image.ninja, 0, 0);
+ *
+ */
+var Karma = exports.Karma = function (options) {
+ Karma._isHtml5(document.doctype.nodeName);
+
+ if ( Karma.karma._initialized === true ) {
+ return Karma.karma;
+ } else {
+ return Karma.karma._init(options);
+ }
+};
+
+
+//helper functions
+
+/**This emulates the Object.create method in ecmascript 5 spec
+ * This isn't a full implementation as it doesn't support
+ * This has the same functionality as Crockford's beget method
+ * and this primary building block for prototypal inheritance in
+ * this library
+ * @param {Object} target that the new object's prototype should point to
+ * @returns {Object} object whose prototype points to target
+ * @example
+ *
+ * var ninja = { weapon : "sword" };
+ * var ninja1 = Karma.create(ninja);
+ * ninja1.sword === "sword"
+ */
+Karma.create = function (target){
+ function F () {};
+ F.prototype = target;
+ return new F();
+};
+
+/** Returns a shallow copy of the passed in object
+ * @param {Object} target to be copied
+ * @returns {Object} a shallow copy of target
+ */
+Karma.clone = function (target){
+ var copy = {};
+ for ( var i in target ) {
+ if(target.hasOwnProperty(i)){
+ copy[i] = target[i];
+ }
+ }
+ return copy;
+};
+
+/** Extends properties of the target object with those of
+ * the source object
+ * @param {Object} target object to be extended
+ * @param {Object} source whose properties will extend target
+ * @returns {Object} target extended by source
+ */
+Karma.objectPlus = function (target, source){
+ for ( var i in source){
+ if (source.hasOwnProperty(i)){
+ target[i] = source[i];
+ }
+ }
+ return target;
+};
+
+/** Creates a new object that is a prototype of the first argument
+ * then extends it with the properties of the second argument
+ * @param {Object} parent1 will be prototype of returned object
+ * @param {Object} parent2 will extend properties of returned object
+ * @returns {Object} object that whose prototype is parent1 and has
+ * been extended with properties of parent2
+ */
+Karma.copyObjectPlus = function (parent1, parent2){
+ function F () {};
+ F.prototype = parent1;
+ var G = new F();
+ return Karma.objectPlus(G, parent2);
+};
+
+//Enables function chaining for a specified list of function names
+//IMPORTANT: use of closures here with "this" and "that" is __very__
+//complicated here
+Karma._makeChain = function (chainingFunctions) {
+ var that = this;
+ var _chainFunction = function ( name ){
+ that[ name ] = function ( ){
+ var type = typeof this.ctx[name];
+ if ( type === "function") {
+ this.ctx[ name ].apply( this.ctx, arguments );
+ }else if ( type === "string" ){
+ this.ctx[ name ] = arguments[0];
+ }else {
+ throw ("wtf?!: impossible to chain " + name + "!");
+ }
+ return this;
+ };
+ };
+
+ for (var i = 0; i < chainingFunctions.length; i++){
+ _chainFunction( chainingFunctions[ i ] );
+ }
+};
+
+//Throws big ugly error if doctype isn't html5
+Karma._isHtml5 = function (doctype){
+ var regex = new RegExp('^html$', 'i');
+ if(!regex.test(doctype)){
+ var errorMsg = "ERROR: The doctype must be set to <!DOCTYPE html> " +
+ "in order to use Karma. Karma require you use html5";
+ var errorElem = document.createElement('div');
+ errorElem.setAttribute('id', 'errorDoctype');
+ errorElem.innerText = errorMsg;
+ document.body.appendChild(errorElem);
+ throw new Error(errorMsg);
+ }
+};
+
+
+/** Stores global settings for the Karma library
+ * @class This object stores the global settings for the Karma library
+ */
+Karma.karma = {
+ /** This is the global locale as passed to Karma(),
+ * such as "en", "es_SP"
+ * @type string
+ * @default undefined
+ */
+ locale : undefined,
+ /** Collection of images with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ image : {},
+ /** Collection of audio with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ audio : {},
+ /** Collection of canvas with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ canvas : {},
+ /** Collection of svgs with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ svg : {},
+ /** Collection of videos with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ video : {},
+ _localized : false,
+ _assetPath : "assets/",
+ _localePath : "",
+ _initialized : false,
+ _statusDiv: undefined,
+ _loaderDiv : undefined,
+ _counters : { total : 0, errors : 0, loaded : 0},
+
+ //init initializes all the assets passed to Karma, that's it
+ //it returns 'this' so it can be used for function chaining
+ _init: function(options) {
+ this._initialized = true;
+
+ //set up message that show count of assets loaded
+ //and has an ordered list to append error messages to
+ var _statusDiv = this._statusDiv = document.createElement('div');
+ this._loaderDiv = this._loaderDiv = document.createElement('div');
+ var errorList = document.createElement('ol');
+
+ _statusDiv.setAttribute('id', 'karma-status');
+ _statusDiv.setAttribute('style', 'position:absolute;');
+ _statusDiv.innerHTML = 'Karma is loading ...';
+ this._loaderDiv.setAttribute('id', 'karma-loader');
+ this._loaderDiv.setAttribute('class', 'status');
+ errorList.setAttribute('id', 'errorList');
+
+ _statusDiv.appendChild(this._loaderDiv);
+ this._statusDiv.appendChild(errorList);
+ document.body.appendChild(_statusDiv);
+
+
+ //chain the functions for kCanvas and kSvg
+ Karma._makeChain.call(Karma.kCanvas,
+ Karma.kCanvas._chainingFunctions);
+ //Karma._makeChain.apply(Karma.kSvg, Karma.kSvg._chainingFunctions);
+
+
+
+ //regular expression that matches the name of aprivate property
+ // the karma object
+ var regexPrivate = new RegExp('^_.*');
+
+ for ( var option in options ) {
+ if (options.hasOwnProperty(option)){
+ if (option === "image" || option === "audio" || option ===
+ "svg" || option === "video" || option === "canvas"){
+
+ if(!(options[option] instanceof Array)){
+ throw new Error("" + option + " must be an array");
+ } else if (options[option].length === 0){
+ continue;
+ }
+ } else if (regexPrivate.test(option)){
+ //don't overwrite a private property of karma object
+ continue;
+ }
+
+ switch (option){
+ case "locale":
+
+ if (this._isValidLocale(options[option])){
+ this.locale = this._normalizeLocale(options[option]);
+ this._localized = true;
+ this._localePath = Karma._computeLocalePath(this.locale);
+ } else {
+ throw new Error("locale provided to karma._init() is invalid");
+ }
+
+ break;
+ case "image":
+ options[option]._type = 'image';
+ Karma._makeImages(options[option]);
+ break;
+ case "audio":
+ options[option]._type = 'audio';
+ Karma._makeAudio(options[option]);
+ break;
+ case "video":
+ options[option]._type = 'video';
+ Karma._makeVideos(options[option]);
+ break;
+ case "svg":
+ options[option]._type = 'svg';
+ Karma._makeSvgs(options[option]);
+ break;
+ case "canvas":
+ options[option]._type = 'canvas';
+ Karma._makeCanvases(options[option]);
+ break;
+ }
+ }
+ }
+
+
+
+ return this;
+ },
+
+ /** Waits until all assets loaded, i.e. ready, then calls callback
+ * @param {Function} [cb] callback function
+ * @returns this
+ * @throws {Error} if Karma.karma is not initialized with the
+ * Karma({ options }) function
+ * @example
+ *
+ * var k = Karma({ . . . your assets here . . . });
+ * k.ready(function(){ .. your code here . . .});
+ *
+ * your code will not be called until all assets have been loaded
+ *
+ */
+ ready : function( cb ) {
+ var that = this;
+ if (Karma.karma._initialized !== true){
+ throw new Error("Karma.karma not initialized");
+ }
+
+ if (this._counters.loaded !== this._counters.total){
+ setTimeout(function(){ that.ready(cb);}, 5);
+ } else if (cb) {
+ //hide the "Karma is loading..." message
+ this._statusDiv.setAttribute('style', 'display:none;');
+
+ cb();
+ } else if (!cb) {
+ //hide the "Karma is loading..." message
+ this._statusDiv.setAttribute('style', 'display:none;');
+
+ //if no options passed, show it works message
+ this._showStarterMessage();
+ }
+
+
+
+
+ return this;
+ },
+
+ //Display Apache-like "It works" message if no options
+ _showStarterMessage : function (){
+ var starterMsg = document.createElement('div');
+ starterMsg.setAttribute('id', 'starterMsg');
+ starterMsg.innerHTML = "<h1>It Works</h1>";
+ document.body.appendChild(starterMsg);
+ },
+
+ //Updates visible counter of how many assets are loaded
+ _updateStatus : function (errorMsg) {
+ var loaded = this._counters.loaded;
+ var total = this._counters.total;
+ var errors = this._counters.errors;
+ this._loaderDiv.innerHTML = "Loaded " + loaded + " / " + total +
+ "" + (errors > 0 ? " Errors [ " + errors +" ]" : '');
+ if (errorMsg) {
+ var liError = document.createElement('li');
+ liError.innerHTML = errorMsg;
+ var errorList = document.getElementById('errorList');
+ errorList.appendChild(liError);
+ }
+ },
+
+ //matches 2 letter country code then optionally
+ //a dash or underscore followed by a country or language identifier
+ //i currently only allow a language identifier 2-3 chars long
+ _isValidLocale : function (locale) {
+ var localeRegex = new RegExp('^[a-zA-Z][a-zA-Z]([-_][a-zA-z]{2,3})?$');
+ return localeRegex.test(locale);
+ },
+
+ _normalizeLocale : function(locale) {
+ var lang = "";
+ var country = "";
+ var divider = "";
+
+ lang = locale.slice(0, 2).toLowerCase();
+ divider = "_";
+ country = locale.slice(3, 6).toUpperCase();
+
+ return locale.length > 2 ? "" + lang + divider + country : lang;
+ },
+
+ // Below are geometry and math helper methods
+
+ /**
+ * Converts a value from degrees to radians.
+ * @param {Number} angle The angle in degrees
+ * @returns {Number} The angle in radians
+ */
+ radians : function( angle ){
+ return ( angle / 180 ) * Math.PI;
+ },
+ /**
+ * Gets the square of the Euclidian (ordinary) distance between 2 points.
+ * @param {Object} Point No. 0
+ * @param {Number} Point0.x
+ * @param {Number} Point0.y
+ * @param {Object} Point No. 1
+ * @param {Number} Point1.x
+ * @param {Number} Point1.y
+ * @returns {Number} The square of the Euclidian distance
+ * @example
+ *
+ * p0 = {x:0, y:1};
+ * p1 = {x:50, y:70};
+ * var d = distance2(p0, p1);
+ *
+ */
+ distance2 : function ( p0, p1 ) {
+ return (p1.x - p0.x) * (p1.x - p0.x) + (p1.y - p1.y) * (p1.y - p1.y);
+ },
+ /**
+ * Gets the Euclidian (ordinary) distance between 2 points.<br>
+ * <b>Warning:</b> It's slower than distance2 function
+ * @param {Object} Point No. 0
+ * @param {Number} Point0.x
+ * @param {Number} Point0.y
+ * @param {Object} Point No. 1
+ * @param {Number} Point1.x
+ * @param {Number} Point1.y
+ * @returns {Number} The Euclidian distance
+ * @example
+ *
+ * p0 = {x:0, y:1};
+ * p1 = {x:50, y:70};
+ * var d = distance2(p0, p1);
+ *
+ */
+ distance : function ( p0, p1 ) {
+ return Math.sqrt( this.distance2( p0, p1 ) );
+ },
+ /** Returns a random number within the range provided
+ * @param {Number} lower limit of the range, lowest number that can be returned
+ * @param {Number} upper limit of the range, highest number that can be returned
+ * @returns {Number} number that is >= lower and <= upper
+ * @example
+ *
+ * var num = rand(0, 10);
+ *
+ * num could be 0, 1, 2, 3 ... or 10
+ *
+ */
+ rand : function ( lower, upper ){
+ return Math.round( Math.random() * (upper - lower) + lower );
+ }
+
+};
+
+/** Prototypal object for images, videos, and audio files but
+ * does not include svg or canvas elements
+ * @class This object is the prototype for images, videos, and audio files but
+ * does not include svg or canvas elements
+ * @ throws {Error} if the individual asset is set to be localized but
+ * the globale locale is not set on the Karma.karma object
+ * @ throws {Error} if the name and file properties are not supplied
+ * @example
+ * kMedia is the prototype object for images, audio, and videos.
+ * These 'media' assets are loaded in a distinctly different way
+ * from the canvas or svg assets. They also have distinctly different
+ * helper methods
+ *
+ * You initialize the kMedia assets by passing an array of objects
+ */
+Karma.kMedia = {
+ /** file location of asset
+ * @type String
+ * @default ""
+ */
+ file : "",
+ /** media object
+ * @type Audio|Image|Video
+ * @default undefined
+ */
+ media : undefined,
+ //actual path to the file
+ _path : "",
+ //if using localized version of this asset
+ _localized : false,
+ //audio, image, or video
+ _type : "",
+ //initializes kMedia instance with values provided by user
+ _init : function (asset) {
+ asset._localized = asset._localized || false;
+ Karma.karma._counters.total++;
+
+ if (asset.name === undefined || asset.file === undefined){
+ throw new Error("properties name and file have to be defined");
+ } else {
+ this.name = asset.name;
+ this.file = asset.file;
+ }
+
+ //_type is a private variable used internally
+ if (asset._type === undefined){
+ throw new Error("the _type property must be set. " +
+ "Blame the karma library authors as this is an internal value");
+ } else {
+ if (Karma._isValidType(asset._type)){
+ this._type = asset._type;
+ switch ( this._type ) {
+ case "image": this.media = new Image();
+ break;
+ case "audio": this.media = new Audio();
+ break;
+ //case "video":
+ //NYI
+ //this.media = new Video();
+ break;
+ default: throw new Error("Media type not supported");
+ }
+
+ } else {
+ throw new Error("the _type property supplied is invalid. " +
+ "Blame the karma library authors as this is an internal value");
+ }
+ }
+
+ if(Karma._isLocalized(asset._localized)){
+ this._localized = asset._localized;
+ this._path = Karma.karma._localePath +
+ this._type + "/";
+ } else {
+ this._path = Karma.karma._assetPath +
+ this._type + "/";
+ }
+
+
+ //IMPORTANT: This one magic line loads the file
+ this.media.src = this.src = this._path + this.file;
+
+ //add event handlers
+ this._addEventHandlers();
+
+ if (this._type === "audio"){
+ this.media.autobuffer = true;
+ this.media.load();
+ }
+
+
+ return this;
+ },
+ //Adds event handlers to update the counters when
+ //the asset is successfully or unsuccessfully loaded
+ _addEventHandlers : function () {
+ var that = this;
+ var loadEvent = "load";
+ //Browser Hack recommended by chromium devs
+ //http://code.google.com/p/chromium/issues/detail?id=20251&q=loading%20audio&colspec=ID%20Stars%20Pri%20Area%20Type%20Status%20Summary%20Modified%20Owner%20Mstone%20OS#c4
+ if (this._type === "audio" || this._type === "video"){
+ loadEvent = "canplaythrough";
+ }
+
+ that.media.addEventListener(
+ loadEvent,
+ function (e) {
+ Karma.karma._counters.loaded++;
+ Karma.karma._updateStatus();
+ that.status = "loaded";}, false);
+
+ that.media.addEventListener(
+ "error",
+ function (e) {
+ Karma.karma._counters.errors++;
+ that.status = "error";
+ var errorMsg = "Error: " + that._type.toUpperCase() +
+ " " + that.name + " cannot be loaded.";
+ Karma.karma._updateStatus(errorMsg);
+ },
+ false);
+ that.media.addEventListener(
+ "abort",
+ function (e) {
+ Karma.karma._counters.total++;
+ that.status = "aborted";
+ var errorMsg = "ABORT: " + that._type.toUpperCase() +
+ " " + that.name + " loading was aborted.";
+ Karma.karma._updateStatus(errorMsg);
+
+ }, false);
+
+ }
+
+};
+
+//determine if it is a valid type of asset
+Karma._isValidType = function (type){
+ return type === "image" ||
+ type === "svg" ||
+ type === "audio" ||
+ type === "video" ||
+ type === "canvas";
+};
+
+Karma._isLocalized = function (boolLocalized) {
+ if (typeof boolLocalized === "boolean" ) {
+ if(boolLocalized === true &&
+ Karma.karma.locale === undefined){
+ throw new Error("You cannot localize a media asset" +
+ " if the global locale for Karma isn't set");
+ } else {
+ return boolLocalized;
+ }
+ } else if (typeof boolLocalized === undefined){
+ return false;
+ } else{
+ throw new Error("This is not a valid value for the localized option");
+ }
+};
+
+Karma._computeLocalePath = function(locale) {
+ return Karma.karma._assetPath + locale + "/";
+};
+
+Karma._makeImages = function (imgConfigs){
+ var makeImage = function (imgConfig){
+ var image = undefined;
+ imgConfig._type = "image";
+ image = Karma.create(Karma.kMedia)._init(imgConfig);
+ Karma.karma.image[imgConfig.name] = image;
+ };
+
+ imgConfigs.forEach(function(imgConfig){ makeImage(imgConfig);});
+
+};
+
+Karma._makeAudio = function (audioConfigs){
+ var makeAudio = function (audioConfig){
+ var audio = undefined;
+ audioConfig._type = "audio";
+ audio = Karma.create(Karma.kMedia)._init(audioConfig);
+ audio.play = function () {
+ //hack to fix the audio "stuttering" problem
+ //more info: https://bugs.launchpad.net/karma/+bug/426108
+ this.media.currentTime = 0.1;
+ this.media.play();
+ };
+ Karma.karma.audio[audioConfig.name] = audio;
+ };
+
+ audioConfigs.forEach(function(audioConfig){ makeAudio(audioConfig);});
+
+};
+
+
+Karma._makeCanvases = function (canvasConfigs){
+ var makeCanvas = function (canvasConfig){
+ var canvas = undefined;
+ canvas = Karma.create(Karma.kCanvas)._init(canvasConfig);
+ Karma.karma.canvas[canvasConfig.name] = canvas;
+ };
+
+ canvasConfigs.forEach(function(canvasConfig){ makeCanvas(canvasConfig);});
+
+};
+
+/** Prototypal object for each canvas element submitted to Karma in the
+ * Karma() method
+ * @throws {Error} if the name and domId for the canvas element are not specified
+ * @thows {Error} if the supplied domId does not match an element in the DOM
+ * @class This object is the prototype for each canvas element submitted to Karma in the
+ * Karma() method
+ */
+Karma.kCanvas = {
+ /** Name of the canvas, used internally by karma.js
+ * @type String
+ * @default ''
+ */
+ name : '',
+ /** Width of canvas element
+ * @type Number
+ * @default 0
+ */
+ width: 0,
+ /** Height of canvas element
+ * @type Number
+ * @default 0
+ */
+ height: 0,
+ /** Whether canvas is visible
+ * @type boolean
+ * @default true
+ */
+ visible: true,
+ /** Element ID for canvas element in html document
+ * @type String
+ * @default undefined
+ */
+ domId: undefined,
+ /** Reference to the DOM element
+ * @type DOMElement
+ * @default undefined
+ */
+ node: undefined,
+ /** The 2 Dimensional Rendering context property for this canvas
+ * @type 2DRenderingContext
+ * @default undefined
+ */
+ ctx: undefined,
+ /** Frames Per Second, I don't know what the purpose of this is,
+ * Felipe made it up
+ * @type Number
+ * @default 24
+ */
+ fps: 24,
+
+ //initializes object with values provides by user
+ _init: function (config) {
+ for (var option in config){
+ if (config.hasOwnProperty(option)){
+ switch (option){
+ case "name":
+ this.name = config[option];
+ break;
+ case "domId":
+ this.domId = config[option];
+ break;
+ case "width":
+ if(!this.height){
+ throw new Error("If you specify a width you must also" +
+ "specify a height");
+ }
+ this.width = config[option];
+ break;
+ case "height":
+ if(!this.width){
+ throw new Error("If you specify a height you must also" +
+ "specify a width");
+ }
+ this.height = parseInt(config.option, 10);
+ break;
+ case "fps":
+ this.fps = parseInt(config.option, 10);
+ break;
+ }
+ }
+ }
+
+ if(this.domId && document.getElementById(this.domId)){
+ this.node = document.getElementById(this.domId);
+ this.ctx = this.node.getContext('2d');
+ } else {
+ throw new Error('you must specify a valid domId that' +
+ 'is in your html page');
+ }
+
+ if(!config.height && !config.width){
+ this.width = parseInt(this.node.getAttribute('width'), 10);
+ this.height = parseInt(this.node.getAttribute('height'), 10);
+ }
+
+ return this;
+ },
+ /** Clear area of canvas element specified by parameters, if no
+ * parameters supplied, clears entire canvas
+ * @param {Number} [x=0] x coordinate, defaults to zero if left blank
+ * @param {Number} [y=0] y coordinate, defaults to zero if left blank
+ * @param {Number} [width=0] width of area to be cleared, defaults
+ * entire width of canvas
+ * @param {Number} [height=0] height of area to be cleared, defaults
+ * entire height of canvas
+ * @returns this
+ * @example
+ *
+ * k.canvas.ninja.clear();
+ * // clears the entire ninja canvas
+ *
+ * k.canvas.ninja.clear(0, 10, 20, 30);
+ * //clears a specific portion of the ninja canvas
+ *
+ */
+ clear : function ( x, y, width, height ) {
+ var that = this;
+ that.ctx.clearRect(
+ x || 0,
+ y || 0,
+ width || that.width,
+ height || that.height
+ );
+ return that;
+ },
+
+ //These are all properties or methods of the canvas element's
+ //2 dimensional context
+ _chainingFunctions : [
+ "globalAlpha", "globalCompositeOperation", "lineWidth", "lineCap",
+ "lineJoin", "miterLimit", "font", "textAlign", "textBaseline", "save",
+ "restore", "scale", "rotate", "translate", "transform", "setTransform",
+ "clearRect", "fillRect", "strokeRect", "beginPath", "closePath",
+ "moveTo", "lineTo", "quadraticCurveTo", "bezierCurveTo", "arcTo",
+ "arc", "rect", "fill", "stroke", "clip", "fillText", "strokeText",
+ "measureText", "isPointInPath", "strokeStyle", "fillStyle",
+ "createLinearGradient", "createRadialGradient", "createPattern",
+ "shadowOffsetX", "shadowOffsetY", "shadowBlur", "shadowColor",
+ //"mozTextStyle", "mozDrawText", "mozMeasureText", "mozPathText",
+ "mozTextAlongPath", "drawImage", "getImageData", "putImageData",
+ "createImageData", "drawWindow"
+ ]
+};
+
+
+
+Karma._makeSvgs = function (svgConfigs){
+ var makeSvg = function (svgConfig){
+ var svg = undefined;
+ svg = Karma.create(Karma.kSvg)._init(svgConfig);
+ Karma.karma.svg[svgConfig.name] = svg;
+ };
+
+ svgConfigs.forEach(function(svgConfig){ makeSvg(svgConfig);});
+
+};
+
+/** Prototypal object for each svg element submitted to Karma in the
+ * Karma() method
+ * @throws {Error} if the name and domId for the svg element are not specified
+ * @thows {Error} if the supplied domId does not match an element in the DOM
+ * @class This object is the prototype for each svg element submitted to Karma in the
+ * Karma() method
+ */
+Karma.kSvg = {
+ /** name of instance, used internally
+ * @typeof string
+ * @default ""
+ */
+ name : "",
+ /** width of element
+ * @type number
+ * @default 0
+ */
+ width: 0,
+ /** height of element
+ * @type number
+ * @default 0
+ */
+ height: 0,
+ /** Status of element, either "loaded" or "error"
+ * @type string
+ * @default ""
+ */
+ status: "",
+ /** Whether canvas is visible
+ * @type boolean
+ * @default true
+ */
+ visible: true,
+ /** Element ID for canvas element in html document
+ * @type String
+ * @default undefined
+ */
+ domId: undefined,
+ /** Reference to the DOM element
+ * @type DOMElement
+ * @default undefined
+ */
+ node: undefined,
+ /** Reference to the SVGDocument
+ * @type SVGDocument
+ * @default undefined
+ */
+ doc: undefined,
+ /** Reference to the root element of the SVG Document
+ * @type DocumentElement
+ * @default undefined
+ */
+ root: undefined,
+ _localized : undefined,
+ _chainingFunctions: [],
+ _init: function (config) {
+ Karma.karma._counters.total++;
+
+ for (var option in config){
+ if (config.hasOwnProperty(option)){
+ switch (option){
+ case "name":
+ this.name = config[option];
+ break;
+ case "domId":
+ this.domId = config[option];
+ break;
+ case "width":
+ if(!this.height){
+ throw new Error("If you specify a width you must also" +
+ "specify a height");
+ }
+ this.width = parseInt(config[option], 10);
+ break;
+ case "height":
+ if(!this.width){
+ throw new Error("If you specify a height you must also" +
+ "specify a width");
+ }
+ this.height = config[option];
+ break;
+ case "fps":
+ this.fps = config[option];
+ break;
+ }
+ }
+ }
+
+ if(this.domId && document.getElementById(this.domId)){
+ this.node = document.getElementById(this.domId);
+ } else {
+ throw new Error('you must specify a valid domId that' +
+ 'is in your html page');
+ }
+
+ if(!config.height && !config.width){
+ this.width = parseInt(this.node.getAttribute('width'), 10);
+ this.height = parseInt(this.node.getAttribute('height'), 10);
+ }
+
+ var that = this;
+ that._addEventHandlers();
+
+ return this;
+
+
+ },
+ _addEventHandlers : function () {
+ var that = this;
+ that.doc = that.node.getSVGDocument();
+ that.node.addEventListener(
+ "load",
+ function (e) {
+ that.doc = that.node.getSVGDocument();
+ that.root = that.doc.documentElement;
+ Karma.karma._counters.loaded++;
+ Karma.karma._updateStatus();
+ that.status = "loaded";
+ }, false);
+
+ that.node.addEventListener(
+ "error",
+ function (e) {
+ Karma.karma._counters.loaded--;
+ Karma.karma._counters.errors++;
+ that.status = "error";
+ var errorMsg = "Error: " + that._type.toUpperCase() +
+ " " + that.name + " cannot be loaded.";
+ Karma.karma._updateStatus(errorMsg);
+ },
+ false);
+ that.node.addEventListener(
+ "abort",
+ function (e) {
+ that.status = "aborted";
+ var errorMsg = "ABORT: " + that._type.toUpperCase() +
+ " " + that.name + " loading was aborted.";
+ Karma.karma._updateStatus(errorMsg);
+
+ }, false);
+
+ }
+};
+
+Karma._makeVideos = function (video){
+
+};
diff --git a/examples/lessons/6_Maths_complexAddition/js/lesson.js b/examples/lessons/6_Maths_complexAddition/js/lesson.js
new file mode 100755
index 0000000..1864fb8
--- /dev/null
+++ b/examples/lessons/6_Maths_complexAddition/js/lesson.js
@@ -0,0 +1,217 @@
+$(document).ready(function(){
+ var k = Karma({
+ audio: [{'name':'correct','file':'correct.wav'},
+ {'name':'incorrect','file':'incorrect.wav'},
+ ]});
+
+ k.ready(function(){
+ var TOTAL_NUMS = 5;
+ var MAX_NUM = 30;
+ var imgCounter;
+ var currentNum; //store the current targeted num id
+ var currentPlayer;
+ var players = ['Red','Blue'];
+ var randNumbers = [];
+ var flag_busy;
+ var TIME_LIMIT = 5; //within this time limit they have to answer the current question
+ var stopTimer = function(){
+ s = 0;
+ clearTimeout(t);
+ };
+ var startTimer = function(){
+ s = 0;
+ increaseTime();
+ };
+
+
+ var increaseTime = function(){
+ s++;
+ if(s === TIME_LIMIT){
+ play = 0;
+ $('#content').addClass('backOpaque');
+ $('#gameOver').html('!!! फेरी खेलौ बटन मा क्लिक गर !!! ');
+ }else{
+ t=setTimeout(function(){increaseTime();},1000);
+ }
+
+ };
+ var genRandomNumbers = function(){
+ randNumbers[0] = k.rand(1,MAX_NUM-1);
+ for(i=1; i<TOTAL_NUMS; i++){
+ do{
+ flag = 0;
+ randNumbers[i] = k.rand(1,MAX_NUM-1);
+ for(j=0; j<i; j++){
+ if(randNumbers[i]===randNumbers[j]){
+ flag++;
+ }
+ }
+ }while(flag != 0 ); //end of do while loop
+ }
+ };
+
+ function showText(parentDiv,divName,topPos,leftPos,numText,color){
+ var textCss = {
+ 'position':'absolute',
+ 'top':topPos+'em',
+ 'left':leftPos+'em',
+ 'font':'2em arial,verdana,geneva,helvetica',
+ 'color':'#'+color,
+ 'z-index':'5'
+ };
+ $('#'+parentDiv).append('<div id="'+divName+'"></div>');
+ $('#'+divName).css(textCss).html(numText);
+ }
+
+ function showPicture(divName,imgName,topPos,leftPos){
+ var imgCss = {
+ 'position':'absolute',
+ 'top':topPos+'em',
+ 'left':leftPos+'em',
+ 'z-index':'2'
+ };
+ $('#content').append('<div id="'+divName+'"></div>');
+ $('#'+divName).css(imgCss).html('<img src="assets/image/'+imgName+'.png" />');
+ }
+
+ function imgAnimate(divName,topPos,leftPos,duration){
+ $('#'+divName).animate(
+ {top:topPos+'em',left:leftPos+'em'},duration,
+ function(ev){
+ flag_busy = 0;
+ $('#txtInput'+players[currentPlayer]).focus();
+ startTimer();
+ }
+ );
+ }
+
+ var animateBoy = function(){
+ showPicture('imgBoy','blueBoy'+imgCounter,30.7,50);
+ if(imgCounter != 4){
+ var t=setTimeout(function(){animateBoy();},500);
+ }else{
+ currentNum = k.rand(0,4);
+ var x = 23.5+(currentNum*9.5);
+ showPicture('imgBlueRing','blueRing',29.5,50);
+ imgAnimate('imgBlueRing',6.2,x,1000);
+ showPicture('imgBoy','blueBoy0',30.7,50);
+ }
+ imgCounter++;
+ };
+
+ var animateGirl = function(){
+ showPicture('imgGirl','redGirl'+imgCounter,30.7,30);
+ if(imgCounter != 4){
+ var t=setTimeout(function(){animateGirl();},500);
+ }else{
+ currentNum = k.rand(0,4);
+ var x = 23.5+(currentNum*9.5);
+ showPicture('imgRedRing','redRing',29.5,34);
+ imgAnimate('imgRedRing',6.2,x,1000);
+ showPicture('imgGirl','redGirl0',30.7,30);
+ }
+ imgCounter++;
+ };
+
+ var nextQuestion = function(){
+ genRandomNumbers();
+ flag_busy = 1;
+ for(var i = 0; i< 5; i++){
+ showText('divNum'+i,'num'+i,2.5,1,randNumbers[i],'E5D700');
+ }
+ showPicture('imgBoy','blueBoy0',30.7,50);
+ showPicture('imgGirl','redGirl0',30.7,30);
+ imgCounter = 0;
+ if(currentPlayer === 0){
+ animateGirl();
+ }else{
+ animateBoy();
+ }
+
+ foucs_blur();
+ };
+
+ function game(){
+ $('#content').removeClass('backOpaque').html('');
+ for(var i = 0;i<5;i++){
+ var x = 22+(i*9.5);
+ showPicture('divNum'+i,'imgNumContainer',7,x);
+ }
+ showPicture('divScoreBox','scoreBox',15.5,22.5);
+
+ showPicture('divtitle','title',2,27.5);
+ showPicture('txtRedTotal','redTotal',16,24);
+ showPicture('txtBlueTotal','blueTotal',16,48);
+ showPicture('txtRedNumPlus','redNumPlus',21.5,24);
+ showPicture('txtBlueNumPlus','blueNumPlus',21.5,48);
+
+ //show current Score of numbers
+ showText('txtRedTotal','divRedScore',1.5,2,0,'FFF');
+ showText('txtBlueTotal','divBlueScore',1.5,2,0,'FFF');
+
+ //text boxes for input
+ showText('txtRedNumPlus','textInputRed',1.6,1.5,'<input type="text" id="txtInputRed" class="blankBox">','FFF');
+ $('#txtInputRed').css({'color':'red','border':'2px solid #FF0000'});
+ showText('txtBlueNumPlus','textInputBlue',1.6,1.5,'<input type="text" id="txtInputBlue" class="blankBox">','FFF');
+ $('#txtInputBlue').css({'color':'blue','border':'2px solid #0000FF'});
+ currentPlayer = 0;
+ nextQuestion();
+ };
+
+
+
+
+ $('#linkStart').click(function(){
+ game();
+ });
+
+ $('#linkPlayAgain').click(function(){
+ game();
+ });
+
+ $('#linkHelp').click(function(){
+ $('#help').slideDown(2000);
+ })
+ .mouseout(function(){
+ $('#help').slideUp(2000);
+ });
+
+
+ var checkAnswer = function(){
+ if(flag_busy === 0){
+ var currentScore = parseInt($('#div'+players[currentPlayer]+'Score').text());
+ var inputTextVal = $('#txtInput'+players[currentPlayer]).val();
+ var totalVal = currentScore + randNumbers[currentNum];
+ if(totalVal == inputTextVal){
+ stopTimer();
+ k.audio.correct.play();
+ inputTextVal = $('#txtInput'+players[currentPlayer]).val('');
+ $('#div'+players[currentPlayer]+'Score').html(totalVal);
+ $('#img'+players[currentPlayer]+'Ring').html('');
+ $('#txtInput'+players[currentPlayer]).blur();
+ if(currentPlayer === 0){
+ currentPlayer = 1;
+ }else{
+ currentPlayer = 0;
+ }
+
+ nextQuestion();
+ }else{
+ k.audio.incorrect.play();
+ }
+ }
+ };
+
+ function foucs_blur(){
+ $('input[type="text"]').keypress(function(event) {
+ if(event.which === 13){
+ checkAnswer();
+ }
+
+ });
+ }
+
+ }); //end of k.ready
+}); //end of document.read
+
+
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/audio/correct.wav b/examples/lessons/6_Maths_lowestCommonMultiple/assets/audio/correct.wav
new file mode 100755
index 0000000..a49ba33
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/audio/correct.wav
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/audio/incorrect.wav b/examples/lessons/6_Maths_lowestCommonMultiple/assets/audio/incorrect.wav
new file mode 100755
index 0000000..906c6a3
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/audio/incorrect.wav
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/bg_footer.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/bg_footer.png
new file mode 100755
index 0000000..8982264
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/bg_footer.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/bg_header.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/bg_header.png
new file mode 100755
index 0000000..98213f7
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/bg_header.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/bg_title_block.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/bg_title_block.png
new file mode 100755
index 0000000..2c9dacf
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/bg_title_block.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_back.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_back.png
new file mode 100755
index 0000000..d9fbf14
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_back.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_back_hover.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_back_hover.png
new file mode 100755
index 0000000..0911fcc
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_back_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_help.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_help.png
new file mode 100755
index 0000000..6753e9c
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_help.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_help_hover.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_help_hover.png
new file mode 100755
index 0000000..d3ccd92
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_help_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_next.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_next.png
new file mode 100755
index 0000000..9d70993
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_next.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_next_hover.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_next_hover.png
new file mode 100755
index 0000000..2cd4d37
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_next_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_ole.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_ole.png
new file mode 100755
index 0000000..0e775e9
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_ole.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_ole_hover.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_ole_hover.png
new file mode 100755
index 0000000..c43c5f7
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_ole_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_play_again.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_play_again.png
new file mode 100755
index 0000000..3594d18
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_play_again.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_play_again_hover.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_play_again_hover.png
new file mode 100755
index 0000000..ebb8f8c
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_play_again_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_play_again_mouse_down.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_play_again_mouse_down.png
new file mode 100755
index 0000000..07d6e45
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_play_again_mouse_down.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_start.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_start.png
new file mode 100755
index 0000000..32e5f20
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_start.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_start_hover.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_start_hover.png
new file mode 100755
index 0000000..811ce78
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_start_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_start_mouse_down.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_start_mouse_down.png
new file mode 100755
index 0000000..5acd43b
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/btn_start_mouse_down.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/check.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/check.png
new file mode 100755
index 0000000..bd0afcb
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/check.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/checkAnsBtn.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/checkAnsBtn.png
new file mode 100755
index 0000000..b7c80d3
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/checkAnsBtn.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/checkAnsBtnHover.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/checkAnsBtnHover.png
new file mode 100755
index 0000000..a0e6b6d
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/checkAnsBtnHover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/correct.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/correct.png
new file mode 100755
index 0000000..7e15698
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/correct.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise1.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise1.png
new file mode 100755
index 0000000..9b3384c
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise1Hover.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise1Hover.png
new file mode 100755
index 0000000..04accd4
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise1Hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise1Title.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise1Title.png
new file mode 100755
index 0000000..8d0892b
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise1Title.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise2.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise2.png
new file mode 100755
index 0000000..1d2df0a
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise2.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise2Hover.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise2Hover.png
new file mode 100755
index 0000000..8215fd7
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise2Hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise3.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise3.png
new file mode 100755
index 0000000..d537da7
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise3.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise3Hover.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise3Hover.png
new file mode 100755
index 0000000..156bf30
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exercise3Hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exerciseRestTitle.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exerciseRestTitle.png
new file mode 100755
index 0000000..ba49afa
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exerciseRestTitle.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exerciseTitle.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exerciseTitle.png
new file mode 100755
index 0000000..9901083
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/exerciseTitle.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/frog0.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/frog0.png
new file mode 100755
index 0000000..8381eaa
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/frog0.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/frog1.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/frog1.png
new file mode 100755
index 0000000..7c4cb36
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/frog1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/help.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/help.png
new file mode 100755
index 0000000..a34ef14
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/help.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/imgWhatzLCM.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/imgWhatzLCM.png
new file mode 100755
index 0000000..bc0c827
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/imgWhatzLCM.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/incorrect.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/incorrect.png
new file mode 100755
index 0000000..e60c32d
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/incorrect.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson1ImgDef0.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson1ImgDef0.png
new file mode 100755
index 0000000..ee9d038
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson1ImgDef0.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson1ImgDef1.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson1ImgDef1.png
new file mode 100755
index 0000000..643c10a
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson1ImgDef1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson1ImgDef2.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson1ImgDef2.png
new file mode 100755
index 0000000..7de05b7
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson1ImgDef2.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson1ImgDef3.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson1ImgDef3.png
new file mode 100755
index 0000000..fc8d63d
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson1ImgDef3.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson1ImgDef4.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson1ImgDef4.png
new file mode 100755
index 0000000..3b99af6
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson1ImgDef4.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef0.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef0.png
new file mode 100755
index 0000000..1d3dc25
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef0.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef1.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef1.png
new file mode 100755
index 0000000..8f39030
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef2.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef2.png
new file mode 100755
index 0000000..a449225
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef2.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef3.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef3.png
new file mode 100755
index 0000000..cd93e70
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef3.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef4.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef4.png
new file mode 100755
index 0000000..b858473
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef4.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef5.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef5.png
new file mode 100755
index 0000000..9855340
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef5.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef6.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef6.png
new file mode 100755
index 0000000..c28d498
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef6.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef7.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef7.png
new file mode 100755
index 0000000..309d45f
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef7.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef8.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef8.png
new file mode 100755
index 0000000..87f4a4a
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef8.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef9.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef9.png
new file mode 100755
index 0000000..fbba765
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgDef9.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgSign.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgSign.png
new file mode 100755
index 0000000..566d986
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson2ImgSign.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef0.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef0.png
new file mode 100755
index 0000000..b7abd2e
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef0.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef1.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef1.png
new file mode 100755
index 0000000..db8c4ad
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef2.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef2.png
new file mode 100755
index 0000000..1e22959
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef2.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef3.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef3.png
new file mode 100755
index 0000000..16c33b3
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef3.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef4.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef4.png
new file mode 100755
index 0000000..92cf39a
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef4.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef5.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef5.png
new file mode 100755
index 0000000..b267c7f
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/lesson3ImgDef5.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/moreQuesBtn.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/moreQuesBtn.png
new file mode 100755
index 0000000..03edd47
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/moreQuesBtn.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/moreQuesBtnHover.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/moreQuesBtnHover.png
new file mode 100755
index 0000000..1086d3e
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/moreQuesBtnHover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/nextBtn.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/nextBtn.png
new file mode 100755
index 0000000..081ef58
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/nextBtn.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/nextBtnHover.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/nextBtnHover.png
new file mode 100755
index 0000000..498ce32
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/nextBtnHover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/picClock.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/picClock.png
new file mode 100755
index 0000000..63e50e2
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/picClock.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/rabbit0.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/rabbit0.png
new file mode 100755
index 0000000..bd9badd
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/rabbit0.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/rabbit1.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/rabbit1.png
new file mode 100755
index 0000000..1585637
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/rabbit1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/showAnsBtn.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/showAnsBtn.png
new file mode 100755
index 0000000..7f3d720
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/showAnsBtn.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/showAnsBtnHover.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/showAnsBtnHover.png
new file mode 100755
index 0000000..3d6907c
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/showAnsBtnHover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/timeLine.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/timeLine.png
new file mode 100755
index 0000000..0891dcd
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/timeLine.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/timeLineIntersect.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/timeLineIntersect.png
new file mode 100755
index 0000000..cc7e88b
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/timeLineIntersect.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/timeRing.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/timeRing.png
new file mode 100755
index 0000000..64ed218
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/timeRing.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/title_block_lt.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/title_block_lt.png
new file mode 100755
index 0000000..4696182
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/title_block_lt.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/title_block_rt.png b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/title_block_rt.png
new file mode 100755
index 0000000..37cc44a
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/assets/image/title_block_rt.png
Binary files differ
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/css/lesson.css b/examples/lessons/6_Maths_lowestCommonMultiple/css/lesson.css
new file mode 100755
index 0000000..0bbcdc6
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/css/lesson.css
@@ -0,0 +1,393 @@
+@CHARSET "UTF-8";
+/****** Page Styles ****/
+
+/* Designed for 1200*900 px screen resolution */
+*{
+ margin:0;
+}
+body {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 10pt;
+ margin: 0px;
+ background-color: #FFFFCC;
+}
+#header {
+ background-image: url(../assets/image/bg_header.png);
+ background-repeat: repeat-x;
+ height: 75px;
+ width: 100%;
+ position: absolute;
+ left: 0px;
+ top: 0px;
+}
+#topbtn_left {
+ float: left;
+ height: 60px;
+ width: 60px;
+ padding-top: 6px;
+ padding-left: 15px;
+}
+
+
+ .linkBack{
+ width: 60px; height: 59px;
+ background:url(../assets/image/btn_back.png);
+ }
+ .linkBack:hover{
+ background:url(../assets/image/btn_back_hover.png);
+ }
+
+#lesson_title {
+ float: left;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 16pt;
+ font-weight: bold;
+ color: #FFFFFF;
+ margin-left: 10px;
+ background-image: url(../assets/image/bg_title_block.png);
+}
+#topbtn_right {
+ float: right;
+ height: 60px;
+ width: 60px;
+ padding-top: 6px;
+ padding-right: 15px;
+}
+ #linkHelp{
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_help.png);
+ }
+ #linkHelp:hover{
+ background:url(../assets/image/btn_help_hover.png);
+ }
+ #linkOle{
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_ole.png);
+ }
+ #linkOle:hover{
+ background:url(../assets/image/btn_ole_hover.png);
+ }
+ .linkNext{
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_next.png);
+ }
+ .linkNext:hover{
+ background:url(../assets/image/btn_next_hover.png);
+ }
+#footer {
+ position:relative;
+ background-image: url(../assets/image/bg_footer.png);
+ background-repeat: repeat-x;
+ height: 75px;
+ width: 100%;
+ left: 0px;
+ bottom: 0px;
+}
+#score_box {
+ float: left;
+ padding-left: 5px;
+ padding-top: 0.7em;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #FFFF00;
+ font-size: 16pt;
+ font-weight: bold;
+}
+#botbtn_right {
+ float: right;
+ height: 55px;
+ padding-right: 5px;
+ padding-top: 10px;
+}
+
+ #linkStart{
+ width: 251px; height: 55px;
+ background:url(../assets/image/btn_start.png);
+ }
+ #linkStart:hover{
+ background:url(../assets/image/btn_start_hover.png);
+ }
+ #linkStart:active{
+ background:url(../assets/image/btn_start_mouse_down.png);
+ }
+ #linkPlayAgain{
+ width: 251px; height: 55px;
+ background:url(../assets/image/btn_play_again.png);
+ }
+ #linkPlayAgain:hover{
+ background:url(../assets/image/btn_play_again_hover.png);
+ }
+ #linkPlayAgain:active{
+ background:url(../assets/image/btn_play_again_mouse_down.png);
+ }
+
+
+#timerBar {
+ display:none;
+ position: absolute;
+ left: 30%;
+ bottom: 25%;
+ width: 200px;
+ height:35px;
+ padding-left: 10px;
+ padding-top: 0px;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #FFFF00;
+ font-size: 16pt;
+ font-weight: bold;
+ }
+
+ .timerBoxes{ /* Show the timer running after the game has began.... */
+ float:right;
+ width: 50px;
+ height: 35px;
+ border: 2px dotted green;
+ color: blue;
+ text-align:center;
+ font : bold 25px Arial Black, Times New Roman;
+ background: #ACC;
+ }
+
+#linkNextLesson{
+ position:absolute;
+ bottom: 75px;
+ right: 10px;
+}
+#linkPrevLesson{
+ display:none;
+ position:absolute;
+ bottom: 75px;
+ left: 10px;
+}
+
+/**** End of the page style ****/
+
+/**** Game Styles ****/
+
+a{
+ color:#FFFFCC;
+}
+img{
+ border:none;
+}
+#currentTitle{
+ width: 150px;
+ height: 80px;
+ font:25px/30px "Courier New", Courier, monospace;
+ font-weight: bold;
+ color: red;
+}
+#content{
+ position:relative;
+ margin: 0px auto;
+ margin-top: 80px;
+ width: 1198px;
+ height: 555px;
+}
+.nextBtn{
+ position:absolute;
+ width: 145px;
+ height: 55px;
+ cursor: pointer;
+ background:url(../assets/image/nextBtn.png);
+}
+.nextBtn:hover{
+ background:url(../assets/image/nextBtnHover.png);
+ }
+
+
+
+.showAns{
+ margin: .2em 6em 0 2em;
+ width: 145px;
+ height: 55px;
+ cursor: pointer;
+ background:url(../assets/image/showAnsBtn.png);
+}
+.showAns:hover{
+ background:url(../assets/image/showAnsBtnHover.png);
+}
+.checkAns{
+ margin: .2em 1em;
+ width: 145px;
+ height: 55px;
+ cursor: pointer;
+ background:url(../assets/image/checkAnsBtn.png);
+}
+.checkAns:hover{
+ background:url(../assets/image/checkAnsBtnHover.png);
+ }
+#moreQues{
+ margin: .2em 1em;
+ width: 145px;
+ height: 55px;
+ cursor: pointer;
+ background:url(../assets/image/moreQuesBtn.png);
+}
+#moreQues:hover{
+ background:url(../assets/image/moreQuesBtnHover.png);
+ }
+.exerciseButtons{
+ position:absolute;
+ width: 159px;
+ height: 54px;
+ cursor: pointer;
+}
+
+#exercise1{
+ background:url(../assets/image/exercise1.png);
+}
+#exercise1:hover{
+ background:url(../assets/image/exercise1Hover.png);
+}
+#exercise2{
+ background:url(../assets/image/exercise2.png);
+}
+#exercise2:hover{
+ background:url(../assets/image/exercise2Hover.png);
+}
+#exercise3{
+ background:url(../assets/image/exercise3.png);
+}
+#exercise3:hover{
+ background:url(../assets/image/exercise3Hover.png);
+}
+
+
+ input.inputBox{
+ size:3;
+ font: 25px/30px Verdana, Geneva, Arial, Helvetica, sans-serif;
+ font-weight: bold;
+ height:30px;
+ width: 100px;
+ text-align:center;
+ }
+
+
+
+ input.ansBox{
+ size:4;
+ font: 25px/30px Verdana, Geneva, Arial, Helvetica, sans-serif;
+ font-weight: bold;
+ height:30px;
+ width: 120px;
+ text-align:center;
+ margin-left: 1em;
+ }
+ .default{
+ background-color: #A6E4FE;
+ }
+ .focus {
+ background-color: #FF9900;
+ }
+ .incorrect {
+ background-color: yellow;
+ }
+
+
+/* Exercise */
+#exerciseContainer{
+ margin: 2px auto;
+ width: 80em;
+ height: 40em;
+ text-align:center;
+}
+.exerciseTitle{
+ margin: .5em 10em;
+}
+.questions{
+ margin: 0 auto;
+ padding: .2em;
+ width: 35em;
+ height: 4em;
+ text-align:left;
+}
+ .numbersBox{
+ width: 6em;
+ border: 2px solid #000;
+ float:left;
+ text-align:center;
+ font: 30px Verdana, Geneva, Arial, Helvetica, sans-serif;
+ background-color: #A6E4FE;
+
+ }
+ .inpBox{
+ float:left;
+ }
+.romanNums{
+ float:left;
+ width: 2em;
+ font: 25px/35px bold Verdana, Geneva, Arial, Helvetica, sans-serif;
+}
+.displayBox{
+ margin: .3em 1em;
+ float:left;
+ width: 24px;
+ height: 24px;
+}
+#giveOptions{
+ margin: 3em auto 1em auto;
+ width: 20em;
+ height: 2em;
+ font: 30px Verdana, Geneva, Arial, Helvetica, sans-serif;
+}
+.options{
+ float:left;
+ width: 100px;
+ height: 40px;
+ margin: 0.2em;
+ background-color: #A6E4FE;
+ border: 2px solid black;
+}
+/*Utilities */
+.float-left{ float:left; }
+.float-right{ float:right; }
+.float-center{ margin:0px 10em;}
+.marginMore{margin: 0px 20em;}
+.clear {clear: both;}
+
+
+
+
+
+
+#help{
+ display:none;
+ position:absolute;
+ right: 60px;
+ top: 75px;;
+ width: 256px;
+ height: 600px;
+ background:url(../assets/image/help.png);
+ z-index:40;
+}
+.backOpaque{
+ background-color: #A4A4A4;
+ opacity: 0.2;
+ }
+
+ #gameOver{
+ opacity: 1;
+ display:none;
+ position:absolute;
+ top:45%;
+ left: 35%;
+ color: blue;
+ text-align:center;
+ font : bold 45px/65px Arial Black, Times New Roman;
+ }
+ #gameOverInfo{
+ margin-top: 35px;
+ text-align:center;
+ font: 20px/25px Helvetica, Geneva, Arial, Verdana, sans-serif;
+ font-weight:bold;
+ color:#FF0000;
+
+ }
+ .specialText{
+ margin-top: 1em;
+ font: 20px/25px Helvetica, Geneva, Arial, Verdana, sans-serif;
+ font-weight:bold;
+ color:#FF9900;
+ border-bottom: 2px dotted #CCC;
+
+ }
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/css/ui.scoreboard.css b/examples/lessons/6_Maths_lowestCommonMultiple/css/ui.scoreboard.css
new file mode 100755
index 0000000..11cdbb5
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/css/ui.scoreboard.css
@@ -0,0 +1,62 @@
+.ui-scoreboard-container-h{
+max-width: 800em;
+max-height: 200px;
+float:left;
+padding-top:0.4em;
+padding-bottom:0.4em;
+}
+
+.ui-scoreboard-spacing-h{
+max-width: 200em;
+max-height: 300em;
+display:inline;
+margin-left:0.2em;
+margin-right:0.4em;
+}
+
+.ui-scoreboard-text{
+font-size:larger;
+text-align: center;
+}
+
+.ui-scoreboard-number-h {
+background-color:black;
+color: white;
+padding-left:0.4em;
+padding-right:0.4em;
+font-size:larger;
+}
+
+.ui-scoreboard-button{
+float:right;
+cursor:pointer;
+}
+
+button .ui-scoreboard-icon{
+float: left;
+margin-right:0.3em;
+}
+.ui-scoreboard-container-v{
+max-width: 200px;
+max-height: 400px;
+float:left;
+padding-top:0.4em;
+padding-bottom:0.4em;
+}
+.ui-scoreboard-spacing-v{
+display:block;
+margin: 0.4em;
+}
+
+.ui-scoreboard-number-v{
+background-color:black;
+color: white;
+width: 1em;
+text-align:center;
+margin-left:auto;
+margin-right: auto;
+padding:0.4em;
+font-size:larger;
+}
+
+
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/index.html b/examples/lessons/6_Maths_lowestCommonMultiple/index.html
new file mode 100755
index 0000000..6d33843
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/index.html
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Class 6 Maths Lowest Common Multiple</title>
+ <meta name="keywords" content="karma,javascript,html5,sugar,sugarlabs,gsoc,ole,nepal" />
+ <link type="text/css" rel="stylesheet" href="css/ui.scoreboard.css" />
+ <link type="text/css" rel="stylesheet" href="css/lesson.css" />
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <link type="image/ico" rel="icon" href="../../assets/default/image/favicon.ico" />
+ <script type="text/javascript" src="js/jquery-1.4.js"></script>
+ <script type="text/javascript" src="js/ui.core.js"></script>
+ <script type="text/javascript" src="js/ui.scoreboard.js"></script>
+ <script type="text/javascript" src="js/karma.js"></script>
+ <script type="text/javascript" src="js/lesson.js"></script>
+</head>
+<body>
+ <div id="header">
+ <div id="topbtn_left"><a href="#"><div id="linkBackLesson" class="linkBack"></div></a></div>
+ <div id="lesson_title">
+ <img src="assets/image/title_block_lt.png" width="33" height="75" align="absmiddle" />
+ Lowest Common Multiple (LCM) || लघुतम समापर्तक (ल.स.)
+ <img src="assets/image/title_block_rt.png" width="33" height="75" align="absmiddle" />
+ </div>
+ <div id="topbtn_right"><a href="#"><div id="linkHelp"></div></a></div>
+ <div id="topbtn_right"><a href="http://olenepal.org"><div id="linkOle"></div></a></div>
+ </div>
+
+ <div id="content"></div>
+ <div id="help"></div>
+ <div id="gameOver"></div>
+ <form name="delayForm">
+ <input type="hidden" name="delayval" size="5">
+ </form>
+
+ <div id="footer">
+ <a href="#"><div id="linkNextLesson" class="linkNext"></div></a>
+ <a href="#"><div id="linkPrevLesson" class="linkBack"></div></a>
+ <div id="score_box"></div>
+ <div id ="timerBar">
+ <img src="assets/image/picClock.png" />
+ <div id="timerBox1" class="timerBoxes"></div>
+ <div id="timerBox2" class="timerBoxes"></div>
+ <div id="timerBox3" class="timerBoxes"></div>
+ </div>
+ <div id="botbtn_right"><a href="#"><div id="linkPlayAgain"></div></a></div>
+ <div id="botbtn_right"><a href="#"><div id="linkStart"></div></a></div>
+ <div id="botbtn_right"><a href="#"><div id="linkShowAns" class="showAns"></div></a></div>
+ <div id="botbtn_right"><a href="#"><div id="linkCheckAns" class="checkAns"></div></a></div>
+
+
+ </div>
+</body>
+</html>
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/js/jquery-1.4.js b/examples/lessons/6_Maths_lowestCommonMultiple/js/jquery-1.4.js
new file mode 100755
index 0000000..a448490
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/js/jquery-1.4.js
@@ -0,0 +1,5999 @@
+/*!
+ * jQuery JavaScript Library v1.4
+ * http://jquery.com/
+ *
+ * Copyright 2010, John Resig
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://docs.jquery.com/License
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ * Copyright 2010, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ *
+ * Date: Wed Jan 13 15:23:05 2010 -0500
+ */
+(function( window, undefined ) {
+
+// Define a local copy of jQuery
+var jQuery = function( selector, context ) {
+ // The jQuery object is actually just the init constructor 'enhanced'
+ return new jQuery.fn.init( selector, context );
+ },
+
+ // Map over jQuery in case of overwrite
+ _jQuery = window.jQuery,
+
+ // Map over the $ in case of overwrite
+ _$ = window.$,
+
+ // Use the correct document accordingly with window argument (sandbox)
+ document = window.document,
+
+ // A central reference to the root jQuery(document)
+ rootjQuery,
+
+ // A simple way to check for HTML strings or ID strings
+ // (both of which we optimize for)
+ quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,
+
+ // Is it a simple selector
+ isSimple = /^.[^:#\[\.,]*$/,
+
+ // Check if a string has a non-whitespace character in it
+ rnotwhite = /\S/,
+
+ // Used for trimming whitespace
+ rtrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g,
+
+ // Match a standalone tag
+ rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
+
+ // Keep a UserAgent string for use with jQuery.browser
+ userAgent = navigator.userAgent,
+
+ // For matching the engine and version of the browser
+ browserMatch,
+
+ // Has the ready events already been bound?
+ readyBound = false,
+
+ // The functions to execute on DOM ready
+ readyList = [],
+
+ // The ready event handler
+ DOMContentLoaded,
+
+ // Save a reference to some core methods
+ toString = Object.prototype.toString,
+ hasOwnProperty = Object.prototype.hasOwnProperty,
+ push = Array.prototype.push,
+ slice = Array.prototype.slice,
+ indexOf = Array.prototype.indexOf;
+
+jQuery.fn = jQuery.prototype = {
+ init: function( selector, context ) {
+ var match, elem, ret, doc;
+
+ // Handle $(""), $(null), or $(undefined)
+ if ( !selector ) {
+ return this;
+ }
+
+ // Handle $(DOMElement)
+ if ( selector.nodeType ) {
+ this.context = this[0] = selector;
+ this.length = 1;
+ return this;
+ }
+
+ // Handle HTML strings
+ if ( typeof selector === "string" ) {
+ // Are we dealing with HTML string or an ID?
+ match = quickExpr.exec( selector );
+
+ // Verify a match, and that no context was specified for #id
+ if ( match && (match[1] || !context) ) {
+
+ // HANDLE: $(html) -> $(array)
+ if ( match[1] ) {
+ doc = (context ? context.ownerDocument || context : document);
+
+ // If a single string is passed in and it's a single tag
+ // just do a createElement and skip the rest
+ ret = rsingleTag.exec( selector );
+
+ if ( ret ) {
+ if ( jQuery.isPlainObject( context ) ) {
+ selector = [ document.createElement( ret[1] ) ];
+ jQuery.fn.attr.call( selector, context, true );
+
+ } else {
+ selector = [ doc.createElement( ret[1] ) ];
+ }
+
+ } else {
+ ret = buildFragment( [ match[1] ], [ doc ] );
+ selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
+ }
+
+ // HANDLE: $("#id")
+ } else {
+ elem = document.getElementById( match[2] );
+
+ if ( elem ) {
+ // Handle the case where IE and Opera return items
+ // by name instead of ID
+ if ( elem.id !== match[2] ) {
+ return rootjQuery.find( selector );
+ }
+
+ // Otherwise, we inject the element directly into the jQuery object
+ this.length = 1;
+ this[0] = elem;
+ }
+
+ this.context = document;
+ this.selector = selector;
+ return this;
+ }
+
+ // HANDLE: $("TAG")
+ } else if ( !context && /^\w+$/.test( selector ) ) {
+ this.selector = selector;
+ this.context = document;
+ selector = document.getElementsByTagName( selector );
+
+ // HANDLE: $(expr, $(...))
+ } else if ( !context || context.jquery ) {
+ return (context || rootjQuery).find( selector );
+
+ // HANDLE: $(expr, context)
+ // (which is just equivalent to: $(context).find(expr)
+ } else {
+ return jQuery( context ).find( selector );
+ }
+
+ // HANDLE: $(function)
+ // Shortcut for document ready
+ } else if ( jQuery.isFunction( selector ) ) {
+ return rootjQuery.ready( selector );
+ }
+
+ if (selector.selector !== undefined) {
+ this.selector = selector.selector;
+ this.context = selector.context;
+ }
+
+ return jQuery.isArray( selector ) ?
+ this.setArray( selector ) :
+ jQuery.makeArray( selector, this );
+ },
+
+ // Start with an empty selector
+ selector: "",
+
+ // The current version of jQuery being used
+ jquery: "1.4",
+
+ // The default length of a jQuery object is 0
+ length: 0,
+
+ // The number of elements contained in the matched element set
+ size: function() {
+ return this.length;
+ },
+
+ toArray: function() {
+ return slice.call( this, 0 );
+ },
+
+ // Get the Nth element in the matched element set OR
+ // Get the whole matched element set as a clean array
+ get: function( num ) {
+ return num == null ?
+
+ // Return a 'clean' array
+ this.toArray() :
+
+ // Return just the object
+ ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
+ },
+
+ // Take an array of elements and push it onto the stack
+ // (returning the new matched element set)
+ pushStack: function( elems, name, selector ) {
+ // Build a new jQuery matched element set
+ var ret = jQuery( elems || null );
+
+ // Add the old object onto the stack (as a reference)
+ ret.prevObject = this;
+
+ ret.context = this.context;
+
+ if ( name === "find" ) {
+ ret.selector = this.selector + (this.selector ? " " : "") + selector;
+ } else if ( name ) {
+ ret.selector = this.selector + "." + name + "(" + selector + ")";
+ }
+
+ // Return the newly-formed element set
+ return ret;
+ },
+
+ // Force the current matched set of elements to become
+ // the specified array of elements (destroying the stack in the process)
+ // You should use pushStack() in order to do this, but maintain the stack
+ setArray: function( elems ) {
+ // Resetting the length to 0, then using the native Array push
+ // is a super-fast way to populate an object with array-like properties
+ this.length = 0;
+ push.apply( this, elems );
+
+ return this;
+ },
+
+ // Execute a callback for every element in the matched set.
+ // (You can seed the arguments with an array of args, but this is
+ // only used internally.)
+ each: function( callback, args ) {
+ return jQuery.each( this, callback, args );
+ },
+
+ ready: function( fn ) {
+ // Attach the listeners
+ jQuery.bindReady();
+
+ // If the DOM is already ready
+ if ( jQuery.isReady ) {
+ // Execute the function immediately
+ fn.call( document, jQuery );
+
+ // Otherwise, remember the function for later
+ } else if ( readyList ) {
+ // Add the function to the wait list
+ readyList.push( fn );
+ }
+
+ return this;
+ },
+
+ eq: function( i ) {
+ return i === -1 ?
+ this.slice( i ) :
+ this.slice( i, +i + 1 );
+ },
+
+ first: function() {
+ return this.eq( 0 );
+ },
+
+ last: function() {
+ return this.eq( -1 );
+ },
+
+ slice: function() {
+ return this.pushStack( slice.apply( this, arguments ),
+ "slice", slice.call(arguments).join(",") );
+ },
+
+ map: function( callback ) {
+ return this.pushStack( jQuery.map(this, function( elem, i ) {
+ return callback.call( elem, i, elem );
+ }));
+ },
+
+ end: function() {
+ return this.prevObject || jQuery(null);
+ },
+
+ // For internal use only.
+ // Behaves like an Array's method, not like a jQuery method.
+ push: push,
+ sort: [].sort,
+ splice: [].splice
+};
+
+// Give the init function the jQuery prototype for later instantiation
+jQuery.fn.init.prototype = jQuery.fn;
+
+jQuery.extend = jQuery.fn.extend = function() {
+ // copy reference to target object
+ var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy;
+
+ // Handle a deep copy situation
+ if ( typeof target === "boolean" ) {
+ deep = target;
+ target = arguments[1] || {};
+ // skip the boolean and the target
+ i = 2;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
+ target = {};
+ }
+
+ // extend jQuery itself if only one argument is passed
+ if ( length === i ) {
+ target = this;
+ --i;
+ }
+
+ for ( ; i < length; i++ ) {
+ // Only deal with non-null/undefined values
+ if ( (options = arguments[ i ]) != null ) {
+ // Extend the base object
+ for ( name in options ) {
+ src = target[ name ];
+ copy = options[ name ];
+
+ // Prevent never-ending loop
+ if ( target === copy ) {
+ continue;
+ }
+
+ // Recurse if we're merging object literal values or arrays
+ if ( deep && copy && ( jQuery.isPlainObject(copy) || jQuery.isArray(copy) ) ) {
+ var clone = src && ( jQuery.isPlainObject(src) || jQuery.isArray(src) ) ? src
+ : jQuery.isArray(copy) ? [] : {};
+
+ // Never move original objects, clone them
+ target[ name ] = jQuery.extend( deep, clone, copy );
+
+ // Don't bring in undefined values
+ } else if ( copy !== undefined ) {
+ target[ name ] = copy;
+ }
+ }
+ }
+ }
+
+ // Return the modified object
+ return target;
+};
+
+jQuery.extend({
+ noConflict: function( deep ) {
+ window.$ = _$;
+
+ if ( deep ) {
+ window.jQuery = _jQuery;
+ }
+
+ return jQuery;
+ },
+
+ // Is the DOM ready to be used? Set to true once it occurs.
+ isReady: false,
+
+ // Handle when the DOM is ready
+ ready: function() {
+ // Make sure that the DOM is not already loaded
+ if ( !jQuery.isReady ) {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( !document.body ) {
+ return setTimeout( jQuery.ready, 13 );
+ }
+
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If there are functions bound, to execute
+ if ( readyList ) {
+ // Execute all of them
+ var fn, i = 0;
+ while ( (fn = readyList[ i++ ]) ) {
+ fn.call( document, jQuery );
+ }
+
+ // Reset the list of functions
+ readyList = null;
+ }
+
+ // Trigger any bound ready events
+ if ( jQuery.fn.triggerHandler ) {
+ jQuery( document ).triggerHandler( "ready" );
+ }
+ }
+ },
+
+ bindReady: function() {
+ if ( readyBound ) {
+ return;
+ }
+
+ readyBound = true;
+
+ // Catch cases where $(document).ready() is called after the
+ // browser event has already occurred.
+ if ( document.readyState === "complete" ) {
+ return jQuery.ready();
+ }
+
+ // Mozilla, Opera and webkit nightlies currently support this event
+ if ( document.addEventListener ) {
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+
+ // A fallback to window.onload, that will always work
+ window.addEventListener( "load", jQuery.ready, false );
+
+ // If IE event model is used
+ } else if ( document.attachEvent ) {
+ // ensure firing before onload,
+ // maybe late but safe also for iframes
+ document.attachEvent("onreadystatechange", DOMContentLoaded);
+
+ // A fallback to window.onload, that will always work
+ window.attachEvent( "onload", jQuery.ready );
+
+ // If IE and not a frame
+ // continually check to see if the document is ready
+ var toplevel = false;
+
+ try {
+ toplevel = window.frameElement == null;
+ } catch(e) {}
+
+ if ( document.documentElement.doScroll && toplevel ) {
+ doScrollCheck();
+ }
+ }
+ },
+
+ // See test/unit/core.js for details concerning isFunction.
+ // Since version 1.3, DOM methods and functions like alert
+ // aren't supported. They return false on IE (#2968).
+ isFunction: function( obj ) {
+ return toString.call(obj) === "[object Function]";
+ },
+
+ isArray: function( obj ) {
+ return toString.call(obj) === "[object Array]";
+ },
+
+ isPlainObject: function( obj ) {
+ // Must be an Object.
+ // Because of IE, we also have to check the presence of the constructor property.
+ // Make sure that DOM nodes and window objects don't pass through, as well
+ if ( !obj || toString.call(obj) !== "[object Object]" || obj.nodeType || obj.setInterval ) {
+ return false;
+ }
+
+ // Not own constructor property must be Object
+ if ( obj.constructor
+ && !hasOwnProperty.call(obj, "constructor")
+ && !hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf") ) {
+ return false;
+ }
+
+ // Own properties are enumerated firstly, so to speed up,
+ // if last one is own, then all properties are own.
+
+ var key;
+ for ( key in obj ) {}
+
+ return key === undefined || hasOwnProperty.call( obj, key );
+ },
+
+ isEmptyObject: function( obj ) {
+ for ( var name in obj ) {
+ return false;
+ }
+ return true;
+ },
+
+ noop: function() {},
+
+ // Evalulates a script in a global context
+ globalEval: function( data ) {
+ if ( data && rnotwhite.test(data) ) {
+ // Inspired by code by Andrea Giammarchi
+ // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
+ var head = document.getElementsByTagName("head")[0] || document.documentElement,
+ script = document.createElement("script");
+
+ script.type = "text/javascript";
+
+ if ( jQuery.support.scriptEval ) {
+ script.appendChild( document.createTextNode( data ) );
+ } else {
+ script.text = data;
+ }
+
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709).
+ head.insertBefore( script, head.firstChild );
+ head.removeChild( script );
+ }
+ },
+
+ nodeName: function( elem, name ) {
+ return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
+ },
+
+ // args is for internal usage only
+ each: function( object, callback, args ) {
+ var name, i = 0,
+ length = object.length,
+ isObj = length === undefined || jQuery.isFunction(object);
+
+ if ( args ) {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.apply( object[ name ], args ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( ; i < length; ) {
+ if ( callback.apply( object[ i++ ], args ) === false ) {
+ break;
+ }
+ }
+ }
+
+ // A special, fast, case for the most common use of each
+ } else {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( var value = object[0];
+ i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
+ }
+ }
+
+ return object;
+ },
+
+ trim: function( text ) {
+ return (text || "").replace( rtrim, "" );
+ },
+
+ // results is for internal usage only
+ makeArray: function( array, results ) {
+ var ret = results || [];
+
+ if ( array != null ) {
+ // The window, strings (and functions) also have 'length'
+ // The extra typeof function check is to prevent crashes
+ // in Safari 2 (See: #3039)
+ if ( array.length == null || typeof array === "string" || jQuery.isFunction(array) || (typeof array !== "function" && array.setInterval) ) {
+ push.call( ret, array );
+ } else {
+ jQuery.merge( ret, array );
+ }
+ }
+
+ return ret;
+ },
+
+ inArray: function( elem, array ) {
+ if ( array.indexOf ) {
+ return array.indexOf( elem );
+ }
+
+ for ( var i = 0, length = array.length; i < length; i++ ) {
+ if ( array[ i ] === elem ) {
+ return i;
+ }
+ }
+
+ return -1;
+ },
+
+ merge: function( first, second ) {
+ var i = first.length, j = 0;
+
+ if ( typeof second.length === "number" ) {
+ for ( var l = second.length; j < l; j++ ) {
+ first[ i++ ] = second[ j ];
+ }
+ } else {
+ while ( second[j] !== undefined ) {
+ first[ i++ ] = second[ j++ ];
+ }
+ }
+
+ first.length = i;
+
+ return first;
+ },
+
+ grep: function( elems, callback, inv ) {
+ var ret = [];
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ if ( !inv !== !callback( elems[ i ], i ) ) {
+ ret.push( elems[ i ] );
+ }
+ }
+
+ return ret;
+ },
+
+ // arg is for internal usage only
+ map: function( elems, callback, arg ) {
+ var ret = [], value;
+
+ // Go through the array, translating each of the items to their
+ // new value (or values).
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ value = callback( elems[ i ], i, arg );
+
+ if ( value != null ) {
+ ret[ ret.length ] = value;
+ }
+ }
+
+ return ret.concat.apply( [], ret );
+ },
+
+ // A global GUID counter for objects
+ guid: 1,
+
+ proxy: function( fn, proxy, thisObject ) {
+ if ( arguments.length === 2 ) {
+ if ( typeof proxy === "string" ) {
+ thisObject = fn;
+ fn = thisObject[ proxy ];
+ proxy = undefined;
+
+ } else if ( proxy && !jQuery.isFunction( proxy ) ) {
+ thisObject = proxy;
+ proxy = undefined;
+ }
+ }
+
+ if ( !proxy && fn ) {
+ proxy = function() {
+ return fn.apply( thisObject || this, arguments );
+ };
+ }
+
+ // Set the guid of unique handler to the same of original handler, so it can be removed
+ if ( fn ) {
+ proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
+ }
+
+ // So proxy can be declared as an argument
+ return proxy;
+ },
+
+ // Use of jQuery.browser is frowned upon.
+ // More details: http://docs.jquery.com/Utilities/jQuery.browser
+ uaMatch: function( ua ) {
+ var ret = { browser: "" };
+
+ ua = ua.toLowerCase();
+
+ if ( /webkit/.test( ua ) ) {
+ ret = { browser: "webkit", version: /webkit[\/ ]([\w.]+)/ };
+
+ } else if ( /opera/.test( ua ) ) {
+ ret = { browser: "opera", version: /version/.test( ua ) ? /version[\/ ]([\w.]+)/ : /opera[\/ ]([\w.]+)/ };
+
+ } else if ( /msie/.test( ua ) ) {
+ ret = { browser: "msie", version: /msie ([\w.]+)/ };
+
+ } else if ( /mozilla/.test( ua ) && !/compatible/.test( ua ) ) {
+ ret = { browser: "mozilla", version: /rv:([\w.]+)/ };
+ }
+
+ ret.version = (ret.version && ret.version.exec( ua ) || [0, "0"])[1];
+
+ return ret;
+ },
+
+ browser: {}
+});
+
+browserMatch = jQuery.uaMatch( userAgent );
+if ( browserMatch.browser ) {
+ jQuery.browser[ browserMatch.browser ] = true;
+ jQuery.browser.version = browserMatch.version;
+}
+
+// Deprecated, use jQuery.browser.webkit instead
+if ( jQuery.browser.webkit ) {
+ jQuery.browser.safari = true;
+}
+
+if ( indexOf ) {
+ jQuery.inArray = function( elem, array ) {
+ return indexOf.call( array, elem );
+ };
+}
+
+// All jQuery objects should point back to these
+rootjQuery = jQuery(document);
+
+// Cleanup functions for the document ready method
+if ( document.addEventListener ) {
+ DOMContentLoaded = function() {
+ document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+ jQuery.ready();
+ };
+
+} else if ( document.attachEvent ) {
+ DOMContentLoaded = function() {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( document.readyState === "complete" ) {
+ document.detachEvent( "onreadystatechange", DOMContentLoaded );
+ jQuery.ready();
+ }
+ };
+}
+
+// The DOM ready check for Internet Explorer
+function doScrollCheck() {
+ if ( jQuery.isReady ) {
+ return;
+ }
+
+ try {
+ // If IE is used, use the trick by Diego Perini
+ // http://javascript.nwbox.com/IEContentLoaded/
+ document.documentElement.doScroll("left");
+ } catch( error ) {
+ setTimeout( doScrollCheck, 1 );
+ return;
+ }
+
+ // and execute any waiting functions
+ jQuery.ready();
+}
+
+if ( indexOf ) {
+ jQuery.inArray = function( elem, array ) {
+ return indexOf.call( array, elem );
+ };
+}
+
+function evalScript( i, elem ) {
+ if ( elem.src ) {
+ jQuery.ajax({
+ url: elem.src,
+ async: false,
+ dataType: "script"
+ });
+ } else {
+ jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
+ }
+
+ if ( elem.parentNode ) {
+ elem.parentNode.removeChild( elem );
+ }
+}
+
+// Mutifunctional method to get and set values to a collection
+// The value/s can be optionally by executed if its a function
+function access( elems, key, value, exec, fn, pass ) {
+ var length = elems.length;
+
+ // Setting many attributes
+ if ( typeof key === "object" ) {
+ for ( var k in key ) {
+ access( elems, k, key[k], exec, fn, value );
+ }
+ return elems;
+ }
+
+ // Setting one attribute
+ if ( value !== undefined ) {
+ // Optionally, function values get executed if exec is true
+ exec = !pass && exec && jQuery.isFunction(value);
+
+ for ( var i = 0; i < length; i++ ) {
+ fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
+ }
+
+ return elems;
+ }
+
+ // Getting an attribute
+ return length ? fn( elems[0], key ) : null;
+}
+
+function now() {
+ return (new Date).getTime();
+}
+(function() {
+
+ jQuery.support = {};
+
+ var root = document.documentElement,
+ script = document.createElement("script"),
+ div = document.createElement("div"),
+ id = "script" + now();
+
+ div.style.display = "none";
+ div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
+
+ var all = div.getElementsByTagName("*"),
+ a = div.getElementsByTagName("a")[0];
+
+ // Can't get basic test support
+ if ( !all || !all.length || !a ) {
+ return;
+ }
+
+ jQuery.support = {
+ // IE strips leading whitespace when .innerHTML is used
+ leadingWhitespace: div.firstChild.nodeType === 3,
+
+ // Make sure that tbody elements aren't automatically inserted
+ // IE will insert them into empty tables
+ tbody: !div.getElementsByTagName("tbody").length,
+
+ // Make sure that link elements get serialized correctly by innerHTML
+ // This requires a wrapper element in IE
+ htmlSerialize: !!div.getElementsByTagName("link").length,
+
+ // Get the style information from getAttribute
+ // (IE uses .cssText insted)
+ style: /red/.test( a.getAttribute("style") ),
+
+ // Make sure that URLs aren't manipulated
+ // (IE normalizes it by default)
+ hrefNormalized: a.getAttribute("href") === "/a",
+
+ // Make sure that element opacity exists
+ // (IE uses filter instead)
+ // Use a regex to work around a WebKit issue. See #5145
+ opacity: /^0.55$/.test( a.style.opacity ),
+
+ // Verify style float existence
+ // (IE uses styleFloat instead of cssFloat)
+ cssFloat: !!a.style.cssFloat,
+
+ // Make sure that if no value is specified for a checkbox
+ // that it defaults to "on".
+ // (WebKit defaults to "" instead)
+ checkOn: div.getElementsByTagName("input")[0].value === "on",
+
+ // Make sure that a selected-by-default option has a working selected property.
+ // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
+ optSelected: document.createElement("select").appendChild( document.createElement("option") ).selected,
+
+ // Will be defined later
+ scriptEval: false,
+ noCloneEvent: true,
+ boxModel: null
+ };
+
+ script.type = "text/javascript";
+ try {
+ script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
+ } catch(e) {}
+
+ root.insertBefore( script, root.firstChild );
+
+ // Make sure that the execution of code works by injecting a script
+ // tag with appendChild/createTextNode
+ // (IE doesn't support this, fails, and uses .text instead)
+ if ( window[ id ] ) {
+ jQuery.support.scriptEval = true;
+ delete window[ id ];
+ }
+
+ root.removeChild( script );
+
+ if ( div.attachEvent && div.fireEvent ) {
+ div.attachEvent("onclick", function click() {
+ // Cloning a node shouldn't copy over any
+ // bound event handlers (IE does this)
+ jQuery.support.noCloneEvent = false;
+ div.detachEvent("onclick", click);
+ });
+ div.cloneNode(true).fireEvent("onclick");
+ }
+
+ // Figure out if the W3C box model works as expected
+ // document.body must exist before we can do this
+ // TODO: This timeout is temporary until I move ready into core.js.
+ jQuery(function() {
+ var div = document.createElement("div");
+ div.style.width = div.style.paddingLeft = "1px";
+
+ document.body.appendChild( div );
+ jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
+ document.body.removeChild( div ).style.display = 'none';
+ div = null;
+ });
+
+ // Technique from Juriy Zaytsev
+ // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
+ var eventSupported = function( eventName ) {
+ var el = document.createElement("div");
+ eventName = "on" + eventName;
+
+ var isSupported = (eventName in el);
+ if ( !isSupported ) {
+ el.setAttribute(eventName, "return;");
+ isSupported = typeof el[eventName] === "function";
+ }
+ el = null;
+
+ return isSupported;
+ };
+
+ jQuery.support.submitBubbles = eventSupported("submit");
+ jQuery.support.changeBubbles = eventSupported("change");
+
+ // release memory in IE
+ root = script = div = all = a = null;
+})();
+
+jQuery.props = {
+ "for": "htmlFor",
+ "class": "className",
+ readonly: "readOnly",
+ maxlength: "maxLength",
+ cellspacing: "cellSpacing",
+ rowspan: "rowSpan",
+ colspan: "colSpan",
+ tabindex: "tabIndex",
+ usemap: "useMap",
+ frameborder: "frameBorder"
+};
+var expando = "jQuery" + now(), uuid = 0, windowData = {};
+var emptyObject = {};
+
+jQuery.extend({
+ cache: {},
+
+ expando:expando,
+
+ // The following elements throw uncatchable exceptions if you
+ // attempt to add expando properties to them.
+ noData: {
+ "embed": true,
+ "object": true,
+ "applet": true
+ },
+
+ data: function( elem, name, data ) {
+ if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
+ return;
+ }
+
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var id = elem[ expando ], cache = jQuery.cache, thisCache;
+
+ // Handle the case where there's no name immediately
+ if ( !name && !id ) {
+ return null;
+ }
+
+ // Compute a unique ID for the element
+ if ( !id ) {
+ id = ++uuid;
+ }
+
+ // Avoid generating a new cache unless none exists and we
+ // want to manipulate it.
+ if ( typeof name === "object" ) {
+ elem[ expando ] = id;
+ thisCache = cache[ id ] = jQuery.extend(true, {}, name);
+ } else if ( cache[ id ] ) {
+ thisCache = cache[ id ];
+ } else if ( typeof data === "undefined" ) {
+ thisCache = emptyObject;
+ } else {
+ thisCache = cache[ id ] = {};
+ }
+
+ // Prevent overriding the named cache with undefined values
+ if ( data !== undefined ) {
+ elem[ expando ] = id;
+ thisCache[ name ] = data;
+ }
+
+ return typeof name === "string" ? thisCache[ name ] : thisCache;
+ },
+
+ removeData: function( elem, name ) {
+ if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
+ return;
+ }
+
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ];
+
+ // If we want to remove a specific section of the element's data
+ if ( name ) {
+ if ( thisCache ) {
+ // Remove the section of cache data
+ delete thisCache[ name ];
+
+ // If we've removed all the data, remove the element's cache
+ if ( jQuery.isEmptyObject(thisCache) ) {
+ jQuery.removeData( elem );
+ }
+ }
+
+ // Otherwise, we want to remove all of the element's data
+ } else {
+ // Clean up the element expando
+ try {
+ delete elem[ expando ];
+ } catch( e ) {
+ // IE has trouble directly removing the expando
+ // but it's ok with using removeAttribute
+ if ( elem.removeAttribute ) {
+ elem.removeAttribute( expando );
+ }
+ }
+
+ // Completely remove the data cache
+ delete cache[ id ];
+ }
+ }
+});
+
+jQuery.fn.extend({
+ data: function( key, value ) {
+ if ( typeof key === "undefined" && this.length ) {
+ return jQuery.data( this[0] );
+
+ } else if ( typeof key === "object" ) {
+ return this.each(function() {
+ jQuery.data( this, key );
+ });
+ }
+
+ var parts = key.split(".");
+ parts[1] = parts[1] ? "." + parts[1] : "";
+
+ if ( value === undefined ) {
+ var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
+
+ if ( data === undefined && this.length ) {
+ data = jQuery.data( this[0], key );
+ }
+ return data === undefined && parts[1] ?
+ this.data( parts[0] ) :
+ data;
+ } else {
+ return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function() {
+ jQuery.data( this, key, value );
+ });
+ }
+ },
+
+ removeData: function( key ) {
+ return this.each(function() {
+ jQuery.removeData( this, key );
+ });
+ }
+});
+jQuery.extend({
+ queue: function( elem, type, data ) {
+ if ( !elem ) {
+ return;
+ }
+
+ type = (type || "fx") + "queue";
+ var q = jQuery.data( elem, type );
+
+ // Speed up dequeue by getting out quickly if this is just a lookup
+ if ( !data ) {
+ return q || [];
+ }
+
+ if ( !q || jQuery.isArray(data) ) {
+ q = jQuery.data( elem, type, jQuery.makeArray(data) );
+
+ } else {
+ q.push( data );
+ }
+
+ return q;
+ },
+
+ dequeue: function( elem, type ) {
+ type = type || "fx";
+
+ var queue = jQuery.queue( elem, type ), fn = queue.shift();
+
+ // If the fx queue is dequeued, always remove the progress sentinel
+ if ( fn === "inprogress" ) {
+ fn = queue.shift();
+ }
+
+ if ( fn ) {
+ // Add a progress sentinel to prevent the fx queue from being
+ // automatically dequeued
+ if ( type === "fx" ) {
+ queue.unshift("inprogress");
+ }
+
+ fn.call(elem, function() {
+ jQuery.dequeue(elem, type);
+ });
+ }
+ }
+});
+
+jQuery.fn.extend({
+ queue: function( type, data ) {
+ if ( typeof type !== "string" ) {
+ data = type;
+ type = "fx";
+ }
+
+ if ( data === undefined ) {
+ return jQuery.queue( this[0], type );
+ }
+ return this.each(function( i, elem ) {
+ var queue = jQuery.queue( this, type, data );
+
+ if ( type === "fx" && queue[0] !== "inprogress" ) {
+ jQuery.dequeue( this, type );
+ }
+ });
+ },
+ dequeue: function( type ) {
+ return this.each(function() {
+ jQuery.dequeue( this, type );
+ });
+ },
+
+ // Based off of the plugin by Clint Helfers, with permission.
+ // http://blindsignals.com/index.php/2009/07/jquery-delay/
+ delay: function( time, type ) {
+ time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
+ type = type || "fx";
+
+ return this.queue( type, function() {
+ var elem = this;
+ setTimeout(function() {
+ jQuery.dequeue( elem, type );
+ }, time );
+ });
+ },
+
+ clearQueue: function( type ) {
+ return this.queue( type || "fx", [] );
+ }
+});
+var rclass = /[\n\t]/g,
+ rspace = /\s+/,
+ rreturn = /\r/g,
+ rspecialurl = /href|src|style/,
+ rtype = /(button|input)/i,
+ rfocusable = /(button|input|object|select|textarea)/i,
+ rclickable = /^(a|area)$/i,
+ rradiocheck = /radio|checkbox/;
+
+jQuery.fn.extend({
+ attr: function( name, value ) {
+ return access( this, name, value, true, jQuery.attr );
+ },
+
+ removeAttr: function( name, fn ) {
+ return this.each(function(){
+ jQuery.attr( this, name, "" );
+ if ( this.nodeType === 1 ) {
+ this.removeAttribute( name );
+ }
+ });
+ },
+
+ addClass: function( value ) {
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.addClass( value.call(this, i, self.attr("class")) );
+ });
+ }
+
+ if ( value && typeof value === "string" ) {
+ var classNames = (value || "").split( rspace );
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var elem = this[i];
+
+ if ( elem.nodeType === 1 ) {
+ if ( !elem.className ) {
+ elem.className = value;
+
+ } else {
+ var className = " " + elem.className + " ";
+ for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
+ if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
+ elem.className += " " + classNames[c];
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ removeClass: function( value ) {
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.removeClass( value.call(this, i, self.attr("class")) );
+ });
+ }
+
+ if ( (value && typeof value === "string") || value === undefined ) {
+ var classNames = (value || "").split(rspace);
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var elem = this[i];
+
+ if ( elem.nodeType === 1 && elem.className ) {
+ if ( value ) {
+ var className = (" " + elem.className + " ").replace(rclass, " ");
+ for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
+ className = className.replace(" " + classNames[c] + " ", " ");
+ }
+ elem.className = className.substring(1, className.length - 1);
+
+ } else {
+ elem.className = "";
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ toggleClass: function( value, stateVal ) {
+ var type = typeof value, isBool = typeof stateVal === "boolean";
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
+ });
+ }
+
+ return this.each(function() {
+ if ( type === "string" ) {
+ // toggle individual class names
+ var className, i = 0, self = jQuery(this),
+ state = stateVal,
+ classNames = value.split( rspace );
+
+ while ( (className = classNames[ i++ ]) ) {
+ // check each className given, space seperated list
+ state = isBool ? state : !self.hasClass( className );
+ self[ state ? "addClass" : "removeClass" ]( className );
+ }
+
+ } else if ( type === "undefined" || type === "boolean" ) {
+ if ( this.className ) {
+ // store className if set
+ jQuery.data( this, "__className__", this.className );
+ }
+
+ // toggle whole className
+ this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || "";
+ }
+ });
+ },
+
+ hasClass: function( selector ) {
+ var className = " " + selector + " ";
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ val: function( value ) {
+ if ( value === undefined ) {
+ var elem = this[0];
+
+ if ( elem ) {
+ if ( jQuery.nodeName( elem, "option" ) ) {
+ return (elem.attributes.value || {}).specified ? elem.value : elem.text;
+ }
+
+ // We need to handle select boxes special
+ if ( jQuery.nodeName( elem, "select" ) ) {
+ var index = elem.selectedIndex,
+ values = [],
+ options = elem.options,
+ one = elem.type === "select-one";
+
+ // Nothing was selected
+ if ( index < 0 ) {
+ return null;
+ }
+
+ // Loop through all the selected options
+ for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
+ var option = options[ i ];
+
+ if ( option.selected ) {
+ // Get the specifc value for the option
+ value = jQuery(option).val();
+
+ // We don't need an array for one selects
+ if ( one ) {
+ return value;
+ }
+
+ // Multi-Selects return an array
+ values.push( value );
+ }
+ }
+
+ return values;
+ }
+
+ // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
+ if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
+ return elem.getAttribute("value") === null ? "on" : elem.value;
+ }
+
+
+ // Everything else, we just grab the value
+ return (elem.value || "").replace(rreturn, "");
+
+ }
+
+ return undefined;
+ }
+
+ var isFunction = jQuery.isFunction(value);
+
+ return this.each(function(i) {
+ var self = jQuery(this), val = value;
+
+ if ( this.nodeType !== 1 ) {
+ return;
+ }
+
+ if ( isFunction ) {
+ val = value.call(this, i, self.val());
+ }
+
+ // Typecast each time if the value is a Function and the appended
+ // value is therefore different each time.
+ if ( typeof val === "number" ) {
+ val += "";
+ }
+
+ if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
+ this.checked = jQuery.inArray( self.val(), val ) >= 0;
+
+ } else if ( jQuery.nodeName( this, "select" ) ) {
+ var values = jQuery.makeArray(val);
+
+ jQuery( "option", this ).each(function() {
+ this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
+ });
+
+ if ( !values.length ) {
+ this.selectedIndex = -1;
+ }
+
+ } else {
+ this.value = val;
+ }
+ });
+ }
+});
+
+jQuery.extend({
+ attrFn: {
+ val: true,
+ css: true,
+ html: true,
+ text: true,
+ data: true,
+ width: true,
+ height: true,
+ offset: true
+ },
+
+ attr: function( elem, name, value, pass ) {
+ // don't set attributes on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ if ( pass && name in jQuery.attrFn ) {
+ return jQuery(elem)[name](value);
+ }
+
+ var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
+ // Whether we are setting (or getting)
+ set = value !== undefined;
+
+ // Try to normalize/fix the name
+ name = notxml && jQuery.props[ name ] || name;
+
+ // Only do all the following if this is a node (faster for style)
+ if ( elem.nodeType === 1 ) {
+ // These attributes require special treatment
+ var special = rspecialurl.test( name );
+
+ // Safari mis-reports the default selected property of an option
+ // Accessing the parent's selectedIndex property fixes it
+ if ( name === "selected" && !jQuery.support.optSelected ) {
+ var parent = elem.parentNode;
+ if ( parent ) {
+ parent.selectedIndex;
+
+ // Make sure that it also works with optgroups, see #5701
+ if ( parent.parentNode ) {
+ parent.parentNode.selectedIndex;
+ }
+ }
+ }
+
+ // If applicable, access the attribute via the DOM 0 way
+ if ( name in elem && notxml && !special ) {
+ if ( set ) {
+ // We can't allow the type property to be changed (since it causes problems in IE)
+ if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
+ throw "type property can't be changed";
+ }
+
+ elem[ name ] = value;
+ }
+
+ // browsers index elements by id/name on forms, give priority to attributes.
+ if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
+ return elem.getAttributeNode( name ).nodeValue;
+ }
+
+ // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
+ // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
+ if ( name === "tabIndex" ) {
+ var attributeNode = elem.getAttributeNode( "tabIndex" );
+
+ return attributeNode && attributeNode.specified ?
+ attributeNode.value :
+ rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
+ 0 :
+ undefined;
+ }
+
+ return elem[ name ];
+ }
+
+ if ( !jQuery.support.style && notxml && name === "style" ) {
+ if ( set ) {
+ elem.style.cssText = "" + value;
+ }
+
+ return elem.style.cssText;
+ }
+
+ if ( set ) {
+ // convert the value to a string (all browsers do this but IE) see #1070
+ elem.setAttribute( name, "" + value );
+ }
+
+ var attr = !jQuery.support.hrefNormalized && notxml && special ?
+ // Some attributes require a special call on IE
+ elem.getAttribute( name, 2 ) :
+ elem.getAttribute( name );
+
+ // Non-existent attributes return null, we normalize to undefined
+ return attr === null ? undefined : attr;
+ }
+
+ // elem is actually elem.style ... set the style
+ // Using attr for specific style information is now deprecated. Use style insead.
+ return jQuery.style( elem, name, value );
+ }
+});
+var fcleanup = function( nm ) {
+ return nm.replace(/[^\w\s\.\|`]/g, function( ch ) {
+ return "\\" + ch;
+ });
+};
+
+/*
+ * A number of helper functions used for managing events.
+ * Many of the ideas behind this code originated from
+ * Dean Edwards' addEvent library.
+ */
+jQuery.event = {
+
+ // Bind an event to an element
+ // Original by Dean Edwards
+ add: function( elem, types, handler, data ) {
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ // For whatever reason, IE has trouble passing the window object
+ // around, causing it to be cloned in the process
+ if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) {
+ elem = window;
+ }
+
+ // Make sure that the function being executed has a unique ID
+ if ( !handler.guid ) {
+ handler.guid = jQuery.guid++;
+ }
+
+ // if data is passed, bind to handler
+ if ( data !== undefined ) {
+ // Create temporary function pointer to original handler
+ var fn = handler;
+
+ // Create unique handler function, wrapped around original handler
+ handler = jQuery.proxy( fn );
+
+ // Store data in unique handler
+ handler.data = data;
+ }
+
+ // Init the element's event structure
+ var events = jQuery.data( elem, "events" ) || jQuery.data( elem, "events", {} ),
+ handle = jQuery.data( elem, "handle" ), eventHandle;
+
+ if ( !handle ) {
+ eventHandle = function() {
+ // Handle the second event of a trigger and when
+ // an event is called after a page has unloaded
+ return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
+ jQuery.event.handle.apply( eventHandle.elem, arguments ) :
+ undefined;
+ };
+
+ handle = jQuery.data( elem, "handle", eventHandle );
+ }
+
+ // If no handle is found then we must be trying to bind to one of the
+ // banned noData elements
+ if ( !handle ) {
+ return;
+ }
+
+ // Add elem as a property of the handle function
+ // This is to prevent a memory leak with non-native
+ // event in IE.
+ handle.elem = elem;
+
+ // Handle multiple events separated by a space
+ // jQuery(...).bind("mouseover mouseout", fn);
+ types = types.split( /\s+/ );
+ var type, i=0;
+ while ( (type = types[ i++ ]) ) {
+ // Namespaced event handlers
+ var namespaces = type.split(".");
+ type = namespaces.shift();
+ handler.type = namespaces.slice(0).sort().join(".");
+
+ // Get the current list of functions bound to this event
+ var handlers = events[ type ],
+ special = this.special[ type ] || {};
+
+
+
+ // Init the event handler queue
+ if ( !handlers ) {
+ handlers = events[ type ] = {};
+
+ // Check for a special event handler
+ // Only use addEventListener/attachEvent if the special
+ // events handler returns false
+ if ( !special.setup || special.setup.call( elem, data, namespaces, handler) === false ) {
+ // Bind the global event handler to the element
+ if ( elem.addEventListener ) {
+ elem.addEventListener( type, handle, false );
+ } else if ( elem.attachEvent ) {
+ elem.attachEvent( "on" + type, handle );
+ }
+ }
+ }
+
+ if ( special.add ) {
+ var modifiedHandler = special.add.call( elem, handler, data, namespaces, handlers );
+ if ( modifiedHandler && jQuery.isFunction( modifiedHandler ) ) {
+ modifiedHandler.guid = modifiedHandler.guid || handler.guid;
+ handler = modifiedHandler;
+ }
+ }
+
+ // Add the function to the element's handler list
+ handlers[ handler.guid ] = handler;
+
+ // Keep track of which events have been used, for global triggering
+ this.global[ type ] = true;
+ }
+
+ // Nullify elem to prevent memory leaks in IE
+ elem = null;
+ },
+
+ global: {},
+
+ // Detach an event or set of events from an element
+ remove: function( elem, types, handler ) {
+ // don't do events on text and comment nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ var events = jQuery.data( elem, "events" ), ret, type, fn;
+
+ if ( events ) {
+ // Unbind all events for the element
+ if ( types === undefined || (typeof types === "string" && types.charAt(0) === ".") ) {
+ for ( type in events ) {
+ this.remove( elem, type + (types || "") );
+ }
+ } else {
+ // types is actually an event object here
+ if ( types.type ) {
+ handler = types.handler;
+ types = types.type;
+ }
+
+ // Handle multiple events separated by a space
+ // jQuery(...).unbind("mouseover mouseout", fn);
+ types = types.split(/\s+/);
+ var i = 0;
+ while ( (type = types[ i++ ]) ) {
+ // Namespaced event handlers
+ var namespaces = type.split(".");
+ type = namespaces.shift();
+ var all = !namespaces.length,
+ cleaned = jQuery.map( namespaces.slice(0).sort(), fcleanup ),
+ namespace = new RegExp("(^|\\.)" + cleaned.join("\\.(?:.*\\.)?") + "(\\.|$)"),
+ special = this.special[ type ] || {};
+
+ if ( events[ type ] ) {
+ // remove the given handler for the given type
+ if ( handler ) {
+ fn = events[ type ][ handler.guid ];
+ delete events[ type ][ handler.guid ];
+
+ // remove all handlers for the given type
+ } else {
+ for ( var handle in events[ type ] ) {
+ // Handle the removal of namespaced events
+ if ( all || namespace.test( events[ type ][ handle ].type ) ) {
+ delete events[ type ][ handle ];
+ }
+ }
+ }
+
+ if ( special.remove ) {
+ special.remove.call( elem, namespaces, fn);
+ }
+
+ // remove generic event handler if no more handlers exist
+ for ( ret in events[ type ] ) {
+ break;
+ }
+ if ( !ret ) {
+ if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
+ if ( elem.removeEventListener ) {
+ elem.removeEventListener( type, jQuery.data( elem, "handle" ), false );
+ } else if ( elem.detachEvent ) {
+ elem.detachEvent( "on" + type, jQuery.data( elem, "handle" ) );
+ }
+ }
+ ret = null;
+ delete events[ type ];
+ }
+ }
+ }
+ }
+
+ // Remove the expando if it's no longer used
+ for ( ret in events ) {
+ break;
+ }
+ if ( !ret ) {
+ var handle = jQuery.data( elem, "handle" );
+ if ( handle ) {
+ handle.elem = null;
+ }
+ jQuery.removeData( elem, "events" );
+ jQuery.removeData( elem, "handle" );
+ }
+ }
+ },
+
+ // bubbling is internal
+ trigger: function( event, data, elem /*, bubbling */ ) {
+ // Event object or event type
+ var type = event.type || event,
+ bubbling = arguments[3];
+
+ if ( !bubbling ) {
+ event = typeof event === "object" ?
+ // jQuery.Event object
+ event[expando] ? event :
+ // Object literal
+ jQuery.extend( jQuery.Event(type), event ) :
+ // Just the event type (string)
+ jQuery.Event(type);
+
+ if ( type.indexOf("!") >= 0 ) {
+ event.type = type = type.slice(0, -1);
+ event.exclusive = true;
+ }
+
+ // Handle a global trigger
+ if ( !elem ) {
+ // Don't bubble custom events when global (to avoid too much overhead)
+ event.stopPropagation();
+
+ // Only trigger if we've ever bound an event for it
+ if ( this.global[ type ] ) {
+ jQuery.each( jQuery.cache, function() {
+ if ( this.events && this.events[type] ) {
+ jQuery.event.trigger( event, data, this.handle.elem );
+ }
+ });
+ }
+ }
+
+ // Handle triggering a single element
+
+ // don't do events on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ // Clean up in case it is reused
+ event.result = undefined;
+ event.target = elem;
+
+ // Clone the incoming data, if any
+ data = jQuery.makeArray( data );
+ data.unshift( event );
+ }
+
+ event.currentTarget = elem;
+
+ // Trigger the event, it is assumed that "handle" is a function
+ var handle = jQuery.data( elem, "handle" );
+ if ( handle ) {
+ handle.apply( elem, data );
+ }
+
+ var nativeFn, nativeHandler;
+ try {
+ if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
+ nativeFn = elem[ type ];
+ nativeHandler = elem[ "on" + type ];
+ }
+ // prevent IE from throwing an error for some elements with some event types, see #3533
+ } catch (e) {}
+
+ var isClick = jQuery.nodeName(elem, "a") && type === "click";
+
+ // Trigger the native events (except for clicks on links)
+ if ( !bubbling && nativeFn && !event.isDefaultPrevented() && !isClick ) {
+ this.triggered = true;
+ try {
+ elem[ type ]();
+ // prevent IE from throwing an error for some hidden elements
+ } catch (e) {}
+
+ // Handle triggering native .onfoo handlers
+ } else if ( nativeHandler && elem[ "on" + type ].apply( elem, data ) === false ) {
+ event.result = false;
+ }
+
+ this.triggered = false;
+
+ if ( !event.isPropagationStopped() ) {
+ var parent = elem.parentNode || elem.ownerDocument;
+ if ( parent ) {
+ jQuery.event.trigger( event, data, parent, true );
+ }
+ }
+ },
+
+ handle: function( event ) {
+ // returned undefined or false
+ var all, handlers;
+
+ event = arguments[0] = jQuery.event.fix( event || window.event );
+ event.currentTarget = this;
+
+ // Namespaced event handlers
+ var namespaces = event.type.split(".");
+ event.type = namespaces.shift();
+
+ // Cache this now, all = true means, any handler
+ all = !namespaces.length && !event.exclusive;
+
+ var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)");
+
+ handlers = ( jQuery.data(this, "events") || {} )[ event.type ];
+
+ for ( var j in handlers ) {
+ var handler = handlers[ j ];
+
+ // Filter the functions by class
+ if ( all || namespace.test(handler.type) ) {
+ // Pass in a reference to the handler function itself
+ // So that we can later remove it
+ event.handler = handler;
+ event.data = handler.data;
+
+ var ret = handler.apply( this, arguments );
+
+ if ( ret !== undefined ) {
+ event.result = ret;
+ if ( ret === false ) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }
+
+ if ( event.isImmediatePropagationStopped() ) {
+ break;
+ }
+
+ }
+ }
+
+ return event.result;
+ },
+
+ props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
+
+ fix: function( event ) {
+ if ( event[ expando ] ) {
+ return event;
+ }
+
+ // store a copy of the original event object
+ // and "clone" to set read-only properties
+ var originalEvent = event;
+ event = jQuery.Event( originalEvent );
+
+ for ( var i = this.props.length, prop; i; ) {
+ prop = this.props[ --i ];
+ event[ prop ] = originalEvent[ prop ];
+ }
+
+ // Fix target property, if necessary
+ if ( !event.target ) {
+ event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
+ }
+
+ // check if target is a textnode (safari)
+ if ( event.target.nodeType === 3 ) {
+ event.target = event.target.parentNode;
+ }
+
+ // Add relatedTarget, if necessary
+ if ( !event.relatedTarget && event.fromElement ) {
+ event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
+ }
+
+ // Calculate pageX/Y if missing and clientX/Y available
+ if ( event.pageX == null && event.clientX != null ) {
+ var doc = document.documentElement, body = document.body;
+ event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
+ event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
+ }
+
+ // Add which for key events
+ if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) {
+ event.which = event.charCode || event.keyCode;
+ }
+
+ // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
+ if ( !event.metaKey && event.ctrlKey ) {
+ event.metaKey = event.ctrlKey;
+ }
+
+ // Add which for click: 1 === left; 2 === middle; 3 === right
+ // Note: button is not normalized, so don't use it
+ if ( !event.which && event.button !== undefined ) {
+ event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
+ }
+
+ return event;
+ },
+
+ // Deprecated, use jQuery.guid instead
+ guid: 1E8,
+
+ // Deprecated, use jQuery.proxy instead
+ proxy: jQuery.proxy,
+
+ special: {
+ ready: {
+ // Make sure the ready event is setup
+ setup: jQuery.bindReady,
+ teardown: jQuery.noop
+ },
+
+ live: {
+ add: function( proxy, data, namespaces, live ) {
+ jQuery.extend( proxy, data || {} );
+
+ proxy.guid += data.selector + data.live;
+ jQuery.event.add( this, data.live, liveHandler, data );
+
+ },
+
+ remove: function( namespaces ) {
+ if ( namespaces.length ) {
+ var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)");
+
+ jQuery.each( (jQuery.data(this, "events").live || {}), function() {
+ if ( name.test(this.type) ) {
+ remove++;
+ }
+ });
+
+ if ( remove < 1 ) {
+ jQuery.event.remove( this, namespaces[0], liveHandler );
+ }
+ }
+ },
+ special: {}
+ },
+ beforeunload: {
+ setup: function( data, namespaces, fn ) {
+ // We only want to do this special case on windows
+ if ( this.setInterval ) {
+ this.onbeforeunload = fn;
+ }
+
+ return false;
+ },
+ teardown: function( namespaces, fn ) {
+ if ( this.onbeforeunload === fn ) {
+ this.onbeforeunload = null;
+ }
+ }
+ }
+ }
+};
+
+jQuery.Event = function( src ) {
+ // Allow instantiation without the 'new' keyword
+ if ( !this.preventDefault ) {
+ return new jQuery.Event( src );
+ }
+
+ // Event object
+ if ( src && src.type ) {
+ this.originalEvent = src;
+ this.type = src.type;
+ // Event type
+ } else {
+ this.type = src;
+ }
+
+ // timeStamp is buggy for some events on Firefox(#3843)
+ // So we won't rely on the native value
+ this.timeStamp = now();
+
+ // Mark it as fixed
+ this[ expando ] = true;
+};
+
+function returnFalse() {
+ return false;
+}
+function returnTrue() {
+ return true;
+}
+
+// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
+// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
+jQuery.Event.prototype = {
+ preventDefault: function() {
+ this.isDefaultPrevented = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+
+ // if preventDefault exists run it on the original event
+ if ( e.preventDefault ) {
+ e.preventDefault();
+ }
+ // otherwise set the returnValue property of the original event to false (IE)
+ e.returnValue = false;
+ },
+ stopPropagation: function() {
+ this.isPropagationStopped = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+ // if stopPropagation exists run it on the original event
+ if ( e.stopPropagation ) {
+ e.stopPropagation();
+ }
+ // otherwise set the cancelBubble property of the original event to true (IE)
+ e.cancelBubble = true;
+ },
+ stopImmediatePropagation: function() {
+ this.isImmediatePropagationStopped = returnTrue;
+ this.stopPropagation();
+ },
+ isDefaultPrevented: returnFalse,
+ isPropagationStopped: returnFalse,
+ isImmediatePropagationStopped: returnFalse
+};
+
+// Checks if an event happened on an element within another element
+// Used in jQuery.event.special.mouseenter and mouseleave handlers
+var withinElement = function( event ) {
+ // Check if mouse(over|out) are still within the same parent element
+ var parent = event.relatedTarget;
+
+ // Traverse up the tree
+ while ( parent && parent !== this ) {
+ // Firefox sometimes assigns relatedTarget a XUL element
+ // which we cannot access the parentNode property of
+ try {
+ parent = parent.parentNode;
+
+ // assuming we've left the element since we most likely mousedover a xul element
+ } catch(e) {
+ break;
+ }
+ }
+
+ if ( parent !== this ) {
+ // set the correct event type
+ event.type = event.data;
+
+ // handle event if we actually just moused on to a non sub-element
+ jQuery.event.handle.apply( this, arguments );
+ }
+
+},
+
+// In case of event delegation, we only need to rename the event.type,
+// liveHandler will take care of the rest.
+delegate = function( event ) {
+ event.type = event.data;
+ jQuery.event.handle.apply( this, arguments );
+};
+
+// Create mouseenter and mouseleave events
+jQuery.each({
+ mouseenter: "mouseover",
+ mouseleave: "mouseout"
+}, function( orig, fix ) {
+ jQuery.event.special[ orig ] = {
+ setup: function( data ) {
+ jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
+ },
+ teardown: function( data ) {
+ jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
+ }
+ };
+});
+
+// submit delegation
+if ( !jQuery.support.submitBubbles ) {
+
+jQuery.event.special.submit = {
+ setup: function( data, namespaces, fn ) {
+ if ( this.nodeName.toLowerCase() !== "form" ) {
+ jQuery.event.add(this, "click.specialSubmit." + fn.guid, function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
+ return trigger( "submit", this, arguments );
+ }
+ });
+
+ jQuery.event.add(this, "keypress.specialSubmit." + fn.guid, function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
+ return trigger( "submit", this, arguments );
+ }
+ });
+
+ } else {
+ return false;
+ }
+ },
+
+ remove: function( namespaces, fn ) {
+ jQuery.event.remove( this, "click.specialSubmit" + (fn ? "."+fn.guid : "") );
+ jQuery.event.remove( this, "keypress.specialSubmit" + (fn ? "."+fn.guid : "") );
+ }
+};
+
+}
+
+// change delegation, happens here so we have bind.
+if ( !jQuery.support.changeBubbles ) {
+
+var formElems = /textarea|input|select/i;
+
+function getVal( elem ) {
+ var type = elem.type, val = elem.value;
+
+ if ( type === "radio" || type === "checkbox" ) {
+ val = elem.checked;
+
+ } else if ( type === "select-multiple" ) {
+ val = elem.selectedIndex > -1 ?
+ jQuery.map( elem.options, function( elem ) {
+ return elem.selected;
+ }).join("-") :
+ "";
+
+ } else if ( elem.nodeName.toLowerCase() === "select" ) {
+ val = elem.selectedIndex;
+ }
+
+ return val;
+}
+
+function testChange( e ) {
+ var elem = e.target, data, val;
+
+ if ( !formElems.test( elem.nodeName ) || elem.readOnly ) {
+ return;
+ }
+
+ data = jQuery.data( elem, "_change_data" );
+ val = getVal(elem);
+
+ if ( val === data ) {
+ return;
+ }
+
+ // the current data will be also retrieved by beforeactivate
+ if ( e.type !== "focusout" || elem.type !== "radio" ) {
+ jQuery.data( elem, "_change_data", val );
+ }
+
+ if ( elem.type !== "select" && (data != null || val) ) {
+ e.type = "change";
+ return jQuery.event.trigger( e, arguments[1], this );
+ }
+}
+
+jQuery.event.special.change = {
+ filters: {
+ focusout: testChange,
+
+ click: function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
+ return testChange.call( this, e );
+ }
+ },
+
+ // Change has to be called before submit
+ // Keydown will be called before keypress, which is used in submit-event delegation
+ keydown: function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
+ (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
+ type === "select-multiple" ) {
+ return testChange.call( this, e );
+ }
+ },
+
+ // Beforeactivate happens also before the previous element is blurred
+ // with this event you can't trigger a change event, but you can store
+ // information/focus[in] is not needed anymore
+ beforeactivate: function( e ) {
+ var elem = e.target;
+
+ if ( elem.nodeName.toLowerCase() === "input" && elem.type === "radio" ) {
+ jQuery.data( elem, "_change_data", getVal(elem) );
+ }
+ }
+ },
+ setup: function( data, namespaces, fn ) {
+ for ( var type in changeFilters ) {
+ jQuery.event.add( this, type + ".specialChange." + fn.guid, changeFilters[type] );
+ }
+
+ return formElems.test( this.nodeName );
+ },
+ remove: function( namespaces, fn ) {
+ for ( var type in changeFilters ) {
+ jQuery.event.remove( this, type + ".specialChange" + (fn ? "."+fn.guid : ""), changeFilters[type] );
+ }
+
+ return formElems.test( this.nodeName );
+ }
+};
+
+var changeFilters = jQuery.event.special.change.filters;
+
+}
+
+function trigger( type, elem, args ) {
+ args[0].type = type;
+ return jQuery.event.handle.apply( elem, args );
+}
+
+// Create "bubbling" focus and blur events
+if ( document.addEventListener ) {
+ jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
+ jQuery.event.special[ fix ] = {
+ setup: function() {
+ this.addEventListener( orig, handler, true );
+ },
+ teardown: function() {
+ this.removeEventListener( orig, handler, true );
+ }
+ };
+
+ function handler( e ) {
+ e = jQuery.event.fix( e );
+ e.type = fix;
+ return jQuery.event.handle.call( this, e );
+ }
+ });
+}
+
+jQuery.each(["bind", "one"], function( i, name ) {
+ jQuery.fn[ name ] = function( type, data, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" ) {
+ for ( var key in type ) {
+ this[ name ](key, data, type[key], fn);
+ }
+ return this;
+ }
+
+ if ( jQuery.isFunction( data ) ) {
+ thisObject = fn;
+ fn = data;
+ data = undefined;
+ }
+
+ var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
+ jQuery( this ).unbind( event, handler );
+ return fn.apply( this, arguments );
+ }) : fn;
+
+ return type === "unload" && name !== "one" ?
+ this.one( type, data, fn, thisObject ) :
+ this.each(function() {
+ jQuery.event.add( this, type, handler, data );
+ });
+ };
+});
+
+jQuery.fn.extend({
+ unbind: function( type, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" && !type.preventDefault ) {
+ for ( var key in type ) {
+ this.unbind(key, type[key]);
+ }
+ return this;
+ }
+
+ return this.each(function() {
+ jQuery.event.remove( this, type, fn );
+ });
+ },
+ trigger: function( type, data ) {
+ return this.each(function() {
+ jQuery.event.trigger( type, data, this );
+ });
+ },
+
+ triggerHandler: function( type, data ) {
+ if ( this[0] ) {
+ var event = jQuery.Event( type );
+ event.preventDefault();
+ event.stopPropagation();
+ jQuery.event.trigger( event, data, this[0] );
+ return event.result;
+ }
+ },
+
+ toggle: function( fn ) {
+ // Save reference to arguments for access in closure
+ var args = arguments, i = 1;
+
+ // link all the functions, so any of them can unbind this click handler
+ while ( i < args.length ) {
+ jQuery.proxy( fn, args[ i++ ] );
+ }
+
+ return this.click( jQuery.proxy( fn, function( event ) {
+ // Figure out which function to execute
+ var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
+ jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
+
+ // Make sure that clicks stop
+ event.preventDefault();
+
+ // and execute the function
+ return args[ lastToggle ].apply( this, arguments ) || false;
+ }));
+ },
+
+ hover: function( fnOver, fnOut ) {
+ return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
+ },
+
+ live: function( type, data, fn ) {
+ if ( jQuery.isFunction( data ) ) {
+ fn = data;
+ data = undefined;
+ }
+
+ jQuery( this.context ).bind( liveConvert( type, this.selector ), {
+ data: data, selector: this.selector, live: type
+ }, fn );
+
+ return this;
+ },
+
+ die: function( type, fn ) {
+ jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null );
+ return this;
+ }
+});
+
+function liveHandler( event ) {
+ var stop = true, elems = [], selectors = [], args = arguments,
+ related, match, fn, elem, j, i, data,
+ live = jQuery.extend({}, jQuery.data( this, "events" ).live);
+
+ for ( j in live ) {
+ fn = live[j];
+ if ( fn.live === event.type ||
+ fn.altLive && jQuery.inArray(event.type, fn.altLive) > -1 ) {
+
+ data = fn.data;
+ if ( !(data.beforeFilter && data.beforeFilter[event.type] &&
+ !data.beforeFilter[event.type](event)) ) {
+ selectors.push( fn.selector );
+ }
+ } else {
+ delete live[j];
+ }
+ }
+
+ match = jQuery( event.target ).closest( selectors, event.currentTarget );
+
+ for ( i = 0, l = match.length; i < l; i++ ) {
+ for ( j in live ) {
+ fn = live[j];
+ elem = match[i].elem;
+ related = null;
+
+ if ( match[i].selector === fn.selector ) {
+ // Those two events require additional checking
+ if ( fn.live === "mouseenter" || fn.live === "mouseleave" ) {
+ related = jQuery( event.relatedTarget ).closest( fn.selector )[0];
+ }
+
+ if ( !related || related !== elem ) {
+ elems.push({ elem: elem, fn: fn });
+ }
+ }
+ }
+ }
+
+ for ( i = 0, l = elems.length; i < l; i++ ) {
+ match = elems[i];
+ event.currentTarget = match.elem;
+ event.data = match.fn.data;
+ if ( match.fn.apply( match.elem, args ) === false ) {
+ stop = false;
+ break;
+ }
+ }
+
+ return stop;
+}
+
+function liveConvert( type, selector ) {
+ return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "&")].join(".");
+}
+
+jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
+ "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
+ "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
+
+ // Handle event binding
+ jQuery.fn[ name ] = function( fn ) {
+ return fn ? this.bind( name, fn ) : this.trigger( name );
+ };
+
+ if ( jQuery.attrFn ) {
+ jQuery.attrFn[ name ] = true;
+ }
+});
+
+// Prevent memory leaks in IE
+// Window isn't included so as not to unbind existing unload events
+// More info:
+// - http://isaacschlueter.com/2006/10/msie-memory-leaks/
+if ( window.attachEvent && !window.addEventListener ) {
+ window.attachEvent("onunload", function() {
+ for ( var id in jQuery.cache ) {
+ if ( jQuery.cache[ id ].handle ) {
+ // Try/Catch is to handle iframes being unloaded, see #4280
+ try {
+ jQuery.event.remove( jQuery.cache[ id ].handle.elem );
+ } catch(e) {}
+ }
+ }
+ });
+}
+/*!
+ * Sizzle CSS Selector Engine - v1.0
+ * Copyright 2009, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ * More information: http://sizzlejs.com/
+ */
+(function(){
+
+var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
+ done = 0,
+ toString = Object.prototype.toString,
+ hasDuplicate = false,
+ baseHasDuplicate = true;
+
+// Here we check if the JavaScript engine is using some sort of
+// optimization where it does not always call our comparision
+// function. If that is the case, discard the hasDuplicate value.
+// Thus far that includes Google Chrome.
+[0, 0].sort(function(){
+ baseHasDuplicate = false;
+ return 0;
+});
+
+var Sizzle = function(selector, context, results, seed) {
+ results = results || [];
+ var origContext = context = context || document;
+
+ if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
+ return [];
+ }
+
+ if ( !selector || typeof selector !== "string" ) {
+ return results;
+ }
+
+ var parts = [], m, set, checkSet, extra, prune = true, contextXML = isXML(context),
+ soFar = selector;
+
+ // Reset the position of the chunker regexp (start from head)
+ while ( (chunker.exec(""), m = chunker.exec(soFar)) !== null ) {
+ soFar = m[3];
+
+ parts.push( m[1] );
+
+ if ( m[2] ) {
+ extra = m[3];
+ break;
+ }
+ }
+
+ if ( parts.length > 1 && origPOS.exec( selector ) ) {
+ if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
+ set = posProcess( parts[0] + parts[1], context );
+ } else {
+ set = Expr.relative[ parts[0] ] ?
+ [ context ] :
+ Sizzle( parts.shift(), context );
+
+ while ( parts.length ) {
+ selector = parts.shift();
+
+ if ( Expr.relative[ selector ] ) {
+ selector += parts.shift();
+ }
+
+ set = posProcess( selector, set );
+ }
+ }
+ } else {
+ // Take a shortcut and set the context if the root selector is an ID
+ // (but not if it'll be faster if the inner selector is an ID)
+ if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
+ Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
+ var ret = Sizzle.find( parts.shift(), context, contextXML );
+ context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];
+ }
+
+ if ( context ) {
+ var ret = seed ?
+ { expr: parts.pop(), set: makeArray(seed) } :
+ Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
+ set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set;
+
+ if ( parts.length > 0 ) {
+ checkSet = makeArray(set);
+ } else {
+ prune = false;
+ }
+
+ while ( parts.length ) {
+ var cur = parts.pop(), pop = cur;
+
+ if ( !Expr.relative[ cur ] ) {
+ cur = "";
+ } else {
+ pop = parts.pop();
+ }
+
+ if ( pop == null ) {
+ pop = context;
+ }
+
+ Expr.relative[ cur ]( checkSet, pop, contextXML );
+ }
+ } else {
+ checkSet = parts = [];
+ }
+ }
+
+ if ( !checkSet ) {
+ checkSet = set;
+ }
+
+ if ( !checkSet ) {
+ throw "Syntax error, unrecognized expression: " + (cur || selector);
+ }
+
+ if ( toString.call(checkSet) === "[object Array]" ) {
+ if ( !prune ) {
+ results.push.apply( results, checkSet );
+ } else if ( context && context.nodeType === 1 ) {
+ for ( var i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {
+ results.push( set[i] );
+ }
+ }
+ } else {
+ for ( var i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
+ results.push( set[i] );
+ }
+ }
+ }
+ } else {
+ makeArray( checkSet, results );
+ }
+
+ if ( extra ) {
+ Sizzle( extra, origContext, results, seed );
+ Sizzle.uniqueSort( results );
+ }
+
+ return results;
+};
+
+Sizzle.uniqueSort = function(results){
+ if ( sortOrder ) {
+ hasDuplicate = baseHasDuplicate;
+ results.sort(sortOrder);
+
+ if ( hasDuplicate ) {
+ for ( var i = 1; i < results.length; i++ ) {
+ if ( results[i] === results[i-1] ) {
+ results.splice(i--, 1);
+ }
+ }
+ }
+ }
+
+ return results;
+};
+
+Sizzle.matches = function(expr, set){
+ return Sizzle(expr, null, null, set);
+};
+
+Sizzle.find = function(expr, context, isXML){
+ var set, match;
+
+ if ( !expr ) {
+ return [];
+ }
+
+ for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
+ var type = Expr.order[i], match;
+
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
+ var left = match[1];
+ match.splice(1,1);
+
+ if ( left.substr( left.length - 1 ) !== "\\" ) {
+ match[1] = (match[1] || "").replace(/\\/g, "");
+ set = Expr.find[ type ]( match, context, isXML );
+ if ( set != null ) {
+ expr = expr.replace( Expr.match[ type ], "" );
+ break;
+ }
+ }
+ }
+ }
+
+ if ( !set ) {
+ set = context.getElementsByTagName("*");
+ }
+
+ return {set: set, expr: expr};
+};
+
+Sizzle.filter = function(expr, set, inplace, not){
+ var old = expr, result = [], curLoop = set, match, anyFound,
+ isXMLFilter = set && set[0] && isXML(set[0]);
+
+ while ( expr && set.length ) {
+ for ( var type in Expr.filter ) {
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
+ var filter = Expr.filter[ type ], found, item, left = match[1];
+ anyFound = false;
+
+ match.splice(1,1);
+
+ if ( left.substr( left.length - 1 ) === "\\" ) {
+ continue;
+ }
+
+ if ( curLoop === result ) {
+ result = [];
+ }
+
+ if ( Expr.preFilter[ type ] ) {
+ match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
+
+ if ( !match ) {
+ anyFound = found = true;
+ } else if ( match === true ) {
+ continue;
+ }
+ }
+
+ if ( match ) {
+ for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
+ if ( item ) {
+ found = filter( item, match, i, curLoop );
+ var pass = not ^ !!found;
+
+ if ( inplace && found != null ) {
+ if ( pass ) {
+ anyFound = true;
+ } else {
+ curLoop[i] = false;
+ }
+ } else if ( pass ) {
+ result.push( item );
+ anyFound = true;
+ }
+ }
+ }
+ }
+
+ if ( found !== undefined ) {
+ if ( !inplace ) {
+ curLoop = result;
+ }
+
+ expr = expr.replace( Expr.match[ type ], "" );
+
+ if ( !anyFound ) {
+ return [];
+ }
+
+ break;
+ }
+ }
+ }
+
+ // Improper expression
+ if ( expr === old ) {
+ if ( anyFound == null ) {
+ throw "Syntax error, unrecognized expression: " + expr;
+ } else {
+ break;
+ }
+ }
+
+ old = expr;
+ }
+
+ return curLoop;
+};
+
+var Expr = Sizzle.selectors = {
+ order: [ "ID", "NAME", "TAG" ],
+ match: {
+ ID: /#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
+ CLASS: /\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
+ NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,
+ ATTR: /\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
+ TAG: /^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,
+ CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
+ POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
+ PSEUDO: /:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
+ },
+ leftMatch: {},
+ attrMap: {
+ "class": "className",
+ "for": "htmlFor"
+ },
+ attrHandle: {
+ href: function(elem){
+ return elem.getAttribute("href");
+ }
+ },
+ relative: {
+ "+": function(checkSet, part){
+ var isPartStr = typeof part === "string",
+ isTag = isPartStr && !/\W/.test(part),
+ isPartStrNotTag = isPartStr && !isTag;
+
+ if ( isTag ) {
+ part = part.toLowerCase();
+ }
+
+ for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
+ if ( (elem = checkSet[i]) ) {
+ while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
+
+ checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
+ elem || false :
+ elem === part;
+ }
+ }
+
+ if ( isPartStrNotTag ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ },
+ ">": function(checkSet, part){
+ var isPartStr = typeof part === "string";
+
+ if ( isPartStr && !/\W/.test(part) ) {
+ part = part.toLowerCase();
+
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ var parent = elem.parentNode;
+ checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
+ }
+ }
+ } else {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ checkSet[i] = isPartStr ?
+ elem.parentNode :
+ elem.parentNode === part;
+ }
+ }
+
+ if ( isPartStr ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ }
+ },
+ "": function(checkSet, part, isXML){
+ var doneName = done++, checkFn = dirCheck;
+
+ if ( typeof part === "string" && !/\W/.test(part) ) {
+ var nodeCheck = part = part.toLowerCase();
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
+ },
+ "~": function(checkSet, part, isXML){
+ var doneName = done++, checkFn = dirCheck;
+
+ if ( typeof part === "string" && !/\W/.test(part) ) {
+ var nodeCheck = part = part.toLowerCase();
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);
+ }
+ },
+ find: {
+ ID: function(match, context, isXML){
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+ return m ? [m] : [];
+ }
+ },
+ NAME: function(match, context){
+ if ( typeof context.getElementsByName !== "undefined" ) {
+ var ret = [], results = context.getElementsByName(match[1]);
+
+ for ( var i = 0, l = results.length; i < l; i++ ) {
+ if ( results[i].getAttribute("name") === match[1] ) {
+ ret.push( results[i] );
+ }
+ }
+
+ return ret.length === 0 ? null : ret;
+ }
+ },
+ TAG: function(match, context){
+ return context.getElementsByTagName(match[1]);
+ }
+ },
+ preFilter: {
+ CLASS: function(match, curLoop, inplace, result, not, isXML){
+ match = " " + match[1].replace(/\\/g, "") + " ";
+
+ if ( isXML ) {
+ return match;
+ }
+
+ for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
+ if ( elem ) {
+ if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) {
+ if ( !inplace ) {
+ result.push( elem );
+ }
+ } else if ( inplace ) {
+ curLoop[i] = false;
+ }
+ }
+ }
+
+ return false;
+ },
+ ID: function(match){
+ return match[1].replace(/\\/g, "");
+ },
+ TAG: function(match, curLoop){
+ return match[1].toLowerCase();
+ },
+ CHILD: function(match){
+ if ( match[1] === "nth" ) {
+ // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
+ var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
+ match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
+ !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
+
+ // calculate the numbers (first)n+(last) including if they are negative
+ match[2] = (test[1] + (test[2] || 1)) - 0;
+ match[3] = test[3] - 0;
+ }
+
+ // TODO: Move to normal caching system
+ match[0] = done++;
+
+ return match;
+ },
+ ATTR: function(match, curLoop, inplace, result, not, isXML){
+ var name = match[1].replace(/\\/g, "");
+
+ if ( !isXML && Expr.attrMap[name] ) {
+ match[1] = Expr.attrMap[name];
+ }
+
+ if ( match[2] === "~=" ) {
+ match[4] = " " + match[4] + " ";
+ }
+
+ return match;
+ },
+ PSEUDO: function(match, curLoop, inplace, result, not){
+ if ( match[1] === "not" ) {
+ // If we're dealing with a complex expression, or a simple one
+ if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
+ match[3] = Sizzle(match[3], null, null, curLoop);
+ } else {
+ var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
+ if ( !inplace ) {
+ result.push.apply( result, ret );
+ }
+ return false;
+ }
+ } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
+ return true;
+ }
+
+ return match;
+ },
+ POS: function(match){
+ match.unshift( true );
+ return match;
+ }
+ },
+ filters: {
+ enabled: function(elem){
+ return elem.disabled === false && elem.type !== "hidden";
+ },
+ disabled: function(elem){
+ return elem.disabled === true;
+ },
+ checked: function(elem){
+ return elem.checked === true;
+ },
+ selected: function(elem){
+ // Accessing this property makes selected-by-default
+ // options in Safari work properly
+ elem.parentNode.selectedIndex;
+ return elem.selected === true;
+ },
+ parent: function(elem){
+ return !!elem.firstChild;
+ },
+ empty: function(elem){
+ return !elem.firstChild;
+ },
+ has: function(elem, i, match){
+ return !!Sizzle( match[3], elem ).length;
+ },
+ header: function(elem){
+ return /h\d/i.test( elem.nodeName );
+ },
+ text: function(elem){
+ return "text" === elem.type;
+ },
+ radio: function(elem){
+ return "radio" === elem.type;
+ },
+ checkbox: function(elem){
+ return "checkbox" === elem.type;
+ },
+ file: function(elem){
+ return "file" === elem.type;
+ },
+ password: function(elem){
+ return "password" === elem.type;
+ },
+ submit: function(elem){
+ return "submit" === elem.type;
+ },
+ image: function(elem){
+ return "image" === elem.type;
+ },
+ reset: function(elem){
+ return "reset" === elem.type;
+ },
+ button: function(elem){
+ return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
+ },
+ input: function(elem){
+ return /input|select|textarea|button/i.test(elem.nodeName);
+ }
+ },
+ setFilters: {
+ first: function(elem, i){
+ return i === 0;
+ },
+ last: function(elem, i, match, array){
+ return i === array.length - 1;
+ },
+ even: function(elem, i){
+ return i % 2 === 0;
+ },
+ odd: function(elem, i){
+ return i % 2 === 1;
+ },
+ lt: function(elem, i, match){
+ return i < match[3] - 0;
+ },
+ gt: function(elem, i, match){
+ return i > match[3] - 0;
+ },
+ nth: function(elem, i, match){
+ return match[3] - 0 === i;
+ },
+ eq: function(elem, i, match){
+ return match[3] - 0 === i;
+ }
+ },
+ filter: {
+ PSEUDO: function(elem, match, i, array){
+ var name = match[1], filter = Expr.filters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+ } else if ( name === "contains" ) {
+ return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
+ } else if ( name === "not" ) {
+ var not = match[3];
+
+ for ( var i = 0, l = not.length; i < l; i++ ) {
+ if ( not[i] === elem ) {
+ return false;
+ }
+ }
+
+ return true;
+ } else {
+ throw "Syntax error, unrecognized expression: " + name;
+ }
+ },
+ CHILD: function(elem, match){
+ var type = match[1], node = elem;
+ switch (type) {
+ case 'only':
+ case 'first':
+ while ( (node = node.previousSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+ if ( type === "first" ) {
+ return true;
+ }
+ node = elem;
+ case 'last':
+ while ( (node = node.nextSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+ return true;
+ case 'nth':
+ var first = match[2], last = match[3];
+
+ if ( first === 1 && last === 0 ) {
+ return true;
+ }
+
+ var doneName = match[0],
+ parent = elem.parentNode;
+
+ if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
+ var count = 0;
+ for ( node = parent.firstChild; node; node = node.nextSibling ) {
+ if ( node.nodeType === 1 ) {
+ node.nodeIndex = ++count;
+ }
+ }
+ parent.sizcache = doneName;
+ }
+
+ var diff = elem.nodeIndex - last;
+ if ( first === 0 ) {
+ return diff === 0;
+ } else {
+ return ( diff % first === 0 && diff / first >= 0 );
+ }
+ }
+ },
+ ID: function(elem, match){
+ return elem.nodeType === 1 && elem.getAttribute("id") === match;
+ },
+ TAG: function(elem, match){
+ return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
+ },
+ CLASS: function(elem, match){
+ return (" " + (elem.className || elem.getAttribute("class")) + " ")
+ .indexOf( match ) > -1;
+ },
+ ATTR: function(elem, match){
+ var name = match[1],
+ result = Expr.attrHandle[ name ] ?
+ Expr.attrHandle[ name ]( elem ) :
+ elem[ name ] != null ?
+ elem[ name ] :
+ elem.getAttribute( name ),
+ value = result + "",
+ type = match[2],
+ check = match[4];
+
+ return result == null ?
+ type === "!=" :
+ type === "=" ?
+ value === check :
+ type === "*=" ?
+ value.indexOf(check) >= 0 :
+ type === "~=" ?
+ (" " + value + " ").indexOf(check) >= 0 :
+ !check ?
+ value && result !== false :
+ type === "!=" ?
+ value !== check :
+ type === "^=" ?
+ value.indexOf(check) === 0 :
+ type === "$=" ?
+ value.substr(value.length - check.length) === check :
+ type === "|=" ?
+ value === check || value.substr(0, check.length + 1) === check + "-" :
+ false;
+ },
+ POS: function(elem, match, i, array){
+ var name = match[2], filter = Expr.setFilters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+ }
+ }
+ }
+};
+
+var origPOS = Expr.match.POS;
+
+for ( var type in Expr.match ) {
+ Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source );
+ Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, function(all, num){
+ return "\\" + (num - 0 + 1);
+ }));
+}
+
+var makeArray = function(array, results) {
+ array = Array.prototype.slice.call( array, 0 );
+
+ if ( results ) {
+ results.push.apply( results, array );
+ return results;
+ }
+
+ return array;
+};
+
+// Perform a simple check to determine if the browser is capable of
+// converting a NodeList to an array using builtin methods.
+try {
+ Array.prototype.slice.call( document.documentElement.childNodes, 0 );
+
+// Provide a fallback method if it does not work
+} catch(e){
+ makeArray = function(array, results) {
+ var ret = results || [];
+
+ if ( toString.call(array) === "[object Array]" ) {
+ Array.prototype.push.apply( ret, array );
+ } else {
+ if ( typeof array.length === "number" ) {
+ for ( var i = 0, l = array.length; i < l; i++ ) {
+ ret.push( array[i] );
+ }
+ } else {
+ for ( var i = 0; array[i]; i++ ) {
+ ret.push( array[i] );
+ }
+ }
+ }
+
+ return ret;
+ };
+}
+
+var sortOrder;
+
+if ( document.documentElement.compareDocumentPosition ) {
+ sortOrder = function( a, b ) {
+ if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.compareDocumentPosition ? -1 : 1;
+ }
+
+ var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+} else if ( "sourceIndex" in document.documentElement ) {
+ sortOrder = function( a, b ) {
+ if ( !a.sourceIndex || !b.sourceIndex ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.sourceIndex ? -1 : 1;
+ }
+
+ var ret = a.sourceIndex - b.sourceIndex;
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+} else if ( document.createRange ) {
+ sortOrder = function( a, b ) {
+ if ( !a.ownerDocument || !b.ownerDocument ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.ownerDocument ? -1 : 1;
+ }
+
+ var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();
+ aRange.setStart(a, 0);
+ aRange.setEnd(a, 0);
+ bRange.setStart(b, 0);
+ bRange.setEnd(b, 0);
+ var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange);
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+}
+
+// Utility function for retreiving the text value of an array of DOM nodes
+function getText( elems ) {
+ var ret = "", elem;
+
+ for ( var i = 0; elems[i]; i++ ) {
+ elem = elems[i];
+
+ // Get the text from text nodes and CDATA nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
+ ret += elem.nodeValue;
+
+ // Traverse everything else, except comment nodes
+ } else if ( elem.nodeType !== 8 ) {
+ ret += getText( elem.childNodes );
+ }
+ }
+
+ return ret;
+}
+
+// Check to see if the browser returns elements by name when
+// querying by getElementById (and provide a workaround)
+(function(){
+ // We're going to inject a fake input element with a specified name
+ var form = document.createElement("div"),
+ id = "script" + (new Date).getTime();
+ form.innerHTML = "<a name='" + id + "'/>";
+
+ // Inject it into the root element, check its status, and remove it quickly
+ var root = document.documentElement;
+ root.insertBefore( form, root.firstChild );
+
+ // The workaround has to do additional checks after a getElementById
+ // Which slows things down for other browsers (hence the branching)
+ if ( document.getElementById( id ) ) {
+ Expr.find.ID = function(match, context, isXML){
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+ return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
+ }
+ };
+
+ Expr.filter.ID = function(elem, match){
+ var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
+ return elem.nodeType === 1 && node && node.nodeValue === match;
+ };
+ }
+
+ root.removeChild( form );
+ root = form = null; // release memory in IE
+})();
+
+(function(){
+ // Check to see if the browser returns only elements
+ // when doing getElementsByTagName("*")
+
+ // Create a fake element
+ var div = document.createElement("div");
+ div.appendChild( document.createComment("") );
+
+ // Make sure no comments are found
+ if ( div.getElementsByTagName("*").length > 0 ) {
+ Expr.find.TAG = function(match, context){
+ var results = context.getElementsByTagName(match[1]);
+
+ // Filter out possible comments
+ if ( match[1] === "*" ) {
+ var tmp = [];
+
+ for ( var i = 0; results[i]; i++ ) {
+ if ( results[i].nodeType === 1 ) {
+ tmp.push( results[i] );
+ }
+ }
+
+ results = tmp;
+ }
+
+ return results;
+ };
+ }
+
+ // Check to see if an attribute returns normalized href attributes
+ div.innerHTML = "<a href='#'></a>";
+ if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
+ div.firstChild.getAttribute("href") !== "#" ) {
+ Expr.attrHandle.href = function(elem){
+ return elem.getAttribute("href", 2);
+ };
+ }
+
+ div = null; // release memory in IE
+})();
+
+if ( document.querySelectorAll ) {
+ (function(){
+ var oldSizzle = Sizzle, div = document.createElement("div");
+ div.innerHTML = "<p class='TEST'></p>";
+
+ // Safari can't handle uppercase or unicode characters when
+ // in quirks mode.
+ if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
+ return;
+ }
+
+ Sizzle = function(query, context, extra, seed){
+ context = context || document;
+
+ // Only use querySelectorAll on non-XML documents
+ // (ID selectors don't work in non-HTML documents)
+ if ( !seed && context.nodeType === 9 && !isXML(context) ) {
+ try {
+ return makeArray( context.querySelectorAll(query), extra );
+ } catch(e){}
+ }
+
+ return oldSizzle(query, context, extra, seed);
+ };
+
+ for ( var prop in oldSizzle ) {
+ Sizzle[ prop ] = oldSizzle[ prop ];
+ }
+
+ div = null; // release memory in IE
+ })();
+}
+
+(function(){
+ var div = document.createElement("div");
+
+ div.innerHTML = "<div class='test e'></div><div class='test'></div>";
+
+ // Opera can't find a second classname (in 9.6)
+ // Also, make sure that getElementsByClassName actually exists
+ if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
+ return;
+ }
+
+ // Safari caches class attributes, doesn't catch changes (in 3.2)
+ div.lastChild.className = "e";
+
+ if ( div.getElementsByClassName("e").length === 1 ) {
+ return;
+ }
+
+ Expr.order.splice(1, 0, "CLASS");
+ Expr.find.CLASS = function(match, context, isXML) {
+ if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
+ return context.getElementsByClassName(match[1]);
+ }
+ };
+
+ div = null; // release memory in IE
+})();
+
+function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ elem = elem[dir];
+ var match = false;
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 && !isXML ){
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+
+ if ( elem.nodeName.toLowerCase() === cur ) {
+ match = elem;
+ break;
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ elem = elem[dir];
+ var match = false;
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 ) {
+ if ( !isXML ) {
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+ if ( typeof cur !== "string" ) {
+ if ( elem === cur ) {
+ match = true;
+ break;
+ }
+
+ } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
+ match = elem;
+ break;
+ }
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+var contains = document.compareDocumentPosition ? function(a, b){
+ return a.compareDocumentPosition(b) & 16;
+} : function(a, b){
+ return a !== b && (a.contains ? a.contains(b) : true);
+};
+
+var isXML = function(elem){
+ // documentElement is verified for cases where it doesn't yet exist
+ // (such as loading iframes in IE - #4833)
+ var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
+ return documentElement ? documentElement.nodeName !== "HTML" : false;
+};
+
+var posProcess = function(selector, context){
+ var tmpSet = [], later = "", match,
+ root = context.nodeType ? [context] : context;
+
+ // Position selectors must be done after the filter
+ // And so must :not(positional) so we move all PSEUDOs to the end
+ while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
+ later += match[0];
+ selector = selector.replace( Expr.match.PSEUDO, "" );
+ }
+
+ selector = Expr.relative[selector] ? selector + "*" : selector;
+
+ for ( var i = 0, l = root.length; i < l; i++ ) {
+ Sizzle( selector, root[i], tmpSet );
+ }
+
+ return Sizzle.filter( later, tmpSet );
+};
+
+// EXPOSE
+jQuery.find = Sizzle;
+jQuery.expr = Sizzle.selectors;
+jQuery.expr[":"] = jQuery.expr.filters;
+jQuery.unique = Sizzle.uniqueSort;
+jQuery.getText = getText;
+jQuery.isXMLDoc = isXML;
+jQuery.contains = contains;
+
+return;
+
+window.Sizzle = Sizzle;
+
+})();
+var runtil = /Until$/,
+ rparentsprev = /^(?:parents|prevUntil|prevAll)/,
+ // Note: This RegExp should be improved, or likely pulled from Sizzle
+ rmultiselector = /,/,
+ slice = Array.prototype.slice;
+
+// Implement the identical functionality for filter and not
+var winnow = function( elements, qualifier, keep ) {
+ if ( jQuery.isFunction( qualifier ) ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ return !!qualifier.call( elem, i, elem ) === keep;
+ });
+
+ } else if ( qualifier.nodeType ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ return (elem === qualifier) === keep;
+ });
+
+ } else if ( typeof qualifier === "string" ) {
+ var filtered = jQuery.grep(elements, function( elem ) {
+ return elem.nodeType === 1;
+ });
+
+ if ( isSimple.test( qualifier ) ) {
+ return jQuery.filter(qualifier, filtered, !keep);
+ } else {
+ qualifier = jQuery.filter( qualifier, elements );
+ }
+ }
+
+ return jQuery.grep(elements, function( elem, i ) {
+ return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
+ });
+};
+
+jQuery.fn.extend({
+ find: function( selector ) {
+ var ret = this.pushStack( "", "find", selector ), length = 0;
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ length = ret.length;
+ jQuery.find( selector, this[i], ret );
+
+ if ( i > 0 ) {
+ // Make sure that the results are unique
+ for ( var n = length; n < ret.length; n++ ) {
+ for ( var r = 0; r < length; r++ ) {
+ if ( ret[r] === ret[n] ) {
+ ret.splice(n--, 1);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return ret;
+ },
+
+ has: function( target ) {
+ var targets = jQuery( target );
+ return this.filter(function() {
+ for ( var i = 0, l = targets.length; i < l; i++ ) {
+ if ( jQuery.contains( this, targets[i] ) ) {
+ return true;
+ }
+ }
+ });
+ },
+
+ not: function( selector ) {
+ return this.pushStack( winnow(this, selector, false), "not", selector);
+ },
+
+ filter: function( selector ) {
+ return this.pushStack( winnow(this, selector, true), "filter", selector );
+ },
+
+ is: function( selector ) {
+ return !!selector && jQuery.filter( selector, this ).length > 0;
+ },
+
+ closest: function( selectors, context ) {
+ if ( jQuery.isArray( selectors ) ) {
+ var ret = [], cur = this[0], match, matches = {}, selector;
+
+ if ( cur && selectors.length ) {
+ for ( var i = 0, l = selectors.length; i < l; i++ ) {
+ selector = selectors[i];
+
+ if ( !matches[selector] ) {
+ matches[selector] = jQuery.expr.match.POS.test( selector ) ?
+ jQuery( selector, context || this.context ) :
+ selector;
+ }
+ }
+
+ while ( cur && cur.ownerDocument && cur !== context ) {
+ for ( selector in matches ) {
+ match = matches[selector];
+
+ if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) {
+ ret.push({ selector: selector, elem: cur });
+ delete matches[selector];
+ }
+ }
+ cur = cur.parentNode;
+ }
+ }
+
+ return ret;
+ }
+
+ var pos = jQuery.expr.match.POS.test( selectors ) ?
+ jQuery( selectors, context || this.context ) : null;
+
+ return this.map(function( i, cur ) {
+ while ( cur && cur.ownerDocument && cur !== context ) {
+ if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selectors) ) {
+ return cur;
+ }
+ cur = cur.parentNode;
+ }
+ return null;
+ });
+ },
+
+ // Determine the position of an element within
+ // the matched set of elements
+ index: function( elem ) {
+ if ( !elem || typeof elem === "string" ) {
+ return jQuery.inArray( this[0],
+ // If it receives a string, the selector is used
+ // If it receives nothing, the siblings are used
+ elem ? jQuery( elem ) : this.parent().children() );
+ }
+ // Locate the position of the desired element
+ return jQuery.inArray(
+ // If it receives a jQuery object, the first element is used
+ elem.jquery ? elem[0] : elem, this );
+ },
+
+ add: function( selector, context ) {
+ var set = typeof selector === "string" ?
+ jQuery( selector, context || this.context ) :
+ jQuery.makeArray( selector ),
+ all = jQuery.merge( this.get(), set );
+
+ return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
+ all :
+ jQuery.unique( all ) );
+ },
+
+ andSelf: function() {
+ return this.add( this.prevObject );
+ }
+});
+
+// A painfully simple check to see if an element is disconnected
+// from a document (should be improved, where feasible).
+function isDisconnected( node ) {
+ return !node || !node.parentNode || node.parentNode.nodeType === 11;
+}
+
+jQuery.each({
+ parent: function( elem ) {
+ var parent = elem.parentNode;
+ return parent && parent.nodeType !== 11 ? parent : null;
+ },
+ parents: function( elem ) {
+ return jQuery.dir( elem, "parentNode" );
+ },
+ parentsUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "parentNode", until );
+ },
+ next: function( elem ) {
+ return jQuery.nth( elem, 2, "nextSibling" );
+ },
+ prev: function( elem ) {
+ return jQuery.nth( elem, 2, "previousSibling" );
+ },
+ nextAll: function( elem ) {
+ return jQuery.dir( elem, "nextSibling" );
+ },
+ prevAll: function( elem ) {
+ return jQuery.dir( elem, "previousSibling" );
+ },
+ nextUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "nextSibling", until );
+ },
+ prevUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "previousSibling", until );
+ },
+ siblings: function( elem ) {
+ return jQuery.sibling( elem.parentNode.firstChild, elem );
+ },
+ children: function( elem ) {
+ return jQuery.sibling( elem.firstChild );
+ },
+ contents: function( elem ) {
+ return jQuery.nodeName( elem, "iframe" ) ?
+ elem.contentDocument || elem.contentWindow.document :
+ jQuery.makeArray( elem.childNodes );
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function( until, selector ) {
+ var ret = jQuery.map( this, fn, until );
+
+ if ( !runtil.test( name ) ) {
+ selector = until;
+ }
+
+ if ( selector && typeof selector === "string" ) {
+ ret = jQuery.filter( selector, ret );
+ }
+
+ ret = this.length > 1 ? jQuery.unique( ret ) : ret;
+
+ if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
+ ret = ret.reverse();
+ }
+
+ return this.pushStack( ret, name, slice.call(arguments).join(",") );
+ };
+});
+
+jQuery.extend({
+ filter: function( expr, elems, not ) {
+ if ( not ) {
+ expr = ":not(" + expr + ")";
+ }
+
+ return jQuery.find.matches(expr, elems);
+ },
+
+ dir: function( elem, dir, until ) {
+ var matched = [], cur = elem[dir];
+ while ( cur && cur.nodeType !== 9 && (until === undefined || !jQuery( cur ).is( until )) ) {
+ if ( cur.nodeType === 1 ) {
+ matched.push( cur );
+ }
+ cur = cur[dir];
+ }
+ return matched;
+ },
+
+ nth: function( cur, result, dir, elem ) {
+ result = result || 1;
+ var num = 0;
+
+ for ( ; cur; cur = cur[dir] ) {
+ if ( cur.nodeType === 1 && ++num === result ) {
+ break;
+ }
+ }
+
+ return cur;
+ },
+
+ sibling: function( n, elem ) {
+ var r = [];
+
+ for ( ; n; n = n.nextSibling ) {
+ if ( n.nodeType === 1 && n !== elem ) {
+ r.push( n );
+ }
+ }
+
+ return r;
+ }
+});
+var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
+ rleadingWhitespace = /^\s+/,
+ rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g,
+ rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,
+ rtagName = /<([\w:]+)/,
+ rtbody = /<tbody/i,
+ rhtml = /<|&\w+;/,
+ fcloseTag = function( all, front, tag ) {
+ return rselfClosing.test( tag ) ?
+ all :
+ front + "></" + tag + ">";
+ },
+ wrapMap = {
+ option: [ 1, "<select multiple='multiple'>", "</select>" ],
+ legend: [ 1, "<fieldset>", "</fieldset>" ],
+ thead: [ 1, "<table>", "</table>" ],
+ tr: [ 2, "<table><tbody>", "</tbody></table>" ],
+ td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
+ col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
+ area: [ 1, "<map>", "</map>" ],
+ _default: [ 0, "", "" ]
+ };
+
+wrapMap.optgroup = wrapMap.option;
+wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
+wrapMap.th = wrapMap.td;
+
+// IE can't serialize <link> and <script> tags normally
+if ( !jQuery.support.htmlSerialize ) {
+ wrapMap._default = [ 1, "div<div>", "</div>" ];
+}
+
+jQuery.fn.extend({
+ text: function( text ) {
+ if ( jQuery.isFunction(text) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ return self.text( text.call(this, i, self.text()) );
+ });
+ }
+
+ if ( typeof text !== "object" && text !== undefined ) {
+ return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
+ }
+
+ return jQuery.getText( this );
+ },
+
+ wrapAll: function( html ) {
+ if ( jQuery.isFunction( html ) ) {
+ return this.each(function(i) {
+ jQuery(this).wrapAll( html.call(this, i) );
+ });
+ }
+
+ if ( this[0] ) {
+ // The elements to wrap the target around
+ var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
+
+ if ( this[0].parentNode ) {
+ wrap.insertBefore( this[0] );
+ }
+
+ wrap.map(function() {
+ var elem = this;
+
+ while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
+ elem = elem.firstChild;
+ }
+
+ return elem;
+ }).append(this);
+ }
+
+ return this;
+ },
+
+ wrapInner: function( html ) {
+ return this.each(function() {
+ var self = jQuery( this ), contents = self.contents();
+
+ if ( contents.length ) {
+ contents.wrapAll( html );
+
+ } else {
+ self.append( html );
+ }
+ });
+ },
+
+ wrap: function( html ) {
+ return this.each(function() {
+ jQuery( this ).wrapAll( html );
+ });
+ },
+
+ unwrap: function() {
+ return this.parent().each(function() {
+ if ( !jQuery.nodeName( this, "body" ) ) {
+ jQuery( this ).replaceWith( this.childNodes );
+ }
+ }).end();
+ },
+
+ append: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 ) {
+ this.appendChild( elem );
+ }
+ });
+ },
+
+ prepend: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 ) {
+ this.insertBefore( elem, this.firstChild );
+ }
+ });
+ },
+
+ before: function() {
+ if ( this[0] && this[0].parentNode ) {
+ return this.domManip(arguments, false, function( elem ) {
+ this.parentNode.insertBefore( elem, this );
+ });
+ } else if ( arguments.length ) {
+ var set = jQuery(arguments[0]);
+ set.push.apply( set, this.toArray() );
+ return this.pushStack( set, "before", arguments );
+ }
+ },
+
+ after: function() {
+ if ( this[0] && this[0].parentNode ) {
+ return this.domManip(arguments, false, function( elem ) {
+ this.parentNode.insertBefore( elem, this.nextSibling );
+ });
+ } else if ( arguments.length ) {
+ var set = this.pushStack( this, "after", arguments );
+ set.push.apply( set, jQuery(arguments[0]).toArray() );
+ return set;
+ }
+ },
+
+ clone: function( events ) {
+ // Do the clone
+ var ret = this.map(function() {
+ if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) {
+ // IE copies events bound via attachEvent when
+ // using cloneNode. Calling detachEvent on the
+ // clone will also remove the events from the orignal
+ // In order to get around this, we use innerHTML.
+ // Unfortunately, this means some modifications to
+ // attributes in IE that are actually only stored
+ // as properties will not be copied (such as the
+ // the name attribute on an input).
+ var html = this.outerHTML, ownerDocument = this.ownerDocument;
+ if ( !html ) {
+ var div = ownerDocument.createElement("div");
+ div.appendChild( this.cloneNode(true) );
+ html = div.innerHTML;
+ }
+
+ return jQuery.clean([html.replace(rinlinejQuery, "")
+ .replace(rleadingWhitespace, "")], ownerDocument)[0];
+ } else {
+ return this.cloneNode(true);
+ }
+ });
+
+ // Copy the events from the original to the clone
+ if ( events === true ) {
+ cloneCopyEvent( this, ret );
+ cloneCopyEvent( this.find("*"), ret.find("*") );
+ }
+
+ // Return the cloned set
+ return ret;
+ },
+
+ html: function( value ) {
+ if ( value === undefined ) {
+ return this[0] && this[0].nodeType === 1 ?
+ this[0].innerHTML.replace(rinlinejQuery, "") :
+ null;
+
+ // See if we can take a shortcut and just use innerHTML
+ } else if ( typeof value === "string" && !/<script/i.test( value ) &&
+ (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
+ !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
+
+ try {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ // Remove element nodes and prevent memory leaks
+ if ( this[i].nodeType === 1 ) {
+ cleanData( this[i].getElementsByTagName("*") );
+ this[i].innerHTML = value;
+ }
+ }
+
+ // If using innerHTML throws an exception, use the fallback method
+ } catch(e) {
+ this.empty().append( value );
+ }
+
+ } else if ( jQuery.isFunction( value ) ) {
+ this.each(function(i){
+ var self = jQuery(this), old = self.html();
+ self.empty().append(function(){
+ return value.call( this, i, old );
+ });
+ });
+
+ } else {
+ this.empty().append( value );
+ }
+
+ return this;
+ },
+
+ replaceWith: function( value ) {
+ if ( this[0] && this[0].parentNode ) {
+ // Make sure that the elements are removed from the DOM before they are inserted
+ // this can help fix replacing a parent with child elements
+ if ( !jQuery.isFunction( value ) ) {
+ value = jQuery( value ).detach();
+ }
+
+ return this.each(function() {
+ var next = this.nextSibling, parent = this.parentNode;
+
+ jQuery(this).remove();
+
+ if ( next ) {
+ jQuery(next).before( value );
+ } else {
+ jQuery(parent).append( value );
+ }
+ });
+ } else {
+ return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value );
+ }
+ },
+
+ detach: function( selector ) {
+ return this.remove( selector, true );
+ },
+
+ domManip: function( args, table, callback ) {
+ var results, first, value = args[0], scripts = [];
+
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ args[0] = value.call(this, i, table ? self.html() : undefined);
+ return self.domManip( args, table, callback );
+ });
+ }
+
+ if ( this[0] ) {
+ // If we're in a fragment, just use that instead of building a new one
+ if ( args[0] && args[0].parentNode && args[0].parentNode.nodeType === 11 ) {
+ results = { fragment: args[0].parentNode };
+ } else {
+ results = buildFragment( args, this, scripts );
+ }
+
+ first = results.fragment.firstChild;
+
+ if ( first ) {
+ table = table && jQuery.nodeName( first, "tr" );
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ callback.call(
+ table ?
+ root(this[i], first) :
+ this[i],
+ results.cacheable || this.length > 1 || i > 0 ?
+ results.fragment.cloneNode(true) :
+ results.fragment
+ );
+ }
+ }
+
+ if ( scripts ) {
+ jQuery.each( scripts, evalScript );
+ }
+ }
+
+ return this;
+
+ function root( elem, cur ) {
+ return jQuery.nodeName(elem, "table") ?
+ (elem.getElementsByTagName("tbody")[0] ||
+ elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
+ elem;
+ }
+ }
+});
+
+function cloneCopyEvent(orig, ret) {
+ var i = 0;
+
+ ret.each(function() {
+ if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) {
+ return;
+ }
+
+ var oldData = jQuery.data( orig[i++] ), curData = jQuery.data( this, oldData ), events = oldData && oldData.events;
+
+ if ( events ) {
+ delete curData.handle;
+ curData.events = {};
+
+ for ( var type in events ) {
+ for ( var handler in events[ type ] ) {
+ jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data );
+ }
+ }
+ }
+ });
+}
+
+function buildFragment( args, nodes, scripts ) {
+ var fragment, cacheable, cached, cacheresults, doc;
+
+ if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) {
+ cacheable = true;
+ cacheresults = jQuery.fragments[ args[0] ];
+ if ( cacheresults ) {
+ if ( cacheresults !== 1 ) {
+ fragment = cacheresults;
+ }
+ cached = true;
+ }
+ }
+
+ if ( !fragment ) {
+ doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
+ fragment = doc.createDocumentFragment();
+ jQuery.clean( args, doc, fragment, scripts );
+ }
+
+ if ( cacheable ) {
+ jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
+ }
+
+ return { fragment: fragment, cacheable: cacheable };
+}
+
+jQuery.fragments = {};
+
+jQuery.each({
+ appendTo: "append",
+ prependTo: "prepend",
+ insertBefore: "before",
+ insertAfter: "after",
+ replaceAll: "replaceWith"
+}, function( name, original ) {
+ jQuery.fn[ name ] = function( selector ) {
+ var ret = [], insert = jQuery( selector );
+
+ for ( var i = 0, l = insert.length; i < l; i++ ) {
+ var elems = (i > 0 ? this.clone(true) : this).get();
+ jQuery.fn[ original ].apply( jQuery(insert[i]), elems );
+ ret = ret.concat( elems );
+ }
+ return this.pushStack( ret, name, insert.selector );
+ };
+});
+
+jQuery.each({
+ // keepData is for internal use only--do not document
+ remove: function( selector, keepData ) {
+ if ( !selector || jQuery.filter( selector, [ this ] ).length ) {
+ if ( !keepData && this.nodeType === 1 ) {
+ cleanData( this.getElementsByTagName("*") );
+ cleanData( [ this ] );
+ }
+
+ if ( this.parentNode ) {
+ this.parentNode.removeChild( this );
+ }
+ }
+ },
+
+ empty: function() {
+ // Remove element nodes and prevent memory leaks
+ if ( this.nodeType === 1 ) {
+ cleanData( this.getElementsByTagName("*") );
+ }
+
+ // Remove any remaining nodes
+ while ( this.firstChild ) {
+ this.removeChild( this.firstChild );
+ }
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function() {
+ return this.each( fn, arguments );
+ };
+});
+
+jQuery.extend({
+ clean: function( elems, context, fragment, scripts ) {
+ context = context || document;
+
+ // !context.createElement fails in IE with an error but returns typeof 'object'
+ if ( typeof context.createElement === "undefined" ) {
+ context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
+ }
+
+ var ret = [];
+
+ jQuery.each(elems, function( i, elem ) {
+ if ( typeof elem === "number" ) {
+ elem += "";
+ }
+
+ if ( !elem ) {
+ return;
+ }
+
+ // Convert html string into DOM nodes
+ if ( typeof elem === "string" && !rhtml.test( elem ) ) {
+ elem = context.createTextNode( elem );
+
+ } else if ( typeof elem === "string" ) {
+ // Fix "XHTML"-style tags in all browsers
+ elem = elem.replace(rxhtmlTag, fcloseTag);
+
+ // Trim whitespace, otherwise indexOf won't work as expected
+ var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
+ wrap = wrapMap[ tag ] || wrapMap._default,
+ depth = wrap[0],
+ div = context.createElement("div");
+
+ // Go to html and back, then peel off extra wrappers
+ div.innerHTML = wrap[1] + elem + wrap[2];
+
+ // Move to the right depth
+ while ( depth-- ) {
+ div = div.lastChild;
+ }
+
+ // Remove IE's autoinserted <tbody> from table fragments
+ if ( !jQuery.support.tbody ) {
+
+ // String was a <table>, *may* have spurious <tbody>
+ var hasBody = rtbody.test(elem),
+ tbody = tag === "table" && !hasBody ?
+ div.firstChild && div.firstChild.childNodes :
+
+ // String was a bare <thead> or <tfoot>
+ wrap[1] === "<table>" && !hasBody ?
+ div.childNodes :
+ [];
+
+ for ( var j = tbody.length - 1; j >= 0 ; --j ) {
+ if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
+ tbody[ j ].parentNode.removeChild( tbody[ j ] );
+ }
+ }
+
+ }
+
+ // IE completely kills leading whitespace when innerHTML is used
+ if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
+ div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
+ }
+
+ elem = jQuery.makeArray( div.childNodes );
+ }
+
+ if ( elem.nodeType ) {
+ ret.push( elem );
+ } else {
+ ret = jQuery.merge( ret, elem );
+ }
+
+ });
+
+ if ( fragment ) {
+ for ( var i = 0; ret[i]; i++ ) {
+ if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
+ scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
+ } else {
+ if ( ret[i].nodeType === 1 ) {
+ ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
+ }
+ fragment.appendChild( ret[i] );
+ }
+ }
+ }
+
+ return ret;
+ }
+});
+
+function cleanData( elems ) {
+ for ( var i = 0, elem, id; (elem = elems[i]) != null; i++ ) {
+ if ( !jQuery.noData[elem.nodeName.toLowerCase()] && (id = elem[expando]) ) {
+ delete jQuery.cache[ id ];
+ }
+ }
+}
+// exclude the following css properties to add px
+var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
+ ralpha = /alpha\([^)]*\)/,
+ ropacity = /opacity=([^)]*)/,
+ rfloat = /float/i,
+ rdashAlpha = /-([a-z])/ig,
+ rupper = /([A-Z])/g,
+ rnumpx = /^-?\d+(?:px)?$/i,
+ rnum = /^-?\d/,
+
+ cssShow = { position: "absolute", visibility: "hidden", display:"block" },
+ cssWidth = [ "Left", "Right" ],
+ cssHeight = [ "Top", "Bottom" ],
+
+ // cache check for defaultView.getComputedStyle
+ getComputedStyle = document.defaultView && document.defaultView.getComputedStyle,
+ // normalize float css property
+ styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat",
+ fcamelCase = function( all, letter ) {
+ return letter.toUpperCase();
+ };
+
+jQuery.fn.css = function( name, value ) {
+ return access( this, name, value, true, function( elem, name, value ) {
+ if ( value === undefined ) {
+ return jQuery.curCSS( elem, name );
+ }
+
+ if ( typeof value === "number" && !rexclude.test(name) ) {
+ value += "px";
+ }
+
+ jQuery.style( elem, name, value );
+ });
+};
+
+jQuery.extend({
+ style: function( elem, name, value ) {
+ // don't set styles on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ // ignore negative width and height values #1599
+ if ( (name === "width" || name === "height") && parseFloat(value) < 0 ) {
+ value = undefined;
+ }
+
+ var style = elem.style || elem, set = value !== undefined;
+
+ // IE uses filters for opacity
+ if ( !jQuery.support.opacity && name === "opacity" ) {
+ if ( set ) {
+ // IE has trouble with opacity if it does not have layout
+ // Force it by setting the zoom level
+ style.zoom = 1;
+
+ // Set the alpha filter to set the opacity
+ var opacity = parseInt( value, 10 ) + "" === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")";
+ var filter = style.filter || jQuery.curCSS( elem, "filter" ) || "";
+ style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : opacity;
+ }
+
+ return style.filter && style.filter.indexOf("opacity=") >= 0 ?
+ (parseFloat( ropacity.exec(style.filter)[1] ) / 100) + "":
+ "";
+ }
+
+ // Make sure we're using the right name for getting the float value
+ if ( rfloat.test( name ) ) {
+ name = styleFloat;
+ }
+
+ name = name.replace(rdashAlpha, fcamelCase);
+
+ if ( set ) {
+ style[ name ] = value;
+ }
+
+ return style[ name ];
+ },
+
+ css: function( elem, name, force, extra ) {
+ if ( name === "width" || name === "height" ) {
+ var val, props = cssShow, which = name === "width" ? cssWidth : cssHeight;
+
+ function getWH() {
+ val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
+
+ if ( extra === "border" ) {
+ return;
+ }
+
+ jQuery.each( which, function() {
+ if ( !extra ) {
+ val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
+ }
+
+ if ( extra === "margin" ) {
+ val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0;
+ } else {
+ val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
+ }
+ });
+ }
+
+ if ( elem.offsetWidth !== 0 ) {
+ getWH();
+ } else {
+ jQuery.swap( elem, props, getWH );
+ }
+
+ return Math.max(0, Math.round(val));
+ }
+
+ return jQuery.curCSS( elem, name, force );
+ },
+
+ curCSS: function( elem, name, force ) {
+ var ret, style = elem.style, filter;
+
+ // IE uses filters for opacity
+ if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) {
+ ret = ropacity.test(elem.currentStyle.filter || "") ?
+ (parseFloat(RegExp.$1) / 100) + "" :
+ "";
+
+ return ret === "" ?
+ "1" :
+ ret;
+ }
+
+ // Make sure we're using the right name for getting the float value
+ if ( rfloat.test( name ) ) {
+ name = styleFloat;
+ }
+
+ if ( !force && style && style[ name ] ) {
+ ret = style[ name ];
+
+ } else if ( getComputedStyle ) {
+
+ // Only "float" is needed here
+ if ( rfloat.test( name ) ) {
+ name = "float";
+ }
+
+ name = name.replace( rupper, "-$1" ).toLowerCase();
+
+ var defaultView = elem.ownerDocument.defaultView;
+
+ if ( !defaultView ) {
+ return null;
+ }
+
+ var computedStyle = defaultView.getComputedStyle( elem, null );
+
+ if ( computedStyle ) {
+ ret = computedStyle.getPropertyValue( name );
+ }
+
+ // We should always get a number back from opacity
+ if ( name === "opacity" && ret === "" ) {
+ ret = "1";
+ }
+
+ } else if ( elem.currentStyle ) {
+ var camelCase = name.replace(rdashAlpha, fcamelCase);
+
+ ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
+
+ // From the awesome hack by Dean Edwards
+ // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
+
+ // If we're not dealing with a regular pixel number
+ // but a number that has a weird ending, we need to convert it to pixels
+ if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
+ // Remember the original values
+ var left = style.left, rsLeft = elem.runtimeStyle.left;
+
+ // Put in the new values to get a computed value out
+ elem.runtimeStyle.left = elem.currentStyle.left;
+ style.left = camelCase === "fontSize" ? "1em" : (ret || 0);
+ ret = style.pixelLeft + "px";
+
+ // Revert the changed values
+ style.left = left;
+ elem.runtimeStyle.left = rsLeft;
+ }
+ }
+
+ return ret;
+ },
+
+ // A method for quickly swapping in/out CSS properties to get correct calculations
+ swap: function( elem, options, callback ) {
+ var old = {};
+
+ // Remember the old values, and insert the new ones
+ for ( var name in options ) {
+ old[ name ] = elem.style[ name ];
+ elem.style[ name ] = options[ name ];
+ }
+
+ callback.call( elem );
+
+ // Revert the old values
+ for ( var name in options ) {
+ elem.style[ name ] = old[ name ];
+ }
+ }
+});
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.hidden = function( elem ) {
+ var width = elem.offsetWidth, height = elem.offsetHeight,
+ skip = elem.nodeName.toLowerCase() === "tr";
+
+ return width === 0 && height === 0 && !skip ?
+ true :
+ width > 0 && height > 0 && !skip ?
+ false :
+ jQuery.curCSS(elem, "display") === "none";
+ };
+
+ jQuery.expr.filters.visible = function( elem ) {
+ return !jQuery.expr.filters.hidden( elem );
+ };
+}
+var jsc = now(),
+ rscript = /<script(.|\s)*?\/script>/gi,
+ rselectTextarea = /select|textarea/i,
+ rinput = /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,
+ jsre = /=\?(&|$)/,
+ rquery = /\?/,
+ rts = /(\?|&)_=.*?(&|$)/,
+ rurl = /^(\w+:)?\/\/([^\/?#]+)/,
+ r20 = /%20/g;
+
+jQuery.fn.extend({
+ // Keep a copy of the old load
+ _load: jQuery.fn.load,
+
+ load: function( url, params, callback ) {
+ if ( typeof url !== "string" ) {
+ return this._load( url );
+
+ // Don't do a request if no elements are being requested
+ } else if ( !this.length ) {
+ return this;
+ }
+
+ var off = url.indexOf(" ");
+ if ( off >= 0 ) {
+ var selector = url.slice(off, url.length);
+ url = url.slice(0, off);
+ }
+
+ // Default to a GET request
+ var type = "GET";
+
+ // If the second parameter was provided
+ if ( params ) {
+ // If it's a function
+ if ( jQuery.isFunction( params ) ) {
+ // We assume that it's the callback
+ callback = params;
+ params = null;
+
+ // Otherwise, build a param string
+ } else if ( typeof params === "object" ) {
+ params = jQuery.param( params, jQuery.ajaxSettings.traditional );
+ type = "POST";
+ }
+ }
+
+ // Request the remote document
+ jQuery.ajax({
+ url: url,
+ type: type,
+ dataType: "html",
+ data: params,
+ context:this,
+ complete: function( res, status ) {
+ // If successful, inject the HTML into all the matched elements
+ if ( status === "success" || status === "notmodified" ) {
+ // See if a selector was specified
+ this.html( selector ?
+ // Create a dummy div to hold the results
+ jQuery("<div />")
+ // inject the contents of the document in, removing the scripts
+ // to avoid any 'Permission Denied' errors in IE
+ .append(res.responseText.replace(rscript, ""))
+
+ // Locate the specified elements
+ .find(selector) :
+
+ // If not, just inject the full result
+ res.responseText );
+ }
+
+ if ( callback ) {
+ this.each( callback, [res.responseText, status, res] );
+ }
+ }
+ });
+
+ return this;
+ },
+
+ serialize: function() {
+ return jQuery.param(this.serializeArray());
+ },
+ serializeArray: function() {
+ return this.map(function() {
+ return this.elements ? jQuery.makeArray(this.elements) : this;
+ })
+ .filter(function() {
+ return this.name && !this.disabled &&
+ (this.checked || rselectTextarea.test(this.nodeName) ||
+ rinput.test(this.type));
+ })
+ .map(function( i, elem ) {
+ var val = jQuery(this).val();
+
+ return val == null ?
+ null :
+ jQuery.isArray(val) ?
+ jQuery.map( val, function( val, i ) {
+ return { name: elem.name, value: val };
+ }) :
+ { name: elem.name, value: val };
+ }).get();
+ }
+});
+
+// Attach a bunch of functions for handling common AJAX events
+jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function( i, o ) {
+ jQuery.fn[o] = function( f ) {
+ return this.bind(o, f);
+ };
+});
+
+jQuery.extend({
+
+ get: function( url, data, callback, type ) {
+ // shift arguments if data argument was omited
+ if ( jQuery.isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = null;
+ }
+
+ return jQuery.ajax({
+ type: "GET",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ getScript: function( url, callback ) {
+ return jQuery.get(url, null, callback, "script");
+ },
+
+ getJSON: function( url, data, callback ) {
+ return jQuery.get(url, data, callback, "json");
+ },
+
+ post: function( url, data, callback, type ) {
+ // shift arguments if data argument was omited
+ if ( jQuery.isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = {};
+ }
+
+ return jQuery.ajax({
+ type: "POST",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ ajaxSetup: function( settings ) {
+ jQuery.extend( jQuery.ajaxSettings, settings );
+ },
+
+ ajaxSettings: {
+ url: location.href,
+ global: true,
+ type: "GET",
+ contentType: "application/x-www-form-urlencoded",
+ processData: true,
+ async: true,
+ /*
+ timeout: 0,
+ data: null,
+ username: null,
+ password: null,
+ traditional: false,
+ */
+ // Create the request object; Microsoft failed to properly
+ // implement the XMLHttpRequest in IE7 (can't request local files),
+ // so we use the ActiveXObject when it is available
+ // This function can be overriden by calling jQuery.ajaxSetup
+ xhr: window.XMLHttpRequest && (window.location.protocol !== "file:" || !window.ActiveXObject) ?
+ function() {
+ return new window.XMLHttpRequest();
+ } :
+ function() {
+ try {
+ return new window.ActiveXObject("Microsoft.XMLHTTP");
+ } catch(e) {}
+ },
+ accepts: {
+ xml: "application/xml, text/xml",
+ html: "text/html",
+ script: "text/javascript, application/javascript",
+ json: "application/json, text/javascript",
+ text: "text/plain",
+ _default: "*/*"
+ }
+ },
+
+ // Last-Modified header cache for next request
+ lastModified: {},
+ etag: {},
+
+ ajax: function( origSettings ) {
+ var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings);
+
+ var jsonp, status, data,
+ callbackContext = s.context || s,
+ type = s.type.toUpperCase();
+
+ // convert data if not already a string
+ if ( s.data && s.processData && typeof s.data !== "string" ) {
+ s.data = jQuery.param( s.data, s.traditional );
+ }
+
+ // Handle JSONP Parameter Callbacks
+ if ( s.dataType === "jsonp" ) {
+ if ( type === "GET" ) {
+ if ( !jsre.test( s.url ) ) {
+ s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?";
+ }
+ } else if ( !s.data || !jsre.test(s.data) ) {
+ s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
+ }
+ s.dataType = "json";
+ }
+
+ // Build temporary JSONP function
+ if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) {
+ jsonp = s.jsonpCallback || ("jsonp" + jsc++);
+
+ // Replace the =? sequence both in the query string and the data
+ if ( s.data ) {
+ s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
+ }
+
+ s.url = s.url.replace(jsre, "=" + jsonp + "$1");
+
+ // We need to make sure
+ // that a JSONP style response is executed properly
+ s.dataType = "script";
+
+ // Handle JSONP-style loading
+ window[ jsonp ] = window[ jsonp ] || function( tmp ) {
+ data = tmp;
+ success();
+ complete();
+ // Garbage collect
+ window[ jsonp ] = undefined;
+
+ try {
+ delete window[ jsonp ];
+ } catch(e) {}
+
+ if ( head ) {
+ head.removeChild( script );
+ }
+ };
+ }
+
+ if ( s.dataType === "script" && s.cache === null ) {
+ s.cache = false;
+ }
+
+ if ( s.cache === false && type === "GET" ) {
+ var ts = now();
+
+ // try replacing _= if it is there
+ var ret = s.url.replace(rts, "$1_=" + ts + "$2");
+
+ // if nothing was replaced, add timestamp to the end
+ s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : "");
+ }
+
+ // If data is available, append data to url for get requests
+ if ( s.data && type === "GET" ) {
+ s.url += (rquery.test(s.url) ? "&" : "?") + s.data;
+ }
+
+ // Watch for a new set of requests
+ if ( s.global && ! jQuery.active++ ) {
+ jQuery.event.trigger( "ajaxStart" );
+ }
+
+ // Matches an absolute URL, and saves the domain
+ var parts = rurl.exec( s.url ),
+ remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host);
+
+ // If we're requesting a remote document
+ // and trying to load JSON or Script with a GET
+ if ( s.dataType === "script" && type === "GET" && remote ) {
+ var head = document.getElementsByTagName("head")[0] || document.documentElement;
+ var script = document.createElement("script");
+ script.src = s.url;
+ if ( s.scriptCharset ) {
+ script.charset = s.scriptCharset;
+ }
+
+ // Handle Script loading
+ if ( !jsonp ) {
+ var done = false;
+
+ // Attach handlers for all browsers
+ script.onload = script.onreadystatechange = function() {
+ if ( !done && (!this.readyState ||
+ this.readyState === "loaded" || this.readyState === "complete") ) {
+ done = true;
+ success();
+ complete();
+
+ // Handle memory leak in IE
+ script.onload = script.onreadystatechange = null;
+ if ( head && script.parentNode ) {
+ head.removeChild( script );
+ }
+ }
+ };
+ }
+
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709 and #4378).
+ head.insertBefore( script, head.firstChild );
+
+ // We handle everything using the script element injection
+ return undefined;
+ }
+
+ var requestDone = false;
+
+ // Create the request object
+ var xhr = s.xhr();
+
+ if ( !xhr ) {
+ return;
+ }
+
+ // Open the socket
+ // Passing null username, generates a login popup on Opera (#2865)
+ if ( s.username ) {
+ xhr.open(type, s.url, s.async, s.username, s.password);
+ } else {
+ xhr.open(type, s.url, s.async);
+ }
+
+ // Need an extra try/catch for cross domain requests in Firefox 3
+ try {
+ // Set the correct header, if data is being sent
+ if ( s.data || origSettings && origSettings.contentType ) {
+ xhr.setRequestHeader("Content-Type", s.contentType);
+ }
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if ( s.ifModified ) {
+ if ( jQuery.lastModified[s.url] ) {
+ xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]);
+ }
+
+ if ( jQuery.etag[s.url] ) {
+ xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]);
+ }
+ }
+
+ // Set header so the called script knows that it's an XMLHttpRequest
+ // Only send the header if it's not a remote XHR
+ if ( !remote ) {
+ xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+ }
+
+ // Set the Accepts header for the server, depending on the dataType
+ xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ?
+ s.accepts[ s.dataType ] + ", */*" :
+ s.accepts._default );
+ } catch(e) {}
+
+ // Allow custom headers/mimetypes and early abort
+ if ( s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false ) {
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active ) {
+ jQuery.event.trigger( "ajaxStop" );
+ }
+
+ // close opended socket
+ xhr.abort();
+ return false;
+ }
+
+ if ( s.global ) {
+ trigger("ajaxSend", [xhr, s]);
+ }
+
+ // Wait for a response to come back
+ var onreadystatechange = xhr.onreadystatechange = function( isTimeout ) {
+ // The request was aborted
+ if ( !xhr || xhr.readyState === 0 ) {
+ // Opera doesn't call onreadystatechange before this point
+ // so we simulate the call
+ if ( !requestDone ) {
+ complete();
+ }
+
+ requestDone = true;
+ if ( xhr ) {
+ xhr.onreadystatechange = jQuery.noop;
+ }
+
+ // The transfer is complete and the data is available, or the request timed out
+ } else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) {
+ requestDone = true;
+ xhr.onreadystatechange = jQuery.noop;
+
+ status = isTimeout === "timeout" ?
+ "timeout" :
+ !jQuery.httpSuccess( xhr ) ?
+ "error" :
+ s.ifModified && jQuery.httpNotModified( xhr, s.url ) ?
+ "notmodified" :
+ "success";
+
+ if ( status === "success" ) {
+ // Watch for, and catch, XML document parse errors
+ try {
+ // process the data (runs the xml through httpData regardless of callback)
+ data = jQuery.httpData( xhr, s.dataType, s );
+ } catch(e) {
+ status = "parsererror";
+ }
+ }
+
+ // Make sure that the request was successful or notmodified
+ if ( status === "success" || status === "notmodified" ) {
+ // JSONP handles its own success callback
+ if ( !jsonp ) {
+ success();
+ }
+ } else {
+ jQuery.handleError(s, xhr, status);
+ }
+
+ // Fire the complete handlers
+ complete();
+
+ if ( isTimeout === "timeout" ) {
+ xhr.abort();
+ }
+
+ // Stop memory leaks
+ if ( s.async ) {
+ xhr = null;
+ }
+ }
+ };
+
+ // Override the abort handler, if we can (IE doesn't allow it, but that's OK)
+ // Opera doesn't fire onreadystatechange at all on abort
+ try {
+ var oldAbort = xhr.abort;
+ xhr.abort = function() {
+ if ( xhr ) {
+ oldAbort.call( xhr );
+ if ( xhr ) {
+ xhr.readyState = 0;
+ }
+ }
+
+ onreadystatechange();
+ };
+ } catch(e) { }
+
+ // Timeout checker
+ if ( s.async && s.timeout > 0 ) {
+ setTimeout(function() {
+ // Check to see if the request is still happening
+ if ( xhr && !requestDone ) {
+ onreadystatechange( "timeout" );
+ }
+ }, s.timeout);
+ }
+
+ // Send the data
+ try {
+ xhr.send( type === "POST" || type === "PUT" || type === "DELETE" ? s.data : null );
+ } catch(e) {
+ jQuery.handleError(s, xhr, null, e);
+ // Fire the complete handlers
+ complete();
+ }
+
+ // firefox 1.5 doesn't fire statechange for sync requests
+ if ( !s.async ) {
+ onreadystatechange();
+ }
+
+ function success() {
+ // If a local callback was specified, fire it and pass it the data
+ if ( s.success ) {
+ s.success.call( callbackContext, data, status, xhr );
+ }
+
+ // Fire the global callback
+ if ( s.global ) {
+ trigger( "ajaxSuccess", [xhr, s] );
+ }
+ }
+
+ function complete() {
+ // Process result
+ if ( s.complete ) {
+ s.complete.call( callbackContext, xhr, status);
+ }
+
+ // The request was completed
+ if ( s.global ) {
+ trigger( "ajaxComplete", [xhr, s] );
+ }
+
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active ) {
+ jQuery.event.trigger( "ajaxStop" );
+ }
+ }
+
+ function trigger(type, args) {
+ (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args);
+ }
+
+ // return XMLHttpRequest to allow aborting the request etc.
+ return xhr;
+ },
+
+ handleError: function( s, xhr, status, e ) {
+ // If a local callback was specified, fire it
+ if ( s.error ) {
+ s.error.call( s.context || window, xhr, status, e );
+ }
+
+ // Fire the global callback
+ if ( s.global ) {
+ (s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] );
+ }
+ },
+
+ // Counter for holding the number of active queries
+ active: 0,
+
+ // Determines if an XMLHttpRequest was successful or not
+ httpSuccess: function( xhr ) {
+ try {
+ // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
+ return !xhr.status && location.protocol === "file:" ||
+ // Opera returns 0 when status is 304
+ ( xhr.status >= 200 && xhr.status < 300 ) ||
+ xhr.status === 304 || xhr.status === 1223 || xhr.status === 0;
+ } catch(e) {}
+
+ return false;
+ },
+
+ // Determines if an XMLHttpRequest returns NotModified
+ httpNotModified: function( xhr, url ) {
+ var lastModified = xhr.getResponseHeader("Last-Modified"),
+ etag = xhr.getResponseHeader("Etag");
+
+ if ( lastModified ) {
+ jQuery.lastModified[url] = lastModified;
+ }
+
+ if ( etag ) {
+ jQuery.etag[url] = etag;
+ }
+
+ // Opera returns 0 when status is 304
+ return xhr.status === 304 || xhr.status === 0;
+ },
+
+ httpData: function( xhr, type, s ) {
+ var ct = xhr.getResponseHeader("content-type") || "",
+ xml = type === "xml" || !type && ct.indexOf("xml") >= 0,
+ data = xml ? xhr.responseXML : xhr.responseText;
+
+ if ( xml && data.documentElement.nodeName === "parsererror" ) {
+ throw "parsererror";
+ }
+
+ // Allow a pre-filtering function to sanitize the response
+ // s is checked to keep backwards compatibility
+ if ( s && s.dataFilter ) {
+ data = s.dataFilter( data, type );
+ }
+
+ // The filter can actually parse the response
+ if ( typeof data === "string" ) {
+ // Get the JavaScript object, if JSON is used.
+ if ( type === "json" || !type && ct.indexOf("json") >= 0 ) {
+ // Make sure the incoming data is actual JSON
+ // Logic borrowed from http://json.org/json2.js
+ if (/^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]")
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ""))) {
+
+ // Try to use the native JSON parser first
+ if ( window.JSON && window.JSON.parse ) {
+ data = window.JSON.parse( data );
+
+ } else {
+ data = (new Function("return " + data))();
+ }
+
+ } else {
+ throw "Invalid JSON: " + data;
+ }
+
+ // If the type is "script", eval it in global context
+ } else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) {
+ jQuery.globalEval( data );
+ }
+ }
+
+ return data;
+ },
+
+ // Serialize an array of form elements or a set of
+ // key/values into a query string
+ param: function( a, traditional ) {
+
+ var s = [];
+
+ // Set traditional to true for jQuery <= 1.3.2 behavior.
+ if ( traditional === undefined ) {
+ traditional = jQuery.ajaxSettings.traditional;
+ }
+
+ function add( key, value ) {
+ // If value is a function, invoke it and return its value
+ value = jQuery.isFunction(value) ? value() : value;
+ s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
+ }
+
+ // If an array was passed in, assume that it is an array of form elements.
+ if ( jQuery.isArray(a) || a.jquery ) {
+ // Serialize the form elements
+ jQuery.each( a, function() {
+ add( this.name, this.value );
+ });
+
+ } else {
+ // If traditional, encode the "old" way (the way 1.3.2 or older
+ // did it), otherwise encode params recursively.
+ jQuery.each( a, function buildParams( prefix, obj ) {
+
+ if ( jQuery.isArray(obj) ) {
+ // Serialize array item.
+ jQuery.each( obj, function( i, v ) {
+ if ( traditional ) {
+ // Treat each array item as a scalar.
+ add( prefix, v );
+ } else {
+ // If array item is non-scalar (array or object), encode its
+ // numeric index to resolve deserialization ambiguity issues.
+ // Note that rack (as of 1.0.0) can't currently deserialize
+ // nested arrays properly, and attempting to do so may cause
+ // a server error. Possible fixes are to modify rack's
+ // deserialization algorithm or to provide an option or flag
+ // to force array serialization to be shallow.
+ buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v );
+ }
+ });
+
+ } else if ( !traditional && obj != null && typeof obj === "object" ) {
+ // Serialize object item.
+ jQuery.each( obj, function( k, v ) {
+ buildParams( prefix + "[" + k + "]", v );
+ });
+
+ } else {
+ // Serialize scalar item.
+ add( prefix, obj );
+ }
+ });
+ }
+
+ // Return the resulting serialization
+ return s.join("&").replace(r20, "+");
+ }
+
+});
+var elemdisplay = {},
+ rfxtypes = /toggle|show|hide/,
+ rfxnum = /^([+-]=)?([\d+-.]+)(.*)$/,
+ timerId,
+ fxAttrs = [
+ // height animations
+ [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
+ // width animations
+ [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
+ // opacity animations
+ [ "opacity" ]
+ ];
+
+jQuery.fn.extend({
+ show: function( speed, callback ) {
+ if ( speed != null ) {
+ return this.animate( genFx("show", 3), speed, callback);
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var old = jQuery.data(this[i], "olddisplay");
+
+ this[i].style.display = old || "";
+
+ if ( jQuery.css(this[i], "display") === "none" ) {
+ var nodeName = this[i].nodeName, display;
+
+ if ( elemdisplay[ nodeName ] ) {
+ display = elemdisplay[ nodeName ];
+
+ } else {
+ var elem = jQuery("<" + nodeName + " />").appendTo("body");
+
+ display = elem.css("display");
+
+ if ( display === "none" ) {
+ display = "block";
+ }
+
+ elem.remove();
+
+ elemdisplay[ nodeName ] = display;
+ }
+
+ jQuery.data(this[i], "olddisplay", display);
+ }
+ }
+
+ // Set the display of the elements in a second loop
+ // to avoid the constant reflow
+ for ( var j = 0, k = this.length; j < k; j++ ) {
+ this[j].style.display = jQuery.data(this[j], "olddisplay") || "";
+ }
+
+ return this;
+ }
+ },
+
+ hide: function( speed, callback ) {
+ if ( speed != null ) {
+ return this.animate( genFx("hide", 3), speed, callback);
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var old = jQuery.data(this[i], "olddisplay");
+ if ( !old && old !== "none" ) {
+ jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display"));
+ }
+ }
+
+ // Set the display of the elements in a second loop
+ // to avoid the constant reflow
+ for ( var j = 0, k = this.length; j < k; j++ ) {
+ this[j].style.display = "none";
+ }
+
+ return this;
+ }
+ },
+
+ // Save the old toggle function
+ _toggle: jQuery.fn.toggle,
+
+ toggle: function( fn, fn2 ) {
+ var bool = typeof fn === "boolean";
+
+ if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
+ this._toggle.apply( this, arguments );
+
+ } else if ( fn == null || bool ) {
+ this.each(function() {
+ var state = bool ? fn : jQuery(this).is(":hidden");
+ jQuery(this)[ state ? "show" : "hide" ]();
+ });
+
+ } else {
+ this.animate(genFx("toggle", 3), fn, fn2);
+ }
+
+ return this;
+ },
+
+ fadeTo: function( speed, to, callback ) {
+ return this.filter(":hidden").css("opacity", 0).show().end()
+ .animate({opacity: to}, speed, callback);
+ },
+
+ animate: function( prop, speed, easing, callback ) {
+ var optall = jQuery.speed(speed, easing, callback);
+
+ if ( jQuery.isEmptyObject( prop ) ) {
+ return this.each( optall.complete );
+ }
+
+ return this[ optall.queue === false ? "each" : "queue" ](function() {
+ var opt = jQuery.extend({}, optall), p,
+ hidden = this.nodeType === 1 && jQuery(this).is(":hidden"),
+ self = this;
+
+ for ( p in prop ) {
+ var name = p.replace(rdashAlpha, fcamelCase);
+
+ if ( p !== name ) {
+ prop[ name ] = prop[ p ];
+ delete prop[ p ];
+ p = name;
+ }
+
+ if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
+ return opt.complete.call(this);
+ }
+
+ if ( ( p === "height" || p === "width" ) && this.style ) {
+ // Store display property
+ opt.display = jQuery.css(this, "display");
+
+ // Make sure that nothing sneaks out
+ opt.overflow = this.style.overflow;
+ }
+
+ if ( jQuery.isArray( prop[p] ) ) {
+ // Create (if needed) and add to specialEasing
+ (opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1];
+ prop[p] = prop[p][0];
+ }
+ }
+
+ if ( opt.overflow != null ) {
+ this.style.overflow = "hidden";
+ }
+
+ opt.curAnim = jQuery.extend({}, prop);
+
+ jQuery.each( prop, function( name, val ) {
+ var e = new jQuery.fx( self, opt, name );
+
+ if ( rfxtypes.test(val) ) {
+ e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop );
+
+ } else {
+ var parts = rfxnum.exec(val),
+ start = e.cur(true) || 0;
+
+ if ( parts ) {
+ var end = parseFloat( parts[2] ),
+ unit = parts[3] || "px";
+
+ // We need to compute starting value
+ if ( unit !== "px" ) {
+ self.style[ name ] = (end || 1) + unit;
+ start = ((end || 1) / e.cur(true)) * start;
+ self.style[ name ] = start + unit;
+ }
+
+ // If a +=/-= token was provided, we're doing a relative animation
+ if ( parts[1] ) {
+ end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
+ }
+
+ e.custom( start, end, unit );
+
+ } else {
+ e.custom( start, val, "" );
+ }
+ }
+ });
+
+ // For JS strict compliance
+ return true;
+ });
+ },
+
+ stop: function( clearQueue, gotoEnd ) {
+ var timers = jQuery.timers;
+
+ if ( clearQueue ) {
+ this.queue([]);
+ }
+
+ this.each(function() {
+ // go in reverse order so anything added to the queue during the loop is ignored
+ for ( var i = timers.length - 1; i >= 0; i-- ) {
+ if ( timers[i].elem === this ) {
+ if (gotoEnd) {
+ // force the next step to be the last
+ timers[i](true);
+ }
+
+ timers.splice(i, 1);
+ }
+ }
+ });
+
+ // start the next in the queue if the last step wasn't forced
+ if ( !gotoEnd ) {
+ this.dequeue();
+ }
+
+ return this;
+ }
+
+});
+
+// Generate shortcuts for custom animations
+jQuery.each({
+ slideDown: genFx("show", 1),
+ slideUp: genFx("hide", 1),
+ slideToggle: genFx("toggle", 1),
+ fadeIn: { opacity: "show" },
+ fadeOut: { opacity: "hide" }
+}, function( name, props ) {
+ jQuery.fn[ name ] = function( speed, callback ) {
+ return this.animate( props, speed, callback );
+ };
+});
+
+jQuery.extend({
+ speed: function( speed, easing, fn ) {
+ var opt = speed && typeof speed === "object" ? speed : {
+ complete: fn || !fn && easing ||
+ jQuery.isFunction( speed ) && speed,
+ duration: speed,
+ easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
+ };
+
+ opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
+ jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default;
+
+ // Queueing
+ opt.old = opt.complete;
+ opt.complete = function() {
+ if ( opt.queue !== false ) {
+ jQuery(this).dequeue();
+ }
+ if ( jQuery.isFunction( opt.old ) ) {
+ opt.old.call( this );
+ }
+ };
+
+ return opt;
+ },
+
+ easing: {
+ linear: function( p, n, firstNum, diff ) {
+ return firstNum + diff * p;
+ },
+ swing: function( p, n, firstNum, diff ) {
+ return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
+ }
+ },
+
+ timers: [],
+
+ fx: function( elem, options, prop ) {
+ this.options = options;
+ this.elem = elem;
+ this.prop = prop;
+
+ if ( !options.orig ) {
+ options.orig = {};
+ }
+ }
+
+});
+
+jQuery.fx.prototype = {
+ // Simple function for setting a style value
+ update: function() {
+ if ( this.options.step ) {
+ this.options.step.call( this.elem, this.now, this );
+ }
+
+ (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
+
+ // Set display property to block for height/width animations
+ if ( ( this.prop === "height" || this.prop === "width" ) && this.elem.style ) {
+ this.elem.style.display = "block";
+ }
+ },
+
+ // Get the current size
+ cur: function( force ) {
+ if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
+ return this.elem[ this.prop ];
+ }
+
+ var r = parseFloat(jQuery.css(this.elem, this.prop, force));
+ return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
+ },
+
+ // Start an animation from one number to another
+ custom: function( from, to, unit ) {
+ this.startTime = now();
+ this.start = from;
+ this.end = to;
+ this.unit = unit || this.unit || "px";
+ this.now = this.start;
+ this.pos = this.state = 0;
+
+ var self = this;
+ function t( gotoEnd ) {
+ return self.step(gotoEnd);
+ }
+
+ t.elem = this.elem;
+
+ if ( t() && jQuery.timers.push(t) && !timerId ) {
+ timerId = setInterval(jQuery.fx.tick, 13);
+ }
+ },
+
+ // Simple 'show' function
+ show: function() {
+ // Remember where we started, so that we can go back to it later
+ this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
+ this.options.show = true;
+
+ // Begin the animation
+ // Make sure that we start at a small width/height to avoid any
+ // flash of content
+ this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
+
+ // Start by showing the element
+ jQuery( this.elem ).show();
+ },
+
+ // Simple 'hide' function
+ hide: function() {
+ // Remember where we started, so that we can go back to it later
+ this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
+ this.options.hide = true;
+
+ // Begin the animation
+ this.custom(this.cur(), 0);
+ },
+
+ // Each step of an animation
+ step: function( gotoEnd ) {
+ var t = now(), done = true;
+
+ if ( gotoEnd || t >= this.options.duration + this.startTime ) {
+ this.now = this.end;
+ this.pos = this.state = 1;
+ this.update();
+
+ this.options.curAnim[ this.prop ] = true;
+
+ for ( var i in this.options.curAnim ) {
+ if ( this.options.curAnim[i] !== true ) {
+ done = false;
+ }
+ }
+
+ if ( done ) {
+ if ( this.options.display != null ) {
+ // Reset the overflow
+ this.elem.style.overflow = this.options.overflow;
+
+ // Reset the display
+ var old = jQuery.data(this.elem, "olddisplay");
+ this.elem.style.display = old ? old : this.options.display;
+
+ if ( jQuery.css(this.elem, "display") === "none" ) {
+ this.elem.style.display = "block";
+ }
+ }
+
+ // Hide the element if the "hide" operation was done
+ if ( this.options.hide ) {
+ jQuery(this.elem).hide();
+ }
+
+ // Reset the properties, if the item has been hidden or shown
+ if ( this.options.hide || this.options.show ) {
+ for ( var p in this.options.curAnim ) {
+ jQuery.style(this.elem, p, this.options.orig[p]);
+ }
+ }
+
+ // Execute the complete function
+ this.options.complete.call( this.elem );
+ }
+
+ return false;
+
+ } else {
+ var n = t - this.startTime;
+ this.state = n / this.options.duration;
+
+ // Perform the easing function, defaults to swing
+ var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop];
+ var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear");
+ this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration);
+ this.now = this.start + ((this.end - this.start) * this.pos);
+
+ // Perform the next step of the animation
+ this.update();
+ }
+
+ return true;
+ }
+};
+
+jQuery.extend( jQuery.fx, {
+ tick: function() {
+ var timers = jQuery.timers;
+
+ for ( var i = 0; i < timers.length; i++ ) {
+ if ( !timers[i]() ) {
+ timers.splice(i--, 1);
+ }
+ }
+
+ if ( !timers.length ) {
+ jQuery.fx.stop();
+ }
+ },
+
+ stop: function() {
+ clearInterval( timerId );
+ timerId = null;
+ },
+
+ speeds: {
+ slow: 600,
+ fast: 200,
+ // Default speed
+ _default: 400
+ },
+
+ step: {
+ opacity: function( fx ) {
+ jQuery.style(fx.elem, "opacity", fx.now);
+ },
+
+ _default: function( fx ) {
+ if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
+ fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
+ } else {
+ fx.elem[ fx.prop ] = fx.now;
+ }
+ }
+ }
+});
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.animated = function( elem ) {
+ return jQuery.grep(jQuery.timers, function( fn ) {
+ return elem === fn.elem;
+ }).length;
+ };
+}
+
+function genFx( type, num ) {
+ var obj = {};
+
+ jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
+ obj[ this ] = type;
+ });
+
+ return obj;
+}
+if ( "getBoundingClientRect" in document.documentElement ) {
+ jQuery.fn.offset = function( options ) {
+ var elem = this[0];
+
+ if ( !elem || !elem.ownerDocument ) {
+ return null;
+ }
+
+ if ( options ) {
+ return this.each(function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ });
+ }
+
+ if ( elem === elem.ownerDocument.body ) {
+ return jQuery.offset.bodyOffset( elem );
+ }
+
+ var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement,
+ clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
+ top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop,
+ left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft;
+
+ return { top: top, left: left };
+ };
+
+} else {
+ jQuery.fn.offset = function( options ) {
+ var elem = this[0];
+
+ if ( !elem || !elem.ownerDocument ) {
+ return null;
+ }
+
+ if ( options ) {
+ return this.each(function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ });
+ }
+
+ if ( elem === elem.ownerDocument.body ) {
+ return jQuery.offset.bodyOffset( elem );
+ }
+
+ jQuery.offset.initialize();
+
+ var offsetParent = elem.offsetParent, prevOffsetParent = elem,
+ doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement,
+ body = doc.body, defaultView = doc.defaultView,
+ prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
+ top = elem.offsetTop, left = elem.offsetLeft;
+
+ while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
+ if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
+ break;
+ }
+
+ computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
+ top -= elem.scrollTop;
+ left -= elem.scrollLeft;
+
+ if ( elem === offsetParent ) {
+ top += elem.offsetTop;
+ left += elem.offsetLeft;
+
+ if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.nodeName)) ) {
+ top += parseFloat( computedStyle.borderTopWidth ) || 0;
+ left += parseFloat( computedStyle.borderLeftWidth ) || 0;
+ }
+
+ prevOffsetParent = offsetParent, offsetParent = elem.offsetParent;
+ }
+
+ if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
+ top += parseFloat( computedStyle.borderTopWidth ) || 0;
+ left += parseFloat( computedStyle.borderLeftWidth ) || 0;
+ }
+
+ prevComputedStyle = computedStyle;
+ }
+
+ if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
+ top += body.offsetTop;
+ left += body.offsetLeft;
+ }
+
+ if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
+ top += Math.max( docElem.scrollTop, body.scrollTop );
+ left += Math.max( docElem.scrollLeft, body.scrollLeft );
+ }
+
+ return { top: top, left: left };
+ };
+}
+
+jQuery.offset = {
+ initialize: function() {
+ var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0,
+ html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
+
+ jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
+
+ container.innerHTML = html;
+ body.insertBefore( container, body.firstChild );
+ innerDiv = container.firstChild;
+ checkDiv = innerDiv.firstChild;
+ td = innerDiv.nextSibling.firstChild.firstChild;
+
+ this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
+ this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
+
+ checkDiv.style.position = "fixed", checkDiv.style.top = "20px";
+ // safari subtracts parent border width here which is 5px
+ this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
+ checkDiv.style.position = checkDiv.style.top = "";
+
+ innerDiv.style.overflow = "hidden", innerDiv.style.position = "relative";
+ this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
+
+ this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
+
+ body.removeChild( container );
+ body = container = innerDiv = checkDiv = table = td = null;
+ jQuery.offset.initialize = jQuery.noop;
+ },
+
+ bodyOffset: function( body ) {
+ var top = body.offsetTop, left = body.offsetLeft;
+
+ jQuery.offset.initialize();
+
+ if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
+ top += parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0;
+ left += parseFloat( jQuery.curCSS(body, "marginLeft", true) ) || 0;
+ }
+
+ return { top: top, left: left };
+ },
+
+ setOffset: function( elem, options, i ) {
+ // set position first, in-case top/left are set even on static elem
+ if ( /static/.test( jQuery.curCSS( elem, "position" ) ) ) {
+ elem.style.position = "relative";
+ }
+ var curElem = jQuery( elem ),
+ curOffset = curElem.offset(),
+ curTop = parseInt( jQuery.curCSS( elem, "top", true ), 10 ) || 0,
+ curLeft = parseInt( jQuery.curCSS( elem, "left", true ), 10 ) || 0;
+
+ if ( jQuery.isFunction( options ) ) {
+ options = options.call( elem, i, curOffset );
+ }
+
+ var props = {
+ top: (options.top - curOffset.top) + curTop,
+ left: (options.left - curOffset.left) + curLeft
+ };
+
+ if ( "using" in options ) {
+ options.using.call( elem, props );
+ } else {
+ curElem.css( props );
+ }
+ }
+};
+
+
+jQuery.fn.extend({
+ position: function() {
+ if ( !this[0] ) {
+ return null;
+ }
+
+ var elem = this[0],
+
+ // Get *real* offsetParent
+ offsetParent = this.offsetParent(),
+
+ // Get correct offsets
+ offset = this.offset(),
+ parentOffset = /^body|html$/i.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
+
+ // Subtract element margins
+ // note: when an element has margin: auto the offsetLeft and marginLeft
+ // are the same in Safari causing offset.left to incorrectly be 0
+ offset.top -= parseFloat( jQuery.curCSS(elem, "marginTop", true) ) || 0;
+ offset.left -= parseFloat( jQuery.curCSS(elem, "marginLeft", true) ) || 0;
+
+ // Add offsetParent borders
+ parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], "borderTopWidth", true) ) || 0;
+ parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], "borderLeftWidth", true) ) || 0;
+
+ // Subtract the two offsets
+ return {
+ top: offset.top - parentOffset.top,
+ left: offset.left - parentOffset.left
+ };
+ },
+
+ offsetParent: function() {
+ return this.map(function() {
+ var offsetParent = this.offsetParent || document.body;
+ while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
+ offsetParent = offsetParent.offsetParent;
+ }
+ return offsetParent;
+ });
+ }
+});
+
+
+// Create scrollLeft and scrollTop methods
+jQuery.each( ["Left", "Top"], function( i, name ) {
+ var method = "scroll" + name;
+
+ jQuery.fn[ method ] = function(val) {
+ var elem = this[0], win;
+
+ if ( !elem ) {
+ return null;
+ }
+
+ if ( val !== undefined ) {
+ // Set the scroll offset
+ return this.each(function() {
+ win = getWindow( this );
+
+ if ( win ) {
+ win.scrollTo(
+ !i ? val : jQuery(win).scrollLeft(),
+ i ? val : jQuery(win).scrollTop()
+ );
+
+ } else {
+ this[ method ] = val;
+ }
+ });
+ } else {
+ win = getWindow( elem );
+
+ // Return the scroll offset
+ return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
+ jQuery.support.boxModel && win.document.documentElement[ method ] ||
+ win.document.body[ method ] :
+ elem[ method ];
+ }
+ };
+});
+
+function getWindow( elem ) {
+ return ("scrollTo" in elem && elem.document) ?
+ elem :
+ elem.nodeType === 9 ?
+ elem.defaultView || elem.parentWindow :
+ false;
+}
+// Create innerHeight, innerWidth, outerHeight and outerWidth methods
+jQuery.each([ "Height", "Width" ], function( i, name ) {
+
+ var type = name.toLowerCase();
+
+ // innerHeight and innerWidth
+ jQuery.fn["inner" + name] = function() {
+ return this[0] ?
+ jQuery.css( this[0], type, false, "padding" ) :
+ null;
+ };
+
+ // outerHeight and outerWidth
+ jQuery.fn["outer" + name] = function( margin ) {
+ return this[0] ?
+ jQuery.css( this[0], type, false, margin ? "margin" : "border" ) :
+ null;
+ };
+
+ jQuery.fn[ type ] = function( size ) {
+ // Get window width or height
+ var elem = this[0];
+ if ( !elem ) {
+ return size == null ? null : this;
+ }
+
+ return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window?
+ // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
+ elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
+ elem.document.body[ "client" + name ] :
+
+ // Get document width or height
+ (elem.nodeType === 9) ? // is it a document
+ // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
+ Math.max(
+ elem.documentElement["client" + name],
+ elem.body["scroll" + name], elem.documentElement["scroll" + name],
+ elem.body["offset" + name], elem.documentElement["offset" + name]
+ ) :
+
+ // Get or set width or height on the element
+ size === undefined ?
+ // Get width or height on the element
+ jQuery.css( elem, type ) :
+
+ // Set the width or height on the element (default to pixels if value is unitless)
+ this.css( type, typeof size === "string" ? size : size + "px" );
+ };
+
+});
+// Expose jQuery to the global object
+window.jQuery = window.$ = jQuery;
+
+})(window);
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/js/karma.js b/examples/lessons/6_Maths_lowestCommonMultiple/js/karma.js
new file mode 100755
index 0000000..03f027b
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/js/karma.js
@@ -0,0 +1,1018 @@
+/* Documentation Note:
+ * Public methods and properties are commented with /** some text *\/
+ * and private methods and properties are commented with //
+ *
+ * Please leave it that way to keep this documentation sane
+ */
+
+
+/*
+* Karma Framework
+* http://karmaeducation.org
+*
+* Copyright (c) 2009
+* Bryan W Berry bryan@olenepal.org
+* Felipe López Toledo zer.subzero@gmail.com
+*
+* Under MIT License:
+* Permission is hereby granted, free of charge, to any person
+* obtaining a copy of this software and associated documentation
+* files (the "Software"), to deal in the Software without
+* restriction, including without limitation the rights to use,
+* copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following
+* conditions:
+*
+* The above copyright notice and this permission notice shall be
+* included in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+/**
+* @fileOverview Contains karma library
+* @author Bryan Berry <bryan@olenepal.org>
+* @author Felipe Lopez Toledo <zer.subzero@gmail.com>
+*/
+
+
+//common.js modules use exports object
+if(!this.exports) {
+ exports = {};
+}
+
+
+
+/** Checks if the current document type is set to HTML 5, throws
+ * an error otherwise, then initializes the karma object and returns
+ * a reference to that object.
+ * @namespace Global namespace for Karma library
+ * @param {Object} [options={}] options for intializing Karma library
+ * @param {String} [options.locale=''] sets current locale Not Yet Implemented
+ * @param {Array} [options.image=[]] array of images to be converted into a collection
+ * @param {Array} [options.audio=[]] array of audio to be converted into a collection
+ * @param {Array} [options.video=[]] array of videos to be converted into a collection
+ * @param {Array} [options.svg=[]] array of SVG elements to be
+ * converted into a collection. Each SVG element must already exist in the html document
+ * @param {Array} [options.canvas=[]] array of canvas elements
+ * to be converted into a collection. Each canvas element must already exist in the
+ * html document and width and height of each element must be set as attributes
+ * @throws {Error} if the document type declaration is not set to HTML 5, e.g.
+ * <!DOCTYPE html>
+ * @throws {Error} If any of the initialization parameters are invalid values
+ * @returns {Object} Karma.karma -- reference to the initialized Karma library
+ * @example
+ *
+ * var k = Karma({
+ * image: [
+ * {name: "ninja", file: "ninja.png"},
+ * {name: "cowboy", file: "cowboy.png"}
+ * ],
+ * audio: [
+ * {name: "woosh", file: "woosh.ogg"},
+ * {name: "yeehaw", file: "yeehaw.ogg"}
+ * ],
+ * video: [
+ * {name: "attack", file: "attack.ogv"},
+ * {name: "ride", file: "ride.ogv"}
+ * ]
+ * canvas: [
+ * {name: "ninja", domId: "ninjaCanvas"},
+ * {name: "cowboy", domId: "cowboyCanvas"}
+ * ],
+ * svg: [
+ * {name: "ninja", domId: "ninjaSvg"},
+ * {name: "cowboy", domId: "cowboySvg"}
+ * ],
+ * });
+ * Next, call the ready function with a callback to your program code
+ *
+ * k.ready(function () { ... your application code . . . }
+ *
+ * after that you can access each asset like so
+ * k.image.ninja;
+ * k.svg.cowboy;
+ * k.audio.yeehaw.play();
+ * k.canvas.ninja.drawImage(k.image.ninja, 0, 0);
+ *
+ */
+var Karma = exports.Karma = function (options) {
+ Karma._isHtml5(document.doctype.nodeName);
+
+ if ( Karma.karma._initialized === true ) {
+ return Karma.karma;
+ } else {
+ return Karma.karma._init(options);
+ }
+};
+
+
+//helper functions
+
+/**This emulates the Object.create method in ecmascript 5 spec
+ * This isn't a full implementation as it doesn't support
+ * This has the same functionality as Crockford's beget method
+ * and this primary building block for prototypal inheritance in
+ * this library
+ * @param {Object} target that the new object's prototype should point to
+ * @returns {Object} object whose prototype points to target
+ * @example
+ *
+ * var ninja = { weapon : "sword" };
+ * var ninja1 = Karma.create(ninja);
+ * ninja1.sword === "sword"
+ */
+Karma.create = function (target){
+ function F () {};
+ F.prototype = target;
+ return new F();
+};
+
+/** Returns a shallow copy of the passed in object
+ * @param {Object} target to be copied
+ * @returns {Object} a shallow copy of target
+ */
+Karma.clone = function (target){
+ var copy = {};
+ for ( var i in target ) {
+ if(target.hasOwnProperty(i)){
+ copy[i] = target[i];
+ }
+ }
+ return copy;
+};
+
+/** Extends properties of the target object with those of
+ * the source object
+ * @param {Object} target object to be extended
+ * @param {Object} source whose properties will extend target
+ * @returns {Object} target extended by source
+ */
+Karma.objectPlus = function (target, source){
+ for ( var i in source){
+ if (source.hasOwnProperty(i)){
+ target[i] = source[i];
+ }
+ }
+ return target;
+};
+
+/** Creates a new object that is a prototype of the first argument
+ * then extends it with the properties of the second argument
+ * @param {Object} parent1 will be prototype of returned object
+ * @param {Object} parent2 will extend properties of returned object
+ * @returns {Object} object that whose prototype is parent1 and has
+ * been extended with properties of parent2
+ */
+Karma.copyObjectPlus = function (parent1, parent2){
+ function F () {};
+ F.prototype = parent1;
+ var G = new F();
+ return Karma.objectPlus(G, parent2);
+};
+
+//Enables function chaining for a specified list of function names
+//IMPORTANT: use of closures here with "this" and "that" is __very__
+//complicated here
+Karma._makeChain = function (chainingFunctions) {
+ var that = this;
+ var _chainFunction = function ( name ){
+ that[ name ] = function ( ){
+ var type = typeof this.ctx[name];
+ if ( type === "function") {
+ this.ctx[ name ].apply( this.ctx, arguments );
+ }else if ( type === "string" ){
+ this.ctx[ name ] = arguments[0];
+ }else {
+ throw ("wtf?!: impossible to chain " + name + "!");
+ }
+ return this;
+ };
+ };
+
+ for (var i = 0; i < chainingFunctions.length; i++){
+ _chainFunction( chainingFunctions[ i ] );
+ }
+};
+
+//Throws big ugly error if doctype isn't html5
+Karma._isHtml5 = function (doctype){
+ var regex = new RegExp('^html$', 'i');
+ if(!regex.test(doctype)){
+ var errorMsg = "ERROR: The doctype must be set to <!DOCTYPE html> " +
+ "in order to use Karma. Karma require you use html5";
+ var errorElem = document.createElement('div');
+ errorElem.setAttribute('id', 'errorDoctype');
+ errorElem.innerText = errorMsg;
+ document.body.appendChild(errorElem);
+ throw new Error(errorMsg);
+ }
+};
+
+
+/** Stores global settings for the Karma library
+ * @class This object stores the global settings for the Karma library
+ */
+Karma.karma = {
+ /** This is the global locale as passed to Karma(),
+ * such as "en", "es_SP"
+ * @type string
+ * @default undefined
+ */
+ locale : undefined,
+ /** Collection of images with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ image : {},
+ /** Collection of audio with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ audio : {},
+ /** Collection of canvas with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ canvas : {},
+ /** Collection of svgs with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ svg : {},
+ /** Collection of videos with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ video : {},
+ _localized : false,
+ _assetPath : "assets/",
+ _localePath : "",
+ _initialized : false,
+ _statusDiv: undefined,
+ _loaderDiv : undefined,
+ _counters : { total : 0, errors : 0, loaded : 0},
+
+ //init initializes all the assets passed to Karma, that's it
+ //it returns 'this' so it can be used for function chaining
+ _init: function(options) {
+ this._initialized = true;
+
+ //set up message that show count of assets loaded
+ //and has an ordered list to append error messages to
+ var _statusDiv = this._statusDiv = document.createElement('div');
+ this._loaderDiv = this._loaderDiv = document.createElement('div');
+ var errorList = document.createElement('ol');
+
+ _statusDiv.setAttribute('id', 'karma-status');
+ _statusDiv.setAttribute('style', 'position:absolute;');
+ _statusDiv.innerHTML = 'Karma is loading ...';
+ this._loaderDiv.setAttribute('id', 'karma-loader');
+ this._loaderDiv.setAttribute('class', 'status');
+ errorList.setAttribute('id', 'errorList');
+
+ _statusDiv.appendChild(this._loaderDiv);
+ this._statusDiv.appendChild(errorList);
+ document.body.appendChild(_statusDiv);
+
+
+ //chain the functions for kCanvas and kSvg
+ Karma._makeChain.call(Karma.kCanvas,
+ Karma.kCanvas._chainingFunctions);
+ //Karma._makeChain.apply(Karma.kSvg, Karma.kSvg._chainingFunctions);
+
+
+
+ //regular expression that matches the name of aprivate property
+ // the karma object
+ var regexPrivate = new RegExp('^_.*');
+
+ for ( var option in options ) {
+ if (options.hasOwnProperty(option)){
+ if (option === "image" || option === "audio" || option ===
+ "svg" || option === "video" || option === "canvas"){
+
+ if(!(options[option] instanceof Array)){
+ throw new Error("" + option + " must be an array");
+ } else if (options[option].length === 0){
+ continue;
+ }
+ } else if (regexPrivate.test(option)){
+ //don't overwrite a private property of karma object
+ continue;
+ }
+
+ switch (option){
+ case "locale":
+
+ if (this._isValidLocale(options[option])){
+ this.locale = this._normalizeLocale(options[option]);
+ this._localized = true;
+ this._localePath = Karma._computeLocalePath(this.locale);
+ } else {
+ throw new Error("locale provided to karma._init() is invalid");
+ }
+
+ break;
+ case "image":
+ options[option]._type = 'image';
+ Karma._makeImages(options[option]);
+ break;
+ case "audio":
+ options[option]._type = 'audio';
+ Karma._makeAudio(options[option]);
+ break;
+ case "video":
+ options[option]._type = 'video';
+ Karma._makeVideos(options[option]);
+ break;
+ case "svg":
+ options[option]._type = 'svg';
+ Karma._makeSvgs(options[option]);
+ break;
+ case "canvas":
+ options[option]._type = 'canvas';
+ Karma._makeCanvases(options[option]);
+ break;
+ }
+ }
+ }
+
+
+
+ return this;
+ },
+
+ /** Waits until all assets loaded, i.e. ready, then calls callback
+ * @param {Function} [cb] callback function
+ * @returns this
+ * @throws {Error} if Karma.karma is not initialized with the
+ * Karma({ options }) function
+ * @example
+ *
+ * var k = Karma({ . . . your assets here . . . });
+ * k.ready(function(){ .. your code here . . .});
+ *
+ * your code will not be called until all assets have been loaded
+ *
+ */
+ ready : function( cb ) {
+ var that = this;
+ if (Karma.karma._initialized !== true){
+ throw new Error("Karma.karma not initialized");
+ }
+
+ if (this._counters.loaded !== this._counters.total){
+ setTimeout(function(){ that.ready(cb);}, 5);
+ } else if (cb) {
+ //hide the "Karma is loading..." message
+ this._statusDiv.setAttribute('style', 'display:none;');
+
+ cb();
+ } else if (!cb) {
+ //hide the "Karma is loading..." message
+ this._statusDiv.setAttribute('style', 'display:none;');
+
+ //if no options passed, show it works message
+ this._showStarterMessage();
+ }
+
+
+
+
+ return this;
+ },
+
+ //Display Apache-like "It works" message if no options
+ _showStarterMessage : function (){
+ var starterMsg = document.createElement('div');
+ starterMsg.setAttribute('id', 'starterMsg');
+ starterMsg.innerHTML = "<h1>It Works</h1>";
+ document.body.appendChild(starterMsg);
+ },
+
+ //Updates visible counter of how many assets are loaded
+ _updateStatus : function (errorMsg) {
+ var loaded = this._counters.loaded;
+ var total = this._counters.total;
+ var errors = this._counters.errors;
+ this._loaderDiv.innerHTML = "Loaded " + loaded + " / " + total +
+ "" + (errors > 0 ? " Errors [ " + errors +" ]" : '');
+ if (errorMsg) {
+ var liError = document.createElement('li');
+ liError.innerHTML = errorMsg;
+ var errorList = document.getElementById('errorList');
+ errorList.appendChild(liError);
+ }
+ },
+
+ //matches 2 letter country code then optionally
+ //a dash or underscore followed by a country or language identifier
+ //i currently only allow a language identifier 2-3 chars long
+ _isValidLocale : function (locale) {
+ var localeRegex = new RegExp('^[a-zA-Z][a-zA-Z]([-_][a-zA-z]{2,3})?$');
+ return localeRegex.test(locale);
+ },
+
+ _normalizeLocale : function(locale) {
+ var lang = "";
+ var country = "";
+ var divider = "";
+
+ lang = locale.slice(0, 2).toLowerCase();
+ divider = "_";
+ country = locale.slice(3, 6).toUpperCase();
+
+ return locale.length > 2 ? "" + lang + divider + country : lang;
+ },
+
+ // Below are geometry and math helper methods
+
+ /**
+ * Converts a value from degrees to radians.
+ * @param {Number} angle The angle in degrees
+ * @returns {Number} The angle in radians
+ */
+ radians : function( angle ){
+ return ( angle / 180 ) * Math.PI;
+ },
+ /**
+ * Gets the square of the Euclidian (ordinary) distance between 2 points.
+ * @param {Object} Point No. 0
+ * @param {Number} Point0.x
+ * @param {Number} Point0.y
+ * @param {Object} Point No. 1
+ * @param {Number} Point1.x
+ * @param {Number} Point1.y
+ * @returns {Number} The square of the Euclidian distance
+ * @example
+ *
+ * p0 = {x:0, y:1};
+ * p1 = {x:50, y:70};
+ * var d = distance2(p0, p1);
+ *
+ */
+ distance2 : function ( p0, p1 ) {
+ return (p1.x - p0.x) * (p1.x - p0.x) + (p1.y - p1.y) * (p1.y - p1.y);
+ },
+ /**
+ * Gets the Euclidian (ordinary) distance between 2 points.<br>
+ * <b>Warning:</b> It's slower than distance2 function
+ * @param {Object} Point No. 0
+ * @param {Number} Point0.x
+ * @param {Number} Point0.y
+ * @param {Object} Point No. 1
+ * @param {Number} Point1.x
+ * @param {Number} Point1.y
+ * @returns {Number} The Euclidian distance
+ * @example
+ *
+ * p0 = {x:0, y:1};
+ * p1 = {x:50, y:70};
+ * var d = distance2(p0, p1);
+ *
+ */
+ distance : function ( p0, p1 ) {
+ return Math.sqrt( this.distance2( p0, p1 ) );
+ },
+ /** Returns a random number within the range provided
+ * @param {Number} lower limit of the range, lowest number that can be returned
+ * @param {Number} upper limit of the range, highest number that can be returned
+ * @returns {Number} number that is >= lower and <= upper
+ * @example
+ *
+ * var num = rand(0, 10);
+ *
+ * num could be 0, 1, 2, 3 ... or 10
+ *
+ */
+ rand : function ( lower, upper ){
+ return Math.round( Math.random() * (upper - lower) + lower );
+ }
+
+};
+
+/** Prototypal object for images, videos, and audio files but
+ * does not include svg or canvas elements
+ * @class This object is the prototype for images, videos, and audio files but
+ * does not include svg or canvas elements
+ * @ throws {Error} if the individual asset is set to be localized but
+ * the globale locale is not set on the Karma.karma object
+ * @ throws {Error} if the name and file properties are not supplied
+ * @example
+ * kMedia is the prototype object for images, audio, and videos.
+ * These 'media' assets are loaded in a distinctly different way
+ * from the canvas or svg assets. They also have distinctly different
+ * helper methods
+ *
+ * You initialize the kMedia assets by passing an array of objects
+ */
+Karma.kMedia = {
+ /** file location of asset
+ * @type String
+ * @default ""
+ */
+ file : "",
+ /** media object
+ * @type Audio|Image|Video
+ * @default undefined
+ */
+ media : undefined,
+ //actual path to the file
+ _path : "",
+ //if using localized version of this asset
+ _localized : false,
+ //audio, image, or video
+ _type : "",
+ //initializes kMedia instance with values provided by user
+ _init : function (asset) {
+ asset._localized = asset._localized || false;
+ Karma.karma._counters.total++;
+
+ if (asset.name === undefined || asset.file === undefined){
+ throw new Error("properties name and file have to be defined");
+ } else {
+ this.name = asset.name;
+ this.file = asset.file;
+ }
+
+ //_type is a private variable used internally
+ if (asset._type === undefined){
+ throw new Error("the _type property must be set. " +
+ "Blame the karma library authors as this is an internal value");
+ } else {
+ if (Karma._isValidType(asset._type)){
+ this._type = asset._type;
+ switch ( this._type ) {
+ case "image": this.media = new Image();
+ break;
+ case "audio": this.media = new Audio();
+ break;
+ //case "video":
+ //NYI
+ //this.media = new Video();
+ break;
+ default: throw new Error("Media type not supported");
+ }
+
+ } else {
+ throw new Error("the _type property supplied is invalid. " +
+ "Blame the karma library authors as this is an internal value");
+ }
+ }
+
+ if(Karma._isLocalized(asset._localized)){
+ this._localized = asset._localized;
+ this._path = Karma.karma._localePath +
+ this._type + "/";
+ } else {
+ this._path = Karma.karma._assetPath +
+ this._type + "/";
+ }
+
+
+ //IMPORTANT: This one magic line loads the file
+ this.media.src = this.src = this._path + this.file;
+
+ //add event handlers
+ this._addEventHandlers();
+
+ if (this._type === "audio"){
+ this.media.autobuffer = true;
+ this.media.load();
+ }
+
+
+ return this;
+ },
+ //Adds event handlers to update the counters when
+ //the asset is successfully or unsuccessfully loaded
+ _addEventHandlers : function () {
+ var that = this;
+ var loadEvent = "load";
+ //Browser Hack recommended by chromium devs
+ //http://code.google.com/p/chromium/issues/detail?id=20251&q=loading%20audio&colspec=ID%20Stars%20Pri%20Area%20Type%20Status%20Summary%20Modified%20Owner%20Mstone%20OS#c4
+ if (this._type === "audio" || this._type === "video"){
+ loadEvent = "canplaythrough";
+ }
+
+ that.media.addEventListener(
+ loadEvent,
+ function (e) {
+ Karma.karma._counters.loaded++;
+ Karma.karma._updateStatus();
+ that.status = "loaded";}, false);
+
+ that.media.addEventListener(
+ "error",
+ function (e) {
+ Karma.karma._counters.errors++;
+ that.status = "error";
+ var errorMsg = "Error: " + that._type.toUpperCase() +
+ " " + that.name + " cannot be loaded.";
+ Karma.karma._updateStatus(errorMsg);
+ },
+ false);
+ that.media.addEventListener(
+ "abort",
+ function (e) {
+ Karma.karma._counters.total++;
+ that.status = "aborted";
+ var errorMsg = "ABORT: " + that._type.toUpperCase() +
+ " " + that.name + " loading was aborted.";
+ Karma.karma._updateStatus(errorMsg);
+
+ }, false);
+
+ }
+
+};
+
+//determine if it is a valid type of asset
+Karma._isValidType = function (type){
+ return type === "image" ||
+ type === "svg" ||
+ type === "audio" ||
+ type === "video" ||
+ type === "canvas";
+};
+
+Karma._isLocalized = function (boolLocalized) {
+ if (typeof boolLocalized === "boolean" ) {
+ if(boolLocalized === true &&
+ Karma.karma.locale === undefined){
+ throw new Error("You cannot localize a media asset" +
+ " if the global locale for Karma isn't set");
+ } else {
+ return boolLocalized;
+ }
+ } else if (typeof boolLocalized === undefined){
+ return false;
+ } else{
+ throw new Error("This is not a valid value for the localized option");
+ }
+};
+
+Karma._computeLocalePath = function(locale) {
+ return Karma.karma._assetPath + locale + "/";
+};
+
+Karma._makeImages = function (imgConfigs){
+ var makeImage = function (imgConfig){
+ var image = undefined;
+ imgConfig._type = "image";
+ image = Karma.create(Karma.kMedia)._init(imgConfig);
+ Karma.karma.image[imgConfig.name] = image;
+ };
+
+ imgConfigs.forEach(function(imgConfig){ makeImage(imgConfig);});
+
+};
+
+Karma._makeAudio = function (audioConfigs){
+ var makeAudio = function (audioConfig){
+ var audio = undefined;
+ audioConfig._type = "audio";
+ audio = Karma.create(Karma.kMedia)._init(audioConfig);
+ audio.play = function () {
+ //hack to fix the audio "stuttering" problem
+ //more info: https://bugs.launchpad.net/karma/+bug/426108
+ this.media.currentTime = 0.1;
+ this.media.play();
+ };
+ Karma.karma.audio[audioConfig.name] = audio;
+ };
+
+ audioConfigs.forEach(function(audioConfig){ makeAudio(audioConfig);});
+
+};
+
+
+Karma._makeCanvases = function (canvasConfigs){
+ var makeCanvas = function (canvasConfig){
+ var canvas = undefined;
+ canvas = Karma.create(Karma.kCanvas)._init(canvasConfig);
+ Karma.karma.canvas[canvasConfig.name] = canvas;
+ };
+
+ canvasConfigs.forEach(function(canvasConfig){ makeCanvas(canvasConfig);});
+
+};
+
+/** Prototypal object for each canvas element submitted to Karma in the
+ * Karma() method
+ * @throws {Error} if the name and domId for the canvas element are not specified
+ * @thows {Error} if the supplied domId does not match an element in the DOM
+ * @class This object is the prototype for each canvas element submitted to Karma in the
+ * Karma() method
+ */
+Karma.kCanvas = {
+ /** Name of the canvas, used internally by karma.js
+ * @type String
+ * @default ''
+ */
+ name : '',
+ /** Width of canvas element
+ * @type Number
+ * @default 0
+ */
+ width: 0,
+ /** Height of canvas element
+ * @type Number
+ * @default 0
+ */
+ height: 0,
+ /** Whether canvas is visible
+ * @type boolean
+ * @default true
+ */
+ visible: true,
+ /** Element ID for canvas element in html document
+ * @type String
+ * @default undefined
+ */
+ domId: undefined,
+ /** Reference to the DOM element
+ * @type DOMElement
+ * @default undefined
+ */
+ node: undefined,
+ /** The 2 Dimensional Rendering context property for this canvas
+ * @type 2DRenderingContext
+ * @default undefined
+ */
+ ctx: undefined,
+ /** Frames Per Second, I don't know what the purpose of this is,
+ * Felipe made it up
+ * @type Number
+ * @default 24
+ */
+ fps: 24,
+
+ //initializes object with values provides by user
+ _init: function (config) {
+ for (var option in config){
+ if (config.hasOwnProperty(option)){
+ switch (option){
+ case "name":
+ this.name = config[option];
+ break;
+ case "domId":
+ this.domId = config[option];
+ break;
+ case "width":
+ if(!this.height){
+ throw new Error("If you specify a width you must also" +
+ "specify a height");
+ }
+ this.width = config[option];
+ break;
+ case "height":
+ if(!this.width){
+ throw new Error("If you specify a height you must also" +
+ "specify a width");
+ }
+ this.height = parseInt(config.option, 10);
+ break;
+ case "fps":
+ this.fps = parseInt(config.option, 10);
+ break;
+ }
+ }
+ }
+
+ if(this.domId && document.getElementById(this.domId)){
+ this.node = document.getElementById(this.domId);
+ this.ctx = this.node.getContext('2d');
+ } else {
+ throw new Error('you must specify a valid domId that' +
+ 'is in your html page');
+ }
+
+ if(!config.height && !config.width){
+ this.width = parseInt(this.node.getAttribute('width'), 10);
+ this.height = parseInt(this.node.getAttribute('height'), 10);
+ }
+
+ return this;
+ },
+ /** Clear area of canvas element specified by parameters, if no
+ * parameters supplied, clears entire canvas
+ * @param {Number} [x=0] x coordinate, defaults to zero if left blank
+ * @param {Number} [y=0] y coordinate, defaults to zero if left blank
+ * @param {Number} [width=0] width of area to be cleared, defaults
+ * entire width of canvas
+ * @param {Number} [height=0] height of area to be cleared, defaults
+ * entire height of canvas
+ * @returns this
+ * @example
+ *
+ * k.canvas.ninja.clear();
+ * // clears the entire ninja canvas
+ *
+ * k.canvas.ninja.clear(0, 10, 20, 30);
+ * //clears a specific portion of the ninja canvas
+ *
+ */
+ clear : function ( x, y, width, height ) {
+ var that = this;
+ that.ctx.clearRect(
+ x || 0,
+ y || 0,
+ width || that.width,
+ height || that.height
+ );
+ return that;
+ },
+
+ //These are all properties or methods of the canvas element's
+ //2 dimensional context
+ _chainingFunctions : [
+ "globalAlpha", "globalCompositeOperation", "lineWidth", "lineCap",
+ "lineJoin", "miterLimit", "font", "textAlign", "textBaseline", "save",
+ "restore", "scale", "rotate", "translate", "transform", "setTransform",
+ "clearRect", "fillRect", "strokeRect", "beginPath", "closePath",
+ "moveTo", "lineTo", "quadraticCurveTo", "bezierCurveTo", "arcTo",
+ "arc", "rect", "fill", "stroke", "clip", "fillText", "strokeText",
+ "measureText", "isPointInPath", "strokeStyle", "fillStyle",
+ "createLinearGradient", "createRadialGradient", "createPattern",
+ "shadowOffsetX", "shadowOffsetY", "shadowBlur", "shadowColor",
+ //"mozTextStyle", "mozDrawText", "mozMeasureText", "mozPathText",
+ "mozTextAlongPath", "drawImage", "getImageData", "putImageData",
+ "createImageData", "drawWindow"
+ ]
+};
+
+
+
+Karma._makeSvgs = function (svgConfigs){
+ var makeSvg = function (svgConfig){
+ var svg = undefined;
+ svg = Karma.create(Karma.kSvg)._init(svgConfig);
+ Karma.karma.svg[svgConfig.name] = svg;
+ };
+
+ svgConfigs.forEach(function(svgConfig){ makeSvg(svgConfig);});
+
+};
+
+/** Prototypal object for each svg element submitted to Karma in the
+ * Karma() method
+ * @throws {Error} if the name and domId for the svg element are not specified
+ * @thows {Error} if the supplied domId does not match an element in the DOM
+ * @class This object is the prototype for each svg element submitted to Karma in the
+ * Karma() method
+ */
+Karma.kSvg = {
+ /** name of instance, used internally
+ * @typeof string
+ * @default ""
+ */
+ name : "",
+ /** width of element
+ * @type number
+ * @default 0
+ */
+ width: 0,
+ /** height of element
+ * @type number
+ * @default 0
+ */
+ height: 0,
+ /** Status of element, either "loaded" or "error"
+ * @type string
+ * @default ""
+ */
+ status: "",
+ /** Whether canvas is visible
+ * @type boolean
+ * @default true
+ */
+ visible: true,
+ /** Element ID for canvas element in html document
+ * @type String
+ * @default undefined
+ */
+ domId: undefined,
+ /** Reference to the DOM element
+ * @type DOMElement
+ * @default undefined
+ */
+ node: undefined,
+ /** Reference to the SVGDocument
+ * @type SVGDocument
+ * @default undefined
+ */
+ doc: undefined,
+ /** Reference to the root element of the SVG Document
+ * @type DocumentElement
+ * @default undefined
+ */
+ root: undefined,
+ _localized : undefined,
+ _chainingFunctions: [],
+ _init: function (config) {
+ Karma.karma._counters.total++;
+
+ for (var option in config){
+ if (config.hasOwnProperty(option)){
+ switch (option){
+ case "name":
+ this.name = config[option];
+ break;
+ case "domId":
+ this.domId = config[option];
+ break;
+ case "width":
+ if(!this.height){
+ throw new Error("If you specify a width you must also" +
+ "specify a height");
+ }
+ this.width = parseInt(config[option], 10);
+ break;
+ case "height":
+ if(!this.width){
+ throw new Error("If you specify a height you must also" +
+ "specify a width");
+ }
+ this.height = config[option];
+ break;
+ case "fps":
+ this.fps = config[option];
+ break;
+ }
+ }
+ }
+
+ if(this.domId && document.getElementById(this.domId)){
+ this.node = document.getElementById(this.domId);
+ } else {
+ throw new Error('you must specify a valid domId that' +
+ 'is in your html page');
+ }
+
+ if(!config.height && !config.width){
+ this.width = parseInt(this.node.getAttribute('width'), 10);
+ this.height = parseInt(this.node.getAttribute('height'), 10);
+ }
+
+ var that = this;
+ that._addEventHandlers();
+
+ return this;
+
+
+ },
+ _addEventHandlers : function () {
+ var that = this;
+ that.doc = that.node.getSVGDocument();
+ that.node.addEventListener(
+ "load",
+ function (e) {
+ that.doc = that.node.getSVGDocument();
+ that.root = that.doc.documentElement;
+ Karma.karma._counters.loaded++;
+ Karma.karma._updateStatus();
+ that.status = "loaded";
+ }, false);
+
+ that.node.addEventListener(
+ "error",
+ function (e) {
+ Karma.karma._counters.loaded--;
+ Karma.karma._counters.errors++;
+ that.status = "error";
+ var errorMsg = "Error: " + that._type.toUpperCase() +
+ " " + that.name + " cannot be loaded.";
+ Karma.karma._updateStatus(errorMsg);
+ },
+ false);
+ that.node.addEventListener(
+ "abort",
+ function (e) {
+ that.status = "aborted";
+ var errorMsg = "ABORT: " + that._type.toUpperCase() +
+ " " + that.name + " loading was aborted.";
+ Karma.karma._updateStatus(errorMsg);
+
+ }, false);
+
+ }
+};
+
+Karma._makeVideos = function (video){
+
+};
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/js/lesson.js b/examples/lessons/6_Maths_lowestCommonMultiple/js/lesson.js
new file mode 100755
index 0000000..8af8e32
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/js/lesson.js
@@ -0,0 +1,694 @@
+$(document).ready(function(){
+ var k = Karma({
+ audio: [{'name':'correct','file':'correct.wav'},
+ {'name':'incorrect','file':'incorrect.wav'},
+ ]});
+
+ k.ready(function(){
+ var i,j,s,t,x,flag,y,m,h;
+ var currentLesson; //variable to keep track of the current lesson
+ var clickCounter; //count the next button clicks for the particular lesson
+ var cutCounter;
+ var currentTopButton,currentLeftButton;
+ var TOTAL_QUES = 5;
+ var imgFrogCounter,frogJmpCount;
+ var imgRabbitCounter,rabbitJmpCount;
+ var timeLineLeft,timeLineInsCount;
+ var posCounter = []; // array Storing the positions of the frogs 0- frog and 1- rabbit
+ var scoreboard;
+ var lcmMethCounter;
+ var flag_frog; //flag is set if frog reaches the rabbit point
+ var maxHtFrogTop,maxHtFrogLeft,baseFrogTop,baseFrogLeft;
+ var maxHtRabbitTop,maxHtRabbitLeft,baseRabbitTop,baseRabbitLeft;
+ var currentTopButton,currentLeftButton;
+ var clickCounter; //store the click for the current lesson
+ var currentExercise;
+ var romanNums = ['i','ii','iii','iv','v'];
+ var randNumbers = [];
+ var numNumbers; //number of numbers in each quesBox
+ var levelNumbers = [45,50,3,6,7,4,24,18,15,25,24,2,20,16,8,4,11,17,12,6,7,10,18,5,2,16,5,12,9,15,
+ 13,65,21,49,37,6,28,84,243,27,248,29,95,25,65,15,25,40,105,35,300,125,900,60,76,30,31,310,225,50,
+ 17,34,51,27,28,36,6,36,216,9,81,243,2,3,4,5,3,90,64,8,1,2,56,14,12,16,18,6,2,98,70,14,49,65,13,26,78,12,9,69,4,30,60,70,40
+ ];
+ var answers = [];
+ var currentSection; //var to store the current section inside a particular exercise
+ var currentInpBox;
+ var flag_section; //flag to show the section is active
+
+ var checkTime = function(timePara){
+ if (timePara<10 ){
+ timePara="0" + timePara;
+ }
+ return timePara;
+ };
+
+ var stopTimer = function(){
+ s = 0;
+ clearTimeout(t);
+ };
+ var startTimer = function(){
+ s = 0;
+ m = 0;
+ h = 0;
+ s=checkTime(s);
+ $('#timerBox1').html(s);
+ increaseTime();
+ };
+
+
+ var increaseTime = function(){
+ if(s>59){
+ m++;
+ m=checkTime(m);
+ $('#timerBox2').html(m);
+ s = 0;
+ }
+ if(m>59){
+ h++;
+ h=checkTime(h);
+ $('#timerBox3').html(h);
+ m=0;
+ }
+
+ s=checkTime(s);
+ $('#timerBox1').html(s);
+ s++;
+ t=setTimeout(function(){increaseTime();},1000);
+
+
+ };
+ function hcf(text1,text2){
+ var gcd=1;
+ if (text1>text2) {text1=text1+text2; text2=text1-text2; text1=text1-text2;}
+ if ((text2==(Math.round(text2/text1))*text1)) {gcd=text1}else {
+ for (var i = Math.round(text1/2) ; i > 1; i=i-1) {
+ if ((text1==(Math.round(text1/i))*i))
+ if ((text2==(Math.round(text2/i))*i)) {gcd=i; i=-1;}
+ }
+ }
+ return gcd;
+ }
+
+ function lcm(t1,t2){
+ var cm=1;
+ var f=hcf(t1,t2);
+ cm=t1*t2/f;
+ return cm;
+ }
+ var genRandNumbers=function (level){
+ var lowerLimit,upperLimit;
+ if(level === 0){
+ numNumbers = 2;
+ lowerLimit = 0;
+ upperLimit = 14;
+ }else if(level === 1){
+ numNumbers = 2;
+ lowerLimit = 15;
+ upperLimit = 29;
+ }else{
+ numNumbers = 3;
+ lowerLimit = 30;
+ upperLimit = 74;
+ }
+
+ randNumbers[0] = k.rand(0,14);
+
+ for(i=0; i<= 14; i++){
+ do{
+ flag = 0;
+ randNumbers[i] = k.rand(0,14);
+ for(j=0; j<i; j++){
+ if(randNumbers[i] === randNumbers[j]){
+ flag++;
+ }
+ }
+ }while(flag != 0 ); //end of do while loop
+ }
+
+ };
+ var delayObject = function(delayId){
+ document.delayForm.delayval.value = 1;
+ //clearTimeout(t);
+ if(delayId === 0){
+ animateFrog();
+ }else if(delayId === 1){
+ animateRabbit();
+ }else if(delayId === 2){
+ showLCMmethod();
+ }
+ else{
+ animateFrog();
+ animateRabbit();
+ }
+
+ };
+
+
+ var assignLevelButtons = function(imgId){
+ var bottomPos = 0.5;
+ var leftPos =20+i*15;
+ var incI = imgId+1;
+ $('#content').append('<div class="exerciseButtons" id="exercise'+incI+'"></div>');
+ var exercisebtncss = {
+ 'bottom': bottomPos+'em',
+ 'left': leftPos+'em'
+
+ };
+ $('#exercise'+incI).css(exercisebtncss).bind({
+ click : function(){
+ currentExercise = imgId;
+ startExercise();
+ }
+ });
+ };
+ function assignQuestions(quesId){
+ $('#exerciseContainer').append('<div id="ques'+quesId+'" class="questions"></div>');
+ $('#ques'+quesId).append('<div class="romanNums">'+romanNums[quesId]+' )</div>');
+ $('#ques'+quesId).append('<div id="numbers'+quesId+'" class="numbersBox"></div>');
+ $('#ques'+quesId).append('<div class="inpBox"><input type="text" id="ans'+quesId+'" class="ansBox" /></div>');
+ $('#ques'+quesId).append('<div id="display'+quesId+'" class="displayBox"></div>');
+ var numCntr = randNumbers[numCounter]*numNumbers;
+ for(j = 0; j< numNumbers; j++){
+ if(j === numNumbers - 1){
+ $('#numbers'+quesId).append(levelNumbers[numCntr]);
+ }else{
+ $('#numbers'+quesId).append(levelNumbers[numCntr]).append(',');
+ }
+ numCntr++;
+ }
+
+ $('#ans'+quesId).addClass('default');
+ var ans;
+ if(currentExercise === 2){
+ ans = lcm(lcm(levelNumbers[numCntr-3],levelNumbers[numCntr-2]),levelNumbers[numCntr-1]);
+
+ }else{
+ ans = lcm(levelNumbers[numCntr-2],levelNumbers[numCntr-1]);
+ }
+ answers[numCounter] = ans;
+ numCounter++;
+ }
+ function nextSection(){
+
+ $('#content').html('').append('<div id="exerciseContainer"></div>');
+ $('#exerciseContainer').append('<img class="exerciseTitle" src="assets/image/exerciseTitle.png" />');
+ if(currentExercise === 0){
+ $('#exerciseContainer').append('<img class="exerciseTitle" src="assets/image/exercise1Title.png" />');
+ }else{
+ $('#exerciseContainer').append('<img class="exerciseTitle" src="assets/image/exerciseRestTitle.png" />');
+ }
+ //generate the boxes
+
+ genRandNumbers(currentExercise);
+
+ scoreboard.scoreboard('reset');
+ scoreboard.scoreboard('incTotal',5);
+
+ for(var x = 0; x< TOTAL_QUES;x++){
+ assignQuestions(x);
+ }
+
+ focus_blur();
+ $('input[type="text"]:first').focus();
+ $('#content').append('<div id="checkButton"></div>');
+ showText('checkButton','checkAns3',14,29,'<div id="chckAns3" class="checkAns"></div>');
+ showText('checkButton','showAns3',18,0,'<div id="showAns3" class="showAns"></div>');
+ showText('checkButton','moreQuesBtn',18,38,'<div id="moreQues"></div>');
+ $('#chckAns3').hide();$('#showAns3').hide();$('#moreQues').hide();
+ check_show();
+ if(currentExercise === 0){
+ $('#exerciseContainer').append('<div id="giveOptions"></div>');
+ for(var y = 0;y<5;y++){
+ $('#giveOptions').append('<div id="opt'+y+'" class="options"></div>');
+ var section = (5*currentSection)+y;
+ $('#opt'+y).text(answers[section]);
+ }
+ }
+ if(currentExercise != 0){
+ $('#timerBar').show();
+ startTimer();
+ }
+ }
+ function startExercise(){
+ flag_section = 1;
+ $('#score_box').show();
+ scoreboard = $('#score_box').scoreboard({'layout':'horizontal',
+ 'winningScore': TOTAL_QUES});
+ currentSection = 0;
+ numCounter = 0;
+
+ nextSection();
+ }
+ var nextLesson = function(){
+
+ clearTimeout(t);
+ flag_section = 0;
+ $('#score_box').hide();
+ $('#linkShowAns').hide();
+ $('#linkCheckAns').hide();
+ $('#timerBar').hide();
+ $('#content').html('').removeClass('backOpaque');
+ $('#gameOver').hide()
+ clickCounter = 0;
+
+ if(currentLesson === 2){
+ showPicture('lesson3ImgDef0','lesson3ImgDef0',0,8);
+ showPicture('lesson3ImgDef1','lesson3ImgDef1',7,25);
+ currentTopButton = 18;
+ currentLeftButton = 35;
+ showNextButton();
+ showText('content','exerciseClickTitle',17,16,'Exercise --- अभ्यास ','FF0000');
+ showText('exerciseClickTitle','line',-.5,-3.5,'_____________________');
+ for( i = 0;i<3;i++){
+ assignLevelButtons(i);
+ }
+ }
+ if(currentLesson === 1){
+ showPicture('lesson2ImgDef0','lesson2ImgDef0',0,1);
+ currentTopButton = 5;
+ currentLeftButton = 80;
+ showNextButton();
+ }
+ else if(currentLesson === 0){
+ $('#linkNextLesson').hide();
+ maxHtFrogTop = .1;
+ baseFrogTop = 2.5;
+ imgFrogCounter = 0;
+ frogJmpCount = 0;
+
+ maxHtRabbitTop = 9;
+ baseRabbitTop = 10;
+ imgRabbitCounter = 0;
+ rabbitJmpCount = 0;
+
+ flag_frog = 0;
+ timeLineInsCount = 0;
+ showPicture('imgFrogTimeline','timeLine',5,1);
+ showPicture('imgFrogAnim','frog0',2.5,2.7);
+
+ showPicture('imgRabbitTimeline','timeLine',14.5,1);
+ showPicture('imgRabbitAnim','rabbit0',10,2.7);
+
+ t=setTimeout(function(){delayObject();},1000); //gives a complete animation
+ }
+ };
+
+ function game(){
+ currentLesson = 0;
+ $('#linkNextLesson').show();
+ $('#linkPrevLesson').hide();
+ nextLesson();
+ }
+
+ //function to display the text and fraction symbols inside a div
+ function showText(parentDiv,divName,topPos,leftPos,numText,color){
+ var textCss = {
+ 'position':'absolute',
+ 'top':topPos+'em',
+ 'left':leftPos+'em',
+ 'font':'2em arial,verdana,geneva,helvetica',
+ 'color':'#'+color,
+ 'z-index':'5',
+ 'white-space':'pre'
+ };
+ $('#'+parentDiv).append('<div id="'+divName+'"></div>');
+ $('#'+divName).css(textCss).html(numText);
+ }
+ function makeAnimContainer(divName,topPos,leftPos,width,height,bgColor){
+ var fracAnimContainer = {
+ 'position':'absolute',
+ 'top': topPos+'em',
+ 'left': leftPos+'em',
+ 'width': width+'em',
+ 'height': height+'em',
+ 'background-color': '#'+bgColor
+ };
+ $('#content').append('<div id="'+divName+'"></div>');
+ $('#'+divName).css(fracAnimContainer);
+ }
+
+
+ //function that keeps the photos at a given place absolute position
+ function showPicture(divName,imgName,topPos,leftPos){
+ var imgCss = {
+ 'position':'absolute',
+ 'top':topPos+'em',
+ 'left':leftPos+'em',
+ };
+ $('#content').append('<div id="'+divName+'"></div>');
+ $('#'+divName).css(imgCss).html('<img src="assets/image/'+imgName+'.png" />');
+ }
+
+ function showNextButton(){
+ $('#content').append('<div class="nextBtn"></div>');
+ $('.nextBtn').show();
+ var nextbtncss = {
+ 'top': currentTopButton+'em',
+ 'left': currentLeftButton+'em'
+ };
+
+ $('.nextBtn').css(nextbtncss);//html('<img src="assets/image/nextBtn.png"/>');
+ $('.nextBtn').click(function(){
+ manageClicks();
+ });
+
+ }
+ function hideNextButton(){
+ $('.nextBtn').hide();
+ }
+
+
+ function showLCMmethod(){
+ if(lcmMethCounter === 0){
+ showPicture('lesson2Sign2','lesson2ImgSign',34.1,15);
+ showText('lesson2Sign2','lesson2Text2',-.1,-.6,'2 2,4');
+ }else if(lcmMethCounter === 1){
+ showText('lesson2Sign2','lesson2Text3',1,.8,'1,2');
+ }else if(lcmMethCounter === 2){
+ showPicture('lesson2ImgDef7','lesson2ImgDef7',32,25);
+ }else if(lcmMethCounter === 3){
+ showPicture('lesson2ImgDef8','lesson2ImgDef8',34.5,25);
+ }else if(lcmMethCounter === 4){
+ showPicture('lesson2ImgDef9','lesson2ImgDef9',39,20);
+ }
+ lcmMethCounter++;
+ t=setTimeout(function(){delayObject(2);},1000); //text lcm
+
+ }
+ function animateFrog(){
+
+ baseFrogLeft = 2.7 + frogJmpCount*9;
+ showPicture('imgFrogAnim','frog1',baseFrogTop-2,baseFrogLeft);
+ baseFrogLeft = 6 + frogJmpCount*9;
+ imgAnimateFrog('imgFrogAnim',maxHtFrogTop,baseFrogLeft,1000);
+
+ }
+ function animateRabbit(){
+ baseRabbitLeft = 4 + rabbitJmpCount*14;
+ showPicture('imgRabbitAnim','rabbit1',baseRabbitTop+1,baseRabbitLeft);
+ baseRabbitLeft = 10 + rabbitJmpCount*14;
+ imgAnimateRabbit('imgRabbitAnim',maxHtRabbitTop,baseRabbitLeft,1000);
+ }
+ function imgAnimateFrog(divName,topPos,leftPos,duration){
+ $('#'+divName).animate(
+ {top:topPos+'em',left:leftPos+'em'},duration,
+ function(ev){
+ if(imgFrogCounter === 0){
+ baseFrogLeft = 11.4 + frogJmpCount * 9;
+ imgFrogCounter++;
+ imgAnimateFrog('imgFrogAnim',baseFrogTop-2,baseFrogLeft,1000);
+
+ }else if(imgFrogCounter === 1){
+ showPicture('imgFrogAnim','frog0',baseFrogTop,baseFrogLeft);
+ showPicture('frogRing'+frogJmpCount,'timeRing',baseFrogTop+1.5,baseFrogLeft+1.2);
+ frogJmpCount++;
+ imgFrogCounter = 0;
+ if(frogJmpCount != 10){
+ if(frogJmpCount%3 != 0){
+ flag_frog = 0;
+ t=setTimeout(function(){delayObject(0);},1000); //frog
+ }
+ else{
+ flag_frog = 1;
+ }
+ if(flag_frog === 1){
+ flag_frog = 0;
+ timeLineLeft = 31.5 + timeLineInsCount*27;
+ showPicture('imgTimeLineIntersect'+timeLineInsCount,'timeLineIntersect',0,timeLineLeft);
+ if(frogJmpCount != 9){
+ t=setTimeout(function(){delayObject(0);},2000); //frog
+ t=setTimeout(function(){delayObject(1);},2000); //rabbit
+ }
+ else{
+ //start the lcm defintion process
+ currentTopButton = 21;
+ currentLeftButton = 80;
+ showNextButton();
+ showPicture('imgLesson1ImgDef0','lesson1ImgDef0',21,18);
+ }
+ timeLineInsCount++;
+ }
+ }
+
+ }
+ });
+ }
+
+ function imgAnimateRabbit(divName,topPos,leftPos,duration){
+ $('#'+divName).animate(
+ {top:topPos+'em',left:leftPos+'em'},duration,
+ function(ev){
+ if(imgRabbitCounter === 0){
+ baseRabbitLeft = 15.5 + rabbitJmpCount * 13.5;
+ imgRabbitCounter++;
+ imgAnimateRabbit('imgRabbitAnim',baseRabbitTop,baseRabbitLeft,1000);
+ }else if(imgRabbitCounter === 1){
+ showPicture('imgRabbitAnim','rabbit0',baseRabbitTop,baseRabbitLeft);
+ showPicture('imgRabbitAnim'+rabbitJmpCount,'timeRing',baseRabbitTop+3.5,baseRabbitLeft+1.5);
+ rabbitJmpCount++;
+ imgRabbitCounter = 0;
+ if(rabbitJmpCount%2 != 0 ){
+ t=setTimeout(function(){delayObject(1);},1000); //frog
+ }
+ }
+
+ });
+ }
+
+ function manageClicks(){
+ if(currentLesson === 2){
+ if(clickCounter === 0){
+ showPicture('lesson3ImgDef2','lesson3ImgDef2',9,0);
+ showText('lesson3ImgDef2','lesson3inputText1',5,0,'<input type="text" id="lesson3input1" class="inputBox" />');
+ showText('lesson3ImgDef2','symChecked1',5,4,'');
+ focus_blur();
+ $('#lesson3input1').focus();
+ showText('lesson3ImgDef2','checkAns1',6.5,-1,'<div id="chckAns1" class="checkAns"></div>');
+ showText('lesson3ImgDef2','shownAns1',6.5,4,'<div id="showAns1" class="showAns"></div>');
+ check_show();
+ hideNextButton();
+ }else if(clickCounter === 1){
+ showPicture('lesson3ImgDef3','lesson3ImgDef3',9,65);
+ showText('lesson3ImgDef3','lesson3inputText2',5,0,'<input type="text" id="lesson3input2" class="inputBox" />');
+ showText('lesson3ImgDef3','symChecked2',5,4,'');
+ focus_blur();
+ $('#lesson3input2').focus();
+ showText('lesson3ImgDef3','checkAns2',6.5,-1,'<div id="chckAns2" class="checkAns"></div>');
+ showText('lesson3ImgDef3','shownAns2',6.5,4,'<div id="showAns2" class="showAns"></div>');
+ check_show();
+ hideNextButton();
+ }else if(clickCounter === 2){
+ showPicture('lesson3ImgDef4','lesson3ImgDef4',22,28);
+ }
+ else if(clickCounter === 3){
+ showPicture('lesson3ImgDef5','lesson3ImgDef5',28,15);
+ hideNextButton();
+ }
+ }
+ else if(currentLesson === 1){
+ if(clickCounter === 0){
+ showPicture('lesson2ImgDef1','lesson2ImgDef1',10,1);
+ }else if(clickCounter === 1){
+ showPicture('lesson2ImgDef2','lesson2ImgDef2',13,1);
+ }else if(clickCounter === 2){
+ showPicture('lesson2ImgDef3','lesson2ImgDef3',15.5,1);
+ }else if(clickCounter === 3){
+ showPicture('lesson2ImgDef4','lesson2ImgDef4',25,1);
+ }else if(clickCounter === 4){
+ showPicture('lesson2ImgDef5','lesson2ImgDef5',27,1);
+ }else if(clickCounter === 5){
+ showPicture('lesson2ImgDef6','lesson2ImgDef6',29.5,10);
+ }else if(clickCounter === 6){
+ lcmMethCounter =0;
+ showPicture('lesson2Sign1','lesson2ImgSign',32,15);
+ showText('lesson2Sign1','lesson2Text1',-.1,-.6,'2 4,8');
+ t=setTimeout(function(){delayObject(2);},1000); //text lcm
+ hideNextButton();
+ }
+ }
+
+ else if(currentLesson === 0){
+ if(clickCounter === 0){
+ $('#linkNextLesson').show();
+ showPicture('imgLesson1ImgDef1','lesson1ImgDef1',24.5,18);
+ }else if(clickCounter === 1){
+ showPicture('imgLesson1ImgDef2','lesson1ImgDef2',28,18);
+ }else if(clickCounter === 2){
+ showPicture('imgLesson1ImgDef3','lesson1ImgDef3',31.5,18);
+ }else if(clickCounter === 3){
+ showPicture('imgLesson1ImgDef4','lesson1ImgDef4',36,20);
+ hideNextButton();
+ }
+ }
+ clickCounter++;
+ }
+
+ function check_show(){
+ $('.checkAns').click(function(){
+ var checkId = $(this).attr('id');
+ var checkId = parseInt(checkId.substring(7));;
+ if(checkId === 1){
+ if($('#lesson3input1').val() == '7'){
+ k.audio.correct.play();
+ $('#symChecked1').html('<img src="assets/image/correct.png" />');
+ }else{
+ k.audio.incorrect.play();
+ $('#symChecked1').html('<img src="assets/image/incorrect.png" />');
+ }
+ }else if(checkId === 2){
+ if($('#lesson3input2').val() == '1,3,7'){
+ k.audio.correct.play();
+ $('#symChecked2').html('<img src="assets/image/correct.png" />');
+ }else{
+ k.audio.incorrect.play();
+ $('#symChecked2').html('<img src="assets/image/incorrect.png" />');
+ }
+ }else if(checkId === 3){
+ for( i = 0; i<5;i++){
+ var section = (5*currentSection)+i;
+ var answer = $('#ans'+i).val();
+ if(answers[section] == answer){
+ $('#display'+i).html('<img src="assets/image/correct.png" />');
+ scoreboard.scoreboard('inc');
+ }else{
+ $('#display'+i).html('<img src="assets/image/incorrect.png" />');
+ }
+ }
+ $('#chckAns3').hide();
+ $('#showAns3').show();
+ if(currentSection != 2){
+ $('#moreQues').show();
+ }
+ stopTimer();
+ }
+ });
+
+
+ $('.showAns').click(function(){
+ var showId = $(this).attr('id');
+ var showId = parseInt(showId.substring(7));
+ if(showId === 1){
+ $('#lesson3input1').val(7)
+ $('#symChecked1').html('<img src="assets/image/correct.png" />');
+ showNextButton();
+ }else if(showId === 2){
+ $('#lesson3input2').val('1,3,7')
+ $('#symChecked2').html('<img src="assets/image/correct.png" />');
+ showNextButton();
+ }else if(showId === 3){
+ for( i = 0; i<5;i++){
+ var section = (5*currentSection)+i;
+ $('#ans'+i).val(answers[section]);
+ $('#display'+i).html('<img src="assets/image/correct.png" />');
+ }
+ $('#showAns3').hide();
+ }
+
+ });
+
+ $('#moreQues').click(function(){
+ currentSection++;
+ nextSection();
+ $('#moreQues').hide();
+ });
+ }
+
+
+ function focus_blur(){
+ $('input[type="text"]')
+ .focus(function() {
+
+ $(this).addClass("focus");
+
+ currentInpBox = $(this).attr("id");
+ currentInpBox = parseInt(currentInpBox.substring(3));
+
+ })
+ .blur(function() {
+ var countBox = 0;
+ $(this).removeClass("focus");
+ for(i = 0;i<5;i++){
+ if($('#ans'+i).val() != ''){
+ countBox++;
+ }
+ }
+ if(countBox === 5){
+ //show check button
+ $('#chckAns3').show();
+ }
+ })
+ .keypress(function(event) {
+ if(event.which === 13){
+ //$(this).removeClass("focus");
+ if(currentInpBox != 4){
+ $('#ans'+currentInpBox).blur();
+ }
+ var currentInpBoxnext = currentInpBox+1;
+ $('#ans'+currentInpBoxnext).focus();
+ }
+ });
+
+ }
+ $('#linkNextLesson').click(function(){
+ currentLesson++;
+ if(currentLesson === 2){
+ $('#linkNextLesson').hide();
+ $('#linkPrevLesson').show();
+ }
+ else{
+ $('#linkNextLesson').show();
+ $('#linkPrevLesson').show();
+ }
+
+ nextLesson();
+ });
+ $('#linkPrevLesson').click(function(){
+
+ if(currentLesson === 2 && flag_section === 1){
+ currentLesson = 2;
+ nextLesson();
+ }else{
+ currentLesson--;
+ if(currentLesson === 0){
+ $('#linkPrevLesson').hide();
+ }
+ else{
+ $('#linkNextLesson').show();
+ $('#linkPrevLesson').show();
+ }
+ nextLesson();
+ }
+
+
+ });
+
+ $('#linkStart').click(function(){
+ game();
+ });
+
+ $('#linkPlayAgain').click(function(){
+ //nextLesson();
+ nextLesson();
+ });
+
+
+
+ $('#linkShowAns').hide();
+ $('#linkCheckAns').hide();
+ $('#linkNextLesson').hide();
+ $('#linkPrevLesson').hide();
+ $('#linkHelp').click(function(){
+ $('#help').slideDown(2000);
+ })
+ .mouseout(function(){
+ $('#help').slideUp(2000);
+ });
+
+
+
+
+
+ }); //end of k.ready
+}); //end of document.read
+
+
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/js/ui.core.js b/examples/lessons/6_Maths_lowestCommonMultiple/js/ui.core.js
new file mode 100755
index 0000000..5493e0a
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/js/ui.core.js
@@ -0,0 +1,519 @@
+/*
+ * jQuery UI 1.7.2
+ *
+ * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * http://docs.jquery.com/UI
+ */
+;jQuery.ui || (function($) {
+
+var _remove = $.fn.remove,
+ isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9);
+
+//Helper functions and ui object
+$.ui = {
+ version: "1.7.2",
+
+ // $.ui.plugin is deprecated. Use the proxy pattern instead.
+ plugin: {
+ add: function(module, option, set) {
+ var proto = $.ui[module].prototype;
+ for(var i in set) {
+ proto.plugins[i] = proto.plugins[i] || [];
+ proto.plugins[i].push([option, set[i]]);
+ }
+ },
+ call: function(instance, name, args) {
+ var set = instance.plugins[name];
+ if(!set || !instance.element[0].parentNode) { return; }
+
+ for (var i = 0; i < set.length; i++) {
+ if (instance.options[set[i][0]]) {
+ set[i][1].apply(instance.element, args);
+ }
+ }
+ }
+ },
+
+ contains: function(a, b) {
+ return document.compareDocumentPosition
+ ? a.compareDocumentPosition(b) & 16
+ : a !== b && a.contains(b);
+ },
+
+ hasScroll: function(el, a) {
+
+ //If overflow is hidden, the element might have extra content, but the user wants to hide it
+ if ($(el).css('overflow') == 'hidden') { return false; }
+
+ var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop',
+ has = false;
+
+ if (el[scroll] > 0) { return true; }
+
+ // TODO: determine which cases actually cause this to happen
+ // if the element doesn't have the scroll set, see if it's possible to
+ // set the scroll
+ el[scroll] = 1;
+ has = (el[scroll] > 0);
+ el[scroll] = 0;
+ return has;
+ },
+
+ isOverAxis: function(x, reference, size) {
+ //Determines when x coordinate is over "b" element axis
+ return (x > reference) && (x < (reference + size));
+ },
+
+ isOver: function(y, x, top, left, height, width) {
+ //Determines when x, y coordinates is over "b" element
+ return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width);
+ },
+
+ keyCode: {
+ BACKSPACE: 8,
+ CAPS_LOCK: 20,
+ COMMA: 188,
+ CONTROL: 17,
+ DELETE: 46,
+ DOWN: 40,
+ END: 35,
+ ENTER: 13,
+ ESCAPE: 27,
+ HOME: 36,
+ INSERT: 45,
+ LEFT: 37,
+ NUMPAD_ADD: 107,
+ NUMPAD_DECIMAL: 110,
+ NUMPAD_DIVIDE: 111,
+ NUMPAD_ENTER: 108,
+ NUMPAD_MULTIPLY: 106,
+ NUMPAD_SUBTRACT: 109,
+ PAGE_DOWN: 34,
+ PAGE_UP: 33,
+ PERIOD: 190,
+ RIGHT: 39,
+ SHIFT: 16,
+ SPACE: 32,
+ TAB: 9,
+ UP: 38
+ }
+};
+
+// WAI-ARIA normalization
+if (isFF2) {
+ var attr = $.attr,
+ removeAttr = $.fn.removeAttr,
+ ariaNS = "http://www.w3.org/2005/07/aaa",
+ ariaState = /^aria-/,
+ ariaRole = /^wairole:/;
+
+ $.attr = function(elem, name, value) {
+ var set = value !== undefined;
+
+ return (name == 'role'
+ ? (set
+ ? attr.call(this, elem, name, "wairole:" + value)
+ : (attr.apply(this, arguments) || "").replace(ariaRole, ""))
+ : (ariaState.test(name)
+ ? (set
+ ? elem.setAttributeNS(ariaNS,
+ name.replace(ariaState, "aaa:"), value)
+ : attr.call(this, elem, name.replace(ariaState, "aaa:")))
+ : attr.apply(this, arguments)));
+ };
+
+ $.fn.removeAttr = function(name) {
+ return (ariaState.test(name)
+ ? this.each(function() {
+ this.removeAttributeNS(ariaNS, name.replace(ariaState, ""));
+ }) : removeAttr.call(this, name));
+ };
+}
+
+//jQuery plugins
+$.fn.extend({
+ remove: function() {
+ // Safari has a native remove event which actually removes DOM elements,
+ // so we have to use triggerHandler instead of trigger (#3037).
+ $("*", this).add(this).each(function() {
+ $(this).triggerHandler("remove");
+ });
+ return _remove.apply(this, arguments );
+ },
+
+ enableSelection: function() {
+ return this
+ .attr('unselectable', 'off')
+ .css('MozUserSelect', '')
+ .unbind('selectstart.ui');
+ },
+
+ disableSelection: function() {
+ return this
+ .attr('unselectable', 'on')
+ .css('MozUserSelect', 'none')
+ .bind('selectstart.ui', function() { return false; });
+ },
+
+ scrollParent: function() {
+ var scrollParent;
+ if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
+ scrollParent = this.parents().filter(function() {
+ return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
+ }).eq(0);
+ } else {
+ scrollParent = this.parents().filter(function() {
+ return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
+ }).eq(0);
+ }
+
+ return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
+ }
+});
+
+
+//Additional selectors
+$.extend($.expr[':'], {
+ data: function(elem, i, match) {
+ return !!$.data(elem, match[3]);
+ },
+
+ focusable: function(element) {
+ var nodeName = element.nodeName.toLowerCase(),
+ tabIndex = $.attr(element, 'tabindex');
+ return (/input|select|textarea|button|object/.test(nodeName)
+ ? !element.disabled
+ : 'a' == nodeName || 'area' == nodeName
+ ? element.href || !isNaN(tabIndex)
+ : !isNaN(tabIndex))
+ // the element and all of its ancestors must be visible
+ // the browser may report that the area is hidden
+ && !$(element)['area' == nodeName ? 'parents' : 'closest'](':hidden').length;
+ },
+
+ tabbable: function(element) {
+ var tabIndex = $.attr(element, 'tabindex');
+ return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(':focusable');
+ }
+});
+
+
+// $.widget is a factory to create jQuery plugins
+// taking some boilerplate code out of the plugin code
+function getter(namespace, plugin, method, args) {
+ function getMethods(type) {
+ var methods = $[namespace][plugin][type] || [];
+ return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods);
+ }
+
+ var methods = getMethods('getter');
+ if (args.length == 1 && typeof args[0] == 'string') {
+ methods = methods.concat(getMethods('getterSetter'));
+ }
+ return ($.inArray(method, methods) != -1);
+}
+
+$.widget = function(name, prototype) {
+ var namespace = name.split(".")[0];
+ name = name.split(".")[1];
+
+ // create plugin method
+ $.fn[name] = function(options) {
+ var isMethodCall = (typeof options == 'string'),
+ args = Array.prototype.slice.call(arguments, 1);
+
+ // prevent calls to internal methods
+ if (isMethodCall && options.substring(0, 1) == '_') {
+ return this;
+ }
+
+ // handle getter methods
+ if (isMethodCall && getter(namespace, name, options, args)) {
+ var instance = $.data(this[0], name);
+ return (instance ? instance[options].apply(instance, args)
+ : undefined);
+ }
+
+ // handle initialization and non-getter methods
+ return this.each(function() {
+ var instance = $.data(this, name);
+
+ // constructor
+ (!instance && !isMethodCall &&
+ $.data(this, name, new $[namespace][name](this, options))._init());
+
+ // method call
+ (instance && isMethodCall && $.isFunction(instance[options]) &&
+ instance[options].apply(instance, args));
+ });
+ };
+
+ // create widget constructor
+ $[namespace] = $[namespace] || {};
+ $[namespace][name] = function(element, options) {
+ var self = this;
+
+ this.namespace = namespace;
+ this.widgetName = name;
+ this.widgetEventPrefix = $[namespace][name].eventPrefix || name;
+ this.widgetBaseClass = namespace + '-' + name;
+
+ this.options = $.extend({},
+ $.widget.defaults,
+ $[namespace][name].defaults,
+ $.metadata && $.metadata.get(element)[name],
+ options);
+
+ this.element = $(element)
+ .bind('setData.' + name, function(event, key, value) {
+ if (event.target == element) {
+ return self._setData(key, value);
+ }
+ })
+ .bind('getData.' + name, function(event, key) {
+ if (event.target == element) {
+ return self._getData(key);
+ }
+ })
+ .bind('remove', function() {
+ return self.destroy();
+ });
+ };
+
+ // add widget prototype
+ $[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype);
+
+ // TODO: merge getter and getterSetter properties from widget prototype
+ // and plugin prototype
+ $[namespace][name].getterSetter = 'option';
+};
+
+$.widget.prototype = {
+ _init: function() {},
+ destroy: function() {
+ this.element.removeData(this.widgetName)
+ .removeClass(this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled')
+ .removeAttr('aria-disabled');
+ },
+
+ option: function(key, value) {
+ var options = key,
+ self = this;
+
+ if (typeof key == "string") {
+ if (value === undefined) {
+ return this._getData(key);
+ }
+ options = {};
+ options[key] = value;
+ }
+
+ $.each(options, function(key, value) {
+ self._setData(key, value);
+ });
+ },
+ _getData: function(key) {
+ return this.options[key];
+ },
+ _setData: function(key, value) {
+ this.options[key] = value;
+
+ if (key == 'disabled') {
+ this.element
+ [value ? 'addClass' : 'removeClass'](
+ this.widgetBaseClass + '-disabled' + ' ' +
+ this.namespace + '-state-disabled')
+ .attr("aria-disabled", value);
+ }
+ },
+
+ enable: function() {
+ this._setData('disabled', false);
+ },
+ disable: function() {
+ this._setData('disabled', true);
+ },
+
+ _trigger: function(type, event, data) {
+ var callback = this.options[type],
+ eventName = (type == this.widgetEventPrefix
+ ? type : this.widgetEventPrefix + type);
+
+ event = $.Event(event);
+ event.type = eventName;
+
+ // copy original event properties over to the new event
+ // this would happen if we could call $.event.fix instead of $.Event
+ // but we don't have a way to force an event to be fixed multiple times
+ if (event.originalEvent) {
+ for (var i = $.event.props.length, prop; i;) {
+ prop = $.event.props[--i];
+ event[prop] = event.originalEvent[prop];
+ }
+ }
+
+ this.element.trigger(event, data);
+
+ return !($.isFunction(callback) && callback.call(this.element[0], event, data) === false
+ || event.isDefaultPrevented());
+ }
+};
+
+$.widget.defaults = {
+ disabled: false
+};
+
+
+/** Mouse Interaction Plugin **/
+
+$.ui.mouse = {
+ _mouseInit: function() {
+ var self = this;
+
+ this.element
+ .bind('mousedown.'+this.widgetName, function(event) {
+ return self._mouseDown(event);
+ })
+ .bind('click.'+this.widgetName, function(event) {
+ if(self._preventClickEvent) {
+ self._preventClickEvent = false;
+ event.stopImmediatePropagation();
+ return false;
+ }
+ });
+
+ // Prevent text selection in IE
+ if ($.browser.msie) {
+ this._mouseUnselectable = this.element.attr('unselectable');
+ this.element.attr('unselectable', 'on');
+ }
+
+ this.started = false;
+ },
+
+ // TODO: make sure destroying one instance of mouse doesn't mess with
+ // other instances of mouse
+ _mouseDestroy: function() {
+ this.element.unbind('.'+this.widgetName);
+
+ // Restore text selection in IE
+ ($.browser.msie
+ && this.element.attr('unselectable', this._mouseUnselectable));
+ },
+
+ _mouseDown: function(event) {
+ // don't let more than one widget handle mouseStart
+ // TODO: figure out why we have to use originalEvent
+ event.originalEvent = event.originalEvent || {};
+ if (event.originalEvent.mouseHandled) { return; }
+
+ // we may have missed mouseup (out of window)
+ (this._mouseStarted && this._mouseUp(event));
+
+ this._mouseDownEvent = event;
+
+ var self = this,
+ btnIsLeft = (event.which == 1),
+ elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false);
+ if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
+ return true;
+ }
+
+ this.mouseDelayMet = !this.options.delay;
+ if (!this.mouseDelayMet) {
+ this._mouseDelayTimer = setTimeout(function() {
+ self.mouseDelayMet = true;
+ }, this.options.delay);
+ }
+
+ if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+ this._mouseStarted = (this._mouseStart(event) !== false);
+ if (!this._mouseStarted) {
+ event.preventDefault();
+ return true;
+ }
+ }
+
+ // these delegates are required to keep context
+ this._mouseMoveDelegate = function(event) {
+ return self._mouseMove(event);
+ };
+ this._mouseUpDelegate = function(event) {
+ return self._mouseUp(event);
+ };
+ $(document)
+ .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
+ .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
+
+ // preventDefault() is used to prevent the selection of text here -
+ // however, in Safari, this causes select boxes not to be selectable
+ // anymore, so this fix is needed
+ ($.browser.safari || event.preventDefault());
+
+ event.originalEvent.mouseHandled = true;
+ return true;
+ },
+
+ _mouseMove: function(event) {
+ // IE mouseup check - mouseup happened when mouse was out of window
+ if ($.browser.msie && !event.button) {
+ return this._mouseUp(event);
+ }
+
+ if (this._mouseStarted) {
+ this._mouseDrag(event);
+ return event.preventDefault();
+ }
+
+ if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+ this._mouseStarted =
+ (this._mouseStart(this._mouseDownEvent, event) !== false);
+ (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
+ }
+
+ return !this._mouseStarted;
+ },
+
+ _mouseUp: function(event) {
+ $(document)
+ .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
+ .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
+
+ if (this._mouseStarted) {
+ this._mouseStarted = false;
+ this._preventClickEvent = (event.target == this._mouseDownEvent.target);
+ this._mouseStop(event);
+ }
+
+ return false;
+ },
+
+ _mouseDistanceMet: function(event) {
+ return (Math.max(
+ Math.abs(this._mouseDownEvent.pageX - event.pageX),
+ Math.abs(this._mouseDownEvent.pageY - event.pageY)
+ ) >= this.options.distance
+ );
+ },
+
+ _mouseDelayMet: function(event) {
+ return this.mouseDelayMet;
+ },
+
+ // These are placeholder methods, to be overriden by extending plugin
+ _mouseStart: function(event) {},
+ _mouseDrag: function(event) {},
+ _mouseStop: function(event) {},
+ _mouseCapture: function(event) { return true; }
+};
+
+$.ui.mouse.defaults = {
+ cancel: null,
+ distance: 1,
+ delay: 0
+};
+
+})(jQuery);
diff --git a/examples/lessons/6_Maths_lowestCommonMultiple/js/ui.scoreboard.js b/examples/lessons/6_Maths_lowestCommonMultiple/js/ui.scoreboard.js
new file mode 100755
index 0000000..53a930a
--- /dev/null
+++ b/examples/lessons/6_Maths_lowestCommonMultiple/js/ui.scoreboard.js
@@ -0,0 +1,107 @@
+(function($){
+ $.widget('ui.scoreboard',
+ {
+ getScore : function(){
+ return this._getData('score');
+ },
+ setScore : function(newScore){
+ this._setData('score', parseInt(newScore));
+ this._refresh();
+ },
+ getTotal : function(){
+ return this._getData('total');
+ },
+ setTotal : function(newTotal){
+ this._setData('total', parseInt(newTotal));
+ this._refresh();
+ },
+ reset : function(){
+ this._setData('score', this._getData('initialScore'));
+ this._setData('total', this._getData('initialTotal'));
+ this._refresh();
+ },
+ inc : function(val){
+ var incVal = parseInt(val) || 1;
+ this._setData('score', this._getData('score') + incVal);
+ this._refresh();
+ if(this._getData('winScore') === this._getData('score')){
+ this.element.trigger('winGame');
+ }
+ },
+ incTotal : function(val){
+ var incVal = parseInt(val) || 1;
+ this._setData('total', this._getData('total') + incVal);
+ this._refresh();
+ },
+ dec : function(val){
+ var decVal = parseInt(val) || 1;
+ this._setData('score', this._getData('score') - decVal);
+ this._refresh();
+ },
+ decTotal : function(val){
+ var decVal = parseInt(val) || 1;
+ this._setData('total', this._getData('total') - decVal);
+ this._refresh();
+ },
+ _init : function(){
+
+ var divDisplay = "inline";
+ var score = this.options.score;
+ var total = this.options.total;
+ var layoutId = "h";
+ var self = this;
+
+
+ this._setData('initialScore', parseInt(this.options.score));
+ this._setData('initialTotal', parseInt(this.options.total));
+ this._setData('score', parseInt(this.options.score));
+ this._setData('total', parseInt(this.options.total));
+ this._setData('winScore', parseInt(this.options.winningScore) || 0);
+
+ if(this.options.layout === "vertical"){
+ layoutId = "v";
+ }
+
+ this.evWinGame = document.createEvent('Events');
+
+ this.element.addClass('ui-scoreboard-container-' + layoutId +
+ ' ui-widget ui-widget-content ui-corner-all');
+
+ var clone = $('<div>')
+ .addClass('ui-scoreboard-spacing-' + layoutId);
+ this._scoreText = $("<div>Score</div>")
+ .addClass('ui-scoreboard-spacing-'+ layoutId +
+ ' ui-corner-all ui-scoreboard-text')
+ .appendTo(this.element);
+ this._score = $("<div>" + score + "</div>")
+ .addClass('ui-scoreboard-spacing-' + layoutId +
+ ' ui-scoreboard-number-' + layoutId)
+ .appendTo(this.element);
+ $("<div>Total</div>")
+ .addClass('ui-scoreboard-spacing-' + layoutId +
+ ' ui-corner-all ' +
+ 'ui-scoreboard-text')
+ .appendTo(this.element);
+ this._total = $("<div>" + total + "</div>")
+ .addClass('ui-scoreboard-spacing-' + layoutId +
+ ' ui-scoreboard-number-' + layoutId)
+ .appendTo(this.element);
+ },
+ _refresh : function(){
+ this._score.text(this._getData('score'));
+ this._total.text(this._getData('total'));
+ },
+ destroy : function(){
+ this.element.remove();
+ $.widget.prototype.destroy.apply(this, arguments);
+ }
+
+
+ });
+
+ $.ui.scoreboard.getter = ['getScore', 'getTotal'];
+ $.ui.scoreboard.defaults = {
+ score: 0, total: 0, layout: "horizontal", winningScore: 0
+ };
+
+ })(jQuery); \ No newline at end of file
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/audio/correct.wav b/examples/lessons/6_Maths_multiplyingFractions/assets/audio/correct.wav
new file mode 100755
index 0000000..a49ba33
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/audio/correct.wav
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/audio/incorrect.wav b/examples/lessons/6_Maths_multiplyingFractions/assets/audio/incorrect.wav
new file mode 100755
index 0000000..906c6a3
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/audio/incorrect.wav
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/afterSimplify.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/afterSimplify.png
new file mode 100755
index 0000000..17408ad
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/afterSimplify.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/beforeSimplify.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/beforeSimplify.png
new file mode 100755
index 0000000..5299c50
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/beforeSimplify.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/bg_footer.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/bg_footer.png
new file mode 100755
index 0000000..8982264
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/bg_footer.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/bg_header.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/bg_header.png
new file mode 100755
index 0000000..98213f7
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/bg_header.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/bg_title_block.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/bg_title_block.png
new file mode 100755
index 0000000..2c9dacf
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/bg_title_block.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_back.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_back.png
new file mode 100755
index 0000000..d9fbf14
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_back.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_back_hover.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_back_hover.png
new file mode 100755
index 0000000..0911fcc
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_back_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_help.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_help.png
new file mode 100755
index 0000000..6753e9c
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_help.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_help_hover.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_help_hover.png
new file mode 100755
index 0000000..d3ccd92
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_help_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_next.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_next.png
new file mode 100755
index 0000000..9d70993
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_next.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_next_hover.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_next_hover.png
new file mode 100755
index 0000000..2cd4d37
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_next_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_ole.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_ole.png
new file mode 100755
index 0000000..0e775e9
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_ole.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_ole_hover.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_ole_hover.png
new file mode 100755
index 0000000..c43c5f7
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_ole_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_play_again.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_play_again.png
new file mode 100755
index 0000000..3594d18
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_play_again.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_play_again_hover.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_play_again_hover.png
new file mode 100755
index 0000000..ebb8f8c
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_play_again_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_play_again_mouse_down.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_play_again_mouse_down.png
new file mode 100755
index 0000000..07d6e45
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_play_again_mouse_down.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_start.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_start.png
new file mode 100755
index 0000000..32e5f20
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_start.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_start_hover.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_start_hover.png
new file mode 100755
index 0000000..811ce78
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_start_hover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_start_mouse_down.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_start_mouse_down.png
new file mode 100755
index 0000000..5acd43b
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/btn_start_mouse_down.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/check.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/check.png
new file mode 100755
index 0000000..bd0afcb
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/check.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/checkAnsBtn.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/checkAnsBtn.png
new file mode 100755
index 0000000..b7c80d3
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/checkAnsBtn.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/checkAnsBtnHover.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/checkAnsBtnHover.png
new file mode 100755
index 0000000..a0e6b6d
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/checkAnsBtnHover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/correct.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/correct.png
new file mode 100755
index 0000000..7e15698
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/correct.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/help.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/help.png
new file mode 100755
index 0000000..54e73d4
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/help.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/img1FractionTotal.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/img1FractionTotal.png
new file mode 100755
index 0000000..1e475ec
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/img1FractionTotal.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/img2FractionTotal.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/img2FractionTotal.png
new file mode 100755
index 0000000..d8f124b
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/img2FractionTotal.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/incorrect.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/incorrect.png
new file mode 100755
index 0000000..e60c32d
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/incorrect.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/leso.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/leso.png
new file mode 100755
index 0000000..5a095ce
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/leso.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgDef1.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgDef1.png
new file mode 100755
index 0000000..b9c002d
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgDef1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgDef2.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgDef2.png
new file mode 100755
index 0000000..ff4000d
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgDef2.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgDown.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgDown.png
new file mode 100755
index 0000000..fd2935d
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgDown.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgFractions.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgFractions.png
new file mode 100755
index 0000000..dab5d3d
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgFractions.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgPart1.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgPart1.png
new file mode 100755
index 0000000..2bab07f
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgPart1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgPart2.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgPart2.png
new file mode 100755
index 0000000..9e31413
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1ImgPart2.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1frac1.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1frac1.png
new file mode 100755
index 0000000..ddf44e7
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson1frac1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgDef1.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgDef1.png
new file mode 100755
index 0000000..0a4c488
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgDef1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgDef2.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgDef2.png
new file mode 100755
index 0000000..b503616
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgDef2.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgDef3.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgDef3.png
new file mode 100755
index 0000000..062c454
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgDef3.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgDef4.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgDef4.png
new file mode 100755
index 0000000..4a7bbc2
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgDef4.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgFractions.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgFractions.png
new file mode 100755
index 0000000..5b16e52
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgFractions.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgPart1.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgPart1.png
new file mode 100755
index 0000000..c61414a
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgPart1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgPart2.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgPart2.png
new file mode 100755
index 0000000..b8848d3
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2ImgPart2.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2frac1.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2frac1.png
new file mode 100755
index 0000000..1a812ce
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2frac1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2frac2.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2frac2.png
new file mode 100755
index 0000000..fe9d37f
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2frac2.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2frac3.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2frac3.png
new file mode 100755
index 0000000..e4f1480
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson2frac3.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson3Img1.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson3Img1.png
new file mode 100755
index 0000000..ffba023
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson3Img1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson3Img2.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson3Img2.png
new file mode 100755
index 0000000..9ef4488
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson3Img2.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson3Img3.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson3Img3.png
new file mode 100755
index 0000000..193ff4f
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson3Img3.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson3ImgPart1.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson3ImgPart1.png
new file mode 100755
index 0000000..31233ef
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson3ImgPart1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson3ImgPart2.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson3ImgPart2.png
new file mode 100755
index 0000000..d5f46ab
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson3ImgPart2.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4Img1.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4Img1.png
new file mode 100755
index 0000000..64a3215
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4Img1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4Img2.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4Img2.png
new file mode 100755
index 0000000..5b2a042
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4Img2.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4Img3.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4Img3.png
new file mode 100755
index 0000000..0292c9b
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4Img3.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4ImgDef1.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4ImgDef1.png
new file mode 100755
index 0000000..8468820
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4ImgDef1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4ImgDef2.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4ImgDef2.png
new file mode 100755
index 0000000..4712a40
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4ImgDef2.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4ImgDef3.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4ImgDef3.png
new file mode 100755
index 0000000..098c531
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4ImgDef3.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4ImgDef4.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4ImgDef4.png
new file mode 100755
index 0000000..a4d8015
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson4ImgDef4.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6Img1.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6Img1.png
new file mode 100755
index 0000000..2cebb8c
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6Img1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6ImgDef1.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6ImgDef1.png
new file mode 100755
index 0000000..0e8bd43
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6ImgDef1.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6ImgDef2.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6ImgDef2.png
new file mode 100755
index 0000000..3e9c971
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6ImgDef2.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6ImgDef3.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6ImgDef3.png
new file mode 100755
index 0000000..2fe8a94
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6ImgDef3.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6ImgDef4.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6ImgDef4.png
new file mode 100755
index 0000000..d3c14aa
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6ImgDef4.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6ImgDef5.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6ImgDef5.png
new file mode 100755
index 0000000..cf2deb1
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/lesson6ImgDef5.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/nextBtn.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/nextBtn.png
new file mode 100755
index 0000000..081ef58
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/nextBtn.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/nextBtnHover.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/nextBtnHover.png
new file mode 100755
index 0000000..498ce32
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/nextBtnHover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/showAnsBtn.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/showAnsBtn.png
new file mode 100755
index 0000000..7f3d720
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/showAnsBtn.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/showAnsBtnHover.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/showAnsBtnHover.png
new file mode 100755
index 0000000..3d6907c
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/showAnsBtnHover.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/title_block_lt.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/title_block_lt.png
new file mode 100755
index 0000000..4696182
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/title_block_lt.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/assets/image/title_block_rt.png b/examples/lessons/6_Maths_multiplyingFractions/assets/image/title_block_rt.png
new file mode 100755
index 0000000..37cc44a
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/assets/image/title_block_rt.png
Binary files differ
diff --git a/examples/lessons/6_Maths_multiplyingFractions/css/lesson.css b/examples/lessons/6_Maths_multiplyingFractions/css/lesson.css
new file mode 100755
index 0000000..1ed5002
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/css/lesson.css
@@ -0,0 +1,339 @@
+@CHARSET "UTF-8";
+/****** Page Styles ****/
+
+/* Designed for 1200*900 px screen resolution */
+*{
+ margin:0;
+}
+body {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 10pt;
+ margin: 0px;
+ background-color: #FFFFCC;
+}
+#header {
+ background-image: url(../assets/image/bg_header.png);
+ background-repeat: repeat-x;
+ height: 75px;
+ width: 100%;
+ position: absolute;
+ left: 0px;
+ top: 0px;
+}
+#topbtn_left {
+ float: left;
+ height: 60px;
+ width: 60px;
+ padding-top: 6px;
+ padding-left: 15px;
+}
+
+
+ .linkBack{
+ width: 60px; height: 59px;
+ background:url(../assets/image/btn_back.png);
+ }
+ .linkBack:hover{
+ background:url(../assets/image/btn_back_hover.png);
+ }
+
+#lesson_title {
+ float: left;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 16pt;
+ font-weight: bold;
+ color: #FFFFFF;
+ margin-left: 10px;
+ background-image: url(../assets/image/bg_title_block.png);
+}
+#topbtn_right {
+ float: right;
+ height: 60px;
+ width: 60px;
+ padding-top: 6px;
+ padding-right: 15px;
+}
+ #linkHelp{
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_help.png);
+ }
+ #linkHelp:hover{
+ background:url(../assets/image/btn_help_hover.png);
+ }
+ #linkOle{
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_ole.png);
+ }
+ #linkOle:hover{
+ background:url(../assets/image/btn_ole_hover.png);
+ }
+ .linkNext{
+ width: 60px; height: 60px;
+ background:url(../assets/image/btn_next.png);
+ }
+ .linkNext:hover{
+ background:url(../assets/image/btn_next_hover.png);
+ }
+#footer {
+ position:relative;
+ background-image: url(../assets/image/bg_footer.png);
+ background-repeat: repeat-x;
+ height: 75px;
+ width: 100%;
+ left: 0px;
+ bottom: 0px;
+}
+#score_box {
+ float: left;
+ padding-left: 5px;
+ padding-top: 0.7em;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #FFFF00;
+ font-size: 16pt;
+ font-weight: bold;
+}
+#botbtn_right {
+ float: right;
+ height: 55px;
+ padding-right: 5px;
+ padding-top: 10px;
+}
+
+ #linkStart{
+ width: 251px; height: 55px;
+ background:url(../assets/image/btn_start.png);
+ }
+ #linkStart:hover{
+ background:url(../assets/image/btn_start_hover.png);
+ }
+ #linkStart:active{
+ background:url(../assets/image/btn_start_mouse_down.png);
+ }
+ #linkPlayAgain{
+ width: 251px; height: 55px;
+ background:url(../assets/image/btn_play_again.png);
+ }
+ #linkPlayAgain:hover{
+ background:url(../assets/image/btn_play_again_hover.png);
+ }
+ #linkPlayAgain:active{
+ background:url(../assets/image/btn_play_again_mouse_down.png);
+ }
+
+
+#timerBar {
+ position: absolute;
+ left: 30%;
+ bottom: 25%;
+ width: 140px;
+ height:35px;
+ padding-left: 10px;
+ padding-top: 0px;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #FFFF00;
+ font-size: 16pt;
+ font-weight: bold;
+ }
+
+ .timerBoxes{ /* Show the timer running after the game has began.... */
+ float:right;
+ width: 80px;
+ height: 35px;
+ border: 2px dotted green;
+ padding-left: 0.5em;
+ color: blue;
+ text-align:center;
+ font : bold 25px Arial Black, Times New Roman;
+ background: #ACC;
+ }
+
+#linkNextLesson{
+ position:absolute;
+ bottom: 75px;
+ right: 10px;
+}
+#linkPrevLesson{
+ display:none;
+ position:absolute;
+ bottom: 75px;
+ left: 10px;
+}
+
+/**** End of the page style ****/
+
+/**** Game Styles ****/
+
+a{
+ color:#FFFFCC;
+}
+img{
+ border:none;
+}
+#currentTitle{
+ width: 150px;
+ height: 80px;
+ font:25px/30px "Courier New", Courier, monospace;
+ font-weight: bold;
+ color: red;
+}
+#content{
+ position:relative;
+ margin: 0 auto;
+ margin-top: 80px;
+ width: 1198px;
+ height: 555px;
+}
+.nextBtn{
+ position:absolute;
+ width: 145px;
+ height: 55px;
+ cursor: pointer;
+ background:url(../assets/image/nextBtn.png);
+}
+.nextBtn:hover{
+ background:url(../assets/image/nextBtnHover.png);
+ }
+
+
+
+
+#linkShowAns{
+ margin: .2em 6em 0 2em;
+ width: 145px;
+ height: 55px;
+ cursor: pointer;
+ background:url(../assets/image/showAnsBtn.png);
+}
+#linkShowAns:hover{
+ background:url(../assets/image/showAnsBtnHover.png);
+}
+#linkCheckAns{
+ margin: .2em 1em;
+ width: 145px;
+ height: 55px;
+ cursor: pointer;
+ background:url(../assets/image/checkAnsBtn.png);
+}
+#linkCheckAns:hover{
+ background:url(../assets/image/checkAnsBtnHover.png);
+ }
+
+ /** lesson 1 **/
+ #imgWhole{
+ position:relative; margin-top: 2em; float:left;
+ }
+ .lessonImgFrac{
+ position:relative; float:left; margin-left: -15em; margin-top: 2em;
+ }
+ #lesson1ImgFractionRight{
+ float:right; margin-top: 2em; margin-right: 20em; }
+ #lesson1frac1{
+ position:absolute; bottom: -3em; right: -4em;
+ }
+
+ /*lesson 2*/
+ #lesson2Div1{
+ float:left;
+ margin-top: 4em; margin-left: 11em;
+ }
+ #lesson2frac1{
+ position:absolute; bottom: -3em; right: 2em;
+ }
+ #lesson2ImgFractionRight{
+ float:right; margin-top: 2em; margin-right: 25em; }
+
+ /* Lesson 3 */
+ #imgRoti1{
+ position:absolute;
+ top: 10em;;
+ left: 3em;
+ }
+ #imgRoti2{
+ position:absolute;
+ top: 9.6em;;
+ left: 30em;
+ }
+ #imgRoti3{
+ position:absolute;
+ top: 10em;;
+ left: 60em;
+ }
+ /* Lesson 5 */
+ #lessonContainer{
+ position:absolute;
+ top: 4em;
+ left: 4em;
+ width:auto;
+ height:auto;
+ }
+ .quesContainer{
+ position:relative;
+ float:left;
+ padding: 0 2em;
+ width: 35em;
+ height: 6.5em;
+ }
+ input.inputFraction{
+ size:3;
+ font: 25px/30px Verdana, Geneva, Arial, Helvetica, sans-serif;
+ font-weight: bold;
+ height:30px;
+ width: 100px;
+ text-align:center;
+ }
+ .focus {
+ background-color: #FF9900;
+ }
+/*Utilities */
+.float-left{ float:left; }
+.float-right{ float:right; }
+.float-center{ margin:0px 10em;}
+.marginMore{margin: 0px 20em;}
+.clear {clear: both;}
+
+
+
+
+
+
+#help{
+ display:none;
+ position:absolute;
+ right: 60px;
+ top: 75px;;
+ width: 256px;
+ height: 600px;
+ background:url(../assets/image/help.png);
+ z-index:40;
+}
+.backOpaque{
+ background-color: #A4A4A4;
+ opacity: 0.2;
+ }
+
+ #gameOver{
+ opacity: 1;
+ display:none;
+ position:absolute;
+ top:45%;
+ left: 35%;
+ color: blue;
+ text-align:center;
+ font : bold 45px/65px Arial Black, Times New Roman;
+ }
+ #gameOverInfo{
+ margin-top: 35px;
+ text-align:center;
+ font: 20px/25px Helvetica, Geneva, Arial, Verdana, sans-serif;
+ font-weight:bold;
+ color:#FF0000;
+
+ }
+ .specialText{
+ margin-top: 1em;
+ font: 20px/25px Helvetica, Geneva, Arial, Verdana, sans-serif;
+ font-weight:bold;
+ color:#FF9900;
+ border-bottom: 2px dotted #CCC;
+
+ }
diff --git a/examples/lessons/6_Maths_multiplyingFractions/css/ui.scoreboard.css b/examples/lessons/6_Maths_multiplyingFractions/css/ui.scoreboard.css
new file mode 100755
index 0000000..11cdbb5
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/css/ui.scoreboard.css
@@ -0,0 +1,62 @@
+.ui-scoreboard-container-h{
+max-width: 800em;
+max-height: 200px;
+float:left;
+padding-top:0.4em;
+padding-bottom:0.4em;
+}
+
+.ui-scoreboard-spacing-h{
+max-width: 200em;
+max-height: 300em;
+display:inline;
+margin-left:0.2em;
+margin-right:0.4em;
+}
+
+.ui-scoreboard-text{
+font-size:larger;
+text-align: center;
+}
+
+.ui-scoreboard-number-h {
+background-color:black;
+color: white;
+padding-left:0.4em;
+padding-right:0.4em;
+font-size:larger;
+}
+
+.ui-scoreboard-button{
+float:right;
+cursor:pointer;
+}
+
+button .ui-scoreboard-icon{
+float: left;
+margin-right:0.3em;
+}
+.ui-scoreboard-container-v{
+max-width: 200px;
+max-height: 400px;
+float:left;
+padding-top:0.4em;
+padding-bottom:0.4em;
+}
+.ui-scoreboard-spacing-v{
+display:block;
+margin: 0.4em;
+}
+
+.ui-scoreboard-number-v{
+background-color:black;
+color: white;
+width: 1em;
+text-align:center;
+margin-left:auto;
+margin-right: auto;
+padding:0.4em;
+font-size:larger;
+}
+
+
diff --git a/examples/lessons/6_Maths_multiplyingFractions/index.html b/examples/lessons/6_Maths_multiplyingFractions/index.html
new file mode 100755
index 0000000..3bee5c3
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/index.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Class 6 Maths Multiplying Fractions</title>
+ <meta name="keywords" content="karma,javascript,html5,sugar,sugarlabs,gsoc,ole,nepal" />
+ <link type="text/css" rel="stylesheet" href="css/ui.scoreboard.css" />
+ <link type="text/css" rel="stylesheet" href="css/lesson.css" />
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <link type="image/ico" rel="icon" href="../../assets/default/image/favicon.ico" />
+ <script type="text/javascript" src="js/jquery-1.4.js"></script>
+ <script type="text/javascript" src="js/ui.core.js"></script>
+ <script type="text/javascript" src="js/ui.scoreboard.js"></script>
+ <script type="text/javascript" src="js/karma.js"></script>
+ <script type="text/javascript" src="js/lesson.js"></script>
+</head>
+<body>
+ <div id="header">
+ <div id="topbtn_left"><a href="#"><div id="linkBackLesson" class="linkBack"></div></a></div>
+ <div id="lesson_title">
+ <img src="assets/image/title_block_lt.png" width="33" height="75" align="absmiddle" />
+ Multiplying Fractions || <span id="currentTitle"> </span>
+ <img src="assets/image/title_block_rt.png" width="33" height="75" align="absmiddle" />
+ </div>
+ <div id="topbtn_right"><a href="#"><div id="linkHelp"></div></a></div>
+ <div id="topbtn_right"><a href="http://olenepal.org"><div id="linkOle"></div></a></div>
+ </div>
+
+ <div id="content"></div>
+ <div id="help"></div>
+ <div id="gameOver"></div>
+ <form name="delayForm">
+ <input type="hidden" name="delayval" size="5">
+ </form>
+
+ <div id="footer">
+ <a href="#"><div id="linkNextLesson" class="linkNext"></div></a>
+ <a href="#"><div id="linkPrevLesson" class="linkBack"></div></a>
+ <div id="score_box"></div>
+ <div id="botbtn_right"><a href="#"><div id="linkPlayAgain"></div></a></div>
+ <div id="botbtn_right"><a href="#"><div id="linkStart"></div></a></div>
+ <div id="botbtn_right"><a href="#"><div id="linkShowAns"></div></a></div>
+ <div id="botbtn_right"><a href="#"><div id="linkCheckAns"></div></a></div>
+
+
+ </div>
+</body>
+</html>
diff --git a/examples/lessons/6_Maths_multiplyingFractions/js/jquery-1.4.js b/examples/lessons/6_Maths_multiplyingFractions/js/jquery-1.4.js
new file mode 100755
index 0000000..a448490
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/js/jquery-1.4.js
@@ -0,0 +1,5999 @@
+/*!
+ * jQuery JavaScript Library v1.4
+ * http://jquery.com/
+ *
+ * Copyright 2010, John Resig
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://docs.jquery.com/License
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ * Copyright 2010, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ *
+ * Date: Wed Jan 13 15:23:05 2010 -0500
+ */
+(function( window, undefined ) {
+
+// Define a local copy of jQuery
+var jQuery = function( selector, context ) {
+ // The jQuery object is actually just the init constructor 'enhanced'
+ return new jQuery.fn.init( selector, context );
+ },
+
+ // Map over jQuery in case of overwrite
+ _jQuery = window.jQuery,
+
+ // Map over the $ in case of overwrite
+ _$ = window.$,
+
+ // Use the correct document accordingly with window argument (sandbox)
+ document = window.document,
+
+ // A central reference to the root jQuery(document)
+ rootjQuery,
+
+ // A simple way to check for HTML strings or ID strings
+ // (both of which we optimize for)
+ quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,
+
+ // Is it a simple selector
+ isSimple = /^.[^:#\[\.,]*$/,
+
+ // Check if a string has a non-whitespace character in it
+ rnotwhite = /\S/,
+
+ // Used for trimming whitespace
+ rtrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g,
+
+ // Match a standalone tag
+ rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
+
+ // Keep a UserAgent string for use with jQuery.browser
+ userAgent = navigator.userAgent,
+
+ // For matching the engine and version of the browser
+ browserMatch,
+
+ // Has the ready events already been bound?
+ readyBound = false,
+
+ // The functions to execute on DOM ready
+ readyList = [],
+
+ // The ready event handler
+ DOMContentLoaded,
+
+ // Save a reference to some core methods
+ toString = Object.prototype.toString,
+ hasOwnProperty = Object.prototype.hasOwnProperty,
+ push = Array.prototype.push,
+ slice = Array.prototype.slice,
+ indexOf = Array.prototype.indexOf;
+
+jQuery.fn = jQuery.prototype = {
+ init: function( selector, context ) {
+ var match, elem, ret, doc;
+
+ // Handle $(""), $(null), or $(undefined)
+ if ( !selector ) {
+ return this;
+ }
+
+ // Handle $(DOMElement)
+ if ( selector.nodeType ) {
+ this.context = this[0] = selector;
+ this.length = 1;
+ return this;
+ }
+
+ // Handle HTML strings
+ if ( typeof selector === "string" ) {
+ // Are we dealing with HTML string or an ID?
+ match = quickExpr.exec( selector );
+
+ // Verify a match, and that no context was specified for #id
+ if ( match && (match[1] || !context) ) {
+
+ // HANDLE: $(html) -> $(array)
+ if ( match[1] ) {
+ doc = (context ? context.ownerDocument || context : document);
+
+ // If a single string is passed in and it's a single tag
+ // just do a createElement and skip the rest
+ ret = rsingleTag.exec( selector );
+
+ if ( ret ) {
+ if ( jQuery.isPlainObject( context ) ) {
+ selector = [ document.createElement( ret[1] ) ];
+ jQuery.fn.attr.call( selector, context, true );
+
+ } else {
+ selector = [ doc.createElement( ret[1] ) ];
+ }
+
+ } else {
+ ret = buildFragment( [ match[1] ], [ doc ] );
+ selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
+ }
+
+ // HANDLE: $("#id")
+ } else {
+ elem = document.getElementById( match[2] );
+
+ if ( elem ) {
+ // Handle the case where IE and Opera return items
+ // by name instead of ID
+ if ( elem.id !== match[2] ) {
+ return rootjQuery.find( selector );
+ }
+
+ // Otherwise, we inject the element directly into the jQuery object
+ this.length = 1;
+ this[0] = elem;
+ }
+
+ this.context = document;
+ this.selector = selector;
+ return this;
+ }
+
+ // HANDLE: $("TAG")
+ } else if ( !context && /^\w+$/.test( selector ) ) {
+ this.selector = selector;
+ this.context = document;
+ selector = document.getElementsByTagName( selector );
+
+ // HANDLE: $(expr, $(...))
+ } else if ( !context || context.jquery ) {
+ return (context || rootjQuery).find( selector );
+
+ // HANDLE: $(expr, context)
+ // (which is just equivalent to: $(context).find(expr)
+ } else {
+ return jQuery( context ).find( selector );
+ }
+
+ // HANDLE: $(function)
+ // Shortcut for document ready
+ } else if ( jQuery.isFunction( selector ) ) {
+ return rootjQuery.ready( selector );
+ }
+
+ if (selector.selector !== undefined) {
+ this.selector = selector.selector;
+ this.context = selector.context;
+ }
+
+ return jQuery.isArray( selector ) ?
+ this.setArray( selector ) :
+ jQuery.makeArray( selector, this );
+ },
+
+ // Start with an empty selector
+ selector: "",
+
+ // The current version of jQuery being used
+ jquery: "1.4",
+
+ // The default length of a jQuery object is 0
+ length: 0,
+
+ // The number of elements contained in the matched element set
+ size: function() {
+ return this.length;
+ },
+
+ toArray: function() {
+ return slice.call( this, 0 );
+ },
+
+ // Get the Nth element in the matched element set OR
+ // Get the whole matched element set as a clean array
+ get: function( num ) {
+ return num == null ?
+
+ // Return a 'clean' array
+ this.toArray() :
+
+ // Return just the object
+ ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
+ },
+
+ // Take an array of elements and push it onto the stack
+ // (returning the new matched element set)
+ pushStack: function( elems, name, selector ) {
+ // Build a new jQuery matched element set
+ var ret = jQuery( elems || null );
+
+ // Add the old object onto the stack (as a reference)
+ ret.prevObject = this;
+
+ ret.context = this.context;
+
+ if ( name === "find" ) {
+ ret.selector = this.selector + (this.selector ? " " : "") + selector;
+ } else if ( name ) {
+ ret.selector = this.selector + "." + name + "(" + selector + ")";
+ }
+
+ // Return the newly-formed element set
+ return ret;
+ },
+
+ // Force the current matched set of elements to become
+ // the specified array of elements (destroying the stack in the process)
+ // You should use pushStack() in order to do this, but maintain the stack
+ setArray: function( elems ) {
+ // Resetting the length to 0, then using the native Array push
+ // is a super-fast way to populate an object with array-like properties
+ this.length = 0;
+ push.apply( this, elems );
+
+ return this;
+ },
+
+ // Execute a callback for every element in the matched set.
+ // (You can seed the arguments with an array of args, but this is
+ // only used internally.)
+ each: function( callback, args ) {
+ return jQuery.each( this, callback, args );
+ },
+
+ ready: function( fn ) {
+ // Attach the listeners
+ jQuery.bindReady();
+
+ // If the DOM is already ready
+ if ( jQuery.isReady ) {
+ // Execute the function immediately
+ fn.call( document, jQuery );
+
+ // Otherwise, remember the function for later
+ } else if ( readyList ) {
+ // Add the function to the wait list
+ readyList.push( fn );
+ }
+
+ return this;
+ },
+
+ eq: function( i ) {
+ return i === -1 ?
+ this.slice( i ) :
+ this.slice( i, +i + 1 );
+ },
+
+ first: function() {
+ return this.eq( 0 );
+ },
+
+ last: function() {
+ return this.eq( -1 );
+ },
+
+ slice: function() {
+ return this.pushStack( slice.apply( this, arguments ),
+ "slice", slice.call(arguments).join(",") );
+ },
+
+ map: function( callback ) {
+ return this.pushStack( jQuery.map(this, function( elem, i ) {
+ return callback.call( elem, i, elem );
+ }));
+ },
+
+ end: function() {
+ return this.prevObject || jQuery(null);
+ },
+
+ // For internal use only.
+ // Behaves like an Array's method, not like a jQuery method.
+ push: push,
+ sort: [].sort,
+ splice: [].splice
+};
+
+// Give the init function the jQuery prototype for later instantiation
+jQuery.fn.init.prototype = jQuery.fn;
+
+jQuery.extend = jQuery.fn.extend = function() {
+ // copy reference to target object
+ var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy;
+
+ // Handle a deep copy situation
+ if ( typeof target === "boolean" ) {
+ deep = target;
+ target = arguments[1] || {};
+ // skip the boolean and the target
+ i = 2;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
+ target = {};
+ }
+
+ // extend jQuery itself if only one argument is passed
+ if ( length === i ) {
+ target = this;
+ --i;
+ }
+
+ for ( ; i < length; i++ ) {
+ // Only deal with non-null/undefined values
+ if ( (options = arguments[ i ]) != null ) {
+ // Extend the base object
+ for ( name in options ) {
+ src = target[ name ];
+ copy = options[ name ];
+
+ // Prevent never-ending loop
+ if ( target === copy ) {
+ continue;
+ }
+
+ // Recurse if we're merging object literal values or arrays
+ if ( deep && copy && ( jQuery.isPlainObject(copy) || jQuery.isArray(copy) ) ) {
+ var clone = src && ( jQuery.isPlainObject(src) || jQuery.isArray(src) ) ? src
+ : jQuery.isArray(copy) ? [] : {};
+
+ // Never move original objects, clone them
+ target[ name ] = jQuery.extend( deep, clone, copy );
+
+ // Don't bring in undefined values
+ } else if ( copy !== undefined ) {
+ target[ name ] = copy;
+ }
+ }
+ }
+ }
+
+ // Return the modified object
+ return target;
+};
+
+jQuery.extend({
+ noConflict: function( deep ) {
+ window.$ = _$;
+
+ if ( deep ) {
+ window.jQuery = _jQuery;
+ }
+
+ return jQuery;
+ },
+
+ // Is the DOM ready to be used? Set to true once it occurs.
+ isReady: false,
+
+ // Handle when the DOM is ready
+ ready: function() {
+ // Make sure that the DOM is not already loaded
+ if ( !jQuery.isReady ) {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( !document.body ) {
+ return setTimeout( jQuery.ready, 13 );
+ }
+
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If there are functions bound, to execute
+ if ( readyList ) {
+ // Execute all of them
+ var fn, i = 0;
+ while ( (fn = readyList[ i++ ]) ) {
+ fn.call( document, jQuery );
+ }
+
+ // Reset the list of functions
+ readyList = null;
+ }
+
+ // Trigger any bound ready events
+ if ( jQuery.fn.triggerHandler ) {
+ jQuery( document ).triggerHandler( "ready" );
+ }
+ }
+ },
+
+ bindReady: function() {
+ if ( readyBound ) {
+ return;
+ }
+
+ readyBound = true;
+
+ // Catch cases where $(document).ready() is called after the
+ // browser event has already occurred.
+ if ( document.readyState === "complete" ) {
+ return jQuery.ready();
+ }
+
+ // Mozilla, Opera and webkit nightlies currently support this event
+ if ( document.addEventListener ) {
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+
+ // A fallback to window.onload, that will always work
+ window.addEventListener( "load", jQuery.ready, false );
+
+ // If IE event model is used
+ } else if ( document.attachEvent ) {
+ // ensure firing before onload,
+ // maybe late but safe also for iframes
+ document.attachEvent("onreadystatechange", DOMContentLoaded);
+
+ // A fallback to window.onload, that will always work
+ window.attachEvent( "onload", jQuery.ready );
+
+ // If IE and not a frame
+ // continually check to see if the document is ready
+ var toplevel = false;
+
+ try {
+ toplevel = window.frameElement == null;
+ } catch(e) {}
+
+ if ( document.documentElement.doScroll && toplevel ) {
+ doScrollCheck();
+ }
+ }
+ },
+
+ // See test/unit/core.js for details concerning isFunction.
+ // Since version 1.3, DOM methods and functions like alert
+ // aren't supported. They return false on IE (#2968).
+ isFunction: function( obj ) {
+ return toString.call(obj) === "[object Function]";
+ },
+
+ isArray: function( obj ) {
+ return toString.call(obj) === "[object Array]";
+ },
+
+ isPlainObject: function( obj ) {
+ // Must be an Object.
+ // Because of IE, we also have to check the presence of the constructor property.
+ // Make sure that DOM nodes and window objects don't pass through, as well
+ if ( !obj || toString.call(obj) !== "[object Object]" || obj.nodeType || obj.setInterval ) {
+ return false;
+ }
+
+ // Not own constructor property must be Object
+ if ( obj.constructor
+ && !hasOwnProperty.call(obj, "constructor")
+ && !hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf") ) {
+ return false;
+ }
+
+ // Own properties are enumerated firstly, so to speed up,
+ // if last one is own, then all properties are own.
+
+ var key;
+ for ( key in obj ) {}
+
+ return key === undefined || hasOwnProperty.call( obj, key );
+ },
+
+ isEmptyObject: function( obj ) {
+ for ( var name in obj ) {
+ return false;
+ }
+ return true;
+ },
+
+ noop: function() {},
+
+ // Evalulates a script in a global context
+ globalEval: function( data ) {
+ if ( data && rnotwhite.test(data) ) {
+ // Inspired by code by Andrea Giammarchi
+ // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
+ var head = document.getElementsByTagName("head")[0] || document.documentElement,
+ script = document.createElement("script");
+
+ script.type = "text/javascript";
+
+ if ( jQuery.support.scriptEval ) {
+ script.appendChild( document.createTextNode( data ) );
+ } else {
+ script.text = data;
+ }
+
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709).
+ head.insertBefore( script, head.firstChild );
+ head.removeChild( script );
+ }
+ },
+
+ nodeName: function( elem, name ) {
+ return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
+ },
+
+ // args is for internal usage only
+ each: function( object, callback, args ) {
+ var name, i = 0,
+ length = object.length,
+ isObj = length === undefined || jQuery.isFunction(object);
+
+ if ( args ) {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.apply( object[ name ], args ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( ; i < length; ) {
+ if ( callback.apply( object[ i++ ], args ) === false ) {
+ break;
+ }
+ }
+ }
+
+ // A special, fast, case for the most common use of each
+ } else {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( var value = object[0];
+ i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
+ }
+ }
+
+ return object;
+ },
+
+ trim: function( text ) {
+ return (text || "").replace( rtrim, "" );
+ },
+
+ // results is for internal usage only
+ makeArray: function( array, results ) {
+ var ret = results || [];
+
+ if ( array != null ) {
+ // The window, strings (and functions) also have 'length'
+ // The extra typeof function check is to prevent crashes
+ // in Safari 2 (See: #3039)
+ if ( array.length == null || typeof array === "string" || jQuery.isFunction(array) || (typeof array !== "function" && array.setInterval) ) {
+ push.call( ret, array );
+ } else {
+ jQuery.merge( ret, array );
+ }
+ }
+
+ return ret;
+ },
+
+ inArray: function( elem, array ) {
+ if ( array.indexOf ) {
+ return array.indexOf( elem );
+ }
+
+ for ( var i = 0, length = array.length; i < length; i++ ) {
+ if ( array[ i ] === elem ) {
+ return i;
+ }
+ }
+
+ return -1;
+ },
+
+ merge: function( first, second ) {
+ var i = first.length, j = 0;
+
+ if ( typeof second.length === "number" ) {
+ for ( var l = second.length; j < l; j++ ) {
+ first[ i++ ] = second[ j ];
+ }
+ } else {
+ while ( second[j] !== undefined ) {
+ first[ i++ ] = second[ j++ ];
+ }
+ }
+
+ first.length = i;
+
+ return first;
+ },
+
+ grep: function( elems, callback, inv ) {
+ var ret = [];
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ if ( !inv !== !callback( elems[ i ], i ) ) {
+ ret.push( elems[ i ] );
+ }
+ }
+
+ return ret;
+ },
+
+ // arg is for internal usage only
+ map: function( elems, callback, arg ) {
+ var ret = [], value;
+
+ // Go through the array, translating each of the items to their
+ // new value (or values).
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ value = callback( elems[ i ], i, arg );
+
+ if ( value != null ) {
+ ret[ ret.length ] = value;
+ }
+ }
+
+ return ret.concat.apply( [], ret );
+ },
+
+ // A global GUID counter for objects
+ guid: 1,
+
+ proxy: function( fn, proxy, thisObject ) {
+ if ( arguments.length === 2 ) {
+ if ( typeof proxy === "string" ) {
+ thisObject = fn;
+ fn = thisObject[ proxy ];
+ proxy = undefined;
+
+ } else if ( proxy && !jQuery.isFunction( proxy ) ) {
+ thisObject = proxy;
+ proxy = undefined;
+ }
+ }
+
+ if ( !proxy && fn ) {
+ proxy = function() {
+ return fn.apply( thisObject || this, arguments );
+ };
+ }
+
+ // Set the guid of unique handler to the same of original handler, so it can be removed
+ if ( fn ) {
+ proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
+ }
+
+ // So proxy can be declared as an argument
+ return proxy;
+ },
+
+ // Use of jQuery.browser is frowned upon.
+ // More details: http://docs.jquery.com/Utilities/jQuery.browser
+ uaMatch: function( ua ) {
+ var ret = { browser: "" };
+
+ ua = ua.toLowerCase();
+
+ if ( /webkit/.test( ua ) ) {
+ ret = { browser: "webkit", version: /webkit[\/ ]([\w.]+)/ };
+
+ } else if ( /opera/.test( ua ) ) {
+ ret = { browser: "opera", version: /version/.test( ua ) ? /version[\/ ]([\w.]+)/ : /opera[\/ ]([\w.]+)/ };
+
+ } else if ( /msie/.test( ua ) ) {
+ ret = { browser: "msie", version: /msie ([\w.]+)/ };
+
+ } else if ( /mozilla/.test( ua ) && !/compatible/.test( ua ) ) {
+ ret = { browser: "mozilla", version: /rv:([\w.]+)/ };
+ }
+
+ ret.version = (ret.version && ret.version.exec( ua ) || [0, "0"])[1];
+
+ return ret;
+ },
+
+ browser: {}
+});
+
+browserMatch = jQuery.uaMatch( userAgent );
+if ( browserMatch.browser ) {
+ jQuery.browser[ browserMatch.browser ] = true;
+ jQuery.browser.version = browserMatch.version;
+}
+
+// Deprecated, use jQuery.browser.webkit instead
+if ( jQuery.browser.webkit ) {
+ jQuery.browser.safari = true;
+}
+
+if ( indexOf ) {
+ jQuery.inArray = function( elem, array ) {
+ return indexOf.call( array, elem );
+ };
+}
+
+// All jQuery objects should point back to these
+rootjQuery = jQuery(document);
+
+// Cleanup functions for the document ready method
+if ( document.addEventListener ) {
+ DOMContentLoaded = function() {
+ document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+ jQuery.ready();
+ };
+
+} else if ( document.attachEvent ) {
+ DOMContentLoaded = function() {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( document.readyState === "complete" ) {
+ document.detachEvent( "onreadystatechange", DOMContentLoaded );
+ jQuery.ready();
+ }
+ };
+}
+
+// The DOM ready check for Internet Explorer
+function doScrollCheck() {
+ if ( jQuery.isReady ) {
+ return;
+ }
+
+ try {
+ // If IE is used, use the trick by Diego Perini
+ // http://javascript.nwbox.com/IEContentLoaded/
+ document.documentElement.doScroll("left");
+ } catch( error ) {
+ setTimeout( doScrollCheck, 1 );
+ return;
+ }
+
+ // and execute any waiting functions
+ jQuery.ready();
+}
+
+if ( indexOf ) {
+ jQuery.inArray = function( elem, array ) {
+ return indexOf.call( array, elem );
+ };
+}
+
+function evalScript( i, elem ) {
+ if ( elem.src ) {
+ jQuery.ajax({
+ url: elem.src,
+ async: false,
+ dataType: "script"
+ });
+ } else {
+ jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
+ }
+
+ if ( elem.parentNode ) {
+ elem.parentNode.removeChild( elem );
+ }
+}
+
+// Mutifunctional method to get and set values to a collection
+// The value/s can be optionally by executed if its a function
+function access( elems, key, value, exec, fn, pass ) {
+ var length = elems.length;
+
+ // Setting many attributes
+ if ( typeof key === "object" ) {
+ for ( var k in key ) {
+ access( elems, k, key[k], exec, fn, value );
+ }
+ return elems;
+ }
+
+ // Setting one attribute
+ if ( value !== undefined ) {
+ // Optionally, function values get executed if exec is true
+ exec = !pass && exec && jQuery.isFunction(value);
+
+ for ( var i = 0; i < length; i++ ) {
+ fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
+ }
+
+ return elems;
+ }
+
+ // Getting an attribute
+ return length ? fn( elems[0], key ) : null;
+}
+
+function now() {
+ return (new Date).getTime();
+}
+(function() {
+
+ jQuery.support = {};
+
+ var root = document.documentElement,
+ script = document.createElement("script"),
+ div = document.createElement("div"),
+ id = "script" + now();
+
+ div.style.display = "none";
+ div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
+
+ var all = div.getElementsByTagName("*"),
+ a = div.getElementsByTagName("a")[0];
+
+ // Can't get basic test support
+ if ( !all || !all.length || !a ) {
+ return;
+ }
+
+ jQuery.support = {
+ // IE strips leading whitespace when .innerHTML is used
+ leadingWhitespace: div.firstChild.nodeType === 3,
+
+ // Make sure that tbody elements aren't automatically inserted
+ // IE will insert them into empty tables
+ tbody: !div.getElementsByTagName("tbody").length,
+
+ // Make sure that link elements get serialized correctly by innerHTML
+ // This requires a wrapper element in IE
+ htmlSerialize: !!div.getElementsByTagName("link").length,
+
+ // Get the style information from getAttribute
+ // (IE uses .cssText insted)
+ style: /red/.test( a.getAttribute("style") ),
+
+ // Make sure that URLs aren't manipulated
+ // (IE normalizes it by default)
+ hrefNormalized: a.getAttribute("href") === "/a",
+
+ // Make sure that element opacity exists
+ // (IE uses filter instead)
+ // Use a regex to work around a WebKit issue. See #5145
+ opacity: /^0.55$/.test( a.style.opacity ),
+
+ // Verify style float existence
+ // (IE uses styleFloat instead of cssFloat)
+ cssFloat: !!a.style.cssFloat,
+
+ // Make sure that if no value is specified for a checkbox
+ // that it defaults to "on".
+ // (WebKit defaults to "" instead)
+ checkOn: div.getElementsByTagName("input")[0].value === "on",
+
+ // Make sure that a selected-by-default option has a working selected property.
+ // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
+ optSelected: document.createElement("select").appendChild( document.createElement("option") ).selected,
+
+ // Will be defined later
+ scriptEval: false,
+ noCloneEvent: true,
+ boxModel: null
+ };
+
+ script.type = "text/javascript";
+ try {
+ script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
+ } catch(e) {}
+
+ root.insertBefore( script, root.firstChild );
+
+ // Make sure that the execution of code works by injecting a script
+ // tag with appendChild/createTextNode
+ // (IE doesn't support this, fails, and uses .text instead)
+ if ( window[ id ] ) {
+ jQuery.support.scriptEval = true;
+ delete window[ id ];
+ }
+
+ root.removeChild( script );
+
+ if ( div.attachEvent && div.fireEvent ) {
+ div.attachEvent("onclick", function click() {
+ // Cloning a node shouldn't copy over any
+ // bound event handlers (IE does this)
+ jQuery.support.noCloneEvent = false;
+ div.detachEvent("onclick", click);
+ });
+ div.cloneNode(true).fireEvent("onclick");
+ }
+
+ // Figure out if the W3C box model works as expected
+ // document.body must exist before we can do this
+ // TODO: This timeout is temporary until I move ready into core.js.
+ jQuery(function() {
+ var div = document.createElement("div");
+ div.style.width = div.style.paddingLeft = "1px";
+
+ document.body.appendChild( div );
+ jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
+ document.body.removeChild( div ).style.display = 'none';
+ div = null;
+ });
+
+ // Technique from Juriy Zaytsev
+ // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
+ var eventSupported = function( eventName ) {
+ var el = document.createElement("div");
+ eventName = "on" + eventName;
+
+ var isSupported = (eventName in el);
+ if ( !isSupported ) {
+ el.setAttribute(eventName, "return;");
+ isSupported = typeof el[eventName] === "function";
+ }
+ el = null;
+
+ return isSupported;
+ };
+
+ jQuery.support.submitBubbles = eventSupported("submit");
+ jQuery.support.changeBubbles = eventSupported("change");
+
+ // release memory in IE
+ root = script = div = all = a = null;
+})();
+
+jQuery.props = {
+ "for": "htmlFor",
+ "class": "className",
+ readonly: "readOnly",
+ maxlength: "maxLength",
+ cellspacing: "cellSpacing",
+ rowspan: "rowSpan",
+ colspan: "colSpan",
+ tabindex: "tabIndex",
+ usemap: "useMap",
+ frameborder: "frameBorder"
+};
+var expando = "jQuery" + now(), uuid = 0, windowData = {};
+var emptyObject = {};
+
+jQuery.extend({
+ cache: {},
+
+ expando:expando,
+
+ // The following elements throw uncatchable exceptions if you
+ // attempt to add expando properties to them.
+ noData: {
+ "embed": true,
+ "object": true,
+ "applet": true
+ },
+
+ data: function( elem, name, data ) {
+ if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
+ return;
+ }
+
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var id = elem[ expando ], cache = jQuery.cache, thisCache;
+
+ // Handle the case where there's no name immediately
+ if ( !name && !id ) {
+ return null;
+ }
+
+ // Compute a unique ID for the element
+ if ( !id ) {
+ id = ++uuid;
+ }
+
+ // Avoid generating a new cache unless none exists and we
+ // want to manipulate it.
+ if ( typeof name === "object" ) {
+ elem[ expando ] = id;
+ thisCache = cache[ id ] = jQuery.extend(true, {}, name);
+ } else if ( cache[ id ] ) {
+ thisCache = cache[ id ];
+ } else if ( typeof data === "undefined" ) {
+ thisCache = emptyObject;
+ } else {
+ thisCache = cache[ id ] = {};
+ }
+
+ // Prevent overriding the named cache with undefined values
+ if ( data !== undefined ) {
+ elem[ expando ] = id;
+ thisCache[ name ] = data;
+ }
+
+ return typeof name === "string" ? thisCache[ name ] : thisCache;
+ },
+
+ removeData: function( elem, name ) {
+ if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
+ return;
+ }
+
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ];
+
+ // If we want to remove a specific section of the element's data
+ if ( name ) {
+ if ( thisCache ) {
+ // Remove the section of cache data
+ delete thisCache[ name ];
+
+ // If we've removed all the data, remove the element's cache
+ if ( jQuery.isEmptyObject(thisCache) ) {
+ jQuery.removeData( elem );
+ }
+ }
+
+ // Otherwise, we want to remove all of the element's data
+ } else {
+ // Clean up the element expando
+ try {
+ delete elem[ expando ];
+ } catch( e ) {
+ // IE has trouble directly removing the expando
+ // but it's ok with using removeAttribute
+ if ( elem.removeAttribute ) {
+ elem.removeAttribute( expando );
+ }
+ }
+
+ // Completely remove the data cache
+ delete cache[ id ];
+ }
+ }
+});
+
+jQuery.fn.extend({
+ data: function( key, value ) {
+ if ( typeof key === "undefined" && this.length ) {
+ return jQuery.data( this[0] );
+
+ } else if ( typeof key === "object" ) {
+ return this.each(function() {
+ jQuery.data( this, key );
+ });
+ }
+
+ var parts = key.split(".");
+ parts[1] = parts[1] ? "." + parts[1] : "";
+
+ if ( value === undefined ) {
+ var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
+
+ if ( data === undefined && this.length ) {
+ data = jQuery.data( this[0], key );
+ }
+ return data === undefined && parts[1] ?
+ this.data( parts[0] ) :
+ data;
+ } else {
+ return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function() {
+ jQuery.data( this, key, value );
+ });
+ }
+ },
+
+ removeData: function( key ) {
+ return this.each(function() {
+ jQuery.removeData( this, key );
+ });
+ }
+});
+jQuery.extend({
+ queue: function( elem, type, data ) {
+ if ( !elem ) {
+ return;
+ }
+
+ type = (type || "fx") + "queue";
+ var q = jQuery.data( elem, type );
+
+ // Speed up dequeue by getting out quickly if this is just a lookup
+ if ( !data ) {
+ return q || [];
+ }
+
+ if ( !q || jQuery.isArray(data) ) {
+ q = jQuery.data( elem, type, jQuery.makeArray(data) );
+
+ } else {
+ q.push( data );
+ }
+
+ return q;
+ },
+
+ dequeue: function( elem, type ) {
+ type = type || "fx";
+
+ var queue = jQuery.queue( elem, type ), fn = queue.shift();
+
+ // If the fx queue is dequeued, always remove the progress sentinel
+ if ( fn === "inprogress" ) {
+ fn = queue.shift();
+ }
+
+ if ( fn ) {
+ // Add a progress sentinel to prevent the fx queue from being
+ // automatically dequeued
+ if ( type === "fx" ) {
+ queue.unshift("inprogress");
+ }
+
+ fn.call(elem, function() {
+ jQuery.dequeue(elem, type);
+ });
+ }
+ }
+});
+
+jQuery.fn.extend({
+ queue: function( type, data ) {
+ if ( typeof type !== "string" ) {
+ data = type;
+ type = "fx";
+ }
+
+ if ( data === undefined ) {
+ return jQuery.queue( this[0], type );
+ }
+ return this.each(function( i, elem ) {
+ var queue = jQuery.queue( this, type, data );
+
+ if ( type === "fx" && queue[0] !== "inprogress" ) {
+ jQuery.dequeue( this, type );
+ }
+ });
+ },
+ dequeue: function( type ) {
+ return this.each(function() {
+ jQuery.dequeue( this, type );
+ });
+ },
+
+ // Based off of the plugin by Clint Helfers, with permission.
+ // http://blindsignals.com/index.php/2009/07/jquery-delay/
+ delay: function( time, type ) {
+ time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
+ type = type || "fx";
+
+ return this.queue( type, function() {
+ var elem = this;
+ setTimeout(function() {
+ jQuery.dequeue( elem, type );
+ }, time );
+ });
+ },
+
+ clearQueue: function( type ) {
+ return this.queue( type || "fx", [] );
+ }
+});
+var rclass = /[\n\t]/g,
+ rspace = /\s+/,
+ rreturn = /\r/g,
+ rspecialurl = /href|src|style/,
+ rtype = /(button|input)/i,
+ rfocusable = /(button|input|object|select|textarea)/i,
+ rclickable = /^(a|area)$/i,
+ rradiocheck = /radio|checkbox/;
+
+jQuery.fn.extend({
+ attr: function( name, value ) {
+ return access( this, name, value, true, jQuery.attr );
+ },
+
+ removeAttr: function( name, fn ) {
+ return this.each(function(){
+ jQuery.attr( this, name, "" );
+ if ( this.nodeType === 1 ) {
+ this.removeAttribute( name );
+ }
+ });
+ },
+
+ addClass: function( value ) {
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.addClass( value.call(this, i, self.attr("class")) );
+ });
+ }
+
+ if ( value && typeof value === "string" ) {
+ var classNames = (value || "").split( rspace );
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var elem = this[i];
+
+ if ( elem.nodeType === 1 ) {
+ if ( !elem.className ) {
+ elem.className = value;
+
+ } else {
+ var className = " " + elem.className + " ";
+ for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
+ if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
+ elem.className += " " + classNames[c];
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ removeClass: function( value ) {
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.removeClass( value.call(this, i, self.attr("class")) );
+ });
+ }
+
+ if ( (value && typeof value === "string") || value === undefined ) {
+ var classNames = (value || "").split(rspace);
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var elem = this[i];
+
+ if ( elem.nodeType === 1 && elem.className ) {
+ if ( value ) {
+ var className = (" " + elem.className + " ").replace(rclass, " ");
+ for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
+ className = className.replace(" " + classNames[c] + " ", " ");
+ }
+ elem.className = className.substring(1, className.length - 1);
+
+ } else {
+ elem.className = "";
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ toggleClass: function( value, stateVal ) {
+ var type = typeof value, isBool = typeof stateVal === "boolean";
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
+ });
+ }
+
+ return this.each(function() {
+ if ( type === "string" ) {
+ // toggle individual class names
+ var className, i = 0, self = jQuery(this),
+ state = stateVal,
+ classNames = value.split( rspace );
+
+ while ( (className = classNames[ i++ ]) ) {
+ // check each className given, space seperated list
+ state = isBool ? state : !self.hasClass( className );
+ self[ state ? "addClass" : "removeClass" ]( className );
+ }
+
+ } else if ( type === "undefined" || type === "boolean" ) {
+ if ( this.className ) {
+ // store className if set
+ jQuery.data( this, "__className__", this.className );
+ }
+
+ // toggle whole className
+ this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || "";
+ }
+ });
+ },
+
+ hasClass: function( selector ) {
+ var className = " " + selector + " ";
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ val: function( value ) {
+ if ( value === undefined ) {
+ var elem = this[0];
+
+ if ( elem ) {
+ if ( jQuery.nodeName( elem, "option" ) ) {
+ return (elem.attributes.value || {}).specified ? elem.value : elem.text;
+ }
+
+ // We need to handle select boxes special
+ if ( jQuery.nodeName( elem, "select" ) ) {
+ var index = elem.selectedIndex,
+ values = [],
+ options = elem.options,
+ one = elem.type === "select-one";
+
+ // Nothing was selected
+ if ( index < 0 ) {
+ return null;
+ }
+
+ // Loop through all the selected options
+ for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
+ var option = options[ i ];
+
+ if ( option.selected ) {
+ // Get the specifc value for the option
+ value = jQuery(option).val();
+
+ // We don't need an array for one selects
+ if ( one ) {
+ return value;
+ }
+
+ // Multi-Selects return an array
+ values.push( value );
+ }
+ }
+
+ return values;
+ }
+
+ // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
+ if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
+ return elem.getAttribute("value") === null ? "on" : elem.value;
+ }
+
+
+ // Everything else, we just grab the value
+ return (elem.value || "").replace(rreturn, "");
+
+ }
+
+ return undefined;
+ }
+
+ var isFunction = jQuery.isFunction(value);
+
+ return this.each(function(i) {
+ var self = jQuery(this), val = value;
+
+ if ( this.nodeType !== 1 ) {
+ return;
+ }
+
+ if ( isFunction ) {
+ val = value.call(this, i, self.val());
+ }
+
+ // Typecast each time if the value is a Function and the appended
+ // value is therefore different each time.
+ if ( typeof val === "number" ) {
+ val += "";
+ }
+
+ if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
+ this.checked = jQuery.inArray( self.val(), val ) >= 0;
+
+ } else if ( jQuery.nodeName( this, "select" ) ) {
+ var values = jQuery.makeArray(val);
+
+ jQuery( "option", this ).each(function() {
+ this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
+ });
+
+ if ( !values.length ) {
+ this.selectedIndex = -1;
+ }
+
+ } else {
+ this.value = val;
+ }
+ });
+ }
+});
+
+jQuery.extend({
+ attrFn: {
+ val: true,
+ css: true,
+ html: true,
+ text: true,
+ data: true,
+ width: true,
+ height: true,
+ offset: true
+ },
+
+ attr: function( elem, name, value, pass ) {
+ // don't set attributes on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ if ( pass && name in jQuery.attrFn ) {
+ return jQuery(elem)[name](value);
+ }
+
+ var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
+ // Whether we are setting (or getting)
+ set = value !== undefined;
+
+ // Try to normalize/fix the name
+ name = notxml && jQuery.props[ name ] || name;
+
+ // Only do all the following if this is a node (faster for style)
+ if ( elem.nodeType === 1 ) {
+ // These attributes require special treatment
+ var special = rspecialurl.test( name );
+
+ // Safari mis-reports the default selected property of an option
+ // Accessing the parent's selectedIndex property fixes it
+ if ( name === "selected" && !jQuery.support.optSelected ) {
+ var parent = elem.parentNode;
+ if ( parent ) {
+ parent.selectedIndex;
+
+ // Make sure that it also works with optgroups, see #5701
+ if ( parent.parentNode ) {
+ parent.parentNode.selectedIndex;
+ }
+ }
+ }
+
+ // If applicable, access the attribute via the DOM 0 way
+ if ( name in elem && notxml && !special ) {
+ if ( set ) {
+ // We can't allow the type property to be changed (since it causes problems in IE)
+ if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
+ throw "type property can't be changed";
+ }
+
+ elem[ name ] = value;
+ }
+
+ // browsers index elements by id/name on forms, give priority to attributes.
+ if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
+ return elem.getAttributeNode( name ).nodeValue;
+ }
+
+ // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
+ // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
+ if ( name === "tabIndex" ) {
+ var attributeNode = elem.getAttributeNode( "tabIndex" );
+
+ return attributeNode && attributeNode.specified ?
+ attributeNode.value :
+ rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
+ 0 :
+ undefined;
+ }
+
+ return elem[ name ];
+ }
+
+ if ( !jQuery.support.style && notxml && name === "style" ) {
+ if ( set ) {
+ elem.style.cssText = "" + value;
+ }
+
+ return elem.style.cssText;
+ }
+
+ if ( set ) {
+ // convert the value to a string (all browsers do this but IE) see #1070
+ elem.setAttribute( name, "" + value );
+ }
+
+ var attr = !jQuery.support.hrefNormalized && notxml && special ?
+ // Some attributes require a special call on IE
+ elem.getAttribute( name, 2 ) :
+ elem.getAttribute( name );
+
+ // Non-existent attributes return null, we normalize to undefined
+ return attr === null ? undefined : attr;
+ }
+
+ // elem is actually elem.style ... set the style
+ // Using attr for specific style information is now deprecated. Use style insead.
+ return jQuery.style( elem, name, value );
+ }
+});
+var fcleanup = function( nm ) {
+ return nm.replace(/[^\w\s\.\|`]/g, function( ch ) {
+ return "\\" + ch;
+ });
+};
+
+/*
+ * A number of helper functions used for managing events.
+ * Many of the ideas behind this code originated from
+ * Dean Edwards' addEvent library.
+ */
+jQuery.event = {
+
+ // Bind an event to an element
+ // Original by Dean Edwards
+ add: function( elem, types, handler, data ) {
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ // For whatever reason, IE has trouble passing the window object
+ // around, causing it to be cloned in the process
+ if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) {
+ elem = window;
+ }
+
+ // Make sure that the function being executed has a unique ID
+ if ( !handler.guid ) {
+ handler.guid = jQuery.guid++;
+ }
+
+ // if data is passed, bind to handler
+ if ( data !== undefined ) {
+ // Create temporary function pointer to original handler
+ var fn = handler;
+
+ // Create unique handler function, wrapped around original handler
+ handler = jQuery.proxy( fn );
+
+ // Store data in unique handler
+ handler.data = data;
+ }
+
+ // Init the element's event structure
+ var events = jQuery.data( elem, "events" ) || jQuery.data( elem, "events", {} ),
+ handle = jQuery.data( elem, "handle" ), eventHandle;
+
+ if ( !handle ) {
+ eventHandle = function() {
+ // Handle the second event of a trigger and when
+ // an event is called after a page has unloaded
+ return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
+ jQuery.event.handle.apply( eventHandle.elem, arguments ) :
+ undefined;
+ };
+
+ handle = jQuery.data( elem, "handle", eventHandle );
+ }
+
+ // If no handle is found then we must be trying to bind to one of the
+ // banned noData elements
+ if ( !handle ) {
+ return;
+ }
+
+ // Add elem as a property of the handle function
+ // This is to prevent a memory leak with non-native
+ // event in IE.
+ handle.elem = elem;
+
+ // Handle multiple events separated by a space
+ // jQuery(...).bind("mouseover mouseout", fn);
+ types = types.split( /\s+/ );
+ var type, i=0;
+ while ( (type = types[ i++ ]) ) {
+ // Namespaced event handlers
+ var namespaces = type.split(".");
+ type = namespaces.shift();
+ handler.type = namespaces.slice(0).sort().join(".");
+
+ // Get the current list of functions bound to this event
+ var handlers = events[ type ],
+ special = this.special[ type ] || {};
+
+
+
+ // Init the event handler queue
+ if ( !handlers ) {
+ handlers = events[ type ] = {};
+
+ // Check for a special event handler
+ // Only use addEventListener/attachEvent if the special
+ // events handler returns false
+ if ( !special.setup || special.setup.call( elem, data, namespaces, handler) === false ) {
+ // Bind the global event handler to the element
+ if ( elem.addEventListener ) {
+ elem.addEventListener( type, handle, false );
+ } else if ( elem.attachEvent ) {
+ elem.attachEvent( "on" + type, handle );
+ }
+ }
+ }
+
+ if ( special.add ) {
+ var modifiedHandler = special.add.call( elem, handler, data, namespaces, handlers );
+ if ( modifiedHandler && jQuery.isFunction( modifiedHandler ) ) {
+ modifiedHandler.guid = modifiedHandler.guid || handler.guid;
+ handler = modifiedHandler;
+ }
+ }
+
+ // Add the function to the element's handler list
+ handlers[ handler.guid ] = handler;
+
+ // Keep track of which events have been used, for global triggering
+ this.global[ type ] = true;
+ }
+
+ // Nullify elem to prevent memory leaks in IE
+ elem = null;
+ },
+
+ global: {},
+
+ // Detach an event or set of events from an element
+ remove: function( elem, types, handler ) {
+ // don't do events on text and comment nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ var events = jQuery.data( elem, "events" ), ret, type, fn;
+
+ if ( events ) {
+ // Unbind all events for the element
+ if ( types === undefined || (typeof types === "string" && types.charAt(0) === ".") ) {
+ for ( type in events ) {
+ this.remove( elem, type + (types || "") );
+ }
+ } else {
+ // types is actually an event object here
+ if ( types.type ) {
+ handler = types.handler;
+ types = types.type;
+ }
+
+ // Handle multiple events separated by a space
+ // jQuery(...).unbind("mouseover mouseout", fn);
+ types = types.split(/\s+/);
+ var i = 0;
+ while ( (type = types[ i++ ]) ) {
+ // Namespaced event handlers
+ var namespaces = type.split(".");
+ type = namespaces.shift();
+ var all = !namespaces.length,
+ cleaned = jQuery.map( namespaces.slice(0).sort(), fcleanup ),
+ namespace = new RegExp("(^|\\.)" + cleaned.join("\\.(?:.*\\.)?") + "(\\.|$)"),
+ special = this.special[ type ] || {};
+
+ if ( events[ type ] ) {
+ // remove the given handler for the given type
+ if ( handler ) {
+ fn = events[ type ][ handler.guid ];
+ delete events[ type ][ handler.guid ];
+
+ // remove all handlers for the given type
+ } else {
+ for ( var handle in events[ type ] ) {
+ // Handle the removal of namespaced events
+ if ( all || namespace.test( events[ type ][ handle ].type ) ) {
+ delete events[ type ][ handle ];
+ }
+ }
+ }
+
+ if ( special.remove ) {
+ special.remove.call( elem, namespaces, fn);
+ }
+
+ // remove generic event handler if no more handlers exist
+ for ( ret in events[ type ] ) {
+ break;
+ }
+ if ( !ret ) {
+ if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
+ if ( elem.removeEventListener ) {
+ elem.removeEventListener( type, jQuery.data( elem, "handle" ), false );
+ } else if ( elem.detachEvent ) {
+ elem.detachEvent( "on" + type, jQuery.data( elem, "handle" ) );
+ }
+ }
+ ret = null;
+ delete events[ type ];
+ }
+ }
+ }
+ }
+
+ // Remove the expando if it's no longer used
+ for ( ret in events ) {
+ break;
+ }
+ if ( !ret ) {
+ var handle = jQuery.data( elem, "handle" );
+ if ( handle ) {
+ handle.elem = null;
+ }
+ jQuery.removeData( elem, "events" );
+ jQuery.removeData( elem, "handle" );
+ }
+ }
+ },
+
+ // bubbling is internal
+ trigger: function( event, data, elem /*, bubbling */ ) {
+ // Event object or event type
+ var type = event.type || event,
+ bubbling = arguments[3];
+
+ if ( !bubbling ) {
+ event = typeof event === "object" ?
+ // jQuery.Event object
+ event[expando] ? event :
+ // Object literal
+ jQuery.extend( jQuery.Event(type), event ) :
+ // Just the event type (string)
+ jQuery.Event(type);
+
+ if ( type.indexOf("!") >= 0 ) {
+ event.type = type = type.slice(0, -1);
+ event.exclusive = true;
+ }
+
+ // Handle a global trigger
+ if ( !elem ) {
+ // Don't bubble custom events when global (to avoid too much overhead)
+ event.stopPropagation();
+
+ // Only trigger if we've ever bound an event for it
+ if ( this.global[ type ] ) {
+ jQuery.each( jQuery.cache, function() {
+ if ( this.events && this.events[type] ) {
+ jQuery.event.trigger( event, data, this.handle.elem );
+ }
+ });
+ }
+ }
+
+ // Handle triggering a single element
+
+ // don't do events on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ // Clean up in case it is reused
+ event.result = undefined;
+ event.target = elem;
+
+ // Clone the incoming data, if any
+ data = jQuery.makeArray( data );
+ data.unshift( event );
+ }
+
+ event.currentTarget = elem;
+
+ // Trigger the event, it is assumed that "handle" is a function
+ var handle = jQuery.data( elem, "handle" );
+ if ( handle ) {
+ handle.apply( elem, data );
+ }
+
+ var nativeFn, nativeHandler;
+ try {
+ if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
+ nativeFn = elem[ type ];
+ nativeHandler = elem[ "on" + type ];
+ }
+ // prevent IE from throwing an error for some elements with some event types, see #3533
+ } catch (e) {}
+
+ var isClick = jQuery.nodeName(elem, "a") && type === "click";
+
+ // Trigger the native events (except for clicks on links)
+ if ( !bubbling && nativeFn && !event.isDefaultPrevented() && !isClick ) {
+ this.triggered = true;
+ try {
+ elem[ type ]();
+ // prevent IE from throwing an error for some hidden elements
+ } catch (e) {}
+
+ // Handle triggering native .onfoo handlers
+ } else if ( nativeHandler && elem[ "on" + type ].apply( elem, data ) === false ) {
+ event.result = false;
+ }
+
+ this.triggered = false;
+
+ if ( !event.isPropagationStopped() ) {
+ var parent = elem.parentNode || elem.ownerDocument;
+ if ( parent ) {
+ jQuery.event.trigger( event, data, parent, true );
+ }
+ }
+ },
+
+ handle: function( event ) {
+ // returned undefined or false
+ var all, handlers;
+
+ event = arguments[0] = jQuery.event.fix( event || window.event );
+ event.currentTarget = this;
+
+ // Namespaced event handlers
+ var namespaces = event.type.split(".");
+ event.type = namespaces.shift();
+
+ // Cache this now, all = true means, any handler
+ all = !namespaces.length && !event.exclusive;
+
+ var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)");
+
+ handlers = ( jQuery.data(this, "events") || {} )[ event.type ];
+
+ for ( var j in handlers ) {
+ var handler = handlers[ j ];
+
+ // Filter the functions by class
+ if ( all || namespace.test(handler.type) ) {
+ // Pass in a reference to the handler function itself
+ // So that we can later remove it
+ event.handler = handler;
+ event.data = handler.data;
+
+ var ret = handler.apply( this, arguments );
+
+ if ( ret !== undefined ) {
+ event.result = ret;
+ if ( ret === false ) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }
+
+ if ( event.isImmediatePropagationStopped() ) {
+ break;
+ }
+
+ }
+ }
+
+ return event.result;
+ },
+
+ props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
+
+ fix: function( event ) {
+ if ( event[ expando ] ) {
+ return event;
+ }
+
+ // store a copy of the original event object
+ // and "clone" to set read-only properties
+ var originalEvent = event;
+ event = jQuery.Event( originalEvent );
+
+ for ( var i = this.props.length, prop; i; ) {
+ prop = this.props[ --i ];
+ event[ prop ] = originalEvent[ prop ];
+ }
+
+ // Fix target property, if necessary
+ if ( !event.target ) {
+ event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
+ }
+
+ // check if target is a textnode (safari)
+ if ( event.target.nodeType === 3 ) {
+ event.target = event.target.parentNode;
+ }
+
+ // Add relatedTarget, if necessary
+ if ( !event.relatedTarget && event.fromElement ) {
+ event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
+ }
+
+ // Calculate pageX/Y if missing and clientX/Y available
+ if ( event.pageX == null && event.clientX != null ) {
+ var doc = document.documentElement, body = document.body;
+ event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
+ event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
+ }
+
+ // Add which for key events
+ if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) {
+ event.which = event.charCode || event.keyCode;
+ }
+
+ // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
+ if ( !event.metaKey && event.ctrlKey ) {
+ event.metaKey = event.ctrlKey;
+ }
+
+ // Add which for click: 1 === left; 2 === middle; 3 === right
+ // Note: button is not normalized, so don't use it
+ if ( !event.which && event.button !== undefined ) {
+ event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
+ }
+
+ return event;
+ },
+
+ // Deprecated, use jQuery.guid instead
+ guid: 1E8,
+
+ // Deprecated, use jQuery.proxy instead
+ proxy: jQuery.proxy,
+
+ special: {
+ ready: {
+ // Make sure the ready event is setup
+ setup: jQuery.bindReady,
+ teardown: jQuery.noop
+ },
+
+ live: {
+ add: function( proxy, data, namespaces, live ) {
+ jQuery.extend( proxy, data || {} );
+
+ proxy.guid += data.selector + data.live;
+ jQuery.event.add( this, data.live, liveHandler, data );
+
+ },
+
+ remove: function( namespaces ) {
+ if ( namespaces.length ) {
+ var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)");
+
+ jQuery.each( (jQuery.data(this, "events").live || {}), function() {
+ if ( name.test(this.type) ) {
+ remove++;
+ }
+ });
+
+ if ( remove < 1 ) {
+ jQuery.event.remove( this, namespaces[0], liveHandler );
+ }
+ }
+ },
+ special: {}
+ },
+ beforeunload: {
+ setup: function( data, namespaces, fn ) {
+ // We only want to do this special case on windows
+ if ( this.setInterval ) {
+ this.onbeforeunload = fn;
+ }
+
+ return false;
+ },
+ teardown: function( namespaces, fn ) {
+ if ( this.onbeforeunload === fn ) {
+ this.onbeforeunload = null;
+ }
+ }
+ }
+ }
+};
+
+jQuery.Event = function( src ) {
+ // Allow instantiation without the 'new' keyword
+ if ( !this.preventDefault ) {
+ return new jQuery.Event( src );
+ }
+
+ // Event object
+ if ( src && src.type ) {
+ this.originalEvent = src;
+ this.type = src.type;
+ // Event type
+ } else {
+ this.type = src;
+ }
+
+ // timeStamp is buggy for some events on Firefox(#3843)
+ // So we won't rely on the native value
+ this.timeStamp = now();
+
+ // Mark it as fixed
+ this[ expando ] = true;
+};
+
+function returnFalse() {
+ return false;
+}
+function returnTrue() {
+ return true;
+}
+
+// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
+// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
+jQuery.Event.prototype = {
+ preventDefault: function() {
+ this.isDefaultPrevented = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+
+ // if preventDefault exists run it on the original event
+ if ( e.preventDefault ) {
+ e.preventDefault();
+ }
+ // otherwise set the returnValue property of the original event to false (IE)
+ e.returnValue = false;
+ },
+ stopPropagation: function() {
+ this.isPropagationStopped = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+ // if stopPropagation exists run it on the original event
+ if ( e.stopPropagation ) {
+ e.stopPropagation();
+ }
+ // otherwise set the cancelBubble property of the original event to true (IE)
+ e.cancelBubble = true;
+ },
+ stopImmediatePropagation: function() {
+ this.isImmediatePropagationStopped = returnTrue;
+ this.stopPropagation();
+ },
+ isDefaultPrevented: returnFalse,
+ isPropagationStopped: returnFalse,
+ isImmediatePropagationStopped: returnFalse
+};
+
+// Checks if an event happened on an element within another element
+// Used in jQuery.event.special.mouseenter and mouseleave handlers
+var withinElement = function( event ) {
+ // Check if mouse(over|out) are still within the same parent element
+ var parent = event.relatedTarget;
+
+ // Traverse up the tree
+ while ( parent && parent !== this ) {
+ // Firefox sometimes assigns relatedTarget a XUL element
+ // which we cannot access the parentNode property of
+ try {
+ parent = parent.parentNode;
+
+ // assuming we've left the element since we most likely mousedover a xul element
+ } catch(e) {
+ break;
+ }
+ }
+
+ if ( parent !== this ) {
+ // set the correct event type
+ event.type = event.data;
+
+ // handle event if we actually just moused on to a non sub-element
+ jQuery.event.handle.apply( this, arguments );
+ }
+
+},
+
+// In case of event delegation, we only need to rename the event.type,
+// liveHandler will take care of the rest.
+delegate = function( event ) {
+ event.type = event.data;
+ jQuery.event.handle.apply( this, arguments );
+};
+
+// Create mouseenter and mouseleave events
+jQuery.each({
+ mouseenter: "mouseover",
+ mouseleave: "mouseout"
+}, function( orig, fix ) {
+ jQuery.event.special[ orig ] = {
+ setup: function( data ) {
+ jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
+ },
+ teardown: function( data ) {
+ jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
+ }
+ };
+});
+
+// submit delegation
+if ( !jQuery.support.submitBubbles ) {
+
+jQuery.event.special.submit = {
+ setup: function( data, namespaces, fn ) {
+ if ( this.nodeName.toLowerCase() !== "form" ) {
+ jQuery.event.add(this, "click.specialSubmit." + fn.guid, function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
+ return trigger( "submit", this, arguments );
+ }
+ });
+
+ jQuery.event.add(this, "keypress.specialSubmit." + fn.guid, function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
+ return trigger( "submit", this, arguments );
+ }
+ });
+
+ } else {
+ return false;
+ }
+ },
+
+ remove: function( namespaces, fn ) {
+ jQuery.event.remove( this, "click.specialSubmit" + (fn ? "."+fn.guid : "") );
+ jQuery.event.remove( this, "keypress.specialSubmit" + (fn ? "."+fn.guid : "") );
+ }
+};
+
+}
+
+// change delegation, happens here so we have bind.
+if ( !jQuery.support.changeBubbles ) {
+
+var formElems = /textarea|input|select/i;
+
+function getVal( elem ) {
+ var type = elem.type, val = elem.value;
+
+ if ( type === "radio" || type === "checkbox" ) {
+ val = elem.checked;
+
+ } else if ( type === "select-multiple" ) {
+ val = elem.selectedIndex > -1 ?
+ jQuery.map( elem.options, function( elem ) {
+ return elem.selected;
+ }).join("-") :
+ "";
+
+ } else if ( elem.nodeName.toLowerCase() === "select" ) {
+ val = elem.selectedIndex;
+ }
+
+ return val;
+}
+
+function testChange( e ) {
+ var elem = e.target, data, val;
+
+ if ( !formElems.test( elem.nodeName ) || elem.readOnly ) {
+ return;
+ }
+
+ data = jQuery.data( elem, "_change_data" );
+ val = getVal(elem);
+
+ if ( val === data ) {
+ return;
+ }
+
+ // the current data will be also retrieved by beforeactivate
+ if ( e.type !== "focusout" || elem.type !== "radio" ) {
+ jQuery.data( elem, "_change_data", val );
+ }
+
+ if ( elem.type !== "select" && (data != null || val) ) {
+ e.type = "change";
+ return jQuery.event.trigger( e, arguments[1], this );
+ }
+}
+
+jQuery.event.special.change = {
+ filters: {
+ focusout: testChange,
+
+ click: function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
+ return testChange.call( this, e );
+ }
+ },
+
+ // Change has to be called before submit
+ // Keydown will be called before keypress, which is used in submit-event delegation
+ keydown: function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
+ (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
+ type === "select-multiple" ) {
+ return testChange.call( this, e );
+ }
+ },
+
+ // Beforeactivate happens also before the previous element is blurred
+ // with this event you can't trigger a change event, but you can store
+ // information/focus[in] is not needed anymore
+ beforeactivate: function( e ) {
+ var elem = e.target;
+
+ if ( elem.nodeName.toLowerCase() === "input" && elem.type === "radio" ) {
+ jQuery.data( elem, "_change_data", getVal(elem) );
+ }
+ }
+ },
+ setup: function( data, namespaces, fn ) {
+ for ( var type in changeFilters ) {
+ jQuery.event.add( this, type + ".specialChange." + fn.guid, changeFilters[type] );
+ }
+
+ return formElems.test( this.nodeName );
+ },
+ remove: function( namespaces, fn ) {
+ for ( var type in changeFilters ) {
+ jQuery.event.remove( this, type + ".specialChange" + (fn ? "."+fn.guid : ""), changeFilters[type] );
+ }
+
+ return formElems.test( this.nodeName );
+ }
+};
+
+var changeFilters = jQuery.event.special.change.filters;
+
+}
+
+function trigger( type, elem, args ) {
+ args[0].type = type;
+ return jQuery.event.handle.apply( elem, args );
+}
+
+// Create "bubbling" focus and blur events
+if ( document.addEventListener ) {
+ jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
+ jQuery.event.special[ fix ] = {
+ setup: function() {
+ this.addEventListener( orig, handler, true );
+ },
+ teardown: function() {
+ this.removeEventListener( orig, handler, true );
+ }
+ };
+
+ function handler( e ) {
+ e = jQuery.event.fix( e );
+ e.type = fix;
+ return jQuery.event.handle.call( this, e );
+ }
+ });
+}
+
+jQuery.each(["bind", "one"], function( i, name ) {
+ jQuery.fn[ name ] = function( type, data, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" ) {
+ for ( var key in type ) {
+ this[ name ](key, data, type[key], fn);
+ }
+ return this;
+ }
+
+ if ( jQuery.isFunction( data ) ) {
+ thisObject = fn;
+ fn = data;
+ data = undefined;
+ }
+
+ var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
+ jQuery( this ).unbind( event, handler );
+ return fn.apply( this, arguments );
+ }) : fn;
+
+ return type === "unload" && name !== "one" ?
+ this.one( type, data, fn, thisObject ) :
+ this.each(function() {
+ jQuery.event.add( this, type, handler, data );
+ });
+ };
+});
+
+jQuery.fn.extend({
+ unbind: function( type, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" && !type.preventDefault ) {
+ for ( var key in type ) {
+ this.unbind(key, type[key]);
+ }
+ return this;
+ }
+
+ return this.each(function() {
+ jQuery.event.remove( this, type, fn );
+ });
+ },
+ trigger: function( type, data ) {
+ return this.each(function() {
+ jQuery.event.trigger( type, data, this );
+ });
+ },
+
+ triggerHandler: function( type, data ) {
+ if ( this[0] ) {
+ var event = jQuery.Event( type );
+ event.preventDefault();
+ event.stopPropagation();
+ jQuery.event.trigger( event, data, this[0] );
+ return event.result;
+ }
+ },
+
+ toggle: function( fn ) {
+ // Save reference to arguments for access in closure
+ var args = arguments, i = 1;
+
+ // link all the functions, so any of them can unbind this click handler
+ while ( i < args.length ) {
+ jQuery.proxy( fn, args[ i++ ] );
+ }
+
+ return this.click( jQuery.proxy( fn, function( event ) {
+ // Figure out which function to execute
+ var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
+ jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
+
+ // Make sure that clicks stop
+ event.preventDefault();
+
+ // and execute the function
+ return args[ lastToggle ].apply( this, arguments ) || false;
+ }));
+ },
+
+ hover: function( fnOver, fnOut ) {
+ return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
+ },
+
+ live: function( type, data, fn ) {
+ if ( jQuery.isFunction( data ) ) {
+ fn = data;
+ data = undefined;
+ }
+
+ jQuery( this.context ).bind( liveConvert( type, this.selector ), {
+ data: data, selector: this.selector, live: type
+ }, fn );
+
+ return this;
+ },
+
+ die: function( type, fn ) {
+ jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null );
+ return this;
+ }
+});
+
+function liveHandler( event ) {
+ var stop = true, elems = [], selectors = [], args = arguments,
+ related, match, fn, elem, j, i, data,
+ live = jQuery.extend({}, jQuery.data( this, "events" ).live);
+
+ for ( j in live ) {
+ fn = live[j];
+ if ( fn.live === event.type ||
+ fn.altLive && jQuery.inArray(event.type, fn.altLive) > -1 ) {
+
+ data = fn.data;
+ if ( !(data.beforeFilter && data.beforeFilter[event.type] &&
+ !data.beforeFilter[event.type](event)) ) {
+ selectors.push( fn.selector );
+ }
+ } else {
+ delete live[j];
+ }
+ }
+
+ match = jQuery( event.target ).closest( selectors, event.currentTarget );
+
+ for ( i = 0, l = match.length; i < l; i++ ) {
+ for ( j in live ) {
+ fn = live[j];
+ elem = match[i].elem;
+ related = null;
+
+ if ( match[i].selector === fn.selector ) {
+ // Those two events require additional checking
+ if ( fn.live === "mouseenter" || fn.live === "mouseleave" ) {
+ related = jQuery( event.relatedTarget ).closest( fn.selector )[0];
+ }
+
+ if ( !related || related !== elem ) {
+ elems.push({ elem: elem, fn: fn });
+ }
+ }
+ }
+ }
+
+ for ( i = 0, l = elems.length; i < l; i++ ) {
+ match = elems[i];
+ event.currentTarget = match.elem;
+ event.data = match.fn.data;
+ if ( match.fn.apply( match.elem, args ) === false ) {
+ stop = false;
+ break;
+ }
+ }
+
+ return stop;
+}
+
+function liveConvert( type, selector ) {
+ return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "&")].join(".");
+}
+
+jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
+ "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
+ "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
+
+ // Handle event binding
+ jQuery.fn[ name ] = function( fn ) {
+ return fn ? this.bind( name, fn ) : this.trigger( name );
+ };
+
+ if ( jQuery.attrFn ) {
+ jQuery.attrFn[ name ] = true;
+ }
+});
+
+// Prevent memory leaks in IE
+// Window isn't included so as not to unbind existing unload events
+// More info:
+// - http://isaacschlueter.com/2006/10/msie-memory-leaks/
+if ( window.attachEvent && !window.addEventListener ) {
+ window.attachEvent("onunload", function() {
+ for ( var id in jQuery.cache ) {
+ if ( jQuery.cache[ id ].handle ) {
+ // Try/Catch is to handle iframes being unloaded, see #4280
+ try {
+ jQuery.event.remove( jQuery.cache[ id ].handle.elem );
+ } catch(e) {}
+ }
+ }
+ });
+}
+/*!
+ * Sizzle CSS Selector Engine - v1.0
+ * Copyright 2009, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ * More information: http://sizzlejs.com/
+ */
+(function(){
+
+var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
+ done = 0,
+ toString = Object.prototype.toString,
+ hasDuplicate = false,
+ baseHasDuplicate = true;
+
+// Here we check if the JavaScript engine is using some sort of
+// optimization where it does not always call our comparision
+// function. If that is the case, discard the hasDuplicate value.
+// Thus far that includes Google Chrome.
+[0, 0].sort(function(){
+ baseHasDuplicate = false;
+ return 0;
+});
+
+var Sizzle = function(selector, context, results, seed) {
+ results = results || [];
+ var origContext = context = context || document;
+
+ if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
+ return [];
+ }
+
+ if ( !selector || typeof selector !== "string" ) {
+ return results;
+ }
+
+ var parts = [], m, set, checkSet, extra, prune = true, contextXML = isXML(context),
+ soFar = selector;
+
+ // Reset the position of the chunker regexp (start from head)
+ while ( (chunker.exec(""), m = chunker.exec(soFar)) !== null ) {
+ soFar = m[3];
+
+ parts.push( m[1] );
+
+ if ( m[2] ) {
+ extra = m[3];
+ break;
+ }
+ }
+
+ if ( parts.length > 1 && origPOS.exec( selector ) ) {
+ if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
+ set = posProcess( parts[0] + parts[1], context );
+ } else {
+ set = Expr.relative[ parts[0] ] ?
+ [ context ] :
+ Sizzle( parts.shift(), context );
+
+ while ( parts.length ) {
+ selector = parts.shift();
+
+ if ( Expr.relative[ selector ] ) {
+ selector += parts.shift();
+ }
+
+ set = posProcess( selector, set );
+ }
+ }
+ } else {
+ // Take a shortcut and set the context if the root selector is an ID
+ // (but not if it'll be faster if the inner selector is an ID)
+ if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
+ Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
+ var ret = Sizzle.find( parts.shift(), context, contextXML );
+ context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];
+ }
+
+ if ( context ) {
+ var ret = seed ?
+ { expr: parts.pop(), set: makeArray(seed) } :
+ Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
+ set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set;
+
+ if ( parts.length > 0 ) {
+ checkSet = makeArray(set);
+ } else {
+ prune = false;
+ }
+
+ while ( parts.length ) {
+ var cur = parts.pop(), pop = cur;
+
+ if ( !Expr.relative[ cur ] ) {
+ cur = "";
+ } else {
+ pop = parts.pop();
+ }
+
+ if ( pop == null ) {
+ pop = context;
+ }
+
+ Expr.relative[ cur ]( checkSet, pop, contextXML );
+ }
+ } else {
+ checkSet = parts = [];
+ }
+ }
+
+ if ( !checkSet ) {
+ checkSet = set;
+ }
+
+ if ( !checkSet ) {
+ throw "Syntax error, unrecognized expression: " + (cur || selector);
+ }
+
+ if ( toString.call(checkSet) === "[object Array]" ) {
+ if ( !prune ) {
+ results.push.apply( results, checkSet );
+ } else if ( context && context.nodeType === 1 ) {
+ for ( var i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {
+ results.push( set[i] );
+ }
+ }
+ } else {
+ for ( var i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
+ results.push( set[i] );
+ }
+ }
+ }
+ } else {
+ makeArray( checkSet, results );
+ }
+
+ if ( extra ) {
+ Sizzle( extra, origContext, results, seed );
+ Sizzle.uniqueSort( results );
+ }
+
+ return results;
+};
+
+Sizzle.uniqueSort = function(results){
+ if ( sortOrder ) {
+ hasDuplicate = baseHasDuplicate;
+ results.sort(sortOrder);
+
+ if ( hasDuplicate ) {
+ for ( var i = 1; i < results.length; i++ ) {
+ if ( results[i] === results[i-1] ) {
+ results.splice(i--, 1);
+ }
+ }
+ }
+ }
+
+ return results;
+};
+
+Sizzle.matches = function(expr, set){
+ return Sizzle(expr, null, null, set);
+};
+
+Sizzle.find = function(expr, context, isXML){
+ var set, match;
+
+ if ( !expr ) {
+ return [];
+ }
+
+ for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
+ var type = Expr.order[i], match;
+
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
+ var left = match[1];
+ match.splice(1,1);
+
+ if ( left.substr( left.length - 1 ) !== "\\" ) {
+ match[1] = (match[1] || "").replace(/\\/g, "");
+ set = Expr.find[ type ]( match, context, isXML );
+ if ( set != null ) {
+ expr = expr.replace( Expr.match[ type ], "" );
+ break;
+ }
+ }
+ }
+ }
+
+ if ( !set ) {
+ set = context.getElementsByTagName("*");
+ }
+
+ return {set: set, expr: expr};
+};
+
+Sizzle.filter = function(expr, set, inplace, not){
+ var old = expr, result = [], curLoop = set, match, anyFound,
+ isXMLFilter = set && set[0] && isXML(set[0]);
+
+ while ( expr && set.length ) {
+ for ( var type in Expr.filter ) {
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
+ var filter = Expr.filter[ type ], found, item, left = match[1];
+ anyFound = false;
+
+ match.splice(1,1);
+
+ if ( left.substr( left.length - 1 ) === "\\" ) {
+ continue;
+ }
+
+ if ( curLoop === result ) {
+ result = [];
+ }
+
+ if ( Expr.preFilter[ type ] ) {
+ match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
+
+ if ( !match ) {
+ anyFound = found = true;
+ } else if ( match === true ) {
+ continue;
+ }
+ }
+
+ if ( match ) {
+ for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
+ if ( item ) {
+ found = filter( item, match, i, curLoop );
+ var pass = not ^ !!found;
+
+ if ( inplace && found != null ) {
+ if ( pass ) {
+ anyFound = true;
+ } else {
+ curLoop[i] = false;
+ }
+ } else if ( pass ) {
+ result.push( item );
+ anyFound = true;
+ }
+ }
+ }
+ }
+
+ if ( found !== undefined ) {
+ if ( !inplace ) {
+ curLoop = result;
+ }
+
+ expr = expr.replace( Expr.match[ type ], "" );
+
+ if ( !anyFound ) {
+ return [];
+ }
+
+ break;
+ }
+ }
+ }
+
+ // Improper expression
+ if ( expr === old ) {
+ if ( anyFound == null ) {
+ throw "Syntax error, unrecognized expression: " + expr;
+ } else {
+ break;
+ }
+ }
+
+ old = expr;
+ }
+
+ return curLoop;
+};
+
+var Expr = Sizzle.selectors = {
+ order: [ "ID", "NAME", "TAG" ],
+ match: {
+ ID: /#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
+ CLASS: /\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
+ NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,
+ ATTR: /\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
+ TAG: /^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,
+ CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
+ POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
+ PSEUDO: /:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
+ },
+ leftMatch: {},
+ attrMap: {
+ "class": "className",
+ "for": "htmlFor"
+ },
+ attrHandle: {
+ href: function(elem){
+ return elem.getAttribute("href");
+ }
+ },
+ relative: {
+ "+": function(checkSet, part){
+ var isPartStr = typeof part === "string",
+ isTag = isPartStr && !/\W/.test(part),
+ isPartStrNotTag = isPartStr && !isTag;
+
+ if ( isTag ) {
+ part = part.toLowerCase();
+ }
+
+ for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
+ if ( (elem = checkSet[i]) ) {
+ while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
+
+ checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
+ elem || false :
+ elem === part;
+ }
+ }
+
+ if ( isPartStrNotTag ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ },
+ ">": function(checkSet, part){
+ var isPartStr = typeof part === "string";
+
+ if ( isPartStr && !/\W/.test(part) ) {
+ part = part.toLowerCase();
+
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ var parent = elem.parentNode;
+ checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
+ }
+ }
+ } else {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ checkSet[i] = isPartStr ?
+ elem.parentNode :
+ elem.parentNode === part;
+ }
+ }
+
+ if ( isPartStr ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ }
+ },
+ "": function(checkSet, part, isXML){
+ var doneName = done++, checkFn = dirCheck;
+
+ if ( typeof part === "string" && !/\W/.test(part) ) {
+ var nodeCheck = part = part.toLowerCase();
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
+ },
+ "~": function(checkSet, part, isXML){
+ var doneName = done++, checkFn = dirCheck;
+
+ if ( typeof part === "string" && !/\W/.test(part) ) {
+ var nodeCheck = part = part.toLowerCase();
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);
+ }
+ },
+ find: {
+ ID: function(match, context, isXML){
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+ return m ? [m] : [];
+ }
+ },
+ NAME: function(match, context){
+ if ( typeof context.getElementsByName !== "undefined" ) {
+ var ret = [], results = context.getElementsByName(match[1]);
+
+ for ( var i = 0, l = results.length; i < l; i++ ) {
+ if ( results[i].getAttribute("name") === match[1] ) {
+ ret.push( results[i] );
+ }
+ }
+
+ return ret.length === 0 ? null : ret;
+ }
+ },
+ TAG: function(match, context){
+ return context.getElementsByTagName(match[1]);
+ }
+ },
+ preFilter: {
+ CLASS: function(match, curLoop, inplace, result, not, isXML){
+ match = " " + match[1].replace(/\\/g, "") + " ";
+
+ if ( isXML ) {
+ return match;
+ }
+
+ for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
+ if ( elem ) {
+ if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) {
+ if ( !inplace ) {
+ result.push( elem );
+ }
+ } else if ( inplace ) {
+ curLoop[i] = false;
+ }
+ }
+ }
+
+ return false;
+ },
+ ID: function(match){
+ return match[1].replace(/\\/g, "");
+ },
+ TAG: function(match, curLoop){
+ return match[1].toLowerCase();
+ },
+ CHILD: function(match){
+ if ( match[1] === "nth" ) {
+ // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
+ var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
+ match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
+ !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
+
+ // calculate the numbers (first)n+(last) including if they are negative
+ match[2] = (test[1] + (test[2] || 1)) - 0;
+ match[3] = test[3] - 0;
+ }
+
+ // TODO: Move to normal caching system
+ match[0] = done++;
+
+ return match;
+ },
+ ATTR: function(match, curLoop, inplace, result, not, isXML){
+ var name = match[1].replace(/\\/g, "");
+
+ if ( !isXML && Expr.attrMap[name] ) {
+ match[1] = Expr.attrMap[name];
+ }
+
+ if ( match[2] === "~=" ) {
+ match[4] = " " + match[4] + " ";
+ }
+
+ return match;
+ },
+ PSEUDO: function(match, curLoop, inplace, result, not){
+ if ( match[1] === "not" ) {
+ // If we're dealing with a complex expression, or a simple one
+ if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
+ match[3] = Sizzle(match[3], null, null, curLoop);
+ } else {
+ var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
+ if ( !inplace ) {
+ result.push.apply( result, ret );
+ }
+ return false;
+ }
+ } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
+ return true;
+ }
+
+ return match;
+ },
+ POS: function(match){
+ match.unshift( true );
+ return match;
+ }
+ },
+ filters: {
+ enabled: function(elem){
+ return elem.disabled === false && elem.type !== "hidden";
+ },
+ disabled: function(elem){
+ return elem.disabled === true;
+ },
+ checked: function(elem){
+ return elem.checked === true;
+ },
+ selected: function(elem){
+ // Accessing this property makes selected-by-default
+ // options in Safari work properly
+ elem.parentNode.selectedIndex;
+ return elem.selected === true;
+ },
+ parent: function(elem){
+ return !!elem.firstChild;
+ },
+ empty: function(elem){
+ return !elem.firstChild;
+ },
+ has: function(elem, i, match){
+ return !!Sizzle( match[3], elem ).length;
+ },
+ header: function(elem){
+ return /h\d/i.test( elem.nodeName );
+ },
+ text: function(elem){
+ return "text" === elem.type;
+ },
+ radio: function(elem){
+ return "radio" === elem.type;
+ },
+ checkbox: function(elem){
+ return "checkbox" === elem.type;
+ },
+ file: function(elem){
+ return "file" === elem.type;
+ },
+ password: function(elem){
+ return "password" === elem.type;
+ },
+ submit: function(elem){
+ return "submit" === elem.type;
+ },
+ image: function(elem){
+ return "image" === elem.type;
+ },
+ reset: function(elem){
+ return "reset" === elem.type;
+ },
+ button: function(elem){
+ return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
+ },
+ input: function(elem){
+ return /input|select|textarea|button/i.test(elem.nodeName);
+ }
+ },
+ setFilters: {
+ first: function(elem, i){
+ return i === 0;
+ },
+ last: function(elem, i, match, array){
+ return i === array.length - 1;
+ },
+ even: function(elem, i){
+ return i % 2 === 0;
+ },
+ odd: function(elem, i){
+ return i % 2 === 1;
+ },
+ lt: function(elem, i, match){
+ return i < match[3] - 0;
+ },
+ gt: function(elem, i, match){
+ return i > match[3] - 0;
+ },
+ nth: function(elem, i, match){
+ return match[3] - 0 === i;
+ },
+ eq: function(elem, i, match){
+ return match[3] - 0 === i;
+ }
+ },
+ filter: {
+ PSEUDO: function(elem, match, i, array){
+ var name = match[1], filter = Expr.filters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+ } else if ( name === "contains" ) {
+ return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
+ } else if ( name === "not" ) {
+ var not = match[3];
+
+ for ( var i = 0, l = not.length; i < l; i++ ) {
+ if ( not[i] === elem ) {
+ return false;
+ }
+ }
+
+ return true;
+ } else {
+ throw "Syntax error, unrecognized expression: " + name;
+ }
+ },
+ CHILD: function(elem, match){
+ var type = match[1], node = elem;
+ switch (type) {
+ case 'only':
+ case 'first':
+ while ( (node = node.previousSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+ if ( type === "first" ) {
+ return true;
+ }
+ node = elem;
+ case 'last':
+ while ( (node = node.nextSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+ return true;
+ case 'nth':
+ var first = match[2], last = match[3];
+
+ if ( first === 1 && last === 0 ) {
+ return true;
+ }
+
+ var doneName = match[0],
+ parent = elem.parentNode;
+
+ if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
+ var count = 0;
+ for ( node = parent.firstChild; node; node = node.nextSibling ) {
+ if ( node.nodeType === 1 ) {
+ node.nodeIndex = ++count;
+ }
+ }
+ parent.sizcache = doneName;
+ }
+
+ var diff = elem.nodeIndex - last;
+ if ( first === 0 ) {
+ return diff === 0;
+ } else {
+ return ( diff % first === 0 && diff / first >= 0 );
+ }
+ }
+ },
+ ID: function(elem, match){
+ return elem.nodeType === 1 && elem.getAttribute("id") === match;
+ },
+ TAG: function(elem, match){
+ return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
+ },
+ CLASS: function(elem, match){
+ return (" " + (elem.className || elem.getAttribute("class")) + " ")
+ .indexOf( match ) > -1;
+ },
+ ATTR: function(elem, match){
+ var name = match[1],
+ result = Expr.attrHandle[ name ] ?
+ Expr.attrHandle[ name ]( elem ) :
+ elem[ name ] != null ?
+ elem[ name ] :
+ elem.getAttribute( name ),
+ value = result + "",
+ type = match[2],
+ check = match[4];
+
+ return result == null ?
+ type === "!=" :
+ type === "=" ?
+ value === check :
+ type === "*=" ?
+ value.indexOf(check) >= 0 :
+ type === "~=" ?
+ (" " + value + " ").indexOf(check) >= 0 :
+ !check ?
+ value && result !== false :
+ type === "!=" ?
+ value !== check :
+ type === "^=" ?
+ value.indexOf(check) === 0 :
+ type === "$=" ?
+ value.substr(value.length - check.length) === check :
+ type === "|=" ?
+ value === check || value.substr(0, check.length + 1) === check + "-" :
+ false;
+ },
+ POS: function(elem, match, i, array){
+ var name = match[2], filter = Expr.setFilters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+ }
+ }
+ }
+};
+
+var origPOS = Expr.match.POS;
+
+for ( var type in Expr.match ) {
+ Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source );
+ Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, function(all, num){
+ return "\\" + (num - 0 + 1);
+ }));
+}
+
+var makeArray = function(array, results) {
+ array = Array.prototype.slice.call( array, 0 );
+
+ if ( results ) {
+ results.push.apply( results, array );
+ return results;
+ }
+
+ return array;
+};
+
+// Perform a simple check to determine if the browser is capable of
+// converting a NodeList to an array using builtin methods.
+try {
+ Array.prototype.slice.call( document.documentElement.childNodes, 0 );
+
+// Provide a fallback method if it does not work
+} catch(e){
+ makeArray = function(array, results) {
+ var ret = results || [];
+
+ if ( toString.call(array) === "[object Array]" ) {
+ Array.prototype.push.apply( ret, array );
+ } else {
+ if ( typeof array.length === "number" ) {
+ for ( var i = 0, l = array.length; i < l; i++ ) {
+ ret.push( array[i] );
+ }
+ } else {
+ for ( var i = 0; array[i]; i++ ) {
+ ret.push( array[i] );
+ }
+ }
+ }
+
+ return ret;
+ };
+}
+
+var sortOrder;
+
+if ( document.documentElement.compareDocumentPosition ) {
+ sortOrder = function( a, b ) {
+ if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.compareDocumentPosition ? -1 : 1;
+ }
+
+ var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+} else if ( "sourceIndex" in document.documentElement ) {
+ sortOrder = function( a, b ) {
+ if ( !a.sourceIndex || !b.sourceIndex ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.sourceIndex ? -1 : 1;
+ }
+
+ var ret = a.sourceIndex - b.sourceIndex;
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+} else if ( document.createRange ) {
+ sortOrder = function( a, b ) {
+ if ( !a.ownerDocument || !b.ownerDocument ) {
+ if ( a == b ) {
+ hasDuplicate = true;
+ }
+ return a.ownerDocument ? -1 : 1;
+ }
+
+ var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();
+ aRange.setStart(a, 0);
+ aRange.setEnd(a, 0);
+ bRange.setStart(b, 0);
+ bRange.setEnd(b, 0);
+ var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange);
+ if ( ret === 0 ) {
+ hasDuplicate = true;
+ }
+ return ret;
+ };
+}
+
+// Utility function for retreiving the text value of an array of DOM nodes
+function getText( elems ) {
+ var ret = "", elem;
+
+ for ( var i = 0; elems[i]; i++ ) {
+ elem = elems[i];
+
+ // Get the text from text nodes and CDATA nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
+ ret += elem.nodeValue;
+
+ // Traverse everything else, except comment nodes
+ } else if ( elem.nodeType !== 8 ) {
+ ret += getText( elem.childNodes );
+ }
+ }
+
+ return ret;
+}
+
+// Check to see if the browser returns elements by name when
+// querying by getElementById (and provide a workaround)
+(function(){
+ // We're going to inject a fake input element with a specified name
+ var form = document.createElement("div"),
+ id = "script" + (new Date).getTime();
+ form.innerHTML = "<a name='" + id + "'/>";
+
+ // Inject it into the root element, check its status, and remove it quickly
+ var root = document.documentElement;
+ root.insertBefore( form, root.firstChild );
+
+ // The workaround has to do additional checks after a getElementById
+ // Which slows things down for other browsers (hence the branching)
+ if ( document.getElementById( id ) ) {
+ Expr.find.ID = function(match, context, isXML){
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+ return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
+ }
+ };
+
+ Expr.filter.ID = function(elem, match){
+ var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
+ return elem.nodeType === 1 && node && node.nodeValue === match;
+ };
+ }
+
+ root.removeChild( form );
+ root = form = null; // release memory in IE
+})();
+
+(function(){
+ // Check to see if the browser returns only elements
+ // when doing getElementsByTagName("*")
+
+ // Create a fake element
+ var div = document.createElement("div");
+ div.appendChild( document.createComment("") );
+
+ // Make sure no comments are found
+ if ( div.getElementsByTagName("*").length > 0 ) {
+ Expr.find.TAG = function(match, context){
+ var results = context.getElementsByTagName(match[1]);
+
+ // Filter out possible comments
+ if ( match[1] === "*" ) {
+ var tmp = [];
+
+ for ( var i = 0; results[i]; i++ ) {
+ if ( results[i].nodeType === 1 ) {
+ tmp.push( results[i] );
+ }
+ }
+
+ results = tmp;
+ }
+
+ return results;
+ };
+ }
+
+ // Check to see if an attribute returns normalized href attributes
+ div.innerHTML = "<a href='#'></a>";
+ if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
+ div.firstChild.getAttribute("href") !== "#" ) {
+ Expr.attrHandle.href = function(elem){
+ return elem.getAttribute("href", 2);
+ };
+ }
+
+ div = null; // release memory in IE
+})();
+
+if ( document.querySelectorAll ) {
+ (function(){
+ var oldSizzle = Sizzle, div = document.createElement("div");
+ div.innerHTML = "<p class='TEST'></p>";
+
+ // Safari can't handle uppercase or unicode characters when
+ // in quirks mode.
+ if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
+ return;
+ }
+
+ Sizzle = function(query, context, extra, seed){
+ context = context || document;
+
+ // Only use querySelectorAll on non-XML documents
+ // (ID selectors don't work in non-HTML documents)
+ if ( !seed && context.nodeType === 9 && !isXML(context) ) {
+ try {
+ return makeArray( context.querySelectorAll(query), extra );
+ } catch(e){}
+ }
+
+ return oldSizzle(query, context, extra, seed);
+ };
+
+ for ( var prop in oldSizzle ) {
+ Sizzle[ prop ] = oldSizzle[ prop ];
+ }
+
+ div = null; // release memory in IE
+ })();
+}
+
+(function(){
+ var div = document.createElement("div");
+
+ div.innerHTML = "<div class='test e'></div><div class='test'></div>";
+
+ // Opera can't find a second classname (in 9.6)
+ // Also, make sure that getElementsByClassName actually exists
+ if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
+ return;
+ }
+
+ // Safari caches class attributes, doesn't catch changes (in 3.2)
+ div.lastChild.className = "e";
+
+ if ( div.getElementsByClassName("e").length === 1 ) {
+ return;
+ }
+
+ Expr.order.splice(1, 0, "CLASS");
+ Expr.find.CLASS = function(match, context, isXML) {
+ if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
+ return context.getElementsByClassName(match[1]);
+ }
+ };
+
+ div = null; // release memory in IE
+})();
+
+function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ elem = elem[dir];
+ var match = false;
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 && !isXML ){
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+
+ if ( elem.nodeName.toLowerCase() === cur ) {
+ match = elem;
+ break;
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ elem = elem[dir];
+ var match = false;
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 ) {
+ if ( !isXML ) {
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+ if ( typeof cur !== "string" ) {
+ if ( elem === cur ) {
+ match = true;
+ break;
+ }
+
+ } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
+ match = elem;
+ break;
+ }
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+var contains = document.compareDocumentPosition ? function(a, b){
+ return a.compareDocumentPosition(b) & 16;
+} : function(a, b){
+ return a !== b && (a.contains ? a.contains(b) : true);
+};
+
+var isXML = function(elem){
+ // documentElement is verified for cases where it doesn't yet exist
+ // (such as loading iframes in IE - #4833)
+ var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
+ return documentElement ? documentElement.nodeName !== "HTML" : false;
+};
+
+var posProcess = function(selector, context){
+ var tmpSet = [], later = "", match,
+ root = context.nodeType ? [context] : context;
+
+ // Position selectors must be done after the filter
+ // And so must :not(positional) so we move all PSEUDOs to the end
+ while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
+ later += match[0];
+ selector = selector.replace( Expr.match.PSEUDO, "" );
+ }
+
+ selector = Expr.relative[selector] ? selector + "*" : selector;
+
+ for ( var i = 0, l = root.length; i < l; i++ ) {
+ Sizzle( selector, root[i], tmpSet );
+ }
+
+ return Sizzle.filter( later, tmpSet );
+};
+
+// EXPOSE
+jQuery.find = Sizzle;
+jQuery.expr = Sizzle.selectors;
+jQuery.expr[":"] = jQuery.expr.filters;
+jQuery.unique = Sizzle.uniqueSort;
+jQuery.getText = getText;
+jQuery.isXMLDoc = isXML;
+jQuery.contains = contains;
+
+return;
+
+window.Sizzle = Sizzle;
+
+})();
+var runtil = /Until$/,
+ rparentsprev = /^(?:parents|prevUntil|prevAll)/,
+ // Note: This RegExp should be improved, or likely pulled from Sizzle
+ rmultiselector = /,/,
+ slice = Array.prototype.slice;
+
+// Implement the identical functionality for filter and not
+var winnow = function( elements, qualifier, keep ) {
+ if ( jQuery.isFunction( qualifier ) ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ return !!qualifier.call( elem, i, elem ) === keep;
+ });
+
+ } else if ( qualifier.nodeType ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ return (elem === qualifier) === keep;
+ });
+
+ } else if ( typeof qualifier === "string" ) {
+ var filtered = jQuery.grep(elements, function( elem ) {
+ return elem.nodeType === 1;
+ });
+
+ if ( isSimple.test( qualifier ) ) {
+ return jQuery.filter(qualifier, filtered, !keep);
+ } else {
+ qualifier = jQuery.filter( qualifier, elements );
+ }
+ }
+
+ return jQuery.grep(elements, function( elem, i ) {
+ return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
+ });
+};
+
+jQuery.fn.extend({
+ find: function( selector ) {
+ var ret = this.pushStack( "", "find", selector ), length = 0;
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ length = ret.length;
+ jQuery.find( selector, this[i], ret );
+
+ if ( i > 0 ) {
+ // Make sure that the results are unique
+ for ( var n = length; n < ret.length; n++ ) {
+ for ( var r = 0; r < length; r++ ) {
+ if ( ret[r] === ret[n] ) {
+ ret.splice(n--, 1);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return ret;
+ },
+
+ has: function( target ) {
+ var targets = jQuery( target );
+ return this.filter(function() {
+ for ( var i = 0, l = targets.length; i < l; i++ ) {
+ if ( jQuery.contains( this, targets[i] ) ) {
+ return true;
+ }
+ }
+ });
+ },
+
+ not: function( selector ) {
+ return this.pushStack( winnow(this, selector, false), "not", selector);
+ },
+
+ filter: function( selector ) {
+ return this.pushStack( winnow(this, selector, true), "filter", selector );
+ },
+
+ is: function( selector ) {
+ return !!selector && jQuery.filter( selector, this ).length > 0;
+ },
+
+ closest: function( selectors, context ) {
+ if ( jQuery.isArray( selectors ) ) {
+ var ret = [], cur = this[0], match, matches = {}, selector;
+
+ if ( cur && selectors.length ) {
+ for ( var i = 0, l = selectors.length; i < l; i++ ) {
+ selector = selectors[i];
+
+ if ( !matches[selector] ) {
+ matches[selector] = jQuery.expr.match.POS.test( selector ) ?
+ jQuery( selector, context || this.context ) :
+ selector;
+ }
+ }
+
+ while ( cur && cur.ownerDocument && cur !== context ) {
+ for ( selector in matches ) {
+ match = matches[selector];
+
+ if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) {
+ ret.push({ selector: selector, elem: cur });
+ delete matches[selector];
+ }
+ }
+ cur = cur.parentNode;
+ }
+ }
+
+ return ret;
+ }
+
+ var pos = jQuery.expr.match.POS.test( selectors ) ?
+ jQuery( selectors, context || this.context ) : null;
+
+ return this.map(function( i, cur ) {
+ while ( cur && cur.ownerDocument && cur !== context ) {
+ if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selectors) ) {
+ return cur;
+ }
+ cur = cur.parentNode;
+ }
+ return null;
+ });
+ },
+
+ // Determine the position of an element within
+ // the matched set of elements
+ index: function( elem ) {
+ if ( !elem || typeof elem === "string" ) {
+ return jQuery.inArray( this[0],
+ // If it receives a string, the selector is used
+ // If it receives nothing, the siblings are used
+ elem ? jQuery( elem ) : this.parent().children() );
+ }
+ // Locate the position of the desired element
+ return jQuery.inArray(
+ // If it receives a jQuery object, the first element is used
+ elem.jquery ? elem[0] : elem, this );
+ },
+
+ add: function( selector, context ) {
+ var set = typeof selector === "string" ?
+ jQuery( selector, context || this.context ) :
+ jQuery.makeArray( selector ),
+ all = jQuery.merge( this.get(), set );
+
+ return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
+ all :
+ jQuery.unique( all ) );
+ },
+
+ andSelf: function() {
+ return this.add( this.prevObject );
+ }
+});
+
+// A painfully simple check to see if an element is disconnected
+// from a document (should be improved, where feasible).
+function isDisconnected( node ) {
+ return !node || !node.parentNode || node.parentNode.nodeType === 11;
+}
+
+jQuery.each({
+ parent: function( elem ) {
+ var parent = elem.parentNode;
+ return parent && parent.nodeType !== 11 ? parent : null;
+ },
+ parents: function( elem ) {
+ return jQuery.dir( elem, "parentNode" );
+ },
+ parentsUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "parentNode", until );
+ },
+ next: function( elem ) {
+ return jQuery.nth( elem, 2, "nextSibling" );
+ },
+ prev: function( elem ) {
+ return jQuery.nth( elem, 2, "previousSibling" );
+ },
+ nextAll: function( elem ) {
+ return jQuery.dir( elem, "nextSibling" );
+ },
+ prevAll: function( elem ) {
+ return jQuery.dir( elem, "previousSibling" );
+ },
+ nextUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "nextSibling", until );
+ },
+ prevUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "previousSibling", until );
+ },
+ siblings: function( elem ) {
+ return jQuery.sibling( elem.parentNode.firstChild, elem );
+ },
+ children: function( elem ) {
+ return jQuery.sibling( elem.firstChild );
+ },
+ contents: function( elem ) {
+ return jQuery.nodeName( elem, "iframe" ) ?
+ elem.contentDocument || elem.contentWindow.document :
+ jQuery.makeArray( elem.childNodes );
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function( until, selector ) {
+ var ret = jQuery.map( this, fn, until );
+
+ if ( !runtil.test( name ) ) {
+ selector = until;
+ }
+
+ if ( selector && typeof selector === "string" ) {
+ ret = jQuery.filter( selector, ret );
+ }
+
+ ret = this.length > 1 ? jQuery.unique( ret ) : ret;
+
+ if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
+ ret = ret.reverse();
+ }
+
+ return this.pushStack( ret, name, slice.call(arguments).join(",") );
+ };
+});
+
+jQuery.extend({
+ filter: function( expr, elems, not ) {
+ if ( not ) {
+ expr = ":not(" + expr + ")";
+ }
+
+ return jQuery.find.matches(expr, elems);
+ },
+
+ dir: function( elem, dir, until ) {
+ var matched = [], cur = elem[dir];
+ while ( cur && cur.nodeType !== 9 && (until === undefined || !jQuery( cur ).is( until )) ) {
+ if ( cur.nodeType === 1 ) {
+ matched.push( cur );
+ }
+ cur = cur[dir];
+ }
+ return matched;
+ },
+
+ nth: function( cur, result, dir, elem ) {
+ result = result || 1;
+ var num = 0;
+
+ for ( ; cur; cur = cur[dir] ) {
+ if ( cur.nodeType === 1 && ++num === result ) {
+ break;
+ }
+ }
+
+ return cur;
+ },
+
+ sibling: function( n, elem ) {
+ var r = [];
+
+ for ( ; n; n = n.nextSibling ) {
+ if ( n.nodeType === 1 && n !== elem ) {
+ r.push( n );
+ }
+ }
+
+ return r;
+ }
+});
+var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
+ rleadingWhitespace = /^\s+/,
+ rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g,
+ rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,
+ rtagName = /<([\w:]+)/,
+ rtbody = /<tbody/i,
+ rhtml = /<|&\w+;/,
+ fcloseTag = function( all, front, tag ) {
+ return rselfClosing.test( tag ) ?
+ all :
+ front + "></" + tag + ">";
+ },
+ wrapMap = {
+ option: [ 1, "<select multiple='multiple'>", "</select>" ],
+ legend: [ 1, "<fieldset>", "</fieldset>" ],
+ thead: [ 1, "<table>", "</table>" ],
+ tr: [ 2, "<table><tbody>", "</tbody></table>" ],
+ td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
+ col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
+ area: [ 1, "<map>", "</map>" ],
+ _default: [ 0, "", "" ]
+ };
+
+wrapMap.optgroup = wrapMap.option;
+wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
+wrapMap.th = wrapMap.td;
+
+// IE can't serialize <link> and <script> tags normally
+if ( !jQuery.support.htmlSerialize ) {
+ wrapMap._default = [ 1, "div<div>", "</div>" ];
+}
+
+jQuery.fn.extend({
+ text: function( text ) {
+ if ( jQuery.isFunction(text) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ return self.text( text.call(this, i, self.text()) );
+ });
+ }
+
+ if ( typeof text !== "object" && text !== undefined ) {
+ return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
+ }
+
+ return jQuery.getText( this );
+ },
+
+ wrapAll: function( html ) {
+ if ( jQuery.isFunction( html ) ) {
+ return this.each(function(i) {
+ jQuery(this).wrapAll( html.call(this, i) );
+ });
+ }
+
+ if ( this[0] ) {
+ // The elements to wrap the target around
+ var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
+
+ if ( this[0].parentNode ) {
+ wrap.insertBefore( this[0] );
+ }
+
+ wrap.map(function() {
+ var elem = this;
+
+ while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
+ elem = elem.firstChild;
+ }
+
+ return elem;
+ }).append(this);
+ }
+
+ return this;
+ },
+
+ wrapInner: function( html ) {
+ return this.each(function() {
+ var self = jQuery( this ), contents = self.contents();
+
+ if ( contents.length ) {
+ contents.wrapAll( html );
+
+ } else {
+ self.append( html );
+ }
+ });
+ },
+
+ wrap: function( html ) {
+ return this.each(function() {
+ jQuery( this ).wrapAll( html );
+ });
+ },
+
+ unwrap: function() {
+ return this.parent().each(function() {
+ if ( !jQuery.nodeName( this, "body" ) ) {
+ jQuery( this ).replaceWith( this.childNodes );
+ }
+ }).end();
+ },
+
+ append: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 ) {
+ this.appendChild( elem );
+ }
+ });
+ },
+
+ prepend: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 ) {
+ this.insertBefore( elem, this.firstChild );
+ }
+ });
+ },
+
+ before: function() {
+ if ( this[0] && this[0].parentNode ) {
+ return this.domManip(arguments, false, function( elem ) {
+ this.parentNode.insertBefore( elem, this );
+ });
+ } else if ( arguments.length ) {
+ var set = jQuery(arguments[0]);
+ set.push.apply( set, this.toArray() );
+ return this.pushStack( set, "before", arguments );
+ }
+ },
+
+ after: function() {
+ if ( this[0] && this[0].parentNode ) {
+ return this.domManip(arguments, false, function( elem ) {
+ this.parentNode.insertBefore( elem, this.nextSibling );
+ });
+ } else if ( arguments.length ) {
+ var set = this.pushStack( this, "after", arguments );
+ set.push.apply( set, jQuery(arguments[0]).toArray() );
+ return set;
+ }
+ },
+
+ clone: function( events ) {
+ // Do the clone
+ var ret = this.map(function() {
+ if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) {
+ // IE copies events bound via attachEvent when
+ // using cloneNode. Calling detachEvent on the
+ // clone will also remove the events from the orignal
+ // In order to get around this, we use innerHTML.
+ // Unfortunately, this means some modifications to
+ // attributes in IE that are actually only stored
+ // as properties will not be copied (such as the
+ // the name attribute on an input).
+ var html = this.outerHTML, ownerDocument = this.ownerDocument;
+ if ( !html ) {
+ var div = ownerDocument.createElement("div");
+ div.appendChild( this.cloneNode(true) );
+ html = div.innerHTML;
+ }
+
+ return jQuery.clean([html.replace(rinlinejQuery, "")
+ .replace(rleadingWhitespace, "")], ownerDocument)[0];
+ } else {
+ return this.cloneNode(true);
+ }
+ });
+
+ // Copy the events from the original to the clone
+ if ( events === true ) {
+ cloneCopyEvent( this, ret );
+ cloneCopyEvent( this.find("*"), ret.find("*") );
+ }
+
+ // Return the cloned set
+ return ret;
+ },
+
+ html: function( value ) {
+ if ( value === undefined ) {
+ return this[0] && this[0].nodeType === 1 ?
+ this[0].innerHTML.replace(rinlinejQuery, "") :
+ null;
+
+ // See if we can take a shortcut and just use innerHTML
+ } else if ( typeof value === "string" && !/<script/i.test( value ) &&
+ (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
+ !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
+
+ try {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ // Remove element nodes and prevent memory leaks
+ if ( this[i].nodeType === 1 ) {
+ cleanData( this[i].getElementsByTagName("*") );
+ this[i].innerHTML = value;
+ }
+ }
+
+ // If using innerHTML throws an exception, use the fallback method
+ } catch(e) {
+ this.empty().append( value );
+ }
+
+ } else if ( jQuery.isFunction( value ) ) {
+ this.each(function(i){
+ var self = jQuery(this), old = self.html();
+ self.empty().append(function(){
+ return value.call( this, i, old );
+ });
+ });
+
+ } else {
+ this.empty().append( value );
+ }
+
+ return this;
+ },
+
+ replaceWith: function( value ) {
+ if ( this[0] && this[0].parentNode ) {
+ // Make sure that the elements are removed from the DOM before they are inserted
+ // this can help fix replacing a parent with child elements
+ if ( !jQuery.isFunction( value ) ) {
+ value = jQuery( value ).detach();
+ }
+
+ return this.each(function() {
+ var next = this.nextSibling, parent = this.parentNode;
+
+ jQuery(this).remove();
+
+ if ( next ) {
+ jQuery(next).before( value );
+ } else {
+ jQuery(parent).append( value );
+ }
+ });
+ } else {
+ return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value );
+ }
+ },
+
+ detach: function( selector ) {
+ return this.remove( selector, true );
+ },
+
+ domManip: function( args, table, callback ) {
+ var results, first, value = args[0], scripts = [];
+
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ args[0] = value.call(this, i, table ? self.html() : undefined);
+ return self.domManip( args, table, callback );
+ });
+ }
+
+ if ( this[0] ) {
+ // If we're in a fragment, just use that instead of building a new one
+ if ( args[0] && args[0].parentNode && args[0].parentNode.nodeType === 11 ) {
+ results = { fragment: args[0].parentNode };
+ } else {
+ results = buildFragment( args, this, scripts );
+ }
+
+ first = results.fragment.firstChild;
+
+ if ( first ) {
+ table = table && jQuery.nodeName( first, "tr" );
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ callback.call(
+ table ?
+ root(this[i], first) :
+ this[i],
+ results.cacheable || this.length > 1 || i > 0 ?
+ results.fragment.cloneNode(true) :
+ results.fragment
+ );
+ }
+ }
+
+ if ( scripts ) {
+ jQuery.each( scripts, evalScript );
+ }
+ }
+
+ return this;
+
+ function root( elem, cur ) {
+ return jQuery.nodeName(elem, "table") ?
+ (elem.getElementsByTagName("tbody")[0] ||
+ elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
+ elem;
+ }
+ }
+});
+
+function cloneCopyEvent(orig, ret) {
+ var i = 0;
+
+ ret.each(function() {
+ if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) {
+ return;
+ }
+
+ var oldData = jQuery.data( orig[i++] ), curData = jQuery.data( this, oldData ), events = oldData && oldData.events;
+
+ if ( events ) {
+ delete curData.handle;
+ curData.events = {};
+
+ for ( var type in events ) {
+ for ( var handler in events[ type ] ) {
+ jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data );
+ }
+ }
+ }
+ });
+}
+
+function buildFragment( args, nodes, scripts ) {
+ var fragment, cacheable, cached, cacheresults, doc;
+
+ if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) {
+ cacheable = true;
+ cacheresults = jQuery.fragments[ args[0] ];
+ if ( cacheresults ) {
+ if ( cacheresults !== 1 ) {
+ fragment = cacheresults;
+ }
+ cached = true;
+ }
+ }
+
+ if ( !fragment ) {
+ doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
+ fragment = doc.createDocumentFragment();
+ jQuery.clean( args, doc, fragment, scripts );
+ }
+
+ if ( cacheable ) {
+ jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
+ }
+
+ return { fragment: fragment, cacheable: cacheable };
+}
+
+jQuery.fragments = {};
+
+jQuery.each({
+ appendTo: "append",
+ prependTo: "prepend",
+ insertBefore: "before",
+ insertAfter: "after",
+ replaceAll: "replaceWith"
+}, function( name, original ) {
+ jQuery.fn[ name ] = function( selector ) {
+ var ret = [], insert = jQuery( selector );
+
+ for ( var i = 0, l = insert.length; i < l; i++ ) {
+ var elems = (i > 0 ? this.clone(true) : this).get();
+ jQuery.fn[ original ].apply( jQuery(insert[i]), elems );
+ ret = ret.concat( elems );
+ }
+ return this.pushStack( ret, name, insert.selector );
+ };
+});
+
+jQuery.each({
+ // keepData is for internal use only--do not document
+ remove: function( selector, keepData ) {
+ if ( !selector || jQuery.filter( selector, [ this ] ).length ) {
+ if ( !keepData && this.nodeType === 1 ) {
+ cleanData( this.getElementsByTagName("*") );
+ cleanData( [ this ] );
+ }
+
+ if ( this.parentNode ) {
+ this.parentNode.removeChild( this );
+ }
+ }
+ },
+
+ empty: function() {
+ // Remove element nodes and prevent memory leaks
+ if ( this.nodeType === 1 ) {
+ cleanData( this.getElementsByTagName("*") );
+ }
+
+ // Remove any remaining nodes
+ while ( this.firstChild ) {
+ this.removeChild( this.firstChild );
+ }
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function() {
+ return this.each( fn, arguments );
+ };
+});
+
+jQuery.extend({
+ clean: function( elems, context, fragment, scripts ) {
+ context = context || document;
+
+ // !context.createElement fails in IE with an error but returns typeof 'object'
+ if ( typeof context.createElement === "undefined" ) {
+ context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
+ }
+
+ var ret = [];
+
+ jQuery.each(elems, function( i, elem ) {
+ if ( typeof elem === "number" ) {
+ elem += "";
+ }
+
+ if ( !elem ) {
+ return;
+ }
+
+ // Convert html string into DOM nodes
+ if ( typeof elem === "string" && !rhtml.test( elem ) ) {
+ elem = context.createTextNode( elem );
+
+ } else if ( typeof elem === "string" ) {
+ // Fix "XHTML"-style tags in all browsers
+ elem = elem.replace(rxhtmlTag, fcloseTag);
+
+ // Trim whitespace, otherwise indexOf won't work as expected
+ var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
+ wrap = wrapMap[ tag ] || wrapMap._default,
+ depth = wrap[0],
+ div = context.createElement("div");
+
+ // Go to html and back, then peel off extra wrappers
+ div.innerHTML = wrap[1] + elem + wrap[2];
+
+ // Move to the right depth
+ while ( depth-- ) {
+ div = div.lastChild;
+ }
+
+ // Remove IE's autoinserted <tbody> from table fragments
+ if ( !jQuery.support.tbody ) {
+
+ // String was a <table>, *may* have spurious <tbody>
+ var hasBody = rtbody.test(elem),
+ tbody = tag === "table" && !hasBody ?
+ div.firstChild && div.firstChild.childNodes :
+
+ // String was a bare <thead> or <tfoot>
+ wrap[1] === "<table>" && !hasBody ?
+ div.childNodes :
+ [];
+
+ for ( var j = tbody.length - 1; j >= 0 ; --j ) {
+ if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
+ tbody[ j ].parentNode.removeChild( tbody[ j ] );
+ }
+ }
+
+ }
+
+ // IE completely kills leading whitespace when innerHTML is used
+ if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
+ div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
+ }
+
+ elem = jQuery.makeArray( div.childNodes );
+ }
+
+ if ( elem.nodeType ) {
+ ret.push( elem );
+ } else {
+ ret = jQuery.merge( ret, elem );
+ }
+
+ });
+
+ if ( fragment ) {
+ for ( var i = 0; ret[i]; i++ ) {
+ if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
+ scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
+ } else {
+ if ( ret[i].nodeType === 1 ) {
+ ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
+ }
+ fragment.appendChild( ret[i] );
+ }
+ }
+ }
+
+ return ret;
+ }
+});
+
+function cleanData( elems ) {
+ for ( var i = 0, elem, id; (elem = elems[i]) != null; i++ ) {
+ if ( !jQuery.noData[elem.nodeName.toLowerCase()] && (id = elem[expando]) ) {
+ delete jQuery.cache[ id ];
+ }
+ }
+}
+// exclude the following css properties to add px
+var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
+ ralpha = /alpha\([^)]*\)/,
+ ropacity = /opacity=([^)]*)/,
+ rfloat = /float/i,
+ rdashAlpha = /-([a-z])/ig,
+ rupper = /([A-Z])/g,
+ rnumpx = /^-?\d+(?:px)?$/i,
+ rnum = /^-?\d/,
+
+ cssShow = { position: "absolute", visibility: "hidden", display:"block" },
+ cssWidth = [ "Left", "Right" ],
+ cssHeight = [ "Top", "Bottom" ],
+
+ // cache check for defaultView.getComputedStyle
+ getComputedStyle = document.defaultView && document.defaultView.getComputedStyle,
+ // normalize float css property
+ styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat",
+ fcamelCase = function( all, letter ) {
+ return letter.toUpperCase();
+ };
+
+jQuery.fn.css = function( name, value ) {
+ return access( this, name, value, true, function( elem, name, value ) {
+ if ( value === undefined ) {
+ return jQuery.curCSS( elem, name );
+ }
+
+ if ( typeof value === "number" && !rexclude.test(name) ) {
+ value += "px";
+ }
+
+ jQuery.style( elem, name, value );
+ });
+};
+
+jQuery.extend({
+ style: function( elem, name, value ) {
+ // don't set styles on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ // ignore negative width and height values #1599
+ if ( (name === "width" || name === "height") && parseFloat(value) < 0 ) {
+ value = undefined;
+ }
+
+ var style = elem.style || elem, set = value !== undefined;
+
+ // IE uses filters for opacity
+ if ( !jQuery.support.opacity && name === "opacity" ) {
+ if ( set ) {
+ // IE has trouble with opacity if it does not have layout
+ // Force it by setting the zoom level
+ style.zoom = 1;
+
+ // Set the alpha filter to set the opacity
+ var opacity = parseInt( value, 10 ) + "" === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")";
+ var filter = style.filter || jQuery.curCSS( elem, "filter" ) || "";
+ style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : opacity;
+ }
+
+ return style.filter && style.filter.indexOf("opacity=") >= 0 ?
+ (parseFloat( ropacity.exec(style.filter)[1] ) / 100) + "":
+ "";
+ }
+
+ // Make sure we're using the right name for getting the float value
+ if ( rfloat.test( name ) ) {
+ name = styleFloat;
+ }
+
+ name = name.replace(rdashAlpha, fcamelCase);
+
+ if ( set ) {
+ style[ name ] = value;
+ }
+
+ return style[ name ];
+ },
+
+ css: function( elem, name, force, extra ) {
+ if ( name === "width" || name === "height" ) {
+ var val, props = cssShow, which = name === "width" ? cssWidth : cssHeight;
+
+ function getWH() {
+ val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
+
+ if ( extra === "border" ) {
+ return;
+ }
+
+ jQuery.each( which, function() {
+ if ( !extra ) {
+ val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
+ }
+
+ if ( extra === "margin" ) {
+ val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0;
+ } else {
+ val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
+ }
+ });
+ }
+
+ if ( elem.offsetWidth !== 0 ) {
+ getWH();
+ } else {
+ jQuery.swap( elem, props, getWH );
+ }
+
+ return Math.max(0, Math.round(val));
+ }
+
+ return jQuery.curCSS( elem, name, force );
+ },
+
+ curCSS: function( elem, name, force ) {
+ var ret, style = elem.style, filter;
+
+ // IE uses filters for opacity
+ if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) {
+ ret = ropacity.test(elem.currentStyle.filter || "") ?
+ (parseFloat(RegExp.$1) / 100) + "" :
+ "";
+
+ return ret === "" ?
+ "1" :
+ ret;
+ }
+
+ // Make sure we're using the right name for getting the float value
+ if ( rfloat.test( name ) ) {
+ name = styleFloat;
+ }
+
+ if ( !force && style && style[ name ] ) {
+ ret = style[ name ];
+
+ } else if ( getComputedStyle ) {
+
+ // Only "float" is needed here
+ if ( rfloat.test( name ) ) {
+ name = "float";
+ }
+
+ name = name.replace( rupper, "-$1" ).toLowerCase();
+
+ var defaultView = elem.ownerDocument.defaultView;
+
+ if ( !defaultView ) {
+ return null;
+ }
+
+ var computedStyle = defaultView.getComputedStyle( elem, null );
+
+ if ( computedStyle ) {
+ ret = computedStyle.getPropertyValue( name );
+ }
+
+ // We should always get a number back from opacity
+ if ( name === "opacity" && ret === "" ) {
+ ret = "1";
+ }
+
+ } else if ( elem.currentStyle ) {
+ var camelCase = name.replace(rdashAlpha, fcamelCase);
+
+ ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
+
+ // From the awesome hack by Dean Edwards
+ // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
+
+ // If we're not dealing with a regular pixel number
+ // but a number that has a weird ending, we need to convert it to pixels
+ if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
+ // Remember the original values
+ var left = style.left, rsLeft = elem.runtimeStyle.left;
+
+ // Put in the new values to get a computed value out
+ elem.runtimeStyle.left = elem.currentStyle.left;
+ style.left = camelCase === "fontSize" ? "1em" : (ret || 0);
+ ret = style.pixelLeft + "px";
+
+ // Revert the changed values
+ style.left = left;
+ elem.runtimeStyle.left = rsLeft;
+ }
+ }
+
+ return ret;
+ },
+
+ // A method for quickly swapping in/out CSS properties to get correct calculations
+ swap: function( elem, options, callback ) {
+ var old = {};
+
+ // Remember the old values, and insert the new ones
+ for ( var name in options ) {
+ old[ name ] = elem.style[ name ];
+ elem.style[ name ] = options[ name ];
+ }
+
+ callback.call( elem );
+
+ // Revert the old values
+ for ( var name in options ) {
+ elem.style[ name ] = old[ name ];
+ }
+ }
+});
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.hidden = function( elem ) {
+ var width = elem.offsetWidth, height = elem.offsetHeight,
+ skip = elem.nodeName.toLowerCase() === "tr";
+
+ return width === 0 && height === 0 && !skip ?
+ true :
+ width > 0 && height > 0 && !skip ?
+ false :
+ jQuery.curCSS(elem, "display") === "none";
+ };
+
+ jQuery.expr.filters.visible = function( elem ) {
+ return !jQuery.expr.filters.hidden( elem );
+ };
+}
+var jsc = now(),
+ rscript = /<script(.|\s)*?\/script>/gi,
+ rselectTextarea = /select|textarea/i,
+ rinput = /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,
+ jsre = /=\?(&|$)/,
+ rquery = /\?/,
+ rts = /(\?|&)_=.*?(&|$)/,
+ rurl = /^(\w+:)?\/\/([^\/?#]+)/,
+ r20 = /%20/g;
+
+jQuery.fn.extend({
+ // Keep a copy of the old load
+ _load: jQuery.fn.load,
+
+ load: function( url, params, callback ) {
+ if ( typeof url !== "string" ) {
+ return this._load( url );
+
+ // Don't do a request if no elements are being requested
+ } else if ( !this.length ) {
+ return this;
+ }
+
+ var off = url.indexOf(" ");
+ if ( off >= 0 ) {
+ var selector = url.slice(off, url.length);
+ url = url.slice(0, off);
+ }
+
+ // Default to a GET request
+ var type = "GET";
+
+ // If the second parameter was provided
+ if ( params ) {
+ // If it's a function
+ if ( jQuery.isFunction( params ) ) {
+ // We assume that it's the callback
+ callback = params;
+ params = null;
+
+ // Otherwise, build a param string
+ } else if ( typeof params === "object" ) {
+ params = jQuery.param( params, jQuery.ajaxSettings.traditional );
+ type = "POST";
+ }
+ }
+
+ // Request the remote document
+ jQuery.ajax({
+ url: url,
+ type: type,
+ dataType: "html",
+ data: params,
+ context:this,
+ complete: function( res, status ) {
+ // If successful, inject the HTML into all the matched elements
+ if ( status === "success" || status === "notmodified" ) {
+ // See if a selector was specified
+ this.html( selector ?
+ // Create a dummy div to hold the results
+ jQuery("<div />")
+ // inject the contents of the document in, removing the scripts
+ // to avoid any 'Permission Denied' errors in IE
+ .append(res.responseText.replace(rscript, ""))
+
+ // Locate the specified elements
+ .find(selector) :
+
+ // If not, just inject the full result
+ res.responseText );
+ }
+
+ if ( callback ) {
+ this.each( callback, [res.responseText, status, res] );
+ }
+ }
+ });
+
+ return this;
+ },
+
+ serialize: function() {
+ return jQuery.param(this.serializeArray());
+ },
+ serializeArray: function() {
+ return this.map(function() {
+ return this.elements ? jQuery.makeArray(this.elements) : this;
+ })
+ .filter(function() {
+ return this.name && !this.disabled &&
+ (this.checked || rselectTextarea.test(this.nodeName) ||
+ rinput.test(this.type));
+ })
+ .map(function( i, elem ) {
+ var val = jQuery(this).val();
+
+ return val == null ?
+ null :
+ jQuery.isArray(val) ?
+ jQuery.map( val, function( val, i ) {
+ return { name: elem.name, value: val };
+ }) :
+ { name: elem.name, value: val };
+ }).get();
+ }
+});
+
+// Attach a bunch of functions for handling common AJAX events
+jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function( i, o ) {
+ jQuery.fn[o] = function( f ) {
+ return this.bind(o, f);
+ };
+});
+
+jQuery.extend({
+
+ get: function( url, data, callback, type ) {
+ // shift arguments if data argument was omited
+ if ( jQuery.isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = null;
+ }
+
+ return jQuery.ajax({
+ type: "GET",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ getScript: function( url, callback ) {
+ return jQuery.get(url, null, callback, "script");
+ },
+
+ getJSON: function( url, data, callback ) {
+ return jQuery.get(url, data, callback, "json");
+ },
+
+ post: function( url, data, callback, type ) {
+ // shift arguments if data argument was omited
+ if ( jQuery.isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = {};
+ }
+
+ return jQuery.ajax({
+ type: "POST",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ ajaxSetup: function( settings ) {
+ jQuery.extend( jQuery.ajaxSettings, settings );
+ },
+
+ ajaxSettings: {
+ url: location.href,
+ global: true,
+ type: "GET",
+ contentType: "application/x-www-form-urlencoded",
+ processData: true,
+ async: true,
+ /*
+ timeout: 0,
+ data: null,
+ username: null,
+ password: null,
+ traditional: false,
+ */
+ // Create the request object; Microsoft failed to properly
+ // implement the XMLHttpRequest in IE7 (can't request local files),
+ // so we use the ActiveXObject when it is available
+ // This function can be overriden by calling jQuery.ajaxSetup
+ xhr: window.XMLHttpRequest && (window.location.protocol !== "file:" || !window.ActiveXObject) ?
+ function() {
+ return new window.XMLHttpRequest();
+ } :
+ function() {
+ try {
+ return new window.ActiveXObject("Microsoft.XMLHTTP");
+ } catch(e) {}
+ },
+ accepts: {
+ xml: "application/xml, text/xml",
+ html: "text/html",
+ script: "text/javascript, application/javascript",
+ json: "application/json, text/javascript",
+ text: "text/plain",
+ _default: "*/*"
+ }
+ },
+
+ // Last-Modified header cache for next request
+ lastModified: {},
+ etag: {},
+
+ ajax: function( origSettings ) {
+ var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings);
+
+ var jsonp, status, data,
+ callbackContext = s.context || s,
+ type = s.type.toUpperCase();
+
+ // convert data if not already a string
+ if ( s.data && s.processData && typeof s.data !== "string" ) {
+ s.data = jQuery.param( s.data, s.traditional );
+ }
+
+ // Handle JSONP Parameter Callbacks
+ if ( s.dataType === "jsonp" ) {
+ if ( type === "GET" ) {
+ if ( !jsre.test( s.url ) ) {
+ s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?";
+ }
+ } else if ( !s.data || !jsre.test(s.data) ) {
+ s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
+ }
+ s.dataType = "json";
+ }
+
+ // Build temporary JSONP function
+ if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) {
+ jsonp = s.jsonpCallback || ("jsonp" + jsc++);
+
+ // Replace the =? sequence both in the query string and the data
+ if ( s.data ) {
+ s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
+ }
+
+ s.url = s.url.replace(jsre, "=" + jsonp + "$1");
+
+ // We need to make sure
+ // that a JSONP style response is executed properly
+ s.dataType = "script";
+
+ // Handle JSONP-style loading
+ window[ jsonp ] = window[ jsonp ] || function( tmp ) {
+ data = tmp;
+ success();
+ complete();
+ // Garbage collect
+ window[ jsonp ] = undefined;
+
+ try {
+ delete window[ jsonp ];
+ } catch(e) {}
+
+ if ( head ) {
+ head.removeChild( script );
+ }
+ };
+ }
+
+ if ( s.dataType === "script" && s.cache === null ) {
+ s.cache = false;
+ }
+
+ if ( s.cache === false && type === "GET" ) {
+ var ts = now();
+
+ // try replacing _= if it is there
+ var ret = s.url.replace(rts, "$1_=" + ts + "$2");
+
+ // if nothing was replaced, add timestamp to the end
+ s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : "");
+ }
+
+ // If data is available, append data to url for get requests
+ if ( s.data && type === "GET" ) {
+ s.url += (rquery.test(s.url) ? "&" : "?") + s.data;
+ }
+
+ // Watch for a new set of requests
+ if ( s.global && ! jQuery.active++ ) {
+ jQuery.event.trigger( "ajaxStart" );
+ }
+
+ // Matches an absolute URL, and saves the domain
+ var parts = rurl.exec( s.url ),
+ remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host);
+
+ // If we're requesting a remote document
+ // and trying to load JSON or Script with a GET
+ if ( s.dataType === "script" && type === "GET" && remote ) {
+ var head = document.getElementsByTagName("head")[0] || document.documentElement;
+ var script = document.createElement("script");
+ script.src = s.url;
+ if ( s.scriptCharset ) {
+ script.charset = s.scriptCharset;
+ }
+
+ // Handle Script loading
+ if ( !jsonp ) {
+ var done = false;
+
+ // Attach handlers for all browsers
+ script.onload = script.onreadystatechange = function() {
+ if ( !done && (!this.readyState ||
+ this.readyState === "loaded" || this.readyState === "complete") ) {
+ done = true;
+ success();
+ complete();
+
+ // Handle memory leak in IE
+ script.onload = script.onreadystatechange = null;
+ if ( head && script.parentNode ) {
+ head.removeChild( script );
+ }
+ }
+ };
+ }
+
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709 and #4378).
+ head.insertBefore( script, head.firstChild );
+
+ // We handle everything using the script element injection
+ return undefined;
+ }
+
+ var requestDone = false;
+
+ // Create the request object
+ var xhr = s.xhr();
+
+ if ( !xhr ) {
+ return;
+ }
+
+ // Open the socket
+ // Passing null username, generates a login popup on Opera (#2865)
+ if ( s.username ) {
+ xhr.open(type, s.url, s.async, s.username, s.password);
+ } else {
+ xhr.open(type, s.url, s.async);
+ }
+
+ // Need an extra try/catch for cross domain requests in Firefox 3
+ try {
+ // Set the correct header, if data is being sent
+ if ( s.data || origSettings && origSettings.contentType ) {
+ xhr.setRequestHeader("Content-Type", s.contentType);
+ }
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if ( s.ifModified ) {
+ if ( jQuery.lastModified[s.url] ) {
+ xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]);
+ }
+
+ if ( jQuery.etag[s.url] ) {
+ xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]);
+ }
+ }
+
+ // Set header so the called script knows that it's an XMLHttpRequest
+ // Only send the header if it's not a remote XHR
+ if ( !remote ) {
+ xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+ }
+
+ // Set the Accepts header for the server, depending on the dataType
+ xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ?
+ s.accepts[ s.dataType ] + ", */*" :
+ s.accepts._default );
+ } catch(e) {}
+
+ // Allow custom headers/mimetypes and early abort
+ if ( s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false ) {
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active ) {
+ jQuery.event.trigger( "ajaxStop" );
+ }
+
+ // close opended socket
+ xhr.abort();
+ return false;
+ }
+
+ if ( s.global ) {
+ trigger("ajaxSend", [xhr, s]);
+ }
+
+ // Wait for a response to come back
+ var onreadystatechange = xhr.onreadystatechange = function( isTimeout ) {
+ // The request was aborted
+ if ( !xhr || xhr.readyState === 0 ) {
+ // Opera doesn't call onreadystatechange before this point
+ // so we simulate the call
+ if ( !requestDone ) {
+ complete();
+ }
+
+ requestDone = true;
+ if ( xhr ) {
+ xhr.onreadystatechange = jQuery.noop;
+ }
+
+ // The transfer is complete and the data is available, or the request timed out
+ } else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) {
+ requestDone = true;
+ xhr.onreadystatechange = jQuery.noop;
+
+ status = isTimeout === "timeout" ?
+ "timeout" :
+ !jQuery.httpSuccess( xhr ) ?
+ "error" :
+ s.ifModified && jQuery.httpNotModified( xhr, s.url ) ?
+ "notmodified" :
+ "success";
+
+ if ( status === "success" ) {
+ // Watch for, and catch, XML document parse errors
+ try {
+ // process the data (runs the xml through httpData regardless of callback)
+ data = jQuery.httpData( xhr, s.dataType, s );
+ } catch(e) {
+ status = "parsererror";
+ }
+ }
+
+ // Make sure that the request was successful or notmodified
+ if ( status === "success" || status === "notmodified" ) {
+ // JSONP handles its own success callback
+ if ( !jsonp ) {
+ success();
+ }
+ } else {
+ jQuery.handleError(s, xhr, status);
+ }
+
+ // Fire the complete handlers
+ complete();
+
+ if ( isTimeout === "timeout" ) {
+ xhr.abort();
+ }
+
+ // Stop memory leaks
+ if ( s.async ) {
+ xhr = null;
+ }
+ }
+ };
+
+ // Override the abort handler, if we can (IE doesn't allow it, but that's OK)
+ // Opera doesn't fire onreadystatechange at all on abort
+ try {
+ var oldAbort = xhr.abort;
+ xhr.abort = function() {
+ if ( xhr ) {
+ oldAbort.call( xhr );
+ if ( xhr ) {
+ xhr.readyState = 0;
+ }
+ }
+
+ onreadystatechange();
+ };
+ } catch(e) { }
+
+ // Timeout checker
+ if ( s.async && s.timeout > 0 ) {
+ setTimeout(function() {
+ // Check to see if the request is still happening
+ if ( xhr && !requestDone ) {
+ onreadystatechange( "timeout" );
+ }
+ }, s.timeout);
+ }
+
+ // Send the data
+ try {
+ xhr.send( type === "POST" || type === "PUT" || type === "DELETE" ? s.data : null );
+ } catch(e) {
+ jQuery.handleError(s, xhr, null, e);
+ // Fire the complete handlers
+ complete();
+ }
+
+ // firefox 1.5 doesn't fire statechange for sync requests
+ if ( !s.async ) {
+ onreadystatechange();
+ }
+
+ function success() {
+ // If a local callback was specified, fire it and pass it the data
+ if ( s.success ) {
+ s.success.call( callbackContext, data, status, xhr );
+ }
+
+ // Fire the global callback
+ if ( s.global ) {
+ trigger( "ajaxSuccess", [xhr, s] );
+ }
+ }
+
+ function complete() {
+ // Process result
+ if ( s.complete ) {
+ s.complete.call( callbackContext, xhr, status);
+ }
+
+ // The request was completed
+ if ( s.global ) {
+ trigger( "ajaxComplete", [xhr, s] );
+ }
+
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active ) {
+ jQuery.event.trigger( "ajaxStop" );
+ }
+ }
+
+ function trigger(type, args) {
+ (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args);
+ }
+
+ // return XMLHttpRequest to allow aborting the request etc.
+ return xhr;
+ },
+
+ handleError: function( s, xhr, status, e ) {
+ // If a local callback was specified, fire it
+ if ( s.error ) {
+ s.error.call( s.context || window, xhr, status, e );
+ }
+
+ // Fire the global callback
+ if ( s.global ) {
+ (s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] );
+ }
+ },
+
+ // Counter for holding the number of active queries
+ active: 0,
+
+ // Determines if an XMLHttpRequest was successful or not
+ httpSuccess: function( xhr ) {
+ try {
+ // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
+ return !xhr.status && location.protocol === "file:" ||
+ // Opera returns 0 when status is 304
+ ( xhr.status >= 200 && xhr.status < 300 ) ||
+ xhr.status === 304 || xhr.status === 1223 || xhr.status === 0;
+ } catch(e) {}
+
+ return false;
+ },
+
+ // Determines if an XMLHttpRequest returns NotModified
+ httpNotModified: function( xhr, url ) {
+ var lastModified = xhr.getResponseHeader("Last-Modified"),
+ etag = xhr.getResponseHeader("Etag");
+
+ if ( lastModified ) {
+ jQuery.lastModified[url] = lastModified;
+ }
+
+ if ( etag ) {
+ jQuery.etag[url] = etag;
+ }
+
+ // Opera returns 0 when status is 304
+ return xhr.status === 304 || xhr.status === 0;
+ },
+
+ httpData: function( xhr, type, s ) {
+ var ct = xhr.getResponseHeader("content-type") || "",
+ xml = type === "xml" || !type && ct.indexOf("xml") >= 0,
+ data = xml ? xhr.responseXML : xhr.responseText;
+
+ if ( xml && data.documentElement.nodeName === "parsererror" ) {
+ throw "parsererror";
+ }
+
+ // Allow a pre-filtering function to sanitize the response
+ // s is checked to keep backwards compatibility
+ if ( s && s.dataFilter ) {
+ data = s.dataFilter( data, type );
+ }
+
+ // The filter can actually parse the response
+ if ( typeof data === "string" ) {
+ // Get the JavaScript object, if JSON is used.
+ if ( type === "json" || !type && ct.indexOf("json") >= 0 ) {
+ // Make sure the incoming data is actual JSON
+ // Logic borrowed from http://json.org/json2.js
+ if (/^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]")
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ""))) {
+
+ // Try to use the native JSON parser first
+ if ( window.JSON && window.JSON.parse ) {
+ data = window.JSON.parse( data );
+
+ } else {
+ data = (new Function("return " + data))();
+ }
+
+ } else {
+ throw "Invalid JSON: " + data;
+ }
+
+ // If the type is "script", eval it in global context
+ } else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) {
+ jQuery.globalEval( data );
+ }
+ }
+
+ return data;
+ },
+
+ // Serialize an array of form elements or a set of
+ // key/values into a query string
+ param: function( a, traditional ) {
+
+ var s = [];
+
+ // Set traditional to true for jQuery <= 1.3.2 behavior.
+ if ( traditional === undefined ) {
+ traditional = jQuery.ajaxSettings.traditional;
+ }
+
+ function add( key, value ) {
+ // If value is a function, invoke it and return its value
+ value = jQuery.isFunction(value) ? value() : value;
+ s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
+ }
+
+ // If an array was passed in, assume that it is an array of form elements.
+ if ( jQuery.isArray(a) || a.jquery ) {
+ // Serialize the form elements
+ jQuery.each( a, function() {
+ add( this.name, this.value );
+ });
+
+ } else {
+ // If traditional, encode the "old" way (the way 1.3.2 or older
+ // did it), otherwise encode params recursively.
+ jQuery.each( a, function buildParams( prefix, obj ) {
+
+ if ( jQuery.isArray(obj) ) {
+ // Serialize array item.
+ jQuery.each( obj, function( i, v ) {
+ if ( traditional ) {
+ // Treat each array item as a scalar.
+ add( prefix, v );
+ } else {
+ // If array item is non-scalar (array or object), encode its
+ // numeric index to resolve deserialization ambiguity issues.
+ // Note that rack (as of 1.0.0) can't currently deserialize
+ // nested arrays properly, and attempting to do so may cause
+ // a server error. Possible fixes are to modify rack's
+ // deserialization algorithm or to provide an option or flag
+ // to force array serialization to be shallow.
+ buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v );
+ }
+ });
+
+ } else if ( !traditional && obj != null && typeof obj === "object" ) {
+ // Serialize object item.
+ jQuery.each( obj, function( k, v ) {
+ buildParams( prefix + "[" + k + "]", v );
+ });
+
+ } else {
+ // Serialize scalar item.
+ add( prefix, obj );
+ }
+ });
+ }
+
+ // Return the resulting serialization
+ return s.join("&").replace(r20, "+");
+ }
+
+});
+var elemdisplay = {},
+ rfxtypes = /toggle|show|hide/,
+ rfxnum = /^([+-]=)?([\d+-.]+)(.*)$/,
+ timerId,
+ fxAttrs = [
+ // height animations
+ [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
+ // width animations
+ [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
+ // opacity animations
+ [ "opacity" ]
+ ];
+
+jQuery.fn.extend({
+ show: function( speed, callback ) {
+ if ( speed != null ) {
+ return this.animate( genFx("show", 3), speed, callback);
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var old = jQuery.data(this[i], "olddisplay");
+
+ this[i].style.display = old || "";
+
+ if ( jQuery.css(this[i], "display") === "none" ) {
+ var nodeName = this[i].nodeName, display;
+
+ if ( elemdisplay[ nodeName ] ) {
+ display = elemdisplay[ nodeName ];
+
+ } else {
+ var elem = jQuery("<" + nodeName + " />").appendTo("body");
+
+ display = elem.css("display");
+
+ if ( display === "none" ) {
+ display = "block";
+ }
+
+ elem.remove();
+
+ elemdisplay[ nodeName ] = display;
+ }
+
+ jQuery.data(this[i], "olddisplay", display);
+ }
+ }
+
+ // Set the display of the elements in a second loop
+ // to avoid the constant reflow
+ for ( var j = 0, k = this.length; j < k; j++ ) {
+ this[j].style.display = jQuery.data(this[j], "olddisplay") || "";
+ }
+
+ return this;
+ }
+ },
+
+ hide: function( speed, callback ) {
+ if ( speed != null ) {
+ return this.animate( genFx("hide", 3), speed, callback);
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var old = jQuery.data(this[i], "olddisplay");
+ if ( !old && old !== "none" ) {
+ jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display"));
+ }
+ }
+
+ // Set the display of the elements in a second loop
+ // to avoid the constant reflow
+ for ( var j = 0, k = this.length; j < k; j++ ) {
+ this[j].style.display = "none";
+ }
+
+ return this;
+ }
+ },
+
+ // Save the old toggle function
+ _toggle: jQuery.fn.toggle,
+
+ toggle: function( fn, fn2 ) {
+ var bool = typeof fn === "boolean";
+
+ if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
+ this._toggle.apply( this, arguments );
+
+ } else if ( fn == null || bool ) {
+ this.each(function() {
+ var state = bool ? fn : jQuery(this).is(":hidden");
+ jQuery(this)[ state ? "show" : "hide" ]();
+ });
+
+ } else {
+ this.animate(genFx("toggle", 3), fn, fn2);
+ }
+
+ return this;
+ },
+
+ fadeTo: function( speed, to, callback ) {
+ return this.filter(":hidden").css("opacity", 0).show().end()
+ .animate({opacity: to}, speed, callback);
+ },
+
+ animate: function( prop, speed, easing, callback ) {
+ var optall = jQuery.speed(speed, easing, callback);
+
+ if ( jQuery.isEmptyObject( prop ) ) {
+ return this.each( optall.complete );
+ }
+
+ return this[ optall.queue === false ? "each" : "queue" ](function() {
+ var opt = jQuery.extend({}, optall), p,
+ hidden = this.nodeType === 1 && jQuery(this).is(":hidden"),
+ self = this;
+
+ for ( p in prop ) {
+ var name = p.replace(rdashAlpha, fcamelCase);
+
+ if ( p !== name ) {
+ prop[ name ] = prop[ p ];
+ delete prop[ p ];
+ p = name;
+ }
+
+ if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
+ return opt.complete.call(this);
+ }
+
+ if ( ( p === "height" || p === "width" ) && this.style ) {
+ // Store display property
+ opt.display = jQuery.css(this, "display");
+
+ // Make sure that nothing sneaks out
+ opt.overflow = this.style.overflow;
+ }
+
+ if ( jQuery.isArray( prop[p] ) ) {
+ // Create (if needed) and add to specialEasing
+ (opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1];
+ prop[p] = prop[p][0];
+ }
+ }
+
+ if ( opt.overflow != null ) {
+ this.style.overflow = "hidden";
+ }
+
+ opt.curAnim = jQuery.extend({}, prop);
+
+ jQuery.each( prop, function( name, val ) {
+ var e = new jQuery.fx( self, opt, name );
+
+ if ( rfxtypes.test(val) ) {
+ e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop );
+
+ } else {
+ var parts = rfxnum.exec(val),
+ start = e.cur(true) || 0;
+
+ if ( parts ) {
+ var end = parseFloat( parts[2] ),
+ unit = parts[3] || "px";
+
+ // We need to compute starting value
+ if ( unit !== "px" ) {
+ self.style[ name ] = (end || 1) + unit;
+ start = ((end || 1) / e.cur(true)) * start;
+ self.style[ name ] = start + unit;
+ }
+
+ // If a +=/-= token was provided, we're doing a relative animation
+ if ( parts[1] ) {
+ end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
+ }
+
+ e.custom( start, end, unit );
+
+ } else {
+ e.custom( start, val, "" );
+ }
+ }
+ });
+
+ // For JS strict compliance
+ return true;
+ });
+ },
+
+ stop: function( clearQueue, gotoEnd ) {
+ var timers = jQuery.timers;
+
+ if ( clearQueue ) {
+ this.queue([]);
+ }
+
+ this.each(function() {
+ // go in reverse order so anything added to the queue during the loop is ignored
+ for ( var i = timers.length - 1; i >= 0; i-- ) {
+ if ( timers[i].elem === this ) {
+ if (gotoEnd) {
+ // force the next step to be the last
+ timers[i](true);
+ }
+
+ timers.splice(i, 1);
+ }
+ }
+ });
+
+ // start the next in the queue if the last step wasn't forced
+ if ( !gotoEnd ) {
+ this.dequeue();
+ }
+
+ return this;
+ }
+
+});
+
+// Generate shortcuts for custom animations
+jQuery.each({
+ slideDown: genFx("show", 1),
+ slideUp: genFx("hide", 1),
+ slideToggle: genFx("toggle", 1),
+ fadeIn: { opacity: "show" },
+ fadeOut: { opacity: "hide" }
+}, function( name, props ) {
+ jQuery.fn[ name ] = function( speed, callback ) {
+ return this.animate( props, speed, callback );
+ };
+});
+
+jQuery.extend({
+ speed: function( speed, easing, fn ) {
+ var opt = speed && typeof speed === "object" ? speed : {
+ complete: fn || !fn && easing ||
+ jQuery.isFunction( speed ) && speed,
+ duration: speed,
+ easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
+ };
+
+ opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
+ jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default;
+
+ // Queueing
+ opt.old = opt.complete;
+ opt.complete = function() {
+ if ( opt.queue !== false ) {
+ jQuery(this).dequeue();
+ }
+ if ( jQuery.isFunction( opt.old ) ) {
+ opt.old.call( this );
+ }
+ };
+
+ return opt;
+ },
+
+ easing: {
+ linear: function( p, n, firstNum, diff ) {
+ return firstNum + diff * p;
+ },
+ swing: function( p, n, firstNum, diff ) {
+ return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
+ }
+ },
+
+ timers: [],
+
+ fx: function( elem, options, prop ) {
+ this.options = options;
+ this.elem = elem;
+ this.prop = prop;
+
+ if ( !options.orig ) {
+ options.orig = {};
+ }
+ }
+
+});
+
+jQuery.fx.prototype = {
+ // Simple function for setting a style value
+ update: function() {
+ if ( this.options.step ) {
+ this.options.step.call( this.elem, this.now, this );
+ }
+
+ (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
+
+ // Set display property to block for height/width animations
+ if ( ( this.prop === "height" || this.prop === "width" ) && this.elem.style ) {
+ this.elem.style.display = "block";
+ }
+ },
+
+ // Get the current size
+ cur: function( force ) {
+ if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
+ return this.elem[ this.prop ];
+ }
+
+ var r = parseFloat(jQuery.css(this.elem, this.prop, force));
+ return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
+ },
+
+ // Start an animation from one number to another
+ custom: function( from, to, unit ) {
+ this.startTime = now();
+ this.start = from;
+ this.end = to;
+ this.unit = unit || this.unit || "px";
+ this.now = this.start;
+ this.pos = this.state = 0;
+
+ var self = this;
+ function t( gotoEnd ) {
+ return self.step(gotoEnd);
+ }
+
+ t.elem = this.elem;
+
+ if ( t() && jQuery.timers.push(t) && !timerId ) {
+ timerId = setInterval(jQuery.fx.tick, 13);
+ }
+ },
+
+ // Simple 'show' function
+ show: function() {
+ // Remember where we started, so that we can go back to it later
+ this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
+ this.options.show = true;
+
+ // Begin the animation
+ // Make sure that we start at a small width/height to avoid any
+ // flash of content
+ this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
+
+ // Start by showing the element
+ jQuery( this.elem ).show();
+ },
+
+ // Simple 'hide' function
+ hide: function() {
+ // Remember where we started, so that we can go back to it later
+ this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
+ this.options.hide = true;
+
+ // Begin the animation
+ this.custom(this.cur(), 0);
+ },
+
+ // Each step of an animation
+ step: function( gotoEnd ) {
+ var t = now(), done = true;
+
+ if ( gotoEnd || t >= this.options.duration + this.startTime ) {
+ this.now = this.end;
+ this.pos = this.state = 1;
+ this.update();
+
+ this.options.curAnim[ this.prop ] = true;
+
+ for ( var i in this.options.curAnim ) {
+ if ( this.options.curAnim[i] !== true ) {
+ done = false;
+ }
+ }
+
+ if ( done ) {
+ if ( this.options.display != null ) {
+ // Reset the overflow
+ this.elem.style.overflow = this.options.overflow;
+
+ // Reset the display
+ var old = jQuery.data(this.elem, "olddisplay");
+ this.elem.style.display = old ? old : this.options.display;
+
+ if ( jQuery.css(this.elem, "display") === "none" ) {
+ this.elem.style.display = "block";
+ }
+ }
+
+ // Hide the element if the "hide" operation was done
+ if ( this.options.hide ) {
+ jQuery(this.elem).hide();
+ }
+
+ // Reset the properties, if the item has been hidden or shown
+ if ( this.options.hide || this.options.show ) {
+ for ( var p in this.options.curAnim ) {
+ jQuery.style(this.elem, p, this.options.orig[p]);
+ }
+ }
+
+ // Execute the complete function
+ this.options.complete.call( this.elem );
+ }
+
+ return false;
+
+ } else {
+ var n = t - this.startTime;
+ this.state = n / this.options.duration;
+
+ // Perform the easing function, defaults to swing
+ var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop];
+ var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear");
+ this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration);
+ this.now = this.start + ((this.end - this.start) * this.pos);
+
+ // Perform the next step of the animation
+ this.update();
+ }
+
+ return true;
+ }
+};
+
+jQuery.extend( jQuery.fx, {
+ tick: function() {
+ var timers = jQuery.timers;
+
+ for ( var i = 0; i < timers.length; i++ ) {
+ if ( !timers[i]() ) {
+ timers.splice(i--, 1);
+ }
+ }
+
+ if ( !timers.length ) {
+ jQuery.fx.stop();
+ }
+ },
+
+ stop: function() {
+ clearInterval( timerId );
+ timerId = null;
+ },
+
+ speeds: {
+ slow: 600,
+ fast: 200,
+ // Default speed
+ _default: 400
+ },
+
+ step: {
+ opacity: function( fx ) {
+ jQuery.style(fx.elem, "opacity", fx.now);
+ },
+
+ _default: function( fx ) {
+ if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
+ fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
+ } else {
+ fx.elem[ fx.prop ] = fx.now;
+ }
+ }
+ }
+});
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.animated = function( elem ) {
+ return jQuery.grep(jQuery.timers, function( fn ) {
+ return elem === fn.elem;
+ }).length;
+ };
+}
+
+function genFx( type, num ) {
+ var obj = {};
+
+ jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
+ obj[ this ] = type;
+ });
+
+ return obj;
+}
+if ( "getBoundingClientRect" in document.documentElement ) {
+ jQuery.fn.offset = function( options ) {
+ var elem = this[0];
+
+ if ( !elem || !elem.ownerDocument ) {
+ return null;
+ }
+
+ if ( options ) {
+ return this.each(function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ });
+ }
+
+ if ( elem === elem.ownerDocument.body ) {
+ return jQuery.offset.bodyOffset( elem );
+ }
+
+ var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement,
+ clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
+ top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop,
+ left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft;
+
+ return { top: top, left: left };
+ };
+
+} else {
+ jQuery.fn.offset = function( options ) {
+ var elem = this[0];
+
+ if ( !elem || !elem.ownerDocument ) {
+ return null;
+ }
+
+ if ( options ) {
+ return this.each(function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ });
+ }
+
+ if ( elem === elem.ownerDocument.body ) {
+ return jQuery.offset.bodyOffset( elem );
+ }
+
+ jQuery.offset.initialize();
+
+ var offsetParent = elem.offsetParent, prevOffsetParent = elem,
+ doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement,
+ body = doc.body, defaultView = doc.defaultView,
+ prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
+ top = elem.offsetTop, left = elem.offsetLeft;
+
+ while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
+ if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
+ break;
+ }
+
+ computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
+ top -= elem.scrollTop;
+ left -= elem.scrollLeft;
+
+ if ( elem === offsetParent ) {
+ top += elem.offsetTop;
+ left += elem.offsetLeft;
+
+ if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.nodeName)) ) {
+ top += parseFloat( computedStyle.borderTopWidth ) || 0;
+ left += parseFloat( computedStyle.borderLeftWidth ) || 0;
+ }
+
+ prevOffsetParent = offsetParent, offsetParent = elem.offsetParent;
+ }
+
+ if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
+ top += parseFloat( computedStyle.borderTopWidth ) || 0;
+ left += parseFloat( computedStyle.borderLeftWidth ) || 0;
+ }
+
+ prevComputedStyle = computedStyle;
+ }
+
+ if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
+ top += body.offsetTop;
+ left += body.offsetLeft;
+ }
+
+ if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
+ top += Math.max( docElem.scrollTop, body.scrollTop );
+ left += Math.max( docElem.scrollLeft, body.scrollLeft );
+ }
+
+ return { top: top, left: left };
+ };
+}
+
+jQuery.offset = {
+ initialize: function() {
+ var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0,
+ html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
+
+ jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
+
+ container.innerHTML = html;
+ body.insertBefore( container, body.firstChild );
+ innerDiv = container.firstChild;
+ checkDiv = innerDiv.firstChild;
+ td = innerDiv.nextSibling.firstChild.firstChild;
+
+ this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
+ this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
+
+ checkDiv.style.position = "fixed", checkDiv.style.top = "20px";
+ // safari subtracts parent border width here which is 5px
+ this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
+ checkDiv.style.position = checkDiv.style.top = "";
+
+ innerDiv.style.overflow = "hidden", innerDiv.style.position = "relative";
+ this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
+
+ this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
+
+ body.removeChild( container );
+ body = container = innerDiv = checkDiv = table = td = null;
+ jQuery.offset.initialize = jQuery.noop;
+ },
+
+ bodyOffset: function( body ) {
+ var top = body.offsetTop, left = body.offsetLeft;
+
+ jQuery.offset.initialize();
+
+ if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
+ top += parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0;
+ left += parseFloat( jQuery.curCSS(body, "marginLeft", true) ) || 0;
+ }
+
+ return { top: top, left: left };
+ },
+
+ setOffset: function( elem, options, i ) {
+ // set position first, in-case top/left are set even on static elem
+ if ( /static/.test( jQuery.curCSS( elem, "position" ) ) ) {
+ elem.style.position = "relative";
+ }
+ var curElem = jQuery( elem ),
+ curOffset = curElem.offset(),
+ curTop = parseInt( jQuery.curCSS( elem, "top", true ), 10 ) || 0,
+ curLeft = parseInt( jQuery.curCSS( elem, "left", true ), 10 ) || 0;
+
+ if ( jQuery.isFunction( options ) ) {
+ options = options.call( elem, i, curOffset );
+ }
+
+ var props = {
+ top: (options.top - curOffset.top) + curTop,
+ left: (options.left - curOffset.left) + curLeft
+ };
+
+ if ( "using" in options ) {
+ options.using.call( elem, props );
+ } else {
+ curElem.css( props );
+ }
+ }
+};
+
+
+jQuery.fn.extend({
+ position: function() {
+ if ( !this[0] ) {
+ return null;
+ }
+
+ var elem = this[0],
+
+ // Get *real* offsetParent
+ offsetParent = this.offsetParent(),
+
+ // Get correct offsets
+ offset = this.offset(),
+ parentOffset = /^body|html$/i.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
+
+ // Subtract element margins
+ // note: when an element has margin: auto the offsetLeft and marginLeft
+ // are the same in Safari causing offset.left to incorrectly be 0
+ offset.top -= parseFloat( jQuery.curCSS(elem, "marginTop", true) ) || 0;
+ offset.left -= parseFloat( jQuery.curCSS(elem, "marginLeft", true) ) || 0;
+
+ // Add offsetParent borders
+ parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], "borderTopWidth", true) ) || 0;
+ parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], "borderLeftWidth", true) ) || 0;
+
+ // Subtract the two offsets
+ return {
+ top: offset.top - parentOffset.top,
+ left: offset.left - parentOffset.left
+ };
+ },
+
+ offsetParent: function() {
+ return this.map(function() {
+ var offsetParent = this.offsetParent || document.body;
+ while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
+ offsetParent = offsetParent.offsetParent;
+ }
+ return offsetParent;
+ });
+ }
+});
+
+
+// Create scrollLeft and scrollTop methods
+jQuery.each( ["Left", "Top"], function( i, name ) {
+ var method = "scroll" + name;
+
+ jQuery.fn[ method ] = function(val) {
+ var elem = this[0], win;
+
+ if ( !elem ) {
+ return null;
+ }
+
+ if ( val !== undefined ) {
+ // Set the scroll offset
+ return this.each(function() {
+ win = getWindow( this );
+
+ if ( win ) {
+ win.scrollTo(
+ !i ? val : jQuery(win).scrollLeft(),
+ i ? val : jQuery(win).scrollTop()
+ );
+
+ } else {
+ this[ method ] = val;
+ }
+ });
+ } else {
+ win = getWindow( elem );
+
+ // Return the scroll offset
+ return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
+ jQuery.support.boxModel && win.document.documentElement[ method ] ||
+ win.document.body[ method ] :
+ elem[ method ];
+ }
+ };
+});
+
+function getWindow( elem ) {
+ return ("scrollTo" in elem && elem.document) ?
+ elem :
+ elem.nodeType === 9 ?
+ elem.defaultView || elem.parentWindow :
+ false;
+}
+// Create innerHeight, innerWidth, outerHeight and outerWidth methods
+jQuery.each([ "Height", "Width" ], function( i, name ) {
+
+ var type = name.toLowerCase();
+
+ // innerHeight and innerWidth
+ jQuery.fn["inner" + name] = function() {
+ return this[0] ?
+ jQuery.css( this[0], type, false, "padding" ) :
+ null;
+ };
+
+ // outerHeight and outerWidth
+ jQuery.fn["outer" + name] = function( margin ) {
+ return this[0] ?
+ jQuery.css( this[0], type, false, margin ? "margin" : "border" ) :
+ null;
+ };
+
+ jQuery.fn[ type ] = function( size ) {
+ // Get window width or height
+ var elem = this[0];
+ if ( !elem ) {
+ return size == null ? null : this;
+ }
+
+ return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window?
+ // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
+ elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
+ elem.document.body[ "client" + name ] :
+
+ // Get document width or height
+ (elem.nodeType === 9) ? // is it a document
+ // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
+ Math.max(
+ elem.documentElement["client" + name],
+ elem.body["scroll" + name], elem.documentElement["scroll" + name],
+ elem.body["offset" + name], elem.documentElement["offset" + name]
+ ) :
+
+ // Get or set width or height on the element
+ size === undefined ?
+ // Get width or height on the element
+ jQuery.css( elem, type ) :
+
+ // Set the width or height on the element (default to pixels if value is unitless)
+ this.css( type, typeof size === "string" ? size : size + "px" );
+ };
+
+});
+// Expose jQuery to the global object
+window.jQuery = window.$ = jQuery;
+
+})(window);
diff --git a/examples/lessons/6_Maths_multiplyingFractions/js/karma.js b/examples/lessons/6_Maths_multiplyingFractions/js/karma.js
new file mode 100755
index 0000000..03f027b
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/js/karma.js
@@ -0,0 +1,1018 @@
+/* Documentation Note:
+ * Public methods and properties are commented with /** some text *\/
+ * and private methods and properties are commented with //
+ *
+ * Please leave it that way to keep this documentation sane
+ */
+
+
+/*
+* Karma Framework
+* http://karmaeducation.org
+*
+* Copyright (c) 2009
+* Bryan W Berry bryan@olenepal.org
+* Felipe López Toledo zer.subzero@gmail.com
+*
+* Under MIT License:
+* Permission is hereby granted, free of charge, to any person
+* obtaining a copy of this software and associated documentation
+* files (the "Software"), to deal in the Software without
+* restriction, including without limitation the rights to use,
+* copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following
+* conditions:
+*
+* The above copyright notice and this permission notice shall be
+* included in all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+* OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+/**
+* @fileOverview Contains karma library
+* @author Bryan Berry <bryan@olenepal.org>
+* @author Felipe Lopez Toledo <zer.subzero@gmail.com>
+*/
+
+
+//common.js modules use exports object
+if(!this.exports) {
+ exports = {};
+}
+
+
+
+/** Checks if the current document type is set to HTML 5, throws
+ * an error otherwise, then initializes the karma object and returns
+ * a reference to that object.
+ * @namespace Global namespace for Karma library
+ * @param {Object} [options={}] options for intializing Karma library
+ * @param {String} [options.locale=''] sets current locale Not Yet Implemented
+ * @param {Array} [options.image=[]] array of images to be converted into a collection
+ * @param {Array} [options.audio=[]] array of audio to be converted into a collection
+ * @param {Array} [options.video=[]] array of videos to be converted into a collection
+ * @param {Array} [options.svg=[]] array of SVG elements to be
+ * converted into a collection. Each SVG element must already exist in the html document
+ * @param {Array} [options.canvas=[]] array of canvas elements
+ * to be converted into a collection. Each canvas element must already exist in the
+ * html document and width and height of each element must be set as attributes
+ * @throws {Error} if the document type declaration is not set to HTML 5, e.g.
+ * <!DOCTYPE html>
+ * @throws {Error} If any of the initialization parameters are invalid values
+ * @returns {Object} Karma.karma -- reference to the initialized Karma library
+ * @example
+ *
+ * var k = Karma({
+ * image: [
+ * {name: "ninja", file: "ninja.png"},
+ * {name: "cowboy", file: "cowboy.png"}
+ * ],
+ * audio: [
+ * {name: "woosh", file: "woosh.ogg"},
+ * {name: "yeehaw", file: "yeehaw.ogg"}
+ * ],
+ * video: [
+ * {name: "attack", file: "attack.ogv"},
+ * {name: "ride", file: "ride.ogv"}
+ * ]
+ * canvas: [
+ * {name: "ninja", domId: "ninjaCanvas"},
+ * {name: "cowboy", domId: "cowboyCanvas"}
+ * ],
+ * svg: [
+ * {name: "ninja", domId: "ninjaSvg"},
+ * {name: "cowboy", domId: "cowboySvg"}
+ * ],
+ * });
+ * Next, call the ready function with a callback to your program code
+ *
+ * k.ready(function () { ... your application code . . . }
+ *
+ * after that you can access each asset like so
+ * k.image.ninja;
+ * k.svg.cowboy;
+ * k.audio.yeehaw.play();
+ * k.canvas.ninja.drawImage(k.image.ninja, 0, 0);
+ *
+ */
+var Karma = exports.Karma = function (options) {
+ Karma._isHtml5(document.doctype.nodeName);
+
+ if ( Karma.karma._initialized === true ) {
+ return Karma.karma;
+ } else {
+ return Karma.karma._init(options);
+ }
+};
+
+
+//helper functions
+
+/**This emulates the Object.create method in ecmascript 5 spec
+ * This isn't a full implementation as it doesn't support
+ * This has the same functionality as Crockford's beget method
+ * and this primary building block for prototypal inheritance in
+ * this library
+ * @param {Object} target that the new object's prototype should point to
+ * @returns {Object} object whose prototype points to target
+ * @example
+ *
+ * var ninja = { weapon : "sword" };
+ * var ninja1 = Karma.create(ninja);
+ * ninja1.sword === "sword"
+ */
+Karma.create = function (target){
+ function F () {};
+ F.prototype = target;
+ return new F();
+};
+
+/** Returns a shallow copy of the passed in object
+ * @param {Object} target to be copied
+ * @returns {Object} a shallow copy of target
+ */
+Karma.clone = function (target){
+ var copy = {};
+ for ( var i in target ) {
+ if(target.hasOwnProperty(i)){
+ copy[i] = target[i];
+ }
+ }
+ return copy;
+};
+
+/** Extends properties of the target object with those of
+ * the source object
+ * @param {Object} target object to be extended
+ * @param {Object} source whose properties will extend target
+ * @returns {Object} target extended by source
+ */
+Karma.objectPlus = function (target, source){
+ for ( var i in source){
+ if (source.hasOwnProperty(i)){
+ target[i] = source[i];
+ }
+ }
+ return target;
+};
+
+/** Creates a new object that is a prototype of the first argument
+ * then extends it with the properties of the second argument
+ * @param {Object} parent1 will be prototype of returned object
+ * @param {Object} parent2 will extend properties of returned object
+ * @returns {Object} object that whose prototype is parent1 and has
+ * been extended with properties of parent2
+ */
+Karma.copyObjectPlus = function (parent1, parent2){
+ function F () {};
+ F.prototype = parent1;
+ var G = new F();
+ return Karma.objectPlus(G, parent2);
+};
+
+//Enables function chaining for a specified list of function names
+//IMPORTANT: use of closures here with "this" and "that" is __very__
+//complicated here
+Karma._makeChain = function (chainingFunctions) {
+ var that = this;
+ var _chainFunction = function ( name ){
+ that[ name ] = function ( ){
+ var type = typeof this.ctx[name];
+ if ( type === "function") {
+ this.ctx[ name ].apply( this.ctx, arguments );
+ }else if ( type === "string" ){
+ this.ctx[ name ] = arguments[0];
+ }else {
+ throw ("wtf?!: impossible to chain " + name + "!");
+ }
+ return this;
+ };
+ };
+
+ for (var i = 0; i < chainingFunctions.length; i++){
+ _chainFunction( chainingFunctions[ i ] );
+ }
+};
+
+//Throws big ugly error if doctype isn't html5
+Karma._isHtml5 = function (doctype){
+ var regex = new RegExp('^html$', 'i');
+ if(!regex.test(doctype)){
+ var errorMsg = "ERROR: The doctype must be set to <!DOCTYPE html> " +
+ "in order to use Karma. Karma require you use html5";
+ var errorElem = document.createElement('div');
+ errorElem.setAttribute('id', 'errorDoctype');
+ errorElem.innerText = errorMsg;
+ document.body.appendChild(errorElem);
+ throw new Error(errorMsg);
+ }
+};
+
+
+/** Stores global settings for the Karma library
+ * @class This object stores the global settings for the Karma library
+ */
+Karma.karma = {
+ /** This is the global locale as passed to Karma(),
+ * such as "en", "es_SP"
+ * @type string
+ * @default undefined
+ */
+ locale : undefined,
+ /** Collection of images with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ image : {},
+ /** Collection of audio with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ audio : {},
+ /** Collection of canvas with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ canvas : {},
+ /** Collection of svgs with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ svg : {},
+ /** Collection of videos with special helper
+ * methods added to each reference
+ * @type object
+ * @default empty object
+ */
+ video : {},
+ _localized : false,
+ _assetPath : "assets/",
+ _localePath : "",
+ _initialized : false,
+ _statusDiv: undefined,
+ _loaderDiv : undefined,
+ _counters : { total : 0, errors : 0, loaded : 0},
+
+ //init initializes all the assets passed to Karma, that's it
+ //it returns 'this' so it can be used for function chaining
+ _init: function(options) {
+ this._initialized = true;
+
+ //set up message that show count of assets loaded
+ //and has an ordered list to append error messages to
+ var _statusDiv = this._statusDiv = document.createElement('div');
+ this._loaderDiv = this._loaderDiv = document.createElement('div');
+ var errorList = document.createElement('ol');
+
+ _statusDiv.setAttribute('id', 'karma-status');
+ _statusDiv.setAttribute('style', 'position:absolute;');
+ _statusDiv.innerHTML = 'Karma is loading ...';
+ this._loaderDiv.setAttribute('id', 'karma-loader');
+ this._loaderDiv.setAttribute('class', 'status');
+ errorList.setAttribute('id', 'errorList');
+
+ _statusDiv.appendChild(this._loaderDiv);
+ this._statusDiv.appendChild(errorList);
+ document.body.appendChild(_statusDiv);
+
+
+ //chain the functions for kCanvas and kSvg
+ Karma._makeChain.call(Karma.kCanvas,
+ Karma.kCanvas._chainingFunctions);
+ //Karma._makeChain.apply(Karma.kSvg, Karma.kSvg._chainingFunctions);
+
+
+
+ //regular expression that matches the name of aprivate property
+ // the karma object
+ var regexPrivate = new RegExp('^_.*');
+
+ for ( var option in options ) {
+ if (options.hasOwnProperty(option)){
+ if (option === "image" || option === "audio" || option ===
+ "svg" || option === "video" || option === "canvas"){
+
+ if(!(options[option] instanceof Array)){
+ throw new Error("" + option + " must be an array");
+ } else if (options[option].length === 0){
+ continue;
+ }
+ } else if (regexPrivate.test(option)){
+ //don't overwrite a private property of karma object
+ continue;
+ }
+
+ switch (option){
+ case "locale":
+
+ if (this._isValidLocale(options[option])){
+ this.locale = this._normalizeLocale(options[option]);
+ this._localized = true;
+ this._localePath = Karma._computeLocalePath(this.locale);
+ } else {
+ throw new Error("locale provided to karma._init() is invalid");
+ }
+
+ break;
+ case "image":
+ options[option]._type = 'image';
+ Karma._makeImages(options[option]);
+ break;
+ case "audio":
+ options[option]._type = 'audio';
+ Karma._makeAudio(options[option]);
+ break;
+ case "video":
+ options[option]._type = 'video';
+ Karma._makeVideos(options[option]);
+ break;
+ case "svg":
+ options[option]._type = 'svg';
+ Karma._makeSvgs(options[option]);
+ break;
+ case "canvas":
+ options[option]._type = 'canvas';
+ Karma._makeCanvases(options[option]);
+ break;
+ }
+ }
+ }
+
+
+
+ return this;
+ },
+
+ /** Waits until all assets loaded, i.e. ready, then calls callback
+ * @param {Function} [cb] callback function
+ * @returns this
+ * @throws {Error} if Karma.karma is not initialized with the
+ * Karma({ options }) function
+ * @example
+ *
+ * var k = Karma({ . . . your assets here . . . });
+ * k.ready(function(){ .. your code here . . .});
+ *
+ * your code will not be called until all assets have been loaded
+ *
+ */
+ ready : function( cb ) {
+ var that = this;
+ if (Karma.karma._initialized !== true){
+ throw new Error("Karma.karma not initialized");
+ }
+
+ if (this._counters.loaded !== this._counters.total){
+ setTimeout(function(){ that.ready(cb);}, 5);
+ } else if (cb) {
+ //hide the "Karma is loading..." message
+ this._statusDiv.setAttribute('style', 'display:none;');
+
+ cb();
+ } else if (!cb) {
+ //hide the "Karma is loading..." message
+ this._statusDiv.setAttribute('style', 'display:none;');
+
+ //if no options passed, show it works message
+ this._showStarterMessage();
+ }
+
+
+
+
+ return this;
+ },
+
+ //Display Apache-like "It works" message if no options
+ _showStarterMessage : function (){
+ var starterMsg = document.createElement('div');
+ starterMsg.setAttribute('id', 'starterMsg');
+ starterMsg.innerHTML = "<h1>It Works</h1>";
+ document.body.appendChild(starterMsg);
+ },
+
+ //Updates visible counter of how many assets are loaded
+ _updateStatus : function (errorMsg) {
+ var loaded = this._counters.loaded;
+ var total = this._counters.total;
+ var errors = this._counters.errors;
+ this._loaderDiv.innerHTML = "Loaded " + loaded + " / " + total +
+ "" + (errors > 0 ? " Errors [ " + errors +" ]" : '');
+ if (errorMsg) {
+ var liError = document.createElement('li');
+ liError.innerHTML = errorMsg;
+ var errorList = document.getElementById('errorList');
+ errorList.appendChild(liError);
+ }
+ },
+
+ //matches 2 letter country code then optionally
+ //a dash or underscore followed by a country or language identifier
+ //i currently only allow a language identifier 2-3 chars long
+ _isValidLocale : function (locale) {
+ var localeRegex = new RegExp('^[a-zA-Z][a-zA-Z]([-_][a-zA-z]{2,3})?$');
+ return localeRegex.test(locale);
+ },
+
+ _normalizeLocale : function(locale) {
+ var lang = "";
+ var country = "";
+ var divider = "";
+
+ lang = locale.slice(0, 2).toLowerCase();
+ divider = "_";
+ country = locale.slice(3, 6).toUpperCase();
+
+ return locale.length > 2 ? "" + lang + divider + country : lang;
+ },
+
+ // Below are geometry and math helper methods
+
+ /**
+ * Converts a value from degrees to radians.
+ * @param {Number} angle The angle in degrees
+ * @returns {Number} The angle in radians
+ */
+ radians : function( angle ){
+ return ( angle / 180 ) * Math.PI;
+ },
+ /**
+ * Gets the square of the Euclidian (ordinary) distance between 2 points.
+ * @param {Object} Point No. 0
+ * @param {Number} Point0.x
+ * @param {Number} Point0.y
+ * @param {Object} Point No. 1
+ * @param {Number} Point1.x
+ * @param {Number} Point1.y
+ * @returns {Number} The square of the Euclidian distance
+ * @example
+ *
+ * p0 = {x:0, y:1};
+ * p1 = {x:50, y:70};
+ * var d = distance2(p0, p1);
+ *
+ */
+ distance2 : function ( p0, p1 ) {
+ return (p1.x - p0.x) * (p1.x - p0.x) + (p1.y - p1.y) * (p1.y - p1.y);
+ },
+ /**
+ * Gets the Euclidian (ordinary) distance between 2 points.<br>
+ * <b>Warning:</b> It's slower than distance2 function
+ * @param {Object} Point No. 0
+ * @param {Number} Point0.x
+ * @param {Number} Point0.y
+ * @param {Object} Point No. 1
+ * @param {Number} Point1.x
+ * @param {Number} Point1.y
+ * @returns {Number} The Euclidian distance
+ * @example
+ *
+ * p0 = {x:0, y:1};
+ * p1 = {x:50, y:70};
+ * var d = distance2(p0, p1);
+ *
+ */
+ distance : function ( p0, p1 ) {
+ return Math.sqrt( this.distance2( p0, p1 ) );
+ },
+ /** Returns a random number within the range provided
+ * @param {Number} lower limit of the range, lowest number that can be returned
+ * @param {Number} upper limit of the range, highest number that can be returned
+ * @returns {Number} number that is >= lower and <= upper
+ * @example
+ *
+ * var num = rand(0, 10);
+ *
+ * num could be 0, 1, 2, 3 ... or 10
+ *
+ */
+ rand : function ( lower, upper ){
+ return Math.round( Math.random() * (upper - lower) + lower );
+ }
+
+};
+
+/** Prototypal object for images, videos, and audio files but
+ * does not include svg or canvas elements
+ * @class This object is the prototype for images, videos, and audio files but
+ * does not include svg or canvas elements
+ * @ throws {Error} if the individual asset is set to be localized but
+ * the globale locale is not set on the Karma.karma object
+ * @ throws {Error} if the name and file properties are not supplied
+ * @example
+ * kMedia is the prototype object for images, audio, and videos.
+ * These 'media' assets are loaded in a distinctly different way
+ * from the canvas or svg assets. They also have distinctly different
+ * helper methods
+ *
+ * You initialize the kMedia assets by passing an array of objects
+ */
+Karma.kMedia = {
+ /** file location of asset
+ * @type String
+ * @default ""
+ */
+ file : "",
+ /** media object
+ * @type Audio|Image|Video
+ * @default undefined
+ */
+ media : undefined,
+ //actual path to the file
+ _path : "",
+ //if using localized version of this asset
+ _localized : false,
+ //audio, image, or video
+ _type : "",
+ //initializes kMedia instance with values provided by user
+ _init : function (asset) {
+ asset._localized = asset._localized || false;
+ Karma.karma._counters.total++;
+
+ if (asset.name === undefined || asset.file === undefined){
+ throw new Error("properties name and file have to be defined");
+ } else {
+ this.name = asset.name;
+ this.file = asset.file;
+ }
+
+ //_type is a private variable used internally
+ if (asset._type === undefined){
+ throw new Error("the _type property must be set. " +
+ "Blame the karma library authors as this is an internal value");
+ } else {
+ if (Karma._isValidType(asset._type)){
+ this._type = asset._type;
+ switch ( this._type ) {
+ case "image": this.media = new Image();
+ break;
+ case "audio": this.media = new Audio();
+ break;
+ //case "video":
+ //NYI
+ //this.media = new Video();
+ break;
+ default: throw new Error("Media type not supported");
+ }
+
+ } else {
+ throw new Error("the _type property supplied is invalid. " +
+ "Blame the karma library authors as this is an internal value");
+ }
+ }
+
+ if(Karma._isLocalized(asset._localized)){
+ this._localized = asset._localized;
+ this._path = Karma.karma._localePath +
+ this._type + "/";
+ } else {
+ this._path = Karma.karma._assetPath +
+ this._type + "/";
+ }
+
+
+ //IMPORTANT: This one magic line loads the file
+ this.media.src = this.src = this._path + this.file;
+
+ //add event handlers
+ this._addEventHandlers();
+
+ if (this._type === "audio"){
+ this.media.autobuffer = true;
+ this.media.load();
+ }
+
+
+ return this;
+ },
+ //Adds event handlers to update the counters when
+ //the asset is successfully or unsuccessfully loaded
+ _addEventHandlers : function () {
+ var that = this;
+ var loadEvent = "load";
+ //Browser Hack recommended by chromium devs
+ //http://code.google.com/p/chromium/issues/detail?id=20251&q=loading%20audio&colspec=ID%20Stars%20Pri%20Area%20Type%20Status%20Summary%20Modified%20Owner%20Mstone%20OS#c4
+ if (this._type === "audio" || this._type === "video"){
+ loadEvent = "canplaythrough";
+ }
+
+ that.media.addEventListener(
+ loadEvent,
+ function (e) {
+ Karma.karma._counters.loaded++;
+ Karma.karma._updateStatus();
+ that.status = "loaded";}, false);
+
+ that.media.addEventListener(
+ "error",
+ function (e) {
+ Karma.karma._counters.errors++;
+ that.status = "error";
+ var errorMsg = "Error: " + that._type.toUpperCase() +
+ " " + that.name + " cannot be loaded.";
+ Karma.karma._updateStatus(errorMsg);
+ },
+ false);
+ that.media.addEventListener(
+ "abort",
+ function (e) {
+ Karma.karma._counters.total++;
+ that.status = "aborted";
+ var errorMsg = "ABORT: " + that._type.toUpperCase() +
+ " " + that.name + " loading was aborted.";
+ Karma.karma._updateStatus(errorMsg);
+
+ }, false);
+
+ }
+
+};
+
+//determine if it is a valid type of asset
+Karma._isValidType = function (type){
+ return type === "image" ||
+ type === "svg" ||
+ type === "audio" ||
+ type === "video" ||
+ type === "canvas";
+};
+
+Karma._isLocalized = function (boolLocalized) {
+ if (typeof boolLocalized === "boolean" ) {
+ if(boolLocalized === true &&
+ Karma.karma.locale === undefined){
+ throw new Error("You cannot localize a media asset" +
+ " if the global locale for Karma isn't set");
+ } else {
+ return boolLocalized;
+ }
+ } else if (typeof boolLocalized === undefined){
+ return false;
+ } else{
+ throw new Error("This is not a valid value for the localized option");
+ }
+};
+
+Karma._computeLocalePath = function(locale) {
+ return Karma.karma._assetPath + locale + "/";
+};
+
+Karma._makeImages = function (imgConfigs){
+ var makeImage = function (imgConfig){
+ var image = undefined;
+ imgConfig._type = "image";
+ image = Karma.create(Karma.kMedia)._init(imgConfig);
+ Karma.karma.image[imgConfig.name] = image;
+ };
+
+ imgConfigs.forEach(function(imgConfig){ makeImage(imgConfig);});
+
+};
+
+Karma._makeAudio = function (audioConfigs){
+ var makeAudio = function (audioConfig){
+ var audio = undefined;
+ audioConfig._type = "audio";
+ audio = Karma.create(Karma.kMedia)._init(audioConfig);
+ audio.play = function () {
+ //hack to fix the audio "stuttering" problem
+ //more info: https://bugs.launchpad.net/karma/+bug/426108
+ this.media.currentTime = 0.1;
+ this.media.play();
+ };
+ Karma.karma.audio[audioConfig.name] = audio;
+ };
+
+ audioConfigs.forEach(function(audioConfig){ makeAudio(audioConfig);});
+
+};
+
+
+Karma._makeCanvases = function (canvasConfigs){
+ var makeCanvas = function (canvasConfig){
+ var canvas = undefined;
+ canvas = Karma.create(Karma.kCanvas)._init(canvasConfig);
+ Karma.karma.canvas[canvasConfig.name] = canvas;
+ };
+
+ canvasConfigs.forEach(function(canvasConfig){ makeCanvas(canvasConfig);});
+
+};
+
+/** Prototypal object for each canvas element submitted to Karma in the
+ * Karma() method
+ * @throws {Error} if the name and domId for the canvas element are not specified
+ * @thows {Error} if the supplied domId does not match an element in the DOM
+ * @class This object is the prototype for each canvas element submitted to Karma in the
+ * Karma() method
+ */
+Karma.kCanvas = {
+ /** Name of the canvas, used internally by karma.js
+ * @type String
+ * @default ''
+ */
+ name : '',
+ /** Width of canvas element
+ * @type Number
+ * @default 0
+ */
+ width: 0,
+ /** Height of canvas element
+ * @type Number
+ * @default 0
+ */
+ height: 0,
+ /** Whether canvas is visible
+ * @type boolean
+ * @default true
+ */
+ visible: true,
+ /** Element ID for canvas element in html document
+ * @type String
+ * @default undefined
+ */
+ domId: undefined,
+ /** Reference to the DOM element
+ * @type DOMElement
+ * @default undefined
+ */
+ node: undefined,
+ /** The 2 Dimensional Rendering context property for this canvas
+ * @type 2DRenderingContext
+ * @default undefined
+ */
+ ctx: undefined,
+ /** Frames Per Second, I don't know what the purpose of this is,
+ * Felipe made it up
+ * @type Number
+ * @default 24
+ */
+ fps: 24,
+
+ //initializes object with values provides by user
+ _init: function (config) {
+ for (var option in config){
+ if (config.hasOwnProperty(option)){
+ switch (option){
+ case "name":
+ this.name = config[option];
+ break;
+ case "domId":
+ this.domId = config[option];
+ break;
+ case "width":
+ if(!this.height){
+ throw new Error("If you specify a width you must also" +
+ "specify a height");
+ }
+ this.width = config[option];
+ break;
+ case "height":
+ if(!this.width){
+ throw new Error("If you specify a height you must also" +
+ "specify a width");
+ }
+ this.height = parseInt(config.option, 10);
+ break;
+ case "fps":
+ this.fps = parseInt(config.option, 10);
+ break;
+ }
+ }
+ }
+
+ if(this.domId && document.getElementById(this.domId)){
+ this.node = document.getElementById(this.domId);
+ this.ctx = this.node.getContext('2d');
+ } else {
+ throw new Error('you must specify a valid domId that' +
+ 'is in your html page');
+ }
+
+ if(!config.height && !config.width){
+ this.width = parseInt(this.node.getAttribute('width'), 10);
+ this.height = parseInt(this.node.getAttribute('height'), 10);
+ }
+
+ return this;
+ },
+ /** Clear area of canvas element specified by parameters, if no
+ * parameters supplied, clears entire canvas
+ * @param {Number} [x=0] x coordinate, defaults to zero if left blank
+ * @param {Number} [y=0] y coordinate, defaults to zero if left blank
+ * @param {Number} [width=0] width of area to be cleared, defaults
+ * entire width of canvas
+ * @param {Number} [height=0] height of area to be cleared, defaults
+ * entire height of canvas
+ * @returns this
+ * @example
+ *
+ * k.canvas.ninja.clear();
+ * // clears the entire ninja canvas
+ *
+ * k.canvas.ninja.clear(0, 10, 20, 30);
+ * //clears a specific portion of the ninja canvas
+ *
+ */
+ clear : function ( x, y, width, height ) {
+ var that = this;
+ that.ctx.clearRect(
+ x || 0,
+ y || 0,
+ width || that.width,
+ height || that.height
+ );
+ return that;
+ },
+
+ //These are all properties or methods of the canvas element's
+ //2 dimensional context
+ _chainingFunctions : [
+ "globalAlpha", "globalCompositeOperation", "lineWidth", "lineCap",
+ "lineJoin", "miterLimit", "font", "textAlign", "textBaseline", "save",
+ "restore", "scale", "rotate", "translate", "transform", "setTransform",
+ "clearRect", "fillRect", "strokeRect", "beginPath", "closePath",
+ "moveTo", "lineTo", "quadraticCurveTo", "bezierCurveTo", "arcTo",
+ "arc", "rect", "fill", "stroke", "clip", "fillText", "strokeText",
+ "measureText", "isPointInPath", "strokeStyle", "fillStyle",
+ "createLinearGradient", "createRadialGradient", "createPattern",
+ "shadowOffsetX", "shadowOffsetY", "shadowBlur", "shadowColor",
+ //"mozTextStyle", "mozDrawText", "mozMeasureText", "mozPathText",
+ "mozTextAlongPath", "drawImage", "getImageData", "putImageData",
+ "createImageData", "drawWindow"
+ ]
+};
+
+
+
+Karma._makeSvgs = function (svgConfigs){
+ var makeSvg = function (svgConfig){
+ var svg = undefined;
+ svg = Karma.create(Karma.kSvg)._init(svgConfig);
+ Karma.karma.svg[svgConfig.name] = svg;
+ };
+
+ svgConfigs.forEach(function(svgConfig){ makeSvg(svgConfig);});
+
+};
+
+/** Prototypal object for each svg element submitted to Karma in the
+ * Karma() method
+ * @throws {Error} if the name and domId for the svg element are not specified
+ * @thows {Error} if the supplied domId does not match an element in the DOM
+ * @class This object is the prototype for each svg element submitted to Karma in the
+ * Karma() method
+ */
+Karma.kSvg = {
+ /** name of instance, used internally
+ * @typeof string
+ * @default ""
+ */
+ name : "",
+ /** width of element
+ * @type number
+ * @default 0
+ */
+ width: 0,
+ /** height of element
+ * @type number
+ * @default 0
+ */
+ height: 0,
+ /** Status of element, either "loaded" or "error"
+ * @type string
+ * @default ""
+ */
+ status: "",
+ /** Whether canvas is visible
+ * @type boolean
+ * @default true
+ */
+ visible: true,
+ /** Element ID for canvas element in html document
+ * @type String
+ * @default undefined
+ */
+ domId: undefined,
+ /** Reference to the DOM element
+ * @type DOMElement
+ * @default undefined
+ */
+ node: undefined,
+ /** Reference to the SVGDocument
+ * @type SVGDocument
+ * @default undefined
+ */
+ doc: undefined,
+ /** Reference to the root element of the SVG Document
+ * @type DocumentElement
+ * @default undefined
+ */
+ root: undefined,
+ _localized : undefined,
+ _chainingFunctions: [],
+ _init: function (config) {
+ Karma.karma._counters.total++;
+
+ for (var option in config){
+ if (config.hasOwnProperty(option)){
+ switch (option){
+ case "name":
+ this.name = config[option];
+ break;
+ case "domId":
+ this.domId = config[option];
+ break;
+ case "width":
+ if(!this.height){
+ throw new Error("If you specify a width you must also" +
+ "specify a height");
+ }
+ this.width = parseInt(config[option], 10);
+ break;
+ case "height":
+ if(!this.width){
+ throw new Error("If you specify a height you must also" +
+ "specify a width");
+ }
+ this.height = config[option];
+ break;
+ case "fps":
+ this.fps = config[option];
+ break;
+ }
+ }
+ }
+
+ if(this.domId && document.getElementById(this.domId)){
+ this.node = document.getElementById(this.domId);
+ } else {
+ throw new Error('you must specify a valid domId that' +
+ 'is in your html page');
+ }
+
+ if(!config.height && !config.width){
+ this.width = parseInt(this.node.getAttribute('width'), 10);
+ this.height = parseInt(this.node.getAttribute('height'), 10);
+ }
+
+ var that = this;
+ that._addEventHandlers();
+
+ return this;
+
+
+ },
+ _addEventHandlers : function () {
+ var that = this;
+ that.doc = that.node.getSVGDocument();
+ that.node.addEventListener(
+ "load",
+ function (e) {
+ that.doc = that.node.getSVGDocument();
+ that.root = that.doc.documentElement;
+ Karma.karma._counters.loaded++;
+ Karma.karma._updateStatus();
+ that.status = "loaded";
+ }, false);
+
+ that.node.addEventListener(
+ "error",
+ function (e) {
+ Karma.karma._counters.loaded--;
+ Karma.karma._counters.errors++;
+ that.status = "error";
+ var errorMsg = "Error: " + that._type.toUpperCase() +
+ " " + that.name + " cannot be loaded.";
+ Karma.karma._updateStatus(errorMsg);
+ },
+ false);
+ that.node.addEventListener(
+ "abort",
+ function (e) {
+ that.status = "aborted";
+ var errorMsg = "ABORT: " + that._type.toUpperCase() +
+ " " + that.name + " loading was aborted.";
+ Karma.karma._updateStatus(errorMsg);
+
+ }, false);
+
+ }
+};
+
+Karma._makeVideos = function (video){
+
+};
diff --git a/examples/lessons/6_Maths_multiplyingFractions/js/lesson.js b/examples/lessons/6_Maths_multiplyingFractions/js/lesson.js
new file mode 100755
index 0000000..82f77df
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/js/lesson.js
@@ -0,0 +1,813 @@
+$(document).ready(function(){
+ var k = Karma({
+ audio: [{'name':'correct','file':'correct.wav'},
+ {'name':'incorrect','file':'incorrect.wav'},
+ ]});
+
+ k.ready(function(){
+ var i,j,s,t;
+ var currentLesson; //variable to keep track of the current lesson
+ var clickCounter; //count the next button clicks for the particular lesson
+ var cutCounter;
+ var currentTopButton,currentLeftButton;
+ var TOTAL_QUES = 10;
+ var frac1 = []; //an array to store the fractions
+ var frac2 = [];
+ var scoreboard;
+ var answers = [1311,24,437,8,
+ 54,2,27,1,
+ 663,42,221,14,
+ 13,8,13,8,
+ 114,48,57,24,
+ 12,48,1,4,
+ 1519,132, 1519,132,
+ 280,30,28,3,
+ 77,4,77,4,
+ 300,10,30,1
+ ]; // 4 answers for a question
+ var flag_busy; //flag is set set to 1 if it is busy
+ var currentAns = []; //array storing the currently set answers
+ var animCount; //to keep track of counting the anim9ations
+
+ var assignQuestion = function(quesId,frac1,frac2,flagWhole1,flagWhole2){
+ var fracInc = 0;
+ var fracCount = 0;
+ var symCounter = 0;
+ symInc = 10*quesId+symCounter;
+ fracInc = 6*quesId+fracCount;
+ $('#lessonContainer').append('<div id="ques'+quesId+'" class="quesContainer"></div>');
+ if(frac1[fracCount]>9){
+ showText('ques'+quesId,'frac1'+fracInc,1,.5,frac1[fracCount]);
+ }else{
+ showText('ques'+quesId,'frac1'+fracInc,1,1,frac1[fracCount]);
+ }
+ fracCount++;fracInc = 6*quesId+fracCount;
+ showText('ques'+quesId,'frac1'+fracInc,.3,1.7,frac1[fracCount]);fracCount++;fracInc = 6*quesId+fracCount;
+ if(flagWhole1 === 0){
+ showText('ques'+quesId,'sym'+symInc,.4,1.7,'_');symCounter++;symInc = 10*quesId+symCounter;
+ }
+ if(frac1[fracCount]>9){
+ showText('ques'+quesId,'frac1'+fracInc,1.6,1.4,frac1[fracCount]);
+ }
+ else{
+ showText('ques'+quesId,'frac1'+fracInc,1.6,1.7,frac1[fracCount]);
+ }
+ fracCount = 0;fracInc = 6*quesId+fracCount;
+ showText('ques'+quesId,'sym'+symInc,.9,2.7,'x');symCounter++;symInc = 10*quesId+symCounter;
+ showText('ques'+quesId,'frac2'+fracInc,1,3.5,frac2[fracCount]); fracCount++;fracInc = 6*quesId+fracCount;
+ showText('ques'+quesId,'frac2'+fracInc,.3,4.2,frac2[fracCount]);fracCount++;fracInc = 6*quesId+fracCount;
+ if(flagWhole2 === 0){
+ showText('ques'+quesId,'sym'+symInc,.4,4.2,'_');symCounter++;symInc = 10*quesId+symCounter;
+ }
+ if(frac2[fracCount]>9){
+ showText('ques'+quesId,'frac2'+fracInc,1.6,4,frac2[fracCount]);
+ }
+ else{
+ showText('ques'+quesId,'frac2'+fracInc,1.6,4.2,frac2[fracCount]);
+ }
+ showText('ques'+quesId,'sym'+symInc,.9,5.3,'=');symCounter++;symInc = 10*quesId+symCounter;
+ showText('ques'+quesId,'sym'+symInc,.4,6.6,'________');symCounter++;symInc = 10*quesId+symCounter;
+ showText('ques'+quesId,'sym'+symInc,.45,6.6,'________');symCounter++;symInc = 10*quesId+symCounter;
+ showText('ques'+quesId,'inputTxt1'+quesId,.1,6.8,'<input id="inTxt1'+quesId+'" type="text" class="inputFraction" />');
+ showText('ques'+quesId,'inputTxt2'+quesId,1.65,6.8,'<input id="inTxt2'+quesId+'" type="text" class="inputFraction" />');
+ showText('ques'+quesId,'sym'+symInc,.9,11.5,'=');symCounter++;symInc =10*quesId+symCounter;
+ showText('ques'+quesId,'sym'+symInc,.4,12.6,'________');symCounter++;symInc = 10*quesId+symCounter;
+ showText('ques'+quesId,'sym'+symInc,.45,12.6,'________');symCounter++;symInc =10*quesId+symCounter;
+ showText('ques'+quesId,'inputTxt3'+quesId,.1,12.8,'<input id="inTxt3'+quesId+'" type="text" class="inputFraction" />');
+ showText('ques'+quesId,'inputTxt4'+quesId,1.65,12.8,'<input id="inTxt4'+quesId+'" type="text" class="inputFraction" />');
+ showText('ques'+quesId,'symChecked1'+quesId,2,11,'');
+ showText('ques'+quesId,'symChecked2'+quesId,2,17,'');
+
+ foucs_blur();
+
+ };
+
+ var nextLesson = function(){
+ $('#linkShowAns').hide();
+ $('#linkCheckAns').hide();
+ $('#content').removeClass('backOpaque');
+ $('#gameOver').hide()
+ clickCounter = 0;
+ $('#score_box').hide();
+ $('#content').html('').append('<div id="lessonContainer"></div>');
+ if(currentLesson === 4){
+ $('#linkShowAns').show();
+ $('#linkCheckAns').show();
+ flag_busy = 0;
+ $('#currentTitle').html('भिन्नहरुको गुणन');
+ $('#score_box').show();
+ scoreboard = $('#score_box').scoreboard({'layout':'horizontal',
+ 'winningScore': TOTAL_QUES});
+ scoreboard.scoreboard('reset');
+ scoreboard.scoreboard('incTotal',10);
+
+ showPicture('divImgSimplify1','beforeSimplify',1,17);
+ showPicture('divImgSimplify2','afterSimplify',1,29);
+ showPicture('divImgSimplify3','beforeSimplify',1,55);
+ showPicture('divImgSimplify4','afterSimplify',1,68);
+
+ frac1[0] = 7; frac1[1] = 1; frac1[2] = 8;
+ frac2[0] = 7; frac2[1] = 2; frac2[2] = 3;
+ assignQuestion(0,frac1,frac2,0,0);
+
+ frac1[0] = 6; frac1[1] = ''; frac1[2] = '';
+ frac2[0] = ''; frac2[1] = 9; frac2[2] = 2;
+ assignQuestion(1,frac1,frac2,1,0);
+
+ frac1[0] = 6; frac1[1] = 3; frac1[2] = 6;
+ frac2[0] = 2; frac2[1] = 3; frac2[2] = 7;
+ assignQuestion(2,frac1,frac2,0,0);
+
+ frac1[0] = 6; frac1[1] = 1; frac1[2] = 2;
+ frac2[0] = ''; frac2[1] = 1; frac2[2] = 4;
+ assignQuestion(3,frac1,frac2,0,0);
+
+ frac1[0] = ''; frac1[1] =6; frac1[2] = 8;
+ frac2[0] = 3; frac2[1] = 1; frac2[2] = 6;
+ assignQuestion(4,frac1,frac2,0,0);
+
+ frac1[0] = ''; frac1[1] =4; frac1[2] = 8;
+ frac2[0] = ''; frac2[1] = 3; frac2[2] = 6;
+ assignQuestion(5,frac1,frac2,0,0);
+
+ frac1[0] = 4; frac1[1] =1; frac1[2] = 12;
+ frac2[0] = 2; frac2[1] = 9; frac2[2] =11;
+ assignQuestion(6,frac1,frac2,0,0);
+
+ frac1[0] = 2; frac1[1] =4; frac1[2] = 5;
+ frac2[0] = 3; frac2[1] = 2; frac2[2] =6;
+ assignQuestion(7,frac1,frac2,0,0);
+
+ frac1[0] = ''; frac1[1] =11; frac1[2] = 2;
+ frac2[0] = ''; frac2[1] = 7; frac2[2] =2;
+ assignQuestion(8,frac1,frac2,0,0);
+
+ frac1[0] = 12; frac1[1] =1; frac1[2] = 2;
+ frac2[0] = 2; frac2[1] = 2; frac2[2] =5;
+ assignQuestion(9,frac1,frac2,0,0);
+ }
+
+ else if(currentLesson === 0){
+ currentTopButton = 10;
+ currentLeftButton = 80;
+ $('#currentTitle').html('भिन्नलाई पूर्ण संख्याले गुणन गर्दा');
+ $('#content').append('<div id="imgWhole"></div>');
+ $('#imgWhole').append('<img class="float-left" src="assets/image/lesson1ImgPart1.png" />');
+ $('#imgWhole').append('<img id="lessonImgAnimate" src="assets/image/lesson1ImgPart2.png" />');
+ var lessonImgAnimate = {
+ 'position':'absolute',
+ 'top':'1.9em',
+ 'left': '6.2em'
+ };
+ $('#lessonImgAnimate').css(lessonImgAnimate);
+ $('#content').append('<img class="float-right" src="assets/image/lesson1ImgDef1.png" />');
+ imgAnimate('lessonImgAnimate',1.9,10,1000);
+ }
+ if(currentLesson === 1){
+ currentTopButton = 5;
+ currentLeftButton = 80;
+ $('#currentTitle').html('भिन्नलाई पूर्ण संख्याले गुणन गर्दा');
+ $('#content').append('<div id="imgWhole"></div>');
+ $('#imgWhole').append('<img class="float-left" src="assets/image/lesson2ImgPart1.png" />');
+ $('#imgWhole').append('<img id="lessonImgAnimate" src="assets/image/lesson2ImgPart2.png" />');
+ var lessonImgAnimate = {
+ 'position':'absolute',
+ 'top':'2.3em',
+ 'left': '7.4em'
+ };
+ $('#lessonImgAnimate').css(lessonImgAnimate);
+ $('#content').append('<div id="lesson2Div1"></div>');
+ $('#lesson2Div1').append('<img class="float-left" src="assets/image/lesson2ImgDef1.png" />');
+ imgAnimate('lessonImgAnimate',2.3,11,1000);
+ }
+ if(currentLesson === 2){
+ currentTopButton = 35;
+ currentLeftButton = 38;
+ showNextButton();
+ $('#currentTitle').html('भिन्नलाई भिन्नले गुणन गर्दा');
+ $('#content').append('<div id="imgRoti1"></div>');
+ $('#imgRoti1').append('<img class="float-left" src="assets/image/lesson3Img1.png" />');
+ $('#imgRoti1').append('<img id="lessonImgAnimate1" src="assets/image/lesson3ImgPart1.png" />');
+ var lessonImgAnimate = {
+ 'position':'absolute',
+ 'top':'15em',
+ 'left': '1.2em'
+ };
+ $('#lessonImgAnimate1').css(lessonImgAnimate);
+
+ $('#content').append('<div id="imgRoti2"></div>');
+ $('#imgRoti2').append('<img class="float-left" src="assets/image/lesson3Img2.png" />');
+ $('#imgRoti2').append('<img id="lessonImgAnimate2" src="assets/image/lesson3ImgPart2.png" />');
+ var lessonImgAnimate = {
+ 'position':'absolute',
+ 'top':'15.1em',
+ 'left': '6em'
+ };
+ $('#lessonImgAnimate2').css(lessonImgAnimate);
+ $('#imgRoti2').hide();
+ $('#content').append('<div id="imgRoti3"></div>');
+ $('#imgRoti3').append('<img class="float-left" src="assets/image/lesson3Img3.png" />');
+ $('#imgRoti3').hide();
+ showFractions();
+ }
+ if(currentLesson === 3){
+ currentTopButton = 20;
+ currentLeftButton = 38;
+ showNextButton();
+ $('#currentTitle').html('फरक हर / अंश भएको दुई भिन्न को गुणन ');
+ showPicture('divImgDef1','lesson4ImgDef1',0,-2);
+ showPicture('divImg1','lesson4Img1',0,70);
+ showFractions();
+ }
+ if(currentLesson === 5){
+ currentTopButton = 10;
+ currentLeftButton = 60;
+ showNextButton();
+ $('#currentTitle').html('तिमीले बुझ्नु पर्ने कुरा ');
+ showPicture('divImgDef1','lesson6ImgDef1',0,-2);
+ showPicture('divImg1','lesson6Img1',15,70);
+ showFractions();
+
+ }
+
+ };
+ //function to display the text and fraction symbols inside a div
+ function showText(parentDiv,divName,topPos,leftPos,numText){ //flatTxt o for text 1 for image
+ var textCss = {
+ 'position':'absolute',
+ 'top':topPos+'em',
+ 'left':leftPos+'em',
+ 'font':'2em arial,verdana,geneva,helvetica'
+ };
+ $('#'+parentDiv).append('<div id="'+divName+'"></div>');
+ $('#'+divName).css(textCss).html(numText);
+ }
+
+ function makeAnimContainer(divName,topPos,leftPos,width,height,bgColor){
+ var fracAnimContainer = {
+ 'position':'absolute',
+ 'top': topPos+'em',
+ 'left': leftPos+'em',
+ 'width': width+'em',
+ 'height': height+'em',
+ 'background-color': '#'+bgColor
+ };
+ $('#content').append('<div id="'+divName+'"></div>');
+ $('#'+divName).css(fracAnimContainer);
+ }
+
+
+ //function that keeps the photos at a given place absolute position
+ function showPicture(divName,imgName,topPos,leftPos){
+ var imgCss = {
+ 'position':'absolute',
+ 'top':topPos+'em',
+ 'left':leftPos+'em',
+ };
+ $('#content').append('<div id="'+divName+'"></div>');
+ $('#'+divName).css(imgCss).html('<img src="assets/image/'+imgName+'.png" />');
+ }
+
+ function game(){
+ currentLesson = 0;
+ $('#linkNextLesson').show();
+ $('#linkPrevLesson').hide();
+
+ nextLesson();
+ }
+ $('#linkNextLesson').hide();
+ $('#linkShowAns').hide();
+ $('#linkCheckAns').hide();
+ $('#linkPrevLesson').hide();
+ $('#linkHelp').mouseover(function(){
+ $('#help').slideDown(2000);
+ })
+ .mouseout(function(){
+ $('#help').slideUp(2000);
+ });
+
+ function delayHideAns(){
+ document.delayForm.delayval.value = 1;
+ clearTimeout(t);
+ for(var i = 0;i<TOTAL_QUES;i++){
+ for(var j=0; j< 4; j++){
+ var k = j+1;
+ $('#inTxt'+k+''+i).val(currentAns[i*4+j]);
+ }
+ }
+ flag_busy = 0;
+ }
+ $('#linkShowAns').click(function(){
+ //alert($('#inTxt10').val());
+
+ //first store the current texboxes values
+ if(flag_busy === 0){
+ flag_busy = 1;
+ for(var i = 0;i<TOTAL_QUES;i++){
+ for(var j=0; j< 4; j++){
+ var k = j+1;
+ currentAns[4*i+j] = $('#inTxt'+k+''+i).val();
+ }
+ }
+
+ for(var i = 0;i<TOTAL_QUES;i++){
+ for(var j=0; j< 4; j++){
+ var k = j+1;
+ $('#inTxt'+k+''+i).val(answers[i*4+j]);
+ }
+ }
+ t=setTimeout(function(){delayHideAns();},5000); //after 5 seconds goes to the same status as user had put input
+ }
+ });
+ $('#linkCheckAns').click(function(){
+ if(flag_busy === 0){
+ for(var i = 0;i<TOTAL_QUES;i++){
+ for(var j=0; j< 4; j++){
+ var k = j+1;
+ currentAns[4*i+j] = $('#inTxt'+k+''+i).val();
+ }
+ }
+ var correctCounter = 0;
+ scoreboard.scoreboard('reset');
+ scoreboard.scoreboard('incTotal',10);
+ for(var i = 0;i<TOTAL_QUES;i++){
+ var checkCount = 0;
+ if(currentAns[4*i+0] == answers[4*i+0] && currentAns[4*i+1] == answers[4*i+1]){
+ $('#symChecked1'+i).html('<img src="assets/image/correct.png" />');
+ checkCount++;
+ }
+ else{
+ $('#symChecked1'+i).html('<img src="assets/image/incorrect.png" />');
+ }
+ if(currentAns[4*i+2] == answers[4*i+2] && currentAns[4*i+3] == answers[4*i+3]){
+ $('#symChecked2'+i).html('<img src="assets/image/correct.png" />');
+ checkCount++;
+ }
+ else{
+ $('#symChecked2'+i).html('<img src="assets/image/incorrect.png" />');
+ }
+ if(checkCount == 2){
+ scoreboard.scoreboard('inc');
+ correctCounter++;
+ if(correctCounter === 10){
+ $('#content').addClass('backOpaque');
+ $('#gameOver').show().html('Great Job !!!');
+ }
+ }
+ }
+ }
+
+ });
+
+
+ //function to be rearranged later
+ function showNextButton(){
+ $('#content').append('<div class="nextBtn"></div>');
+ $('.nextBtn').show();
+ var nextbtncss = {
+ 'top': currentTopButton+'em',
+ 'left': currentLeftButton+'em'
+ };
+
+ $('.nextBtn').css(nextbtncss);//html('<img src="assets/image/nextBtn.png"/>');
+
+ }
+ function hideNextButton(){
+ $('.nextBtn').hide();
+ }
+
+ function showLesson1ImgFraction(){
+ $('#content').append('<div id="lesson1ImgFraction" class="lessonImgFrac"></div>');
+ $('#lesson1ImgFraction').append('<img src="assets/image/lesson1ImgFractions.png" />');
+ $('#content').append('<div id="lesson1ImgFractionRight"></div>');
+ $('#lesson1ImgFractionRight').append('<img src="assets/image/img1FractionTotal.png" />');
+ $('#lesson1ImgFractionRight').hide();
+ assignLessonImages(0,8.8,6.8,3);
+ assignLessonImages(1,8.5,24.4,2);
+ assignLessonImages(2,8.7,44,1);
+ assignLessonImages(3,8.7,44,1);
+ imgAnimateNoNxtBtn('lessonImg0',8.8,58,2000);
+ imgAnimateNoNxtBtn('lessonImg1',8.8,65,2000);
+ imgAnimateNoNxtBtn('lessonImg2',6,65,2000);
+ imgAnimateNoNxtBtn('lessonImg3',10,65,2000);
+ }
+
+ function imgAnimateNoNxtBtn(divName,topPos,leftPos,duration){
+ $('#'+divName).animate(
+ {top:topPos+'em',left:leftPos+'em'},duration,
+ function(ev){
+ if(divName == 'lessonImg3'){
+ for(i = 0;i<4;i++){
+ $('#lessonImg'+i).hide();
+ }
+ $('#lesson1ImgFractionRight').show();
+ showNextButton();
+ $('.nextBtn').click(function(){
+ $('#content').append('<img src="assets/image/lesson1ImgDef2.png" />');
+ $('.nextBtn').hide();
+ });
+ }
+
+ });
+
+ }
+
+ function assignLessonImages(imgId,topPos,leftPos,zIndex){
+ if(imgId === 3){
+ $('#lesson1ImgFraction').append('<img id="lessonImg'+imgId+'" src="assets/image/lesson1ImgDown.png" />');
+
+ }
+ else{
+ $('#lesson1ImgFraction').append('<img id="lessonImg'+imgId+'" src="assets/image/lesson1ImgPart2.png" />');
+ }
+ var lessonImgAnimate = {
+ 'position':'absolute',
+ 'top':topPos+'em',
+ 'left':leftPos+'em',
+ 'z-index':zIndex
+ };
+ $('#lessonImg'+imgId).css(lessonImgAnimate);
+
+ }
+
+ function delayCutNext(){
+ document.delayForm.delayval.value = 1;
+ if(cutCounter === 0){
+ showText('divAnim3','textCutSym1',2.9,7.5,'/');
+ }
+ else if(cutCounter === 1){
+ showText('divAnim3','textCutSym2',3.3,8.1,1);
+ }
+ else if(cutCounter === 2){
+ showText('divAnim3','textCutSym3',1.2,10.2,'/');
+ }
+ else if(cutCounter === 3){
+ showText('divAnim3','textCutSym4',.6,10.6,2);
+ }
+ else if(cutCounter === 4){
+ showText('divAnim3','textCutSym5',2.9,10.2,'/');
+ }
+ else if(cutCounter === 5){
+ showText('divAnim3','textCutSym6',3.3,10.6,1);
+ }
+ else if(cutCounter === 6){
+ showText('divAnim3','textCutSym7',1.2,7.5,'/');
+ }
+ else if(cutCounter === 7){
+ showText('divAnim3','textCutSym8',.6,8.1,7);
+ }
+ else if(cutCounter === 8){
+ showText('divAnim3','textSym19',2,12,'=');
+
+ }
+ else if(cutCounter === 9){
+ showText('divAnim3','textSym20',2,13,14);
+ }
+ clearTimeout(t);
+ cutCounter++;
+ startCuttingProcess();
+
+ }
+
+ function startCuttingProcess(){
+ t=setTimeout(function(){delayCutNext();},500);
+ }
+
+ function imgAnimate(divName,topPos,leftPos,duration){
+ $('#'+divName).animate(
+ {top:topPos+'em',left:leftPos+'em'},duration,
+ function(ev){ //callback function after the animation is complete
+ //alert('animation complete');
+ if(currentLesson === 3){
+ if(animCount === 0){
+ showText('divAnim1','textSym1',.4,4.8,'x');
+ imgAnimate('text3Anim',.5,5.5,1000);
+ }
+ else if(animCount === 1){
+ showText('divAnim1','textSym2',.4,3.5,'(');
+ showText('divAnim1','textSym3',.4,6.3,')');
+ showText('divAnim1','textSym4',.4,6.8,'+');
+ imgAnimate('text2Anim',.5,7.4,1500);
+ }
+ else if(animCount === 2){
+ showText('divAnim1','textSym5',.6,3.3,'_________');
+ imgAnimate('text4Anim',1.7,5.4,1500);
+ }
+ else if(animCount === 3){
+ showText('divAnim1','text5Anim',1.7,5.4,4);
+ showText('divAnim1','textSym6',1,8.5,'=');
+ showText('divAnim1','textSym7',.5,9.7,21);
+ showText('divAnim1','text6',.55,9.6,'__');
+ imgAnimate('text5Anim',1.7,9.8,1500);
+
+ }
+ else if(animCount === 4){
+ showText('divAnim1','text2frac1',.5,9.7,21);
+ showText('divAnim1','text2frac2',.55,9.6,'__');
+ showText('divAnim1','text2frac3',1.7,9.8,4);
+
+ showFractions();
+ }
+ else if(animCount === 5){
+ showText('divAnim2','textSym8',.4,4.8,'x');
+ imgAnimate('text8Anim',.5,5.5,1000);
+ }
+ else if(animCount === 6){
+ showText('divAnim2','textSym9',.4,3.5,'(');
+ showText('divAnim2','textSym10',.4,6.3,')');
+ showText('divAnim2','textSym11',.4,6.8,'+');
+ imgAnimate('text7Anim',.5,7.7,1500);
+ }
+ else if(animCount === 7){
+ showText('divAnim2','textSym13',.6,3.3,'_________');
+ imgAnimate('text9Anim',1.7,5.4,1500);
+ }
+ else if(animCount === 8){
+ showText('divAnim2','text10Anim',1.7,5.4,3);
+ showText('divAnim2','textSym14',1,8.5,'=');
+ showText('divAnim2','textSym15',.5,9.7,8);
+ showText('divAnim2','text12',.55,9.6,'__');
+ imgAnimate('text10Anim',1.7,9.8,1500);
+
+ }
+ else if(animCount === 9){
+ showText('divAnim2','text4frac1',.5,9.7,8);
+ showText('divAnim2','text4frac2',.55,9.6,'__');
+ showText('divAnim2','text4frac3',1.7,9.8,3);
+ showFractions();
+ }
+ else if(animCount === 13){
+ hideNextButton();
+ showText('divAnim3','textSym16',2,2.3,'x');
+ imgAnimate('text3frac1',8,-12,1000);
+ imgAnimate('text3frac2',7.3,-11.25,1000);
+ imgAnimate('text3frac3',7.55,-11.3,1000);
+ imgAnimate('text3frac4',8.8,-11.25,1000);
+ }
+ else if(animCount === 17){
+ showText('divAnim3','textSym17',2,5,'=');
+ imgAnimate('text2frac1',7.3,20,1000);
+ imgAnimate('text2frac2',7.55,20,1000);
+ imgAnimate('text2frac3',8.8,20.3,1000);
+ }
+ else if(animCount === 20){
+ showText('divAnim3','textSym18',2,8.5,'X');
+ imgAnimate('text4frac1',7.3,-5,1000);
+ imgAnimate('text4frac2',7.55,-5.3,1000);
+ imgAnimate('text4frac3',8.8,-5,1000);
+
+ }
+ else if(animCount === 23){
+
+ cutCounter = 0;
+ startCuttingProcess();
+ }
+ animCount++;
+
+ }
+ else{
+ showNextButton();
+ if(currentLesson === 2){
+ if(clickCounter === 0){
+ clickCounter++;
+ $('#imgRoti2').show();
+ showFractions();
+ }
+ else if(clickCounter === 1){
+ clickCounter++;
+ $('#imgRoti3').show();
+ $('.nextBtn').hide();
+
+ }
+
+ }
+
+ else if(currentLesson === 1){
+ if(clickCounter ===0){
+ $('#imgWhole').append('<img id="lesson2frac1" src="assets/image/lesson2frac1.png">');
+ $('.nextBtn').click(function(){
+ $('#lesson2Div1').append('<img src="assets/image/lesson2frac2.png">');
+ clickCounter++;
+ showFractions();
+ });
+ }
+
+ }
+ else if(currentLesson === 0) {
+ $('#imgWhole').append('<img id="lesson1frac1" src="assets/image/lesson1frac1.png">');
+ $('.nextBtn').click(function(){
+ showLesson1ImgFraction();
+ $('.nextBtn').hide();
+ });
+ }
+ }
+ });
+
+ }
+
+ function showFractions(){
+ showNextButton();
+ $('.nextBtn').click(function(){
+ if(currentLesson === 3){
+ if(clickCounter === 0){
+ showPicture('divImg2','lesson4Img2',28,-2);
+ showPicture('divImgDef2','lesson4ImgDef2',4,-2);
+ clickCounter++;
+ showFractions();
+ }
+ else if(clickCounter === 1){
+ showPicture('divImgDef3','lesson4ImgDef3',8,-2);
+ clickCounter++;
+ showFractions();
+ }
+ else if(clickCounter === 2){
+ showPicture('divImg4','lesson4Img3',38,10);
+ clickCounter++;
+ showFractions();
+ }
+ else if(clickCounter === 3){
+ showPicture('divImgDef4','lesson4ImgDef4',12,15);
+ clickCounter++;
+ //hideNextButton();
+ }
+ else if(clickCounter === 4){ //next animation stuffs
+ //animation stuffs of fraction great work needs to be done
+ hideNextButton();
+ makeAnimContainer('divAnim1',18,4,25,7,'8977FE');
+ showText('divAnim1','text1',1,.5,5);
+ showText('divAnim1','text2',.3,1.25,1);
+ showText('divAnim1','text3',.55,1.3,'_');
+ showText('divAnim1','text4',1.8,1.25,4);
+ showText('divAnim1','text5',1,2.35,'=');
+
+ showText('divAnim1','text1Anim',1,.5,5);
+ showText('divAnim1','text2Anim',.3,1.25,1);
+ showText('divAnim1','text3Anim',1.8,1.25,4);
+ showText('divAnim1','text4Anim',1.8,1.25,4);
+ // for animating the fractin part
+ showText('divAnim1','text1frac1',1,.5,5);
+ showText('divAnim1','text1frac2',.3,1.25,1);
+ showText('divAnim1','text1frac3',.55,1.3,'_');
+ showText('divAnim1','text1frac4',1.8,1.25,4);
+
+ animCount = 0;
+ imgAnimate('text1Anim',.5,4,1000);
+ clickCounter++;
+
+
+ }
+ else if(clickCounter === 5){ //next animation stuffs
+ hideNextButton();
+ makeAnimContainer('divAnim2',18,60,25,7,'8977FE');
+
+
+ showText('divAnim2','text7',1,.5,2);
+ showText('divAnim2','text8',.3,1.25,2);
+ showText('divAnim2','text9',.55,1.3,'_');
+ showText('divAnim2','text10',1.8,1.25,3);
+ showText('divAnim2','text11',1,2.35,'=');
+
+ showText('divAnim2','text6Anim',1,.5,2);
+ showText('divAnim2','text7Anim',.3,1.25,2);
+ showText('divAnim2','text8Anim',1.8,1.25,3);
+ showText('divAnim2','text9Anim',1.8,1.25,3);
+ imgAnimate('text6Anim',.5,4,1000);
+
+ showText('divAnim2','text3frac1',1,.5,2);
+ showText('divAnim2','text3frac2',.3,1.25,2);
+ showText('divAnim2','text3frac3',.55,1.3,'_');
+ showText('divAnim2','text3frac4',1.8,1.25,3);
+ clickCounter++;
+ }
+ else if(clickCounter === 6){
+ makeAnimContainer('divAnim3',30,30,30,8);
+ imgAnimate('text1frac1',8,13.5,1000);
+ imgAnimate('text1frac2',7.3,14.25,1000);
+ imgAnimate('text1frac3',7.55,14.3,1000);
+ imgAnimate('text1frac4',8.8,14.25,1000);
+
+ }
+
+ }
+
+
+ else if(currentLesson === 2){
+
+ if(clickCounter === 0){
+ imgAnimate('lessonImgAnimate1',15,32.8,1000);
+ }
+ else if(clickCounter === 1){
+ imgAnimate('lessonImgAnimate2',15.3,40,1000);
+ }
+
+
+ }
+ else if(currentLesson === 1){
+
+ if(clickCounter ===1){
+ $('#lesson2Div1').append('<img src="assets/image/lesson2frac3.png">');
+ clickCounter++;
+ showFractions();
+
+ }
+ else if(clickCounter ===2){
+ $('#content').append('<img class="float-center" src="assets/image/lesson2ImgDef2.png">');
+ clickCounter++;
+ showFractions();
+ }
+ else if(clickCounter ===3){
+ $('#content').append('<div id="lesson2ImgFraction" class="lessonImgFrac"></div>');
+ $('#lesson2ImgFraction').append('<img src="assets/image/lesson2ImgFractions.png" />');
+ clickCounter++;
+ showFractions();
+ }
+ else if(clickCounter ===4){
+ $('#content').append('<div id="lesson2ImgFractionRight"></div>');
+ $('#lesson2ImgFractionRight').append('<img src="assets/image/img2FractionTotal.png" />');
+ clickCounter++;
+ showFractions();
+ }
+ else if(clickCounter ===5){
+ $('#content').append('<img class="float-left" src="assets/image/lesson2ImgDef3.png" />');
+ clickCounter++;
+ showFractions();
+ }
+ else if(clickCounter ===6){
+ $('#content').append('<img class="float-right" src="assets/image/lesson2ImgDef4.png" />');
+ clickCounter++;
+ $('.nextBtn').hide();
+ }
+
+ }
+ else if(currentLesson === 5){
+ if(clickCounter === 0){
+ showPicture('divImgDef2','lesson6ImgDef2',11,-2);
+ }
+ else if(clickCounter === 1){
+ showPicture('divImgDef3','lesson6ImgDef3',20,-2);
+ }
+ else if(clickCounter === 2){
+ showPicture('divImgDef4','lesson6ImgDef4',27,-2);
+ }
+ else if(clickCounter === 3){
+ showPicture('divImgDef5','lesson6ImgDef5',33,-2);
+ hideNextButton();
+ }
+ clickCounter++;
+ }
+ });
+ }
+
+
+ function foucs_blur(){
+ $('input[type="text"]')
+ .focus(function() {
+ $(this).addClass("focus");
+ })
+ .blur(function() {
+ $(this).removeClass("focus");
+ })
+ }
+
+ $('#linkNextLesson').click(function(){
+ currentLesson++;
+ if(currentLesson === 5){
+ $('#linkNextLesson').hide();
+ $('#linkPrevLesson').show();
+ }
+ else{
+ $('#linkNextLesson').show();
+ $('#linkPrevLesson').show();
+ }
+
+ nextLesson();
+ });
+ $('#linkPrevLesson').click(function(){
+ currentLesson--;
+ if(currentLesson === 0){
+ $('#linkPrevLesson').hide();
+ }
+ else{
+ $('#linkNextLesson').show();
+ $('#linkPrevLesson').show();
+ }
+
+ nextLesson();
+ });
+
+
+ $('#linkStart').click(function(){
+ game();
+ });
+
+ $('#linkPlayAgain').click(function(){
+ nextLesson();
+ });
+
+
+
+
+ }); //end of k.ready
+}); //end of document.read
+
+
diff --git a/examples/lessons/6_Maths_multiplyingFractions/js/lesson.js~ b/examples/lessons/6_Maths_multiplyingFractions/js/lesson.js~
new file mode 100755
index 0000000..87b9d9b
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/js/lesson.js~
@@ -0,0 +1,813 @@
+$(document).ready(function(){
+ var k = Karma({
+ audio: [{'name':'correct','file':'correct.wav'},
+ {'name':'incorrect','file':'incorrect.wav'},
+ ]});
+
+ k.ready(function(){
+ var i,j,s,t;
+ var currentLesson; //variable to keep track of the current lesson
+ var clickCounter; //count the next button clicks for the particular lesson
+ var cutCounter;
+ var currentTopButton,currentLeftButton;
+ var TOTAL_QUES = 10;
+ var frac1 = []; //an array to store the fractions
+ var frac2 = [];
+ var scoreboard;
+ var answers = [1311,24,437,8,
+ 54,2,27,1,
+ 663,42,221,14,
+ 13,8,13,8,
+ 114,48,57,24,
+ 12,48,1,4,
+ 1519,132, 1519,132,
+ 280,30,28,3,
+ 77,4,77,4,
+ 300,10,30,1
+ ]; // 4 answers for a question
+ var flag_busy; //flag is set set to 1 if it is busy
+ var currentAns = []; //array storing the currently set answers
+ var animCount; //to keep track of counting the anim9ations
+
+ var assignQuestion = function(quesId,frac1,frac2,flagWhole1,flagWhole2){
+ var fracInc = 0;
+ var fracCount = 0;
+ var symCounter = 0;
+ symInc = 10*quesId+symCounter;
+ fracInc = 6*quesId+fracCount;
+ $('#lessonContainer').append('<div id="ques'+quesId+'" class="quesContainer"></div>');
+ if(frac1[fracCount]>9){
+ showText('ques'+quesId,'frac1'+fracInc,1,.5,frac1[fracCount]);
+ }else{
+ showText('ques'+quesId,'frac1'+fracInc,1,1,frac1[fracCount]);
+ }
+ fracCount++;fracInc = 6*quesId+fracCount;
+ showText('ques'+quesId,'frac1'+fracInc,.3,1.7,frac1[fracCount]);fracCount++;fracInc = 6*quesId+fracCount;
+ if(flagWhole1 === 0){
+ showText('ques'+quesId,'sym'+symInc,.4,1.7,'_');symCounter++;symInc = 10*quesId+symCounter;
+ }
+ if(frac1[fracCount]>9){
+ showText('ques'+quesId,'frac1'+fracInc,1.6,1.4,frac1[fracCount]);
+ }
+ else{
+ showText('ques'+quesId,'frac1'+fracInc,1.6,1.7,frac1[fracCount]);
+ }
+ fracCount = 0;fracInc = 6*quesId+fracCount;
+ showText('ques'+quesId,'sym'+symInc,.9,2.7,'x');symCounter++;symInc = 10*quesId+symCounter;
+ showText('ques'+quesId,'frac2'+fracInc,1,3.5,frac2[fracCount]); fracCount++;fracInc = 6*quesId+fracCount;
+ showText('ques'+quesId,'frac2'+fracInc,.3,4.2,frac2[fracCount]);fracCount++;fracInc = 6*quesId+fracCount;
+ if(flagWhole2 === 0){
+ showText('ques'+quesId,'sym'+symInc,.4,4.2,'_');symCounter++;symInc = 10*quesId+symCounter;
+ }
+ if(frac2[fracCount]>9){
+ showText('ques'+quesId,'frac2'+fracInc,1.6,4,frac2[fracCount]);
+ }
+ else{
+ showText('ques'+quesId,'frac2'+fracInc,1.6,4.2,frac2[fracCount]);
+ }
+ showText('ques'+quesId,'sym'+symInc,.9,5.3,'=');symCounter++;symInc = 10*quesId+symCounter;
+ showText('ques'+quesId,'sym'+symInc,.4,6.6,'________');symCounter++;symInc = 10*quesId+symCounter;
+ showText('ques'+quesId,'sym'+symInc,.45,6.6,'________');symCounter++;symInc = 10*quesId+symCounter;
+ showText('ques'+quesId,'inputTxt1'+quesId,.1,6.8,'<input id="inTxt1'+quesId+'" type="text" class="inputFraction" />');
+ showText('ques'+quesId,'inputTxt2'+quesId,1.65,6.8,'<input id="inTxt2'+quesId+'" type="text" class="inputFraction" />');
+ showText('ques'+quesId,'sym'+symInc,.9,11.5,'=');symCounter++;symInc =10*quesId+symCounter;
+ showText('ques'+quesId,'sym'+symInc,.4,12.6,'________');symCounter++;symInc = 10*quesId+symCounter;
+ showText('ques'+quesId,'sym'+symInc,.45,12.6,'________');symCounter++;symInc =10*quesId+symCounter;
+ showText('ques'+quesId,'inputTxt3'+quesId,.1,12.8,'<input id="inTxt3'+quesId+'" type="text" class="inputFraction" />');
+ showText('ques'+quesId,'inputTxt4'+quesId,1.65,12.8,'<input id="inTxt4'+quesId+'" type="text" class="inputFraction" />');
+ showText('ques'+quesId,'symChecked1'+quesId,2,11,'');
+ showText('ques'+quesId,'symChecked2'+quesId,2,17,'');
+
+ foucs_blur();
+
+ };
+
+ var nextLesson = function(){
+ $('#linkShowAns').hide();
+ $('#linkCheckAns').hide();
+ $('#content').removeClass('backOpaque');
+ $('#gameOver').hide()
+ clickCounter = 0;
+ $('#score_board').hide();
+ $('#content').html('').append('<div id="lessonContainer"></div>');
+ if(currentLesson === 4){
+ $('#linkShowAns').show();
+ $('#linkCheckAns').show();
+ flag_busy = 0;
+ $('#currentTitle').html('भिन्नहरुको गुणन');
+ $('#score_board').show();
+ scoreboard = $('#score_box').scoreboard({'layout':'horizontal',
+ 'winningScore': TOTAL_QUES});
+ scoreboard.scoreboard('reset');
+ scoreboard.scoreboard('incTotal',10);
+
+ showPicture('divImgSimplify1','beforeSimplify',1,17);
+ showPicture('divImgSimplify2','afterSimplify',1,29);
+ showPicture('divImgSimplify3','beforeSimplify',1,55);
+ showPicture('divImgSimplify4','afterSimplify',1,68);
+
+ frac1[0] = 7; frac1[1] = 1; frac1[2] = 8;
+ frac2[0] = 7; frac2[1] = 2; frac2[2] = 3;
+ assignQuestion(0,frac1,frac2,0,0);
+
+ frac1[0] = 6; frac1[1] = ''; frac1[2] = '';
+ frac2[0] = ''; frac2[1] = 9; frac2[2] = 2;
+ assignQuestion(1,frac1,frac2,1,0);
+
+ frac1[0] = 6; frac1[1] = 3; frac1[2] = 6;
+ frac2[0] = 2; frac2[1] = 3; frac2[2] = 7;
+ assignQuestion(2,frac1,frac2,0,0);
+
+ frac1[0] = 6; frac1[1] = 1; frac1[2] = 2;
+ frac2[0] = ''; frac2[1] = 1; frac2[2] = 4;
+ assignQuestion(3,frac1,frac2,0,0);
+
+ frac1[0] = ''; frac1[1] =6; frac1[2] = 8;
+ frac2[0] = 3; frac2[1] = 1; frac2[2] = 6;
+ assignQuestion(4,frac1,frac2,0,0);
+
+ frac1[0] = ''; frac1[1] =4; frac1[2] = 8;
+ frac2[0] = ''; frac2[1] = 3; frac2[2] = 6;
+ assignQuestion(5,frac1,frac2,0,0);
+
+ frac1[0] = 4; frac1[1] =1; frac1[2] = 12;
+ frac2[0] = 2; frac2[1] = 9; frac2[2] =11;
+ assignQuestion(6,frac1,frac2,0,0);
+
+ frac1[0] = 2; frac1[1] =4; frac1[2] = 5;
+ frac2[0] = 3; frac2[1] = 2; frac2[2] =6;
+ assignQuestion(7,frac1,frac2,0,0);
+
+ frac1[0] = ''; frac1[1] =11; frac1[2] = 2;
+ frac2[0] = ''; frac2[1] = 7; frac2[2] =2;
+ assignQuestion(8,frac1,frac2,0,0);
+
+ frac1[0] = 12; frac1[1] =1; frac1[2] = 2;
+ frac2[0] = 2; frac2[1] = 2; frac2[2] =5;
+ assignQuestion(9,frac1,frac2,0,0);
+ }
+
+ else if(currentLesson === 0){
+ currentTopButton = 10;
+ currentLeftButton = 80;
+ $('#currentTitle').html('भिन्नलाई पूर्ण संख्याले गुणन गर्दा');
+ $('#content').append('<div id="imgWhole"></div>');
+ $('#imgWhole').append('<img class="float-left" src="assets/image/lesson1ImgPart1.png" />');
+ $('#imgWhole').append('<img id="lessonImgAnimate" src="assets/image/lesson1ImgPart2.png" />');
+ var lessonImgAnimate = {
+ 'position':'absolute',
+ 'top':'1.9em',
+ 'left': '6.2em'
+ };
+ $('#lessonImgAnimate').css(lessonImgAnimate);
+ $('#content').append('<img class="float-right" src="assets/image/lesson1ImgDef1.png" />');
+ imgAnimate('lessonImgAnimate',1.9,10,1000);
+ }
+ if(currentLesson === 1){
+ currentTopButton = 5;
+ currentLeftButton = 80;
+ $('#currentTitle').html('भिन्नलाई पूर्ण संख्याले गुणन गर्दा');
+ $('#content').append('<div id="imgWhole"></div>');
+ $('#imgWhole').append('<img class="float-left" src="assets/image/lesson2ImgPart1.png" />');
+ $('#imgWhole').append('<img id="lessonImgAnimate" src="assets/image/lesson2ImgPart2.png" />');
+ var lessonImgAnimate = {
+ 'position':'absolute',
+ 'top':'2.3em',
+ 'left': '7.4em'
+ };
+ $('#lessonImgAnimate').css(lessonImgAnimate);
+ $('#content').append('<div id="lesson2Div1"></div>');
+ $('#lesson2Div1').append('<img class="float-left" src="assets/image/lesson2ImgDef1.png" />');
+ imgAnimate('lessonImgAnimate',2.3,11,1000);
+ }
+ if(currentLesson === 2){
+ currentTopButton = 35;
+ currentLeftButton = 38;
+ showNextButton();
+ $('#currentTitle').html('भिन्नलाई भिन्नले गुणन गर्दा');
+ $('#content').append('<div id="imgRoti1"></div>');
+ $('#imgRoti1').append('<img class="float-left" src="assets/image/lesson3Img1.png" />');
+ $('#imgRoti1').append('<img id="lessonImgAnimate1" src="assets/image/lesson3ImgPart1.png" />');
+ var lessonImgAnimate = {
+ 'position':'absolute',
+ 'top':'15em',
+ 'left': '1.2em'
+ };
+ $('#lessonImgAnimate1').css(lessonImgAnimate);
+
+ $('#content').append('<div id="imgRoti2"></div>');
+ $('#imgRoti2').append('<img class="float-left" src="assets/image/lesson3Img2.png" />');
+ $('#imgRoti2').append('<img id="lessonImgAnimate2" src="assets/image/lesson3ImgPart2.png" />');
+ var lessonImgAnimate = {
+ 'position':'absolute',
+ 'top':'15.1em',
+ 'left': '6em'
+ };
+ $('#lessonImgAnimate2').css(lessonImgAnimate);
+ $('#imgRoti2').hide();
+ $('#content').append('<div id="imgRoti3"></div>');
+ $('#imgRoti3').append('<img class="float-left" src="assets/image/lesson3Img3.png" />');
+ $('#imgRoti3').hide();
+ showFractions();
+ }
+ if(currentLesson === 3){
+ currentTopButton = 20;
+ currentLeftButton = 38;
+ showNextButton();
+ $('#currentTitle').html('फरक हर / अंश भएको दुई भिन्न को गुणन ');
+ showPicture('divImgDef1','lesson4ImgDef1',0,-2);
+ showPicture('divImg1','lesson4Img1',0,70);
+ showFractions();
+ }
+ if(currentLesson === 5){
+ currentTopButton = 10;
+ currentLeftButton = 60;
+ showNextButton();
+ $('#currentTitle').html('तिमीले बुझ्नु पर्ने कुरा ');
+ showPicture('divImgDef1','lesson6ImgDef1',0,-2);
+ showPicture('divImg1','lesson6Img1',15,70);
+ showFractions();
+
+ }
+
+ };
+ //function to display the text and fraction symbols inside a div
+ function showText(parentDiv,divName,topPos,leftPos,numText){ //flatTxt o for text 1 for image
+ var textCss = {
+ 'position':'absolute',
+ 'top':topPos+'em',
+ 'left':leftPos+'em',
+ 'font':'2em arial,verdana,geneva,helvetica'
+ };
+ $('#'+parentDiv).append('<div id="'+divName+'"></div>');
+ $('#'+divName).css(textCss).html(numText);
+ }
+
+ function makeAnimContainer(divName,topPos,leftPos,width,height,bgColor){
+ var fracAnimContainer = {
+ 'position':'absolute',
+ 'top': topPos+'em',
+ 'left': leftPos+'em',
+ 'width': width+'em',
+ 'height': height+'em',
+ 'background-color': '#'+bgColor
+ };
+ $('#content').append('<div id="'+divName+'"></div>');
+ $('#'+divName).css(fracAnimContainer);
+ }
+
+
+ //function that keeps the photos at a given place absolute position
+ function showPicture(divName,imgName,topPos,leftPos){
+ var imgCss = {
+ 'position':'absolute',
+ 'top':topPos+'em',
+ 'left':leftPos+'em',
+ };
+ $('#content').append('<div id="'+divName+'"></div>');
+ $('#'+divName).css(imgCss).html('<img src="assets/image/'+imgName+'.png" />');
+ }
+
+ function game(){
+ currentLesson = 0;
+ $('#linkNextLesson').show();
+ $('#linkPrevLesson').hide();
+
+ nextLesson();
+ }
+ $('#linkNextLesson').hide();
+ $('#linkShowAns').hide();
+ $('#linkCheckAns').hide();
+ $('#linkPrevLesson').hide();
+ $('#linkHelp').mouseover(function(){
+ $('#help').slideDown(2000);
+ })
+ .mouseout(function(){
+ $('#help').slideUp(2000);
+ });
+
+ function delayHideAns(){
+ document.delayForm.delayval.value = 1;
+ clearTimeout(t);
+ for(var i = 0;i<TOTAL_QUES;i++){
+ for(var j=0; j< 4; j++){
+ var k = j+1;
+ $('#inTxt'+k+''+i).val(currentAns[i*4+j]);
+ }
+ }
+ flag_busy = 0;
+ }
+ $('#linkShowAns').click(function(){
+ //alert($('#inTxt10').val());
+
+ //first store the current texboxes values
+ if(flag_busy === 0){
+ flag_busy = 1;
+ for(var i = 0;i<TOTAL_QUES;i++){
+ for(var j=0; j< 4; j++){
+ var k = j+1;
+ currentAns[4*i+j] = $('#inTxt'+k+''+i).val();
+ }
+ }
+
+ for(var i = 0;i<TOTAL_QUES;i++){
+ for(var j=0; j< 4; j++){
+ var k = j+1;
+ $('#inTxt'+k+''+i).val(answers[i*4+j]);
+ }
+ }
+ t=setTimeout(function(){delayHideAns();},5000); //after 5 seconds goes to the same status as user had put input
+ }
+ });
+ $('#linkCheckAns').click(function(){
+ if(flag_busy === 0){
+ for(var i = 0;i<TOTAL_QUES;i++){
+ for(var j=0; j< 4; j++){
+ var k = j+1;
+ currentAns[4*i+j] = $('#inTxt'+k+''+i).val();
+ }
+ }
+ var correctCounter = 0;
+ scoreboard.scoreboard('reset');
+ scoreboard.scoreboard('incTotal',10);
+ for(var i = 0;i<TOTAL_QUES;i++){
+ var checkCount = 0;
+ if(currentAns[4*i+0] == answers[4*i+0] && currentAns[4*i+1] == answers[4*i+1]){
+ $('#symChecked1'+i).html('<img src="assets/image/correct.png" />');
+ checkCount++;
+ }
+ else{
+ $('#symChecked1'+i).html('<img src="assets/image/incorrect.png" />');
+ }
+ if(currentAns[4*i+2] == answers[4*i+2] && currentAns[4*i+3] == answers[4*i+3]){
+ $('#symChecked2'+i).html('<img src="assets/image/correct.png" />');
+ checkCount++;
+ }
+ else{
+ $('#symChecked2'+i).html('<img src="assets/image/incorrect.png" />');
+ }
+ if(checkCount == 2){
+ scoreboard.scoreboard('inc');
+ correctCounter++;
+ if(correctCounter === 10){
+ $('#content').addClass('backOpaque');
+ $('#gameOver').show().html('Great Job !!!');
+ }
+ }
+ }
+ }
+
+ });
+
+
+ //function to be rearranged later
+ function showNextButton(){
+ $('#content').append('<div class="nextBtn"></div>');
+ $('.nextBtn').show();
+ var nextbtncss = {
+ 'top': currentTopButton+'em',
+ 'left': currentLeftButton+'em'
+ };
+
+ $('.nextBtn').css(nextbtncss);//html('<img src="assets/image/nextBtn.png"/>');
+
+ }
+ function hideNextButton(){
+ $('.nextBtn').hide();
+ }
+
+ function showLesson1ImgFraction(){
+ $('#content').append('<div id="lesson1ImgFraction" class="lessonImgFrac"></div>');
+ $('#lesson1ImgFraction').append('<img src="assets/image/lesson1ImgFractions.png" />');
+ $('#content').append('<div id="lesson1ImgFractionRight"></div>');
+ $('#lesson1ImgFractionRight').append('<img src="assets/image/img1FractionTotal.png" />');
+ $('#lesson1ImgFractionRight').hide();
+ assignLessonImages(0,8.8,6.8,3);
+ assignLessonImages(1,8.5,24.4,2);
+ assignLessonImages(2,8.7,44,1);
+ assignLessonImages(3,8.7,44,1);
+ imgAnimateNoNxtBtn('lessonImg0',8.8,58,2000);
+ imgAnimateNoNxtBtn('lessonImg1',8.8,65,2000);
+ imgAnimateNoNxtBtn('lessonImg2',6,65,2000);
+ imgAnimateNoNxtBtn('lessonImg3',10,65,2000);
+ }
+
+ function imgAnimateNoNxtBtn(divName,topPos,leftPos,duration){
+ $('#'+divName).animate(
+ {top:topPos+'em',left:leftPos+'em'},duration,
+ function(ev){
+ if(divName == 'lessonImg3'){
+ for(i = 0;i<4;i++){
+ $('#lessonImg'+i).hide();
+ }
+ $('#lesson1ImgFractionRight').show();
+ showNextButton();
+ $('.nextBtn').click(function(){
+ $('#content').append('<img src="assets/image/lesson1ImgDef2.png" />');
+ $('.nextBtn').hide();
+ });
+ }
+
+ });
+
+ }
+
+ function assignLessonImages(imgId,topPos,leftPos,zIndex){
+ if(imgId === 3){
+ $('#lesson1ImgFraction').append('<img id="lessonImg'+imgId+'" src="assets/image/lesson1ImgDown.png" />');
+
+ }
+ else{
+ $('#lesson1ImgFraction').append('<img id="lessonImg'+imgId+'" src="assets/image/lesson1ImgPart2.png" />');
+ }
+ var lessonImgAnimate = {
+ 'position':'absolute',
+ 'top':topPos+'em',
+ 'left':leftPos+'em',
+ 'z-index':zIndex
+ };
+ $('#lessonImg'+imgId).css(lessonImgAnimate);
+
+ }
+
+ function delayCutNext(){
+ document.delayForm.delayval.value = 1;
+ if(cutCounter === 0){
+ showText('divAnim3','textCutSym1',2.9,7.5,'/');
+ }
+ else if(cutCounter === 1){
+ showText('divAnim3','textCutSym2',3.3,8.1,1);
+ }
+ else if(cutCounter === 2){
+ showText('divAnim3','textCutSym3',1.2,10.2,'/');
+ }
+ else if(cutCounter === 3){
+ showText('divAnim3','textCutSym4',.6,10.6,2);
+ }
+ else if(cutCounter === 4){
+ showText('divAnim3','textCutSym5',2.9,10.2,'/');
+ }
+ else if(cutCounter === 5){
+ showText('divAnim3','textCutSym6',3.3,10.6,1);
+ }
+ else if(cutCounter === 6){
+ showText('divAnim3','textCutSym7',1.2,7.5,'/');
+ }
+ else if(cutCounter === 7){
+ showText('divAnim3','textCutSym8',.6,8.1,7);
+ }
+ else if(cutCounter === 8){
+ showText('divAnim3','textSym19',2,12,'=');
+
+ }
+ else if(cutCounter === 9){
+ showText('divAnim3','textSym20',2,13,14);
+ }
+ clearTimeout(t);
+ cutCounter++;
+ startCuttingProcess();
+
+ }
+
+ function startCuttingProcess(){
+ t=setTimeout(function(){delayCutNext();},500);
+ }
+
+ function imgAnimate(divName,topPos,leftPos,duration){
+ $('#'+divName).animate(
+ {top:topPos+'em',left:leftPos+'em'},duration,
+ function(ev){ //callback function after the animation is complete
+ //alert('animation complete');
+ if(currentLesson === 3){
+ if(animCount === 0){
+ showText('divAnim1','textSym1',.4,4.8,'x');
+ imgAnimate('text3Anim',.5,5.5,1000);
+ }
+ else if(animCount === 1){
+ showText('divAnim1','textSym2',.4,3.5,'(');
+ showText('divAnim1','textSym3',.4,6.3,')');
+ showText('divAnim1','textSym4',.4,6.8,'+');
+ imgAnimate('text2Anim',.5,7.4,1500);
+ }
+ else if(animCount === 2){
+ showText('divAnim1','textSym5',.6,3.3,'_________');
+ imgAnimate('text4Anim',1.7,5.4,1500);
+ }
+ else if(animCount === 3){
+ showText('divAnim1','text5Anim',1.7,5.4,4);
+ showText('divAnim1','textSym6',1,8.5,'=');
+ showText('divAnim1','textSym7',.5,9.7,21);
+ showText('divAnim1','text6',.55,9.6,'__');
+ imgAnimate('text5Anim',1.7,9.8,1500);
+
+ }
+ else if(animCount === 4){
+ showText('divAnim1','text2frac1',.5,9.7,21);
+ showText('divAnim1','text2frac2',.55,9.6,'__');
+ showText('divAnim1','text2frac3',1.7,9.8,4);
+
+ showFractions();
+ }
+ else if(animCount === 5){
+ showText('divAnim2','textSym8',.4,4.8,'x');
+ imgAnimate('text8Anim',.5,5.5,1000);
+ }
+ else if(animCount === 6){
+ showText('divAnim2','textSym9',.4,3.5,'(');
+ showText('divAnim2','textSym10',.4,6.3,')');
+ showText('divAnim2','textSym11',.4,6.8,'+');
+ imgAnimate('text7Anim',.5,7.7,1500);
+ }
+ else if(animCount === 7){
+ showText('divAnim2','textSym13',.6,3.3,'_________');
+ imgAnimate('text9Anim',1.7,5.4,1500);
+ }
+ else if(animCount === 8){
+ showText('divAnim2','text10Anim',1.7,5.4,3);
+ showText('divAnim2','textSym14',1,8.5,'=');
+ showText('divAnim2','textSym15',.5,9.7,8);
+ showText('divAnim2','text12',.55,9.6,'__');
+ imgAnimate('text10Anim',1.7,9.8,1500);
+
+ }
+ else if(animCount === 9){
+ showText('divAnim2','text4frac1',.5,9.7,8);
+ showText('divAnim2','text4frac2',.55,9.6,'__');
+ showText('divAnim2','text4frac3',1.7,9.8,3);
+ showFractions();
+ }
+ else if(animCount === 13){
+ hideNextButton();
+ showText('divAnim3','textSym16',2,2.3,'x');
+ imgAnimate('text3frac1',8,-12,1000);
+ imgAnimate('text3frac2',7.3,-11.25,1000);
+ imgAnimate('text3frac3',7.55,-11.3,1000);
+ imgAnimate('text3frac4',8.8,-11.25,1000);
+ }
+ else if(animCount === 17){
+ showText('divAnim3','textSym17',2,5,'=');
+ imgAnimate('text2frac1',7.3,20,1000);
+ imgAnimate('text2frac2',7.55,20,1000);
+ imgAnimate('text2frac3',8.8,20.3,1000);
+ }
+ else if(animCount === 20){
+ showText('divAnim3','textSym18',2,8.5,'X');
+ imgAnimate('text4frac1',7.3,-5,1000);
+ imgAnimate('text4frac2',7.55,-5.3,1000);
+ imgAnimate('text4frac3',8.8,-5,1000);
+
+ }
+ else if(animCount === 23){
+
+ cutCounter = 0;
+ startCuttingProcess();
+ }
+ animCount++;
+
+ }
+ else{
+ showNextButton();
+ if(currentLesson === 2){
+ if(clickCounter === 0){
+ clickCounter++;
+ $('#imgRoti2').show();
+ showFractions();
+ }
+ else if(clickCounter === 1){
+ clickCounter++;
+ $('#imgRoti3').show();
+ $('.nextBtn').hide();
+
+ }
+
+ }
+
+ else if(currentLesson === 1){
+ if(clickCounter ===0){
+ $('#imgWhole').append('<img id="lesson2frac1" src="assets/image/lesson2frac1.png">');
+ $('.nextBtn').click(function(){
+ $('#lesson2Div1').append('<img src="assets/image/lesson2frac2.png">');
+ clickCounter++;
+ showFractions();
+ });
+ }
+
+ }
+ else if(currentLesson === 0) {
+ $('#imgWhole').append('<img id="lesson1frac1" src="assets/image/lesson1frac1.png">');
+ $('.nextBtn').click(function(){
+ showLesson1ImgFraction();
+ $('.nextBtn').hide();
+ });
+ }
+ }
+ });
+
+ }
+
+ function showFractions(){
+ showNextButton();
+ $('.nextBtn').click(function(){
+ if(currentLesson === 3){
+ if(clickCounter === 0){
+ showPicture('divImg2','lesson4Img2',28,-2);
+ showPicture('divImgDef2','lesson4ImgDef2',4,-2);
+ clickCounter++;
+ showFractions();
+ }
+ else if(clickCounter === 1){
+ showPicture('divImgDef3','lesson4ImgDef3',8,-2);
+ clickCounter++;
+ showFractions();
+ }
+ else if(clickCounter === 2){
+ showPicture('divImg4','lesson4Img3',38,10);
+ clickCounter++;
+ showFractions();
+ }
+ else if(clickCounter === 3){
+ showPicture('divImgDef4','lesson4ImgDef4',12,15);
+ clickCounter++;
+ //hideNextButton();
+ }
+ else if(clickCounter === 4){ //next animation stuffs
+ //animation stuffs of fraction great work needs to be done
+ hideNextButton();
+ makeAnimContainer('divAnim1',18,4,25,7,'8977FE');
+ showText('divAnim1','text1',1,.5,5);
+ showText('divAnim1','text2',.3,1.25,1);
+ showText('divAnim1','text3',.55,1.3,'_');
+ showText('divAnim1','text4',1.8,1.25,4);
+ showText('divAnim1','text5',1,2.35,'=');
+
+ showText('divAnim1','text1Anim',1,.5,5);
+ showText('divAnim1','text2Anim',.3,1.25,1);
+ showText('divAnim1','text3Anim',1.8,1.25,4);
+ showText('divAnim1','text4Anim',1.8,1.25,4);
+ // for animating the fractin part
+ showText('divAnim1','text1frac1',1,.5,5);
+ showText('divAnim1','text1frac2',.3,1.25,1);
+ showText('divAnim1','text1frac3',.55,1.3,'_');
+ showText('divAnim1','text1frac4',1.8,1.25,4);
+
+ animCount = 0;
+ imgAnimate('text1Anim',.5,4,1000);
+ clickCounter++;
+
+
+ }
+ else if(clickCounter === 5){ //next animation stuffs
+ hideNextButton();
+ makeAnimContainer('divAnim2',18,60,25,7,'8977FE');
+
+
+ showText('divAnim2','text7',1,.5,2);
+ showText('divAnim2','text8',.3,1.25,2);
+ showText('divAnim2','text9',.55,1.3,'_');
+ showText('divAnim2','text10',1.8,1.25,3);
+ showText('divAnim2','text11',1,2.35,'=');
+
+ showText('divAnim2','text6Anim',1,.5,2);
+ showText('divAnim2','text7Anim',.3,1.25,2);
+ showText('divAnim2','text8Anim',1.8,1.25,3);
+ showText('divAnim2','text9Anim',1.8,1.25,3);
+ imgAnimate('text6Anim',.5,4,1000);
+
+ showText('divAnim2','text3frac1',1,.5,2);
+ showText('divAnim2','text3frac2',.3,1.25,2);
+ showText('divAnim2','text3frac3',.55,1.3,'_');
+ showText('divAnim2','text3frac4',1.8,1.25,3);
+ clickCounter++;
+ }
+ else if(clickCounter === 6){
+ makeAnimContainer('divAnim3',30,30,30,8);
+ imgAnimate('text1frac1',8,13.5,1000);
+ imgAnimate('text1frac2',7.3,14.25,1000);
+ imgAnimate('text1frac3',7.55,14.3,1000);
+ imgAnimate('text1frac4',8.8,14.25,1000);
+
+ }
+
+ }
+
+
+ else if(currentLesson === 2){
+
+ if(clickCounter === 0){
+ imgAnimate('lessonImgAnimate1',15,32.8,1000);
+ }
+ else if(clickCounter === 1){
+ imgAnimate('lessonImgAnimate2',15.3,40,1000);
+ }
+
+
+ }
+ else if(currentLesson === 1){
+
+ if(clickCounter ===1){
+ $('#lesson2Div1').append('<img src="assets/image/lesson2frac3.png">');
+ clickCounter++;
+ showFractions();
+
+ }
+ else if(clickCounter ===2){
+ $('#content').append('<img class="float-center" src="assets/image/lesson2ImgDef2.png">');
+ clickCounter++;
+ showFractions();
+ }
+ else if(clickCounter ===3){
+ $('#content').append('<div id="lesson2ImgFraction" class="lessonImgFrac"></div>');
+ $('#lesson2ImgFraction').append('<img src="assets/image/lesson2ImgFractions.png" />');
+ clickCounter++;
+ showFractions();
+ }
+ else if(clickCounter ===4){
+ $('#content').append('<div id="lesson2ImgFractionRight"></div>');
+ $('#lesson2ImgFractionRight').append('<img src="assets/image/img2FractionTotal.png" />');
+ clickCounter++;
+ showFractions();
+ }
+ else if(clickCounter ===5){
+ $('#content').append('<img class="float-left" src="assets/image/lesson2ImgDef3.png" />');
+ clickCounter++;
+ showFractions();
+ }
+ else if(clickCounter ===6){
+ $('#content').append('<img class="float-right" src="assets/image/lesson2ImgDef4.png" />');
+ clickCounter++;
+ $('.nextBtn').hide();
+ }
+
+ }
+ else if(currentLesson === 5){
+ if(clickCounter === 0){
+ showPicture('divImgDef2','lesson6ImgDef2',11,-2);
+ }
+ else if(clickCounter === 1){
+ showPicture('divImgDef3','lesson6ImgDef3',20,-2);
+ }
+ else if(clickCounter === 2){
+ showPicture('divImgDef4','lesson6ImgDef4',27,-2);
+ }
+ else if(clickCounter === 3){
+ showPicture('divImgDef5','lesson6ImgDef5',33,-2);
+ hideNextButton();
+ }
+ clickCounter++;
+ }
+ });
+ }
+
+
+ function foucs_blur(){
+ $('input[type="text"]')
+ .focus(function() {
+ $(this).addClass("focus");
+ })
+ .blur(function() {
+ $(this).removeClass("focus");
+ })
+ }
+
+ $('#linkNextLesson').click(function(){
+ currentLesson++;
+ if(currentLesson === 5){
+ $('#linkNextLesson').hide();
+ $('#linkPrevLesson').show();
+ }
+ else{
+ $('#linkNextLesson').show();
+ $('#linkPrevLesson').show();
+ }
+
+ nextLesson();
+ });
+ $('#linkPrevLesson').click(function(){
+ currentLesson--;
+ if(currentLesson === 0){
+ $('#linkPrevLesson').hide();
+ }
+ else{
+ $('#linkNextLesson').show();
+ $('#linkPrevLesson').show();
+ }
+
+ nextLesson();
+ });
+
+
+ $('#linkStart').click(function(){
+ game();
+ });
+
+ $('#linkPlayAgain').click(function(){
+ nextLesson();
+ });
+
+
+
+
+ }); //end of k.ready
+}); //end of document.read
+
+
diff --git a/examples/lessons/6_Maths_multiplyingFractions/js/ui.core.js b/examples/lessons/6_Maths_multiplyingFractions/js/ui.core.js
new file mode 100755
index 0000000..5493e0a
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/js/ui.core.js
@@ -0,0 +1,519 @@
+/*
+ * jQuery UI 1.7.2
+ *
+ * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * http://docs.jquery.com/UI
+ */
+;jQuery.ui || (function($) {
+
+var _remove = $.fn.remove,
+ isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9);
+
+//Helper functions and ui object
+$.ui = {
+ version: "1.7.2",
+
+ // $.ui.plugin is deprecated. Use the proxy pattern instead.
+ plugin: {
+ add: function(module, option, set) {
+ var proto = $.ui[module].prototype;
+ for(var i in set) {
+ proto.plugins[i] = proto.plugins[i] || [];
+ proto.plugins[i].push([option, set[i]]);
+ }
+ },
+ call: function(instance, name, args) {
+ var set = instance.plugins[name];
+ if(!set || !instance.element[0].parentNode) { return; }
+
+ for (var i = 0; i < set.length; i++) {
+ if (instance.options[set[i][0]]) {
+ set[i][1].apply(instance.element, args);
+ }
+ }
+ }
+ },
+
+ contains: function(a, b) {
+ return document.compareDocumentPosition
+ ? a.compareDocumentPosition(b) & 16
+ : a !== b && a.contains(b);
+ },
+
+ hasScroll: function(el, a) {
+
+ //If overflow is hidden, the element might have extra content, but the user wants to hide it
+ if ($(el).css('overflow') == 'hidden') { return false; }
+
+ var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop',
+ has = false;
+
+ if (el[scroll] > 0) { return true; }
+
+ // TODO: determine which cases actually cause this to happen
+ // if the element doesn't have the scroll set, see if it's possible to
+ // set the scroll
+ el[scroll] = 1;
+ has = (el[scroll] > 0);
+ el[scroll] = 0;
+ return has;
+ },
+
+ isOverAxis: function(x, reference, size) {
+ //Determines when x coordinate is over "b" element axis
+ return (x > reference) && (x < (reference + size));
+ },
+
+ isOver: function(y, x, top, left, height, width) {
+ //Determines when x, y coordinates is over "b" element
+ return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width);
+ },
+
+ keyCode: {
+ BACKSPACE: 8,
+ CAPS_LOCK: 20,
+ COMMA: 188,
+ CONTROL: 17,
+ DELETE: 46,
+ DOWN: 40,
+ END: 35,
+ ENTER: 13,
+ ESCAPE: 27,
+ HOME: 36,
+ INSERT: 45,
+ LEFT: 37,
+ NUMPAD_ADD: 107,
+ NUMPAD_DECIMAL: 110,
+ NUMPAD_DIVIDE: 111,
+ NUMPAD_ENTER: 108,
+ NUMPAD_MULTIPLY: 106,
+ NUMPAD_SUBTRACT: 109,
+ PAGE_DOWN: 34,
+ PAGE_UP: 33,
+ PERIOD: 190,
+ RIGHT: 39,
+ SHIFT: 16,
+ SPACE: 32,
+ TAB: 9,
+ UP: 38
+ }
+};
+
+// WAI-ARIA normalization
+if (isFF2) {
+ var attr = $.attr,
+ removeAttr = $.fn.removeAttr,
+ ariaNS = "http://www.w3.org/2005/07/aaa",
+ ariaState = /^aria-/,
+ ariaRole = /^wairole:/;
+
+ $.attr = function(elem, name, value) {
+ var set = value !== undefined;
+
+ return (name == 'role'
+ ? (set
+ ? attr.call(this, elem, name, "wairole:" + value)
+ : (attr.apply(this, arguments) || "").replace(ariaRole, ""))
+ : (ariaState.test(name)
+ ? (set
+ ? elem.setAttributeNS(ariaNS,
+ name.replace(ariaState, "aaa:"), value)
+ : attr.call(this, elem, name.replace(ariaState, "aaa:")))
+ : attr.apply(this, arguments)));
+ };
+
+ $.fn.removeAttr = function(name) {
+ return (ariaState.test(name)
+ ? this.each(function() {
+ this.removeAttributeNS(ariaNS, name.replace(ariaState, ""));
+ }) : removeAttr.call(this, name));
+ };
+}
+
+//jQuery plugins
+$.fn.extend({
+ remove: function() {
+ // Safari has a native remove event which actually removes DOM elements,
+ // so we have to use triggerHandler instead of trigger (#3037).
+ $("*", this).add(this).each(function() {
+ $(this).triggerHandler("remove");
+ });
+ return _remove.apply(this, arguments );
+ },
+
+ enableSelection: function() {
+ return this
+ .attr('unselectable', 'off')
+ .css('MozUserSelect', '')
+ .unbind('selectstart.ui');
+ },
+
+ disableSelection: function() {
+ return this
+ .attr('unselectable', 'on')
+ .css('MozUserSelect', 'none')
+ .bind('selectstart.ui', function() { return false; });
+ },
+
+ scrollParent: function() {
+ var scrollParent;
+ if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
+ scrollParent = this.parents().filter(function() {
+ return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
+ }).eq(0);
+ } else {
+ scrollParent = this.parents().filter(function() {
+ return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
+ }).eq(0);
+ }
+
+ return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
+ }
+});
+
+
+//Additional selectors
+$.extend($.expr[':'], {
+ data: function(elem, i, match) {
+ return !!$.data(elem, match[3]);
+ },
+
+ focusable: function(element) {
+ var nodeName = element.nodeName.toLowerCase(),
+ tabIndex = $.attr(element, 'tabindex');
+ return (/input|select|textarea|button|object/.test(nodeName)
+ ? !element.disabled
+ : 'a' == nodeName || 'area' == nodeName
+ ? element.href || !isNaN(tabIndex)
+ : !isNaN(tabIndex))
+ // the element and all of its ancestors must be visible
+ // the browser may report that the area is hidden
+ && !$(element)['area' == nodeName ? 'parents' : 'closest'](':hidden').length;
+ },
+
+ tabbable: function(element) {
+ var tabIndex = $.attr(element, 'tabindex');
+ return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(':focusable');
+ }
+});
+
+
+// $.widget is a factory to create jQuery plugins
+// taking some boilerplate code out of the plugin code
+function getter(namespace, plugin, method, args) {
+ function getMethods(type) {
+ var methods = $[namespace][plugin][type] || [];
+ return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods);
+ }
+
+ var methods = getMethods('getter');
+ if (args.length == 1 && typeof args[0] == 'string') {
+ methods = methods.concat(getMethods('getterSetter'));
+ }
+ return ($.inArray(method, methods) != -1);
+}
+
+$.widget = function(name, prototype) {
+ var namespace = name.split(".")[0];
+ name = name.split(".")[1];
+
+ // create plugin method
+ $.fn[name] = function(options) {
+ var isMethodCall = (typeof options == 'string'),
+ args = Array.prototype.slice.call(arguments, 1);
+
+ // prevent calls to internal methods
+ if (isMethodCall && options.substring(0, 1) == '_') {
+ return this;
+ }
+
+ // handle getter methods
+ if (isMethodCall && getter(namespace, name, options, args)) {
+ var instance = $.data(this[0], name);
+ return (instance ? instance[options].apply(instance, args)
+ : undefined);
+ }
+
+ // handle initialization and non-getter methods
+ return this.each(function() {
+ var instance = $.data(this, name);
+
+ // constructor
+ (!instance && !isMethodCall &&
+ $.data(this, name, new $[namespace][name](this, options))._init());
+
+ // method call
+ (instance && isMethodCall && $.isFunction(instance[options]) &&
+ instance[options].apply(instance, args));
+ });
+ };
+
+ // create widget constructor
+ $[namespace] = $[namespace] || {};
+ $[namespace][name] = function(element, options) {
+ var self = this;
+
+ this.namespace = namespace;
+ this.widgetName = name;
+ this.widgetEventPrefix = $[namespace][name].eventPrefix || name;
+ this.widgetBaseClass = namespace + '-' + name;
+
+ this.options = $.extend({},
+ $.widget.defaults,
+ $[namespace][name].defaults,
+ $.metadata && $.metadata.get(element)[name],
+ options);
+
+ this.element = $(element)
+ .bind('setData.' + name, function(event, key, value) {
+ if (event.target == element) {
+ return self._setData(key, value);
+ }
+ })
+ .bind('getData.' + name, function(event, key) {
+ if (event.target == element) {
+ return self._getData(key);
+ }
+ })
+ .bind('remove', function() {
+ return self.destroy();
+ });
+ };
+
+ // add widget prototype
+ $[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype);
+
+ // TODO: merge getter and getterSetter properties from widget prototype
+ // and plugin prototype
+ $[namespace][name].getterSetter = 'option';
+};
+
+$.widget.prototype = {
+ _init: function() {},
+ destroy: function() {
+ this.element.removeData(this.widgetName)
+ .removeClass(this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled')
+ .removeAttr('aria-disabled');
+ },
+
+ option: function(key, value) {
+ var options = key,
+ self = this;
+
+ if (typeof key == "string") {
+ if (value === undefined) {
+ return this._getData(key);
+ }
+ options = {};
+ options[key] = value;
+ }
+
+ $.each(options, function(key, value) {
+ self._setData(key, value);
+ });
+ },
+ _getData: function(key) {
+ return this.options[key];
+ },
+ _setData: function(key, value) {
+ this.options[key] = value;
+
+ if (key == 'disabled') {
+ this.element
+ [value ? 'addClass' : 'removeClass'](
+ this.widgetBaseClass + '-disabled' + ' ' +
+ this.namespace + '-state-disabled')
+ .attr("aria-disabled", value);
+ }
+ },
+
+ enable: function() {
+ this._setData('disabled', false);
+ },
+ disable: function() {
+ this._setData('disabled', true);
+ },
+
+ _trigger: function(type, event, data) {
+ var callback = this.options[type],
+ eventName = (type == this.widgetEventPrefix
+ ? type : this.widgetEventPrefix + type);
+
+ event = $.Event(event);
+ event.type = eventName;
+
+ // copy original event properties over to the new event
+ // this would happen if we could call $.event.fix instead of $.Event
+ // but we don't have a way to force an event to be fixed multiple times
+ if (event.originalEvent) {
+ for (var i = $.event.props.length, prop; i;) {
+ prop = $.event.props[--i];
+ event[prop] = event.originalEvent[prop];
+ }
+ }
+
+ this.element.trigger(event, data);
+
+ return !($.isFunction(callback) && callback.call(this.element[0], event, data) === false
+ || event.isDefaultPrevented());
+ }
+};
+
+$.widget.defaults = {
+ disabled: false
+};
+
+
+/** Mouse Interaction Plugin **/
+
+$.ui.mouse = {
+ _mouseInit: function() {
+ var self = this;
+
+ this.element
+ .bind('mousedown.'+this.widgetName, function(event) {
+ return self._mouseDown(event);
+ })
+ .bind('click.'+this.widgetName, function(event) {
+ if(self._preventClickEvent) {
+ self._preventClickEvent = false;
+ event.stopImmediatePropagation();
+ return false;
+ }
+ });
+
+ // Prevent text selection in IE
+ if ($.browser.msie) {
+ this._mouseUnselectable = this.element.attr('unselectable');
+ this.element.attr('unselectable', 'on');
+ }
+
+ this.started = false;
+ },
+
+ // TODO: make sure destroying one instance of mouse doesn't mess with
+ // other instances of mouse
+ _mouseDestroy: function() {
+ this.element.unbind('.'+this.widgetName);
+
+ // Restore text selection in IE
+ ($.browser.msie
+ && this.element.attr('unselectable', this._mouseUnselectable));
+ },
+
+ _mouseDown: function(event) {
+ // don't let more than one widget handle mouseStart
+ // TODO: figure out why we have to use originalEvent
+ event.originalEvent = event.originalEvent || {};
+ if (event.originalEvent.mouseHandled) { return; }
+
+ // we may have missed mouseup (out of window)
+ (this._mouseStarted && this._mouseUp(event));
+
+ this._mouseDownEvent = event;
+
+ var self = this,
+ btnIsLeft = (event.which == 1),
+ elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false);
+ if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
+ return true;
+ }
+
+ this.mouseDelayMet = !this.options.delay;
+ if (!this.mouseDelayMet) {
+ this._mouseDelayTimer = setTimeout(function() {
+ self.mouseDelayMet = true;
+ }, this.options.delay);
+ }
+
+ if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+ this._mouseStarted = (this._mouseStart(event) !== false);
+ if (!this._mouseStarted) {
+ event.preventDefault();
+ return true;
+ }
+ }
+
+ // these delegates are required to keep context
+ this._mouseMoveDelegate = function(event) {
+ return self._mouseMove(event);
+ };
+ this._mouseUpDelegate = function(event) {
+ return self._mouseUp(event);
+ };
+ $(document)
+ .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
+ .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
+
+ // preventDefault() is used to prevent the selection of text here -
+ // however, in Safari, this causes select boxes not to be selectable
+ // anymore, so this fix is needed
+ ($.browser.safari || event.preventDefault());
+
+ event.originalEvent.mouseHandled = true;
+ return true;
+ },
+
+ _mouseMove: function(event) {
+ // IE mouseup check - mouseup happened when mouse was out of window
+ if ($.browser.msie && !event.button) {
+ return this._mouseUp(event);
+ }
+
+ if (this._mouseStarted) {
+ this._mouseDrag(event);
+ return event.preventDefault();
+ }
+
+ if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+ this._mouseStarted =
+ (this._mouseStart(this._mouseDownEvent, event) !== false);
+ (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
+ }
+
+ return !this._mouseStarted;
+ },
+
+ _mouseUp: function(event) {
+ $(document)
+ .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
+ .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
+
+ if (this._mouseStarted) {
+ this._mouseStarted = false;
+ this._preventClickEvent = (event.target == this._mouseDownEvent.target);
+ this._mouseStop(event);
+ }
+
+ return false;
+ },
+
+ _mouseDistanceMet: function(event) {
+ return (Math.max(
+ Math.abs(this._mouseDownEvent.pageX - event.pageX),
+ Math.abs(this._mouseDownEvent.pageY - event.pageY)
+ ) >= this.options.distance
+ );
+ },
+
+ _mouseDelayMet: function(event) {
+ return this.mouseDelayMet;
+ },
+
+ // These are placeholder methods, to be overriden by extending plugin
+ _mouseStart: function(event) {},
+ _mouseDrag: function(event) {},
+ _mouseStop: function(event) {},
+ _mouseCapture: function(event) { return true; }
+};
+
+$.ui.mouse.defaults = {
+ cancel: null,
+ distance: 1,
+ delay: 0
+};
+
+})(jQuery);
diff --git a/examples/lessons/6_Maths_multiplyingFractions/js/ui.scoreboard.js b/examples/lessons/6_Maths_multiplyingFractions/js/ui.scoreboard.js
new file mode 100755
index 0000000..53a930a
--- /dev/null
+++ b/examples/lessons/6_Maths_multiplyingFractions/js/ui.scoreboard.js
@@ -0,0 +1,107 @@
+(function($){
+ $.widget('ui.scoreboard',
+ {
+ getScore : function(){
+ return this._getData('score');
+ },
+ setScore : function(newScore){
+ this._setData('score', parseInt(newScore));
+ this._refresh();
+ },
+ getTotal : function(){
+ return this._getData('total');
+ },
+ setTotal : function(newTotal){
+ this._setData('total', parseInt(newTotal));
+ this._refresh();
+ },
+ reset : function(){
+ this._setData('score', this._getData('initialScore'));
+ this._setData('total', this._getData('initialTotal'));
+ this._refresh();
+ },
+ inc : function(val){
+ var incVal = parseInt(val) || 1;
+ this._setData('score', this._getData('score') + incVal);
+ this._refresh();
+ if(this._getData('winScore') === this._getData('score')){
+ this.element.trigger('winGame');
+ }
+ },
+ incTotal : function(val){
+ var incVal = parseInt(val) || 1;
+ this._setData('total', this._getData('total') + incVal);
+ this._refresh();
+ },
+ dec : function(val){
+ var decVal = parseInt(val) || 1;
+ this._setData('score', this._getData('score') - decVal);
+ this._refresh();
+ },
+ decTotal : function(val){
+ var decVal = parseInt(val) || 1;
+ this._setData('total', this._getData('total') - decVal);
+ this._refresh();
+ },
+ _init : function(){
+
+ var divDisplay = "inline";
+ var score = this.options.score;
+ var total = this.options.total;
+ var layoutId = "h";
+ var self = this;
+
+
+ this._setData('initialScore', parseInt(this.options.score));
+ this._setData('initialTotal', parseInt(this.options.total));
+ this._setData('score', parseInt(this.options.score));
+ this._setData('total', parseInt(this.options.total));
+ this._setData('winScore', parseInt(this.options.winningScore) || 0);
+
+ if(this.options.layout === "vertical"){
+ layoutId = "v";
+ }
+
+ this.evWinGame = document.createEvent('Events');
+
+ this.element.addClass('ui-scoreboard-container-' + layoutId +
+ ' ui-widget ui-widget-content ui-corner-all');
+
+ var clone = $('<div>')
+ .addClass('ui-scoreboard-spacing-' + layoutId);
+ this._scoreText = $("<div>Score</div>")
+ .addClass('ui-scoreboard-spacing-'+ layoutId +
+ ' ui-corner-all ui-scoreboard-text')
+ .appendTo(this.element);
+ this._score = $("<div>" + score + "</div>")
+ .addClass('ui-scoreboard-spacing-' + layoutId +
+ ' ui-scoreboard-number-' + layoutId)
+ .appendTo(this.element);
+ $("<div>Total</div>")
+ .addClass('ui-scoreboard-spacing-' + layoutId +
+ ' ui-corner-all ' +
+ 'ui-scoreboard-text')
+ .appendTo(this.element);
+ this._total = $("<div>" + total + "</div>")
+ .addClass('ui-scoreboard-spacing-' + layoutId +
+ ' ui-scoreboard-number-' + layoutId)
+ .appendTo(this.element);
+ },
+ _refresh : function(){
+ this._score.text(this._getData('score'));
+ this._total.text(this._getData('total'));
+ },
+ destroy : function(){
+ this.element.remove();
+ $.widget.prototype.destroy.apply(this, arguments);
+ }
+
+
+ });
+
+ $.ui.scoreboard.getter = ['getScore', 'getTotal'];
+ $.ui.scoreboard.defaults = {
+ score: 0, total: 0, layout: "horizontal", winningScore: 0
+ };
+
+ })(jQuery); \ No newline at end of file