// custom codes

var guide_max = 1010
var guide_sexy_max = 116
var guide_guy_max = 46

var g_first_msg =
  "Here's the list of all Deskop Ladies, sorted by different categories! "
+ "Currently there are " + guide_max + " gals in total~!"
var gm_first_msg =
  "Here's the list of all Deskop Guys, sorted by different categories! "
+ "Currently there are " + guide_guy_max + " guys in total~!"
var gs_first_msg =
  "Well, here are some sexy babies for your *strange* taste ^_^; Currently "
+ "there are " + guide_sexy_max + " sexy gals in total~!"

var dynamic_desktop_list = [
  "NEWS Report (Top Stories)", 'show_window(1, ["Here are the news headlines of the top stories~!", "News here will be updated frequently so come back often~!"])',
  "NEWS Report (Video Games)", 'show_window(2, ["Here are the news headlines about video games~!", "News here will be updated frequently so come back often~!"])',
  "Search the Web", 'show_window(4, ["Looking for something? Let me find it for you~!"])',
  "AnimeTheme.com Email", 'show_window(0, ["Get your own @animetheme.com email address for FREE! If you already have one, check your emails now~!"])',
  "Anime Theme Forums", 'autoRunMain(forums["Main"],event,this)',
//  "Special Features & Softwares", 'autoRunMain("cool/",event,this)',
  "Anime Theme Shop!", 'guide_says("Support Anime Theme! Buy something please~! ^_^"); draw_list("Anime Theme Shop",animetheme_shop_list)',
//  "VOTE for Anime Theme!", 'self.open("http://www.anime100.com/cgi-bin/rank/rankem.cgi?id=anitheme")',
  "Change Desktop Lady", 'guide_says(g_first_msg); draw_list("Guides List",g_list)',
  "Change Desktop Guy", 'guide_says(gm_first_msg); draw_list("Guy Guides List",gm_list)',
  "Change Desktop Lady (M)", 'if (confirmGS()) {guide_says(gs_first_msg); draw_list("Sexy Guides List",gs_list)}'
]

function XmasBG() {
  activate_guide('build_list("Christmas Background", [["Please choose a background image~!"],["Please choose a background image~!"],["See ya~!"]], choose_xmas_bg)')
}

if (season_special)
  dynamic_desktop_list = dynamic_desktop_list.concat(["Change X'mas Background", 'XmasBG()', "Change X'mas Lady", 'guideByClass("Christmas",false)'])

var search_amazon = 'show_window(3, ["Find your favorite products at Amazon.com~!"])'

var animetheme_shop_list = [
  "Anime and Manga", 'guide_says("Buy GREAT Anime stuff at a GREAT price! Shop at our partners~!"); draw_list("Anime Shop",anime_shop_list)',
  "Video Games / Others", 'guide_says("Buy ANYTHING you need online from our Amazon.com links! Support Anime Theme~!"); draw_list("Other Shop",other_shop_list)',
  "SEARCH for your favorites!", search_amazon
]

var anime_shop_list = [
  "Best Sellers!", 'self.open("http://store.yahoo.com/cgi-bin/clink?animenation+HePpWU+bestsellers.html")',
  "Customer Picks!", 'self.open("http://store.yahoo.com/cgi-bin/clink?animenation+HePpWU+ourpicks.html")',
  "Red Hot Deals!", 'self.open("http://store.yahoo.com/cgi-bin/clink?animenation+HePpWU+redhotdeals.html")',
  "SEARCH for your favorites!", search_amazon,
  "AnimeNation.com Home", 'self.open("http://store.yahoo.com/cgi-bin/clink?animenation+HePpWU+index.html")',
  "[Back]", 'draw_list("Anime Theme Shop",animetheme_shop_list)'
]

var other_shop_list = [
  "PlayStation 3", 'self.open("http://www.amazon.com/b?%5Fencoding=UTF8&node=14210751&tag=animetheme-20&linkCode=ur2&camp=1789&creative=9325")',
  "PlayStation 2", 'self.open("http://www.amazon.com/b?%5Fencoding=UTF8&node=301712&tag=animetheme-20&linkCode=ur2&camp=1789&creative=9325")',
  "Xbox360", 'self.open("http://www.amazon.com/b?%5Fencoding=UTF8&node=14220161&tag=animetheme-20&linkCode=ur2&camp=1789&creative=9325")',
  "Nintendo Wii", 'self.open("http://www.amazon.com/b?%5Fencoding=UTF8&node=14218901&tag=animetheme-20&linkCode=ur2&camp=1789&creative=9325")',
  "GameCube", 'self.open("http://www.amazon.com/exec/obidos/redirect?tag=animetheme-20&path=tg/browse/-/541022")',
  "PC Games", 'self.open("http://www.amazon.com/exec/obidos/redirect?tag=animetheme-20&path=tg/browse/-/229575")',

  "Sony PSP", 'self.open("http://www.amazon.com/b?%5Fencoding=UTF8&node=11075221&tag=animetheme-20&linkCode=ur2&camp=1789&creative=9325")',
  "Nintendo DS", 'self.open("http://www.amazon.com/b?%5Fencoding=UTF8&node=11075831&tag=animetheme-20&linkCode=ur2&camp=1789&creative=9325")',
  "GameBoy Advance", 'self.open("http://www.amazon.com/exec/obidos/redirect?tag=animetheme-20&path=tg/browse/-/541020")',

  "Top 100 Hot Books!", 'self.open("http://www.amazon.com/exec/obidos/redirect?tag=animetheme-20&path=subst/lists/best/amazon-bestsellers.html")',
  "Top 100 Hot CDs!", 'self.open("http://www.amazon.com/exec/obidos/redirect?tag=animetheme-20&path=subst/music/charts/hot-100-music.html")',
  "Top 100 Hot Videos!", 'self.open("http://www.amazon.com/exec/obidos/redirect?tag=animetheme-20&path=subst/video/sellers/amazon-top-100-video.html")',
  "Top 100 Hot DVDs!", 'self.open("http://www.amazon.com/exec/obidos/redirect?tag=animetheme-20&path=subst/video/sellers/amazon-top-100-dvd.html")',

  "SEARCH for your favorites!", search_amazon,
  "Amazon.com Home", 'self.open("http://www.amazon.com/exec/obidos/redirect-home/animetheme-20")',
  "[Back]", 'draw_list("Anime Theme Shop",animetheme_shop_list)'
]

var forum_email_list = [
  "Anime Theme Forums", 'autoRunMain(forums["Main"],event,this)',
//  "RPG-style Chatroom!<br>(Anime Theme World Online)", 'autoRunMain(forums["Forum Chat"],event,this)',
  "AnimeTheme.com Email<br>(Login / Signup)", 'show_window(0, ["Get your own @animetheme.com email address for FREE! If you already have one, check your emails now~!"])'
]

var g_list = [
//  "NEW gals (July 1, 2008)",'guideByClass("NEW gals (July 1, 2008)",false)',

  "From Anime",'draw_list("G Anime List",g_lists[0])',
  "From Games",'draw_list("G Games List",g_lists[1])',
  "By Costumes",'draw_list("G Costumes List",g_lists[2])',
  "By Careers",'draw_list("G Careers List",g_lists[3])',
  "Miscellaneous",'draw_list("G Miscellaneous List",g_lists[4])',

  "Best Collection",'guideByClass("Best Collection",false)',

  "Your Favorites (Guys & Gals)",'if (g_favorites.length) {guideByClass("Favorites",false)} else {alert("Your favorite guide list is empty.")}',
  "All Gals",'guideByClass("All gals",false)',
  "DOWNLOAD!", 'if (confirm("You are about to download all normal Desktop Ladies and Desktop Guys images (899 GIF images in total) as a single ZIP archive.\\n\\nPlease note that this is available to Anime Theme Premier members ONLY.")) self.open("http://www.animetheme.com/cgi-bin/ikonboard/download.cgi?src=atp_members/guides_normal.zip")'
]

var g_lists = []
g_lists[0] = [
  "Ah My Goddess","",
  "Akazukin Cha Cha","",
  "Bakuen Campus Guardress","",
  "Bastard","",
  "Battle Athletes","",
  "Card Captor Sakura","",
  "Chobits","",
  "Cowboy Bebop","",
  "Di Gi Charat","",
  "Dirty Pair","",
  "Futari Ni Omakase","",
  "G-taste","",
  "Galaxy Angel","",
  "Gundam SEED","",
  "Hand Maid May","",
  "History's Strongest Disciple Kenichi","",
  "Inu-Yasha","",
  "K-ON!","",
  "Kiddy Grade","",
  "Lost Universe","",
  "Love Hina","",
  "Macross","",
  "Mahoromatic","",
  "Mahou Sensei Negima","",
  "Maison Ikkoku","",
  "Masamune Shirow","",
  "Nadesico","",
  "Neon Genesis Evangelion","",
  "Please Teacher","",
  "Read or Die","",
  "Sailor Moon","",
  "Shakugan No Shana","",
  "Sister Princess","",
  "Slayers","",
  "Tenchi Muyo","",
  "The Melancholy of Haruhi Suzumiya","",
  "You are Under Arrest","",
  "Misc Anime / Manga","",

  "All Anime",""
]
g_lists[1] = [
  "Asgladh / Guren","",
  "Comics Party","",
  "Dead or Alive","",
  "Dragon Quest","",
  "Dynasty Warriors","",
  "Final Fantasy VII","",
  "Final Fantasy IX","",
  "Final Fantasy X/X-2","",
  "Final Fantasy XII","",
  "Guilty Gear","",
  "Kakyusei","",
  "Manga Carta","",
  "Parasite EVE","",
  "Princess Holiday","",
  "Ragnarok Online","",
  "Sakura Wars","",
  "Sentimental Graffiti","",
  "Shikigami No Shiro","",
  "SNK / CAPCOM","",
  "Studio e.go!","",
  "The War of Genesis","",
  "To Heart","",
  "Welcome to Pia Carrot","",
  "With You","",
  "Misc Game I","",
  "Misc Game II","",
  "Misc Game III","",
  "Misc Game IV","",
  "Misc Game V","",

  "All Games",""
]
g_lists[2] = [
  "Animal-like costume","",
  "Bra-top / Underwear","",
  "Bunny costume","",
  "Swimming suit",""
]
g_lists[3] = [
  "Maiden / Waitress","",
  "Nurse / Doctor","",
  "Office lady","",
  "Policewoman","",
  "Student",""
]
g_lists[4] = [
  "3D CG","",
  "Christmas","",
  "From Carnelian","",
  "From Murakami","",
  "From Tony Taka","",
  "Maid NoNo","",
  "OS Ladies","",
  "Tora","",
  "Uniform Gals Drawing Contest",""
]

for (var i = 0; i < g_lists.length; i++)
  for (var k = 1; k < g_lists[i].length; k += 2)
    g_lists[i][k] = 'guideByClass("'+g_lists[i][k-1]+'",false)'

var gm_list = [
//  "NEW guys (September 17, 2004)",'guideByClass("NEW guys (September 17, 2004) (Guys)",false)',
  "D.N.Angel",'guideByClass("D.N.Angel (Guys)",false)',
  "Guilty Gear",'guideByClass("Guilty Gear (Guys)",false)',
  "Final Fantasy IX",'guideByClass("FF9 (Guys)",false)',
  "Final Fantasy XII",'guideByClass("FF12 (Guys)",false)',
  "Fushigi Yuugi",'guideByClass("Fushigi Yuugi (Guys)",false)',
  "Inu-Yasha",'guideByClass("Inu-Yasha (Guys)",false)',
  "Shikigami No Shiro",'guideByClass("Shikigami No Shiro (Guys)",false)',
  "SNK",'guideByClass("SNK (Guys)",false)',
  "Suikoden",'guideByClass("Suikoden (Guys)",false)',
  "Trigun",'guideByClass("Trigun (Guys)",false)',
  "Miscellaneous",'guideByClass("Misc (Guys)",false)',
  "Your Favorites (Guys & Gals)",'if (g_favorites.length) {guideByClass("Favorites",false)} else {alert("Your favorite guide list is empty.")}',
  "All Guys",'guideByClass("All guides (Guys)",false)'
]

var gs_list = [
//  "NEW Gals (January 15, 2007)",'guideByClass("NEW gals (January 15, 2007)",true)',
//  "NEW Gals (January 7, 2006)",'guideByClass("NEW gals (January 7, 2006)",true)',
  "By Careers",'draw_list("GS Careers List",gs_lists[2])',
  "By Costumes",'draw_list("GS Costumes List",gs_lists[1])',
  "From Asgladh / Guren",'guideByClass("From Asgladh / Guren",true)',
  "From Dead or Alive",'guideByClass("From Dead or Alive",true)',
  "From G-taste",'draw_list("GS G-taste List",gs_lists[0])',
  "From SNK",'guideByClass("From SNK",true)',
  "From Other Anime / Game",'guideByClass("From Other Anime / Game",true)',

  "Best Collection",'guideByClass("Best Collection",true)',

  "Your Favorites",'if (gs_favorites.length) {guideByClass("Favorites",true)} else {alert("Your favorite (M-rated) gal list is empty.")}',
//  "All Gals",'guideByClass("All gals",true)',
  "Animated Gals!",'autoRunMain("gallery/ani/",event,this)',
  "DOWNLOAD!", 'if (confirm("You are about to download all SEXY Desktop Ladies images (103 GIF images in total) as a single ZIP archive.\\n\\nPlease note that this is available to Anime Theme Premier members ONLY.")) self.open("http://www.animetheme.com/cgi-bin/ikonboard/download.cgi?src=atp_members/guides_sexy.zip")'
]

var gs_lists = []
gs_lists[0] = [
//  "Black and white","",
  "Color","",
  "Futari Ni Omakase","",
  "All G-taste",""
]
gs_lists[1] = [
  "Bra-top / Underwear","",
  "Bunny costume","",
  "Half-naked","",
  "Swimming suit",""
]
gs_lists[2] = [
  "Maiden / Waitress","",
  "Nurse","",
  "Office lady","",
  "Student",""
]

for (var i = 0; i < gs_lists.length; i++)
  for (var k = 1; k < gs_lists[i].length; k += 2)
    gs_lists[i][k] = 'guideByClass("'+gs_lists[i][k-1]+'",true)'

var g_class = []

g_class["Ah My Goddess"] = [283,749]
g_class["Akazukin Cha Cha"] = [223]
g_class["Bakuen Campus Guardress"] = [241]
g_class["Bastard"] = ["907-908"]
g_class["Battle Athletes"] = ["331-332","336-337",570]
g_class["Card Captor Sakura"] = ["96-104",147,338]
g_class["Chobits"] = [640]
g_class["Cowboy Bebop"] = [329]
g_class["Di Gi Charat"] = [144,"287-294",342,376,"461-462","571-573","614-615","655-657",748,816]
g_class["Dirty Pair"] = [261]
g_class["Futari Ni Omakase"] = [89,"91-95",245,467]
g_class["G-taste"] = ["51-54",88,90,"108-112","195-210",246,378,389,"468-502"]
g_class["Galaxy Angel"] = [405,"712-713"]
g_class["Gundam SEED"] = [801]
g_class["Hand Maid May"] = [341,460,567,789]
g_class["History's Strongest Disciple Kenichi"] = [950]
g_class["Inu-Yasha"] = ["552-558"]
g_class["K-ON!"] = ["1006-1009"]
g_class["Kiddy Grade"] = [790,968]
g_class["Lost Universe"] = ["441-443",788]
g_class["Love Hina"] = ["295-306","324-328","526-527",767,854]
g_class["Macross"] = [887]
g_class["Mahoromatic"] = ["646-648"]
g_class["Mahou Sensei Negima"] = ["979-1004"]
g_class["Maison Ikkoku"] = ["559-563"]
g_class["Masamune Shirow"] = ["548-551"]
g_class["Nadesico"] = [340,345]
g_class["Neon Genesis Evangelion"] = ["43-50","309-319",377,"387-388",417,911]
g_class["Please Teacher"] = [751]
g_class["Read or Die"] = [723,775]
g_class["Sailor Moon"] = [16,214,219,222]
g_class["Shakugan No Shana"] = [967]
g_class["Sister Princess"] = [791]
g_class["Slayers"] = [226]
g_class["Tenchi Muyo"] = ["187-188"]
g_class["The Melancholy of Haruhi Suzumiya"] = [898-905,"952-966","973-978"]
g_class["You are Under Arrest"] = [174,218]
g_class["Misc Anime / Manga"] = [671]

g_class["All Anime"] = []
for (var i = 0; i < g_lists[0].length/2-2; i++)
  g_class["All Anime"][i] = g_lists[0][2*i]

g_class["Asgladh / Guren"] = ["3-15","17-24","59-77","168-173","520-521"]
g_class["Comics Party"] = ["784-787"]
g_class["Dead or Alive"] = [41,157,159,"160-161",243,"247-249","575-577","669-670","685-689"]
g_class["Dragon Quest"] = [888]
g_class["Dynasty Warriors"] = ["798"]
g_class["Final Fantasy VII"] = [156,186,"280-281","284-285",465]
g_class["Final Fantasy IX"] = ["154-155"]
g_class["Final Fantasy X/X-2"] = [447,503,"537-542"]
g_class["Final Fantasy XII"] = ["970-972"]
g_class["Guilty Gear"] = [639,"682-684"]
g_class["Kakyusei"] = ["35-36",105,"151-152"]
g_class["Manga Carta"] = ["856-873"]
g_class["Parasite EVE"] = [282]
g_class["Princess Holiday"] = ["605-610"]
g_class["Ragnarok Online"] = [569,"753-757",799]
g_class["Sakura Wars"] = [39,215,"768-772",934,951]
g_class["Sentimental Graffiti"] = [415,418,"421-422",430,"432-433","944-949"]
g_class["Shikigami No Shiro"] = ["564-565","611-613"]
g_class["SNK / CAPCOM"] = [40,55,"80-81","137-138","142",189,"212-213",221,"253-254","269-270",307,"320-323","524-525",574,"626-638",653,"846-847",920]
g_class["The War of Genesis"] = ["881-885"]
g_class["Studio e.go!"] = ["181-184",251,"396-397",399,410,412,436,456,"796-797"]
g_class["To Heart"] = [38,139,148,150,"776-777"]
g_class["Welcome to Pia Carrot"] = ["0-2","26-34",429,"844-845"]
g_class["With You"] = ["56-58"]
g_class["Misc Game I"] = ["589-596"]
g_class["Misc Game II"] = ["543-547","658-663"]
g_class["Misc Game III"] = ["356-373"]
g_class["Misc Game IV"] = ["779-783","921-923"]
g_class["Misc Game V"] = ["840-843"]

g_class["All Games"] = []
for (var i = 0; i < g_lists[1].length/2-2; i++)
  g_class["All Games"][i] = g_lists[1][2*i]

g_class["Animal-like costume"] = [4,10,12,19,"21-24",65,72,74,"125-132",147,149,168,179,192,213,"231-232",236,255,262,267,"278-279","322-323",333,343,375,404,420,466,491,"524-525","528-529","532-533",598,"627-628","633-635",643,"753-756","817-820","828-832",917,933,937,"Di Gi Charat","Tora"]
g_class["Bra-top / Underwear"] = ["10-11",42,79,105,156,159,164,167,172,"175-176",178,185,"190-191",241,245,"247-249","263-264",328,348,363,365,369,"372-373","387-388","390-391",415,418,"421-422",430,432,505,514,"520-521",536,"539-540","594-595",598,824,"890-891",910,918,939,980]
g_class["Bunny costume"] = [18,146,210,214,219,273,330,348,417,431,"477-478","487-488",498,876,895,951]
g_class["Swimming suit"] = [56,58,110,158,162,194,246,266,271,279,304,345,374,464,494,562,"581-582",589,659,685,"704-707",752,"767-768",823,827,853,877,905,"913-914",923,956,979,982,984,986,"988-1004"]

g_class["Maiden / Waitress"] = ["0-2","26-28","32-34",38,"51-52","106-107",112,"117-118",129,131,143,145,"183-184",197,216,"224-225",238,240,252,355,381,389,404,429,"479-482",499,"530-531",534,"543-547",651,667,"695-703",730,"740-745",750,"792-795","825-826",874,880,890,916,927,932,"Hand Maid May","Maid NoNo","Mahoromatic"]
g_class["Nurse / Doctor"] = ["108-109",209,408,411,463,"468-469","518-519",587,649,"734-735"]
g_class["Office lady"] = [30,"53-54",198,"200-201","203-204","206-208",475,"485-486",497]
g_class["Policewoman"] = ["You are Under Arrest","Futari Ni Omakase"]
g_class["Student"] = ["35-37",42,78,"97-99",101,104,"123-124",133,"135-136",139,148,150,152,163,177,250,275,"299-300",305,309,315,"317-318",324,327,331,336,337,339,347,"359-360",362,364,366,371,377,379,"387-388","390-391",400,413,"423-428",440,455,"489-490",492,495,501,535,"552-553",556,577,588,630,733,"771-784","831-837",889,891,896,"898-904",911,920,922,936,"944-949","952-953",955,"958-960",962,964,966,977]

g_class["3D CG"] = ["581-587"]
g_class["Christmas"] = ["186-187",287,297,326,392,578,"708-711","854-855","967-969","1005-1006"]
g_class["From Carnelian"] = [354,"522-523","602-604",645,668,848]
g_class["From Murakami"] = ["740-747","821-826","874-875","913-916"]
g_class["From Tony Taka"] = [569, "836-839",886,890,"892-895",1005]
g_class["Maid NoNo"] = ["84-87","121-122",217,230]
g_class["OS Ladies"] = ["672-681","690-705"]
g_class["Tora"] = ["724-739"]
g_class["Uniform Gals Drawing Contest"] = [158,"162-167"]

g_class["Best Collection"] = ["0-7","9-11","14-16","18-20",24,"26-28",32,"34-37",42,"51-55",59,61,"64-66",72,85,"89-90","92-95",98,"102-103",105,"107-108",121,140,152,164,170,172,"176-177",179,192,195,"198-200",203,"208-210",212,214,"245-246",262,264,267,"274-275",279,"284-286",305,307,312,"316-318",328,331,342,344,"366-367",379,"387-388",398,415,"417-418","420-422",431,"441-443",445,"460-461",467,"471-472","485-486","489-501",503,"518-520","525-532",537,"539-540","542-545",547,549,"552-554",566,569,573,575,"577-580",588,"598-610",614,"619-622","624-625",639,"642-661","667-671","683-685",694,"697-698",703,"705-706","708-710","712-715",721,"723-727",730,"733-735",737,"743-747","750-752",754,"757-758",760,"762-764","767-772",775,"777-784","788-791",800,814,"816-817",819,"824-828","835-838",840,845,"846-848","856-873",876,"878-880","885-887","889-895","898-904","906-918","921-923","930-933","938-940",942,"944-1009"]

//g_class["NEW gals (July 1, 2008)"] = ["973-1004"]

g_class["All gals"] = []

// Guys

g_class["D.N.Angel (Guys)"] = ["4-5!"]
g_class["Guilty Gear (Guys)"] = ["37-43!"]
g_class["FF9 (Guys)"] = ["22-25!"]
g_class["FF12 (Guys)"] = ["44-46!"]
g_class["Fushigi Yuugi (Guys)"] = ["2-3!"]
g_class["Inu-Yasha (Guys)"] = ["26-32!"]
g_class["Shikigami No Shiro (Guys)"] = ["33-36!"]
g_class["SNK (Guys)"] = [-1]
g_class["Suikoden (Guys)"] = ["6-16!"]
g_class["Trigun (Guys)"] = ["17-19!"]
g_class["Misc (Guys)"] = ["20-21!"]

//g_class["NEW guys (September 17, 2004) (Guys)"] = ["37-43!"]

g_class["All guides (Guys)"] = ["1-"+guide_guy_max+"!"]

// Sexy gals

//g_class["S Black and white"] = ["12-21","32-33",40]
g_class["S Color"] = ["2-6","8-11","22-24",26,"34-35","37-39",42,"59-61","65-80",113]
g_class["S Futari Ni Omakase"] = ["0-1",25,36]
g_class["S All G-taste"] = []
for (var i = 0; i < gs_lists[0].length/2-1; i++)
  g_class["S All G-taste"][i] = "S " + gs_lists[0][2*i]

g_class["S Bra-top / Underwear"] = [1,3,5,7,12,24,31,"34-35",41,51,55,"70-72",76,81,95,109,114]
g_class["S Bunny costume"] = [2,"9-10",12,61,73,93]
g_class["S Half-naked"] = ["7-8","28-30","44-50","52-54",56,58,64,75,82,84,102,114]
g_class["S Swimming suit"] = [0,"74-75","79-80"]

g_class["S Maiden / Waitress"] = [4,6,11,"22-23",38,40,63,"71-72",96,"103-104"]
g_class["S Nurse"] = [3,24,65,77,90]
g_class["S Office lady"] = [13,16,17,37,39,"59-60","67-69",78]
g_class["S Student"] = [27,56,83,89,100,106,"110-112"]

g_class["S From Asgladh / Guren"] = ["27-31","43-54"]
g_class["S From Dead or Alive"] = [81,87]
g_class["S From SNK"] = [85]
g_class["S From Other Anime / Game"] = [88,91,"97-99"]

g_class["S Best Collection"] = ["0-1","3-9",11,"22-24",30,"34-36","38-39","41-44",46,"49-50",52,"54-58","60-62","64-115"]

//g_class["S NEW gals (January 15, 2007)"] = [11,"38-39","103-115"]
//g_class["S NEW gals (January 7, 2006)"] = ["97-102"]

//g_class["S All gals"] = []

function guideByClass(str, isSexy) {
  str = str.replace(/\&apos;/g, "'")

  if (isSexy)
    str = "S " + str
  if (!g_class[str]) {
    guide_says("Sorry, not available yet... >_<")
    return
  }

  guide_string = (/All gals/.test(str)) ? "" : str
  if (next_guide(isSexy))
    leave_main_menu([((isSexy) ? "Hmmm... your taste is a little bit... ^_^;" : "A new Desktop Guide is coming. See you next time~!")])
}

function desktop_services() {
  activate_guide('build_list("Main Menu", [["How can I help? I will do what I can~!"], ["Please choose your desired service~!","New comer? Get your @animetheme.com email address for FREE~!","Please visit our sponsors during your stay in Anime Theme~!","Anime Theme is the BEST~!"], ["See ya~!"]], dynamic_desktop_list)')
}

function forum_email() {
  activate_guide('build_list("Forums Email Menu", [["New comer? Get a FREE @animetheme.com email address! Check out our forums too~!"], ["Please choose your desired service~!","New comer? Get your own @animetheme.com email address for FREE~!","Please visit our sponsors during your stay in Anime Theme~!","Anime Theme is the BEST~!"], ["See ya~!"]], forum_email_list)')
}

// Desktop Lady bookmarks

var g_favorites = []
var gs_favorites = []
var g_fav_flags, gm_fav_flags, gs_fav_flags
var g_fav_save_name = "g_all_fav_v2"

var dc = []
var dc_index = []
dc_index["g_fav"] = 0
dc_index["gm_fav"] = 1
dc_index["gs_fav"] = 2


// remove old version cookies

var dc_old_names = ["g_favorites", "gm_favorites", "gs_favorites"]
var dc_old_existed

// v0
for (var i = 0; i < dc_old_names.length; i++) {
  var n = dc_old_names[i]
  var v = cookie_get(n)

  dc[i] = v

  if (v) {
    cookie_set(n + "=x", -1)

    dc_old_existed = true
  }
}

// v1
if (!dc_old_existed) {
  dc = cookie_get("g_all_fav_v1")
  if (dc) {
    dc = dc.split("|")
    cookie_set("g_all_fav_v1=x", -1)

    dc_old_existed = true
  }
}

// update to v2

if (!dc_old_existed)
  dc = null
else {
  g_fav_cookie("g_fav", dc[0])
  g_fav_cookie("gm_fav", dc[1])
  g_fav_cookie("gs_fav", dc[2])
  cookie_set(g_fav_save_name + "=" + dc.join("|"), 365)

  defaultStatus = "Cookies updated (v2)"
}

// done


// load and process deskop guide cookies

if (!dc)
  dc = cookie_get(g_fav_save_name).split("|")

var g_fav_max = [guide_max, guide_guy_max, guide_sexy_max]

for (var i = 0; i < 3; i++) {
  var flags = new Array(g_fav_max[i])

  var n = dc_old_names[i]
  self[n.replace(/orites/, "_flags")] = flags

  var v = dc[i]
  if (!v)
    continue

  v = v.replace(/\{(\d+)\}/, function (m0, m1) { m1 = parseInt(m1); var str = ""; for (var z = 0; z < m1; z++) { str += "0" }; return str } )

  var g_fav = (i == 2) ? gs_favorites : g_favorites
  for (var k = 0; k < v.length; k++) {
    var c = parseInt(v.charAt(k))
    flags[k] = c
    if (c)
      g_fav[g_fav.length] = (i == 1) ? -(k+1) : k
  }
}

// done


g_class["Favorites"] = []
g_class["S Favorites"] = []
guide_arrays["Favorites"] = g_favorites
guide_arrays["S Favorites"] = gs_favorites

var gf_max = g_favorites.length
var gsf_max = gs_favorites.length
var ggf_max = gf_max + gsf_max

var fav_chance = 0.25 + ggf_max/20 * 0.5
if (fav_chance > 0.75)
  fav_chance = 0.75

if (ggf_max && (Math.random() < fav_chance)) {
  if (Math.ceil(Math.random() * ggf_max) > gf_max) {
    g_prefix = "gs"
    guide_string = "S Favorites"
  }
  else {
    g_prefix = "g"
    guide_string = "Favorites"
  }
}
else {
  g_prefix = "g"
  guide_string = "Best Collection"

  guideArray(guide_string)
}

function g_fav_mark(type) {
  Lguide_menu.style.visibility = "hidden"

  var mark, msg
  msg = '\n\nGuides on your list will have a higher chance to appear at startup.\n\n'

  if ((type == 1) || (type == 0)) {
    if (type == 1)
      msg = 'By marking this guide, you add him/her to your favorite guide list.' + msg + 'Press OK to mark this guide.'
    else
      msg = 'By unmarking this guide, you remove him/her from your favorite guide list.' + msg + 'Press OK to unmark this guide.'
    if (!confirm(msg))
      return

    mark = type
    marked_flags = [gf_num]
  }
  else if (guide_string) {
    if (!confirm('By marking the guide group that you have selected ('+guide_string+'), you put ALL guides from this group to your favorite guide list.'+msg+'Press OK to mark ALL guides from this group.'))
      return

    gf_prefix = (/^S /.test(guide_string)) ? "gs" : "g"
    mark = 1
    marked_flags = guide_arrays[guide_string]
  }
  else
    return

  var g_ext = (marked_flags[0] < 0) ? "m" : ""
  var flags = self[gf_prefix + g_ext + "_fav_flags"]
  var favs = self[gf_prefix + "_favorites"]

  for (var i = 0; i < marked_flags.length; i++) {
    var f = marked_flags[i]
    if (!!flags[f] == !!mark)
      continue

    flags[((f < 0) ? Math.abs(f)-1 : f)] = mark
    if (mark == 1)
      favs[favs.length] = f
    else {
      for (var k = 0; k < favs.length; k++)
        if (favs[k] == f)
          favs = favs.slice(0,k).concat(favs.slice(k+1))
      self[gf_prefix + "_favorites"] = favs
      guide_arrays[((gf_prefix=="g") ? "" : "S ") + "Favorites"] = favs
    }
  }

  g_fav_cookie(gf_prefix + g_ext + "_fav", flags.toString())
  cookie_set(g_fav_save_name + "=" + dc.join("|"), 365)

  g_fav_report()
}

function g_fav_clear() {
  Lguide_menu.style.visibility = "hidden"

  if (!confirm('This will CLEAR your favorite guide list!'))
    return

  g_fav_flags = new Array(guide_max)
  gm_fav_flags = new Array(guide_guy_max)
  gs_fav_flags = new Array(guide_sexy_max)
  g_favorites = []
  gs_favorites = []
  guide_arrays["Favorites"] = g_favorites
  guide_arrays["S Favorites"] = gs_favorites

  g_fav_cookie("g_fav")
  g_fav_cookie("gm_fav")
  g_fav_cookie("gs_fav")
  cookie_set(g_fav_save_name + "=x", -1)

  g_fav_report()
}

function g_fav_report() {
  if (navigator.cookieEnabled)
    alert("Your favorite guide list has been updated successfully!\n\n("+g_favorites.length+" normal guide(s), "+gs_favorites.length+" M-rated guide(s))")
  else
    alert("ERROR: The cookie function on your browser has been disabled. You need to enable it to save the Deskop Guide settings.")
}

function g_fav_cookie(name, value) {
  if (value) {
    value = (value) ? value.replace(/^\,/, "0,").replace(/\,$/, ",0").replace(/\,\,/g, ",0,").replace(/\,\,/g, ",0,") : ""

    value = value.replace(/\,/g, "")
    value = value.replace(/0+$/, "")
    value = value.replace(/(0{5,})/g, function (m0, m1) { return "{" + m1.length + "}" })
  }
  else
    value = ""

  dc[dc_index[name]] = value

  return value
}

function psp_rss() {
  alert(
  '  Anime Theme is proud to present you our RSS Channel for PlayStation Portable (PSP)! You can download Anime and game wallpapers, musics and videos to your PSP!\n\n'
+ '  To subscribe, open "Internet Browser" on your PSP and type in the following address.\n\n\n'
+ '          http://www.animetheme.com/cgi-bin/rss.cgi\n\n\n'
+ '  PSP Firmware 2.80 is required.'
  )
}

